@stone-js/use-react 0.3.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/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ 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
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, InitializationError, ErrorOptions, ClassType, BlueprintContext, NextMiddleware, ILogger, MetaMiddleware } from '@stone-js/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
11
  /**
@@ -396,6 +396,83 @@ interface MetaAdapterErrorPage<RawEventType, RawResponseType, ExecutionContextTy
396
396
  */
397
397
  declare const StoneContext: react.Context<StoneContextType>;
398
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
+
399
476
  /**
400
477
  * ReactRuntimeOptions
401
478
  */
@@ -481,81 +558,41 @@ declare const MetaReactRuntime: {
481
558
  };
482
559
 
483
560
  /**
484
- * A useReact event handler for processing incoming events
485
- * For single event handler.
561
+ * Prepare the page to render.
486
562
  *
487
- * Multiple event handlers will be processed by the router.
563
+ * Here we prepare the page to render by resolving
564
+ * the handler, handler the event, and rendering the component.
488
565
  *
489
- * @template IncomingEventType - The type representing the incoming event.
490
- * @template OutgoingResponseType - The type representing the outgoing response.
491
- */
492
- declare class UseReactEventHandler<IncomingEventType extends ReactIncomingEvent = ReactIncomingEvent> implements IEventHandler<IncomingEventType, MetaPage<IncomingEventType>> {
493
- private readonly blueprint;
494
- /**
495
- * Constructs a `UseReactEventHandler` instance.
496
- *
497
- * @param options - The UseReactEventHandler options including blueprint.
498
- */
499
- constructor({ blueprint }: {
500
- blueprint: IBlueprint;
501
- });
502
- /**
503
- * Handle an incoming event.
504
- *
505
- * @returns The outgoing response.
506
- */
507
- handle(): MetaPage<IncomingEventType>;
508
- /**
509
- * Get the component event handler.
510
- *
511
- * @returns The component event handler.
512
- * @throws {UseReactError} If the component event handler is missing.
513
- */
514
- private getComponentEventHandler;
515
- }
516
-
517
- /**
518
- * UseReactError response type.
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.
519
570
  */
520
- type UseReactErrorResponseType = Record<'content' | 'statusCode', Partial<MetaErrorPage<ReactIncomingEvent>> | number>;
571
+ declare function preparePage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
521
572
  /**
522
- * Class representing an UseReactUseReactKernelErrorHandler.
573
+ * Prepare the error page to render.
523
574
  *
524
- * Kernel level error handler for React applications.
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.
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.
578
+ *
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.
547
583
  */
548
- interface OnPreparingResponseOptions {
549
- container: IContainer;
550
- event: IncomingBrowserEvent;
551
- response: ReactOutgoingResponse;
552
- }
584
+ declare function prepareErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
553
585
  /**
554
- * Hook that runs just before preparing the response.
586
+ * Prepare the fallback error page to render.
555
587
  *
556
- * @param context - The context of the hook.
557
- */
558
- declare function onPreparingResponse({ event, response, container }: OnPreparingResponseOptions): Promise<void>;
588
+ * We prepare a fallback error page if no event nor error handler is provided.
589
+ *
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.
@@ -735,52 +772,6 @@ declare function renderStoneSnapshot(snapshot: string): string;
735
772
  */
736
773
  declare function executeHooks(name: UseReactHookName, context: UseReactHookListenerContext): Promise<void>;
737
774
 
738
- /**
739
- * Prepare the page to render.
740
- *
741
- * Here we prepare the page to render by resolving
742
- * the handler, handler the event, and rendering the component.
743
- *
744
- * @param event - The incoming HTTP event.
745
- * @param response - The outgoing HTTP response.
746
- * @param container - The service container.
747
- * @param snapshot - The response snapshot.
748
- */
749
- declare function preparePage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
750
- /**
751
- * Prepare the error page to render.
752
- *
753
- * Error pages are prepared sepatately because their handler
754
- * is different from the normal page handler.
755
- * Their handler takes an error as the first argument and the event as the second.
756
- *
757
- * @param event - The incoming HTTP event.
758
- * @param response - The outgoing HTTP response.
759
- * @param container - The service container.
760
- * @param snapshot - The response snapshot.
761
- */
762
- declare function prepareErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
763
- /**
764
- * Prepare the fallback error page to render.
765
- *
766
- * We prepare a fallback error page if no event nor error handler is provided.
767
- *
768
- * @param event - The incoming event.
769
- * @param response - The outgoing response.
770
- * @param container - The service container.
771
- * @param snapshot - The response snapshot.
772
- */
773
- declare function prepareFallbackErrorPage(event: IncomingBrowserEvent, response: ReactOutgoingResponse, container: IContainer, snapshot: ResponseSnapshotType): Promise<void>;
774
-
775
- /**
776
- * Constants for the Stone SNAPSHOT
777
- */
778
- declare const STONE_SNAPSHOT = "__STONE_SNAPSHOT__";
779
- /**
780
- * Constants for the Stone Page Event Outlet
781
- */
782
- declare const STONE_PAGE_EVENT_OUTLET = "stone:inject:react-page:outlet";
783
-
784
775
  /**
785
776
  * Options for configuring the use-react service provider.
786
777
  */
@@ -822,6 +813,15 @@ declare const MetaUseReactServiceProvider: {
822
813
  isClass: boolean;
823
814
  };
824
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
822
+ */
823
+ declare const STONE_PAGE_EVENT_OUTLET = "stone:inject:react-page:outlet";
824
+
825
825
  /**
826
826
  * Configuration options for integrating React with Stone.js.
827
827
  */
@@ -884,127 +884,55 @@ interface UseReactBlueprint extends StoneBlueprint<ReactIncomingEvent, ReactOutg
884
884
  *
885
885
  * - Defines middleware, lifecycle hooks, and the default HTML template path.
886
886
  */
887
- declare const internalUseReactBlueprint: UseReactBlueprint;
888
-
889
- /**
890
- * Defines a Stone React app using a factory-based main handler.
891
- *
892
- * @param module - A factory function for the main page.
893
- * @param options - Optional application-level configuration.
894
- * @param blueprints - Additional blueprints to merge.
895
- * @returns A fully merged Stone blueprint.
896
- */
897
- declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: FactoryPage<U>, options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
898
- /**
899
- * Defines a Stone React app using a class-based main handler.
900
- *
901
- * @param module - A class constructor for the main page.
902
- * @param options - Optional application-level configuration.
903
- * @param blueprints - Additional blueprints to merge.
904
- * @returns A fully merged Stone blueprint.
905
- */
906
- declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: PageClass<U>, options: Partial<UseReactAppConfig> & {
907
- isClass: boolean;
908
- }, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
909
- /**
910
- * Defines a Stone React app without a main handler (router-only).
911
- *
912
- * @param options - 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>(options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
917
-
918
- /**
919
- * Utility function to define a factory-based adapter error page.
920
- *
921
- * @param module - The adapter error page module.
922
- * @param options - Optional adapter error page options.
923
- * @returns The UseReactBlueprint.
924
- */
925
- declare function defineAdapterErrorPage(module: FactoryAdapterErrorPage<unknown, unknown, unknown>, options?: AdapterErrorPageOptions): UseReactBlueprint;
926
- /**
927
- * Utility function to define a class-based adapter error page.
928
- *
929
- * @param module - The adapter error page module.
930
- * @param options - Adapter error page options.
931
- * @returns The UseReactBlueprint.
932
- */
933
- declare function defineAdapterErrorPage(module: AdapterErrorPageClass<unknown, unknown, unknown>, options: AdapterErrorPageOptions & {
934
- isClass: boolean;
935
- }): UseReactBlueprint;
936
-
937
- /**
938
- * UseReactBrowserErrorHandler options.
939
- */
940
- interface UseReactBrowserErrorHandlerOptions {
941
- blueprint: IBlueprint;
942
- }
943
- /**
944
- * Class representing an UseReactBrowserErrorHandler.
945
- *
946
- * Adapter level error handler for React applications.
947
- */
948
- declare class UseReactBrowserErrorHandler implements IAdapterErrorHandler<unknown, unknown, unknown> {
949
- private readonly logger;
950
- private readonly blueprint;
951
- /**
952
- * Create an UseReactBrowserErrorHandler.
953
- *
954
- * @param options - UseReactBrowserErrorHandler options.
955
- */
956
- constructor({ blueprint }: UseReactBrowserErrorHandlerOptions);
957
- /**
958
- * Handle an error.
959
- *
960
- * @param error - The error to handle.
961
- * @param context - The context of the adapter.
962
- * @returns The raw response.
963
- */
964
- handle(error: any, context: AdapterErrorContext<unknown, unknown, unknown>): Promise<AdapterEventBuilderType<unknown>>;
965
- /**
966
- * Get the error body.
967
- *
968
- * @param error - The error to handle.
969
- * @returns The error body.
970
- */
971
- private renderError;
972
- }
973
-
974
- /**
975
- * Stone Error.
976
- */
977
- declare const StoneError: FunctionComponent;
887
+ declare const internalUseReactBlueprint: UseReactBlueprint;
978
888
 
979
889
  /**
980
- * Create an UseReact response.
890
+ * Utility function to define a factory-based adapter error page.
981
891
  *
982
- * @param options - The options for creating the response.
983
- * @returns The React response.
892
+ * @param module - The adapter error page module.
893
+ * @param options - Optional adapter error page options.
894
+ * @returns The UseReactBlueprint.
984
895
  */
985
- declare const reactResponse: (options: ReactResponseOptions) => ReactOutgoingResponse;
896
+ declare function defineAdapterErrorPage(module: FactoryAdapterErrorPage<unknown, unknown, unknown>, options?: AdapterErrorPageOptions): UseReactBlueprint;
986
897
  /**
987
- * Create an UseReact redirect response.
898
+ * Utility function to define a class-based adapter error page.
988
899
  *
989
- * @param options - The options for creating the response.
990
- * @returns The React redirect response.
900
+ * @param module - The adapter error page module.
901
+ * @param options - Adapter error page options.
902
+ * @returns The UseReactBlueprint.
991
903
  */
992
- declare const reactRedirectResponse: (options: ReactRedirectResponseOptions) => ReactOutgoingResponse;
904
+ declare function defineAdapterErrorPage(module: AdapterErrorPageClass<unknown, unknown, unknown>, options: AdapterErrorPageOptions & {
905
+ isClass: boolean;
906
+ }): UseReactBlueprint;
993
907
 
994
908
  /**
995
- * Stone Client options.
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.
996
915
  */
997
- interface StoneClientOptions {
998
- children: ReactNode;
999
- }
916
+ declare function defineStoneReactApp<U extends ReactIncomingEvent = ReactIncomingEvent>(module: FactoryPage<U>, options?: Partial<UseReactAppConfig>, blueprints?: Array<StoneBlueprint<any, any> & Record<string, any>>): StoneBlueprint<U>;
1000
917
  /**
1001
- * Stone Client.
1002
- * This component is used to wrap content
1003
- * that should only be rendered on the client.
918
+ * Defines a Stone React app using a class-based main handler.
1004
919
  *
1005
- * @param options - The options to create the Stone Client.
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.
1006
924
  */
1007
- declare const StoneClient: FunctionComponent<StoneClientOptions>;
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>;
1008
936
 
1009
937
  /**
1010
938
  * Utility function to define a factory-based page.
@@ -1067,6 +995,58 @@ declare function defineErrorPage(module: ErrorPageClass<ReactIncomingEvent>, opt
1067
995
  isClass: true;
1068
996
  }): UseReactBlueprint;
1069
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
+
1070
1050
  interface BaseProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
1071
1051
  noRel?: boolean;
1072
1052
  external?: boolean;
@@ -1087,6 +1067,11 @@ type StoneLinkOptions = (BaseProps & {
1087
1067
  */
1088
1068
  declare const StoneLink: FunctionComponent<StoneLinkOptions>;
1089
1069
 
1070
+ /**
1071
+ * Stone Error.
1072
+ */
1073
+ declare const StoneError: FunctionComponent;
1074
+
1090
1075
  /**
1091
1076
  * Stone Page options.
1092
1077
  */
@@ -1143,11 +1128,19 @@ interface StoneServerOptions {
1143
1128
  declare const StoneServer: FunctionComponent<StoneServerOptions>;
1144
1129
 
1145
1130
  /**
1146
- * Custom error for react operations.
1131
+ * Stone Client options.
1147
1132
  */
1148
- declare class UseReactError extends InitializationError {
1149
- constructor(message: string, options?: ErrorOptions);
1133
+ interface StoneClientOptions {
1134
+ children: ReactNode;
1150
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>;
1151
1144
 
1152
1145
  /**
1153
1146
  * A class decorator for defining a class as a React Handler layout.
@@ -1189,24 +1182,6 @@ declare const AdapterErrorPage: <T extends ClassType = ClassType>(options: Adapt
1189
1182
  */
1190
1183
  declare const ErrorPage: <T extends ClassType = ClassType>(options: ErrorPageOptions) => ClassDecorator;
1191
1184
 
1192
- /**
1193
- * Hook decorator to mark a method as a lifecycle hook
1194
- * And automatically add it to the global lifecycle hook registry.
1195
- *
1196
- * @example
1197
- * ```typescript
1198
- * class MyClass {
1199
- * // ...
1200
- * @Hook('onPreparingPage')
1201
- * onPreparingPage () {}
1202
- * }
1203
- * ```
1204
- *
1205
- * @param name - The name of the lifecycle hook.
1206
- * @returns A class decorator function that sets the metadata using the provided options.
1207
- */
1208
- declare const Hook: <T extends Function = Function>(name: HookName) => MethodDecorator;
1209
-
1210
1185
  /**
1211
1186
  * A class decorator for defining a class as a React Page route action.
1212
1187
  * Uses the `Match` decorator internally to register the route with the HTTP `GET` method.
@@ -1232,6 +1207,24 @@ declare const Hook: <T extends Function = Function>(name: HookName) => MethodDec
1232
1207
  */
1233
1208
  declare const Page: <T extends ClassType = ClassType>(path: string | string[], options?: PageOptions) => ClassDecorator;
1234
1209
 
1210
+ /**
1211
+ * Hook decorator to mark a method as a lifecycle hook
1212
+ * And automatically add it to the global lifecycle hook registry.
1213
+ *
1214
+ * @example
1215
+ * ```typescript
1216
+ * class MyClass {
1217
+ * // ...
1218
+ * @Hook('onPreparingPage')
1219
+ * onPreparingPage () {}
1220
+ * }
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.
1225
+ */
1226
+ declare const Hook: <T extends Function = Function>(name: HookName) => MethodDecorator;
1227
+
1235
1228
  /**
1236
1229
  * Decorator to set the status code of the response.
1237
1230
  *
@@ -1389,6 +1382,13 @@ declare const SetReactPageLayoutMiddleware: (context: BlueprintContext<IBlueprin
1389
1382
  */
1390
1383
  declare function SetUseReactEventHandlerMiddleware(context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>): Promise<IBlueprint>;
1391
1384
 
1385
+ /**
1386
+ * Custom error for react operations.
1387
+ */
1388
+ declare class UseReactError extends InitializationError {
1389
+ constructor(message: string, options?: ErrorOptions);
1390
+ }
1391
+
1392
1392
  /**
1393
1393
  * UseReactServerErrorHandler options.
1394
1394
  */
@@ -1452,6 +1452,50 @@ interface UseReactOptions extends Partial<UseReactConfig> {
1452
1452
  */
1453
1453
  declare const UseReact: <T extends ClassType = ClassType>(options?: UseReactOptions) => ClassDecorator;
1454
1454
 
1455
+ /**
1456
+ * Blueprint middleware to set BrowserResponseMiddleware for the Browser adapter.
1457
+ *
1458
+ * The MetaBrowserResponseMiddleware is an adapter middleware and is useful
1459
+ * for handling outgoing responses and rendering them in the browser.
1460
+ *
1461
+ * @param context - The configuration context containing modules and blueprint.
1462
+ * @param next - The next pipeline function to continue processing.
1463
+ * @returns The updated blueprint or a promise resolving to it.
1464
+ *
1465
+ * @example
1466
+ * ```typescript
1467
+ * SetBrowserResponseMiddlewareMiddleware(context, next)
1468
+ * ```
1469
+ */
1470
+ declare const SetBrowserResponseMiddlewareMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promise<IBlueprint>;
1471
+ /**
1472
+ * Blueprint middleware to process and register adapter error page definitions from modules.
1473
+ *
1474
+ * @param context - The configuration context containing modules and blueprint.
1475
+ * @param next - The next pipeline function to continue processing.
1476
+ * @returns The updated blueprint or a promise resolving to it.
1477
+ *
1478
+ * @example
1479
+ * ```typescript
1480
+ * SetReactAdapterErrorPageMiddleware(context, next)
1481
+ * ```
1482
+ */
1483
+ declare const SetReactAdapterErrorPageMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
1484
+ /**
1485
+ * Configuration for react processing middleware.
1486
+ *
1487
+ * This array defines a list of middleware pipes, each with a `pipe` function and a `priority`.
1488
+ * These pipes are executed in the order of their priority values, with lower values running first.
1489
+ */
1490
+ declare const metaBrowserUseReactBlueprintMiddleware: Array<MetaMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>>;
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
+
1455
1499
  /**
1456
1500
  * Adapter Middleware for handling outgoing responses and rendering them in the browser.
1457
1501
  */
@@ -1518,49 +1562,5 @@ declare const MetaBrowserResponseMiddleware: {
1518
1562
  isClass: boolean;
1519
1563
  };
1520
1564
 
1521
- /**
1522
- * Default blueprint for a React-based Stone.js application.
1523
- *
1524
- * - Defines middleware, lifecycle hooks, and the default HTML template path.
1525
- */
1526
- declare const useReactBlueprint: UseReactBlueprint;
1527
-
1528
- /**
1529
- * Blueprint middleware to set BrowserResponseMiddleware for the Browser adapter.
1530
- *
1531
- * The MetaBrowserResponseMiddleware is an adapter middleware and is useful
1532
- * for handling outgoing responses and rendering them in the browser.
1533
- *
1534
- * @param context - The configuration context containing modules and blueprint.
1535
- * @param next - The next pipeline function to continue processing.
1536
- * @returns The updated blueprint or a promise resolving to it.
1537
- *
1538
- * @example
1539
- * ```typescript
1540
- * SetBrowserResponseMiddlewareMiddleware(context, next)
1541
- * ```
1542
- */
1543
- declare const SetBrowserResponseMiddlewareMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promise<IBlueprint>;
1544
- /**
1545
- * Blueprint middleware to process and register adapter error page definitions from modules.
1546
- *
1547
- * @param context - The configuration context containing modules and blueprint.
1548
- * @param next - The next pipeline function to continue processing.
1549
- * @returns The updated blueprint or a promise resolving to it.
1550
- *
1551
- * @example
1552
- * ```typescript
1553
- * SetReactAdapterErrorPageMiddleware(context, next)
1554
- * ```
1555
- */
1556
- declare const SetReactAdapterErrorPageMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promiseable<IBlueprint>;
1557
- /**
1558
- * Configuration for react processing middleware.
1559
- *
1560
- * This array defines a list of middleware pipes, each with a `pipe` function and a `priority`.
1561
- * These pipes are executed in the order of their priority values, with lower values running first.
1562
- */
1563
- declare const metaBrowserUseReactBlueprintMiddleware: Array<MetaMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>>;
1564
-
1565
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 };
1566
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 };