@pyreon/zero 0.11.9 → 0.12.0

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 (82) hide show
  1. package/lib/font.js +20 -7
  2. package/lib/font.js.map +1 -1
  3. package/lib/image-plugin.js.map +1 -1
  4. package/lib/index.js +21 -7
  5. package/lib/index.js.map +1 -1
  6. package/lib/link.js +1 -0
  7. package/lib/link.js.map +1 -1
  8. package/lib/types/actions.d.ts +57 -0
  9. package/lib/types/actions.d.ts.map +1 -0
  10. package/lib/types/adapters/bun.d.ts +6 -0
  11. package/lib/types/adapters/bun.d.ts.map +1 -0
  12. package/lib/types/adapters/index.d.ts +10 -0
  13. package/lib/types/adapters/index.d.ts.map +1 -0
  14. package/lib/types/adapters/node.d.ts +6 -0
  15. package/lib/types/adapters/node.d.ts.map +1 -0
  16. package/lib/types/adapters/static.d.ts +7 -0
  17. package/lib/types/adapters/static.d.ts.map +1 -0
  18. package/lib/types/api-routes.d.ts +66 -0
  19. package/lib/types/api-routes.d.ts.map +1 -0
  20. package/lib/types/app.d.ts +24 -0
  21. package/lib/types/app.d.ts.map +1 -0
  22. package/lib/types/cache.d.ts +54 -0
  23. package/lib/types/cache.d.ts.map +1 -0
  24. package/lib/types/client.d.ts +19 -0
  25. package/lib/types/client.d.ts.map +1 -0
  26. package/lib/types/compression.d.ts +33 -0
  27. package/lib/types/compression.d.ts.map +1 -0
  28. package/lib/types/config.d.ts +18 -0
  29. package/lib/types/config.d.ts.map +1 -0
  30. package/lib/types/cors.d.ts +32 -0
  31. package/lib/types/cors.d.ts.map +1 -0
  32. package/lib/types/entry-server.d.ts +37 -0
  33. package/lib/types/entry-server.d.ts.map +1 -0
  34. package/lib/types/error-overlay.d.ts +6 -0
  35. package/lib/types/error-overlay.d.ts.map +1 -0
  36. package/lib/types/favicon.d.ts +43 -0
  37. package/lib/types/favicon.d.ts.map +1 -0
  38. package/lib/types/font.d.ts +119 -0
  39. package/lib/types/font.d.ts.map +1 -0
  40. package/lib/types/fs-router.d.ts +47 -0
  41. package/lib/types/fs-router.d.ts.map +1 -0
  42. package/lib/types/i18n-routing.d.ts +98 -0
  43. package/lib/types/i18n-routing.d.ts.map +1 -0
  44. package/lib/types/image-plugin.d.ts +79 -0
  45. package/lib/types/image-plugin.d.ts.map +1 -0
  46. package/lib/types/image.d.ts +51 -0
  47. package/lib/types/image.d.ts.map +1 -0
  48. package/lib/types/index.d.ts +46 -0
  49. package/lib/types/index.d.ts.map +1 -0
  50. package/lib/types/isr.d.ts +9 -0
  51. package/lib/types/isr.d.ts.map +1 -0
  52. package/lib/types/link.d.ts +127 -0
  53. package/lib/types/link.d.ts.map +1 -0
  54. package/lib/types/meta.d.ts +91 -0
  55. package/lib/types/meta.d.ts.map +1 -0
  56. package/lib/types/middleware.d.ts +35 -0
  57. package/lib/types/middleware.d.ts.map +1 -0
  58. package/lib/types/not-found.d.ts +7 -0
  59. package/lib/types/not-found.d.ts.map +1 -0
  60. package/lib/types/rate-limit.d.ts +34 -0
  61. package/lib/types/rate-limit.d.ts.map +1 -0
  62. package/lib/types/script.d.ts +35 -0
  63. package/lib/types/script.d.ts.map +1 -0
  64. package/lib/types/seo.d.ts +88 -0
  65. package/lib/types/seo.d.ts.map +1 -0
  66. package/lib/types/testing.d.ts +85 -0
  67. package/lib/types/testing.d.ts.map +1 -0
  68. package/lib/types/theme.d.ts +39 -0
  69. package/lib/types/theme.d.ts.map +1 -0
  70. package/lib/types/types.d.ts +111 -0
  71. package/lib/types/types.d.ts.map +1 -0
  72. package/lib/types/utils/use-intersection-observer.d.ts +10 -0
  73. package/lib/types/utils/use-intersection-observer.d.ts.map +1 -0
  74. package/lib/types/utils/with-headers.d.ts +6 -0
  75. package/lib/types/utils/with-headers.d.ts.map +1 -0
  76. package/lib/types/vite-plugin.d.ts +17 -0
  77. package/lib/types/vite-plugin.d.ts.map +1 -0
  78. package/package.json +10 -10
  79. package/src/favicon.ts +2 -2
  80. package/src/font.ts +32 -8
  81. package/src/image-plugin.ts +1 -1
  82. package/src/link.tsx +7 -0
@@ -0,0 +1,119 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface FontConfig {
3
+ /**
4
+ * Google Fonts families.
5
+ *
6
+ * Accepts both string shorthand and structured objects:
7
+ * - String: "Inter:wght@400;500;700" or "Inter:wght@100..900"
8
+ * - Object: { family: "Inter", weights: [400, 500, 700] }
9
+ * - Variable: { family: "Inter", variable: true, weightRange: [100, 900] }
10
+ */
11
+ google?: GoogleFontInput[];
12
+ /** Local font files. */
13
+ local?: LocalFont[];
14
+ /** Default font-display strategy. Default: "swap" */
15
+ display?: FontDisplay;
16
+ /** Preload critical fonts. Default: true */
17
+ preload?: boolean;
18
+ /** Self-host Google Fonts at build time. Default: true */
19
+ selfHost?: boolean;
20
+ /** Fallback font metrics for reducing CLS. */
21
+ fallbacks?: Record<string, FallbackMetrics>;
22
+ }
23
+ /** Static Google Font config. */
24
+ export interface GoogleFontStatic {
25
+ family: string;
26
+ weights: number[];
27
+ italic?: boolean;
28
+ variable?: false;
29
+ }
30
+ /** Variable Google Font config. */
31
+ export interface GoogleFontVariable {
32
+ family: string;
33
+ /** Weight range as [min, max] tuple. e.g. [100, 900] */
34
+ weightRange: [number, number];
35
+ italic?: boolean;
36
+ variable: true;
37
+ }
38
+ /** Google font input: structured object or string shorthand. */
39
+ export type GoogleFontInput = GoogleFontStatic | GoogleFontVariable | string;
40
+ export interface LocalFont {
41
+ family: string;
42
+ src: string;
43
+ /** Single weight (400) or variable range ("100 900"). */
44
+ weight?: number | `${number} ${number}`;
45
+ style?: 'normal' | 'italic';
46
+ display?: FontDisplay;
47
+ }
48
+ export type FontDisplay = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
49
+ /** Metrics for generating size-adjusted fallback fonts to reduce CLS. */
50
+ export interface FallbackMetrics {
51
+ /** The fallback font to adjust. e.g. "Arial", "Georgia" */
52
+ fallback: string;
53
+ /** Size adjustment factor. e.g. 1.05 */
54
+ sizeAdjust?: number;
55
+ /** Ascent override percentage. e.g. 90 */
56
+ ascentOverride?: number;
57
+ /** Descent override percentage. e.g. 22 */
58
+ descentOverride?: number;
59
+ /** Line gap override percentage. e.g. 0 */
60
+ lineGapOverride?: number;
61
+ }
62
+ interface ResolvedFontBase {
63
+ family: string;
64
+ italic: boolean;
65
+ }
66
+ interface StaticFont extends ResolvedFontBase {
67
+ variable: false;
68
+ weights: number[];
69
+ }
70
+ interface VariableFont extends ResolvedFontBase {
71
+ variable: true;
72
+ weightRange: [number, number];
73
+ }
74
+ type ResolvedFont = StaticFont | VariableFont;
75
+ /**
76
+ * Normalize a GoogleFontInput (string or object) into a ResolvedFont.
77
+ */
78
+ export declare function resolveGoogleFont(input: GoogleFontInput): ResolvedFont;
79
+ /**
80
+ * Parse Google Fonts family string shorthand.
81
+ *
82
+ * Static weights: "Inter:wght@400;500;700"
83
+ * Variable range: "Inter:wght@100..900"
84
+ * Variable with italic: "Inter:ital,wght@100..900"
85
+ */
86
+ export declare function parseGoogleFamily(input: string): ResolvedFont;
87
+ /**
88
+ * Generate a Google Fonts CSS URL.
89
+ */
90
+ export declare function googleFontsUrl(families: ResolvedFont[], display?: FontDisplay): string;
91
+ /**
92
+ * Zero font optimization Vite plugin.
93
+ *
94
+ * Dev mode: injects Google Fonts CDN link for fast startup.
95
+ * Build mode: downloads and self-hosts fonts for maximum performance + privacy.
96
+ *
97
+ * @example
98
+ * import { fontPlugin } from "@pyreon/zero/font"
99
+ *
100
+ * export default {
101
+ * plugins: [
102
+ * pyreon(),
103
+ * zero(),
104
+ * fontPlugin({
105
+ * google: ["Inter:wght@400;500;600;700", "JetBrains Mono:wght@400"],
106
+ * fallbacks: {
107
+ * "Inter": { fallback: "Arial", sizeAdjust: 1.07, ascentOverride: 90 },
108
+ * },
109
+ * }),
110
+ * ],
111
+ * }
112
+ */
113
+ export declare function fontPlugin(config?: FontConfig): Plugin;
114
+ /**
115
+ * Generate CSS variables for font families.
116
+ */
117
+ export declare function fontVariables(families: Record<string, string>): string;
118
+ export {};
119
+ //# sourceMappingURL=font.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../src/font.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAYlC,MAAM,WAAW,UAAU;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;IAC1B,wBAAwB;IACxB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC5C;AAED,iCAAiC;AACjC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB;AAED,mCAAmC;AACnC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,IAAI,CAAA;CACf;AAED,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,MAAM,CAAA;AAE5E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAA;IAC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H,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAKtE"}
@@ -0,0 +1,47 @@
1
+ import type { FileRoute, RenderMode } from './types';
2
+ /**
3
+ * Parse a set of file paths (relative to routes dir) into FileRoute objects.
4
+ *
5
+ * @param files Array of file paths like ["index.tsx", "users/[id].tsx"]
6
+ * @param defaultMode Default rendering mode from config
7
+ */
8
+ export declare function parseFileRoutes(files: string[], defaultMode?: RenderMode): FileRoute[];
9
+ /**
10
+ * Convert a file path (without extension) to a URL path pattern.
11
+ *
12
+ * Examples:
13
+ * "index" → "/"
14
+ * "about" → "/about"
15
+ * "users/index" → "/users"
16
+ * "users/[id]" → "/users/:id"
17
+ * "blog/[...slug]" → "/blog/:slug*"
18
+ * "(auth)/login" → "/login" (group stripped)
19
+ * "_layout" → "/" (layout marker)
20
+ */
21
+ export declare function filePathToUrlPath(filePath: string): string;
22
+ /**
23
+ * Generate a virtual module that exports a nested route tree.
24
+ * Wires up layouts as parent routes with children, loaders, guards,
25
+ * error/loading components, middleware, and meta from route module exports.
26
+ */
27
+ export interface GenerateRouteModuleOptions {
28
+ /**
29
+ * When true, skip lazy() for route components and use static imports.
30
+ * Use for SSG/prerender mode where all routes are rendered at build time
31
+ * and code splitting provides no benefit. Avoids Rolldown warnings about
32
+ * static + dynamic imports of the same module.
33
+ */
34
+ staticImports?: boolean;
35
+ }
36
+ export declare function generateRouteModule(files: string[], routesDir: string, options?: GenerateRouteModuleOptions): string;
37
+ /**
38
+ * Generate a virtual module that maps URL patterns to their middleware exports.
39
+ * Used by the server entry to dispatch per-route middleware.
40
+ */
41
+ export declare function generateMiddlewareModule(files: string[], routesDir: string): string;
42
+ /**
43
+ * Scan a directory for route files.
44
+ * Returns paths relative to the routes directory.
45
+ */
46
+ export declare function scanRouteFiles(routesDir: string): Promise<string[]>;
47
+ //# sourceMappingURL=fs-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-router.d.ts","sourceRoot":"","sources":["../../src/fs-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAgCpD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,GAAE,UAAkB,GAAG,SAAS,EAAE,CAK7F;AA0CD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiC1D;AA6ED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,0BAA0B,GACnC,MAAM,CA0JR;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAqBnF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBzE"}
@@ -0,0 +1,98 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface I18nRoutingConfig {
3
+ /** Supported locales. e.g. ["en", "de", "cs"] */
4
+ locales: string[];
5
+ /** Default locale — served without prefix (/ instead of /en/). */
6
+ defaultLocale: string;
7
+ /** Redirect root to detected locale. Default: true */
8
+ detectLocale?: boolean;
9
+ /** Cookie name to persist locale preference. Default: "locale" */
10
+ cookieName?: string;
11
+ /** URL strategy. Default: "prefix-except-default" */
12
+ strategy?: 'prefix' | 'prefix-except-default';
13
+ }
14
+ export interface LocaleContext {
15
+ /** Current locale code. e.g. "en", "de" */
16
+ locale: string;
17
+ /** All supported locales. */
18
+ locales: string[];
19
+ /** Default locale. */
20
+ defaultLocale: string;
21
+ /** Build a localized path. e.g. localePath("/about", "de") → "/de/about" */
22
+ localePath: (path: string, locale?: string) => string;
23
+ /** Get hreflang alternates for the current path. */
24
+ alternates: () => Array<{
25
+ locale: string;
26
+ url: string;
27
+ }>;
28
+ }
29
+ /**
30
+ * Detect preferred locale from Accept-Language header.
31
+ */
32
+ export declare function detectLocaleFromHeader(acceptLanguage: string | null | undefined, locales: string[], defaultLocale: string): string;
33
+ /**
34
+ * Extract locale from a URL path.
35
+ * Returns { locale, pathWithoutLocale }.
36
+ */
37
+ export declare function extractLocaleFromPath(path: string, locales: string[], defaultLocale: string): {
38
+ locale: string;
39
+ pathWithoutLocale: string;
40
+ };
41
+ /**
42
+ * Build a localized path.
43
+ */
44
+ export declare function buildLocalePath(path: string, locale: string, defaultLocale: string, strategy: 'prefix' | 'prefix-except-default'): string;
45
+ /**
46
+ * Create a LocaleContext for use in components and loaders.
47
+ */
48
+ export declare function createLocaleContext(locale: string, path: string, config: I18nRoutingConfig): LocaleContext;
49
+ /**
50
+ * I18n routing middleware for Zero's server.
51
+ *
52
+ * - Detects locale from URL prefix or Accept-Language header
53
+ * - Redirects root to preferred locale (when detectLocale is true)
54
+ * - Sets locale context for loaders and components
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // zero.config.ts
59
+ * import { i18nRouting } from "@pyreon/zero"
60
+ *
61
+ * export default defineConfig({
62
+ * plugins: [
63
+ * i18nRouting({
64
+ * locales: ["en", "de", "cs"],
65
+ * defaultLocale: "en",
66
+ * }),
67
+ * ],
68
+ * })
69
+ * ```
70
+ */
71
+ export declare function i18nRouting(config: I18nRoutingConfig): Plugin;
72
+ /** @internal Context for the current locale. */
73
+ export declare const LocaleCtx: import("@pyreon/core").Context<string>;
74
+ /** Current locale signal — set by the server middleware or client-side detection. */
75
+ export declare const localeSignal: import("@pyreon/reactivity").Signal<string>;
76
+ /**
77
+ * Read the current locale reactively.
78
+ *
79
+ * Returns the locale signal value directly — reactive in both SSR and CSR.
80
+ * The server middleware sets `localeSignal` per-request, and client-side
81
+ * `setLocale()` updates it as well.
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * const locale = useLocale() // "en", "de", etc.
86
+ * ```
87
+ */
88
+ export declare function useLocale(): string;
89
+ /**
90
+ * Set the locale client-side and update the URL.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * <button onClick={() => setLocale('de')}>Deutsch</button>
95
+ * ```
96
+ */
97
+ export declare function setLocale(locale: string, config: I18nRoutingConfig): void;
98
+ //# sourceMappingURL=i18n-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-routing.d.ts","sourceRoot":"","sources":["../../src/i18n-routing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAelC,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,kEAAkE;IAClE,aAAa,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,QAAQ,GAAG,uBAAuB,CAAA;CAC9C;AAED,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,6BAA6B;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,sBAAsB;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,4EAA4E;IAC5E,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACrD,oDAAoD;IACpD,UAAU,EAAE,MAAM,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,OAAO,EAAE,MAAM,EAAE,EACjB,aAAa,EAAE,MAAM,GACpB,MAAM,CAoBR;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,aAAa,EAAE,MAAM,GACpB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAY/C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,QAAQ,GAAG,uBAAuB,GAC3C,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GACxB,aAAa,CA6Bf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CA4D7D;AAcD,gDAAgD;AAChD,eAAO,MAAM,SAAS,wCAA8B,CAAA;AAEpD,qFAAqF;AACrF,eAAO,MAAM,YAAY,6CAAe,CAAA;AAExC;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GACxB,IAAI,CAqBN"}
@@ -0,0 +1,79 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface ImagePluginConfig {
3
+ /** Output directory for processed images. Default: "assets/img" */
4
+ outDir?: string;
5
+ /** Default widths for responsive images. Default: [640, 1024, 1920] */
6
+ widths?: number[];
7
+ /** Output formats. Default: ["webp"] */
8
+ formats?: ImageFormat[];
9
+ /** Quality for lossy formats (1-100). Default: 80 */
10
+ quality?: number;
11
+ /** Blur placeholder size in px. Default: 16 */
12
+ placeholderSize?: number;
13
+ /** File patterns to process. Default: /\.(jpe?g|png|webp|avif)$/i */
14
+ include?: RegExp;
15
+ }
16
+ export type ImageFormat = 'webp' | 'avif' | 'jpeg' | 'png';
17
+ /** Per-format source set for <picture> <source> elements. */
18
+ export interface FormatSource {
19
+ /** MIME type. e.g. "image/webp", "image/avif" */
20
+ type: string;
21
+ /** srcset string for this format. e.g. "/img-640.webp 640w, /img-1920.webp 1920w" */
22
+ srcset: string;
23
+ }
24
+ export interface ProcessedImage {
25
+ /** Fallback source path (last format, largest width). */
26
+ src: string;
27
+ /** Fallback srcset string (last format). */
28
+ srcset: string;
29
+ /** Intrinsic width. */
30
+ width: number;
31
+ /** Intrinsic height. */
32
+ height: number;
33
+ /** Base64 blur placeholder data URI. */
34
+ placeholder: string;
35
+ /** Per-format source sets for <picture> element. Ordered by priority (best format first). */
36
+ formats: FormatSource[];
37
+ /** Flat list of all sources. */
38
+ sources: Array<{
39
+ src: string;
40
+ width: number;
41
+ format: string;
42
+ }>;
43
+ }
44
+ /**
45
+ * Zero image processing Vite plugin.
46
+ *
47
+ * Transforms image imports with query params into optimized responsive images:
48
+ *
49
+ * @example
50
+ * // vite.config.ts
51
+ * import { imagePlugin } from "@pyreon/zero/image-plugin"
52
+ *
53
+ * export default {
54
+ * plugins: [
55
+ * pyreon(),
56
+ * zero(),
57
+ * imagePlugin({ widths: [480, 960, 1440], quality: 85 }),
58
+ * ],
59
+ * }
60
+ *
61
+ * @example
62
+ * // In a component — import with ?optimize
63
+ * import hero from "./images/hero.jpg?optimize"
64
+ * // hero = { src, srcset, width, height, placeholder }
65
+ *
66
+ * <Image {...hero} alt="Hero" priority />
67
+ */
68
+ export declare function imagePlugin(config?: ImagePluginConfig): Plugin;
69
+ /** @internal Exported for testing */
70
+ export declare function parseJpegDimensions(buffer: Buffer): {
71
+ width: number;
72
+ height: number;
73
+ };
74
+ /** @internal Exported for testing */
75
+ export declare function parseWebPDimensions(buffer: Buffer): {
76
+ width: number;
77
+ height: number;
78
+ };
79
+ //# sourceMappingURL=image-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-plugin.d.ts","sourceRoot":"","sources":["../../src/image-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA4BlC,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,wCAAwC;IACxC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;IACvB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAA;AAE1D,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAA;IACX,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAA;IACnB,6FAA6F;IAC7F,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,gCAAgC;IAChC,OAAO,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC/D;AAID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,MAAM,GAAE,iBAAsB,GAAG,MAAM,CAwDlE;AAmKD,qCAAqC;AACrC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAeA;AAED,qCAAqC;AACrC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAuBA"}
@@ -0,0 +1,51 @@
1
+ import type { VNodeChild } from '@pyreon/core';
2
+ import type { FormatSource } from './image-plugin';
3
+ export interface ImageProps {
4
+ /** Image source URL. */
5
+ src: string;
6
+ /** Alt text (required for accessibility). */
7
+ alt: string;
8
+ /** Intrinsic width of the image. */
9
+ width: number;
10
+ /** Intrinsic height of the image. */
11
+ height: number;
12
+ /** Responsive sizes attribute. Default: "100vw" */
13
+ sizes?: string;
14
+ /** Responsive srcset string or source array. */
15
+ srcset?: string | ImageSource[];
16
+ /** Per-format source sets for <picture>. Provided automatically by imagePlugin. */
17
+ formats?: FormatSource[];
18
+ /** Loading strategy. "lazy" uses IntersectionObserver, "eager" loads immediately. Default: "lazy" */
19
+ loading?: 'lazy' | 'eager';
20
+ /** Mark as priority (LCP image). Disables lazy loading, adds fetchPriority="high". */
21
+ priority?: boolean;
22
+ /** Low-quality placeholder image URL or base64 data URI for blur-up effect. */
23
+ placeholder?: string;
24
+ /** CSS class name. */
25
+ class?: string;
26
+ /** Inline styles. */
27
+ style?: string;
28
+ /** CSS object-fit. Default: "cover" */
29
+ fit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
30
+ /** Decode async. Default: true */
31
+ decoding?: 'sync' | 'async' | 'auto';
32
+ }
33
+ export interface ImageSource {
34
+ src: string;
35
+ width: number;
36
+ }
37
+ /**
38
+ * Optimized image component with lazy loading, responsive images,
39
+ * multi-format <picture> support, and blur-up placeholders.
40
+ *
41
+ * @example
42
+ * // With imagePlugin — spread the import directly
43
+ * import hero from "./hero.jpg?optimize"
44
+ * <Image {...hero} alt="Hero" priority />
45
+ *
46
+ * @example
47
+ * // Manual usage
48
+ * <Image src="/hero.jpg" alt="Hero" width={1200} height={630} />
49
+ */
50
+ export declare function Image(props: ImageProps): VNodeChild;
51
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAalD,MAAM,WAAW,UAAU;IACzB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAA;IACX,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC/B,mFAAmF;IACnF,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAA;IAC1D,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;CACrC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAoGnD"}
@@ -0,0 +1,46 @@
1
+ export type { CreateAppOptions } from "./app";
2
+ export { createApp } from "./app";
3
+ export type { CreateServerOptions } from "./entry-server";
4
+ export { createServer } from "./entry-server";
5
+ export { zeroPlugin as default } from "./vite-plugin";
6
+ export type { GenerateRouteModuleOptions } from './fs-router';
7
+ export { filePathToUrlPath, generateMiddlewareModule, generateRouteModule, parseFileRoutes, scanRouteFiles, } from './fs-router';
8
+ export { defineConfig, resolveConfig } from "./config";
9
+ export { createISRHandler } from "./isr";
10
+ export { bunAdapter, nodeAdapter, resolveAdapter, staticAdapter, } from "./adapters";
11
+ export type { ImageProps, ImageSource } from "./image";
12
+ export { Image } from "./image";
13
+ export type { LinkProps, LinkRenderProps, UseLinkReturn } from "./link";
14
+ export { createLink, Link, prefetchRoute, useLink } from "./link";
15
+ export type { ScriptProps, ScriptStrategy } from "./script";
16
+ export { Script } from "./script";
17
+ export { render404Page } from "./not-found";
18
+ export type { CacheConfig, CacheRule } from "./cache";
19
+ export { cacheMiddleware, securityHeaders, varyEncoding } from "./cache";
20
+ export { compose, getContext } from "./middleware";
21
+ export type { FallbackMetrics, FontConfig, FontDisplay, GoogleFontInput, GoogleFontStatic, GoogleFontVariable, LocalFont, } from "./font";
22
+ export { fontPlugin, fontVariables } from "./font";
23
+ export type { FormatSource, ImageFormat, ImagePluginConfig, ProcessedImage, } from "./image-plugin";
24
+ export { imagePlugin } from "./image-plugin";
25
+ export type { Theme } from "./theme";
26
+ export { initTheme, resolvedTheme, setTheme, ThemeToggle, theme, themeScript, toggleTheme, } from "./theme";
27
+ export type { ChangeFreq, JsonLdType, RobotsConfig, RobotsRule, SeoPluginConfig, SitemapConfig, SitemapEntry, } from "./seo";
28
+ export { generateRobots, generateSitemap, jsonLd, seoMiddleware, seoPlugin, } from "./seo";
29
+ export type { ApiContext, ApiHandler, ApiRouteEntry, ApiRouteModule, HttpMethod, } from "./api-routes";
30
+ export { createApiMiddleware, generateApiRouteModule } from "./api-routes";
31
+ export type { CorsConfig } from "./cors";
32
+ export { corsMiddleware } from "./cors";
33
+ export type { RateLimitConfig } from "./rate-limit";
34
+ export { rateLimitMiddleware } from "./rate-limit";
35
+ export type { CompressionConfig } from "./compression";
36
+ export { compressionMiddleware, compressResponse, isCompressible, } from "./compression";
37
+ export type { Action, ActionContext, ActionHandler } from "./actions";
38
+ export { createActionMiddleware, defineAction } from "./actions";
39
+ export type { FaviconPluginConfig } from "./favicon";
40
+ export { faviconPlugin } from "./favicon";
41
+ export type { MetaProps } from "./meta";
42
+ export { buildMetaTags, Meta } from "./meta";
43
+ export type { I18nRoutingConfig, LocaleContext } from "./i18n-routing";
44
+ export { buildLocalePath, createLocaleContext, detectLocaleFromHeader, extractLocaleFromPath, i18nRouting, setLocale, useLocale, } from "./i18n-routing";
45
+ export type { Adapter, AdapterBuildOptions, FileRoute, ISRConfig, LoaderContext, RenderMode, RouteMeta, RouteMiddlewareEntry, RouteModule, ZeroConfig, } from "./types";
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAItD,YAAY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7C,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,SAAS,GACT,MAAM,gBAAgB,CAAC;AAIxB,YAAY,EACX,OAAO,EACP,mBAAmB,EACnB,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,WAAW,EACX,UAAU,GACV,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ISRConfig } from './types';
2
+ /**
3
+ * In-memory ISR cache with stale-while-revalidate semantics.
4
+ *
5
+ * Wraps an SSR handler and caches responses per URL path.
6
+ * Serves stale content immediately while revalidating in the background.
7
+ */
8
+ export declare function createISRHandler(handler: (req: Request) => Promise<Response>, config: ISRConfig): (req: Request) => Promise<Response>;
9
+ //# sourceMappingURL=isr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isr.d.ts","sourceRoot":"","sources":["../../src/isr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAUxC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAC5C,MAAM,EAAE,SAAS,GAChB,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CA2ErC"}
@@ -0,0 +1,127 @@
1
+ export interface LinkProps {
2
+ /** Target URL path. */
3
+ href: string;
4
+ /** Link content. */
5
+ children?: any;
6
+ /** CSS class name. */
7
+ class?: string;
8
+ /** Class applied when this link matches the current route. */
9
+ activeClass?: string;
10
+ /** Class applied when this link exactly matches the current route. */
11
+ exactActiveClass?: string;
12
+ /** Prefetch strategy. Default: "hover" */
13
+ prefetch?: 'hover' | 'viewport' | 'none';
14
+ /** Open in new tab. */
15
+ external?: boolean;
16
+ /** Inline styles. */
17
+ style?: string;
18
+ /** ARIA label. */
19
+ 'aria-label'?: string;
20
+ /** Additional click handler — called before navigation. Call e.preventDefault() to cancel. */
21
+ onClick?: ((e: MouseEvent) => void) | undefined;
22
+ }
23
+ /** Props passed to a custom component via createLink. */
24
+ export interface LinkRenderProps {
25
+ href: string;
26
+ ref: import('@pyreon/core').Ref<HTMLAnchorElement>;
27
+ onClick: (e: MouseEvent) => void;
28
+ onMouseEnter: () => void;
29
+ onTouchStart: () => void;
30
+ isActive: () => boolean;
31
+ isExactActive: () => boolean;
32
+ /** Reactive class string — pass directly to element for auto-updates on route change. */
33
+ class: (() => string) | string | undefined;
34
+ style?: string;
35
+ target?: string;
36
+ rel?: string;
37
+ 'aria-label'?: string;
38
+ children?: any;
39
+ }
40
+ /** Return type of useLink. */
41
+ export interface UseLinkReturn {
42
+ /** Ref object — attach to the root element for viewport-based prefetch. */
43
+ ref: import('@pyreon/core').Ref<HTMLAnchorElement>;
44
+ /** Click handler — performs client-side navigation. */
45
+ handleClick: (e: MouseEvent) => void;
46
+ /** Mouse enter handler — triggers hover prefetch. */
47
+ handleMouseEnter: () => void;
48
+ /** Touch start handler — triggers prefetch on mobile. */
49
+ handleTouchStart: () => void;
50
+ /** Whether the link partially matches the current route. */
51
+ isActive: () => boolean;
52
+ /** Whether the link exactly matches the current route. */
53
+ isExactActive: () => boolean;
54
+ /** Resolved class string including active classes. */
55
+ classes: () => string;
56
+ }
57
+ /**
58
+ * Prefetch a route's JS chunk by injecting `<link rel="prefetch">` into the
59
+ * document head. Deduplicates — calling with the same href twice is a no-op.
60
+ *
61
+ * @example
62
+ * prefetchRoute('/about')
63
+ * prefetchRoute('/dashboard')
64
+ */
65
+ export declare function prefetchRoute(href: string): void;
66
+ /**
67
+ * Composable that provides all link behavior — navigation, prefetching,
68
+ * active state, and viewport observation.
69
+ *
70
+ * Use this for full control when `createLink` is too opinionated.
71
+ *
72
+ * @example
73
+ * function MyLink(props: LinkProps) {
74
+ * const link = useLink(props)
75
+ * return (
76
+ * <button ref={link.ref} class={link.classes()} onClick={link.handleClick}>
77
+ * {props.children}
78
+ * </button>
79
+ * )
80
+ * }
81
+ */
82
+ export declare function useLink(props: LinkProps): UseLinkReturn;
83
+ /**
84
+ * Higher-order component that wraps any component with link behavior.
85
+ *
86
+ * The wrapped component receives {@link LinkRenderProps} with all handlers,
87
+ * active state, and accessibility attributes pre-wired.
88
+ *
89
+ * @example
90
+ * // Custom button link
91
+ * const ButtonLink = createLink((props) => (
92
+ * <button
93
+ * ref={props.ref}
94
+ * class={props.class}
95
+ * onClick={props.onClick}
96
+ * onMouseEnter={props.onMouseEnter}
97
+ * >
98
+ * {props.children}
99
+ * </button>
100
+ * ))
101
+ *
102
+ * // Custom styled component
103
+ * const CardLink = createLink((props) => (
104
+ * <div
105
+ * ref={props.ref}
106
+ * class={`card ${props.isActive() ? "card--active" : ""}`}
107
+ * onClick={props.onClick}
108
+ * onMouseEnter={props.onMouseEnter}
109
+ * >
110
+ * {props.children}
111
+ * </div>
112
+ * ))
113
+ *
114
+ * // Usage
115
+ * <ButtonLink href="/about">About</ButtonLink>
116
+ * <CardLink href="/posts" prefetch="viewport">Posts</CardLink>
117
+ */
118
+ export declare function createLink(Component: (props: LinkRenderProps) => any): (props: LinkProps) => any;
119
+ /**
120
+ * Default navigation link built on an `<a>` tag.
121
+ *
122
+ * @example
123
+ * <Link href="/about" prefetch="viewport">About</Link>
124
+ * <Link href="/posts" activeClass="nav-active">Posts</Link>
125
+ */
126
+ export declare const Link: (props: LinkProps) => any;
127
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/link.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,sBAAs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