@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/browser.js +69 -69
- package/dist/index.d.ts +287 -287
- package/dist/index.js +374 -374
- package/package.json +7 -7
package/dist/browser.js
CHANGED
|
@@ -710,48 +710,6 @@ class ReactRuntime {
|
|
|
710
710
|
*/
|
|
711
711
|
const MetaReactRuntime = { module: ReactRuntime, isClass: true, alias: 'reactRuntime', singleton: true };
|
|
712
712
|
|
|
713
|
-
/**
|
|
714
|
-
* A useReact event handler for processing incoming events
|
|
715
|
-
* For single event handler.
|
|
716
|
-
*
|
|
717
|
-
* Multiple event handlers will be processed by the router.
|
|
718
|
-
*
|
|
719
|
-
* @template IncomingEventType - The type representing the incoming event.
|
|
720
|
-
* @template OutgoingResponseType - The type representing the outgoing response.
|
|
721
|
-
*/
|
|
722
|
-
class UseReactEventHandler {
|
|
723
|
-
blueprint;
|
|
724
|
-
/**
|
|
725
|
-
* Constructs a `UseReactEventHandler` instance.
|
|
726
|
-
*
|
|
727
|
-
* @param options - The UseReactEventHandler options including blueprint.
|
|
728
|
-
*/
|
|
729
|
-
constructor({ blueprint }) {
|
|
730
|
-
this.blueprint = blueprint;
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Handle an incoming event.
|
|
734
|
-
*
|
|
735
|
-
* @returns The outgoing response.
|
|
736
|
-
*/
|
|
737
|
-
handle() {
|
|
738
|
-
return this.getComponentEventHandler();
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Get the component event handler.
|
|
742
|
-
*
|
|
743
|
-
* @returns The component event handler.
|
|
744
|
-
* @throws {UseReactError} If the component event handler is missing.
|
|
745
|
-
*/
|
|
746
|
-
getComponentEventHandler() {
|
|
747
|
-
const handler = this.blueprint.get('stone.useReact.componentEventHandler');
|
|
748
|
-
if (isEmpty(handler)) {
|
|
749
|
-
throw new UseReactError('The component event handler is missing.');
|
|
750
|
-
}
|
|
751
|
-
return handler;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
|
|
755
713
|
/**
|
|
756
714
|
* Class representing an UseReactUseReactKernelErrorHandler.
|
|
757
715
|
*
|
|
@@ -871,6 +829,48 @@ async function onPreparingResponse({ event, response, container }) {
|
|
|
871
829
|
}
|
|
872
830
|
}
|
|
873
831
|
|
|
832
|
+
/**
|
|
833
|
+
* A useReact event handler for processing incoming events
|
|
834
|
+
* For single event handler.
|
|
835
|
+
*
|
|
836
|
+
* Multiple event handlers will be processed by the router.
|
|
837
|
+
*
|
|
838
|
+
* @template IncomingEventType - The type representing the incoming event.
|
|
839
|
+
* @template OutgoingResponseType - The type representing the outgoing response.
|
|
840
|
+
*/
|
|
841
|
+
class UseReactEventHandler {
|
|
842
|
+
blueprint;
|
|
843
|
+
/**
|
|
844
|
+
* Constructs a `UseReactEventHandler` instance.
|
|
845
|
+
*
|
|
846
|
+
* @param options - The UseReactEventHandler options including blueprint.
|
|
847
|
+
*/
|
|
848
|
+
constructor({ blueprint }) {
|
|
849
|
+
this.blueprint = blueprint;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Handle an incoming event.
|
|
853
|
+
*
|
|
854
|
+
* @returns The outgoing response.
|
|
855
|
+
*/
|
|
856
|
+
handle() {
|
|
857
|
+
return this.getComponentEventHandler();
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Get the component event handler.
|
|
861
|
+
*
|
|
862
|
+
* @returns The component event handler.
|
|
863
|
+
* @throws {UseReactError} If the component event handler is missing.
|
|
864
|
+
*/
|
|
865
|
+
getComponentEventHandler() {
|
|
866
|
+
const handler = this.blueprint.get('stone.useReact.componentEventHandler');
|
|
867
|
+
if (isEmpty(handler)) {
|
|
868
|
+
throw new UseReactError('The component event handler is missing.');
|
|
869
|
+
}
|
|
870
|
+
return handler;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
874
|
/**
|
|
875
875
|
* Use React Service Provider.
|
|
876
876
|
*/
|
|
@@ -912,6 +912,33 @@ class UseReactServiceProvider {
|
|
|
912
912
|
*/
|
|
913
913
|
const MetaUseReactServiceProvider = { module: UseReactServiceProvider, isClass: true };
|
|
914
914
|
|
|
915
|
+
/**
|
|
916
|
+
* Utility function to define an adapter error page.
|
|
917
|
+
*
|
|
918
|
+
* @param module - The adapter error page module.
|
|
919
|
+
* @param options - Optional adapter error page options.
|
|
920
|
+
* @returns The UseReactBlueprint.
|
|
921
|
+
*/
|
|
922
|
+
function defineAdapterErrorPage(module, options) {
|
|
923
|
+
const error = options?.error ?? 'default';
|
|
924
|
+
const adapterErrorPages = Object.fromEntries([error].flat().map((err) => [
|
|
925
|
+
err,
|
|
926
|
+
{
|
|
927
|
+
...options,
|
|
928
|
+
module,
|
|
929
|
+
error: err,
|
|
930
|
+
isFactory: options?.isClass !== true
|
|
931
|
+
}
|
|
932
|
+
]));
|
|
933
|
+
return {
|
|
934
|
+
stone: {
|
|
935
|
+
useReact: {
|
|
936
|
+
adapterErrorPages
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
|
|
915
942
|
/**
|
|
916
943
|
* Default blueprint for a React-based Stone.js application.
|
|
917
944
|
*
|
|
@@ -966,33 +993,6 @@ function defineStoneReactApp(moduleOrOptions = {}, optionsOrBlueprints, maybeBlu
|
|
|
966
993
|
return mergeBlueprints(stoneBlueprint, internalUseReactBlueprint, ...blueprints, { stone: stonePart });
|
|
967
994
|
}
|
|
968
995
|
|
|
969
|
-
/**
|
|
970
|
-
* Utility function to define an adapter error page.
|
|
971
|
-
*
|
|
972
|
-
* @param module - The adapter error page module.
|
|
973
|
-
* @param options - Optional adapter error page options.
|
|
974
|
-
* @returns The UseReactBlueprint.
|
|
975
|
-
*/
|
|
976
|
-
function defineAdapterErrorPage(module, options) {
|
|
977
|
-
const error = options?.error ?? 'default';
|
|
978
|
-
const adapterErrorPages = Object.fromEntries([error].flat().map((err) => [
|
|
979
|
-
err,
|
|
980
|
-
{
|
|
981
|
-
...options,
|
|
982
|
-
module,
|
|
983
|
-
error: err,
|
|
984
|
-
isFactory: options?.isClass !== true
|
|
985
|
-
}
|
|
986
|
-
]));
|
|
987
|
-
return {
|
|
988
|
-
stone: {
|
|
989
|
-
useReact: {
|
|
990
|
-
adapterErrorPages
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
|
|
996
996
|
/**
|
|
997
997
|
* Utility function to define a page.
|
|
998
998
|
*
|