@pyreon/zero 0.12.2 → 0.12.4
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.
- package/lib/actions.js +97 -0
- package/lib/actions.js.map +1 -0
- package/lib/ai.js +503 -0
- package/lib/ai.js.map +1 -0
- package/lib/api-routes.js +137 -0
- package/lib/api-routes.js.map +1 -0
- package/lib/compression.js +80 -0
- package/lib/compression.js.map +1 -0
- package/lib/cors.js +57 -0
- package/lib/cors.js.map +1 -0
- package/lib/csp.js +119 -0
- package/lib/csp.js.map +1 -0
- package/lib/env.js +217 -0
- package/lib/env.js.map +1 -0
- package/lib/favicon.js +424 -0
- package/lib/favicon.js.map +1 -0
- package/lib/i18n-routing.js +167 -0
- package/lib/i18n-routing.js.map +1 -0
- package/lib/index.js +340 -4015
- package/lib/index.js.map +1 -1
- package/lib/link.js +5 -0
- package/lib/link.js.map +1 -1
- package/lib/logger.js +78 -0
- package/lib/logger.js.map +1 -0
- package/lib/meta.js +310 -0
- package/lib/meta.js.map +1 -0
- package/lib/middleware.js +53 -0
- package/lib/middleware.js.map +1 -0
- package/lib/og-image.js +233 -0
- package/lib/og-image.js.map +1 -0
- package/lib/rate-limit.js +76 -0
- package/lib/rate-limit.js.map +1 -0
- package/lib/server.js +1534 -0
- package/lib/server.js.map +1 -0
- package/lib/testing.js +179 -0
- package/lib/testing.js.map +1 -0
- package/lib/theme.js +11 -2
- package/lib/theme.js.map +1 -1
- package/lib/types/actions.d.ts +27 -24
- package/lib/types/actions.d.ts.map +1 -1
- package/lib/types/ai.d.ts +76 -95
- package/lib/types/ai.d.ts.map +1 -1
- package/lib/types/api-routes.d.ts +37 -33
- package/lib/types/api-routes.d.ts.map +1 -1
- package/lib/types/cache.d.ts +26 -22
- package/lib/types/cache.d.ts.map +1 -1
- package/lib/types/client.d.ts +13 -9
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/compression.d.ts +14 -10
- package/lib/types/compression.d.ts.map +1 -1
- package/lib/types/config.d.ts +39 -4
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/cors.d.ts +20 -16
- package/lib/types/cors.d.ts.map +1 -1
- package/lib/types/csp.d.ts +42 -61
- package/lib/types/csp.d.ts.map +1 -1
- package/lib/types/env.d.ts +26 -26
- package/lib/types/env.d.ts.map +1 -1
- package/lib/types/favicon.d.ts +58 -54
- package/lib/types/favicon.d.ts.map +1 -1
- package/lib/types/font.d.ts +68 -65
- package/lib/types/font.d.ts.map +1 -1
- package/lib/types/i18n-routing.d.ts +43 -37
- package/lib/types/i18n-routing.d.ts.map +1 -1
- package/lib/types/image-plugin.d.ts +49 -45
- package/lib/types/image-plugin.d.ts.map +1 -1
- package/lib/types/image.d.ts +47 -36
- package/lib/types/image.d.ts.map +1 -1
- package/lib/types/index.d.ts +594 -56
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/link.d.ts +61 -56
- package/lib/types/link.d.ts.map +1 -1
- package/lib/types/logger.d.ts +37 -48
- package/lib/types/logger.d.ts.map +1 -1
- package/lib/types/meta.d.ts +145 -105
- package/lib/types/meta.d.ts.map +1 -1
- package/lib/types/middleware.d.ts +8 -4
- package/lib/types/middleware.d.ts.map +1 -1
- package/lib/types/og-image.d.ts +63 -59
- package/lib/types/og-image.d.ts.map +1 -1
- package/lib/types/rate-limit.d.ts +20 -16
- package/lib/types/rate-limit.d.ts.map +1 -1
- package/lib/types/script.d.ts +23 -19
- package/lib/types/script.d.ts.map +1 -1
- package/lib/types/seo.d.ts +47 -43
- package/lib/types/seo.d.ts.map +1 -1
- package/lib/types/server.d.ts +455 -0
- package/lib/types/server.d.ts.map +1 -0
- package/lib/types/testing.d.ts +64 -27
- package/lib/types/testing.d.ts.map +1 -1
- package/lib/types/theme.d.ts +22 -12
- package/lib/types/theme.d.ts.map +1 -1
- package/package.json +17 -12
- package/src/actions.ts +1 -3
- package/src/adapters/bun.ts +2 -0
- package/src/adapters/cloudflare.ts +2 -0
- package/src/adapters/netlify.ts +2 -0
- package/src/adapters/node.ts +2 -0
- package/src/adapters/validate.ts +16 -0
- package/src/adapters/vercel.ts +2 -0
- package/src/compression.ts +19 -3
- package/src/entry-server.ts +28 -5
- package/src/index.ts +20 -182
- package/src/link.tsx +6 -0
- package/src/meta.tsx +78 -16
- package/src/rate-limit.ts +11 -9
- package/src/server.ts +70 -0
- package/src/theme.tsx +12 -1
- package/src/vite-plugin.ts +5 -1
- package/lib/fs-router-Dil4IKZR.js +0 -290
- package/lib/fs-router-Dil4IKZR.js.map +0 -1
- package/lib/types/adapters/bun.d.ts +0 -6
- package/lib/types/adapters/bun.d.ts.map +0 -1
- package/lib/types/adapters/cloudflare.d.ts +0 -26
- package/lib/types/adapters/cloudflare.d.ts.map +0 -1
- package/lib/types/adapters/index.d.ts +0 -13
- package/lib/types/adapters/index.d.ts.map +0 -1
- package/lib/types/adapters/netlify.d.ts +0 -21
- package/lib/types/adapters/netlify.d.ts.map +0 -1
- package/lib/types/adapters/node.d.ts +0 -6
- package/lib/types/adapters/node.d.ts.map +0 -1
- package/lib/types/adapters/static.d.ts +0 -7
- package/lib/types/adapters/static.d.ts.map +0 -1
- package/lib/types/adapters/vercel.d.ts +0 -21
- package/lib/types/adapters/vercel.d.ts.map +0 -1
- package/lib/types/app.d.ts +0 -24
- package/lib/types/app.d.ts.map +0 -1
- package/lib/types/entry-server.d.ts +0 -37
- package/lib/types/entry-server.d.ts.map +0 -1
- package/lib/types/error-overlay.d.ts +0 -6
- package/lib/types/error-overlay.d.ts.map +0 -1
- package/lib/types/fs-router.d.ts +0 -47
- package/lib/types/fs-router.d.ts.map +0 -1
- package/lib/types/isr.d.ts +0 -9
- package/lib/types/isr.d.ts.map +0 -1
- package/lib/types/not-found.d.ts +0 -7
- package/lib/types/not-found.d.ts.map +0 -1
- package/lib/types/types.d.ts +0 -111
- package/lib/types/types.d.ts.map +0 -1
- package/lib/types/utils/use-intersection-observer.d.ts +0 -10
- package/lib/types/utils/use-intersection-observer.d.ts.map +0 -1
- package/lib/types/utils/with-headers.d.ts +0 -6
- package/lib/types/utils/with-headers.d.ts.map +0 -1
- package/lib/types/vite-plugin.d.ts +0 -17
- package/lib/types/vite-plugin.d.ts.map +0 -1
package/lib/types/index.d.ts
CHANGED
|
@@ -1,56 +1,594 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
import * as _pyreon_core0 from "@pyreon/core";
|
|
2
|
+
import { ComponentFn, VNodeChild } from "@pyreon/core";
|
|
3
|
+
import * as _pyreon_reactivity0 from "@pyreon/reactivity";
|
|
4
|
+
import { NavigationGuard } from "@pyreon/router";
|
|
5
|
+
import { Middleware } from "@pyreon/server";
|
|
6
|
+
|
|
7
|
+
//#region src/image-plugin.d.ts
|
|
8
|
+
/** Per-format source set for <picture> <source> elements. */
|
|
9
|
+
interface FormatSource {
|
|
10
|
+
/** MIME type. e.g. "image/webp", "image/avif" */
|
|
11
|
+
type: string;
|
|
12
|
+
/** srcset string for this format. e.g. "/img-640.webp 640w, /img-1920.webp 1920w" */
|
|
13
|
+
srcset: string;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/image.d.ts
|
|
17
|
+
interface ImageProps {
|
|
18
|
+
/** Image source URL. */
|
|
19
|
+
src: string;
|
|
20
|
+
/** Alt text (required for accessibility). */
|
|
21
|
+
alt: string;
|
|
22
|
+
/** Intrinsic width of the image. */
|
|
23
|
+
width: number;
|
|
24
|
+
/** Intrinsic height of the image. */
|
|
25
|
+
height: number;
|
|
26
|
+
/** Responsive sizes attribute. Default: "100vw" */
|
|
27
|
+
sizes?: string;
|
|
28
|
+
/** Responsive srcset string or source array. */
|
|
29
|
+
srcset?: string | ImageSource[];
|
|
30
|
+
/** Per-format source sets for <picture>. Provided automatically by imagePlugin. */
|
|
31
|
+
formats?: FormatSource[];
|
|
32
|
+
/** Loading strategy. "lazy" uses IntersectionObserver, "eager" loads immediately. Default: "lazy" */
|
|
33
|
+
loading?: 'lazy' | 'eager';
|
|
34
|
+
/** Mark as priority (LCP image). Disables lazy loading, adds fetchPriority="high". */
|
|
35
|
+
priority?: boolean;
|
|
36
|
+
/** Low-quality placeholder image URL or base64 data URI for blur-up effect. */
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
/** CSS class name. */
|
|
39
|
+
class?: string;
|
|
40
|
+
/** Inline styles. */
|
|
41
|
+
style?: string;
|
|
42
|
+
/** CSS object-fit. Default: "cover" */
|
|
43
|
+
fit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
44
|
+
/** Decode async. Default: true */
|
|
45
|
+
decoding?: 'sync' | 'async' | 'auto';
|
|
46
|
+
}
|
|
47
|
+
interface ImageSource {
|
|
48
|
+
src: string;
|
|
49
|
+
width: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Optimized image component with lazy loading, responsive images,
|
|
53
|
+
* multi-format <picture> support, and blur-up placeholders.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // With imagePlugin — spread the import directly
|
|
57
|
+
* import hero from "./hero.jpg?optimize"
|
|
58
|
+
* <Image {...hero} alt="Hero" priority />
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Manual usage
|
|
62
|
+
* <Image src="/hero.jpg" alt="Hero" width={1200} height={630} />
|
|
63
|
+
*/
|
|
64
|
+
declare function Image(props: ImageProps): VNodeChild;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/link.d.ts
|
|
67
|
+
interface LinkProps {
|
|
68
|
+
/** Target URL path. */
|
|
69
|
+
href: string;
|
|
70
|
+
/** Link content. */
|
|
71
|
+
children?: any;
|
|
72
|
+
/** CSS class name. */
|
|
73
|
+
class?: string;
|
|
74
|
+
/** Class applied when this link matches the current route. */
|
|
75
|
+
activeClass?: string;
|
|
76
|
+
/** Class applied when this link exactly matches the current route. */
|
|
77
|
+
exactActiveClass?: string;
|
|
78
|
+
/** Prefetch strategy. Default: "hover" */
|
|
79
|
+
prefetch?: 'hover' | 'viewport' | 'none';
|
|
80
|
+
/** Open in new tab. */
|
|
81
|
+
external?: boolean;
|
|
82
|
+
/** Inline styles. */
|
|
83
|
+
style?: string;
|
|
84
|
+
/** ARIA label. */
|
|
85
|
+
'aria-label'?: string;
|
|
86
|
+
/** Additional click handler — called before navigation. Call e.preventDefault() to cancel. */
|
|
87
|
+
onClick?: ((e: MouseEvent) => void) | undefined;
|
|
88
|
+
}
|
|
89
|
+
/** Props passed to a custom component via createLink. */
|
|
90
|
+
interface LinkRenderProps {
|
|
91
|
+
href: string;
|
|
92
|
+
ref: _pyreon_core0.Ref<HTMLAnchorElement>;
|
|
93
|
+
onClick: (e: MouseEvent) => void;
|
|
94
|
+
onMouseEnter: () => void;
|
|
95
|
+
onTouchStart: () => void;
|
|
96
|
+
isActive: () => boolean;
|
|
97
|
+
isExactActive: () => boolean;
|
|
98
|
+
/** Reactive class string — pass directly to element for auto-updates on route change. */
|
|
99
|
+
class: (() => string) | string | undefined;
|
|
100
|
+
style?: string;
|
|
101
|
+
target?: string;
|
|
102
|
+
rel?: string;
|
|
103
|
+
'aria-label'?: string;
|
|
104
|
+
children?: any;
|
|
105
|
+
}
|
|
106
|
+
/** Return type of useLink. */
|
|
107
|
+
interface UseLinkReturn {
|
|
108
|
+
/** Ref object — attach to the root element for viewport-based prefetch. */
|
|
109
|
+
ref: _pyreon_core0.Ref<HTMLAnchorElement>;
|
|
110
|
+
/** Click handler — performs client-side navigation. */
|
|
111
|
+
handleClick: (e: MouseEvent) => void;
|
|
112
|
+
/** Mouse enter handler — triggers hover prefetch. */
|
|
113
|
+
handleMouseEnter: () => void;
|
|
114
|
+
/** Touch start handler — triggers prefetch on mobile. */
|
|
115
|
+
handleTouchStart: () => void;
|
|
116
|
+
/** Whether the link partially matches the current route. */
|
|
117
|
+
isActive: () => boolean;
|
|
118
|
+
/** Whether the link exactly matches the current route. */
|
|
119
|
+
isExactActive: () => boolean;
|
|
120
|
+
/** Resolved class string including active classes. */
|
|
121
|
+
classes: () => string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Prefetch a route's JS chunk by injecting `<link rel="prefetch">` into the
|
|
125
|
+
* document head. Deduplicates — calling with the same href twice is a no-op.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* prefetchRoute('/about')
|
|
129
|
+
* prefetchRoute('/dashboard')
|
|
130
|
+
*/
|
|
131
|
+
declare function prefetchRoute(href: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* Composable that provides all link behavior — navigation, prefetching,
|
|
134
|
+
* active state, and viewport observation.
|
|
135
|
+
*
|
|
136
|
+
* Use this for full control when `createLink` is too opinionated.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* function MyLink(props: LinkProps) {
|
|
140
|
+
* const link = useLink(props)
|
|
141
|
+
* return (
|
|
142
|
+
* <button ref={link.ref} class={link.classes()} onClick={link.handleClick}>
|
|
143
|
+
* {props.children}
|
|
144
|
+
* </button>
|
|
145
|
+
* )
|
|
146
|
+
* }
|
|
147
|
+
*/
|
|
148
|
+
declare function useLink(props: LinkProps): UseLinkReturn;
|
|
149
|
+
/**
|
|
150
|
+
* Higher-order component that wraps any component with link behavior.
|
|
151
|
+
*
|
|
152
|
+
* The wrapped component receives {@link LinkRenderProps} with all handlers,
|
|
153
|
+
* active state, and accessibility attributes pre-wired.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* // Custom button link
|
|
157
|
+
* const ButtonLink = createLink((props) => (
|
|
158
|
+
* <button
|
|
159
|
+
* ref={props.ref}
|
|
160
|
+
* class={props.class}
|
|
161
|
+
* onClick={props.onClick}
|
|
162
|
+
* onMouseEnter={props.onMouseEnter}
|
|
163
|
+
* >
|
|
164
|
+
* {props.children}
|
|
165
|
+
* </button>
|
|
166
|
+
* ))
|
|
167
|
+
*
|
|
168
|
+
* // Custom styled component
|
|
169
|
+
* const CardLink = createLink((props) => (
|
|
170
|
+
* <div
|
|
171
|
+
* ref={props.ref}
|
|
172
|
+
* class={`card ${props.isActive() ? "card--active" : ""}`}
|
|
173
|
+
* onClick={props.onClick}
|
|
174
|
+
* onMouseEnter={props.onMouseEnter}
|
|
175
|
+
* >
|
|
176
|
+
* {props.children}
|
|
177
|
+
* </div>
|
|
178
|
+
* ))
|
|
179
|
+
*
|
|
180
|
+
* // Usage
|
|
181
|
+
* <ButtonLink href="/about">About</ButtonLink>
|
|
182
|
+
* <CardLink href="/posts" prefetch="viewport">Posts</CardLink>
|
|
183
|
+
*/
|
|
184
|
+
declare function createLink(Component: (props: LinkRenderProps) => any): (props: LinkProps) => any;
|
|
185
|
+
/**
|
|
186
|
+
* Default navigation link built on an `<a>` tag.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* <Link href="/about" prefetch="viewport">About</Link>
|
|
190
|
+
* <Link href="/posts" activeClass="nav-active">Posts</Link>
|
|
191
|
+
*/
|
|
192
|
+
declare const Link: (props: LinkProps) => any;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/script.d.ts
|
|
195
|
+
interface ScriptProps {
|
|
196
|
+
/** Script source URL. */
|
|
197
|
+
src: string;
|
|
198
|
+
/** Loading strategy. Default: "afterHydration" */
|
|
199
|
+
strategy?: ScriptStrategy;
|
|
200
|
+
/** Inline script content (alternative to src). */
|
|
201
|
+
children?: string;
|
|
202
|
+
/** Script id for deduplication. */
|
|
203
|
+
id?: string;
|
|
204
|
+
/** Async attribute. Default: true */
|
|
205
|
+
async?: boolean;
|
|
206
|
+
/** onLoad callback. */
|
|
207
|
+
onLoad?: () => void;
|
|
208
|
+
/** onError callback. */
|
|
209
|
+
onError?: (error: Error) => void;
|
|
210
|
+
}
|
|
211
|
+
type ScriptStrategy = 'beforeHydration' | 'afterHydration' | 'onIdle' | 'onInteraction' | 'onViewport';
|
|
212
|
+
/**
|
|
213
|
+
* Optimized script loading component.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* // Load analytics after page is interactive
|
|
217
|
+
* <Script src="https://analytics.example.com/script.js" strategy="onIdle" />
|
|
218
|
+
*
|
|
219
|
+
* // Load chat widget when user scrolls
|
|
220
|
+
* <Script src="/chat-widget.js" strategy="onViewport" />
|
|
221
|
+
*
|
|
222
|
+
* // Inline script with deferred execution
|
|
223
|
+
* <Script strategy="afterHydration">
|
|
224
|
+
* {`console.log("App hydrated!")`}
|
|
225
|
+
* </Script>
|
|
226
|
+
*/
|
|
227
|
+
declare function Script(props: ScriptProps): VNodeChild;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/i18n-routing.d.ts
|
|
230
|
+
interface I18nRoutingConfig {
|
|
231
|
+
/** Supported locales. e.g. ["en", "de", "cs"] */
|
|
232
|
+
locales: string[];
|
|
233
|
+
/** Default locale — served without prefix (/ instead of /en/). */
|
|
234
|
+
defaultLocale: string;
|
|
235
|
+
/** Redirect root to detected locale. Default: true */
|
|
236
|
+
detectLocale?: boolean;
|
|
237
|
+
/** Cookie name to persist locale preference. Default: "locale" */
|
|
238
|
+
cookieName?: string;
|
|
239
|
+
/** URL strategy. Default: "prefix-except-default" */
|
|
240
|
+
strategy?: 'prefix' | 'prefix-except-default';
|
|
241
|
+
}
|
|
242
|
+
interface LocaleContext {
|
|
243
|
+
/** Current locale code. e.g. "en", "de" */
|
|
244
|
+
locale: string;
|
|
245
|
+
/** All supported locales. */
|
|
246
|
+
locales: string[];
|
|
247
|
+
/** Default locale. */
|
|
248
|
+
defaultLocale: string;
|
|
249
|
+
/** Build a localized path. e.g. localePath("/about", "de") → "/de/about" */
|
|
250
|
+
localePath: (path: string, locale?: string) => string;
|
|
251
|
+
/** Get hreflang alternates for the current path. */
|
|
252
|
+
alternates: () => Array<{
|
|
253
|
+
locale: string;
|
|
254
|
+
url: string;
|
|
255
|
+
}>;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Extract locale from a URL path.
|
|
259
|
+
* Returns { locale, pathWithoutLocale }.
|
|
260
|
+
*/
|
|
261
|
+
declare function extractLocaleFromPath(path: string, locales: string[], defaultLocale: string): {
|
|
262
|
+
locale: string;
|
|
263
|
+
pathWithoutLocale: string;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Build a localized path.
|
|
267
|
+
*/
|
|
268
|
+
declare function buildLocalePath(path: string, locale: string, defaultLocale: string, strategy: 'prefix' | 'prefix-except-default'): string;
|
|
269
|
+
/**
|
|
270
|
+
* Read the current locale reactively.
|
|
271
|
+
*
|
|
272
|
+
* Returns the locale signal value directly — reactive in both SSR and CSR.
|
|
273
|
+
* The server middleware sets `localeSignal` per-request, and client-side
|
|
274
|
+
* `setLocale()` updates it as well.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```tsx
|
|
278
|
+
* const locale = useLocale() // "en", "de", etc.
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
declare function useLocale(): string;
|
|
282
|
+
/**
|
|
283
|
+
* Set the locale client-side and update the URL.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```tsx
|
|
287
|
+
* <button onClick={() => setLocale('de')}>Deutsch</button>
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
declare function setLocale(locale: string, config: I18nRoutingConfig): void;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/meta.d.ts
|
|
293
|
+
/** Favicon plugin config shape (type-only). */
|
|
294
|
+
interface FaviconPluginConfig {
|
|
295
|
+
source: string;
|
|
296
|
+
themeColor?: string;
|
|
297
|
+
manifest?: boolean;
|
|
298
|
+
locales?: Record<string, {
|
|
299
|
+
source: string;
|
|
300
|
+
darkSource?: string;
|
|
301
|
+
}>;
|
|
302
|
+
[key: string]: unknown;
|
|
303
|
+
}
|
|
304
|
+
interface MetaProps {
|
|
305
|
+
/** Page title. Accepts reactive accessor `() => string`. */
|
|
306
|
+
title?: string | (() => string);
|
|
307
|
+
/** Page description. Accepts reactive accessor. */
|
|
308
|
+
description?: string | (() => string);
|
|
309
|
+
/** Canonical URL. Also sets og:url. */
|
|
310
|
+
canonical?: string;
|
|
311
|
+
/** Open Graph image URL. Also sets twitter:image. */
|
|
312
|
+
image?: string;
|
|
313
|
+
/** Image alt text for accessibility. */
|
|
314
|
+
imageAlt?: string;
|
|
315
|
+
/** Image width in pixels (og:image:width). Helps crawlers layout before loading. */
|
|
316
|
+
imageWidth?: number;
|
|
317
|
+
/** Image height in pixels (og:image:height). */
|
|
318
|
+
imageHeight?: number;
|
|
319
|
+
/** Open Graph type. Default: "website" */
|
|
320
|
+
type?: 'website' | 'article' | 'product' | 'profile';
|
|
321
|
+
/** Site name for og:site_name. */
|
|
322
|
+
siteName?: string;
|
|
323
|
+
/** Twitter card type. Default: "summary_large_image" */
|
|
324
|
+
twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
325
|
+
/** Twitter @handle. */
|
|
326
|
+
twitterSite?: string;
|
|
327
|
+
/** Twitter creator @handle. */
|
|
328
|
+
twitterCreator?: string;
|
|
329
|
+
/** Locale. Default: "en_US" */
|
|
330
|
+
locale?: string;
|
|
331
|
+
/** Alternate locales for hreflang. */
|
|
332
|
+
alternateLocales?: Array<{
|
|
333
|
+
locale: string;
|
|
334
|
+
url: string;
|
|
335
|
+
}>;
|
|
336
|
+
/** Robots directives. Default: "index, follow" */
|
|
337
|
+
robots?: string;
|
|
338
|
+
/** Convenience: set `true` to emit `noindex, nofollow`. Overrides `robots`. */
|
|
339
|
+
noIndex?: boolean;
|
|
340
|
+
/** Published time (ISO 8601) for article type. */
|
|
341
|
+
publishedTime?: string;
|
|
342
|
+
/** Modified time (ISO 8601) for article type. */
|
|
343
|
+
modifiedTime?: string;
|
|
344
|
+
/** Article author. */
|
|
345
|
+
author?: string;
|
|
346
|
+
/** Article tags. */
|
|
347
|
+
tags?: string[];
|
|
348
|
+
/** JSON-LD structured data object. */
|
|
349
|
+
jsonLd?: Record<string, unknown>;
|
|
350
|
+
/** Additional custom meta tags. */
|
|
351
|
+
extra?: Array<{
|
|
352
|
+
name?: string;
|
|
353
|
+
property?: string;
|
|
354
|
+
content: string;
|
|
355
|
+
}>;
|
|
356
|
+
/**
|
|
357
|
+
* Open Graph video URL. Also sets og:video:type if the URL ends with
|
|
358
|
+
* a known extension (.mp4, .webm).
|
|
359
|
+
*/
|
|
360
|
+
video?: string;
|
|
361
|
+
/** Video width in pixels. */
|
|
362
|
+
videoWidth?: number;
|
|
363
|
+
/** Video height in pixels. */
|
|
364
|
+
videoHeight?: number;
|
|
365
|
+
/**
|
|
366
|
+
* Open Graph audio URL.
|
|
367
|
+
*/
|
|
368
|
+
audio?: string;
|
|
369
|
+
/**
|
|
370
|
+
* I18n routing config — when provided, auto-generates hreflang alternate
|
|
371
|
+
* links for all locales based on the current path.
|
|
372
|
+
* Also sets og:locale and og:locale:alternate.
|
|
373
|
+
*/
|
|
374
|
+
i18n?: I18nRoutingConfig;
|
|
375
|
+
/** Base URL for building absolute hreflang URLs. e.g. "https://example.com" */
|
|
376
|
+
origin?: string;
|
|
377
|
+
/**
|
|
378
|
+
* Favicon plugin config — when provided, injects locale-aware favicon
|
|
379
|
+
* `<link>` tags into `<head>`. Uses the current locale to select
|
|
380
|
+
* the correct favicon set.
|
|
381
|
+
*/
|
|
382
|
+
favicon?: FaviconPluginConfig;
|
|
383
|
+
/**
|
|
384
|
+
* OG image template name — auto-resolves to the correct locale-specific
|
|
385
|
+
* OG image path generated by `ogImagePlugin`.
|
|
386
|
+
* Sets both `og:image` and `twitter:image` unless `image` is also provided.
|
|
387
|
+
*/
|
|
388
|
+
ogTemplate?: string;
|
|
389
|
+
/** Output directory for OG images. Default: "og" */
|
|
390
|
+
ogImageDir?: string;
|
|
391
|
+
/** OG image format. Default: "png" */
|
|
392
|
+
ogImageFormat?: 'png' | 'jpeg';
|
|
393
|
+
children?: VNodeChild;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Declarative meta component for SSR-compatible page metadata.
|
|
397
|
+
*
|
|
398
|
+
* Supports reactive title/description — when passed as `() => string` accessors,
|
|
399
|
+
* they are forwarded to `useHead()` as a reactive getter so updates propagate
|
|
400
|
+
* automatically via signal tracking.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* <Meta title="My Page" description="..." image="/og.jpg" canonical="https://..." />
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @example Reactive title
|
|
408
|
+
* ```tsx
|
|
409
|
+
* const count = signal(0)
|
|
410
|
+
* <Meta title={() => `${count()} items`} />
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
declare function Meta(props: MetaProps): VNodeChild;
|
|
414
|
+
interface MetaTagEntry {
|
|
415
|
+
name?: string;
|
|
416
|
+
property?: string;
|
|
417
|
+
content: string;
|
|
418
|
+
[key: string]: string | undefined;
|
|
419
|
+
}
|
|
420
|
+
interface LinkTagEntry {
|
|
421
|
+
rel: string;
|
|
422
|
+
href?: string;
|
|
423
|
+
hreflang?: string;
|
|
424
|
+
type?: string;
|
|
425
|
+
sizes?: string;
|
|
426
|
+
[key: string]: string | undefined;
|
|
427
|
+
}
|
|
428
|
+
interface ScriptTagEntry {
|
|
429
|
+
type: string;
|
|
430
|
+
children: string;
|
|
431
|
+
}
|
|
432
|
+
interface MetaTags {
|
|
433
|
+
meta: MetaTagEntry[];
|
|
434
|
+
link: LinkTagEntry[];
|
|
435
|
+
script: ScriptTagEntry[];
|
|
436
|
+
}
|
|
437
|
+
declare function buildMetaTags(props: Omit<MetaProps, 'title' | 'description' | 'children'> & {
|
|
438
|
+
title?: string;
|
|
439
|
+
description?: string;
|
|
440
|
+
}): MetaTags;
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/theme.d.ts
|
|
443
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
444
|
+
/** Reactive theme signal. */
|
|
445
|
+
declare const theme: _pyreon_reactivity0.Signal<Theme>;
|
|
446
|
+
/**
|
|
447
|
+
* Set the default theme for SSR (when `matchMedia` is unavailable).
|
|
448
|
+
* Call once at server startup before rendering.
|
|
449
|
+
*/
|
|
450
|
+
declare function setSSRThemeDefault(value: 'light' | 'dark'): void;
|
|
451
|
+
/** Computed resolved theme (what's actually applied). */
|
|
452
|
+
declare function resolvedTheme(): 'light' | 'dark';
|
|
453
|
+
/** Toggle between light and dark. */
|
|
454
|
+
declare function toggleTheme(): void;
|
|
455
|
+
/** Set theme explicitly. */
|
|
456
|
+
declare function setTheme(t: Theme): void;
|
|
457
|
+
/**
|
|
458
|
+
* Initialize the theme system. Call once in your app entry or layout.
|
|
459
|
+
* Reads from localStorage, listens for system preference changes.
|
|
460
|
+
*/
|
|
461
|
+
declare function initTheme(): void;
|
|
462
|
+
/**
|
|
463
|
+
* Theme toggle button component.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* import { ThemeToggle } from "@pyreon/zero/theme"
|
|
467
|
+
* <ThemeToggle />
|
|
468
|
+
*/
|
|
469
|
+
declare function ThemeToggle(props: {
|
|
470
|
+
class?: string;
|
|
471
|
+
style?: string;
|
|
472
|
+
}): VNodeChild;
|
|
473
|
+
/**
|
|
474
|
+
* Inline script to prevent flash of wrong theme.
|
|
475
|
+
* Include this in your index.html <head> BEFORE any stylesheets.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* // index.html
|
|
479
|
+
* <head>
|
|
480
|
+
* <script>{themeScript}</script>
|
|
481
|
+
* ...
|
|
482
|
+
* </head>
|
|
483
|
+
*/
|
|
484
|
+
declare const themeScript = "(function(){try{var t=localStorage.getItem(\"zero-theme\");var r=t===\"light\"?\"light\":t===\"dark\"?\"dark\":window.matchMedia(\"(prefers-color-scheme:dark)\").matches?\"dark\":\"light\";document.documentElement.dataset.theme=r}catch(e){}})()";
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/types.d.ts
|
|
487
|
+
/** What a route file (e.g. `src/routes/index.tsx`) can export. */
|
|
488
|
+
interface RouteModule {
|
|
489
|
+
/** Default export is the page component. */
|
|
490
|
+
default?: ComponentFn;
|
|
491
|
+
/** Layout wrapper — wraps this route and all children. */
|
|
492
|
+
layout?: ComponentFn;
|
|
493
|
+
/** Loading component shown while lazy-loading or during Suspense. */
|
|
494
|
+
loading?: ComponentFn;
|
|
495
|
+
/** Error component shown when the route errors. */
|
|
496
|
+
error?: ComponentFn;
|
|
497
|
+
/** Server-side data loader. */
|
|
498
|
+
loader?: (ctx: LoaderContext) => Promise<unknown>;
|
|
499
|
+
/** Per-route middleware. */
|
|
500
|
+
middleware?: Middleware | Middleware[];
|
|
501
|
+
/** Navigation guard — can redirect or block navigation. */
|
|
502
|
+
guard?: NavigationGuard;
|
|
503
|
+
/** Route metadata. */
|
|
504
|
+
meta?: RouteMeta;
|
|
505
|
+
/** Rendering mode override for this route. */
|
|
506
|
+
renderMode?: RenderMode;
|
|
507
|
+
}
|
|
508
|
+
/** Context passed to route loaders. */
|
|
509
|
+
interface LoaderContext {
|
|
510
|
+
params: Record<string, string>;
|
|
511
|
+
query: Record<string, string>;
|
|
512
|
+
signal: AbortSignal;
|
|
513
|
+
request: Request;
|
|
514
|
+
}
|
|
515
|
+
/** Per-route metadata. */
|
|
516
|
+
interface RouteMeta {
|
|
517
|
+
title?: string;
|
|
518
|
+
description?: string;
|
|
519
|
+
[key: string]: unknown;
|
|
520
|
+
}
|
|
521
|
+
type RenderMode = 'ssr' | 'ssg' | 'spa' | 'isr';
|
|
522
|
+
interface ISRConfig {
|
|
523
|
+
/** Revalidation interval in seconds. */
|
|
524
|
+
revalidate: number;
|
|
525
|
+
}
|
|
526
|
+
interface ZeroConfig {
|
|
527
|
+
/** Default rendering mode. Default: "ssr" */
|
|
528
|
+
mode?: RenderMode;
|
|
529
|
+
/** Vite config overrides. */
|
|
530
|
+
vite?: Record<string, unknown>;
|
|
531
|
+
/** SSR options. */
|
|
532
|
+
ssr?: {
|
|
533
|
+
/** Streaming mode. Default: "string" */mode?: 'string' | 'stream';
|
|
534
|
+
};
|
|
535
|
+
/** SSG options — only used when mode is "ssg". */
|
|
536
|
+
ssg?: {
|
|
537
|
+
/** Paths to prerender (or function returning paths). */paths?: string[] | (() => string[] | Promise<string[]>);
|
|
538
|
+
};
|
|
539
|
+
/** ISR config — only used when mode is "isr". */
|
|
540
|
+
isr?: ISRConfig;
|
|
541
|
+
/** Deploy adapter. Default: "node" */
|
|
542
|
+
adapter?: 'node' | 'bun' | 'static' | 'vercel' | 'cloudflare' | 'netlify';
|
|
543
|
+
/** Base URL path. Default: "/" */
|
|
544
|
+
base?: string;
|
|
545
|
+
/** App-level middleware applied to all routes. */
|
|
546
|
+
middleware?: Middleware[];
|
|
547
|
+
/** Server port for dev/preview. Default: 3000 */
|
|
548
|
+
port?: number;
|
|
549
|
+
}
|
|
550
|
+
/** Internal representation of a file-system route before conversion to RouteRecord. */
|
|
551
|
+
interface FileRoute {
|
|
552
|
+
/** File path relative to routes dir (e.g. "users/[id].tsx") */
|
|
553
|
+
filePath: string;
|
|
554
|
+
/** Parsed URL path pattern (e.g. "/users/:id") */
|
|
555
|
+
urlPath: string;
|
|
556
|
+
/** Directory path for grouping (e.g. "users" or "" for root) */
|
|
557
|
+
dirPath: string;
|
|
558
|
+
/** Route segment depth for nesting. */
|
|
559
|
+
depth: number;
|
|
560
|
+
/** Whether this is a layout file. */
|
|
561
|
+
isLayout: boolean;
|
|
562
|
+
/** Whether this is an error boundary file. */
|
|
563
|
+
isError: boolean;
|
|
564
|
+
/** Whether this is a loading fallback file. */
|
|
565
|
+
isLoading: boolean;
|
|
566
|
+
/** Whether this is a not-found (404) file. */
|
|
567
|
+
isNotFound: boolean;
|
|
568
|
+
/** Whether this is a catch-all route. */
|
|
569
|
+
isCatchAll: boolean;
|
|
570
|
+
/** Resolved rendering mode. */
|
|
571
|
+
renderMode: RenderMode;
|
|
572
|
+
}
|
|
573
|
+
/** Entry mapping a URL pattern to its route-level middleware. */
|
|
574
|
+
interface RouteMiddlewareEntry {
|
|
575
|
+
pattern: string;
|
|
576
|
+
middleware: Middleware | Middleware[];
|
|
577
|
+
}
|
|
578
|
+
interface Adapter {
|
|
579
|
+
name: string;
|
|
580
|
+
/** Build the production server/output for this adapter. */
|
|
581
|
+
build(options: AdapterBuildOptions): Promise<void>;
|
|
582
|
+
}
|
|
583
|
+
interface AdapterBuildOptions {
|
|
584
|
+
/** Path to the built server entry. */
|
|
585
|
+
serverEntry: string;
|
|
586
|
+
/** Path to the client build output. */
|
|
587
|
+
clientOutDir: string;
|
|
588
|
+
/** Final output directory. */
|
|
589
|
+
outDir: string;
|
|
590
|
+
config: ZeroConfig;
|
|
591
|
+
}
|
|
592
|
+
//#endregion
|
|
593
|
+
export { type Adapter, type AdapterBuildOptions, type FileRoute, type I18nRoutingConfig, type ISRConfig, Image, type ImageProps, type ImageSource, Link, type LinkProps, type LinkRenderProps, type LoaderContext, type LocaleContext, Meta, type MetaProps, type RenderMode, type RouteMeta, type RouteMiddlewareEntry, type RouteModule, Script, type ScriptProps, type ScriptStrategy, type Theme, ThemeToggle, type UseLinkReturn, type ZeroConfig, buildLocalePath, buildMetaTags, createLink, extractLocaleFromPath, initTheme, prefetchRoute, resolvedTheme, setLocale, setSSRThemeDefault, setTheme, theme, themeScript, toggleTheme, useLink, useLocale };
|
|
594
|
+
//# sourceMappingURL=index2.d.ts.map
|