dce-reactkit 3.6.1 → 3.6.2

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.
@@ -50,7 +50,7 @@ export declare const confirm: (title: string, text: string, opts?: {
50
50
  * @param error the error to show
51
51
  * @param [errorTitle] title of the error box
52
52
  */
53
- export declare const showFatalError: (error: any, errorTitle?: string) => undefined;
53
+ export declare const showFatalError: (error: any, errorTitle?: string) => Promise<void>;
54
54
  /**
55
55
  * Add a handler for when a fatal error occurs
56
56
  * @author Gabe Abrams
@@ -60,6 +60,6 @@ export declare const addFatalErrorHandler: (handler: () => void) => void;
60
60
  * Show the "session expired" message
61
61
  * @author Gabe Abrams
62
62
  */
63
- export declare const showSessionExpiredMessage: () => undefined;
63
+ export declare const showSessionExpiredMessage: () => void;
64
64
  declare const AppWrapper: React.FC<Props>;
65
65
  export default AppWrapper;
package/dist/esm/index.js CHANGED
@@ -802,6 +802,28 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
802
802
  /*------------------------------------------------------------------------*/
803
803
  /* --------------------------- Static Helpers --------------------------- */
804
804
  /*------------------------------------------------------------------------*/
805
+ // Timestamp after initialization when helpers should be available
806
+ const timestampWhenHelpersShouldBeAvailable = Date.now() + 2000;
807
+ /**
808
+ * Wait for a little while for a helper to exist
809
+ * @author Gabe Abrams
810
+ * @param checkForHelper a function that returns true if the helper exists
811
+ * @returns true if the helper exists, false if the process timed out
812
+ */
813
+ const waitForHelper = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
814
+ // Wait for helper to exist
815
+ while (!checkForHelper()) {
816
+ // Check if we should stop waiting
817
+ if (Date.now() > timestampWhenHelpersShouldBeAvailable) {
818
+ // Stop waiting
819
+ return false;
820
+ }
821
+ // Wait a little while
822
+ yield waitMs(10);
823
+ }
824
+ // Helper exists
825
+ return true;
826
+ });
805
827
  /*----------------------------------------*/
806
828
  /* ----------- Redirect/Leave ----------- */
807
829
  /*----------------------------------------*/
@@ -848,6 +870,10 @@ let onAlertClosed;
848
870
  * @param text the text to display in the alert
849
871
  */
850
872
  const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
873
+ // Wait for helper to exist
874
+ yield waitForHelper(() => {
875
+ return !!setAlertInfo;
876
+ });
851
877
  // Fallback if alert not available
852
878
  if (!setAlertInfo) {
853
879
  // eslint-disable-next-line no-alert
@@ -889,6 +915,10 @@ let onConfirmClosed;
889
915
  * @returns true if the user confirmed
890
916
  */
891
917
  const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, function* () {
918
+ // Wait for helper to exist
919
+ yield waitForHelper(() => {
920
+ return !!setConfirmInfo;
921
+ });
892
922
  // Fallback if confirm is not available
893
923
  if (!setConfirmInfo) {
894
924
  // eslint-disable-next-line no-alert
@@ -923,7 +953,7 @@ const fatalErrorHandlers = [];
923
953
  * @param error the error to show
924
954
  * @param [errorTitle] title of the error box
925
955
  */
926
- const showFatalError = (error, errorTitle = 'An Error Occurred') => {
956
+ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(void 0, void 0, void 0, function* () {
927
957
  var _a, _b;
928
958
  // Determine message and code
929
959
  const message = (typeof error === 'string'
@@ -953,17 +983,21 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => {
953
983
  errorTitle,
954
984
  },
955
985
  });
986
+ // Wait for helper to exist
987
+ yield waitForHelper(() => {
988
+ return (!!setFatalErrorMessage
989
+ && !!setFatalErrorCode);
990
+ });
956
991
  // Handle case where app hasn't loaded
957
992
  if (!setFatalErrorMessage || !setFatalErrorCode) {
958
993
  alert$1(errorTitle, `${message} (code: ${code}). Please contact support.`);
959
- return undefined;
994
+ return;
960
995
  }
961
996
  // Use setters
962
997
  setFatalErrorMessage(message);
963
998
  setFatalErrorCode(code);
964
999
  setFatalErrorTitle(errorTitle);
965
- return undefined;
966
- };
1000
+ });
967
1001
  /**
968
1002
  * Add a handler for when a fatal error occurs
969
1003
  * @author Gabe Abrams