akeyless-client-commons 1.1.17-test.1 → 1.1.17-test.10

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.
@@ -253,7 +253,7 @@ function _ts_generator(thisArg, body) {
253
253
  }
254
254
  }
255
255
  import { CountryOptions as CountryOptions2 } from "akeyless-types-commons";
256
- import { useEffect as useEffect3, useLayoutEffect, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
256
+ import { useEffect, useLayoutEffect } from "react";
257
257
  // src/helpers/firebase.ts
258
258
  import moment from "moment";
259
259
  import { initializeApp } from "firebase/app";
@@ -425,11 +425,11 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
425
425
  collectionRef = query(collectionRef, orderBy(order.fieldName, order.direction));
426
426
  });
427
427
  }
428
- var unsubscribe = onSnapshot(collectionRef, function(snapshot2) {
428
+ var unsubscribe = onSnapshot(collectionRef, function(snapshot3) {
429
429
  if (!snapshotsFirstTime.includes(config.collectionName)) {
430
430
  var _config_onFirstTime, _config_extraParsers;
431
431
  snapshotsFirstTime.push(config.collectionName);
432
- var documents = snapshot2.docs.map(function(doc2) {
432
+ var documents = snapshot3.docs.map(function(doc2) {
433
433
  return simpleExtractData(doc2);
434
434
  });
435
435
  (_config_onFirstTime = config.onFirstTime) === null || _config_onFirstTime === void 0 ? void 0 : _config_onFirstTime.call(config, documents, config);
@@ -443,7 +443,7 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
443
443
  var addedDocs = [];
444
444
  var modifiedDocs = [];
445
445
  var removedDocs = [];
446
- snapshot2.docChanges().forEach(function(change) {
446
+ snapshot3.docChanges().forEach(function(change) {
447
447
  if (change.type === "added") {
448
448
  addedDocs.push(simpleExtractData(change.doc));
449
449
  } else if (change.type === "modified") {
@@ -550,6 +550,7 @@ var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseD
550
550
  var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
551
551
  // src/helpers/socket.ts
552
552
  import { io } from "socket.io-client";
553
+ var SESSION_STORAGE_KEY = "sessionId";
553
554
  var SocketService = /*#__PURE__*/ function() {
554
555
  "use strict";
555
556
  function _SocketService() {
@@ -557,6 +558,7 @@ var SocketService = /*#__PURE__*/ function() {
557
558
  this.socket = null;
558
559
  this.connectCallbacks = [];
559
560
  this.disconnectCallbacks = [];
561
+ this.authToken = null;
560
562
  }
561
563
  _create_class(_SocketService, [
562
564
  {
@@ -566,16 +568,23 @@ var SocketService = /*#__PURE__*/ function() {
566
568
  var _this = this;
567
569
  if (!this.socket) {
568
570
  var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
569
- console.log("socketUrl", socketUrl);
570
571
  this.socket = io(socketUrl, {
571
572
  path: "/api/data-socket/connect",
572
- transports: [
573
- "websocket"
574
- ]
573
+ auth: function(cb) {
574
+ var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
575
+ var token = _this.authToken;
576
+ var authPayload = {};
577
+ if (token) authPayload.token = token;
578
+ if (sessionId) authPayload.sessionId = sessionId;
579
+ cb(authPayload);
580
+ },
581
+ reconnection: true,
582
+ reconnectionAttempts: 30,
583
+ reconnectionDelay: 2 * 1e3
575
584
  });
576
585
  this.socket.on("connect", function() {
577
- var _this_socket;
578
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
586
+ var _this_socket, _this_socket1;
587
+ console.log("\uD83D\uDFE2 Socket connected: ".concat((_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id, " (recovered - ").concat((_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.recovered, ")"));
579
588
  _this.connectCallbacks.forEach(function(cb) {
580
589
  return cb();
581
590
  });
@@ -586,6 +595,12 @@ var SocketService = /*#__PURE__*/ function() {
586
595
  return cb();
587
596
  });
588
597
  });
598
+ this.socket.on("session", function(param) {
599
+ var sessionId = param.sessionId;
600
+ if (sessionId) {
601
+ localStorage.setItem(SESSION_STORAGE_KEY, sessionId);
602
+ }
603
+ });
589
604
  this.socket.on("connect_error", function(error) {
590
605
  console.error("Socket connection error:", error);
591
606
  });
@@ -608,10 +623,93 @@ var SocketService = /*#__PURE__*/ function() {
608
623
  return this.socket;
609
624
  }
610
625
  },
626
+ {
627
+ /// connection management methods
628
+ key: "startSession",
629
+ value: function startSession(token) {
630
+ this.setAuthToken(token);
631
+ this.initSocket();
632
+ }
633
+ },
634
+ {
635
+ key: "onConnect",
636
+ value: function onConnect(callback) {
637
+ var _this = this;
638
+ var _this_socket;
639
+ if (!this.connectCallbacks.includes(callback)) {
640
+ this.connectCallbacks.push(callback);
641
+ }
642
+ if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
643
+ callback();
644
+ }
645
+ return function() {
646
+ return _this.offConnect(callback);
647
+ };
648
+ }
649
+ },
650
+ {
651
+ key: "offConnect",
652
+ value: function offConnect(callback) {
653
+ this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
654
+ return cb !== callback;
655
+ });
656
+ }
657
+ },
658
+ {
659
+ key: "onDisconnect",
660
+ value: function onDisconnect(callback) {
661
+ var _this = this;
662
+ if (!this.disconnectCallbacks.includes(callback)) {
663
+ this.disconnectCallbacks.push(callback);
664
+ }
665
+ if (this.socket && !this.socket.connected) {
666
+ callback();
667
+ }
668
+ return function() {
669
+ return _this.offDisconnect(callback);
670
+ };
671
+ }
672
+ },
673
+ {
674
+ key: "offDisconnect",
675
+ value: function offDisconnect(callback) {
676
+ this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
677
+ return cb !== callback;
678
+ });
679
+ }
680
+ },
681
+ {
682
+ key: "isConnected",
683
+ value: function isConnected() {
684
+ var _this_socket;
685
+ return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
686
+ }
687
+ },
688
+ {
689
+ key: "setAuthToken",
690
+ value: function setAuthToken(token) {
691
+ this.authToken = token;
692
+ if (this.socket) {
693
+ this.socket.connect();
694
+ }
695
+ }
696
+ },
697
+ {
698
+ key: "disconnectSocket",
699
+ value: function disconnectSocket() {
700
+ if (this.socket) {
701
+ this.socket.io.engine.close();
702
+ }
703
+ }
704
+ },
611
705
  {
612
706
  /// subscribe to collections
613
707
  key: "subscribeToCollections",
614
708
  value: function subscribeToCollections(config) {
709
+ var _this = this;
710
+ if (config.length === 0) {
711
+ return function() {};
712
+ }
615
713
  var s = this.getSocketInstance();
616
714
  var collectionsNames = config.map(function(c) {
617
715
  return c.collectionName;
@@ -619,48 +717,24 @@ var SocketService = /*#__PURE__*/ function() {
619
717
  var eventHandlers = [];
620
718
  config.forEach(function(configuration) {
621
719
  var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers, conditions = configuration.conditions, orderBy2 = configuration.orderBy;
622
- s.on("initial:".concat(collectionName), onFirstTime);
623
- eventHandlers.push({
624
- eventName: "initial:".concat(collectionName),
625
- handler: onFirstTime
626
- });
627
- s.on("add:".concat(collectionName), onAdd);
628
- eventHandlers.push({
629
- eventName: "add:".concat(collectionName),
630
- handler: onAdd
631
- });
632
- s.on("update:".concat(collectionName), onModify);
633
- eventHandlers.push({
634
- eventName: "update:".concat(collectionName),
635
- handler: onModify
636
- });
637
- s.on("delete:".concat(collectionName), onRemove);
638
- eventHandlers.push({
639
- eventName: "delete:".concat(collectionName),
640
- handler: onRemove
641
- });
642
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
643
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
644
- s.on("initial:".concat(collectionName), extraOnFirstTime);
645
- eventHandlers.push({
646
- eventName: "initial:".concat(collectionName),
647
- handler: extraOnFirstTime
648
- });
649
- s.on("add:".concat(collectionName), extraOnAdd);
650
- eventHandlers.push({
651
- eventName: "add:".concat(collectionName),
652
- handler: extraOnAdd
653
- });
654
- s.on("update:".concat(collectionName), extraOnModify);
655
- eventHandlers.push({
656
- eventName: "update:".concat(collectionName),
657
- handler: extraOnModify
658
- });
659
- s.on("delete:".concat(collectionName), extraOnRemove);
720
+ var attach = function(eventName, handler) {
721
+ _this.socket.off(eventName, handler);
722
+ _this.socket.on(eventName, handler);
660
723
  eventHandlers.push({
661
- eventName: "delete:".concat(collectionName),
662
- handler: extraOnRemove
724
+ eventName: eventName,
725
+ handler: handler
663
726
  });
727
+ };
728
+ attach("initial:".concat(collectionName), onFirstTime);
729
+ attach("add:".concat(collectionName), onAdd);
730
+ attach("update:".concat(collectionName), onModify);
731
+ attach("delete:".concat(collectionName), onRemove);
732
+ extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
733
+ var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
734
+ attach("initial:".concat(collectionName), extraOnFirstTime);
735
+ attach("add:".concat(collectionName), extraOnAdd);
736
+ attach("update:".concat(collectionName), extraOnModify);
737
+ attach("delete:".concat(collectionName), extraOnRemove);
664
738
  });
665
739
  });
666
740
  s.emit("subscribe_collections", collectionsNames, function(callback) {
@@ -761,49 +835,6 @@ var SocketService = /*#__PURE__*/ function() {
761
835
  });
762
836
  });
763
837
  }
764
- },
765
- {
766
- /// connection management methods
767
- key: "onConnect",
768
- value: function onConnect(callback) {
769
- var _this_socket;
770
- this.connectCallbacks.push(callback);
771
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
772
- callback();
773
- }
774
- }
775
- },
776
- {
777
- key: "offConnect",
778
- value: function offConnect(callback) {
779
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
780
- return cb !== callback;
781
- });
782
- }
783
- },
784
- {
785
- key: "onDisconnect",
786
- value: function onDisconnect(callback) {
787
- this.disconnectCallbacks.push(callback);
788
- if (this.socket && !this.socket.connected) {
789
- callback();
790
- }
791
- }
792
- },
793
- {
794
- key: "offDisconnect",
795
- value: function offDisconnect(callback) {
796
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
797
- return cb !== callback;
798
- });
799
- }
800
- },
801
- {
802
- key: "isConnected",
803
- value: function isConnected() {
804
- var _this_socket;
805
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
806
- }
807
838
  }
808
839
  ], [
809
840
  {
@@ -819,11 +850,54 @@ var SocketService = /*#__PURE__*/ function() {
819
850
  return _SocketService;
820
851
  }();
821
852
  var socketServiceInstance = SocketService.getInstance();
853
+ // src/hooks/global.ts
854
+ var useDocumentTitle = function(title) {
855
+ useEffect(function() {
856
+ document.title = title;
857
+ }, [
858
+ title
859
+ ]);
860
+ return null;
861
+ };
862
+ var useSetUserCountry = function(setUserCountry, changLang) {
863
+ useLayoutEffect(function() {
864
+ var currentCountry = localStorage.getItem("userCountry");
865
+ if (!currentCountry) {
866
+ var updateCountry = /*#__PURE__*/ function() {
867
+ var _ref = _async_to_generator(function() {
868
+ var country;
869
+ return _ts_generator(this, function(_state) {
870
+ switch(_state.label){
871
+ case 0:
872
+ return [
873
+ 4,
874
+ getUserCountryByIp()
875
+ ];
876
+ case 1:
877
+ country = _state.sent();
878
+ changLang(country === CountryOptions2.IL ? "he" : "en");
879
+ setUserCountry(country);
880
+ localStorage.setItem("userCountry", country);
881
+ return [
882
+ 2
883
+ ];
884
+ }
885
+ });
886
+ });
887
+ return function updateCountry() {
888
+ return _ref.apply(this, arguments);
889
+ };
890
+ }();
891
+ updateCountry();
892
+ }
893
+ }, []);
894
+ return null;
895
+ };
822
896
  // src/hooks/react.ts
823
897
  import { isEqual as isEqual2 } from "lodash";
824
- import { useEffect, useMemo, useRef } from "react";
898
+ import { useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
825
899
  function useSafeEffect(callback, dependencies, error_message) {
826
- useEffect(function() {
900
+ useEffect2(function() {
827
901
  try {
828
902
  callback();
829
903
  } catch (error) {
@@ -832,73 +906,88 @@ function useSafeEffect(callback, dependencies, error_message) {
832
906
  }, dependencies);
833
907
  }
834
908
  var useDeepCompareMemo = function(factory, dependencies) {
835
- var previousDepsRef = useRef([]);
909
+ var previousDepsRef = useRef2([]);
836
910
  if (!isEqual2(dependencies, previousDepsRef.current)) {
837
911
  previousDepsRef.current = dependencies;
838
912
  }
839
- return useMemo(factory, previousDepsRef.current);
913
+ return useMemo2(factory, previousDepsRef.current);
840
914
  };
841
915
  function useDeepCompareEffect(effect, dependencies) {
842
- var previousDepsRef = useRef();
916
+ var previousDepsRef = useRef2();
843
917
  if (!isEqual2(previousDepsRef.current, dependencies)) {
844
918
  previousDepsRef.current = dependencies;
845
919
  }
846
- useEffect(effect, [
920
+ useEffect2(effect, [
847
921
  previousDepsRef.current
848
922
  ]);
849
923
  }
850
- // src/hooks/socket.ts
851
- import { useEffect as useEffect2, useState } from "react";
852
- var useSocketSubscription = function(configs, label, settings) {
853
- var _useState = _sliced_to_array(useState(socketServiceInstance.isConnected()), 2), socketConnected = _useState[0], setSocketConnected = _useState[1];
854
- var _useState1 = _sliced_to_array(useState([]), 2), cleanupSubscriptions = _useState1[0], setCleanupSubscriptions = _useState1[1];
924
+ // src/hooks/WebWorker.ts
925
+ import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3 } from "react";
926
+ // src/hooks/snapshots.ts
927
+ import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState2 } from "react";
928
+ var useSocketSnapshots = function(configs, label, settings) {
929
+ var _auth_currentUser;
930
+ var _useState2 = _sliced_to_array(useState2(socketServiceInstance.isConnected()), 2), socketConnected = _useState2[0], setSocketConnected = _useState2[1];
931
+ var _useState21 = _sliced_to_array(useState2([]), 2), cleanupSubscriptions = _useState21[0], setCleanupSubscriptions = _useState21[1];
932
+ var socketStarted = useRef4(false);
855
933
  useDeepCompareEffect(function() {
856
- if (socketConnected) {
934
+ if (!auth.currentUser) {
935
+ return;
936
+ }
937
+ var subscribe = function() {
938
+ if (configs.length === 0) {
939
+ return;
940
+ }
941
+ var disposer = socketServiceInstance.subscribeToCollections(configs);
857
942
  setCleanupSubscriptions(function(prev) {
858
943
  return _to_consumable_array(prev).concat([
859
- socketServiceInstance.subscribeToCollections(configs)
944
+ disposer
860
945
  ]);
861
946
  });
862
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
947
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
863
948
  console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
864
949
  return c.collectionName;
865
950
  }).join(", ")));
866
951
  }
867
- } else {
868
- socketServiceInstance.getSocketInstance();
869
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
870
- console.log("==> ".concat(label || "Cache snapshots", " started... "));
871
- }
952
+ };
953
+ if (socketServiceInstance.isConnected()) {
954
+ setSocketConnected(true);
955
+ subscribe();
956
+ } else if (!socketStarted.current) {
957
+ socketStarted.current = true;
958
+ auth.currentUser.getIdToken().then(function(token) {
959
+ socketServiceInstance.startSession(token);
960
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
961
+ console.log("==> ".concat(label || "Cache snapshots", " started... "));
962
+ }
963
+ });
872
964
  }
873
- var uiOnConnect = function() {
965
+ var offConnect = socketServiceInstance.onConnect(function() {
874
966
  setSocketConnected(true);
875
- };
876
- var uiOnDisconnect = function() {
967
+ socketStarted.current = false;
968
+ subscribe();
969
+ });
970
+ var offDisconnect = socketServiceInstance.onDisconnect(function() {
971
+ setSocketConnected(false);
877
972
  cleanupSubscriptions.forEach(function(cleanup) {
878
973
  return cleanup();
879
974
  });
880
- setSocketConnected(false);
881
- };
882
- socketServiceInstance.onConnect(uiOnConnect);
883
- socketServiceInstance.onDisconnect(uiOnDisconnect);
884
- setSocketConnected(socketServiceInstance.isConnected());
975
+ });
885
976
  return function() {
977
+ cleanupSubscriptions.forEach(function(cleanup) {
978
+ return cleanup();
979
+ });
980
+ offConnect === null || offConnect === void 0 ? void 0 : offConnect();
981
+ offDisconnect === null || offDisconnect === void 0 ? void 0 : offDisconnect();
886
982
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
887
- console.log("==> ".concat(label || "Cache snapshots", " stopped. "));
888
- }
889
- if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
890
- cleanupSubscriptions.forEach(function(cleanup) {
891
- return cleanup();
892
- });
893
- socketServiceInstance.offConnect(uiOnConnect);
894
- socketServiceInstance.offDisconnect(uiOnDisconnect);
983
+ console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
895
984
  }
896
985
  };
897
986
  }, [
898
- socketConnected,
899
- configs
987
+ configs,
988
+ (_auth_currentUser = auth.currentUser) === null || _auth_currentUser === void 0 ? void 0 : _auth_currentUser.uid
900
989
  ]);
901
- useEffect2(function() {
990
+ useEffect4(function() {
902
991
  return function() {
903
992
  cleanupSubscriptions.forEach(function(cleanup) {
904
993
  return cleanup();
@@ -909,18 +998,9 @@ var useSocketSubscription = function(configs, label, settings) {
909
998
  socketConnected: socketConnected
910
999
  };
911
1000
  };
912
- // src/hooks/global.ts
913
- var useDocumentTitle = function(title) {
914
- useEffect3(function() {
915
- document.title = title;
916
- }, [
917
- title
918
- ]);
919
- return null;
920
- };
921
- var useSnapshotBulk = function(configs, label, settings) {
922
- var snapshotsFirstTime = useRef2([]);
923
- var unsubscribeFunctions = useRef2([]);
1001
+ var useDbSnapshots = function(configs, label, settings) {
1002
+ var snapshotsFirstTime = useRef4([]);
1003
+ var unsubscribeFunctions = useRef4([]);
924
1004
  useDeepCompareEffect(function() {
925
1005
  var start = performance.now();
926
1006
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
@@ -956,7 +1036,7 @@ var useSnapshotBulk = function(configs, label, settings) {
956
1036
  label,
957
1037
  settings
958
1038
  ]);
959
- useEffect3(function() {
1039
+ useEffect4(function() {
960
1040
  return function() {
961
1041
  unsubscribeFunctions.current.forEach(function(unsubscribe) {
962
1042
  if (unsubscribe) {
@@ -969,9 +1049,9 @@ var useSnapshotBulk = function(configs, label, settings) {
969
1049
  };
970
1050
  }, []);
971
1051
  };
972
- var useSmartSnapshot = function(configs, label, settings) {
1052
+ var useSmartSnapshots = function(configs, label, settings) {
973
1053
  var _useState2 = _sliced_to_array(useState2(null), 2), cacheCollectionsConfig = _useState2[0], setCacheCollectionsConfig = _useState2[1];
974
- useEffect3(function() {
1054
+ useEffect4(function() {
975
1055
  get_document_by_id("nx-settings", "cache_collections_config").then(function(res) {
976
1056
  return setCacheCollectionsConfig(res);
977
1057
  });
@@ -979,73 +1059,38 @@ var useSmartSnapshot = function(configs, label, settings) {
979
1059
  return setCacheCollectionsConfig(null);
980
1060
  };
981
1061
  }, []);
982
- var groupedConfig = useMemo2(function() {
1062
+ var _useMemo3 = useMemo3(function() {
983
1063
  if (!cacheCollectionsConfig) {
984
1064
  return {
985
- configForDb: [],
986
- configForCache: []
1065
+ dbConfig: [],
1066
+ cacheConfig: []
987
1067
  };
988
1068
  }
989
- var configForDb = [];
990
- var configForCache = [];
1069
+ var dbConfig2 = [];
1070
+ var cacheConfig2 = [];
991
1071
  configs.forEach(function(cfg) {
992
1072
  var collectionName = cfg.collectionName, _cfg_subscribeTo = cfg.subscribeTo, subscribeTo = _cfg_subscribeTo === void 0 ? "cache" : _cfg_subscribeTo;
993
- if (subscribeTo === "cache" && cacheCollectionsConfig[collectionName]) {
994
- configForCache.push(cfg);
1073
+ if (subscribeTo === "cache" && cacheCollectionsConfig[collectionName].sync_direction !== "redis_to_firebase") {
1074
+ cacheConfig2.push(cfg);
995
1075
  } else {
996
- configForDb.push(cfg);
1076
+ dbConfig2.push(cfg);
997
1077
  }
998
1078
  });
999
1079
  return {
1000
- configForDb: configForDb,
1001
- configForCache: configForCache
1080
+ dbConfig: dbConfig2,
1081
+ cacheConfig: cacheConfig2
1002
1082
  };
1003
1083
  }, [
1004
1084
  configs,
1005
1085
  cacheCollectionsConfig
1006
- ]);
1007
- useSnapshotBulk(groupedConfig.configForDb, label, settings);
1008
- var socketConnected = useSocketSubscription(groupedConfig.configForCache, label, settings).socketConnected;
1086
+ ]), dbConfig = _useMemo3.dbConfig, cacheConfig = _useMemo3.cacheConfig;
1087
+ useDbSnapshots(dbConfig, label, settings);
1088
+ var socketConnected = useSocketSnapshots(cacheConfig, label, settings).socketConnected;
1009
1089
  return {
1010
- groupedConfig: groupedConfig,
1090
+ dbConfig: dbConfig,
1091
+ cacheConfig: cacheConfig,
1011
1092
  socketConnected: socketConnected
1012
1093
  };
1013
1094
  };
1014
- var useSetUserCountry = function(setUserCountry, changLang) {
1015
- useLayoutEffect(function() {
1016
- var currentCountry = localStorage.getItem("userCountry");
1017
- if (!currentCountry) {
1018
- var updateCountry = /*#__PURE__*/ function() {
1019
- var _ref = _async_to_generator(function() {
1020
- var country;
1021
- return _ts_generator(this, function(_state) {
1022
- switch(_state.label){
1023
- case 0:
1024
- return [
1025
- 4,
1026
- getUserCountryByIp()
1027
- ];
1028
- case 1:
1029
- country = _state.sent();
1030
- changLang(country === CountryOptions2.IL ? "he" : "en");
1031
- setUserCountry(country);
1032
- localStorage.setItem("userCountry", country);
1033
- return [
1034
- 2
1035
- ];
1036
- }
1037
- });
1038
- });
1039
- return function updateCountry() {
1040
- return _ref.apply(this, arguments);
1041
- };
1042
- }();
1043
- updateCountry();
1044
- }
1045
- }, []);
1046
- return null;
1047
- };
1048
- // src/hooks/WebWorker.ts
1049
- import { useCallback as useCallback2, useEffect as useEffect4, useRef as useRef3 } from "react";
1050
- export { useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshot, useSnapshotBulk, useSocketSubscription };
1095
+ export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots };
1051
1096
  //# sourceMappingURL=index.mjs.map