@stone-js/use-react 0.2.0 → 0.3.1
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/browser.js +172 -168
- package/dist/index.d.ts +273 -278
- package/dist/index.js +291 -287
- package/package.json +15 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HeadContext as HeadContext$1, HTMLMetaDescriptor, FunctionalEventHandler, Route, Router, DecoratorPageRouteDefinition, NavigateOptions } from '@stone-js/router';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ElementType, FunctionComponent } from 'react';
|
|
3
|
+
import { ReactNode, ElementType, FunctionComponent, AnchorHTMLAttributes, HTMLAttributes } from 'react';
|
|
4
4
|
import { Config } from '@stone-js/config';
|
|
5
5
|
import { BrowserEvent, BrowserResponse, BrowserContext, BrowserAdapterResponseBuilder } from '@stone-js/browser-adapter';
|
|
6
6
|
import { IncomingHttpEvent, OutgoingHttpResponse, RedirectResponse, IncomingHttpEventOptions, RedirectResponseOptions, OutgoingHttpResponseOptions } from '@stone-js/http-core';
|
|
7
|
-
import { IncomingBrowserEvent, OutgoingBrowserResponse, RedirectBrowserResponse,
|
|
8
|
-
import {
|
|
7
|
+
import { IncomingBrowserEvent, IncomingBrowserEventOptions, OutgoingBrowserResponse, RedirectBrowserResponse, RedirectBrowserResponseOptions, OutgoingBrowserResponseOptions } from '@stone-js/browser-core';
|
|
8
|
+
import { AdapterErrorHandlerOptions, FunctionalAdapterErrorHandler, IBlueprint, IContainer, AdapterContext, ErrorHandlerOptions, FunctionalErrorHandler, Promiseable, HookName as HookName$1, Laziable, LifecycleHookType, OutgoingResponseOptions, IEventHandler, IErrorHandler, AdapterErrorContext, IServiceProvider, AppConfig, StoneBlueprint, IAdapterErrorHandler, AdapterEventBuilderType, ClassType, BlueprintContext, NextMiddleware, InitializationError, ErrorOptions, ILogger, MetaMiddleware } from '@stone-js/core';
|
|
9
9
|
import { Root } from 'react-dom/client';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Stone DOM Attribute.
|
|
13
|
+
*/
|
|
14
|
+
declare const STONE_DOM_ATTR = "data-stone-head";
|
|
15
|
+
/**
|
|
16
|
+
* Apply meta tags to the document document.head.
|
|
17
|
+
*
|
|
18
|
+
* @param document - The document object.
|
|
19
|
+
* @param meta - The meta tag descriptor.
|
|
20
|
+
*/
|
|
21
|
+
declare const applyMeta: (document: Document, meta: HTMLMetaDescriptor) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Apply the head context to the document document.head.
|
|
24
|
+
*
|
|
25
|
+
* @param document - The document object.
|
|
26
|
+
* @param context - The head context containing meta, link, script, and style descriptors.
|
|
27
|
+
*/
|
|
28
|
+
declare const applyHeadContextToDom: (document: Document, context: HeadContext$1) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Escape HTML special characters in a string.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The head context containing meta, link, script, and style descriptors.
|
|
33
|
+
* @param html - The HTML string to escape.
|
|
34
|
+
* @returns The escaped string.
|
|
35
|
+
*/
|
|
36
|
+
declare const applyHeadContextToHtmlString: (context: HeadContext$1, html: string) => string;
|
|
37
|
+
|
|
11
38
|
/**
|
|
12
39
|
* The type representing the Head Context for React.
|
|
13
40
|
* It extends the BaseHeadContext to include additional properties specific to React.
|
|
@@ -363,6 +390,89 @@ interface MetaAdapterErrorPage<RawEventType, RawResponseType, ExecutionContextTy
|
|
|
363
390
|
module: AdapterErrorPageType<RawEventType, RawResponseType, ExecutionContextType> | Laziable<AdapterErrorPageType<RawEventType, RawResponseType, ExecutionContextType>>;
|
|
364
391
|
}
|
|
365
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Stone context.
|
|
395
|
+
* Usefull to pass data to the components.
|
|
396
|
+
*/
|
|
397
|
+
declare const StoneContext: react.Context<StoneContextType>;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* A useReact event handler for processing incoming events
|
|
401
|
+
* For single event handler.
|
|
402
|
+
*
|
|
403
|
+
* Multiple event handlers will be processed by the router.
|
|
404
|
+
*
|
|
405
|
+
* @template IncomingEventType - The type representing the incoming event.
|
|
406
|
+
* @template OutgoingResponseType - The type representing the outgoing response.
|
|
407
|
+
*/
|
|
408
|
+
declare class UseReactEventHandler<IncomingEventType extends ReactIncomingEvent = ReactIncomingEvent> implements IEventHandler<IncomingEventType, MetaPage<IncomingEventType>> {
|
|
409
|
+
private readonly blueprint;
|
|
410
|
+
/**
|
|
411
|
+
* Constructs a `UseReactEventHandler` instance.
|
|
412
|
+
*
|
|
413
|
+
* @param options - The UseReactEventHandler options including blueprint.
|
|
414
|
+
*/
|
|
415
|
+
constructor({ blueprint }: {
|
|
416
|
+
blueprint: IBlueprint;
|
|
417
|
+
});
|
|
418
|
+
/**
|
|
419
|
+
* Handle an incoming event.
|
|
420
|
+
*
|
|
421
|
+
* @returns The outgoing response.
|
|
422
|
+
*/
|
|
423
|
+
handle(): MetaPage<IncomingEventType>;
|
|
424
|
+
/**
|
|
425
|
+
* Get the component event handler.
|
|
426
|
+
*
|
|
427
|
+
* @returns The component event handler.
|
|
428
|
+
* @throws {UseReactError} If the component event handler is missing.
|
|
429
|
+
*/
|
|
430
|
+
private getComponentEventHandler;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* UseReactError response type.
|
|
435
|
+
*/
|
|
436
|
+
type UseReactErrorResponseType = Record<'content' | 'statusCode', Partial<MetaErrorPage<ReactIncomingEvent>> | number>;
|
|
437
|
+
/**
|
|
438
|
+
* Class representing an UseReactUseReactKernelErrorHandler.
|
|
439
|
+
*
|
|
440
|
+
* Kernel level error handler for React applications.
|
|
441
|
+
*/
|
|
442
|
+
declare class UseReactKernelErrorHandler implements IErrorHandler<ReactIncomingEvent, UseReactErrorResponseType> {
|
|
443
|
+
private readonly blueprint;
|
|
444
|
+
/**
|
|
445
|
+
* Create an UseReactUseReactKernelErrorHandler.
|
|
446
|
+
*
|
|
447
|
+
* @param options - UseReactUseReactKernelErrorHandler options.
|
|
448
|
+
*/
|
|
449
|
+
constructor({ blueprint }: {
|
|
450
|
+
blueprint: IBlueprint;
|
|
451
|
+
});
|
|
452
|
+
/**
|
|
453
|
+
* Handle an error.
|
|
454
|
+
*
|
|
455
|
+
* @param error - The error to handle.
|
|
456
|
+
* @returns The outgoing http response.
|
|
457
|
+
*/
|
|
458
|
+
handle(error: any): UseReactErrorResponseType;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Options for onPreparingResponse hook.
|
|
463
|
+
*/
|
|
464
|
+
interface OnPreparingResponseOptions {
|
|
465
|
+
container: IContainer;
|
|
466
|
+
event: IncomingBrowserEvent;
|
|
467
|
+
response: ReactOutgoingResponse;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Hook that runs just before preparing the response.
|
|
471
|
+
*
|
|
472
|
+
* @param context - The context of the hook.
|
|
473
|
+
*/
|
|
474
|
+
declare function onPreparingResponse({ event, response, container }: OnPreparingResponseOptions): Promise<void>;
|
|
475
|
+
|
|
366
476
|
/**
|
|
367
477
|
* ReactRuntimeOptions
|
|
368
478
|
*/
|
|
@@ -448,114 +558,41 @@ declare const MetaReactRuntime: {
|
|
|
448
558
|
};
|
|
449
559
|
|
|
450
560
|
/**
|
|
451
|
-
|
|
452
|
-
*/
|
|
453
|
-
declare const STONE_DOM_ATTR = "data-stone-head";
|
|
454
|
-
/**
|
|
455
|
-
* Apply meta tags to the document document.head.
|
|
456
|
-
*
|
|
457
|
-
* @param document - The document object.
|
|
458
|
-
* @param meta - The meta tag descriptor.
|
|
459
|
-
*/
|
|
460
|
-
declare const applyMeta: (document: Document, meta: HTMLMetaDescriptor) => void;
|
|
461
|
-
/**
|
|
462
|
-
* Apply the head context to the document document.head.
|
|
561
|
+
* Prepare the page to render.
|
|
463
562
|
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*/
|
|
467
|
-
declare const applyHeadContextToDom: (document: Document, context: HeadContext$1) => void;
|
|
468
|
-
/**
|
|
469
|
-
* Escape HTML special characters in a string.
|
|
563
|
+
* Here we prepare the page to render by resolving
|
|
564
|
+
* the handler, handler the event, and rendering the component.
|
|
470
565
|
*
|
|
471
|
-
* @param
|
|
472
|
-
* @param
|
|
473
|
-
* @
|
|
566
|
+
* @param event - The incoming HTTP event.
|
|
567
|
+
* @param response - The outgoing HTTP response.
|
|
568
|
+
* @param container - The service container.
|
|
569
|
+
* @param snapshot - The response snapshot.
|
|
474
570
|
*/
|
|
475
|
-
declare
|
|
476
|
-
|
|
571
|
+
declare function preparePage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
|
|
477
572
|
/**
|
|
478
|
-
*
|
|
479
|
-
* For single event handler.
|
|
573
|
+
* Prepare the error page to render.
|
|
480
574
|
*
|
|
481
|
-
*
|
|
575
|
+
* Error pages are prepared sepatately because their handler
|
|
576
|
+
* is different from the normal page handler.
|
|
577
|
+
* Their handler takes an error as the first argument and the event as the second.
|
|
482
578
|
*
|
|
483
|
-
* @
|
|
484
|
-
* @
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
private readonly blueprint;
|
|
488
|
-
/**
|
|
489
|
-
* Constructs a `UseReactEventHandler` instance.
|
|
490
|
-
*
|
|
491
|
-
* @param options - The UseReactEventHandler options including blueprint.
|
|
492
|
-
*/
|
|
493
|
-
constructor({ blueprint }: {
|
|
494
|
-
blueprint: IBlueprint;
|
|
495
|
-
});
|
|
496
|
-
/**
|
|
497
|
-
* Handle an incoming event.
|
|
498
|
-
*
|
|
499
|
-
* @returns The outgoing response.
|
|
500
|
-
*/
|
|
501
|
-
handle(): MetaPage<IncomingEventType>;
|
|
502
|
-
/**
|
|
503
|
-
* Get the component event handler.
|
|
504
|
-
*
|
|
505
|
-
* @returns The component event handler.
|
|
506
|
-
* @throws {UseReactError} If the component event handler is missing.
|
|
507
|
-
*/
|
|
508
|
-
private getComponentEventHandler;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Stone context.
|
|
513
|
-
* Usefull to pass data to the components.
|
|
514
|
-
*/
|
|
515
|
-
declare const StoneContext: react.Context<StoneContextType>;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* UseReactError response type.
|
|
579
|
+
* @param event - The incoming HTTP event.
|
|
580
|
+
* @param response - The outgoing HTTP response.
|
|
581
|
+
* @param container - The service container.
|
|
582
|
+
* @param snapshot - The response snapshot.
|
|
519
583
|
*/
|
|
520
|
-
|
|
584
|
+
declare function prepareErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
|
|
521
585
|
/**
|
|
522
|
-
*
|
|
586
|
+
* Prepare the fallback error page to render.
|
|
523
587
|
*
|
|
524
|
-
*
|
|
525
|
-
*/
|
|
526
|
-
declare class UseReactKernelErrorHandler implements IErrorHandler<ReactIncomingEvent, UseReactErrorResponseType> {
|
|
527
|
-
private readonly blueprint;
|
|
528
|
-
/**
|
|
529
|
-
* Create an UseReactUseReactKernelErrorHandler.
|
|
530
|
-
*
|
|
531
|
-
* @param options - UseReactUseReactKernelErrorHandler options.
|
|
532
|
-
*/
|
|
533
|
-
constructor({ blueprint }: {
|
|
534
|
-
blueprint: IBlueprint;
|
|
535
|
-
});
|
|
536
|
-
/**
|
|
537
|
-
* Handle an error.
|
|
538
|
-
*
|
|
539
|
-
* @param error - The error to handle.
|
|
540
|
-
* @returns The outgoing http response.
|
|
541
|
-
*/
|
|
542
|
-
handle(error: any): UseReactErrorResponseType;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Options for onPreparingResponse hook.
|
|
547
|
-
*/
|
|
548
|
-
interface OnPreparingResponseOptions {
|
|
549
|
-
container: IContainer;
|
|
550
|
-
event: IncomingBrowserEvent;
|
|
551
|
-
response: ReactOutgoingResponse;
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Hook that runs just before preparing the response.
|
|
588
|
+
* We prepare a fallback error page if no event nor error handler is provided.
|
|
555
589
|
*
|
|
556
|
-
* @param
|
|
557
|
-
|
|
558
|
-
|
|
590
|
+
* @param event - The incoming event.
|
|
591
|
+
* @param response - The outgoing response.
|
|
592
|
+
* @param container - The service container.
|
|
593
|
+
* @param snapshot - The response snapshot.
|
|
594
|
+
*/
|
|
595
|
+
declare function prepareFallbackErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
|
|
559
596
|
|
|
560
597
|
/**
|
|
561
598
|
* Build the React application for the current route.
|
|
@@ -777,48 +814,11 @@ declare const MetaUseReactServiceProvider: {
|
|
|
777
814
|
};
|
|
778
815
|
|
|
779
816
|
/**
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
* Here we prepare the page to render by resolving
|
|
783
|
-
* the handler, handler the event, and rendering the component.
|
|
784
|
-
*
|
|
785
|
-
* @param event - The incoming HTTP event.
|
|
786
|
-
* @param response - The outgoing HTTP response.
|
|
787
|
-
* @param container - The service container.
|
|
788
|
-
* @param snapshot - The response snapshot.
|
|
817
|
+
* Constants for the Stone SNAPSHOT
|
|
789
818
|
*/
|
|
790
|
-
declare
|
|
819
|
+
declare const STONE_SNAPSHOT = "__STONE_SNAPSHOT__";
|
|
791
820
|
/**
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
* Error pages are prepared sepatately because their handler
|
|
795
|
-
* is different from the normal page handler.
|
|
796
|
-
* Their handler takes an error as the first argument and the event as the second.
|
|
797
|
-
*
|
|
798
|
-
* @param event - The incoming HTTP event.
|
|
799
|
-
* @param response - The outgoing HTTP response.
|
|
800
|
-
* @param container - The service container.
|
|
801
|
-
* @param snapshot - The response snapshot.
|
|
802
|
-
*/
|
|
803
|
-
declare function prepareErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
|
|
804
|
-
/**
|
|
805
|
-
* Prepare the fallback error page to render.
|
|
806
|
-
*
|
|
807
|
-
* We prepare a fallback error page if no event nor error handler is provided.
|
|
808
|
-
*
|
|
809
|
-
* @param event - The incoming event.
|
|
810
|
-
* @param response - The outgoing response.
|
|
811
|
-
* @param container - The service container.
|
|
812
|
-
* @param snapshot - The response snapshot.
|
|
813
|
-
*/
|
|
814
|
-
declare function prepareFallbackErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* Constants for the Stone SNAPSHOT
|
|
818
|
-
*/
|
|
819
|
-
declare const STONE_SNAPSHOT = "__STONE_SNAPSHOT__";
|
|
820
|
-
/**
|
|
821
|
-
* Constants for the Stone Page Event Outlet
|
|
821
|
+
* Constants for the Stone Page Event Outlet
|
|
822
822
|
*/
|
|
823
823
|
declare const STONE_PAGE_EVENT_OUTLET = "stone:inject:react-page:outlet";
|
|
824
824
|
|
|
@@ -905,6 +905,35 @@ declare function defineAdapterErrorPage(module: AdapterErrorPageClass<unknown, u
|
|
|
905
905
|
isClass: boolean;
|
|
906
906
|
}): UseReactBlueprint;
|
|
907
907
|
|
|
908
|
+
/**
|
|
909
|
+
* Defines a Stone React app using a factory-based main handler.
|
|
910
|
+
*
|
|
911
|
+
* @param module - A factory function for the main page.
|
|
912
|
+
* @param options - Optional application-level configuration.
|
|
913
|
+
* @param blueprints - Additional blueprints to merge.
|
|
914
|
+
* @returns A fully merged Stone blueprint.
|
|
915
|
+
*/
|
|
916
|
+
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: FactoryPage<U>, options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
917
|
+
/**
|
|
918
|
+
* Defines a Stone React app using a class-based main handler.
|
|
919
|
+
*
|
|
920
|
+
* @param module - A class constructor for the main page.
|
|
921
|
+
* @param options - Optional application-level configuration.
|
|
922
|
+
* @param blueprints - Additional blueprints to merge.
|
|
923
|
+
* @returns A fully merged Stone blueprint.
|
|
924
|
+
*/
|
|
925
|
+
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: PageClass<U>, options: Partial<UseReactAppConfig> & {
|
|
926
|
+
isClass: boolean;
|
|
927
|
+
}, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
928
|
+
/**
|
|
929
|
+
* Defines a Stone React app without a main handler (router-only).
|
|
930
|
+
*
|
|
931
|
+
* @param options - Application-level configuration.
|
|
932
|
+
* @param blueprints - Additional blueprints to merge.
|
|
933
|
+
* @returns A fully merged Stone blueprint.
|
|
934
|
+
*/
|
|
935
|
+
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
936
|
+
|
|
908
937
|
/**
|
|
909
938
|
* Utility function to define a factory-based page.
|
|
910
939
|
*
|
|
@@ -966,35 +995,6 @@ declare function defineErrorPage(module: ErrorPageClass<ReactIncomingEvent>, opt
|
|
|
966
995
|
isClass: true;
|
|
967
996
|
}): UseReactBlueprint;
|
|
968
997
|
|
|
969
|
-
/**
|
|
970
|
-
* Defines a Stone React app using a factory-based main handler.
|
|
971
|
-
*
|
|
972
|
-
* @param module - A factory function for the main page.
|
|
973
|
-
* @param options - Optional application-level configuration.
|
|
974
|
-
* @param blueprints - Additional blueprints to merge.
|
|
975
|
-
* @returns A fully merged Stone blueprint.
|
|
976
|
-
*/
|
|
977
|
-
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: FactoryPage<U>, options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
978
|
-
/**
|
|
979
|
-
* Defines a Stone React app using a class-based main handler.
|
|
980
|
-
*
|
|
981
|
-
* @param module - A class constructor for the main page.
|
|
982
|
-
* @param options - Optional application-level configuration.
|
|
983
|
-
* @param blueprints - Additional blueprints to merge.
|
|
984
|
-
* @returns A fully merged Stone blueprint.
|
|
985
|
-
*/
|
|
986
|
-
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: PageClass<U>, options: Partial<UseReactAppConfig> & {
|
|
987
|
-
isClass: boolean;
|
|
988
|
-
}, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
989
|
-
/**
|
|
990
|
-
* Defines a Stone React app without a main handler (router-only).
|
|
991
|
-
*
|
|
992
|
-
* @param options - Application-level configuration.
|
|
993
|
-
* @param blueprints - Additional blueprints to merge.
|
|
994
|
-
* @returns A fully merged Stone blueprint.
|
|
995
|
-
*/
|
|
996
|
-
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
997
|
-
|
|
998
998
|
/**
|
|
999
999
|
* UseReactBrowserErrorHandler options.
|
|
1000
1000
|
*/
|
|
@@ -1047,33 +1047,9 @@ declare const reactResponse: (options: ReactResponseOptions) => ReactOutgoingRes
|
|
|
1047
1047
|
*/
|
|
1048
1048
|
declare const reactRedirectResponse: (options: ReactRedirectResponseOptions) => ReactOutgoingResponse;
|
|
1049
1049
|
|
|
1050
|
-
|
|
1051
|
-
* Stone Error.
|
|
1052
|
-
*/
|
|
1053
|
-
declare const StoneError: FunctionComponent;
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
* Stone Client options.
|
|
1057
|
-
*/
|
|
1058
|
-
interface StoneClientOptions {
|
|
1059
|
-
children: ReactNode;
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* Stone Client.
|
|
1063
|
-
* This component is used to wrap content
|
|
1064
|
-
* that should only be rendered on the client.
|
|
1065
|
-
*
|
|
1066
|
-
* @param options - The options to create the Stone Client.
|
|
1067
|
-
*/
|
|
1068
|
-
declare const StoneClient: FunctionComponent<StoneClientOptions>;
|
|
1069
|
-
|
|
1070
|
-
interface BaseProps {
|
|
1071
|
-
rel?: string;
|
|
1072
|
-
href?: string;
|
|
1073
|
-
target?: string;
|
|
1050
|
+
interface BaseProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
1074
1051
|
noRel?: boolean;
|
|
1075
1052
|
external?: boolean;
|
|
1076
|
-
className?: string;
|
|
1077
1053
|
children: ReactNode;
|
|
1078
1054
|
defaultNav?: boolean;
|
|
1079
1055
|
selectedClass?: string;
|
|
@@ -1087,10 +1063,15 @@ type StoneLinkOptions = (BaseProps & {
|
|
|
1087
1063
|
to: string | NavigateOptions;
|
|
1088
1064
|
});
|
|
1089
1065
|
/**
|
|
1090
|
-
*
|
|
1066
|
+
* Internal link component using Stone.js router.
|
|
1091
1067
|
*/
|
|
1092
1068
|
declare const StoneLink: FunctionComponent<StoneLinkOptions>;
|
|
1093
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
* Stone Error.
|
|
1072
|
+
*/
|
|
1073
|
+
declare const StoneError: FunctionComponent;
|
|
1074
|
+
|
|
1094
1075
|
/**
|
|
1095
1076
|
* Stone Page options.
|
|
1096
1077
|
*/
|
|
@@ -1115,8 +1096,7 @@ declare const StonePage: FunctionComponent<StonePageOptions>;
|
|
|
1115
1096
|
/**
|
|
1116
1097
|
* Stone Outlet options.
|
|
1117
1098
|
*/
|
|
1118
|
-
interface StoneOutletOptions {
|
|
1119
|
-
children: ReactNode;
|
|
1099
|
+
interface StoneOutletOptions extends HTMLAttributes<HTMLDivElement> {
|
|
1120
1100
|
}
|
|
1121
1101
|
/**
|
|
1122
1102
|
* A dynamic rendering component that updates its content based on a global event.
|
|
@@ -1147,6 +1127,21 @@ interface StoneServerOptions {
|
|
|
1147
1127
|
*/
|
|
1148
1128
|
declare const StoneServer: FunctionComponent<StoneServerOptions>;
|
|
1149
1129
|
|
|
1130
|
+
/**
|
|
1131
|
+
* Stone Client options.
|
|
1132
|
+
*/
|
|
1133
|
+
interface StoneClientOptions {
|
|
1134
|
+
children: ReactNode;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Stone Client.
|
|
1138
|
+
* This component is used to wrap content
|
|
1139
|
+
* that should only be rendered on the client.
|
|
1140
|
+
*
|
|
1141
|
+
* @param options - The options to create the Stone Client.
|
|
1142
|
+
*/
|
|
1143
|
+
declare const StoneClient: FunctionComponent<StoneClientOptions>;
|
|
1144
|
+
|
|
1150
1145
|
/**
|
|
1151
1146
|
* A class decorator for defining a class as a React Handler layout.
|
|
1152
1147
|
*
|
|
@@ -1187,24 +1182,6 @@ declare const AdapterErrorPage: <T extends ClassType = ClassType>(options: Adapt
|
|
|
1187
1182
|
*/
|
|
1188
1183
|
declare const ErrorPage: <T extends ClassType = ClassType>(options: ErrorPageOptions) => ClassDecorator;
|
|
1189
1184
|
|
|
1190
|
-
/**
|
|
1191
|
-
* Hook decorator to mark a method as a lifecycle hook
|
|
1192
|
-
* And automatically add it to the global lifecycle hook registry.
|
|
1193
|
-
*
|
|
1194
|
-
* @example
|
|
1195
|
-
* ```typescript
|
|
1196
|
-
* class MyClass {
|
|
1197
|
-
* // ...
|
|
1198
|
-
* @Hook('onPreparingPage')
|
|
1199
|
-
* onPreparingPage () {}
|
|
1200
|
-
* }
|
|
1201
|
-
* ```
|
|
1202
|
-
*
|
|
1203
|
-
* @param name - The name of the lifecycle hook.
|
|
1204
|
-
* @returns A class decorator function that sets the metadata using the provided options.
|
|
1205
|
-
*/
|
|
1206
|
-
declare const Hook: <T extends Function = Function>(name: HookName) => MethodDecorator;
|
|
1207
|
-
|
|
1208
1185
|
/**
|
|
1209
1186
|
* A class decorator for defining a class as a React Page route action.
|
|
1210
1187
|
* Uses the `Match` decorator internally to register the route with the HTTP `GET` method.
|
|
@@ -1228,27 +1205,25 @@ declare const Hook: <T extends Function = Function>(name: HookName) => MethodDec
|
|
|
1228
1205
|
* }
|
|
1229
1206
|
* ```
|
|
1230
1207
|
*/
|
|
1231
|
-
declare const Page: <T extends ClassType = ClassType>(path: string, options?: PageOptions) => ClassDecorator;
|
|
1208
|
+
declare const Page: <T extends ClassType = ClassType>(path: string | string[], options?: PageOptions) => ClassDecorator;
|
|
1232
1209
|
|
|
1233
1210
|
/**
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
* @param options - Configuration options for the layout definition.
|
|
1237
|
-
* @returns A method decorator to be applied to a class method.
|
|
1211
|
+
* Hook decorator to mark a method as a lifecycle hook
|
|
1212
|
+
* And automatically add it to the global lifecycle hook registry.
|
|
1238
1213
|
*
|
|
1239
1214
|
* @example
|
|
1240
1215
|
* ```typescript
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
* render({ data }) {
|
|
1246
|
-
* return <h1>User name: {data.name}</h1>;
|
|
1247
|
-
* }
|
|
1216
|
+
* class MyClass {
|
|
1217
|
+
* // ...
|
|
1218
|
+
* @Hook('onPreparingPage')
|
|
1219
|
+
* onPreparingPage () {}
|
|
1248
1220
|
* }
|
|
1249
1221
|
* ```
|
|
1222
|
+
*
|
|
1223
|
+
* @param name - The name of the lifecycle hook.
|
|
1224
|
+
* @returns A class decorator function that sets the metadata using the provided options.
|
|
1250
1225
|
*/
|
|
1251
|
-
declare const
|
|
1226
|
+
declare const Hook: <T extends Function = Function>(name: HookName) => MethodDecorator;
|
|
1252
1227
|
|
|
1253
1228
|
/**
|
|
1254
1229
|
* Decorator to set the status code of the response.
|
|
@@ -1272,6 +1247,26 @@ declare const PageLayout: <T extends ClassType = ClassType>(options: PageLayoutO
|
|
|
1272
1247
|
*/
|
|
1273
1248
|
declare const PageStatus: <T extends Function = Function>(statusCode?: number, headers?: HeadersType) => MethodDecorator;
|
|
1274
1249
|
|
|
1250
|
+
/**
|
|
1251
|
+
* A class decorator for defining a class as a React Page layout.
|
|
1252
|
+
*
|
|
1253
|
+
* @param options - Configuration options for the layout definition.
|
|
1254
|
+
* @returns A method decorator to be applied to a class method.
|
|
1255
|
+
*
|
|
1256
|
+
* @example
|
|
1257
|
+
* ```typescript
|
|
1258
|
+
* import { PageLayout } from '@stone-js/use-react';
|
|
1259
|
+
*
|
|
1260
|
+
* @PageLayout({ name: 'UserPageLayout' })
|
|
1261
|
+
* class UserPageLayout {
|
|
1262
|
+
* render({ data }) {
|
|
1263
|
+
* return <h1>User name: {data.name}</h1>;
|
|
1264
|
+
* }
|
|
1265
|
+
* }
|
|
1266
|
+
* ```
|
|
1267
|
+
*/
|
|
1268
|
+
declare const PageLayout: <T extends ClassType = ClassType>(options: PageLayoutOptions) => ClassDecorator;
|
|
1269
|
+
|
|
1275
1270
|
/**
|
|
1276
1271
|
* Decorator to create a snapshot of the current data.
|
|
1277
1272
|
*
|
|
@@ -1294,6 +1289,31 @@ declare const PageStatus: <T extends Function = Function>(statusCode?: number, h
|
|
|
1294
1289
|
*/
|
|
1295
1290
|
declare const Snapshot: <T extends Function = Function>(name?: string) => MethodDecorator;
|
|
1296
1291
|
|
|
1292
|
+
/**
|
|
1293
|
+
* Constants are defined here to prevent Circular dependency between modules
|
|
1294
|
+
* This pattern must be applied to all Stone libraries or third party libraries.
|
|
1295
|
+
*/
|
|
1296
|
+
/**
|
|
1297
|
+
* A unique symbol key to mark classes as React Page component.
|
|
1298
|
+
*/
|
|
1299
|
+
declare const REACT_PAGE_KEY: unique symbol;
|
|
1300
|
+
/**
|
|
1301
|
+
* A unique symbol key to mark classes as React Page layout component.
|
|
1302
|
+
*/
|
|
1303
|
+
declare const REACT_PAGE_LAYOUT_KEY: unique symbol;
|
|
1304
|
+
/**
|
|
1305
|
+
* A unique symbol key to mark classes as React Error handler component.
|
|
1306
|
+
*/
|
|
1307
|
+
declare const REACT_ERROR_PAGE_KEY: unique symbol;
|
|
1308
|
+
/**
|
|
1309
|
+
* A unique symbol key to mark classes as React Adapter Error handler component.
|
|
1310
|
+
*/
|
|
1311
|
+
declare const REACT_ADAPTER_ERROR_PAGE_KEY: unique symbol;
|
|
1312
|
+
/**
|
|
1313
|
+
* A unique symbol key to mark classes as React Stone application entry point.
|
|
1314
|
+
*/
|
|
1315
|
+
declare const STONE_REACT_APP_KEY: unique symbol;
|
|
1316
|
+
|
|
1297
1317
|
/**
|
|
1298
1318
|
* Blueprint middleware to dynamically set lifecycle hooks for react.
|
|
1299
1319
|
*
|
|
@@ -1362,31 +1382,6 @@ declare const SetReactPageLayoutMiddleware: (context: BlueprintContext<IBlueprin
|
|
|
1362
1382
|
*/
|
|
1363
1383
|
declare function SetUseReactEventHandlerMiddleware(context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>): Promise<IBlueprint>;
|
|
1364
1384
|
|
|
1365
|
-
/**
|
|
1366
|
-
* Constants are defined here to prevent Circular dependency between modules
|
|
1367
|
-
* This pattern must be applied to all Stone libraries or third party libraries.
|
|
1368
|
-
*/
|
|
1369
|
-
/**
|
|
1370
|
-
* A unique symbol key to mark classes as React Page component.
|
|
1371
|
-
*/
|
|
1372
|
-
declare const REACT_PAGE_KEY: unique symbol;
|
|
1373
|
-
/**
|
|
1374
|
-
* A unique symbol key to mark classes as React Page layout component.
|
|
1375
|
-
*/
|
|
1376
|
-
declare const REACT_PAGE_LAYOUT_KEY: unique symbol;
|
|
1377
|
-
/**
|
|
1378
|
-
* A unique symbol key to mark classes as React Error handler component.
|
|
1379
|
-
*/
|
|
1380
|
-
declare const REACT_ERROR_PAGE_KEY: unique symbol;
|
|
1381
|
-
/**
|
|
1382
|
-
* A unique symbol key to mark classes as React Adapter Error handler component.
|
|
1383
|
-
*/
|
|
1384
|
-
declare const REACT_ADAPTER_ERROR_PAGE_KEY: unique symbol;
|
|
1385
|
-
/**
|
|
1386
|
-
* A unique symbol key to mark classes as React Stone application entry point.
|
|
1387
|
-
*/
|
|
1388
|
-
declare const STONE_REACT_APP_KEY: unique symbol;
|
|
1389
|
-
|
|
1390
1385
|
/**
|
|
1391
1386
|
* Custom error for react operations.
|
|
1392
1387
|
*/
|
|
@@ -1441,6 +1436,22 @@ declare class UseReactServerErrorHandler implements IAdapterErrorHandler<unknown
|
|
|
1441
1436
|
*/
|
|
1442
1437
|
declare function setUseReactAdapterErrorHandler(errorHandler: typeof UseReactServerErrorHandler | typeof UseReactBrowserErrorHandler, context: BlueprintContext<IBlueprint, ClassType>): BlueprintContext<IBlueprint, ClassType>;
|
|
1443
1438
|
|
|
1439
|
+
/**
|
|
1440
|
+
* UseReact decorator options.
|
|
1441
|
+
*/
|
|
1442
|
+
interface UseReactOptions extends Partial<UseReactConfig> {
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* UseReact decorator.
|
|
1446
|
+
*
|
|
1447
|
+
* UseReact is a class decorator that allows you to use React components in your Stone application.
|
|
1448
|
+
* The decorator is used to define the React configuration for the class.
|
|
1449
|
+
*
|
|
1450
|
+
* @param options - UseReactOptions
|
|
1451
|
+
* @returns ClassDecorator
|
|
1452
|
+
*/
|
|
1453
|
+
declare const UseReact: <T extends ClassType = ClassType>(options?: UseReactOptions) => ClassDecorator;
|
|
1454
|
+
|
|
1444
1455
|
/**
|
|
1445
1456
|
* Blueprint middleware to set BrowserResponseMiddleware for the Browser adapter.
|
|
1446
1457
|
*
|
|
@@ -1478,6 +1489,13 @@ declare const SetReactAdapterErrorPageMiddleware: (context: BlueprintContext<IBl
|
|
|
1478
1489
|
*/
|
|
1479
1490
|
declare const metaBrowserUseReactBlueprintMiddleware: Array<MetaMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>>;
|
|
1480
1491
|
|
|
1492
|
+
/**
|
|
1493
|
+
* Default blueprint for a React-based Stone.js application.
|
|
1494
|
+
*
|
|
1495
|
+
* - Defines middleware, lifecycle hooks, and the default HTML template path.
|
|
1496
|
+
*/
|
|
1497
|
+
declare const useReactBlueprint: UseReactBlueprint;
|
|
1498
|
+
|
|
1481
1499
|
/**
|
|
1482
1500
|
* Adapter Middleware for handling outgoing responses and rendering them in the browser.
|
|
1483
1501
|
*/
|
|
@@ -1544,28 +1562,5 @@ declare const MetaBrowserResponseMiddleware: {
|
|
|
1544
1562
|
isClass: boolean;
|
|
1545
1563
|
};
|
|
1546
1564
|
|
|
1547
|
-
/**
|
|
1548
|
-
* UseReact decorator options.
|
|
1549
|
-
*/
|
|
1550
|
-
interface UseReactOptions extends Partial<UseReactConfig> {
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
* UseReact decorator.
|
|
1554
|
-
*
|
|
1555
|
-
* UseReact is a class decorator that allows you to use React components in your Stone application.
|
|
1556
|
-
* The decorator is used to define the React configuration for the class.
|
|
1557
|
-
*
|
|
1558
|
-
* @param options - UseReactOptions
|
|
1559
|
-
* @returns ClassDecorator
|
|
1560
|
-
*/
|
|
1561
|
-
declare const UseReact: <T extends ClassType = ClassType>(options?: UseReactOptions) => ClassDecorator;
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* Default blueprint for a React-based Stone.js application.
|
|
1565
|
-
*
|
|
1566
|
-
* - Defines middleware, lifecycle hooks, and the default HTML template path.
|
|
1567
|
-
*/
|
|
1568
|
-
declare const useReactBlueprint: UseReactBlueprint;
|
|
1569
|
-
|
|
1570
1565
|
export { AdapterErrorPage, BrowserResponseMiddleware, ErrorPage, Hook, MetaBrowserResponseMiddleware, MetaReactRuntime, MetaUseReactServiceProvider, Page, PageLayout, PageStatus, REACT_ADAPTER_ERROR_PAGE_KEY, REACT_ERROR_PAGE_KEY, REACT_PAGE_KEY, REACT_PAGE_LAYOUT_KEY, ReactRuntime, STONE_DOM_ATTR, STONE_PAGE_EVENT_OUTLET, STONE_REACT_APP_KEY, STONE_SNAPSHOT, SetBrowserResponseMiddlewareMiddleware, SetReactAdapterErrorPageMiddleware, SetReactKernelErrorPageMiddleware, SetReactPageLayoutMiddleware, SetReactRouteDefinitionsMiddleware, SetUseReactEventHandlerMiddleware, SetUseReactHooksMiddleware, Snapshot, StoneClient, StoneContext, StoneError, StoneLink, StoneOutlet, StonePage, StoneServer, UseReact, UseReactBrowserErrorHandler, UseReactError, UseReactEventHandler, UseReactKernelErrorHandler, UseReactServiceProvider, applyHeadContextToDom, applyHeadContextToHtmlString, applyMeta, buildAdapterErrorComponent, buildAppComponent, buildLayoutComponent, buildPageComponent, defineAdapterErrorPage, defineErrorPage, definePage, definePageLayout, defineStoneReactApp, executeHandler, executeHooks, getAppRootElement, getBrowserContent, getResponseSnapshot, getServerContent, htmlTemplate, hydrateReactApp, internalUseReactBlueprint, isClient, isSSR, isServer, metaBrowserUseReactBlueprintMiddleware, onPreparingResponse, prepareErrorPage, prepareFallbackErrorPage, preparePage, reactRedirectResponse, reactResponse, renderReactApp, renderStoneSnapshot, resolveComponent, resolveLazyComponent, setUseReactAdapterErrorHandler, snapshotResponse, useReactBlueprint };
|
|
1571
1566
|
export type { AdapterErrorPageClass, AdapterErrorPageOptions, AdapterErrorPageRenderContext, AdapterErrorPageType, AdapterPageLayoutRenderContext, BrowserResponseContent, ErrorPageClass, ErrorPageHeadContext, ErrorPageOptions, ErrorPageRenderContext, ErrorPageType, FactoryAdapterErrorPage, FactoryErrorPage, FactoryPage, FactoryPageLayout, HeadContext, HeadersType, HookName, IAdapterErrorPage, IErrorPage, IPage, IPageLayout, IRoute, IRouter, ISnapshot, MetaAdapterErrorPage, MetaErrorPage, MetaPage, MetaPageLayout, OnPreparingResponseOptions, PageClass, PageHeadContext, PageLayoutClass, PageLayoutOptions, PageLayoutRenderContext, PageLayoutType, PageOptions, PageRenderContext, PageType, ReactBrowserAdapterContext, ReactIncomingEvent, ReactIncomingEventOptions, ReactLifecycleHookType, ReactOutgoingResponse, ReactOutgoingResponseOptions, ReactRedirectResponseOptions, ReactResponseOptions, ReactRuntimeOptions, ResponseSnapshotType, StoneContextType, StoneLinkOptions, StoneOutletOptions, UseReactAppConfig, UseReactBlueprint, UseReactBrowserErrorHandlerOptions, UseReactConfig, UseReactErrorResponseType, UseReactHookListener, UseReactHookListenerContext, UseReactHookName, UseReactHookType, UseReactOptions, UseReactServiceProviderOptions };
|