@alepha/react 0.14.1 → 0.14.2

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 (68) hide show
  1. package/dist/auth/index.browser.js +1488 -4
  2. package/dist/auth/index.browser.js.map +1 -1
  3. package/dist/auth/index.d.ts +2 -2
  4. package/dist/auth/index.js +1827 -4
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/core/index.d.ts +54 -937
  7. package/dist/core/index.d.ts.map +1 -1
  8. package/dist/core/index.js +132 -2010
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/form/index.d.ts.map +1 -1
  11. package/dist/form/index.js +6 -1
  12. package/dist/form/index.js.map +1 -1
  13. package/dist/head/index.browser.js +3 -1
  14. package/dist/head/index.browser.js.map +1 -1
  15. package/dist/head/index.d.ts +552 -8
  16. package/dist/head/index.d.ts.map +1 -1
  17. package/dist/head/index.js +15 -1
  18. package/dist/head/index.js.map +1 -1
  19. package/dist/{core → router}/index.browser.js +126 -516
  20. package/dist/router/index.browser.js.map +1 -0
  21. package/dist/router/index.d.ts +1334 -0
  22. package/dist/router/index.d.ts.map +1 -0
  23. package/dist/router/index.js +1939 -0
  24. package/dist/router/index.js.map +1 -0
  25. package/package.json +12 -6
  26. package/src/auth/index.ts +1 -1
  27. package/src/auth/services/ReactAuth.ts +1 -1
  28. package/src/core/components/ClientOnly.tsx +14 -0
  29. package/src/core/components/ErrorBoundary.tsx +3 -2
  30. package/src/core/contexts/AlephaContext.ts +3 -0
  31. package/src/core/contexts/AlephaProvider.tsx +2 -1
  32. package/src/core/index.ts +13 -102
  33. package/src/form/services/FormModel.ts +5 -0
  34. package/src/head/index.ts +16 -7
  35. package/src/head/interfaces/Head.ts +3 -0
  36. package/src/head/providers/HeadProvider.ts +6 -1
  37. package/src/head/providers/ServerHeadProvider.ts +20 -0
  38. package/src/{core → router}/components/ErrorViewer.tsx +2 -0
  39. package/src/router/components/Link.tsx +21 -0
  40. package/src/{core → router}/components/NestedView.tsx +3 -5
  41. package/src/router/components/NotFound.tsx +30 -0
  42. package/src/router/errors/Redirection.ts +28 -0
  43. package/src/{core → router}/hooks/useActive.ts +6 -2
  44. package/src/{core → router}/hooks/useQueryParams.ts +2 -2
  45. package/src/{core → router}/hooks/useRouter.ts +1 -1
  46. package/src/{core → router}/hooks/useRouterState.ts +1 -1
  47. package/src/{core → router}/index.browser.ts +14 -12
  48. package/src/{core/index.shared-router.ts → router/index.shared.ts} +6 -3
  49. package/src/router/index.ts +125 -0
  50. package/src/{core → router}/primitives/$page.ts +1 -1
  51. package/src/{core → router}/providers/ReactBrowserProvider.ts +3 -13
  52. package/src/{core → router}/providers/ReactBrowserRendererProvider.ts +3 -0
  53. package/src/{core → router}/providers/ReactBrowserRouterProvider.ts +3 -0
  54. package/src/{core → router}/providers/ReactPageProvider.ts +5 -3
  55. package/src/{core → router}/providers/ReactServerProvider.ts +9 -28
  56. package/src/{core → router}/services/ReactPageServerService.ts +3 -0
  57. package/src/{core → router}/services/ReactPageService.ts +5 -5
  58. package/src/{core → router}/services/ReactRouter.ts +26 -5
  59. package/dist/core/index.browser.js.map +0 -1
  60. package/dist/core/index.native.js +0 -403
  61. package/dist/core/index.native.js.map +0 -1
  62. package/src/core/components/Link.tsx +0 -18
  63. package/src/core/components/NotFound.tsx +0 -27
  64. package/src/core/errors/Redirection.ts +0 -13
  65. package/src/core/hooks/useSchema.ts +0 -88
  66. package/src/core/index.native.ts +0 -21
  67. package/src/core/index.shared.ts +0 -9
  68. /package/src/{core → router}/contexts/RouterLayerContext.ts +0 -0
@@ -0,0 +1,1334 @@
1
+ import { ClientOnlyProps } from "@alepha/react";
2
+ import * as alepha12 from "alepha";
3
+ import { Alepha, AlephaError, Async, KIND, Primitive, Static, TObject, TSchema } from "alepha";
4
+ import { DateTimeProvider } from "alepha/datetime";
5
+ import * as alepha_logger0 from "alepha/logger";
6
+ import { LinkProvider } from "alepha/server/links";
7
+ import { Route, RouterProvider } from "alepha/router";
8
+ import * as react0 from "react";
9
+ import { AnchorHTMLAttributes, CSSProperties, FC, ReactNode } from "react";
10
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
11
+ import * as alepha_server0 from "alepha/server";
12
+ import { ServerHandler, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
13
+ import { ServerStaticProvider } from "alepha/server/static";
14
+ import * as alepha_server_cache0 from "alepha/server/cache";
15
+ import { ServerRouteCache } from "alepha/server/cache";
16
+
17
+ //#region ../../src/router/errors/Redirection.d.ts
18
+
19
+ /**
20
+ * Used for Redirection during the page loading.
21
+ *
22
+ * Depends on the context, it can be thrown or just returned.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { Redirection } from "@alepha/react";
27
+ *
28
+ * const MyPage = $page({
29
+ * resolve: async () => {
30
+ * if (needRedirect) {
31
+ * throw new Redirection("/new-path");
32
+ * }
33
+ * },
34
+ * });
35
+ * ```
36
+ */
37
+ declare class Redirection extends AlephaError {
38
+ readonly redirect: string;
39
+ constructor(redirect: string);
40
+ }
41
+ //#endregion
42
+ //#region ../../src/router/providers/ReactPageProvider.d.ts
43
+ declare const envSchema$2: alepha12.TObject<{
44
+ REACT_STRICT_MODE: alepha12.TBoolean;
45
+ }>;
46
+ declare module "alepha" {
47
+ interface Env extends Partial<Static<typeof envSchema$2>> {}
48
+ }
49
+ /**
50
+ * Handle page routes for React applications. (Browser and Server)
51
+ */
52
+ declare class ReactPageProvider {
53
+ protected readonly log: alepha_logger0.Logger;
54
+ protected readonly env: {
55
+ REACT_STRICT_MODE: boolean;
56
+ };
57
+ protected readonly alepha: Alepha;
58
+ protected readonly pages: PageRoute[];
59
+ getPages(): PageRoute[];
60
+ getConcretePages(): ConcretePageRoute[];
61
+ page(name: string): PageRoute;
62
+ pathname(name: string, options?: {
63
+ params?: Record<string, string>;
64
+ query?: Record<string, string>;
65
+ }): string;
66
+ url(name: string, options?: {
67
+ params?: Record<string, string>;
68
+ host?: string;
69
+ }): URL;
70
+ root(state: ReactRouterState): ReactNode;
71
+ protected convertStringObjectToObject: (schema?: TSchema, value?: any) => any;
72
+ /**
73
+ * Create a new RouterState based on a given route and request.
74
+ * This method resolves the layers for the route, applying any query and params schemas defined in the route.
75
+ * It also handles errors and redirects.
76
+ */
77
+ createLayers(route: PageRoute, state: ReactRouterState, previous?: PreviousLayerData[]): Promise<CreateLayersResult>;
78
+ protected getErrorHandler(route: PageRoute): ErrorHandler | undefined;
79
+ protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
80
+ renderError(error: Error): ReactNode;
81
+ renderEmptyView(): ReactNode;
82
+ href(page: {
83
+ options: {
84
+ name?: string;
85
+ };
86
+ }, params?: Record<string, any>): string;
87
+ compile(path: string, params?: Record<string, string>): string;
88
+ protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
89
+ protected readonly configure: alepha12.HookPrimitive<"configure">;
90
+ protected map(pages: Array<PagePrimitive>, target: PagePrimitive): PageRouteEntry;
91
+ add(entry: PageRouteEntry): void;
92
+ protected createMatch(page: PageRoute): string;
93
+ protected _next: number;
94
+ protected nextId(): string;
95
+ }
96
+ declare const isPageRoute: (it: any) => it is PageRoute;
97
+ interface PageRouteEntry extends Omit<PagePrimitiveOptions, "children" | "parent"> {
98
+ children?: PageRouteEntry[];
99
+ }
100
+ interface ConcretePageRoute extends PageRoute {
101
+ /**
102
+ * When exported, static routes can be split into multiple pages with different params.
103
+ * We replace 'name' by the new name for each static entry, and old 'name' becomes 'staticName'.
104
+ */
105
+ staticName?: string;
106
+ params?: Record<string, string>;
107
+ }
108
+ interface PageRoute extends PageRouteEntry {
109
+ type: "page";
110
+ name: string;
111
+ parent?: PageRoute;
112
+ match: string;
113
+ }
114
+ interface Layer {
115
+ config?: {
116
+ query?: Record<string, any>;
117
+ params?: Record<string, any>;
118
+ context?: Record<string, any>;
119
+ };
120
+ name: string;
121
+ props?: Record<string, any>;
122
+ error?: Error;
123
+ part?: string;
124
+ element: ReactNode;
125
+ index: number;
126
+ path: string;
127
+ route?: PageRoute;
128
+ cache?: boolean;
129
+ }
130
+ type PreviousLayerData = Omit<Layer, "element" | "index" | "path">;
131
+ interface AnchorProps {
132
+ href: string;
133
+ onClick: (ev?: any) => any;
134
+ }
135
+ interface ReactRouterState {
136
+ /**
137
+ * Stack of layers for the current page.
138
+ */
139
+ layers: Array<Layer>;
140
+ /**
141
+ * URL of the current page.
142
+ */
143
+ url: URL;
144
+ /**
145
+ * Error handler for the current page.
146
+ */
147
+ onError: ErrorHandler;
148
+ /**
149
+ * Params extracted from the URL for the current page.
150
+ */
151
+ params: Record<string, any>;
152
+ /**
153
+ * Query parameters extracted from the URL for the current page.
154
+ */
155
+ query: Record<string, string>;
156
+ /**
157
+ * Optional meta information associated with the current page.
158
+ */
159
+ meta: Record<string, any>;
160
+ name?: string;
161
+ }
162
+ interface RouterStackItem {
163
+ route: PageRoute;
164
+ config?: Record<string, any>;
165
+ props?: Record<string, any>;
166
+ error?: Error;
167
+ cache?: boolean;
168
+ }
169
+ interface TransitionOptions {
170
+ previous?: PreviousLayerData[];
171
+ }
172
+ interface CreateLayersResult {
173
+ redirect?: string;
174
+ state?: ReactRouterState;
175
+ }
176
+ //#endregion
177
+ //#region ../../src/router/services/ReactPageService.d.ts
178
+ /**
179
+ * $page methods interface.
180
+ */
181
+ declare abstract class ReactPageService {
182
+ fetch(pathname: string, options?: PagePrimitiveRenderOptions): Promise<{
183
+ html: string;
184
+ response: Response;
185
+ }>;
186
+ render(name: string, options?: PagePrimitiveRenderOptions): Promise<PagePrimitiveRenderResult>;
187
+ }
188
+ //#endregion
189
+ //#region ../../src/router/primitives/$page.d.ts
190
+ /**
191
+ * Main primitive for defining a React route in the application.
192
+ *
193
+ * The $page primitive is the core building block for creating type-safe, SSR-enabled React routes.
194
+ * It provides a declarative way to define pages with powerful features:
195
+ *
196
+ * **Routing & Navigation**
197
+ * - URL pattern matching with parameters (e.g., `/users/:id`)
198
+ * - Nested routing with parent-child relationships
199
+ * - Type-safe URL parameter and query string validation
200
+ *
201
+ * **Data Loading**
202
+ * - Server-side data fetching with the `resolve` function
203
+ * - Automatic serialization and hydration for SSR
204
+ * - Access to request context, URL params, and parent data
205
+ *
206
+ * **Component Loading**
207
+ * - Direct component rendering or lazy loading for code splitting
208
+ * - Client-only rendering when browser APIs are needed
209
+ * - Automatic fallback handling during hydration
210
+ *
211
+ * **Performance Optimization**
212
+ * - Static generation for pre-rendered pages at build time
213
+ * - Server-side caching with configurable TTL and providers
214
+ * - Code splitting through lazy component loading
215
+ *
216
+ * **Error Handling**
217
+ * - Custom error handlers with support for redirects
218
+ * - Hierarchical error handling (child → parent)
219
+ * - HTTP status code handling (404, 401, etc.)
220
+ *
221
+ * **Page Animations**
222
+ * - CSS-based enter/exit animations
223
+ * - Dynamic animations based on page state
224
+ * - Custom timing and easing functions
225
+ *
226
+ * **Lifecycle Management**
227
+ * - Server response hooks for headers and status codes
228
+ * - Page leave handlers for cleanup (browser only)
229
+ * - Permission-based access control
230
+ *
231
+ * @example Simple page with data fetching
232
+ * ```typescript
233
+ * const userProfile = $page({
234
+ * path: "/users/:id",
235
+ * schema: {
236
+ * params: t.object({ id: t.integer() }),
237
+ * query: t.object({ tab: t.optional(t.text()) })
238
+ * },
239
+ * resolve: async ({ params }) => {
240
+ * const user = await userApi.getUser(params.id);
241
+ * return { user };
242
+ * },
243
+ * lazy: () => import("./UserProfile.tsx")
244
+ * });
245
+ * ```
246
+ *
247
+ * @example Nested routing with error handling
248
+ * ```typescript
249
+ * const projectSection = $page({
250
+ * path: "/projects/:id",
251
+ * children: () => [projectBoard, projectSettings],
252
+ * resolve: async ({ params }) => {
253
+ * const project = await projectApi.get(params.id);
254
+ * return { project };
255
+ * },
256
+ * errorHandler: (error) => {
257
+ * if (HttpError.is(error, 404)) {
258
+ * return <ProjectNotFound />;
259
+ * }
260
+ * }
261
+ * });
262
+ * ```
263
+ *
264
+ * @example Static generation with caching
265
+ * ```typescript
266
+ * const blogPost = $page({
267
+ * path: "/blog/:slug",
268
+ * static: {
269
+ * entries: posts.map(p => ({ params: { slug: p.slug } }))
270
+ * },
271
+ * resolve: async ({ params }) => {
272
+ * const post = await loadPost(params.slug);
273
+ * return { post };
274
+ * }
275
+ * });
276
+ * ```
277
+ */
278
+ declare const $page: {
279
+ <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = TPropsParentDefault>(options: PagePrimitiveOptions<TConfig, TProps, TPropsParent>): PagePrimitive<TConfig, TProps, TPropsParent>;
280
+ [KIND]: typeof PagePrimitive;
281
+ };
282
+ interface PagePrimitiveOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
283
+ /**
284
+ * Identifier name for the page. Must be unique.
285
+ *
286
+ * @default Primitive key
287
+ */
288
+ name?: string;
289
+ /**
290
+ * Add a pathname to the page.
291
+ *
292
+ * Pathname can contain parameters, like `/post/:slug`.
293
+ *
294
+ * @default ""
295
+ */
296
+ path?: string;
297
+ /**
298
+ * Add an input schema to define:
299
+ * - `params`: parameters from the pathname.
300
+ * - `query`: query parameters from the URL.
301
+ */
302
+ schema?: TConfig;
303
+ /**
304
+ * Load data before rendering the page.
305
+ *
306
+ * This function receives
307
+ * - the request context (params, query, etc.)
308
+ * - the parent props (if page has a parent)
309
+ *
310
+ * > In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.
311
+ *
312
+ * Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.
313
+ * It's common to throw a `NotFoundError` to display a 404 page.
314
+ *
315
+ * RedirectError can be thrown to redirect the user to another page.
316
+ */
317
+ resolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;
318
+ /**
319
+ * Default props to pass to the component when rendering the page.
320
+ *
321
+ * Resolved props from the `resolve` function will override these default props.
322
+ */
323
+ props?: () => Partial<TProps>;
324
+ /**
325
+ * The component to render when the page is loaded.
326
+ *
327
+ * If `lazy` is defined, this will be ignored.
328
+ * Prefer using `lazy` to improve the initial loading time.
329
+ */
330
+ component?: FC<TProps & TPropsParent>;
331
+ /**
332
+ * Lazy load the component when the page is loaded.
333
+ *
334
+ * It's recommended to use this for components to improve the initial loading time
335
+ * and enable code-splitting.
336
+ */
337
+ lazy?: () => Promise<{
338
+ default: FC<TProps & TPropsParent>;
339
+ }>;
340
+ /**
341
+ * Attach child pages to create nested routes.
342
+ * This will make the page a parent route.
343
+ */
344
+ children?: Array<PagePrimitive> | (() => Array<PagePrimitive>);
345
+ /**
346
+ * Define a parent page for nested routing.
347
+ */
348
+ parent?: PagePrimitive<PageConfigSchema, TPropsParent, any>;
349
+ /**
350
+ * Function to determine if the page can be accessed.
351
+ *
352
+ * If it returns false, the page will not be accessible and a 403 Forbidden error will be returned.
353
+ * This function can be used to implement permission-based access control.
354
+ */
355
+ can?: () => boolean;
356
+ /**
357
+ * Catch any error from the `resolve` function or during `rendering`.
358
+ *
359
+ * Expected to return one of the following:
360
+ * - a ReactNode to render an error page
361
+ * - a Redirection to redirect the user
362
+ * - undefined to let the error propagate
363
+ *
364
+ * If not defined, the error will be thrown and handled by the server or client error handler.
365
+ * If a leaf $page does not define an error handler, the error can be caught by parent pages.
366
+ *
367
+ * @example Catch a 404 from API and render a custom not found component:
368
+ * ```ts
369
+ * resolve: async ({ params, query }) => {
370
+ * api.fetch("/api/resource", { params, query });
371
+ * },
372
+ * errorHandler: (error, context) => {
373
+ * if (HttpError.is(error, 404)) {
374
+ * return <ResourceNotFound />;
375
+ * }
376
+ * }
377
+ * ```
378
+ *
379
+ * @example Catch an 401 error and redirect the user to the login page:
380
+ * ```ts
381
+ * resolve: async ({ params, query }) => {
382
+ * // but the user is not authenticated
383
+ * api.fetch("/api/resource", { params, query });
384
+ * },
385
+ * errorHandler: (error, context) => {
386
+ * if (HttpError.is(error, 401)) {
387
+ * // throwing a Redirection is also valid!
388
+ * return new Redirection("/login");
389
+ * }
390
+ * }
391
+ * ```
392
+ */
393
+ errorHandler?: ErrorHandler;
394
+ /**
395
+ * If true, the page will be considered as a static page, immutable and cacheable.
396
+ * Replace boolean by an object to define static entries. (e.g. list of params/query)
397
+ *
398
+ * Browser-side: it only works with `alepha/vite`, which can pre-render the page at build time.
399
+ *
400
+ * Server-side: It will act as timeless cached page. You can use `cache` to configure the cache behavior.
401
+ */
402
+ static?: boolean | {
403
+ entries?: Array<Partial<PageRequestConfig<TConfig>>>;
404
+ };
405
+ cache?: ServerRouteCache;
406
+ /**
407
+ * If true, force the page to be rendered only on the client-side (browser).
408
+ * It uses the `<ClientOnly/>` component to render the page.
409
+ */
410
+ client?: boolean | ClientOnlyProps;
411
+ /**
412
+ * Called before the server response is sent to the client. (server only)
413
+ */
414
+ onServerResponse?: (request: ServerRequest) => unknown;
415
+ /**
416
+ * Called when user leaves the page. (browser only)
417
+ */
418
+ onLeave?: () => void;
419
+ /**
420
+ * @experimental
421
+ *
422
+ * Add a css animation when the page is loaded or unloaded.
423
+ * It uses CSS animations, so you need to define the keyframes in your CSS.
424
+ *
425
+ * @example Simple animation name
426
+ * ```ts
427
+ * animation: "fadeIn"
428
+ * ```
429
+ *
430
+ * CSS example:
431
+ * ```css
432
+ * @keyframes fadeIn {
433
+ * from { opacity: 0; }
434
+ * to { opacity: 1; }
435
+ * }
436
+ * ```
437
+ *
438
+ * @example Detailed animation
439
+ * ```ts
440
+ * animation: {
441
+ * enter: { name: "fadeIn", duration: 300 },
442
+ * exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
443
+ * }
444
+ * ```
445
+ *
446
+ * @example Only exit animation
447
+ * ```ts
448
+ * animation: {
449
+ * exit: "fadeOut"
450
+ * }
451
+ * ```
452
+ *
453
+ * @example With custom timing function
454
+ * ```ts
455
+ * animation: {
456
+ * enter: { name: "fadeIn", duration: 300, timing: "cubic-bezier(0.4, 0, 0.2, 1)" },
457
+ * exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
458
+ * }
459
+ * ```
460
+ */
461
+ animation?: PageAnimation;
462
+ }
463
+ type ErrorHandler = (error: Error, state: ReactRouterState) => ReactNode | Redirection | undefined;
464
+ declare class PagePrimitive<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> extends Primitive<PagePrimitiveOptions<TConfig, TProps, TPropsParent>> {
465
+ protected readonly reactPageService: ReactPageService;
466
+ protected onInit(): void;
467
+ get name(): string;
468
+ /**
469
+ * For testing or build purposes.
470
+ *
471
+ * This will render the page (HTML layout included or not) and return the HTML + context.
472
+ * Only valid for server-side rendering, it will throw an error if called on the client-side.
473
+ */
474
+ render(options?: PagePrimitiveRenderOptions): Promise<PagePrimitiveRenderResult>;
475
+ fetch(options?: PagePrimitiveRenderOptions): Promise<{
476
+ html: string;
477
+ response: Response;
478
+ }>;
479
+ match(url: string): boolean;
480
+ pathname(config: any): string;
481
+ }
482
+ interface PageConfigSchema {
483
+ query?: TSchema;
484
+ params?: TSchema;
485
+ }
486
+ type TPropsDefault = any;
487
+ type TPropsParentDefault = {};
488
+ interface PagePrimitiveRenderOptions {
489
+ params?: Record<string, string>;
490
+ query?: Record<string, string>;
491
+ /**
492
+ * If true, the HTML layout will be included in the response.
493
+ * If false, only the page content will be returned.
494
+ *
495
+ * @default true
496
+ */
497
+ html?: boolean;
498
+ hydration?: boolean;
499
+ }
500
+ interface PagePrimitiveRenderResult {
501
+ html: string;
502
+ state: ReactRouterState;
503
+ redirect?: string;
504
+ }
505
+ interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema> {
506
+ params: TConfig["params"] extends TSchema ? Static<TConfig["params"]> : Record<string, string>;
507
+ query: TConfig["query"] extends TSchema ? Static<TConfig["query"]> : Record<string, string>;
508
+ }
509
+ type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & Omit<ReactRouterState, "layers" | "onError">;
510
+ type PageAnimation = PageAnimationObject | ((state: ReactRouterState) => PageAnimationObject | undefined);
511
+ type PageAnimationObject = CssAnimationName | {
512
+ enter?: CssAnimation | CssAnimationName;
513
+ exit?: CssAnimation | CssAnimationName;
514
+ };
515
+ type CssAnimationName = string;
516
+ type CssAnimation = {
517
+ name: string;
518
+ duration?: number;
519
+ timing?: string;
520
+ };
521
+ //#endregion
522
+ //#region ../../src/router/providers/ReactBrowserRouterProvider.d.ts
523
+ interface BrowserRoute extends Route {
524
+ page: PageRoute;
525
+ }
526
+ /**
527
+ * Implementation of AlephaRouter for React in browser environment.
528
+ */
529
+ declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
530
+ protected readonly log: alepha_logger0.Logger;
531
+ protected readonly alepha: Alepha;
532
+ protected readonly pageApi: ReactPageProvider;
533
+ add(entry: PageRouteEntry): void;
534
+ protected readonly configure: alepha12.HookPrimitive<"configure">;
535
+ transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
536
+ root(state: ReactRouterState): ReactNode;
537
+ }
538
+ //#endregion
539
+ //#region ../../src/core/components/ClientOnly.d.ts
540
+ interface ClientOnlyProps$1 {
541
+ fallback?: ReactNode;
542
+ disabled?: boolean;
543
+ }
544
+ //#endregion
545
+ //#region ../../src/core/index.d.ts
546
+ declare module "alepha" {
547
+ interface Hooks {
548
+ /**
549
+ * Fires when a user action is starting.
550
+ * Action can be a form submission, a route transition, or a custom action.
551
+ */
552
+ "react:action:begin": {
553
+ type: string;
554
+ id?: string;
555
+ };
556
+ /**
557
+ * Fires when a user action has succeeded.
558
+ * Action can be a form submission, a route transition, or a custom action.
559
+ */
560
+ "react:action:success": {
561
+ type: string;
562
+ id?: string;
563
+ };
564
+ /**
565
+ * Fires when a user action has failed.
566
+ * Action can be a form submission, a route transition, or a custom action.
567
+ */
568
+ "react:action:error": {
569
+ type: string;
570
+ id?: string;
571
+ error: Error;
572
+ };
573
+ /**
574
+ * Fires when a user action has completed, regardless of success or failure.
575
+ * Action can be a form submission, a route transition, or a custom action.
576
+ */
577
+ "react:action:end": {
578
+ type: string;
579
+ id?: string;
580
+ };
581
+ }
582
+ }
583
+ /**
584
+ * Provides full-stack React development with declarative routing, server-side rendering, and client-side hydration.
585
+ *
586
+ * The React module enables building modern React applications using the `$page` primitive on class properties.
587
+ * It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full
588
+ * type safety and schema validation for route parameters and data.
589
+ *
590
+ * @see {@link $page}
591
+ * @module alepha.react
592
+ */
593
+ //#endregion
594
+ //#region ../../src/router/services/ReactRouter.d.ts
595
+ interface RouterGoOptions {
596
+ replace?: boolean;
597
+ params?: Record<string, string>;
598
+ query?: Record<string, string>;
599
+ meta?: Record<string, any>;
600
+ /**
601
+ * Recreate the whole page, ignoring the current state.
602
+ */
603
+ force?: boolean;
604
+ }
605
+ /**
606
+ * Friendly browser router API.
607
+ *
608
+ * Can be safely used server-side, but most methods will be no-op.
609
+ */
610
+ declare class ReactRouter<T$1 extends object> {
611
+ protected readonly alepha: Alepha;
612
+ protected readonly pageApi: ReactPageProvider;
613
+ get state(): ReactRouterState;
614
+ get pages(): PageRoute[];
615
+ get concretePages(): ConcretePageRoute[];
616
+ get browser(): ReactBrowserProvider | undefined;
617
+ isActive(href: string, options?: {
618
+ startWith?: boolean;
619
+ }): boolean;
620
+ node(name: keyof VirtualRouter<T$1> | string, config?: {
621
+ params?: Record<string, any>;
622
+ query?: Record<string, any>;
623
+ }): {
624
+ label: any;
625
+ children: undefined;
626
+ type: "page";
627
+ name: string;
628
+ parent?: PageRoute;
629
+ match: string;
630
+ path?: string | undefined;
631
+ schema?: PageConfigSchema | undefined;
632
+ resolve?: ((context: PageResolve<PageConfigSchema, TPropsParentDefault>) => any) | undefined;
633
+ props?: (() => Partial<any>) | undefined;
634
+ component?: react0.FC<any> | undefined;
635
+ lazy?: (() => Promise<{
636
+ default: react0.FC<any>;
637
+ }>) | undefined;
638
+ can?: (() => boolean) | undefined;
639
+ errorHandler?: ErrorHandler | undefined;
640
+ static?: boolean | {
641
+ entries?: Partial<PageRequestConfig<PageConfigSchema>>[] | undefined;
642
+ } | undefined;
643
+ cache?: alepha_server_cache0.ServerRouteCache | undefined;
644
+ client?: (boolean | ClientOnlyProps$1) | undefined;
645
+ onServerResponse?: ((request: alepha_server0.ServerRequest) => unknown) | undefined;
646
+ onLeave?: (() => void) | undefined;
647
+ animation?: PageAnimation | undefined;
648
+ } | {
649
+ label: any;
650
+ href: string;
651
+ children: undefined;
652
+ type: "page";
653
+ name: string;
654
+ parent?: PageRoute;
655
+ match: string;
656
+ path?: string | undefined;
657
+ schema?: PageConfigSchema | undefined;
658
+ resolve?: ((context: PageResolve<PageConfigSchema, TPropsParentDefault>) => any) | undefined;
659
+ props?: (() => Partial<any>) | undefined;
660
+ component?: react0.FC<any> | undefined;
661
+ lazy?: (() => Promise<{
662
+ default: react0.FC<any>;
663
+ }>) | undefined;
664
+ can?: (() => boolean) | undefined;
665
+ errorHandler?: ErrorHandler | undefined;
666
+ static?: boolean | {
667
+ entries?: Partial<PageRequestConfig<PageConfigSchema>>[] | undefined;
668
+ } | undefined;
669
+ cache?: alepha_server_cache0.ServerRouteCache | undefined;
670
+ client?: (boolean | ClientOnlyProps$1) | undefined;
671
+ onServerResponse?: ((request: alepha_server0.ServerRequest) => unknown) | undefined;
672
+ onLeave?: (() => void) | undefined;
673
+ animation?: PageAnimation | undefined;
674
+ };
675
+ path(name: keyof VirtualRouter<T$1> | string, config?: {
676
+ params?: Record<string, any>;
677
+ query?: Record<string, any>;
678
+ }): string;
679
+ /**
680
+ * Reload the current page.
681
+ * This is equivalent to calling `go()` with the current pathname and search.
682
+ */
683
+ reload(): Promise<void>;
684
+ getURL(): URL;
685
+ get location(): Location;
686
+ get current(): ReactRouterState;
687
+ get pathname(): string;
688
+ get query(): Record<string, string>;
689
+ back(): Promise<void>;
690
+ forward(): Promise<void>;
691
+ invalidate(props?: Record<string, any>): Promise<void>;
692
+ go(path: string, options?: RouterGoOptions): Promise<void>;
693
+ go(path: keyof VirtualRouter<T$1>, options?: RouterGoOptions): Promise<void>;
694
+ anchor(path: string, options?: RouterGoOptions): AnchorProps;
695
+ anchor(path: keyof VirtualRouter<T$1>, options?: RouterGoOptions): AnchorProps;
696
+ base(path: string): string;
697
+ /**
698
+ * Set query params.
699
+ *
700
+ * @param record
701
+ * @param options
702
+ */
703
+ setQueryParams(record: Record<string, any> | ((queryParams: Record<string, any>) => Record<string, any>), options?: {
704
+ /**
705
+ * If true, this will add a new entry to the history stack.
706
+ */
707
+ push?: boolean;
708
+ }): void;
709
+ }
710
+ type VirtualRouter<T$1> = { [K in keyof T$1 as T$1[K] extends PagePrimitive ? K : never]: T$1[K] };
711
+ //#endregion
712
+ //#region ../../src/router/providers/ReactBrowserProvider.d.ts
713
+ declare const envSchema$1: alepha12.TObject<{
714
+ REACT_ROOT_ID: alepha12.TString;
715
+ }>;
716
+ declare module "alepha" {
717
+ interface Env extends Partial<Static<typeof envSchema$1>> {}
718
+ }
719
+ /**
720
+ * React browser renderer configuration atom
721
+ */
722
+ declare const reactBrowserOptions: alepha12.Atom<alepha12.TObject<{
723
+ scrollRestoration: alepha12.TUnsafe<"top" | "manual">;
724
+ }>, "alepha.react.browser.options">;
725
+ type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
726
+ declare module "alepha" {
727
+ interface State {
728
+ [reactBrowserOptions.key]: ReactBrowserRendererOptions;
729
+ }
730
+ }
731
+ declare class ReactBrowserProvider {
732
+ protected readonly env: {
733
+ REACT_ROOT_ID: string;
734
+ };
735
+ protected readonly log: alepha_logger0.Logger;
736
+ protected readonly client: LinkProvider;
737
+ protected readonly alepha: Alepha;
738
+ protected readonly router: ReactBrowserRouterProvider;
739
+ protected readonly dateTimeProvider: DateTimeProvider;
740
+ protected readonly options: Readonly<{
741
+ scrollRestoration: "top" | "manual";
742
+ }>;
743
+ protected getRootElement(): HTMLElement;
744
+ transitioning?: {
745
+ to: string;
746
+ from?: string;
747
+ };
748
+ get state(): ReactRouterState;
749
+ /**
750
+ * Accessor for Document DOM API.
751
+ */
752
+ get document(): Document;
753
+ /**
754
+ * Accessor for History DOM API.
755
+ */
756
+ get history(): History;
757
+ /**
758
+ * Accessor for Location DOM API.
759
+ */
760
+ get location(): Location;
761
+ get base(): string;
762
+ get url(): string;
763
+ pushState(path: string, replace?: boolean): void;
764
+ invalidate(props?: Record<string, any>): Promise<void>;
765
+ go(url: string, options?: RouterGoOptions): Promise<void>;
766
+ protected render(options?: RouterRenderOptions): Promise<void>;
767
+ /**
768
+ * Get embedded layers from the server.
769
+ */
770
+ protected getHydrationState(): ReactHydrationState | undefined;
771
+ protected readonly onTransitionEnd: alepha12.HookPrimitive<"react:transition:end">;
772
+ readonly ready: alepha12.HookPrimitive<"ready">;
773
+ }
774
+ type ReactHydrationState = {
775
+ layers?: Array<PreviousLayerData>;
776
+ } & {
777
+ [key: string]: any;
778
+ };
779
+ interface RouterRenderOptions {
780
+ url?: string;
781
+ previous?: PreviousLayerData[];
782
+ meta?: Record<string, any>;
783
+ }
784
+ //#endregion
785
+ //#region ../../src/router/components/ErrorViewer.d.ts
786
+ interface ErrorViewerProps {
787
+ error: Error;
788
+ alepha: Alepha;
789
+ }
790
+ /**
791
+ * Error viewer component that displays error details in development mode
792
+ */
793
+ declare const ErrorViewer: ({
794
+ error,
795
+ alepha
796
+ }: ErrorViewerProps) => react_jsx_runtime0.JSX.Element;
797
+ //#endregion
798
+ //#region ../../src/router/components/Link.d.ts
799
+ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
800
+ href: string;
801
+ }
802
+ /**
803
+ * Link component for client-side navigation.
804
+ *
805
+ * It's a simple wrapper around an anchor (`<a>`) element using the `useRouter` hook.
806
+ */
807
+ declare const Link: (props: LinkProps) => react0.DetailedReactHTMLElement<{
808
+ href: string;
809
+ onClick: (ev?: any) => any;
810
+ download?: any;
811
+ hrefLang?: string | undefined;
812
+ media?: string | undefined;
813
+ ping?: string | undefined;
814
+ target?: react0.HTMLAttributeAnchorTarget | undefined;
815
+ type?: string | undefined;
816
+ referrerPolicy?: react0.HTMLAttributeReferrerPolicy | undefined;
817
+ defaultChecked?: boolean | undefined;
818
+ defaultValue?: string | number | readonly string[] | undefined;
819
+ suppressContentEditableWarning?: boolean | undefined;
820
+ suppressHydrationWarning?: boolean | undefined;
821
+ accessKey?: string | undefined;
822
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
823
+ autoFocus?: boolean | undefined;
824
+ className?: string | undefined;
825
+ contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
826
+ contextMenu?: string | undefined;
827
+ dir?: string | undefined;
828
+ draggable?: (boolean | "true" | "false") | undefined;
829
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
830
+ hidden?: boolean | undefined;
831
+ id?: string | undefined;
832
+ lang?: string | undefined;
833
+ nonce?: string | undefined;
834
+ slot?: string | undefined;
835
+ spellCheck?: (boolean | "true" | "false") | undefined;
836
+ style?: react0.CSSProperties | undefined;
837
+ tabIndex?: number | undefined;
838
+ title?: string | undefined;
839
+ translate?: "yes" | "no" | undefined;
840
+ radioGroup?: string | undefined;
841
+ role?: react0.AriaRole | undefined;
842
+ about?: string | undefined;
843
+ content?: string | undefined;
844
+ datatype?: string | undefined;
845
+ inlist?: any;
846
+ prefix?: string | undefined;
847
+ property?: string | undefined;
848
+ rel?: string | undefined;
849
+ resource?: string | undefined;
850
+ rev?: string | undefined;
851
+ typeof?: string | undefined;
852
+ vocab?: string | undefined;
853
+ autoCorrect?: string | undefined;
854
+ autoSave?: string | undefined;
855
+ color?: string | undefined;
856
+ itemProp?: string | undefined;
857
+ itemScope?: boolean | undefined;
858
+ itemType?: string | undefined;
859
+ itemID?: string | undefined;
860
+ itemRef?: string | undefined;
861
+ results?: number | undefined;
862
+ security?: string | undefined;
863
+ unselectable?: "on" | "off" | undefined;
864
+ popover?: "" | "auto" | "manual" | "hint" | undefined;
865
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
866
+ popoverTarget?: string | undefined;
867
+ inert?: boolean | undefined;
868
+ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
869
+ is?: string | undefined;
870
+ exportparts?: string | undefined;
871
+ part?: string | undefined;
872
+ "aria-activedescendant"?: string | undefined;
873
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
874
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
875
+ "aria-braillelabel"?: string | undefined;
876
+ "aria-brailleroledescription"?: string | undefined;
877
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
878
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
879
+ "aria-colcount"?: number | undefined;
880
+ "aria-colindex"?: number | undefined;
881
+ "aria-colindextext"?: string | undefined;
882
+ "aria-colspan"?: number | undefined;
883
+ "aria-controls"?: string | undefined;
884
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
885
+ "aria-describedby"?: string | undefined;
886
+ "aria-description"?: string | undefined;
887
+ "aria-details"?: string | undefined;
888
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
889
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
890
+ "aria-errormessage"?: string | undefined;
891
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
892
+ "aria-flowto"?: string | undefined;
893
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
894
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
895
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
896
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
897
+ "aria-keyshortcuts"?: string | undefined;
898
+ "aria-label"?: string | undefined;
899
+ "aria-labelledby"?: string | undefined;
900
+ "aria-level"?: number | undefined;
901
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
902
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
903
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
904
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
905
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
906
+ "aria-owns"?: string | undefined;
907
+ "aria-placeholder"?: string | undefined;
908
+ "aria-posinset"?: number | undefined;
909
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
910
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
911
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
912
+ "aria-required"?: (boolean | "true" | "false") | undefined;
913
+ "aria-roledescription"?: string | undefined;
914
+ "aria-rowcount"?: number | undefined;
915
+ "aria-rowindex"?: number | undefined;
916
+ "aria-rowindextext"?: string | undefined;
917
+ "aria-rowspan"?: number | undefined;
918
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
919
+ "aria-setsize"?: number | undefined;
920
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
921
+ "aria-valuemax"?: number | undefined;
922
+ "aria-valuemin"?: number | undefined;
923
+ "aria-valuenow"?: number | undefined;
924
+ "aria-valuetext"?: string | undefined;
925
+ children?: react0.ReactNode | undefined;
926
+ dangerouslySetInnerHTML?: {
927
+ __html: string | TrustedHTML;
928
+ } | undefined;
929
+ onCopy?: react0.ClipboardEventHandler<HTMLAnchorElement> | undefined;
930
+ onCopyCapture?: react0.ClipboardEventHandler<HTMLAnchorElement> | undefined;
931
+ onCut?: react0.ClipboardEventHandler<HTMLAnchorElement> | undefined;
932
+ onCutCapture?: react0.ClipboardEventHandler<HTMLAnchorElement> | undefined;
933
+ onPaste?: react0.ClipboardEventHandler<HTMLAnchorElement> | undefined;
934
+ onPasteCapture?: react0.ClipboardEventHandler<HTMLAnchorElement> | undefined;
935
+ onCompositionEnd?: react0.CompositionEventHandler<HTMLAnchorElement> | undefined;
936
+ onCompositionEndCapture?: react0.CompositionEventHandler<HTMLAnchorElement> | undefined;
937
+ onCompositionStart?: react0.CompositionEventHandler<HTMLAnchorElement> | undefined;
938
+ onCompositionStartCapture?: react0.CompositionEventHandler<HTMLAnchorElement> | undefined;
939
+ onCompositionUpdate?: react0.CompositionEventHandler<HTMLAnchorElement> | undefined;
940
+ onCompositionUpdateCapture?: react0.CompositionEventHandler<HTMLAnchorElement> | undefined;
941
+ onFocus?: react0.FocusEventHandler<HTMLAnchorElement> | undefined;
942
+ onFocusCapture?: react0.FocusEventHandler<HTMLAnchorElement> | undefined;
943
+ onBlur?: react0.FocusEventHandler<HTMLAnchorElement> | undefined;
944
+ onBlurCapture?: react0.FocusEventHandler<HTMLAnchorElement> | undefined;
945
+ onChange?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
946
+ onChangeCapture?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
947
+ onBeforeInput?: react0.InputEventHandler<HTMLAnchorElement> | undefined;
948
+ onBeforeInputCapture?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
949
+ onInput?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
950
+ onInputCapture?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
951
+ onReset?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
952
+ onResetCapture?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
953
+ onSubmit?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
954
+ onSubmitCapture?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
955
+ onInvalid?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
956
+ onInvalidCapture?: react0.FormEventHandler<HTMLAnchorElement> | undefined;
957
+ onLoad?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
958
+ onLoadCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
959
+ onError?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
960
+ onErrorCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
961
+ onKeyDown?: react0.KeyboardEventHandler<HTMLAnchorElement> | undefined;
962
+ onKeyDownCapture?: react0.KeyboardEventHandler<HTMLAnchorElement> | undefined;
963
+ onKeyPress?: react0.KeyboardEventHandler<HTMLAnchorElement> | undefined;
964
+ onKeyPressCapture?: react0.KeyboardEventHandler<HTMLAnchorElement> | undefined;
965
+ onKeyUp?: react0.KeyboardEventHandler<HTMLAnchorElement> | undefined;
966
+ onKeyUpCapture?: react0.KeyboardEventHandler<HTMLAnchorElement> | undefined;
967
+ onAbort?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
968
+ onAbortCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
969
+ onCanPlay?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
970
+ onCanPlayCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
971
+ onCanPlayThrough?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
972
+ onCanPlayThroughCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
973
+ onDurationChange?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
974
+ onDurationChangeCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
975
+ onEmptied?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
976
+ onEmptiedCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
977
+ onEncrypted?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
978
+ onEncryptedCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
979
+ onEnded?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
980
+ onEndedCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
981
+ onLoadedData?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
982
+ onLoadedDataCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
983
+ onLoadedMetadata?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
984
+ onLoadedMetadataCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
985
+ onLoadStart?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
986
+ onLoadStartCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
987
+ onPause?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
988
+ onPauseCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
989
+ onPlay?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
990
+ onPlayCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
991
+ onPlaying?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
992
+ onPlayingCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
993
+ onProgress?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
994
+ onProgressCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
995
+ onRateChange?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
996
+ onRateChangeCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
997
+ onSeeked?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
998
+ onSeekedCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
999
+ onSeeking?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1000
+ onSeekingCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1001
+ onStalled?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1002
+ onStalledCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1003
+ onSuspend?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1004
+ onSuspendCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1005
+ onTimeUpdate?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1006
+ onTimeUpdateCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1007
+ onVolumeChange?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1008
+ onVolumeChangeCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1009
+ onWaiting?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1010
+ onWaitingCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1011
+ onAuxClick?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1012
+ onAuxClickCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1013
+ onClickCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1014
+ onContextMenu?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1015
+ onContextMenuCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1016
+ onDoubleClick?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1017
+ onDoubleClickCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1018
+ onDrag?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1019
+ onDragCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1020
+ onDragEnd?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1021
+ onDragEndCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1022
+ onDragEnter?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1023
+ onDragEnterCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1024
+ onDragExit?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1025
+ onDragExitCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1026
+ onDragLeave?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1027
+ onDragLeaveCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1028
+ onDragOver?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1029
+ onDragOverCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1030
+ onDragStart?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1031
+ onDragStartCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1032
+ onDrop?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1033
+ onDropCapture?: react0.DragEventHandler<HTMLAnchorElement> | undefined;
1034
+ onMouseDown?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1035
+ onMouseDownCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1036
+ onMouseEnter?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1037
+ onMouseLeave?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1038
+ onMouseMove?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1039
+ onMouseMoveCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1040
+ onMouseOut?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1041
+ onMouseOutCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1042
+ onMouseOver?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1043
+ onMouseOverCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1044
+ onMouseUp?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1045
+ onMouseUpCapture?: react0.MouseEventHandler<HTMLAnchorElement> | undefined;
1046
+ onSelect?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1047
+ onSelectCapture?: react0.ReactEventHandler<HTMLAnchorElement> | undefined;
1048
+ onTouchCancel?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1049
+ onTouchCancelCapture?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1050
+ onTouchEnd?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1051
+ onTouchEndCapture?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1052
+ onTouchMove?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1053
+ onTouchMoveCapture?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1054
+ onTouchStart?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1055
+ onTouchStartCapture?: react0.TouchEventHandler<HTMLAnchorElement> | undefined;
1056
+ onPointerDown?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1057
+ onPointerDownCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1058
+ onPointerMove?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1059
+ onPointerMoveCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1060
+ onPointerUp?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1061
+ onPointerUpCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1062
+ onPointerCancel?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1063
+ onPointerCancelCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1064
+ onPointerEnter?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1065
+ onPointerLeave?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1066
+ onPointerOver?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1067
+ onPointerOverCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1068
+ onPointerOut?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1069
+ onPointerOutCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1070
+ onGotPointerCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1071
+ onGotPointerCaptureCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1072
+ onLostPointerCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1073
+ onLostPointerCaptureCapture?: react0.PointerEventHandler<HTMLAnchorElement> | undefined;
1074
+ onScroll?: react0.UIEventHandler<HTMLAnchorElement> | undefined;
1075
+ onScrollCapture?: react0.UIEventHandler<HTMLAnchorElement> | undefined;
1076
+ onScrollEnd?: react0.UIEventHandler<HTMLAnchorElement> | undefined;
1077
+ onScrollEndCapture?: react0.UIEventHandler<HTMLAnchorElement> | undefined;
1078
+ onWheel?: react0.WheelEventHandler<HTMLAnchorElement> | undefined;
1079
+ onWheelCapture?: react0.WheelEventHandler<HTMLAnchorElement> | undefined;
1080
+ onAnimationStart?: react0.AnimationEventHandler<HTMLAnchorElement> | undefined;
1081
+ onAnimationStartCapture?: react0.AnimationEventHandler<HTMLAnchorElement> | undefined;
1082
+ onAnimationEnd?: react0.AnimationEventHandler<HTMLAnchorElement> | undefined;
1083
+ onAnimationEndCapture?: react0.AnimationEventHandler<HTMLAnchorElement> | undefined;
1084
+ onAnimationIteration?: react0.AnimationEventHandler<HTMLAnchorElement> | undefined;
1085
+ onAnimationIterationCapture?: react0.AnimationEventHandler<HTMLAnchorElement> | undefined;
1086
+ onToggle?: react0.ToggleEventHandler<HTMLAnchorElement> | undefined;
1087
+ onBeforeToggle?: react0.ToggleEventHandler<HTMLAnchorElement> | undefined;
1088
+ onTransitionCancel?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1089
+ onTransitionCancelCapture?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1090
+ onTransitionEnd?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1091
+ onTransitionEndCapture?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1092
+ onTransitionRun?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1093
+ onTransitionRunCapture?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1094
+ onTransitionStart?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1095
+ onTransitionStartCapture?: react0.TransitionEventHandler<HTMLAnchorElement> | undefined;
1096
+ }, HTMLElement>;
1097
+ //#endregion
1098
+ //#region ../../src/router/components/NestedView.d.ts
1099
+ interface NestedViewProps {
1100
+ children?: ReactNode;
1101
+ errorBoundary?: false | ((error: Error) => ReactNode);
1102
+ }
1103
+ declare const _default: react0.MemoExoticComponent<(props: NestedViewProps) => react_jsx_runtime0.JSX.Element>;
1104
+ //#endregion
1105
+ //#region ../../src/router/components/NotFound.d.ts
1106
+ /**
1107
+ * Default 404 Not Found page component.
1108
+ */
1109
+ declare const NotFound: (props: {
1110
+ style?: CSSProperties;
1111
+ }) => react_jsx_runtime0.JSX.Element;
1112
+ //#endregion
1113
+ //#region ../../src/router/contexts/RouterLayerContext.d.ts
1114
+ interface RouterLayerContextValue {
1115
+ index: number;
1116
+ path: string;
1117
+ onError: ErrorHandler;
1118
+ }
1119
+ declare const RouterLayerContext: react0.Context<RouterLayerContextValue | undefined>;
1120
+ //#endregion
1121
+ //#region ../../src/router/hooks/useActive.d.ts
1122
+ interface UseActiveOptions {
1123
+ href: string;
1124
+ startWith?: boolean;
1125
+ }
1126
+ /**
1127
+ * Hook to determine if a given route is active and to provide anchor props for navigation.
1128
+ * This hook refreshes on router state changes.
1129
+ */
1130
+ declare const useActive: (args: string | UseActiveOptions) => UseActiveHook;
1131
+ interface UseActiveHook {
1132
+ isActive: boolean;
1133
+ anchorProps: AnchorProps;
1134
+ isPending: boolean;
1135
+ }
1136
+ //#endregion
1137
+ //#region ../../src/router/hooks/useQueryParams.d.ts
1138
+ /**
1139
+ * Hook to manage query parameters in the URL using a defined schema.
1140
+ */
1141
+ declare const useQueryParams: <T$1 extends TObject>(schema: T$1, options?: UseQueryParamsHookOptions) => [Partial<Static<T$1>>, (data: Static<T$1>) => void];
1142
+ interface UseQueryParamsHookOptions {
1143
+ format?: "base64" | "querystring";
1144
+ key?: string;
1145
+ push?: boolean;
1146
+ }
1147
+ //#endregion
1148
+ //#region ../../src/router/hooks/useRouter.d.ts
1149
+ /**
1150
+ * Use this hook to access the React Router instance.
1151
+ *
1152
+ * You can add a type parameter to specify the type of your application.
1153
+ * This will allow you to use the router in a typesafe way.
1154
+ *
1155
+ * @example
1156
+ * class App {
1157
+ * home = $page();
1158
+ * }
1159
+ *
1160
+ * const router = useRouter<App>();
1161
+ * router.go("home"); // typesafe
1162
+ */
1163
+ declare const useRouter: <T$1 extends object = any>() => ReactRouter<T$1>;
1164
+ //#endregion
1165
+ //#region ../../src/router/hooks/useRouterState.d.ts
1166
+ declare const useRouterState: () => ReactRouterState;
1167
+ //#endregion
1168
+ //#region ../../src/router/providers/ReactServerProvider.d.ts
1169
+ declare const envSchema: alepha12.TObject<{
1170
+ REACT_SSR_ENABLED: alepha12.TOptional<alepha12.TBoolean>;
1171
+ REACT_ROOT_ID: alepha12.TString;
1172
+ }>;
1173
+ declare module "alepha" {
1174
+ interface Env extends Partial<Static<typeof envSchema>> {}
1175
+ interface State {
1176
+ "alepha.react.server.ssr"?: boolean;
1177
+ "alepha.react.server.template"?: string;
1178
+ }
1179
+ }
1180
+ /**
1181
+ * React server provider configuration atom
1182
+ */
1183
+ declare const reactServerOptions: alepha12.Atom<alepha12.TObject<{
1184
+ publicDir: alepha12.TString;
1185
+ staticServer: alepha12.TObject<{
1186
+ disabled: alepha12.TBoolean;
1187
+ path: alepha12.TString;
1188
+ }>;
1189
+ }>, "alepha.react.server.options">;
1190
+ type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
1191
+ declare module "alepha" {
1192
+ interface State {
1193
+ [reactServerOptions.key]: ReactServerProviderOptions;
1194
+ }
1195
+ }
1196
+ /**
1197
+ * React server provider responsible for SSR and static file serving.
1198
+ *
1199
+ * Use `react-dom/server` under the hood.
1200
+ */
1201
+ declare class ReactServerProvider {
1202
+ protected readonly log: alepha_logger0.Logger;
1203
+ protected readonly alepha: Alepha;
1204
+ protected readonly env: {
1205
+ REACT_SSR_ENABLED?: boolean | undefined;
1206
+ REACT_ROOT_ID: string;
1207
+ };
1208
+ protected readonly pageApi: ReactPageProvider;
1209
+ protected readonly serverStaticProvider: ServerStaticProvider;
1210
+ protected readonly serverRouterProvider: ServerRouterProvider;
1211
+ protected readonly serverTimingProvider: ServerTimingProvider;
1212
+ readonly ROOT_DIV_REGEX: RegExp;
1213
+ protected preprocessedTemplate: PreprocessedTemplate | null;
1214
+ protected readonly options: Readonly<{
1215
+ publicDir: string;
1216
+ staticServer: {
1217
+ disabled: boolean;
1218
+ path: string;
1219
+ };
1220
+ }>;
1221
+ /**
1222
+ * Configure the React server provider.
1223
+ */
1224
+ readonly onConfigure: alepha12.HookPrimitive<"configure">;
1225
+ get template(): string;
1226
+ protected registerPages(templateLoader: TemplateLoader): Promise<void>;
1227
+ /**
1228
+ * Get the public directory path where static files are located.
1229
+ */
1230
+ protected getPublicDirectory(): string;
1231
+ /**
1232
+ * Configure the static file server to serve files from the given root directory.
1233
+ */
1234
+ protected configureStaticServer(root: string): Promise<void>;
1235
+ /**
1236
+ * Configure Vite for SSR.
1237
+ */
1238
+ protected configureVite(ssrEnabled: boolean): Promise<void>;
1239
+ /**
1240
+ * For testing purposes, creates a render function that can be used.
1241
+ */
1242
+ render(name: string, options?: PagePrimitiveRenderOptions): Promise<PagePrimitiveRenderResult>;
1243
+ protected createHandler(route: PageRoute, templateLoader: TemplateLoader): ServerHandler;
1244
+ renderToHtml(template: string, state: ReactRouterState, hydration?: boolean): string | Redirection;
1245
+ protected preprocessTemplate(template: string): PreprocessedTemplate;
1246
+ protected fillTemplate(response: {
1247
+ html: string;
1248
+ }, app: string, script: string): void;
1249
+ }
1250
+ type TemplateLoader = () => Promise<string | undefined>;
1251
+ interface PreprocessedTemplate {
1252
+ beforeApp: string;
1253
+ afterApp: string;
1254
+ beforeScript: string;
1255
+ afterScript: string;
1256
+ }
1257
+ //#endregion
1258
+ //#region ../../src/router/index.d.ts
1259
+ declare module "alepha" {
1260
+ interface State {
1261
+ "alepha.react.router.state"?: ReactRouterState;
1262
+ }
1263
+ interface Hooks {
1264
+ /**
1265
+ * Fires when the React application is starting to be rendered on the server.
1266
+ */
1267
+ "react:server:render:begin": {
1268
+ request?: ServerRequest;
1269
+ state: ReactRouterState;
1270
+ };
1271
+ /**
1272
+ * Fires when the React application has been rendered on the server.
1273
+ */
1274
+ "react:server:render:end": {
1275
+ request?: ServerRequest;
1276
+ state: ReactRouterState;
1277
+ html: string;
1278
+ };
1279
+ /**
1280
+ * Fires when the React application is being rendered on the browser.
1281
+ */
1282
+ "react:browser:render": {
1283
+ root: HTMLElement;
1284
+ element: ReactNode;
1285
+ state: ReactRouterState;
1286
+ hydration?: ReactHydrationState;
1287
+ };
1288
+ /**
1289
+ * Fires when a route transition is starting.
1290
+ */
1291
+ "react:transition:begin": {
1292
+ previous: ReactRouterState;
1293
+ state: ReactRouterState;
1294
+ animation?: PageAnimation;
1295
+ };
1296
+ /**
1297
+ * Fires when a route transition has succeeded.
1298
+ */
1299
+ "react:transition:success": {
1300
+ state: ReactRouterState;
1301
+ };
1302
+ /**
1303
+ * Fires when a route transition has failed.
1304
+ */
1305
+ "react:transition:error": {
1306
+ state: ReactRouterState;
1307
+ error: Error;
1308
+ };
1309
+ /**
1310
+ * Fires when a route transition has completed, regardless of success or failure.
1311
+ */
1312
+ "react:transition:end": {
1313
+ state: ReactRouterState;
1314
+ };
1315
+ }
1316
+ }
1317
+ /**
1318
+ * Provides declarative routing with the `$page` primitive for building type-safe React routes.
1319
+ *
1320
+ * This module enables:
1321
+ * - URL pattern matching with parameters (e.g., `/users/:id`)
1322
+ * - Nested routing with parent-child relationships
1323
+ * - Type-safe URL parameter and query string validation
1324
+ * - Server-side data fetching with the `resolve` function
1325
+ * - Lazy loading and code splitting
1326
+ * - Page animations and error handling
1327
+ *
1328
+ * @see {@link $page}
1329
+ * @module alepha.react.router
1330
+ */
1331
+ declare const AlephaReactRouter: alepha12.Service<alepha12.Module>;
1332
+ //#endregion
1333
+ export { $page, AlephaReactRouter, AnchorProps, ConcretePageRoute, CreateLayersResult, ErrorHandler, ErrorViewer, Layer, Link, type LinkProps, _default as NestedView, NestedViewProps, NotFound, PageAnimation, PageConfigSchema, PagePrimitive, PagePrimitiveOptions, PagePrimitiveRenderOptions, PagePrimitiveRenderResult, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactBrowserRendererOptions, ReactHydrationState, ReactPageProvider, ReactPageService, ReactRouter, ReactRouterState, ReactServerProvider, ReactServerProviderOptions, Redirection, type RouterGoOptions, RouterLayerContext, RouterLayerContextValue, RouterRenderOptions, RouterStackItem, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActiveHook, UseActiveOptions, UseQueryParamsHookOptions, VirtualRouter, isPageRoute, reactBrowserOptions, reactServerOptions, useActive, useQueryParams, useRouter, useRouterState };
1334
+ //# sourceMappingURL=index.d.ts.map