@alepha/react 0.7.5 → 0.7.7

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/dist/index.d.ts CHANGED
@@ -1,87 +1,26 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { TSchema as TSchema$1, KIND, OPTIONS, Static, Async, Alepha, Service, TObject, Module } from '@alepha/core';
3
- import { ServerRequest, ApiLinksResponse, HttpClient, ClientScope, HttpVirtualClient, ServerRouterProvider, ServerTimingProvider, ServerHandler } from '@alepha/server';
4
- import * as React from 'react';
5
- import React__default, { PropsWithChildren, ReactNode, FC, ErrorInfo, AnchorHTMLAttributes } from 'react';
6
- import { ServerRouteCache } from '@alepha/server-cache';
7
- import { Root } from 'react-dom/client';
8
- import { RouterProvider, Route } from '@alepha/router';
9
- import * as react_jsx_runtime from 'react/jsx-runtime';
10
- import { ServerStaticProvider } from '@alepha/server-static';
11
-
12
- /** Symbol key applied to readonly types */
13
- declare const ReadonlyKind: unique symbol;
14
- /** Symbol key applied to optional types */
15
- declare const OptionalKind: unique symbol;
16
- /** Symbol key applied to types */
17
- declare const Hint: unique symbol;
18
- /** Symbol key applied to types */
19
- declare const Kind: unique symbol;
20
-
21
- type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
22
- type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
23
- interface StringOptions extends SchemaOptions {
24
- /** The maximum string length */
25
- maxLength?: number;
26
- /** The minimum string length */
27
- minLength?: number;
28
- /** A regular expression pattern this string should match */
29
- pattern?: string;
30
- /** A format this string should match */
31
- format?: StringFormatOption;
32
- /** The content encoding for this string */
33
- contentEncoding?: StringContentEncodingOption;
34
- /** The content media type for this string */
35
- contentMediaType?: string;
36
- }
37
- interface TString extends TSchema, StringOptions {
38
- [Kind]: 'String';
39
- static: string;
40
- type: 'string';
41
- }
42
-
43
- interface TBoolean extends TSchema {
44
- [Kind]: 'Boolean';
45
- static: boolean;
46
- type: 'boolean';
47
- }
48
-
49
- type TOptional<T extends TSchema> = T & {
50
- [OptionalKind]: 'Optional';
51
- };
52
-
53
- interface SchemaOptions {
54
- $schema?: string;
55
- /** Id for this schema */
56
- $id?: string;
57
- /** Title of this schema */
58
- title?: string;
59
- /** Description of this schema */
60
- description?: string;
61
- /** Default value for this schema */
62
- default?: any;
63
- /** Example values matching this schema */
64
- examples?: any;
65
- /** Optional annotation for readOnly */
66
- readOnly?: boolean;
67
- /** Optional annotation for writeOnly */
68
- writeOnly?: boolean;
69
- [prop: string]: any;
70
- }
71
- interface TKind {
72
- [Kind]: string;
73
- }
74
- interface TSchema extends TKind, SchemaOptions {
75
- [ReadonlyKind]?: string;
76
- [OptionalKind]?: string;
77
- [Hint]?: string;
78
- params: unknown[];
79
- static: unknown;
80
- }
1
+ import * as _alepha_core12 from "@alepha/core";
2
+ import * as _alepha_core23 from "@alepha/core";
3
+ import * as _alepha_core16 from "@alepha/core";
4
+ import * as _alepha_core6 from "@alepha/core";
5
+ import { Alepha, Async, KIND, Module, OPTIONS, Service, Static, TObject, TSchema } from "@alepha/core";
6
+ import { ApiLinksResponse, ServerHandler, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "@alepha/server";
7
+ import { ServerRouteCache } from "@alepha/server-cache";
8
+ import * as react19 from "react";
9
+ import * as react20 from "react";
10
+ import React, { AnchorHTMLAttributes, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
11
+ import * as react_jsx_runtime22 from "react/jsx-runtime";
12
+ import * as react_jsx_runtime21 from "react/jsx-runtime";
13
+ import { ClientScope, HttpVirtualClient, LinkProvider } from "@alepha/server-links";
14
+ import { ServerStaticProvider } from "@alepha/server-static";
15
+ import { Route, RouterProvider } from "@alepha/router";
16
+ import * as _sinclair_typebox11 from "@sinclair/typebox";
17
+ import * as _sinclair_typebox1 from "@sinclair/typebox";
18
+ import { Root } from "react-dom/client";
81
19
 
20
+ //#region src/components/ClientOnly.d.ts
82
21
  interface ClientOnlyProps {
83
- fallback?: ReactNode;
84
- disabled?: boolean;
22
+ fallback?: ReactNode;
23
+ disabled?: boolean;
85
24
  }
86
25
  /**
87
26
  * A small utility component that renders its children only on the client side.
@@ -94,397 +33,343 @@ interface ClientOnlyProps {
94
33
  * - you want to prevent pre-rendering of a component
95
34
  */
96
35
  declare const ClientOnly: (props: PropsWithChildren<ClientOnlyProps>) => ReactNode;
97
-
36
+ //#endregion
37
+ //#region src/descriptors/$page.d.ts
98
38
  declare const KEY = "PAGE";
99
39
  interface PageConfigSchema {
100
- query?: TSchema$1;
101
- params?: TSchema$1;
40
+ query?: TSchema;
41
+ params?: TSchema;
102
42
  }
103
43
  type TPropsDefault = any;
104
44
  type TPropsParentDefault = {};
105
45
  interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
106
- /**
107
- * Name your page.
108
- *
109
- * @default Descriptor key
110
- */
111
- name?: string;
112
- /**
113
- * Optional description of the page.
114
- */
115
- description?: string;
116
- /**
117
- * Add a pathname to the page.
118
- *
119
- * Pathname can contain parameters, like `/post/:slug`.
120
- *
121
- * @default ""
122
- */
123
- path?: string;
124
- /**
125
- * Add an input schema to define:
126
- * - `params`: parameters from the pathname.
127
- * - `query`: query parameters from the URL.
128
- */
129
- schema?: TConfig;
130
- /**
131
- * Load data before rendering the page.
132
- *
133
- * This function receives
134
- * - the request context and
135
- * - the parent props (if page has a parent)
136
- *
137
- * In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.
138
- *
139
- * Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.
140
- * It's common to throw a `NotFoundError` to display a 404 page.
141
- *
142
- * RedirectError can be thrown to redirect the user to another page.
143
- */
144
- resolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;
145
- /**
146
- * The component to render when the page is loaded.
147
- *
148
- * If `lazy` is defined, this will be ignored.
149
- * Prefer using `lazy` to improve the initial loading time.
150
- */
151
- component?: FC<TProps & TPropsParent>;
152
- /**
153
- * Lazy load the component when the page is loaded.
154
- *
155
- * It's recommended to use this for components to improve the initial loading time
156
- * and enable code-splitting.
157
- */
158
- lazy?: () => Promise<{
159
- default: FC<TProps & TPropsParent>;
160
- }>;
161
- /**
162
- * Set some children pages and make the page a parent page.
163
- *
164
- * /!\ Parent page can't be rendered directly. /!\
165
- *
166
- * If you still want to render at this pathname, add a child page with an empty path.
167
- */
168
- children?: Array<{
169
- [OPTIONS]: PageDescriptorOptions;
170
- }>;
171
- parent?: {
172
- [OPTIONS]: PageDescriptorOptions<PageConfigSchema, TPropsParent>;
173
- };
174
- can?: () => boolean;
175
- head?: Head$1 | ((props: TProps, previous?: Head$1) => Head$1);
176
- errorHandler?: (error: Error) => ReactNode;
177
- prerender?: boolean | {
178
- entries?: Array<Partial<PageRequestConfig<TConfig>>>;
179
- };
180
- /**
181
- * If true, the page will be rendered on the client-side.
182
- */
183
- client?: boolean | ClientOnlyProps;
184
- afterHandler?: (request: ServerRequest) => any;
185
- cache?: ServerRouteCache;
46
+ /**
47
+ * Name your page.
48
+ *
49
+ * @default Descriptor key
50
+ */
51
+ name?: string;
52
+ /**
53
+ * Optional description of the page.
54
+ */
55
+ description?: string;
56
+ /**
57
+ * Add a pathname to the page.
58
+ *
59
+ * Pathname can contain parameters, like `/post/:slug`.
60
+ *
61
+ * @default ""
62
+ */
63
+ path?: string;
64
+ /**
65
+ * Add an input schema to define:
66
+ * - `params`: parameters from the pathname.
67
+ * - `query`: query parameters from the URL.
68
+ */
69
+ schema?: TConfig;
70
+ /**
71
+ * Load data before rendering the page.
72
+ *
73
+ * This function receives
74
+ * - the request context and
75
+ * - the parent props (if page has a parent)
76
+ *
77
+ * In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.
78
+ *
79
+ * Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.
80
+ * It's common to throw a `NotFoundError` to display a 404 page.
81
+ *
82
+ * RedirectError can be thrown to redirect the user to another page.
83
+ */
84
+ resolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;
85
+ /**
86
+ * The component to render when the page is loaded.
87
+ *
88
+ * If `lazy` is defined, this will be ignored.
89
+ * Prefer using `lazy` to improve the initial loading time.
90
+ */
91
+ component?: FC<TProps & TPropsParent>;
92
+ /**
93
+ * Lazy load the component when the page is loaded.
94
+ *
95
+ * It's recommended to use this for components to improve the initial loading time
96
+ * and enable code-splitting.
97
+ */
98
+ lazy?: () => Promise<{
99
+ default: FC<TProps & TPropsParent>;
100
+ }>;
101
+ /**
102
+ * Set some children pages and make the page a parent page.
103
+ *
104
+ * /!\ Parent page can't be rendered directly. /!\
105
+ *
106
+ * If you still want to render at this pathname, add a child page with an empty path.
107
+ */
108
+ children?: Array<{
109
+ [OPTIONS]: PageDescriptorOptions;
110
+ }>;
111
+ parent?: {
112
+ [OPTIONS]: PageDescriptorOptions<PageConfigSchema, TPropsParent>;
113
+ };
114
+ can?: () => boolean;
115
+ errorHandler?: (error: Error) => ReactNode;
116
+ prerender?: boolean | {
117
+ entries?: Array<Partial<PageRequestConfig<TConfig>>>;
118
+ };
119
+ /**
120
+ * If true, the page will be rendered on the client-side.
121
+ */
122
+ client?: boolean | ClientOnlyProps;
123
+ afterHandler?: (request: ServerRequest) => any;
124
+ cache?: ServerRouteCache;
186
125
  }
187
126
  interface PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
188
- [KIND]: typeof KEY;
189
- [OPTIONS]: PageDescriptorOptions<TConfig, TProps, TPropsParent>;
190
- /**
191
- * For testing or build purposes, this will render the page (with or without the HTML layout) and return the HTML and context.
192
- * Only valid for server-side rendering, it will throw an error if called on the client-side.
193
- */
194
- render: (options?: PageDescriptorRenderOptions) => Promise<PageDescriptorRenderResult>;
127
+ [KIND]: typeof KEY;
128
+ [OPTIONS]: PageDescriptorOptions<TConfig, TProps, TPropsParent>;
129
+ /**
130
+ * For testing or build purposes, this will render the page (with or without the HTML layout) and return the HTML and context.
131
+ * Only valid for server-side rendering, it will throw an error if called on the client-side.
132
+ */
133
+ render: (options?: PageDescriptorRenderOptions) => Promise<PageDescriptorRenderResult>;
195
134
  }
196
135
  /**
197
136
  * Main descriptor for defining a React route in the application.
198
137
  */
199
138
  declare const $page: {
200
- <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = TPropsParentDefault>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
201
- [KIND]: string;
139
+ <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = TPropsParentDefault>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
140
+ [KIND]: string;
202
141
  };
203
142
  interface PageDescriptorRenderOptions {
204
- params?: Record<string, string>;
205
- query?: Record<string, string>;
206
- withLayout?: boolean;
143
+ params?: Record<string, string>;
144
+ query?: Record<string, string>;
145
+ html?: boolean;
146
+ hydration?: boolean;
207
147
  }
208
148
  interface PageDescriptorRenderResult {
209
- html: string;
210
- context: PageReactContext;
211
- }
212
- interface Head$1 {
213
- title?: string;
214
- description?: string;
215
- titleSeparator?: string;
216
- htmlAttributes?: Record<string, string>;
217
- bodyAttributes?: Record<string, string>;
218
- meta?: Array<{
219
- name: string;
220
- content: string;
221
- }>;
222
- keywords?: string[];
223
- author?: string;
224
- robots?: string;
225
- themeColor?: string;
226
- viewport?: string | {
227
- width?: string;
228
- height?: string;
229
- initialScale?: string;
230
- maximumScale?: string;
231
- userScalable?: "no" | "yes" | "0" | "1";
232
- interactiveWidget?: "resizes-visual" | "resizes-content" | "overlays-content";
233
- };
234
- og?: {
235
- title?: string;
236
- description?: string;
237
- image?: string;
238
- url?: string;
239
- type?: string;
240
- };
241
- twitter?: {
242
- card?: string;
243
- title?: string;
244
- description?: string;
245
- image?: string;
246
- site?: string;
247
- };
149
+ html: string;
150
+ context: PageReactContext;
248
151
  }
249
152
  interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema> {
250
- params: TConfig["params"] extends TSchema$1 ? Static<TConfig["params"]> : Record<string, string>;
251
- query: TConfig["query"] extends TSchema$1 ? Static<TConfig["query"]> : Record<string, string>;
153
+ params: TConfig["params"] extends TSchema ? Static<TConfig["params"]> : Record<string, string>;
154
+ query: TConfig["query"] extends TSchema ? Static<TConfig["query"]> : Record<string, string>;
252
155
  }
253
156
  type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & PageReactContext;
254
-
255
- declare const envSchema$1: _alepha_core.TObject<{
256
- REACT_STRICT_MODE: TBoolean;
157
+ //#endregion
158
+ //#region src/providers/PageDescriptorProvider.d.ts
159
+ declare const envSchema$1: _alepha_core12.TObject<{
160
+ REACT_STRICT_MODE: _sinclair_typebox11.TBoolean;
257
161
  }>;
258
162
  declare module "@alepha/core" {
259
- interface Env extends Partial<Static<typeof envSchema$1>> {
260
- }
163
+ interface Env extends Partial<Static<typeof envSchema$1>> {}
261
164
  }
262
165
  declare class PageDescriptorProvider {
263
- protected readonly log: _alepha_core.Logger;
264
- protected readonly env: {
265
- REACT_STRICT_MODE: boolean;
166
+ protected readonly log: _alepha_core12.Logger;
167
+ protected readonly env: {
168
+ REACT_STRICT_MODE: boolean;
169
+ };
170
+ protected readonly alepha: Alepha;
171
+ protected readonly pages: PageRoute[];
172
+ getPages(): PageRoute[];
173
+ page(name: string): PageRoute;
174
+ url(name: string, options?: {
175
+ params?: Record<string, string>;
176
+ base?: string;
177
+ }): URL;
178
+ root(state: RouterState, context: PageReactContext): ReactNode;
179
+ createLayers(route: PageRoute, request: PageRequest): Promise<CreateLayersResult>;
180
+ protected getErrorHandler(route: PageRoute): ((error: Error) => ReactNode) | undefined;
181
+ protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
182
+ renderError(error: Error): ReactNode;
183
+ renderEmptyView(): ReactNode;
184
+ href(page: {
185
+ options: {
186
+ name?: string;
266
187
  };
267
- protected readonly alepha: Alepha;
268
- protected readonly pages: PageRoute[];
269
- getPages(): PageRoute[];
270
- page(name: string): PageRoute;
271
- url(name: string, options?: {
272
- params?: Record<string, string>;
273
- base?: string;
274
- }): URL;
275
- root(state: RouterState, context: PageReactContext): ReactNode;
276
- createLayers(route: PageRoute, request: PageRequest): Promise<CreateLayersResult>;
277
- protected getErrorHandler(route: PageRoute): ((error: Error) => ReactNode) | undefined;
278
- protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
279
- protected fillHead(page: PageRoute, ctx: PageRequest, props: Record<string, any>): void;
280
- renderError(error: Error): ReactNode;
281
- renderEmptyView(): ReactNode;
282
- href(page: {
283
- options: {
284
- name?: string;
285
- };
286
- }, params?: Record<string, any>): string;
287
- compile(path: string, params?: Record<string, string>): string;
288
- protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
289
- protected readonly configure: _alepha_core.HookDescriptor<"configure">;
290
- protected map(pages: Array<{
291
- value: {
292
- [OPTIONS]: PageDescriptorOptions;
293
- };
294
- }>, target: {
295
- [OPTIONS]: PageDescriptorOptions;
296
- }): PageRouteEntry;
297
- add(entry: PageRouteEntry): void;
298
- protected createMatch(page: PageRoute): string;
299
- protected _next: number;
300
- protected nextId(): string;
188
+ }, params?: Record<string, any>): string;
189
+ compile(path: string, params?: Record<string, string>): string;
190
+ protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
191
+ protected readonly configure: _alepha_core12.HookDescriptor<"configure">;
192
+ protected map(pages: Array<{
193
+ value: {
194
+ [OPTIONS]: PageDescriptorOptions;
195
+ };
196
+ }>, target: {
197
+ [OPTIONS]: PageDescriptorOptions;
198
+ }): PageRouteEntry;
199
+ add(entry: PageRouteEntry): void;
200
+ protected createMatch(page: PageRoute): string;
201
+ protected _next: number;
202
+ protected nextId(): string;
301
203
  }
302
204
  declare const isPageRoute: (it: any) => it is PageRoute;
303
205
  interface PageRouteEntry extends Omit<PageDescriptorOptions, "children" | "parent"> {
304
- children?: PageRouteEntry[];
206
+ children?: PageRouteEntry[];
305
207
  }
306
208
  interface PageRoute extends PageRouteEntry {
307
- type: "page";
308
- name: string;
309
- parent?: PageRoute;
310
- match: string;
209
+ type: "page";
210
+ name: string;
211
+ parent?: PageRoute;
212
+ match: string;
311
213
  }
312
214
  interface Layer {
313
- config?: {
314
- query?: Record<string, any>;
315
- params?: Record<string, any>;
316
- context?: Record<string, any>;
317
- };
318
- name: string;
319
- props?: Record<string, any>;
320
- error?: Error;
321
- part?: string;
322
- element: ReactNode;
323
- index: number;
324
- path: string;
215
+ config?: {
216
+ query?: Record<string, any>;
217
+ params?: Record<string, any>;
218
+ context?: Record<string, any>;
219
+ };
220
+ name: string;
221
+ props?: Record<string, any>;
222
+ error?: Error;
223
+ part?: string;
224
+ element: ReactNode;
225
+ index: number;
226
+ path: string;
227
+ route?: PageRoute;
325
228
  }
326
229
  type PreviousLayerData = Omit<Layer, "element" | "index" | "path">;
327
230
  interface AnchorProps {
328
- href: string;
329
- onClick: (ev: any) => any;
231
+ href: string;
232
+ onClick: (ev: any) => any;
330
233
  }
331
234
  interface RouterState {
332
- pathname: string;
333
- search: string;
334
- layers: Array<Layer>;
235
+ pathname: string;
236
+ search: string;
237
+ layers: Array<Layer>;
335
238
  }
336
239
  interface TransitionOptions {
337
- state?: RouterState;
338
- previous?: PreviousLayerData[];
339
- context?: PageReactContext;
240
+ state?: RouterState;
241
+ previous?: PreviousLayerData[];
242
+ context?: PageReactContext;
340
243
  }
341
244
  interface RouterStackItem {
342
- route: PageRoute;
343
- config?: Record<string, any>;
344
- props?: Record<string, any>;
345
- error?: Error;
245
+ route: PageRoute;
246
+ config?: Record<string, any>;
247
+ props?: Record<string, any>;
248
+ error?: Error;
346
249
  }
347
250
  interface RouterRenderResult {
348
- state: RouterState;
349
- context: PageReactContext;
350
- redirect?: string;
251
+ state: RouterState;
252
+ context: PageReactContext;
253
+ redirect?: string;
351
254
  }
352
255
  interface PageRequest extends PageReactContext {
353
- params: Record<string, any>;
354
- query: Record<string, string>;
355
- previous?: PreviousLayerData[];
256
+ params: Record<string, any>;
257
+ query: Record<string, string>;
258
+ previous?: PreviousLayerData[];
356
259
  }
357
260
  interface CreateLayersResult extends RouterState {
358
- redirect?: string;
261
+ redirect?: string;
359
262
  }
360
263
  /**
361
264
  * It's like RouterState, but publicly available in React context.
362
265
  * This is where we store all plugin data!
363
266
  */
364
267
  interface PageReactContext {
365
- url: URL;
366
- head: Head$1;
367
- onError: (error: Error) => ReactNode;
368
- links?: ApiLinksResponse;
369
- }
370
-
371
- interface Head {
372
- title?: string;
373
- htmlAttributes?: Record<string, string>;
374
- bodyAttributes?: Record<string, string>;
375
- meta?: Array<{
376
- name: string;
377
- content: string;
378
- }>;
379
- }
380
- declare class ServerHeadProvider {
381
- renderHead(template: string, head: Head): string;
382
- mergeAttributes(existing: string, attrs: Record<string, string>): string;
383
- parseAttributes(attrStr: string): Record<string, string>;
384
- escapeHtml(str: string): string;
385
- }
386
-
387
- declare class BrowserHeadProvider {
388
- renderHead(document: Document, head: Head): void;
268
+ url: URL;
269
+ onError: (error: Error) => ReactNode;
270
+ links?: ApiLinksResponse;
389
271
  }
390
-
272
+ //#endregion
273
+ //#region src/providers/BrowserRouterProvider.d.ts
391
274
  interface BrowserRoute extends Route {
392
- page: PageRoute;
275
+ page: PageRoute;
393
276
  }
394
277
  declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
395
- protected readonly log: _alepha_core.Logger;
396
- protected readonly alepha: Alepha;
397
- protected readonly pageDescriptorProvider: PageDescriptorProvider;
398
- add(entry: PageRouteEntry): void;
399
- protected readonly configure: _alepha_core.HookDescriptor<"configure">;
400
- transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
401
- root(state: RouterState, context: PageReactContext): ReactNode;
402
- }
403
-
278
+ protected readonly log: _alepha_core23.Logger;
279
+ protected readonly alepha: Alepha;
280
+ protected readonly pageDescriptorProvider: PageDescriptorProvider;
281
+ add(entry: PageRouteEntry): void;
282
+ protected readonly configure: _alepha_core23.HookDescriptor<"configure">;
283
+ transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
284
+ root(state: RouterState, context: PageReactContext): ReactNode;
285
+ }
286
+ //#endregion
287
+ //#region src/providers/ReactBrowserProvider.d.ts
404
288
  declare class ReactBrowserProvider {
405
- protected readonly log: _alepha_core.Logger;
406
- protected readonly client: HttpClient;
407
- protected readonly alepha: Alepha;
408
- protected readonly router: BrowserRouterProvider;
409
- protected readonly headProvider: BrowserHeadProvider;
410
- protected root: Root;
411
- transitioning?: {
412
- to: string;
413
- };
414
- state: RouterState;
415
- get document(): Document;
416
- get history(): History;
417
- get url(): string;
418
- invalidate(props?: Record<string, any>): Promise<void>;
419
- go(url: string, options?: RouterGoOptions): Promise<void>;
420
- protected render(options?: {
421
- url?: string;
422
- previous?: PreviousLayerData[];
423
- }): Promise<RouterRenderResult>;
424
- /**
425
- * Get embedded layers from the server.
426
- */
427
- protected getHydrationState(): ReactHydrationState | undefined;
428
- readonly ready: _alepha_core.HookDescriptor<"ready">;
429
- readonly onTransitionEnd: _alepha_core.HookDescriptor<"react:transition:end">;
289
+ protected readonly log: _alepha_core16.Logger;
290
+ protected readonly client: LinkProvider;
291
+ protected readonly alepha: Alepha;
292
+ protected readonly router: BrowserRouterProvider;
293
+ protected root: Root;
294
+ transitioning?: {
295
+ to: string;
296
+ };
297
+ state: RouterState;
298
+ get document(): Document;
299
+ get history(): History;
300
+ get url(): string;
301
+ invalidate(props?: Record<string, any>): Promise<void>;
302
+ go(url: string, options?: RouterGoOptions): Promise<void>;
303
+ protected render(options?: {
304
+ url?: string;
305
+ previous?: PreviousLayerData[];
306
+ }): Promise<RouterRenderResult>;
307
+ /**
308
+ * Get embedded layers from the server.
309
+ */
310
+ protected getHydrationState(): ReactHydrationState | undefined;
311
+ readonly ready: _alepha_core16.HookDescriptor<"ready">;
430
312
  }
431
313
  interface RouterGoOptions {
432
- replace?: boolean;
433
- match?: TransitionOptions;
434
- params?: Record<string, string>;
314
+ replace?: boolean;
315
+ match?: TransitionOptions;
316
+ params?: Record<string, string>;
435
317
  }
436
318
  interface ReactHydrationState {
437
- layers?: Array<PreviousLayerData>;
438
- links?: ApiLinksResponse;
319
+ layers?: Array<PreviousLayerData>;
320
+ links?: ApiLinksResponse;
439
321
  }
440
-
322
+ //#endregion
323
+ //#region src/components/ErrorBoundary.d.ts
441
324
  /**
442
325
  * Props for the ErrorBoundary component.
443
326
  */
444
327
  interface ErrorBoundaryProps {
445
- /**
446
- * Fallback React node to render when an error is caught.
447
- * If not provided, a default error message will be shown.
448
- */
449
- fallback: (error: Error) => ReactNode;
450
- /**
451
- * Optional callback that receives the error and error info.
452
- * Use this to log errors to a monitoring service.
453
- */
454
- onError?: (error: Error, info: ErrorInfo) => void;
328
+ /**
329
+ * Fallback React node to render when an error is caught.
330
+ * If not provided, a default error message will be shown.
331
+ */
332
+ fallback: (error: Error) => ReactNode;
333
+ /**
334
+ * Optional callback that receives the error and error info.
335
+ * Use this to log errors to a monitoring service.
336
+ */
337
+ onError?: (error: Error, info: ErrorInfo) => void;
455
338
  }
456
339
  /**
457
340
  * State of the ErrorBoundary component.
458
341
  */
459
342
  interface ErrorBoundaryState {
460
- error?: Error;
343
+ error?: Error;
461
344
  }
462
345
  /**
463
346
  * A reusable error boundary for catching rendering errors
464
347
  * in any part of the React component tree.
465
348
  */
466
- declare class ErrorBoundary extends React__default.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
467
- constructor(props: ErrorBoundaryProps);
468
- /**
469
- * Update state so the next render shows the fallback UI.
470
- */
471
- static getDerivedStateFromError(error: Error): ErrorBoundaryState;
472
- /**
473
- * Lifecycle method called when an error is caught.
474
- * You can log the error or perform side effects here.
475
- */
476
- componentDidCatch(error: Error, info: ErrorInfo): void;
477
- render(): ReactNode;
478
- }
479
-
349
+ declare class ErrorBoundary extends React.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
350
+ constructor(props: ErrorBoundaryProps);
351
+ /**
352
+ * Update state so the next render shows the fallback UI.
353
+ */
354
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
355
+ /**
356
+ * Lifecycle method called when an error is caught.
357
+ * You can log the error or perform side effects here.
358
+ */
359
+ componentDidCatch(error: Error, info: ErrorInfo): void;
360
+ render(): ReactNode;
361
+ }
362
+ //#endregion
363
+ //#region src/components/Link.d.ts
480
364
  interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
481
- to: string | PageDescriptor;
482
- children?: React__default.ReactNode;
365
+ to: string | PageDescriptor;
366
+ children?: React.ReactNode;
483
367
  }
484
- declare const Link: (props: LinkProps) => react_jsx_runtime.JSX.Element | null;
485
-
368
+ declare const Link: (props: LinkProps) => react_jsx_runtime22.JSX.Element | null;
369
+ //#endregion
370
+ //#region src/components/NestedView.d.ts
486
371
  interface NestedViewProps {
487
- children?: ReactNode;
372
+ children?: ReactNode;
488
373
  }
489
374
  /**
490
375
  * A component that renders the current view of the nested router layer.
@@ -507,201 +392,224 @@ interface NestedViewProps {
507
392
  * }
508
393
  * ```
509
394
  */
510
- declare const NestedView: (props: NestedViewProps) => react_jsx_runtime.JSX.Element;
511
-
395
+ declare const NestedView: (props: NestedViewProps) => react_jsx_runtime21.JSX.Element;
396
+ //#endregion
397
+ //#region src/contexts/RouterContext.d.ts
512
398
  interface RouterContextValue {
513
- alepha: Alepha;
514
- state: RouterState;
515
- context: PageReactContext;
399
+ alepha: Alepha;
400
+ state: RouterState;
401
+ context: PageReactContext;
516
402
  }
517
- declare const RouterContext: React.Context<RouterContextValue | undefined>;
518
-
403
+ declare const RouterContext: react19.Context<RouterContextValue | undefined>;
404
+ //#endregion
405
+ //#region src/contexts/RouterLayerContext.d.ts
519
406
  interface RouterLayerContextValue {
520
- index: number;
521
- path: string;
407
+ index: number;
408
+ path: string;
522
409
  }
523
- declare const RouterLayerContext: React.Context<RouterLayerContextValue | undefined>;
524
-
410
+ declare const RouterLayerContext: react20.Context<RouterLayerContextValue | undefined>;
411
+ //#endregion
412
+ //#region src/hooks/RouterHookApi.d.ts
525
413
  declare class RouterHookApi {
526
- private readonly pages;
527
- private readonly state;
528
- private readonly layer;
529
- private readonly browser?;
530
- constructor(pages: PageRoute[], state: RouterState, layer: {
531
- path: string;
532
- }, browser?: ReactBrowserProvider | undefined);
533
- get current(): RouterState;
534
- get pathname(): string;
535
- get query(): Record<string, string>;
536
- back(): Promise<void>;
537
- forward(): Promise<void>;
538
- invalidate(props?: Record<string, any>): Promise<void>;
539
- /**
540
- * Create a valid href for the given pathname.
541
- *
542
- * @param pathname
543
- * @param layer
544
- */
545
- createHref(pathname: HrefLike, layer?: {
546
- path: string;
547
- }, options?: {
548
- params?: Record<string, any>;
549
- }): string;
550
- go(path: string, options?: RouterGoOptions): Promise<void>;
551
- go<T extends object>(path: keyof VirtualRouter<T>, options?: RouterGoOptions): Promise<void>;
552
- anchor(path: string, options?: {
553
- params?: Record<string, any>;
554
- }): AnchorProps;
555
- anchor<T extends object>(path: keyof VirtualRouter<T>, options?: {
556
- params?: Record<string, any>;
557
- }): AnchorProps;
414
+ private readonly pages;
415
+ private readonly state;
416
+ private readonly layer;
417
+ private readonly browser?;
418
+ constructor(pages: PageRoute[], state: RouterState, layer: {
419
+ path: string;
420
+ }, browser?: ReactBrowserProvider | undefined);
421
+ get current(): RouterState;
422
+ get pathname(): string;
423
+ get query(): Record<string, string>;
424
+ back(): Promise<void>;
425
+ forward(): Promise<void>;
426
+ invalidate(props?: Record<string, any>): Promise<void>;
427
+ /**
428
+ * Create a valid href for the given pathname.
429
+ *
430
+ * @param pathname
431
+ * @param layer
432
+ */
433
+ createHref(pathname: HrefLike, layer?: {
434
+ path: string;
435
+ }, options?: {
436
+ params?: Record<string, any>;
437
+ }): string;
438
+ go(path: string, options?: RouterGoOptions): Promise<void>;
439
+ go<T extends object>(path: keyof VirtualRouter<T>, options?: RouterGoOptions): Promise<void>;
440
+ anchor(path: string, options?: {
441
+ params?: Record<string, any>;
442
+ }): AnchorProps;
443
+ anchor<T extends object>(path: keyof VirtualRouter<T>, options?: {
444
+ params?: Record<string, any>;
445
+ }): AnchorProps;
446
+ /**
447
+ * Set query params.
448
+ *
449
+ * @param record
450
+ * @param options
451
+ */
452
+ setQueryParams(record: Record<string, any> | ((queryParams: Record<string, any>) => Record<string, any>), options?: {
558
453
  /**
559
- * Set query params.
560
- *
561
- * @param record
562
- * @param options
454
+ * If true, this will add a new entry to the history stack.
563
455
  */
564
- setQueryParams(record: Record<string, any> | ((queryParams: Record<string, any>) => Record<string, any>), options?: {
565
- /**
566
- * If true, this will add a new entry to the history stack.
567
- */
568
- push?: boolean;
569
- }): void;
456
+ push?: boolean;
457
+ }): void;
570
458
  }
571
459
  type HrefLike = string | {
572
- options: {
573
- path?: string;
574
- name?: string;
575
- };
576
- };
577
- type VirtualRouter<T> = {
578
- [K in keyof T as T[K] extends PageDescriptor ? K : never]: T[K];
460
+ options: {
461
+ path?: string;
462
+ name?: string;
463
+ };
579
464
  };
580
-
465
+ type VirtualRouter<T> = { [K in keyof T as T[K] extends PageDescriptor ? K : never]: T[K] };
466
+ //#endregion
467
+ //#region src/errors/RedirectionError.d.ts
581
468
  declare class RedirectionError extends Error {
582
- readonly page: HrefLike;
583
- constructor(page: HrefLike);
469
+ readonly page: HrefLike;
470
+ constructor(page: HrefLike);
584
471
  }
585
-
472
+ //#endregion
473
+ //#region src/hooks/useActive.d.ts
586
474
  declare const useActive: (path: HrefLike) => UseActiveHook;
587
475
  interface UseActiveHook {
588
- isActive: boolean;
589
- anchorProps: AnchorProps;
590
- isPending: boolean;
591
- name?: string;
476
+ isActive: boolean;
477
+ anchorProps: AnchorProps;
478
+ isPending: boolean;
479
+ name?: string;
592
480
  }
593
-
481
+ //#endregion
482
+ //#region src/hooks/useAlepha.d.ts
594
483
  declare const useAlepha: () => Alepha;
595
-
484
+ //#endregion
485
+ //#region src/hooks/useClient.d.ts
596
486
  declare const useClient: <T extends object>(_scope?: ClientScope) => HttpVirtualClient<T>;
597
-
487
+ //#endregion
488
+ //#region src/hooks/useInject.d.ts
598
489
  declare const useInject: <T extends object>(clazz: Service<T>) => T;
599
-
490
+ //#endregion
491
+ //#region src/hooks/useQueryParams.d.ts
600
492
  interface UseQueryParamsHookOptions {
601
- format?: "base64" | "querystring";
602
- key?: string;
603
- push?: boolean;
493
+ format?: "base64" | "querystring";
494
+ key?: string;
495
+ push?: boolean;
604
496
  }
605
497
  declare const useQueryParams: <T extends TObject>(schema: T, options?: UseQueryParamsHookOptions) => [Static<T>, (data: Static<T>) => void];
606
-
498
+ //#endregion
499
+ //#region src/hooks/useRouter.d.ts
607
500
  declare const useRouter: () => RouterHookApi;
608
-
501
+ //#endregion
502
+ //#region src/hooks/useRouterEvents.d.ts
609
503
  declare const useRouterEvents: (opts?: {
610
- onBegin?: (ev: {
611
- state: RouterState;
612
- }) => void;
613
- onEnd?: (ev: {
614
- state: RouterState;
615
- }) => void;
616
- onError?: (ev: {
617
- state: RouterState;
618
- error: Error;
619
- }) => void;
504
+ onBegin?: (ev: {
505
+ state: RouterState;
506
+ }) => void;
507
+ onEnd?: (ev: {
508
+ state: RouterState;
509
+ }) => void;
510
+ onError?: (ev: {
511
+ state: RouterState;
512
+ error: Error;
513
+ }) => void;
620
514
  }, deps?: any[]) => void;
621
-
515
+ //#endregion
516
+ //#region src/hooks/useRouterState.d.ts
622
517
  declare const useRouterState: () => RouterState;
623
-
624
- declare const envSchema: _alepha_core.TObject<{
625
- REACT_SERVER_DIST: TString;
626
- REACT_SERVER_PREFIX: TString;
627
- REACT_SSR_ENABLED: TOptional<TBoolean>;
628
- REACT_ROOT_ID: TString;
518
+ //#endregion
519
+ //#region src/providers/ReactServerProvider.d.ts
520
+ declare const envSchema: _alepha_core6.TObject<{
521
+ REACT_SERVER_DIST: _sinclair_typebox1.TString;
522
+ REACT_SERVER_PREFIX: _sinclair_typebox1.TString;
523
+ REACT_SSR_ENABLED: _sinclair_typebox1.TOptional<_sinclair_typebox1.TBoolean>;
524
+ REACT_ROOT_ID: _sinclair_typebox1.TString;
629
525
  }>;
630
526
  declare module "@alepha/core" {
631
- interface Env extends Partial<Static<typeof envSchema>> {
632
- }
633
- interface State {
634
- "ReactServerProvider.template"?: string;
635
- "ReactServerProvider.ssr"?: boolean;
636
- }
527
+ interface Env extends Partial<Static<typeof envSchema>> {}
528
+ interface State {
529
+ "ReactServerProvider.template"?: string;
530
+ "ReactServerProvider.ssr"?: boolean;
531
+ }
637
532
  }
638
533
  declare class ReactServerProvider {
639
- protected readonly log: _alepha_core.Logger;
640
- protected readonly alepha: Alepha;
641
- protected readonly pageDescriptorProvider: PageDescriptorProvider;
642
- protected readonly serverStaticProvider: ServerStaticProvider;
643
- protected readonly serverRouterProvider: ServerRouterProvider;
644
- protected readonly headProvider: ServerHeadProvider;
645
- protected readonly serverTimingProvider: ServerTimingProvider;
646
- protected readonly env: {
647
- REACT_SSR_ENABLED?: boolean | undefined;
648
- REACT_SERVER_DIST: string;
649
- REACT_SERVER_PREFIX: string;
650
- REACT_ROOT_ID: string;
651
- };
652
- protected readonly ROOT_DIV_REGEX: RegExp;
653
- readonly onConfigure: _alepha_core.HookDescriptor<"configure">;
654
- get template(): string | undefined;
655
- protected registerPages(templateLoader: TemplateLoader): Promise<void>;
656
- protected getPublicDirectory(): string;
657
- protected configureStaticServer(root: string): Promise<void>;
658
- protected configureVite(ssrEnabled: boolean): Promise<void>;
659
- /**
660
- * For testing purposes, creates a render function that can be used.
661
- */
662
- protected createRenderFunction(name: string, withIndex?: boolean): (options?: {
663
- params?: Record<string, string>;
664
- query?: Record<string, string>;
665
- }) => Promise<{
666
- context: PageRequest;
667
- html: string;
668
- }>;
669
- protected createHandler(page: PageRoute, templateLoader: TemplateLoader): ServerHandler;
670
- renderToHtml(template: string, state: RouterState, context: PageReactContext): string;
671
- protected fillTemplate(response: {
672
- html: string;
673
- }, app: string, script: string): void;
534
+ protected readonly log: _alepha_core6.Logger;
535
+ protected readonly alepha: Alepha;
536
+ protected readonly pageDescriptorProvider: PageDescriptorProvider;
537
+ protected readonly serverStaticProvider: ServerStaticProvider;
538
+ protected readonly serverRouterProvider: ServerRouterProvider;
539
+ protected readonly serverTimingProvider: ServerTimingProvider;
540
+ protected readonly env: {
541
+ REACT_SSR_ENABLED?: boolean | undefined;
542
+ REACT_SERVER_DIST: string;
543
+ REACT_SERVER_PREFIX: string;
544
+ REACT_ROOT_ID: string;
545
+ };
546
+ protected readonly ROOT_DIV_REGEX: RegExp;
547
+ readonly onConfigure: _alepha_core6.HookDescriptor<"configure">;
548
+ get template(): string;
549
+ protected registerPages(templateLoader: TemplateLoader): Promise<void>;
550
+ protected getPublicDirectory(): string;
551
+ protected configureStaticServer(root: string): Promise<void>;
552
+ protected configureVite(ssrEnabled: boolean): Promise<void>;
553
+ /**
554
+ * For testing purposes, creates a render function that can be used.
555
+ */
556
+ protected createRenderFunction(name: string, withIndex?: boolean): (options?: PageDescriptorRenderOptions) => Promise<{
557
+ context: PageRequest;
558
+ state: CreateLayersResult;
559
+ html: string;
560
+ } | {
561
+ context: PageRequest;
562
+ html: string;
563
+ }>;
564
+ protected createHandler(page: PageRoute, templateLoader: TemplateLoader): ServerHandler;
565
+ renderToHtml(template: string, state: RouterState, context: PageReactContext, hydration?: boolean): string;
566
+ protected fillTemplate(response: {
567
+ html: string;
568
+ }, app: string, script: string): void;
674
569
  }
675
570
  type TemplateLoader = () => Promise<string | undefined>;
676
-
571
+ //#endregion
572
+ //#region src/index.d.ts
677
573
  declare module "@alepha/core" {
678
- interface Hooks {
679
- "react:browser:render": {
680
- state: RouterState;
681
- context: PageReactContext;
682
- hydration?: ReactHydrationState;
683
- };
684
- "react:server:render": {
685
- request: ServerRequest;
686
- pageRequest: PageRequest;
687
- };
688
- "react:transition:begin": {
689
- state: RouterState;
690
- context: PageReactContext;
691
- };
692
- "react:transition:success": {
693
- state: RouterState;
694
- };
695
- "react:transition:error": {
696
- error: Error;
697
- state: RouterState;
698
- context: PageReactContext;
699
- };
700
- "react:transition:end": {
701
- state: RouterState;
702
- context: PageReactContext;
703
- };
704
- }
574
+ interface Hooks {
575
+ "react:router:createLayers": {
576
+ request: ServerRequest;
577
+ context: PageRequest;
578
+ layers: PageRequest[];
579
+ };
580
+ "react:server:render:begin": {
581
+ request?: ServerRequest;
582
+ context: PageRequest;
583
+ };
584
+ "react:server:render:end": {
585
+ request?: ServerRequest;
586
+ context: PageRequest;
587
+ state: RouterState;
588
+ html: string;
589
+ };
590
+ "react:browser:render": {
591
+ state: RouterState;
592
+ context: PageReactContext;
593
+ hydration?: ReactHydrationState;
594
+ };
595
+ "react:transition:begin": {
596
+ state: RouterState;
597
+ context: PageReactContext;
598
+ };
599
+ "react:transition:success": {
600
+ state: RouterState;
601
+ context: PageReactContext;
602
+ };
603
+ "react:transition:error": {
604
+ error: Error;
605
+ state: RouterState;
606
+ context: PageReactContext;
607
+ };
608
+ "react:transition:end": {
609
+ state: RouterState;
610
+ context: PageReactContext;
611
+ };
612
+ }
705
613
  }
706
614
  /**
707
615
  * Alepha React Module
@@ -713,8 +621,9 @@ declare module "@alepha/core" {
713
621
  * @module alepha.react
714
622
  */
715
623
  declare class AlephaReact implements Module {
716
- readonly name = "alepha.react";
717
- readonly $services: (alepha: Alepha) => Alepha;
624
+ readonly name = "alepha.react";
625
+ readonly $services: (alepha: Alepha) => Alepha;
718
626
  }
719
-
720
- export { $page, AlephaReact, type AnchorProps, ClientOnly, type CreateLayersResult, ErrorBoundary, type Head$1 as Head, type HrefLike, type Layer, Link, NestedView, type PageConfigSchema, type PageDescriptor, type PageDescriptorOptions, PageDescriptorProvider, type PageDescriptorRenderOptions, type PageDescriptorRenderResult, type PageReactContext, type PageRequest, type PageRequestConfig, type PageResolve, type PageRoute, type PageRouteEntry, type PreviousLayerData, ReactBrowserProvider, type ReactHydrationState, ReactServerProvider, RedirectionError, RouterContext, type RouterContextValue, type RouterGoOptions, RouterHookApi, RouterLayerContext, type RouterLayerContextValue, type RouterRenderResult, type RouterStackItem, type RouterState, type TPropsDefault, type TPropsParentDefault, type TransitionOptions, type UseActiveHook, type UseQueryParamsHookOptions, type VirtualRouter, isPageRoute, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
627
+ //#endregion
628
+ export { $page, AlephaReact, AnchorProps, ClientOnly, CreateLayersResult, ErrorBoundary, HrefLike, Layer, Link, NestedView, PageConfigSchema, PageDescriptor, PageDescriptorOptions, PageDescriptorProvider, PageDescriptorRenderOptions, PageDescriptorRenderResult, PageReactContext, PageRequest, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactHydrationState, ReactServerProvider, RedirectionError, RouterContext, RouterContextValue, RouterGoOptions, RouterHookApi, RouterLayerContext, RouterLayerContextValue, RouterRenderResult, RouterStackItem, RouterState, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActiveHook, UseQueryParamsHookOptions, VirtualRouter, isPageRoute, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
629
+ //# sourceMappingURL=index.d.ts.map