dce-reactkit 3.6.1 → 3.6.3
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/cjs/index.js +72 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/AppWrapper.d.ts +2 -2
- package/dist/esm/index.js +72 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/AppWrapper.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AppWrapper.tsx +63 -8
- package/src/helpers/visitServerEndpoint.tsx +38 -0
package/dist/cjs/index.js
CHANGED
|
@@ -670,6 +670,36 @@ var LogLevel;
|
|
|
670
670
|
})(LogLevel || (LogLevel = {}));
|
|
671
671
|
var LogLevel$1 = LogLevel;
|
|
672
672
|
|
|
673
|
+
/*------------------------------------------------------------------------*/
|
|
674
|
+
/* --------------------------- Static Helpers --------------------------- */
|
|
675
|
+
/*------------------------------------------------------------------------*/
|
|
676
|
+
// Timestamp after initialization when helpers should be available
|
|
677
|
+
const timestampWhenHelpersShouldBeAvailable$1 = Date.now() + 2000;
|
|
678
|
+
/**
|
|
679
|
+
* Wait for a little while for a helper to exist
|
|
680
|
+
* @author Gabe Abrams
|
|
681
|
+
* @param checkForHelper a function that returns true if the helper exists
|
|
682
|
+
* @returns true if the helper exists, false if the process timed out
|
|
683
|
+
*/
|
|
684
|
+
const waitForHelper$1 = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
|
|
685
|
+
// Wait for helper to exist
|
|
686
|
+
while (!checkForHelper()) {
|
|
687
|
+
// Check if we should stop waiting
|
|
688
|
+
if (Date.now() > timestampWhenHelpersShouldBeAvailable$1) {
|
|
689
|
+
// Stop waiting
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
// Wait a little while
|
|
693
|
+
yield waitMs(10);
|
|
694
|
+
}
|
|
695
|
+
// Helper exists
|
|
696
|
+
return true;
|
|
697
|
+
});
|
|
698
|
+
/*------------------------------------------------------------------------*/
|
|
699
|
+
/* Listener */
|
|
700
|
+
/*------------------------------------------------------------------------*/
|
|
701
|
+
// Handler for session expiry
|
|
702
|
+
let sessionExpiryHandler;
|
|
673
703
|
// Keep track of whether or not session expiry has already been handled
|
|
674
704
|
let sessionAlreadyExpired = false;
|
|
675
705
|
/*------------------------------------------------------------------------*/
|
|
@@ -762,6 +792,10 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
|
|
|
762
792
|
});
|
|
763
793
|
}
|
|
764
794
|
sessionAlreadyExpired = true;
|
|
795
|
+
// Wait for helper to exist
|
|
796
|
+
yield waitForHelper$1(() => {
|
|
797
|
+
return !!sessionExpiryHandler;
|
|
798
|
+
});
|
|
765
799
|
// Show session expiration message
|
|
766
800
|
{
|
|
767
801
|
// Fallback to alert
|
|
@@ -828,6 +862,28 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
828
862
|
/*------------------------------------------------------------------------*/
|
|
829
863
|
/* --------------------------- Static Helpers --------------------------- */
|
|
830
864
|
/*------------------------------------------------------------------------*/
|
|
865
|
+
// Timestamp after initialization when helpers should be available
|
|
866
|
+
const timestampWhenHelpersShouldBeAvailable = Date.now() + 2000;
|
|
867
|
+
/**
|
|
868
|
+
* Wait for a little while for a helper to exist
|
|
869
|
+
* @author Gabe Abrams
|
|
870
|
+
* @param checkForHelper a function that returns true if the helper exists
|
|
871
|
+
* @returns true if the helper exists, false if the process timed out
|
|
872
|
+
*/
|
|
873
|
+
const waitForHelper = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
|
|
874
|
+
// Wait for helper to exist
|
|
875
|
+
while (!checkForHelper()) {
|
|
876
|
+
// Check if we should stop waiting
|
|
877
|
+
if (Date.now() > timestampWhenHelpersShouldBeAvailable) {
|
|
878
|
+
// Stop waiting
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
// Wait a little while
|
|
882
|
+
yield waitMs(10);
|
|
883
|
+
}
|
|
884
|
+
// Helper exists
|
|
885
|
+
return true;
|
|
886
|
+
});
|
|
831
887
|
/*----------------------------------------*/
|
|
832
888
|
/* ----------- Redirect/Leave ----------- */
|
|
833
889
|
/*----------------------------------------*/
|
|
@@ -874,6 +930,10 @@ let onAlertClosed;
|
|
|
874
930
|
* @param text the text to display in the alert
|
|
875
931
|
*/
|
|
876
932
|
const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
933
|
+
// Wait for helper to exist
|
|
934
|
+
yield waitForHelper(() => {
|
|
935
|
+
return !!setAlertInfo;
|
|
936
|
+
});
|
|
877
937
|
// Fallback if alert not available
|
|
878
938
|
if (!setAlertInfo) {
|
|
879
939
|
// eslint-disable-next-line no-alert
|
|
@@ -915,6 +975,10 @@ let onConfirmClosed;
|
|
|
915
975
|
* @returns true if the user confirmed
|
|
916
976
|
*/
|
|
917
977
|
const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
978
|
+
// Wait for helper to exist
|
|
979
|
+
yield waitForHelper(() => {
|
|
980
|
+
return !!setConfirmInfo;
|
|
981
|
+
});
|
|
918
982
|
// Fallback if confirm is not available
|
|
919
983
|
if (!setConfirmInfo) {
|
|
920
984
|
// eslint-disable-next-line no-alert
|
|
@@ -949,7 +1013,7 @@ const fatalErrorHandlers = [];
|
|
|
949
1013
|
* @param error the error to show
|
|
950
1014
|
* @param [errorTitle] title of the error box
|
|
951
1015
|
*/
|
|
952
|
-
const showFatalError = (error, errorTitle = 'An Error Occurred') => {
|
|
1016
|
+
const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(void 0, void 0, void 0, function* () {
|
|
953
1017
|
var _a, _b;
|
|
954
1018
|
// Determine message and code
|
|
955
1019
|
const message = (typeof error === 'string'
|
|
@@ -979,17 +1043,21 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => {
|
|
|
979
1043
|
errorTitle,
|
|
980
1044
|
},
|
|
981
1045
|
});
|
|
1046
|
+
// Wait for helper to exist
|
|
1047
|
+
yield waitForHelper(() => {
|
|
1048
|
+
return (!!setFatalErrorMessage
|
|
1049
|
+
&& !!setFatalErrorCode);
|
|
1050
|
+
});
|
|
982
1051
|
// Handle case where app hasn't loaded
|
|
983
1052
|
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
984
1053
|
alert$1(errorTitle, `${message} (code: ${code}). Please contact support.`);
|
|
985
|
-
return
|
|
1054
|
+
return;
|
|
986
1055
|
}
|
|
987
1056
|
// Use setters
|
|
988
1057
|
setFatalErrorMessage(message);
|
|
989
1058
|
setFatalErrorCode(code);
|
|
990
1059
|
setFatalErrorTitle(errorTitle);
|
|
991
|
-
|
|
992
|
-
};
|
|
1060
|
+
});
|
|
993
1061
|
/**
|
|
994
1062
|
* Add a handler for when a fatal error occurs
|
|
995
1063
|
* @author Gabe Abrams
|