@stone-js/use-react 0.1.0 → 0.2.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/README.md +2 -2
- package/dist/browser.js +1790 -0
- package/dist/index.d.ts +356 -351
- package/dist/index.js +433 -590
- package/package.json +11 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionalEventHandler, HeadContext as HeadContext$1, Route, Router, DecoratorPageRouteDefinition, HTMLMetaDescriptor, NavigateOptions } from '@stone-js/router';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode, ElementType, FunctionComponent } from 'react';
|
|
4
4
|
import { Config } from '@stone-js/config';
|
|
5
5
|
import { BrowserEvent, BrowserResponse, BrowserContext, BrowserAdapterResponseBuilder } from '@stone-js/browser-adapter';
|
|
6
|
-
import { IncomingHttpEvent, OutgoingHttpResponse, RedirectResponse, IncomingHttpEventOptions,
|
|
7
|
-
import { IncomingBrowserEvent, OutgoingBrowserResponse, RedirectBrowserResponse, IncomingBrowserEventOptions,
|
|
8
|
-
import { IContainer, Promiseable, Laziable, FunctionalErrorHandler, IBlueprint, FunctionalAdapterErrorHandler, OutgoingResponseOptions, HookName as HookName$1, LifecycleHookType, ErrorHandlerOptions, AdapterErrorHandlerOptions, AdapterContext,
|
|
6
|
+
import { IncomingHttpEvent, OutgoingHttpResponse, RedirectResponse, IncomingHttpEventOptions, RedirectResponseOptions, OutgoingHttpResponseOptions } from '@stone-js/http-core';
|
|
7
|
+
import { IncomingBrowserEvent, OutgoingBrowserResponse, RedirectBrowserResponse, IncomingBrowserEventOptions, RedirectBrowserResponseOptions, OutgoingBrowserResponseOptions } from '@stone-js/browser-core';
|
|
8
|
+
import { IContainer, Promiseable, Laziable, FunctionalErrorHandler, IBlueprint, FunctionalAdapterErrorHandler, OutgoingResponseOptions, HookName as HookName$1, LifecycleHookType, ErrorHandlerOptions, AdapterErrorHandlerOptions, AdapterContext, IEventHandler, IErrorHandler, AdapterErrorContext, IServiceProvider, StoneBlueprint, AppConfig, 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
|
-
|
|
38
11
|
/**
|
|
39
12
|
* The type representing the Head Context for React.
|
|
40
13
|
* It extends the BaseHeadContext to include additional properties specific to React.
|
|
@@ -66,6 +39,14 @@ type ReactIncomingEvent = IncomingHttpEvent | IncomingBrowserEvent;
|
|
|
66
39
|
* Incoming event options for React.
|
|
67
40
|
*/
|
|
68
41
|
type ReactIncomingEventOptions = IncomingBrowserEventOptions | IncomingHttpEventOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Redirect response options for React.
|
|
44
|
+
*/
|
|
45
|
+
type ReactRedirectResponseOptions = RedirectResponseOptions | RedirectBrowserResponseOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Outgoing response options for React.
|
|
48
|
+
*/
|
|
49
|
+
type ReactResponseOptions = OutgoingHttpResponseOptions | ReactOutgoingResponseOptions | ReactRedirectResponseOptions | OutgoingBrowserResponseOptions;
|
|
69
50
|
/**
|
|
70
51
|
* Outgoing response for React.
|
|
71
52
|
*/
|
|
@@ -467,47 +448,31 @@ declare const MetaReactRuntime: {
|
|
|
467
448
|
};
|
|
468
449
|
|
|
469
450
|
/**
|
|
470
|
-
|
|
451
|
+
* Stone DOM Attribute.
|
|
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.
|
|
471
459
|
*/
|
|
472
|
-
|
|
473
|
-
blueprint: IBlueprint;
|
|
474
|
-
}
|
|
460
|
+
declare const applyMeta: (document: Document, meta: HTMLMetaDescriptor) => void;
|
|
475
461
|
/**
|
|
476
|
-
*
|
|
462
|
+
* Apply the head context to the document document.head.
|
|
477
463
|
*
|
|
478
|
-
*
|
|
464
|
+
* @param document - The document object.
|
|
465
|
+
* @param context - The head context containing meta, link, script, and style descriptors.
|
|
479
466
|
*/
|
|
480
|
-
declare
|
|
481
|
-
private readonly logger;
|
|
482
|
-
private readonly blueprint;
|
|
483
|
-
/**
|
|
484
|
-
* Create an UseReactBrowserErrorHandler.
|
|
485
|
-
*
|
|
486
|
-
* @param options - UseReactBrowserErrorHandler options.
|
|
487
|
-
*/
|
|
488
|
-
constructor({ blueprint }: UseReactBrowserErrorHandlerOptions);
|
|
489
|
-
/**
|
|
490
|
-
* Handle an error.
|
|
491
|
-
*
|
|
492
|
-
* @param error - The error to handle.
|
|
493
|
-
* @param context - The context of the adapter.
|
|
494
|
-
* @returns The raw response.
|
|
495
|
-
*/
|
|
496
|
-
handle(error: any, context: AdapterErrorContext<unknown, unknown, unknown>): Promise<AdapterEventBuilderType<unknown>>;
|
|
497
|
-
/**
|
|
498
|
-
* Get the error body.
|
|
499
|
-
*
|
|
500
|
-
* @param error - The error to handle.
|
|
501
|
-
* @returns The error body.
|
|
502
|
-
*/
|
|
503
|
-
private renderError;
|
|
504
|
-
}
|
|
505
|
-
|
|
467
|
+
declare const applyHeadContextToDom: (document: Document, context: HeadContext$1) => void;
|
|
506
468
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
469
|
+
* Escape HTML special characters in a string.
|
|
470
|
+
*
|
|
471
|
+
* @param context - The head context containing meta, link, script, and style descriptors.
|
|
472
|
+
* @param html - The HTML string to escape.
|
|
473
|
+
* @returns The escaped string.
|
|
509
474
|
*/
|
|
510
|
-
declare const
|
|
475
|
+
declare const applyHeadContextToHtmlString: (context: HeadContext$1, html: string) => string;
|
|
511
476
|
|
|
512
477
|
/**
|
|
513
478
|
* A useReact event handler for processing incoming events
|
|
@@ -543,6 +508,12 @@ declare class UseReactEventHandler<IncomingEventType extends ReactIncomingEvent
|
|
|
543
508
|
private getComponentEventHandler;
|
|
544
509
|
}
|
|
545
510
|
|
|
511
|
+
/**
|
|
512
|
+
* Stone context.
|
|
513
|
+
* Usefull to pass data to the components.
|
|
514
|
+
*/
|
|
515
|
+
declare const StoneContext: react.Context<StoneContextType>;
|
|
516
|
+
|
|
546
517
|
/**
|
|
547
518
|
* UseReactError response type.
|
|
548
519
|
*/
|
|
@@ -732,9 +703,9 @@ declare function getBrowserContent(app: ReactNode, component: ReactNode, layout:
|
|
|
732
703
|
* @param container - The service container.
|
|
733
704
|
* @param event - The incoming browser event.
|
|
734
705
|
* @param head - The head context.
|
|
735
|
-
* @returns
|
|
706
|
+
* @returns The server response content as a string.
|
|
736
707
|
*/
|
|
737
|
-
declare function getServerContent(component: ReactNode, data: Partial<ResponseSnapshotType>, container: IContainer, event: IncomingBrowserEvent, head?: HeadContext):
|
|
708
|
+
declare function getServerContent(component: ReactNode, data: Partial<ResponseSnapshotType>, container: IContainer, event: IncomingBrowserEvent, head?: HeadContext): string;
|
|
738
709
|
/**
|
|
739
710
|
* Get the response snapshot.
|
|
740
711
|
*
|
|
@@ -764,6 +735,47 @@ declare function renderStoneSnapshot(snapshot: string): string;
|
|
|
764
735
|
*/
|
|
765
736
|
declare function executeHooks(name: UseReactHookName, context: UseReactHookListenerContext): Promise<void>;
|
|
766
737
|
|
|
738
|
+
/**
|
|
739
|
+
* Options for configuring the use-react service provider.
|
|
740
|
+
*/
|
|
741
|
+
interface UseReactServiceProviderOptions {
|
|
742
|
+
container: IContainer;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Use React Service Provider.
|
|
746
|
+
*/
|
|
747
|
+
declare class UseReactServiceProvider implements IServiceProvider {
|
|
748
|
+
private readonly container;
|
|
749
|
+
/**
|
|
750
|
+
* Constructs a new `UseReactServiceProvider` instance.
|
|
751
|
+
*
|
|
752
|
+
* @param container - The container to register services in.
|
|
753
|
+
*/
|
|
754
|
+
constructor(container: IContainer);
|
|
755
|
+
/**
|
|
756
|
+
* Register method for the service provider.
|
|
757
|
+
*/
|
|
758
|
+
register(): Promiseable<void>;
|
|
759
|
+
/**
|
|
760
|
+
* Boot method for the service provider.
|
|
761
|
+
*/
|
|
762
|
+
boot(): Promiseable<void>;
|
|
763
|
+
/**
|
|
764
|
+
* Register the snapshot.
|
|
765
|
+
*
|
|
766
|
+
* We save the snapshot on server side rendering and
|
|
767
|
+
* we use it to hydrate the application on the client side.
|
|
768
|
+
*/
|
|
769
|
+
private registerSnapshot;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* MetaUseReactServiceProvider
|
|
773
|
+
*/
|
|
774
|
+
declare const MetaUseReactServiceProvider: {
|
|
775
|
+
module: typeof UseReactServiceProvider;
|
|
776
|
+
isClass: boolean;
|
|
777
|
+
};
|
|
778
|
+
|
|
767
779
|
/**
|
|
768
780
|
* Prepare the page to render.
|
|
769
781
|
*
|
|
@@ -801,59 +813,6 @@ declare function prepareErrorPage(event: IncomingBrowserEvent, response: ReactOu
|
|
|
801
813
|
*/
|
|
802
814
|
declare function prepareFallbackErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
|
|
803
815
|
|
|
804
|
-
/**
|
|
805
|
-
* Create an UseReact response.
|
|
806
|
-
*
|
|
807
|
-
* @param options - The options for creating the response.
|
|
808
|
-
* @returns The React response.
|
|
809
|
-
*/
|
|
810
|
-
declare const reactResponse: (options: OutgoingHttpResponseOptions | OutgoingBrowserResponseOptions | RedirectResponseOptions | RedirectBrowserResponseOptions) => Promise<ReactOutgoingResponse>;
|
|
811
|
-
/**
|
|
812
|
-
* Create an UseReact redirect response.
|
|
813
|
-
*
|
|
814
|
-
* @param options - The options for creating the response.
|
|
815
|
-
* @returns The React redirect response.
|
|
816
|
-
*/
|
|
817
|
-
declare const reactRedirectResponse: (options: RedirectResponseOptions | RedirectBrowserResponseOptions) => Promise<ReactOutgoingResponse>;
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* UseReactServerErrorHandler options.
|
|
821
|
-
*/
|
|
822
|
-
interface UseReactServerErrorHandlerOptions {
|
|
823
|
-
logger: ILogger;
|
|
824
|
-
blueprint: IBlueprint;
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Class representing an UseReactServerErrorHandler.
|
|
828
|
-
*
|
|
829
|
-
* Adapter level error handler for React applications.
|
|
830
|
-
*/
|
|
831
|
-
declare class UseReactServerErrorHandler implements IAdapterErrorHandler<unknown, unknown, unknown> {
|
|
832
|
-
private readonly logger;
|
|
833
|
-
private readonly blueprint;
|
|
834
|
-
/**
|
|
835
|
-
* Create an UseReactServerErrorHandler.
|
|
836
|
-
*
|
|
837
|
-
* @param options - UseReactServerErrorHandler options.
|
|
838
|
-
*/
|
|
839
|
-
constructor({ blueprint }: UseReactServerErrorHandlerOptions);
|
|
840
|
-
/**
|
|
841
|
-
* Handle an error.
|
|
842
|
-
*
|
|
843
|
-
* @param error - The error to handle.
|
|
844
|
-
* @param context - The context of the adapter.
|
|
845
|
-
* @returns The raw response.
|
|
846
|
-
*/
|
|
847
|
-
handle(error: any, context: AdapterErrorContext<unknown, unknown, unknown>): Promise<AdapterEventBuilderType<unknown>>;
|
|
848
|
-
/**
|
|
849
|
-
* Get the error body.
|
|
850
|
-
*
|
|
851
|
-
* @param error - The error to handle.
|
|
852
|
-
* @returns The error body.
|
|
853
|
-
*/
|
|
854
|
-
private getErrorBody;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
816
|
/**
|
|
858
817
|
* Constants for the Stone SNAPSHOT
|
|
859
818
|
*/
|
|
@@ -863,47 +822,6 @@ declare const STONE_SNAPSHOT = "__STONE_SNAPSHOT__";
|
|
|
863
822
|
*/
|
|
864
823
|
declare const STONE_PAGE_EVENT_OUTLET = "stone:inject:react-page:outlet";
|
|
865
824
|
|
|
866
|
-
/**
|
|
867
|
-
* Options for configuring the use-react service provider.
|
|
868
|
-
*/
|
|
869
|
-
interface UseReactServiceProviderOptions {
|
|
870
|
-
container: IContainer;
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* Use React Service Provider.
|
|
874
|
-
*/
|
|
875
|
-
declare class UseReactServiceProvider implements IServiceProvider {
|
|
876
|
-
private readonly container;
|
|
877
|
-
/**
|
|
878
|
-
* Constructs a new `UseReactServiceProvider` instance.
|
|
879
|
-
*
|
|
880
|
-
* @param container - The container to register services in.
|
|
881
|
-
*/
|
|
882
|
-
constructor(container: IContainer);
|
|
883
|
-
/**
|
|
884
|
-
* Register method for the service provider.
|
|
885
|
-
*/
|
|
886
|
-
register(): Promiseable<void>;
|
|
887
|
-
/**
|
|
888
|
-
* Boot method for the service provider.
|
|
889
|
-
*/
|
|
890
|
-
boot(): Promiseable<void>;
|
|
891
|
-
/**
|
|
892
|
-
* Register the snapshot.
|
|
893
|
-
*
|
|
894
|
-
* We save the snapshot on server side rendering and
|
|
895
|
-
* we use it to hydrate the application on the client side.
|
|
896
|
-
*/
|
|
897
|
-
private registerSnapshot;
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* MetaUseReactServiceProvider
|
|
901
|
-
*/
|
|
902
|
-
declare const MetaUseReactServiceProvider: {
|
|
903
|
-
module: typeof UseReactServiceProvider;
|
|
904
|
-
isClass: boolean;
|
|
905
|
-
};
|
|
906
|
-
|
|
907
825
|
/**
|
|
908
826
|
* Configuration options for integrating React with Stone.js.
|
|
909
827
|
*/
|
|
@@ -923,6 +841,12 @@ interface UseReactConfig {
|
|
|
923
841
|
* A map of layout components with their respective event handlers.
|
|
924
842
|
*/
|
|
925
843
|
layout?: Record<string, MetaPageLayout>;
|
|
844
|
+
/**
|
|
845
|
+
* A list of platforms to ignore for React rendering.
|
|
846
|
+
* This can be used to disable React rendering on specific platforms.
|
|
847
|
+
* For example, you might want to ignore rendering on CLI platforms.
|
|
848
|
+
*/
|
|
849
|
+
ignorePlatforms?: string[];
|
|
926
850
|
/**
|
|
927
851
|
* Handles incoming events for the root React component.
|
|
928
852
|
*/
|
|
@@ -960,7 +884,7 @@ interface UseReactBlueprint extends StoneBlueprint<ReactIncomingEvent, ReactOutg
|
|
|
960
884
|
*
|
|
961
885
|
* - Defines middleware, lifecycle hooks, and the default HTML template path.
|
|
962
886
|
*/
|
|
963
|
-
declare const
|
|
887
|
+
declare const internalUseReactBlueprint: UseReactBlueprint;
|
|
964
888
|
|
|
965
889
|
/**
|
|
966
890
|
* Utility function to define a factory-based adapter error page.
|
|
@@ -982,69 +906,25 @@ declare function defineAdapterErrorPage(module: AdapterErrorPageClass<unknown, u
|
|
|
982
906
|
}): UseReactBlueprint;
|
|
983
907
|
|
|
984
908
|
/**
|
|
985
|
-
*
|
|
909
|
+
* Utility function to define a factory-based page.
|
|
986
910
|
*
|
|
987
|
-
* @param module -
|
|
988
|
-
* @param options -
|
|
989
|
-
* @
|
|
990
|
-
* @returns A fully merged Stone blueprint.
|
|
911
|
+
* @param module - The EventHandler module.
|
|
912
|
+
* @param options - Page definition options.
|
|
913
|
+
* @returns The UseReactBlueprint.
|
|
991
914
|
*/
|
|
992
|
-
declare function
|
|
915
|
+
declare function definePage<U extends ReactIncomingEvent = ReactIncomingEvent>(module: FactoryPage<U>, options: PageOptions & {
|
|
916
|
+
isClass?: undefined;
|
|
917
|
+
}): Partial<StoneBlueprint<U>>;
|
|
993
918
|
/**
|
|
994
|
-
*
|
|
919
|
+
* Utility function to define a class-based page.
|
|
995
920
|
*
|
|
996
|
-
* @param module -
|
|
997
|
-
* @param options -
|
|
998
|
-
* @
|
|
999
|
-
* @returns A fully merged Stone blueprint.
|
|
921
|
+
* @param module - The EventHandler module.
|
|
922
|
+
* @param options - Page definition options.
|
|
923
|
+
* @returns The UseReactBlueprint.
|
|
1000
924
|
*/
|
|
1001
|
-
declare function
|
|
1002
|
-
isClass:
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Defines a Stone React app without a main handler (router-only).
|
|
1006
|
-
*
|
|
1007
|
-
* @param options - Application-level configuration.
|
|
1008
|
-
* @param blueprints - Additional blueprints to merge.
|
|
1009
|
-
* @returns A fully merged Stone blueprint.
|
|
1010
|
-
*/
|
|
1011
|
-
declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* Stone Client options.
|
|
1015
|
-
*/
|
|
1016
|
-
interface StoneClientOptions {
|
|
1017
|
-
children: ReactNode;
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* Stone Client.
|
|
1021
|
-
* This component is used to wrap content
|
|
1022
|
-
* that should only be rendered on the client.
|
|
1023
|
-
*
|
|
1024
|
-
* @param options - The options to create the Stone Client.
|
|
1025
|
-
*/
|
|
1026
|
-
declare const StoneClient: FunctionComponent<StoneClientOptions>;
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* Utility function to define a factory-based page.
|
|
1030
|
-
*
|
|
1031
|
-
* @param module - The EventHandler module.
|
|
1032
|
-
* @param options - Page definition options.
|
|
1033
|
-
* @returns The UseReactBlueprint.
|
|
1034
|
-
*/
|
|
1035
|
-
declare function definePage<U extends ReactIncomingEvent = ReactIncomingEvent>(module: FactoryPage<U>, options: PageOptions & {
|
|
1036
|
-
isClass?: undefined;
|
|
1037
|
-
}): Partial<StoneBlueprint<U>>;
|
|
1038
|
-
/**
|
|
1039
|
-
* Utility function to define a class-based page.
|
|
1040
|
-
*
|
|
1041
|
-
* @param module - The EventHandler module.
|
|
1042
|
-
* @param options - Page definition options.
|
|
1043
|
-
* @returns The UseReactBlueprint.
|
|
1044
|
-
*/
|
|
1045
|
-
declare function definePage<U extends ReactIncomingEvent = ReactIncomingEvent>(module: PageClass<U>, options: PageOptions & {
|
|
1046
|
-
isClass: true;
|
|
1047
|
-
}): Partial<StoneBlueprint<U>>;
|
|
925
|
+
declare function definePage<U extends ReactIncomingEvent = ReactIncomingEvent>(module: PageClass<U>, options: PageOptions & {
|
|
926
|
+
isClass: true;
|
|
927
|
+
}): Partial<StoneBlueprint<U>>;
|
|
1048
928
|
/**
|
|
1049
929
|
* Utility function to define a factory-based page layout.
|
|
1050
930
|
*
|
|
@@ -1086,11 +966,107 @@ declare function defineErrorPage(module: ErrorPageClass<ReactIncomingEvent>, opt
|
|
|
1086
966
|
isClass: true;
|
|
1087
967
|
}): UseReactBlueprint;
|
|
1088
968
|
|
|
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
|
+
/**
|
|
999
|
+
* UseReactBrowserErrorHandler options.
|
|
1000
|
+
*/
|
|
1001
|
+
interface UseReactBrowserErrorHandlerOptions {
|
|
1002
|
+
blueprint: IBlueprint;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Class representing an UseReactBrowserErrorHandler.
|
|
1006
|
+
*
|
|
1007
|
+
* Adapter level error handler for React applications.
|
|
1008
|
+
*/
|
|
1009
|
+
declare class UseReactBrowserErrorHandler implements IAdapterErrorHandler<unknown, unknown, unknown> {
|
|
1010
|
+
private readonly logger;
|
|
1011
|
+
private readonly blueprint;
|
|
1012
|
+
/**
|
|
1013
|
+
* Create an UseReactBrowserErrorHandler.
|
|
1014
|
+
*
|
|
1015
|
+
* @param options - UseReactBrowserErrorHandler options.
|
|
1016
|
+
*/
|
|
1017
|
+
constructor({ blueprint }: UseReactBrowserErrorHandlerOptions);
|
|
1018
|
+
/**
|
|
1019
|
+
* Handle an error.
|
|
1020
|
+
*
|
|
1021
|
+
* @param error - The error to handle.
|
|
1022
|
+
* @param context - The context of the adapter.
|
|
1023
|
+
* @returns The raw response.
|
|
1024
|
+
*/
|
|
1025
|
+
handle(error: any, context: AdapterErrorContext<unknown, unknown, unknown>): Promise<AdapterEventBuilderType<unknown>>;
|
|
1026
|
+
/**
|
|
1027
|
+
* Get the error body.
|
|
1028
|
+
*
|
|
1029
|
+
* @param error - The error to handle.
|
|
1030
|
+
* @returns The error body.
|
|
1031
|
+
*/
|
|
1032
|
+
private renderError;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Create an UseReact response.
|
|
1037
|
+
*
|
|
1038
|
+
* @param options - The options for creating the response.
|
|
1039
|
+
* @returns The React response.
|
|
1040
|
+
*/
|
|
1041
|
+
declare const reactResponse: (options: ReactResponseOptions) => ReactOutgoingResponse;
|
|
1042
|
+
/**
|
|
1043
|
+
* Create an UseReact redirect response.
|
|
1044
|
+
*
|
|
1045
|
+
* @param options - The options for creating the response.
|
|
1046
|
+
* @returns The React redirect response.
|
|
1047
|
+
*/
|
|
1048
|
+
declare const reactRedirectResponse: (options: ReactRedirectResponseOptions) => ReactOutgoingResponse;
|
|
1049
|
+
|
|
1089
1050
|
/**
|
|
1090
1051
|
* Stone Error.
|
|
1091
1052
|
*/
|
|
1092
1053
|
declare const StoneError: FunctionComponent;
|
|
1093
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
|
+
|
|
1094
1070
|
interface BaseProps {
|
|
1095
1071
|
rel?: string;
|
|
1096
1072
|
href?: string;
|
|
@@ -1115,26 +1091,6 @@ type StoneLinkOptions = (BaseProps & {
|
|
|
1115
1091
|
*/
|
|
1116
1092
|
declare const StoneLink: FunctionComponent<StoneLinkOptions>;
|
|
1117
1093
|
|
|
1118
|
-
/**
|
|
1119
|
-
* Stone Outlet options.
|
|
1120
|
-
*/
|
|
1121
|
-
interface StoneOutletOptions {
|
|
1122
|
-
children: ReactNode;
|
|
1123
|
-
}
|
|
1124
|
-
/**
|
|
1125
|
-
* A dynamic rendering component that updates its content based on a global event.
|
|
1126
|
-
*
|
|
1127
|
-
* - Listens for `stone:inject:react-page:outlet` and updates its view when triggered.
|
|
1128
|
-
* - Uses `useState` to manage the currently displayed content.
|
|
1129
|
-
* - Automatically cleans up event listeners on unmount.
|
|
1130
|
-
*
|
|
1131
|
-
* This component enables dynamic content updates within a Stone.js application.
|
|
1132
|
-
*
|
|
1133
|
-
* @param options - The options to create the Stone Outlet.
|
|
1134
|
-
* @returns The Stone Outlet component.
|
|
1135
|
-
*/
|
|
1136
|
-
declare const StoneOutlet: FunctionComponent<StoneOutletOptions>;
|
|
1137
|
-
|
|
1138
1094
|
/**
|
|
1139
1095
|
* Stone Page options.
|
|
1140
1096
|
*/
|
|
@@ -1156,6 +1112,26 @@ interface StonePageOptions {
|
|
|
1156
1112
|
*/
|
|
1157
1113
|
declare const StonePage: FunctionComponent<StonePageOptions>;
|
|
1158
1114
|
|
|
1115
|
+
/**
|
|
1116
|
+
* Stone Outlet options.
|
|
1117
|
+
*/
|
|
1118
|
+
interface StoneOutletOptions {
|
|
1119
|
+
children: ReactNode;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* A dynamic rendering component that updates its content based on a global event.
|
|
1123
|
+
*
|
|
1124
|
+
* - Listens for `stone:inject:react-page:outlet` and updates its view when triggered.
|
|
1125
|
+
* - Uses `useState` to manage the currently displayed content.
|
|
1126
|
+
* - Automatically cleans up event listeners on unmount.
|
|
1127
|
+
*
|
|
1128
|
+
* This component enables dynamic content updates within a Stone.js application.
|
|
1129
|
+
*
|
|
1130
|
+
* @param options - The options to create the Stone Outlet.
|
|
1131
|
+
* @returns The Stone Outlet component.
|
|
1132
|
+
*/
|
|
1133
|
+
declare const StoneOutlet: FunctionComponent<StoneOutletOptions>;
|
|
1134
|
+
|
|
1159
1135
|
/**
|
|
1160
1136
|
* Stone Server options.
|
|
1161
1137
|
*/
|
|
@@ -1191,6 +1167,26 @@ declare const StoneServer: FunctionComponent<StoneServerOptions>;
|
|
|
1191
1167
|
*/
|
|
1192
1168
|
declare const AdapterErrorPage: <T extends ClassType = ClassType>(options: AdapterErrorPageOptions) => ClassDecorator;
|
|
1193
1169
|
|
|
1170
|
+
/**
|
|
1171
|
+
* A class decorator for defining a class as a React Handler layout.
|
|
1172
|
+
*
|
|
1173
|
+
* @param options - Configuration options for the layout definition.
|
|
1174
|
+
* @returns A method decorator to be applied to a class method.
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* ```typescript
|
|
1178
|
+
* import { ErrorPage } from '@stone-js/use-react';
|
|
1179
|
+
*
|
|
1180
|
+
* @ErrorPage({ error: 'UserNotFoundError' })
|
|
1181
|
+
* class UserErrorPage {
|
|
1182
|
+
* render({ error }) {
|
|
1183
|
+
* return <h1>User name: {error.message}</h1>;
|
|
1184
|
+
* }
|
|
1185
|
+
* }
|
|
1186
|
+
* ```
|
|
1187
|
+
*/
|
|
1188
|
+
declare const ErrorPage: <T extends ClassType = ClassType>(options: ErrorPageOptions) => ClassDecorator;
|
|
1189
|
+
|
|
1194
1190
|
/**
|
|
1195
1191
|
* Hook decorator to mark a method as a lifecycle hook
|
|
1196
1192
|
* And automatically add it to the global lifecycle hook registry.
|
|
@@ -1234,26 +1230,6 @@ declare const Hook: <T extends Function = Function>(name: HookName) => MethodDec
|
|
|
1234
1230
|
*/
|
|
1235
1231
|
declare const Page: <T extends ClassType = ClassType>(path: string, options?: PageOptions) => ClassDecorator;
|
|
1236
1232
|
|
|
1237
|
-
/**
|
|
1238
|
-
* A class decorator for defining a class as a React Handler layout.
|
|
1239
|
-
*
|
|
1240
|
-
* @param options - Configuration options for the layout definition.
|
|
1241
|
-
* @returns A method decorator to be applied to a class method.
|
|
1242
|
-
*
|
|
1243
|
-
* @example
|
|
1244
|
-
* ```typescript
|
|
1245
|
-
* import { ErrorPage } from '@stone-js/use-react';
|
|
1246
|
-
*
|
|
1247
|
-
* @ErrorPage({ error: 'UserNotFoundError' })
|
|
1248
|
-
* class UserErrorPage {
|
|
1249
|
-
* render({ error }) {
|
|
1250
|
-
* return <h1>User name: {error.message}</h1>;
|
|
1251
|
-
* }
|
|
1252
|
-
* }
|
|
1253
|
-
* ```
|
|
1254
|
-
*/
|
|
1255
|
-
declare const ErrorPage: <T extends ClassType = ClassType>(options: ErrorPageOptions) => ClassDecorator;
|
|
1256
|
-
|
|
1257
1233
|
/**
|
|
1258
1234
|
* A class decorator for defining a class as a React Page layout.
|
|
1259
1235
|
*
|
|
@@ -1318,29 +1294,6 @@ declare const PageStatus: <T extends Function = Function>(statusCode?: number, h
|
|
|
1318
1294
|
*/
|
|
1319
1295
|
declare const Snapshot: <T extends Function = Function>(name?: string) => MethodDecorator;
|
|
1320
1296
|
|
|
1321
|
-
/**
|
|
1322
|
-
* UseReact decorator options.
|
|
1323
|
-
*/
|
|
1324
|
-
interface UseReactOptions extends Partial<UseReactConfig> {
|
|
1325
|
-
}
|
|
1326
|
-
/**
|
|
1327
|
-
* UseReact decorator.
|
|
1328
|
-
*
|
|
1329
|
-
* UseReact is a class decorator that allows you to use React components in your Stone application.
|
|
1330
|
-
* The decorator is used to define the React configuration for the class.
|
|
1331
|
-
*
|
|
1332
|
-
* @param options - UseReactOptions
|
|
1333
|
-
* @returns ClassDecorator
|
|
1334
|
-
*/
|
|
1335
|
-
declare const UseReact: <T extends ClassType = ClassType>(options?: UseReactOptions) => ClassDecorator;
|
|
1336
|
-
|
|
1337
|
-
/**
|
|
1338
|
-
* Custom error for react operations.
|
|
1339
|
-
*/
|
|
1340
|
-
declare class UseReactError extends InitializationError {
|
|
1341
|
-
constructor(message: string, options?: ErrorOptions);
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1297
|
/**
|
|
1345
1298
|
* Blueprint middleware to dynamically set lifecycle hooks for react.
|
|
1346
1299
|
*
|
|
@@ -1354,22 +1307,6 @@ declare class UseReactError extends InitializationError {
|
|
|
1354
1307
|
* ```
|
|
1355
1308
|
*/
|
|
1356
1309
|
declare const SetUseReactHooksMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
|
|
1357
|
-
/**
|
|
1358
|
-
* Blueprint middleware to set BrowserResponseMiddleware for the Browser adapter.
|
|
1359
|
-
*
|
|
1360
|
-
* The MetaBrowserResponseMiddleware is an adapter middleware and is useful
|
|
1361
|
-
* for handling outgoing responses and rendering them in the browser.
|
|
1362
|
-
*
|
|
1363
|
-
* @param context - The configuration context containing modules and blueprint.
|
|
1364
|
-
* @param next - The next pipeline function to continue processing.
|
|
1365
|
-
* @returns The updated blueprint or a promise resolving to it.
|
|
1366
|
-
*
|
|
1367
|
-
* @example
|
|
1368
|
-
* ```typescript
|
|
1369
|
-
* SetBrowserResponseMiddlewareMiddleware(context, next)
|
|
1370
|
-
* ```
|
|
1371
|
-
*/
|
|
1372
|
-
declare const SetBrowserResponseMiddlewareMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promise<IBlueprint>;
|
|
1373
1310
|
/**
|
|
1374
1311
|
* Blueprint middleware to process and register kernel error page definitions from modules.
|
|
1375
1312
|
*
|
|
@@ -1384,7 +1321,7 @@ declare const SetBrowserResponseMiddlewareMiddleware: (context: BlueprintContext
|
|
|
1384
1321
|
*/
|
|
1385
1322
|
declare const SetReactKernelErrorPageMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
|
|
1386
1323
|
/**
|
|
1387
|
-
* Blueprint middleware to process and register
|
|
1324
|
+
* Blueprint middleware to process and register route definitions from modules.
|
|
1388
1325
|
*
|
|
1389
1326
|
* @param context - The configuration context containing modules and blueprint.
|
|
1390
1327
|
* @param next - The next pipeline function to continue processing.
|
|
@@ -1392,12 +1329,12 @@ declare const SetReactKernelErrorPageMiddleware: (context: BlueprintContext<IBlu
|
|
|
1392
1329
|
*
|
|
1393
1330
|
* @example
|
|
1394
1331
|
* ```typescript
|
|
1395
|
-
*
|
|
1332
|
+
* SetReactRouteDefinitionsMiddleware(context, next)
|
|
1396
1333
|
* ```
|
|
1397
1334
|
*/
|
|
1398
|
-
declare const
|
|
1335
|
+
declare const SetReactRouteDefinitionsMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
|
|
1399
1336
|
/**
|
|
1400
|
-
* Blueprint middleware to
|
|
1337
|
+
* Blueprint middleware to process and register layout definitions from modules.
|
|
1401
1338
|
*
|
|
1402
1339
|
* @param context - The configuration context containing modules and blueprint.
|
|
1403
1340
|
* @param next - The next pipeline function to continue processing.
|
|
@@ -1405,38 +1342,110 @@ declare const SetReactAdapterErrorPageMiddleware: (context: BlueprintContext<IBl
|
|
|
1405
1342
|
*
|
|
1406
1343
|
* @example
|
|
1407
1344
|
* ```typescript
|
|
1408
|
-
*
|
|
1345
|
+
* SetReactPageLayoutMiddleware(context, next)
|
|
1409
1346
|
* ```
|
|
1410
1347
|
*/
|
|
1411
|
-
declare const
|
|
1348
|
+
declare const SetReactPageLayoutMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
|
|
1412
1349
|
/**
|
|
1413
|
-
* Blueprint middleware to set
|
|
1350
|
+
* Blueprint middleware to set the UseReact as the main event handler for the application.
|
|
1351
|
+
*
|
|
1352
|
+
* Set as fallback event handler if none of the other event handlers are registered.
|
|
1414
1353
|
*
|
|
1415
1354
|
* @param context - The configuration context containing modules and blueprint.
|
|
1416
|
-
* @param next - The next
|
|
1417
|
-
* @returns The updated blueprint
|
|
1355
|
+
* @param next - The next function in the pipeline.
|
|
1356
|
+
* @returns The updated blueprint.
|
|
1418
1357
|
*
|
|
1419
1358
|
* @example
|
|
1420
1359
|
* ```typescript
|
|
1421
|
-
*
|
|
1360
|
+
* SetUseReactEventHandlerMiddleware({ modules, blueprint }, next);
|
|
1422
1361
|
* ```
|
|
1423
1362
|
*/
|
|
1424
|
-
declare
|
|
1363
|
+
declare function SetUseReactEventHandlerMiddleware(context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>): Promise<IBlueprint>;
|
|
1364
|
+
|
|
1425
1365
|
/**
|
|
1426
|
-
*
|
|
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
|
+
/**
|
|
1391
|
+
* Custom error for react operations.
|
|
1392
|
+
*/
|
|
1393
|
+
declare class UseReactError extends InitializationError {
|
|
1394
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* UseReactServerErrorHandler options.
|
|
1399
|
+
*/
|
|
1400
|
+
interface UseReactServerErrorHandlerOptions {
|
|
1401
|
+
logger: ILogger;
|
|
1402
|
+
blueprint: IBlueprint;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Class representing an UseReactServerErrorHandler.
|
|
1427
1406
|
*
|
|
1428
|
-
*
|
|
1429
|
-
|
|
1430
|
-
|
|
1407
|
+
* Adapter level error handler for React applications.
|
|
1408
|
+
*/
|
|
1409
|
+
declare class UseReactServerErrorHandler implements IAdapterErrorHandler<unknown, unknown, unknown> {
|
|
1410
|
+
private readonly logger;
|
|
1411
|
+
private readonly blueprint;
|
|
1412
|
+
/**
|
|
1413
|
+
* Create an UseReactServerErrorHandler.
|
|
1414
|
+
*
|
|
1415
|
+
* @param options - UseReactServerErrorHandler options.
|
|
1416
|
+
*/
|
|
1417
|
+
constructor({ blueprint }: UseReactServerErrorHandlerOptions);
|
|
1418
|
+
/**
|
|
1419
|
+
* Handle an error.
|
|
1420
|
+
*
|
|
1421
|
+
* @param error - The error to handle.
|
|
1422
|
+
* @param context - The context of the adapter.
|
|
1423
|
+
* @returns The raw response.
|
|
1424
|
+
*/
|
|
1425
|
+
handle(error: any, context: AdapterErrorContext<unknown, unknown, unknown>): Promise<AdapterEventBuilderType<unknown>>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Get the error body.
|
|
1428
|
+
*
|
|
1429
|
+
* @param error - The error to handle.
|
|
1430
|
+
* @returns The error body.
|
|
1431
|
+
*/
|
|
1432
|
+
private getErrorBody;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Sets the error handler for the React adapter and registers error pages.
|
|
1431
1437
|
*
|
|
1432
|
-
* @
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1435
|
-
* ```
|
|
1438
|
+
* @param errorHandler - The error handler to set for the React adapter.
|
|
1439
|
+
* @param context - The blueprint context containing modules and blueprint.
|
|
1440
|
+
* @returns The updated blueprint context with the error handler and error pages set.
|
|
1436
1441
|
*/
|
|
1437
|
-
declare
|
|
1442
|
+
declare function setUseReactAdapterErrorHandler(errorHandler: typeof UseReactServerErrorHandler | typeof UseReactBrowserErrorHandler, context: BlueprintContext<IBlueprint, ClassType>): BlueprintContext<IBlueprint, ClassType>;
|
|
1443
|
+
|
|
1438
1444
|
/**
|
|
1439
|
-
* Blueprint middleware to
|
|
1445
|
+
* Blueprint middleware to set BrowserResponseMiddleware for the Browser adapter.
|
|
1446
|
+
*
|
|
1447
|
+
* The MetaBrowserResponseMiddleware is an adapter middleware and is useful
|
|
1448
|
+
* for handling outgoing responses and rendering them in the browser.
|
|
1440
1449
|
*
|
|
1441
1450
|
* @param context - The configuration context containing modules and blueprint.
|
|
1442
1451
|
* @param next - The next pipeline function to continue processing.
|
|
@@ -1444,32 +1453,30 @@ declare const SetReactRouteDefinitionsMiddleware: (context: BlueprintContext<IBl
|
|
|
1444
1453
|
*
|
|
1445
1454
|
* @example
|
|
1446
1455
|
* ```typescript
|
|
1447
|
-
*
|
|
1456
|
+
* SetBrowserResponseMiddlewareMiddleware(context, next)
|
|
1448
1457
|
* ```
|
|
1449
1458
|
*/
|
|
1450
|
-
declare const
|
|
1459
|
+
declare const SetBrowserResponseMiddlewareMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promise<IBlueprint>;
|
|
1451
1460
|
/**
|
|
1452
|
-
* Blueprint middleware to
|
|
1453
|
-
*
|
|
1454
|
-
* Set as fallback event handler if none of the other event handlers are registered.
|
|
1461
|
+
* Blueprint middleware to process and register adapter error page definitions from modules.
|
|
1455
1462
|
*
|
|
1456
1463
|
* @param context - The configuration context containing modules and blueprint.
|
|
1457
|
-
* @param next - The next function
|
|
1458
|
-
* @returns The updated blueprint.
|
|
1464
|
+
* @param next - The next pipeline function to continue processing.
|
|
1465
|
+
* @returns The updated blueprint or a promise resolving to it.
|
|
1459
1466
|
*
|
|
1460
1467
|
* @example
|
|
1461
1468
|
* ```typescript
|
|
1462
|
-
*
|
|
1469
|
+
* SetReactAdapterErrorPageMiddleware(context, next)
|
|
1463
1470
|
* ```
|
|
1464
1471
|
*/
|
|
1465
|
-
declare
|
|
1472
|
+
declare const SetReactAdapterErrorPageMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
|
|
1466
1473
|
/**
|
|
1467
1474
|
* Configuration for react processing middleware.
|
|
1468
1475
|
*
|
|
1469
1476
|
* This array defines a list of middleware pipes, each with a `pipe` function and a `priority`.
|
|
1470
1477
|
* These pipes are executed in the order of their priority values, with lower values running first.
|
|
1471
1478
|
*/
|
|
1472
|
-
declare const
|
|
1479
|
+
declare const metaBrowserUseReactBlueprintMiddleware: Array<MetaMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>>;
|
|
1473
1480
|
|
|
1474
1481
|
/**
|
|
1475
1482
|
* Adapter Middleware for handling outgoing responses and rendering them in the browser.
|
|
@@ -1538,29 +1545,27 @@ declare const MetaBrowserResponseMiddleware: {
|
|
|
1538
1545
|
};
|
|
1539
1546
|
|
|
1540
1547
|
/**
|
|
1541
|
-
*
|
|
1542
|
-
* This pattern must be applied to all Stone libraries or third party libraries.
|
|
1543
|
-
*/
|
|
1544
|
-
/**
|
|
1545
|
-
* A unique symbol key to mark classes as React Page component.
|
|
1546
|
-
*/
|
|
1547
|
-
declare const REACT_PAGE_KEY: unique symbol;
|
|
1548
|
-
/**
|
|
1549
|
-
* A unique symbol key to mark classes as React Page layout component.
|
|
1550
|
-
*/
|
|
1551
|
-
declare const REACT_PAGE_LAYOUT_KEY: unique symbol;
|
|
1552
|
-
/**
|
|
1553
|
-
* A unique symbol key to mark classes as React Error handler component.
|
|
1548
|
+
* UseReact decorator options.
|
|
1554
1549
|
*/
|
|
1555
|
-
|
|
1550
|
+
interface UseReactOptions extends Partial<UseReactConfig> {
|
|
1551
|
+
}
|
|
1556
1552
|
/**
|
|
1557
|
-
*
|
|
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
|
|
1558
1560
|
*/
|
|
1559
|
-
declare const
|
|
1561
|
+
declare const UseReact: <T extends ClassType = ClassType>(options?: UseReactOptions) => ClassDecorator;
|
|
1562
|
+
|
|
1560
1563
|
/**
|
|
1561
|
-
*
|
|
1564
|
+
* Default blueprint for a React-based Stone.js application.
|
|
1565
|
+
*
|
|
1566
|
+
* - Defines middleware, lifecycle hooks, and the default HTML template path.
|
|
1562
1567
|
*/
|
|
1563
|
-
declare const
|
|
1568
|
+
declare const useReactBlueprint: UseReactBlueprint;
|
|
1564
1569
|
|
|
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,
|
|
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, ReactRuntimeOptions, ResponseSnapshotType, StoneContextType, StoneLinkOptions, StoneOutletOptions, UseReactAppConfig, UseReactBlueprint, UseReactBrowserErrorHandlerOptions, UseReactConfig, UseReactErrorResponseType, UseReactHookListener, UseReactHookListenerContext, UseReactHookName, UseReactHookType, UseReactOptions,
|
|
1570
|
+
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
|
+
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 };
|