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.
package/dist/cjs/index.js CHANGED
@@ -828,6 +828,28 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
828
828
  /*------------------------------------------------------------------------*/
829
829
  /* --------------------------- Static Helpers --------------------------- */
830
830
  /*------------------------------------------------------------------------*/
831
+ // Timestamp after initialization when helpers should be available
832
+ const timestampWhenHelpersShouldBeAvailable = Date.now() + 2000;
833
+ /**
834
+ * Wait for a little while for a helper to exist
835
+ * @author Gabe Abrams
836
+ * @param checkForHelper a function that returns true if the helper exists
837
+ * @returns true if the helper exists, false if the process timed out
838
+ */
839
+ const waitForHelper = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
840
+ // Wait for helper to exist
841
+ while (!checkForHelper()) {
842
+ // Check if we should stop waiting
843
+ if (Date.now() > timestampWhenHelpersShouldBeAvailable) {
844
+ // Stop waiting
845
+ return false;
846
+ }
847
+ // Wait a little while
848
+ yield waitMs(10);
849
+ }
850
+ // Helper exists
851
+ return true;
852
+ });
831
853
  /*----------------------------------------*/
832
854
  /* ----------- Redirect/Leave ----------- */
833
855
  /*----------------------------------------*/
@@ -874,6 +896,10 @@ let onAlertClosed;
874
896
  * @param text the text to display in the alert
875
897
  */
876
898
  const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
899
+ // Wait for helper to exist
900
+ yield waitForHelper(() => {
901
+ return !!setAlertInfo;
902
+ });
877
903
  // Fallback if alert not available
878
904
  if (!setAlertInfo) {
879
905
  // eslint-disable-next-line no-alert
@@ -915,6 +941,10 @@ let onConfirmClosed;
915
941
  * @returns true if the user confirmed
916
942
  */
917
943
  const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, function* () {
944
+ // Wait for helper to exist
945
+ yield waitForHelper(() => {
946
+ return !!setConfirmInfo;
947
+ });
918
948
  // Fallback if confirm is not available
919
949
  if (!setConfirmInfo) {
920
950
  // eslint-disable-next-line no-alert
@@ -949,7 +979,7 @@ const fatalErrorHandlers = [];
949
979
  * @param error the error to show
950
980
  * @param [errorTitle] title of the error box
951
981
  */
952
- const showFatalError = (error, errorTitle = 'An Error Occurred') => {
982
+ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(void 0, void 0, void 0, function* () {
953
983
  var _a, _b;
954
984
  // Determine message and code
955
985
  const message = (typeof error === 'string'
@@ -979,17 +1009,21 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => {
979
1009
  errorTitle,
980
1010
  },
981
1011
  });
1012
+ // Wait for helper to exist
1013
+ yield waitForHelper(() => {
1014
+ return (!!setFatalErrorMessage
1015
+ && !!setFatalErrorCode);
1016
+ });
982
1017
  // Handle case where app hasn't loaded
983
1018
  if (!setFatalErrorMessage || !setFatalErrorCode) {
984
1019
  alert$1(errorTitle, `${message} (code: ${code}). Please contact support.`);
985
- return undefined;
1020
+ return;
986
1021
  }
987
1022
  // Use setters
988
1023
  setFatalErrorMessage(message);
989
1024
  setFatalErrorCode(code);
990
1025
  setFatalErrorTitle(errorTitle);
991
- return undefined;
992
- };
1026
+ });
993
1027
  /**
994
1028
  * Add a handler for when a fatal error occurs
995
1029
  * @author Gabe Abrams