@alepha/react 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts DELETED
@@ -1,872 +0,0 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { Static as Static$1, TSchema as TSchema$1, Async, KIND, EventEmitter, Alepha, ClassEntry, TObject as TObject$1 } from '@alepha/core';
3
- import * as react from 'react';
4
- import { ReactNode, FC } from 'react';
5
- import * as _alepha_server from '@alepha/server';
6
- import { ServerProvider, HttpClient, ServeDescriptorOptions, RouteObject } from '@alepha/server';
7
- import * as _alepha_cache from '@alepha/cache';
8
- import { SecurityProvider, UserAccountToken, UserAccountInfo } from '@alepha/security';
9
- import { Configuration } from 'openid-client';
10
- import { MatchFunction, ParamData } from 'path-to-regexp';
11
- import { Root } from 'react-dom/client';
12
-
13
- interface NestedViewProps {
14
- children?: ReactNode;
15
- }
16
- /**
17
- * Nested view component
18
- *
19
- * @param props
20
- * @constructor
21
- */
22
- declare const NestedView: (props: NestedViewProps) => string | number | boolean | react.ReactElement<any, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null;
23
-
24
- /** Symbol key applied to readonly types */
25
- declare const ReadonlyKind: unique symbol;
26
- /** Symbol key applied to optional types */
27
- declare const OptionalKind: unique symbol;
28
- /** Symbol key applied to types */
29
- declare const Hint: unique symbol;
30
- /** Symbol key applied to types */
31
- declare const Kind: unique symbol;
32
-
33
- type TReadonly<T extends TSchema> = T & {
34
- [ReadonlyKind]: 'Readonly';
35
- };
36
-
37
- 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);
38
- type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
39
- interface StringOptions extends SchemaOptions {
40
- /** The maximum string length */
41
- maxLength?: number;
42
- /** The minimum string length */
43
- minLength?: number;
44
- /** A regular expression pattern this string should match */
45
- pattern?: string;
46
- /** A format this string should match */
47
- format?: StringFormatOption;
48
- /** The content encoding for this string */
49
- contentEncoding?: StringContentEncodingOption;
50
- /** The content media type for this string */
51
- contentMediaType?: string;
52
- }
53
- interface TString extends TSchema, StringOptions {
54
- [Kind]: 'String';
55
- static: string;
56
- type: 'string';
57
- }
58
-
59
- interface TBoolean extends TSchema {
60
- [Kind]: 'Boolean';
61
- static: boolean;
62
- type: 'boolean';
63
- }
64
-
65
- type TOptional<T extends TSchema> = T & {
66
- [OptionalKind]: 'Optional';
67
- };
68
-
69
- type RecordStatic<Key extends TSchema, Type extends TSchema, P extends unknown[]> = (Evaluate<{
70
- [_ in Assert<Static<Key>, PropertyKey>]: Static<Type, P>;
71
- }>);
72
- interface TRecord<Key extends TSchema = TSchema, Type extends TSchema = TSchema> extends TSchema {
73
- [Kind]: 'Record';
74
- static: RecordStatic<Key, Type, this['params']>;
75
- type: 'object';
76
- patternProperties: {
77
- [pattern: string]: Type;
78
- };
79
- additionalProperties: TAdditionalProperties;
80
- }
81
-
82
- /** Creates a static type from a TypeBox type */
83
- type Static<Type extends TSchema, Params extends unknown[] = [], Result = (Type & {
84
- params: Params;
85
- })['static']> = Result;
86
-
87
- type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
88
- [K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
89
- }[keyof T];
90
- type ReadonlyPropertyKeys<T extends TProperties> = {
91
- [K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
92
- }[keyof T];
93
- type OptionalPropertyKeys<T extends TProperties> = {
94
- [K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
95
- }[keyof T];
96
- type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
97
- type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
98
- type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
99
- [K in keyof T]: Static<T[K], P>;
100
- }>;
101
- type TPropertyKey = string | number;
102
- type TProperties = Record<TPropertyKey, TSchema>;
103
- type TAdditionalProperties = undefined | TSchema | boolean;
104
- interface ObjectOptions extends SchemaOptions {
105
- /** Additional property constraints for this object */
106
- additionalProperties?: TAdditionalProperties;
107
- /** The minimum number of properties allowed on this object */
108
- minProperties?: number;
109
- /** The maximum number of properties allowed on this object */
110
- maxProperties?: number;
111
- }
112
- interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
113
- [Kind]: 'Object';
114
- static: ObjectStatic<T, this['params']>;
115
- additionalProperties?: TAdditionalProperties;
116
- type: 'object';
117
- properties: T;
118
- required?: string[];
119
- }
120
-
121
- type Assert<T, E> = T extends E ? T : never;
122
- type Evaluate<T> = T extends infer O ? {
123
- [K in keyof O]: O[K];
124
- } : never;
125
-
126
- interface SchemaOptions {
127
- $schema?: string;
128
- /** Id for this schema */
129
- $id?: string;
130
- /** Title of this schema */
131
- title?: string;
132
- /** Description of this schema */
133
- description?: string;
134
- /** Default value for this schema */
135
- default?: any;
136
- /** Example values matching this schema */
137
- examples?: any;
138
- /** Optional annotation for readOnly */
139
- readOnly?: boolean;
140
- /** Optional annotation for writeOnly */
141
- writeOnly?: boolean;
142
- [prop: string]: any;
143
- }
144
- interface TKind {
145
- [Kind]: string;
146
- }
147
- interface TSchema extends TKind, SchemaOptions {
148
- [ReadonlyKind]?: string;
149
- [OptionalKind]?: string;
150
- [Hint]?: string;
151
- params: unknown[];
152
- static: unknown;
153
- }
154
-
155
- declare const sessionUserSchema: _alepha_core.TObject<{
156
- id: TString;
157
- name: TOptional<TString>;
158
- }>;
159
- declare const sessionSchema: _alepha_core.TObject<{
160
- user: TOptional<_alepha_core.TObject<{
161
- id: TString;
162
- name: TOptional<TString>;
163
- }>>;
164
- }>;
165
- type Session = Static$1<typeof sessionSchema>;
166
- declare const envSchema$1: _alepha_core.TObject<{
167
- REACT_OIDC_ISSUER: TOptional<TString>;
168
- REACT_OIDC_CLIENT_ID: TOptional<TString>;
169
- REACT_OIDC_CLIENT_SECRET: TOptional<TString>;
170
- REACT_OIDC_REDIRECT_URI: TOptional<TString>;
171
- }>;
172
- declare module "fastify" {
173
- interface FastifyRequest {
174
- session?: ReactServerSession;
175
- }
176
- }
177
- declare module "@alepha/core" {
178
- interface Env extends Partial<Static$1<typeof envSchema$1>> {
179
- }
180
- }
181
- declare class ReactSessionProvider {
182
- protected readonly SSID = "ssid";
183
- protected readonly log: _alepha_core.Logger;
184
- protected readonly env: {
185
- REACT_OIDC_ISSUER?: string | undefined;
186
- REACT_OIDC_CLIENT_ID?: string | undefined;
187
- REACT_OIDC_CLIENT_SECRET?: string | undefined;
188
- REACT_OIDC_REDIRECT_URI?: string | undefined;
189
- };
190
- protected readonly serverProvider: ServerProvider;
191
- protected readonly securityProvider: SecurityProvider;
192
- protected readonly sessions: _alepha_cache.CacheDescriptor<ReactServerSession, any[]>;
193
- protected clients: Configuration[];
194
- get redirectUri(): string;
195
- protected readonly configure: _alepha_core.HookDescriptor<"configure">;
196
- /**
197
- *
198
- * @param sessionId
199
- * @param session
200
- * @protected
201
- */
202
- protected setSession(sessionId: string, session: ReactServerSession): Promise<void>;
203
- /**
204
- *
205
- * @param sessionId
206
- * @protected
207
- */
208
- protected getSession(sessionId: string): Promise<ReactServerSession | undefined>;
209
- /**
210
- *
211
- * @protected
212
- */
213
- protected readonly beforeRequest: _alepha_core.HookDescriptor<"configure:fastify">;
214
- /**
215
- *
216
- */
217
- readonly login: _alepha_server.RouteDescriptor<{
218
- query: _alepha_core.TObject<{
219
- redirect: TOptional<TString>;
220
- }>;
221
- }>;
222
- /**
223
- *
224
- */
225
- readonly callback: _alepha_server.RouteDescriptor<{
226
- headers: TRecord<TString, TString>;
227
- cookies: _alepha_core.TObject<{
228
- ssid: TString;
229
- }>;
230
- }>;
231
- readonly logout: _alepha_server.RouteDescriptor<{
232
- query: _alepha_core.TObject<{
233
- redirect: TOptional<TString>;
234
- }>;
235
- cookies: _alepha_core.TObject<{
236
- ssid: TString;
237
- }>;
238
- }>;
239
- readonly session: _alepha_server.RouteDescriptor<{
240
- headers: _alepha_core.TObject<{
241
- authorization: TString;
242
- }>;
243
- response: _alepha_core.TObject<{
244
- user: TOptional<_alepha_core.TObject<{
245
- id: TString;
246
- name: TOptional<TString>;
247
- }>>;
248
- }>;
249
- }>;
250
- }
251
- interface ReactServerSession {
252
- access_token?: string;
253
- expires_in?: number;
254
- refresh_token?: string;
255
- id_token?: string;
256
- scope?: string;
257
- issued_at?: number;
258
- authorizationCodeGrant?: {
259
- codeVerifier: string;
260
- redirectUri: string;
261
- nonce?: string;
262
- max_age?: number;
263
- state?: string;
264
- };
265
- }
266
-
267
- declare class ReactBrowserProvider {
268
- protected readonly log: _alepha_core.Logger;
269
- protected readonly client: HttpClient;
270
- protected readonly router: Router;
271
- protected root: Root;
272
- transitioning?: {
273
- to: string;
274
- };
275
- state: RouterState;
276
- /**
277
- *
278
- */
279
- get document(): Document;
280
- /**
281
- *
282
- */
283
- get history(): History;
284
- /**
285
- *
286
- */
287
- get url(): string;
288
- /**
289
- *
290
- * @param props
291
- */
292
- invalidate(props?: Record<string, any>): Promise<void>;
293
- /**
294
- *
295
- * @param url
296
- * @param options
297
- */
298
- go(url: string, options?: RouterGoOptions): Promise<void>;
299
- /**
300
- *
301
- * @param options
302
- * @protected
303
- */
304
- protected render(options?: {
305
- url?: string;
306
- previous?: PreviousLayerData[];
307
- }): Promise<{
308
- url: string;
309
- }>;
310
- /**
311
- * Get embedded layers from the server.
312
- *
313
- * @protected
314
- */
315
- protected getEmbeddedCache(): {
316
- session?: Session;
317
- layers?: PreviousLayerData[];
318
- } | undefined;
319
- /**
320
- *
321
- * @protected
322
- */
323
- protected getRootElement(): HTMLElement;
324
- /**
325
- *
326
- * @protected
327
- */
328
- protected ready: _alepha_core.HookDescriptor<"ready">;
329
- /**
330
- *
331
- * @protected
332
- */
333
- protected stop: _alepha_core.HookDescriptor<"stop">;
334
- }
335
- /**
336
- *
337
- */
338
- interface RouterGoOptions {
339
- replace?: boolean;
340
- match?: RouterMatchOptions;
341
- }
342
-
343
- declare class RouterHookApi {
344
- private readonly state;
345
- private readonly layer;
346
- private readonly browser?;
347
- constructor(state: RouterState, layer: {
348
- path: string;
349
- }, browser?: ReactBrowserProvider | undefined);
350
- /**
351
- *
352
- */
353
- get current(): RouterState;
354
- /**
355
- *
356
- */
357
- get pathname(): string;
358
- /**
359
- *
360
- */
361
- get query(): Record<string, string>;
362
- /**
363
- *
364
- */
365
- back(): Promise<void>;
366
- /**
367
- *
368
- */
369
- forward(): Promise<void>;
370
- /**
371
- *
372
- * @param props
373
- */
374
- invalidate(props?: Record<string, any>): Promise<void>;
375
- /**
376
- * Create a valid href for the given pathname.
377
- *
378
- * @param pathname
379
- * @param layer
380
- */
381
- createHref(pathname: HrefLike, layer?: {
382
- path: string;
383
- }): string;
384
- /**
385
- *
386
- * @param path
387
- * @param options
388
- */
389
- go(path: HrefLike, options?: RouterGoOptions): Promise<void>;
390
- /**
391
- *
392
- * @param path
393
- */
394
- createAnchorProps(path: string): AnchorProps;
395
- /**
396
- * Set query params.
397
- *
398
- * @param record
399
- * @param options
400
- */
401
- setQueryParams(record: Record<string, any>, options?: {
402
- /**
403
- * If true, this will merge current query params with the new ones.
404
- */
405
- merge?: boolean;
406
- /**
407
- * If true, this will add a new entry to the history stack.
408
- */
409
- push?: boolean;
410
- }): void;
411
- }
412
- type HrefLike = string | {
413
- options: {
414
- path?: string;
415
- name?: string;
416
- };
417
- };
418
-
419
- declare const pageDescriptorKey = "PAGE";
420
- interface PageDescriptorConfigSchema {
421
- query?: TSchema$1;
422
- params?: TSchema$1;
423
- }
424
- type TPropsDefault = any;
425
- type TPropsParentDefault = object;
426
- interface PageDescriptorOptions<TConfig extends PageDescriptorConfigSchema = PageDescriptorConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
427
- parent?: {
428
- options: PageDescriptorOptions<any, TPropsParent>;
429
- };
430
- name?: string;
431
- path?: string;
432
- schema?: TConfig;
433
- abstract?: boolean;
434
- resolve?: (config: PageDescriptorConfigValue<TConfig> & TPropsParent & {
435
- user?: UserAccountToken;
436
- }) => Async<TProps>;
437
- component?: FC<TProps & TPropsParent>;
438
- lazy?: () => Promise<{
439
- default: FC<TProps & TPropsParent>;
440
- }>;
441
- children?: () => Array<{
442
- options: PageDescriptorOptions;
443
- }>;
444
- notFoundHandler?: FC<{
445
- error: Error;
446
- }>;
447
- errorHandler?: FC<{
448
- error: Error;
449
- url: string;
450
- }>;
451
- }
452
- interface PageDescriptorConfigValue<TConfig extends PageDescriptorConfigSchema = PageDescriptorConfigSchema> {
453
- query: TConfig["query"] extends TSchema$1 ? Static$1<TConfig["query"]> : Record<string, string>;
454
- params: TConfig["params"] extends TSchema$1 ? Static$1<TConfig["params"]> : Record<string, string>;
455
- pathname: string;
456
- }
457
- interface PageDescriptor<TConfig extends PageDescriptorConfigSchema = PageDescriptorConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
458
- [KIND]: typeof pageDescriptorKey;
459
- render: (options?: {
460
- params?: Record<string, string>;
461
- query?: Record<string, string>;
462
- }) => Promise<string>;
463
- go: () => void;
464
- createAnchorProps: (routerHook: RouterHookApi) => {
465
- href: string;
466
- onClick: () => void;
467
- };
468
- options: PageDescriptorOptions<TConfig, TProps, TPropsParent>;
469
- }
470
- declare const $page: {
471
- <TConfig extends PageDescriptorConfigSchema = PageDescriptorConfigSchema, TProps extends object = any, TPropsParent extends object = object>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
472
- [KIND]: string;
473
- };
474
-
475
- declare class RedirectException extends Error {
476
- readonly page: HrefLike;
477
- constructor(page: HrefLike);
478
- }
479
- declare class Router extends EventEmitter<RouterEvents> {
480
- protected readonly log: _alepha_core.Logger;
481
- protected readonly alepha: Alepha;
482
- protected readonly pages: PageRoute[];
483
- protected notFoundPageRoute?: PageRoute;
484
- /**
485
- * Get the page by name.
486
- *
487
- * @param name - Page name
488
- * @return PageRoute
489
- */
490
- page(name: string): PageRoute;
491
- /**
492
- *
493
- */
494
- root(state: RouterState, opts?: {
495
- user?: UserAccountInfo;
496
- }): ReactNode;
497
- /**
498
- *
499
- * @param url
500
- * @param options
501
- */
502
- render(url: string, options?: RouterRenderOptions): Promise<{
503
- element: ReactNode;
504
- layers: Layer[];
505
- redirect?: string;
506
- }>;
507
- /**
508
- *
509
- * @param url
510
- * @param options
511
- * @protected
512
- */
513
- match(url: string, options?: RouterMatchOptions): Promise<Layer[]>;
514
- /**
515
- * Create layers for the given route.
516
- *
517
- * @param route
518
- * @param params
519
- * @param query
520
- * @param previous
521
- * @param user
522
- * @protected
523
- */
524
- createLayers(url: string, route: PageRoute, params?: Record<string, any>, query?: Record<string, string>, previous?: PreviousLayerData[], user?: UserAccountInfo): Promise<Layer[]>;
525
- /**
526
- *
527
- * @param route
528
- * @protected
529
- */
530
- protected getErrorHandler(route: PageRoute): react.FC<{
531
- error: Error;
532
- url: string;
533
- }> | undefined;
534
- /**
535
- *
536
- * @param page
537
- * @param props
538
- * @protected
539
- */
540
- protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
541
- /**
542
- *
543
- * @param e
544
- * @protected
545
- */
546
- protected renderError(e: Error): ReactNode;
547
- /**
548
- * Render an empty view.
549
- *
550
- * @protected
551
- */
552
- protected renderEmptyView(): ReactNode;
553
- /**
554
- * Create a valid href for the given page.
555
- * @param page
556
- * @param params
557
- */
558
- href(page: {
559
- options: {
560
- name?: string;
561
- };
562
- }, params?: Record<string, any>): string;
563
- /**
564
- *
565
- * @param index
566
- * @param path
567
- * @param view
568
- * @protected
569
- */
570
- protected renderView(index: number, path: string, view?: ReactNode): ReactNode;
571
- /**
572
- *
573
- * @param entry
574
- */
575
- add(entry: PageRouteEntry): void;
576
- /**
577
- * Create a match function for the given page.
578
- *
579
- * @param page
580
- * @protected
581
- */
582
- protected createMatchFunction(page: PageRoute): {
583
- exec: MatchFunction<ParamData>;
584
- path: string;
585
- } | undefined;
586
- /**
587
- *
588
- */
589
- empty(): boolean;
590
- /**
591
- *
592
- * @protected
593
- */
594
- protected _next: number;
595
- /**
596
- *
597
- * @protected
598
- */
599
- protected nextId(): string;
600
- }
601
- interface PageRouteEntry extends Omit<PageDescriptorOptions, "children" | "parent"> {
602
- /**
603
- *
604
- */
605
- name?: string;
606
- /**
607
- *
608
- */
609
- match?: {
610
- /**
611
- *
612
- */
613
- exec: MatchFunction<ParamData>;
614
- /**
615
- *
616
- */
617
- path: string;
618
- };
619
- /**
620
- *
621
- */
622
- children?: PageRouteEntry[];
623
- /**
624
- *
625
- */
626
- parent?: PageRoute;
627
- }
628
- interface PageRoute extends PageRouteEntry {
629
- /**
630
- *
631
- */
632
- name: string;
633
- /**
634
- *
635
- */
636
- parent?: PageRoute;
637
- }
638
- interface Layer {
639
- /**
640
- *
641
- */
642
- config?: {
643
- /**
644
- *
645
- */
646
- query?: Record<string, any>;
647
- /**
648
- *
649
- */
650
- params?: Record<string, any>;
651
- /**
652
- *
653
- */
654
- context?: Record<string, any>;
655
- };
656
- /**
657
- *
658
- */
659
- name: string;
660
- /**
661
- *
662
- */
663
- props?: Record<string, any>;
664
- /**
665
- *
666
- */
667
- part?: string;
668
- /**
669
- *
670
- */
671
- element: ReactNode;
672
- /**
673
- *
674
- */
675
- index: number;
676
- /**
677
- *
678
- */
679
- path: string;
680
- }
681
- /**
682
- *
683
- */
684
- type PreviousLayerData = Omit<Layer, "element">;
685
- interface AnchorProps {
686
- /**
687
- *
688
- */
689
- href?: string;
690
- /**
691
- *
692
- * @param ev
693
- */
694
- onClick?: (ev: any) => any;
695
- }
696
- interface RouterMatchOptions {
697
- /**
698
- *
699
- */
700
- previous?: PreviousLayerData[];
701
- /**
702
- *
703
- */
704
- user?: UserAccountInfo;
705
- }
706
- interface RouterEvents {
707
- /**
708
- *
709
- */
710
- begin: undefined;
711
- /**
712
- *
713
- */
714
- success: undefined;
715
- /**
716
- *
717
- */
718
- error: Error;
719
- /**
720
- *
721
- */
722
- end: RouterState;
723
- }
724
- interface RouterState {
725
- /**
726
- *
727
- */
728
- pathname: string;
729
- /**
730
- *
731
- */
732
- search: string;
733
- /**
734
- *
735
- */
736
- layers: Array<Layer>;
737
- }
738
- interface RouterRenderOptions extends RouterMatchOptions {
739
- /**
740
- * State to update.
741
- */
742
- state?: RouterState;
743
- }
744
- interface RouterStackItem {
745
- route: PageRoute;
746
- config?: Record<string, any>;
747
- props?: Record<string, any>;
748
- error?: Error;
749
- }
750
-
751
- interface RouterContextValue {
752
- router: Router;
753
- alepha: Alepha;
754
- state: RouterState;
755
- session?: Session;
756
- }
757
- declare const RouterContext: react.Context<RouterContextValue | undefined>;
758
-
759
- interface RouterLayerContextValue {
760
- index: number;
761
- path: string;
762
- }
763
- declare const RouterLayerContext: react.Context<RouterLayerContextValue | undefined>;
764
-
765
- declare const useActive: (path: HrefLike) => UseActiveHook;
766
- interface UseActiveHook {
767
- isActive: boolean;
768
- anchorProps: AnchorProps;
769
- isPending: boolean;
770
- name?: string;
771
- }
772
-
773
- declare const useClient: () => HttpClient;
774
-
775
- declare const useInject: <T extends object>(classEntry: ClassEntry<T>) => T;
776
-
777
- interface UseQueryParamsHookOptions {
778
- format?: "base64" | "querystring";
779
- key?: string;
780
- push?: boolean;
781
- }
782
- declare const useQueryParams: <T extends TObject$1>(schema: T, options?: UseQueryParamsHookOptions) => [Static$1<T>, (data: Static$1<T>) => void];
783
-
784
- /**
785
- *
786
- */
787
- declare const useRouter: () => RouterHookApi;
788
-
789
- declare const useRouterEvents: (opts?: {
790
- onBegin?: () => void;
791
- onEnd?: (it: RouterState) => void;
792
- onError?: (it: Error) => void;
793
- }) => void;
794
-
795
- declare const useRouterState: () => RouterState;
796
-
797
- declare class PageDescriptorProvider {
798
- protected readonly alepha: Alepha;
799
- protected readonly router: Router;
800
- protected readonly configure: _alepha_core.HookDescriptor<"configure">;
801
- /**
802
- * Transform
803
- * @param pages
804
- * @param target
805
- * @protected
806
- */
807
- protected map(pages: Array<{
808
- value: {
809
- options: PageDescriptorOptions;
810
- };
811
- }>, target: {
812
- options: PageDescriptorOptions;
813
- }): PageRouteEntry;
814
- }
815
-
816
- declare const envSchema: TObject<{
817
- REACT_SERVER_DIST: TString;
818
- REACT_SERVER_PREFIX: TString;
819
- REACT_SSR_ENABLED: TBoolean;
820
- REACT_SSR_OUTLET: TString;
821
- }>;
822
- declare module "@alepha/core" {
823
- interface Env extends Partial<Static$1<typeof envSchema>> {
824
- }
825
- }
826
- declare class ReactServerProvider {
827
- protected readonly log: _alepha_core.Logger;
828
- protected readonly alepha: Alepha;
829
- protected readonly router: Router;
830
- protected readonly server: ServerProvider;
831
- protected readonly env: {
832
- REACT_SERVER_DIST: string;
833
- REACT_SERVER_PREFIX: string;
834
- REACT_SSR_ENABLED: boolean;
835
- REACT_SSR_OUTLET: string;
836
- };
837
- protected readonly configure: _alepha_core.HookDescriptor<"configure">;
838
- protected configureRoutes(): Promise<void>;
839
- /**
840
- *
841
- * @param root
842
- * @protected
843
- */
844
- protected createStaticHandler(root: string): ServeDescriptorOptions;
845
- /**
846
- *
847
- * @param templateLoader
848
- * @protected
849
- */
850
- protected createHandler(templateLoader: () => Promise<string | undefined>): RouteObject;
851
- protected processDescriptors(): void;
852
- /**
853
- *
854
- * @param url
855
- * @protected
856
- */
857
- protected notFoundHandler(url: string): Response | undefined;
858
- /**
859
- *
860
- * @param url
861
- * @param template
862
- * @param user
863
- */
864
- ssr(url: string, template?: string, user?: UserAccountInfo): Promise<Response>;
865
- }
866
-
867
- declare class ReactModule {
868
- protected readonly alepha: Alepha;
869
- constructor();
870
- }
871
-
872
- export { $page, type AnchorProps, type HrefLike, type Layer, NestedView, type PageDescriptor, type PageDescriptorConfigSchema, type PageDescriptorConfigValue, type PageDescriptorOptions, PageDescriptorProvider, type PageRoute, type PageRouteEntry, type PreviousLayerData, ReactBrowserProvider, ReactModule, ReactServerProvider, type ReactServerSession, ReactSessionProvider, RedirectException, Router, RouterContext, type RouterContextValue, type RouterEvents, type RouterGoOptions, RouterHookApi, RouterLayerContext, type RouterLayerContextValue, type RouterMatchOptions, type RouterRenderOptions, type RouterStackItem, type RouterState, type Session, type TPropsDefault, type TPropsParentDefault, type UseActiveHook, type UseQueryParamsHookOptions, envSchema, pageDescriptorKey, sessionSchema, sessionUserSchema, useActive, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };