akeyless-client-commons 1.1.36 → 1.1.38

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.
@@ -7,9 +7,6 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
- function _array_without_holes(arr) {
11
- if (Array.isArray(arr)) return _array_like_to_array(arr);
12
- }
13
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
11
  try {
15
12
  var info = gen[key](arg);
@@ -78,9 +75,6 @@ function _instanceof(left, right) {
78
75
  return left instanceof right;
79
76
  }
80
77
  }
81
- function _iterable_to_array(iter) {
82
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
83
- }
84
78
  function _iterable_to_array_limit(arr, i) {
85
79
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
86
80
  if (_i == null) return;
@@ -108,9 +102,6 @@ function _iterable_to_array_limit(arr, i) {
108
102
  function _non_iterable_rest() {
109
103
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
110
104
  }
111
- function _non_iterable_spread() {
112
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
113
- }
114
105
  function _object_spread(target) {
115
106
  for(var i = 1; i < arguments.length; i++){
116
107
  var source = arguments[i] != null ? arguments[i] : {};
@@ -153,9 +144,6 @@ function _object_spread_props(target, source) {
153
144
  function _sliced_to_array(arr, i) {
154
145
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
155
146
  }
156
- function _to_consumable_array(arr) {
157
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
158
- }
159
147
  function _unsupported_iterable_to_array(o, minLen) {
160
148
  if (!o) return;
161
149
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -954,6 +942,37 @@ var useWebWorker = function(fn, options) {
954
942
  if (!isSupportedRef.current) {
955
943
  return function() {};
956
944
  }
945
+ if (options === null || options === void 0 ? void 0 : options.warmStart) {
946
+ try {
947
+ ensureWorker();
948
+ } catch (error) {
949
+ console.error("Error creating worker", error);
950
+ }
951
+ }
952
+ return function() {
953
+ if (workerRef.current) {
954
+ workerRef.current.terminate();
955
+ workerRef.current = null;
956
+ }
957
+ if (workerUrlRef.current) {
958
+ URL.revokeObjectURL(workerUrlRef.current);
959
+ workerUrlRef.current = null;
960
+ }
961
+ pendingJobsRef.current.forEach(function(job) {
962
+ job.reject(new Error("Worker terminated"));
963
+ });
964
+ pendingJobsRef.current.clear();
965
+ isReadyRef.current = false;
966
+ };
967
+ }, [
968
+ fn,
969
+ options === null || options === void 0 ? void 0 : options.debug,
970
+ options === null || options === void 0 ? void 0 : options.name,
971
+ options === null || options === void 0 ? void 0 : options.onError
972
+ ]);
973
+ var ensureWorker = useCallback2(function() {
974
+ if (!isSupportedRef.current) return;
975
+ if (workerRef.current) return;
957
976
  var functionString = fn.toString();
958
977
  var workerSource = [
959
978
  "const userFn = (".concat(functionString, ");"),
@@ -1007,30 +1026,23 @@ var useWebWorker = function(fn, options) {
1007
1026
  job.reject(err);
1008
1027
  });
1009
1028
  pendingJobsRef.current.clear();
1010
- };
1011
- if (workerRef.current) {
1012
- workerRef.current.terminate();
1013
- }
1014
- if (workerUrlRef.current) {
1015
- URL.revokeObjectURL(workerUrlRef.current);
1016
- }
1017
- workerRef.current = worker;
1018
- workerUrlRef.current = url;
1019
- return function() {
1020
- if (workerRef.current) {
1021
- workerRef.current.terminate();
1029
+ if (options === null || options === void 0 ? void 0 : options.recreateOnError) {
1030
+ try {
1031
+ var _workerRef_current;
1032
+ (_workerRef_current = workerRef.current) === null || _workerRef_current === void 0 ? void 0 : _workerRef_current.terminate();
1033
+ } catch (_) {}
1022
1034
  workerRef.current = null;
1035
+ if (workerUrlRef.current) {
1036
+ try {
1037
+ URL.revokeObjectURL(workerUrlRef.current);
1038
+ } catch (_) {}
1039
+ workerUrlRef.current = null;
1040
+ }
1041
+ isReadyRef.current = false;
1023
1042
  }
1024
- if (workerUrlRef.current) {
1025
- URL.revokeObjectURL(workerUrlRef.current);
1026
- workerUrlRef.current = null;
1027
- }
1028
- pendingJobsRef.current.forEach(function(job) {
1029
- job.reject(new Error("Worker terminated"));
1030
- });
1031
- pendingJobsRef.current.clear();
1032
- isReadyRef.current = false;
1033
1043
  };
1044
+ workerRef.current = worker;
1045
+ workerUrlRef.current = url;
1034
1046
  }, [
1035
1047
  fn,
1036
1048
  options === null || options === void 0 ? void 0 : options.debug,
@@ -1039,6 +1051,7 @@ var useWebWorker = function(fn, options) {
1039
1051
  ]);
1040
1052
  var runWorkerBase = useCallback2(function(data, transfer) {
1041
1053
  if (!workerRef.current) {
1054
+ ensureWorker();
1042
1055
  if (options === null || options === void 0 ? void 0 : options.debug) {
1043
1056
  console.warn("[WebWorker".concat((options === null || options === void 0 ? void 0 : options.name) ? ":" + options.name : "", "] fallback to main thread"));
1044
1057
  }
@@ -1097,11 +1110,24 @@ var useWebWorker = function(fn, options) {
1097
1110
  reject: reject
1098
1111
  });
1099
1112
  try {
1100
- if (transfer && transfer.length) {
1113
+ var shouldTransfer = Array.isArray(transfer) ? transfer : [];
1114
+ if (!shouldTransfer.length) {
1115
+ var maybeArrayBuffer = _instanceof(data === null || data === void 0 ? void 0 : data.buffer, ArrayBuffer) ? data.buffer : void 0;
1116
+ if (maybeArrayBuffer) {
1117
+ workerRef.current.postMessage({
1118
+ id: id,
1119
+ payload: data
1120
+ }, [
1121
+ maybeArrayBuffer
1122
+ ]);
1123
+ return;
1124
+ }
1125
+ }
1126
+ if (shouldTransfer.length) {
1101
1127
  workerRef.current.postMessage({
1102
1128
  id: id,
1103
1129
  payload: data
1104
- }, transfer);
1130
+ }, shouldTransfer);
1105
1131
  } else {
1106
1132
  workerRef.current.postMessage({
1107
1133
  id: id,
@@ -1121,7 +1147,8 @@ var useWebWorker = function(fn, options) {
1121
1147
  fn,
1122
1148
  options === null || options === void 0 ? void 0 : options.debug,
1123
1149
  options === null || options === void 0 ? void 0 : options.name,
1124
- options === null || options === void 0 ? void 0 : options.onError
1150
+ options === null || options === void 0 ? void 0 : options.onError,
1151
+ ensureWorker
1125
1152
  ]);
1126
1153
  var runWorker = runWorkerBase;
1127
1154
  runWorker.isSupported = function() {
@@ -1136,18 +1163,89 @@ var useWebWorker = function(fn, options) {
1136
1163
  runWorker.lastError = function() {
1137
1164
  return lastErrorRef.current;
1138
1165
  };
1166
+ runWorker.terminate = function() {
1167
+ if (workerRef.current) {
1168
+ try {
1169
+ workerRef.current.terminate();
1170
+ } catch (error) {
1171
+ console.error("Error terminating worker", error);
1172
+ }
1173
+ workerRef.current = null;
1174
+ }
1175
+ if (workerUrlRef.current) {
1176
+ try {
1177
+ URL.revokeObjectURL(workerUrlRef.current);
1178
+ } catch (error) {
1179
+ console.error("Error revoking worker URL", error);
1180
+ }
1181
+ workerUrlRef.current = null;
1182
+ }
1183
+ pendingJobsRef.current.forEach(function(job) {
1184
+ return job.reject(new Error("Worker terminated"));
1185
+ });
1186
+ pendingJobsRef.current.clear();
1187
+ isReadyRef.current = false;
1188
+ };
1139
1189
  return runWorker;
1140
1190
  };
1141
- var WebWorker_default = useWebWorker;
1142
1191
  // src/hooks/snapshots.ts
1143
- import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState2 } from "react";
1192
+ import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4, useState as useState2 } from "react";
1144
1193
  // src/hooks/snapshotWorker.ts
1145
- var wrapConfigsWithWorker = function(cfgs, runProcessor) {
1194
+ var wrapConfigsWithWorker = function(cfgs, runProcessor, options) {
1195
+ var recentEvents = /* @__PURE__ */ new Map();
1196
+ var _options_eventTtlMs;
1197
+ var EVENT_TTL_MS = (_options_eventTtlMs = options === null || options === void 0 ? void 0 : options.eventTtlMs) !== null && _options_eventTtlMs !== void 0 ? _options_eventTtlMs : 1500;
1198
+ var _options_maxRecentEvents;
1199
+ var MAX_RECENT = (_options_maxRecentEvents = options === null || options === void 0 ? void 0 : options.maxRecentEvents) !== null && _options_maxRecentEvents !== void 0 ? _options_maxRecentEvents : 500;
1200
+ var now = function() {
1201
+ return Date.now();
1202
+ };
1203
+ var makeKey = function(op, docs, collectionName) {
1204
+ try {
1205
+ var ids = (docs || []).map(function(d) {
1206
+ return d === null || d === void 0 ? void 0 : d.id;
1207
+ }).filter(Boolean).sort().join(",");
1208
+ return "".concat(collectionName || "unknown", ":").concat(op, ":").concat(ids);
1209
+ } catch (e) {
1210
+ return "".concat(collectionName || "unknown", ":").concat(op, ":*");
1211
+ }
1212
+ };
1213
+ var shouldProcess = function(key) {
1214
+ var ts = recentEvents.get(key);
1215
+ if (ts && now() - ts < EVENT_TTL_MS) {
1216
+ return false;
1217
+ }
1218
+ if (recentEvents.size > MAX_RECENT) {
1219
+ var cutoff = now() - EVENT_TTL_MS;
1220
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1221
+ try {
1222
+ for(var _iterator = Array.from(recentEvents.entries())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1223
+ var _step_value = _sliced_to_array(_step.value, 2), k = _step_value[0], v = _step_value[1];
1224
+ if (v < cutoff) recentEvents.delete(k);
1225
+ }
1226
+ } catch (err) {
1227
+ _didIteratorError = true;
1228
+ _iteratorError = err;
1229
+ } finally{
1230
+ try {
1231
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1232
+ _iterator.return();
1233
+ }
1234
+ } finally{
1235
+ if (_didIteratorError) {
1236
+ throw _iteratorError;
1237
+ }
1238
+ }
1239
+ }
1240
+ }
1241
+ recentEvents.set(key, now());
1242
+ return true;
1243
+ };
1146
1244
  var wrapCb = function(cb, op, run) {
1147
1245
  if (!cb) return void 0;
1148
1246
  return /*#__PURE__*/ function() {
1149
1247
  var _ref = _async_to_generator(function(docs, config) {
1150
- var safeDocs, _ref, processed, e;
1248
+ var key, safeDocs, _ref, processed, e;
1151
1249
  return _ts_generator(this, function(_state) {
1152
1250
  switch(_state.label){
1153
1251
  case 0:
@@ -1157,7 +1255,13 @@ var wrapConfigsWithWorker = function(cfgs, runProcessor) {
1157
1255
  ,
1158
1256
  3
1159
1257
  ]);
1160
- safeDocs = JSON.parse(JSON.stringify(docs));
1258
+ key = makeKey(op, docs, config === null || config === void 0 ? void 0 : config.collectionName);
1259
+ if (!shouldProcess(key)) {
1260
+ return [
1261
+ 2
1262
+ ];
1263
+ }
1264
+ safeDocs = (options === null || options === void 0 ? void 0 : options.jsonClone) === false ? docs : JSON.parse(JSON.stringify(docs));
1161
1265
  return [
1162
1266
  4,
1163
1267
  run({
@@ -1214,11 +1318,13 @@ var wrapConfigsWithWorker = function(cfgs, runProcessor) {
1214
1318
  var useDbSnapshots = function(configs, label, settings) {
1215
1319
  var snapshotsFirstTime = useRef4([]);
1216
1320
  var unsubscribeFunctions = useRef4([]);
1217
- var runProcessor = WebWorker_default(function(payload) {
1321
+ var lastDbCollectionsRef = useRef4([]);
1322
+ var workerProcessorDb = useCallback3(function(payload) {
1218
1323
  return {
1219
1324
  docs: payload.docs
1220
1325
  };
1221
- }, settings === null || settings === void 0 ? void 0 : settings.worker);
1326
+ }, []);
1327
+ var runProcessor = useWebWorker(workerProcessorDb, settings === null || settings === void 0 ? void 0 : settings.worker);
1222
1328
  var wrapConfigsForWorker = function(cfgs) {
1223
1329
  return wrapConfigsWithWorker(cfgs, function(payload) {
1224
1330
  return runProcessor(payload);
@@ -1230,6 +1336,9 @@ var useDbSnapshots = function(configs, label, settings) {
1230
1336
  console.log("==> ".concat(label || "DB snapshots", " started from db... "));
1231
1337
  }
1232
1338
  var wrappedConfigs = wrapConfigsForWorker(configs);
1339
+ lastDbCollectionsRef.current = configs.map(function(c) {
1340
+ return c.collectionName;
1341
+ });
1233
1342
  var snapshotResults = wrappedConfigs.map(function(config) {
1234
1343
  return snapshot(config, snapshotsFirstTime.current, settings);
1235
1344
  });
@@ -1245,11 +1354,15 @@ var useDbSnapshots = function(configs, label, settings) {
1245
1354
  });
1246
1355
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
1247
1356
  return function() {
1357
+ var _settings_worker;
1248
1358
  unsubscribeFunctions.current.forEach(function(unsubscribe) {
1249
1359
  if (unsubscribe) {
1250
1360
  unsubscribe();
1251
1361
  }
1252
1362
  });
1363
+ if ((settings === null || settings === void 0 ? void 0 : (_settings_worker = settings.worker) === null || _settings_worker === void 0 ? void 0 : _settings_worker.debug) && lastDbCollectionsRef.current.length) {
1364
+ console.log("==> ".concat(label || "DB snapshots", " cleanup: cleaned previous subscriptions for [").concat(lastDbCollectionsRef.current.join(", "), "]"));
1365
+ }
1253
1366
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1254
1367
  console.log("==> ".concat(label || "DB snapshots", " unsubscribed from db"));
1255
1368
  }
@@ -1262,11 +1375,15 @@ var useDbSnapshots = function(configs, label, settings) {
1262
1375
  ]);
1263
1376
  useEffect4(function() {
1264
1377
  return function() {
1378
+ var _settings_worker;
1265
1379
  unsubscribeFunctions.current.forEach(function(unsubscribe) {
1266
1380
  if (unsubscribe) {
1267
1381
  unsubscribe();
1268
1382
  }
1269
1383
  });
1384
+ if ((settings === null || settings === void 0 ? void 0 : (_settings_worker = settings.worker) === null || _settings_worker === void 0 ? void 0 : _settings_worker.debug) && lastDbCollectionsRef.current.length) {
1385
+ console.log("==> ".concat(label || "DB snapshots", " cleanup: cleaned previous subscriptions for [").concat(lastDbCollectionsRef.current.join(", "), "]"));
1386
+ }
1270
1387
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1271
1388
  console.log("==> ".concat(label || "DB snapshots", " unsubscribed"));
1272
1389
  }
@@ -1300,6 +1417,10 @@ var useSmartSnapshots = function(configs, label, settings) {
1300
1417
  configForDb.push(cfg);
1301
1418
  }
1302
1419
  });
1420
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1421
+ console.log("configForDb", configForDb);
1422
+ console.log("configForCache", configForCache);
1423
+ }
1303
1424
  return {
1304
1425
  configForDb: configForDb,
1305
1426
  configForCache: configForCache
@@ -1318,36 +1439,70 @@ var useSmartSnapshots = function(configs, label, settings) {
1318
1439
  var useSocketSnapshots = function(configs, label, settings) {
1319
1440
  var _auth_currentUser;
1320
1441
  var _useState2 = _sliced_to_array(useState2(socketServiceInstance.isConnected()), 2), socketConnected = _useState2[0], setSocketConnected = _useState2[1];
1321
- var _useState21 = _sliced_to_array(useState2([]), 2), cleanupSubscriptions = _useState21[0], setCleanupSubscriptions = _useState21[1];
1442
+ var cleanupSubscriptionsRef = useRef4([]);
1322
1443
  var socketStarted = useRef4(false);
1323
- var runProcessor = WebWorker_default(function(payload) {
1444
+ var activeSubscriptionKeyRef = useRef4(null);
1445
+ var activeCollectionsRef = useRef4(/* @__PURE__ */ new Set());
1446
+ var offConnectRef = useRef4(null);
1447
+ var offDisconnectRef = useRef4(null);
1448
+ var workerProcessorSocket = useCallback3(function(payload) {
1324
1449
  return {
1325
1450
  docs: payload.docs
1326
1451
  };
1327
- }, settings === null || settings === void 0 ? void 0 : settings.worker);
1452
+ }, []);
1453
+ var runProcessor = useWebWorker(workerProcessorSocket, settings === null || settings === void 0 ? void 0 : settings.worker);
1328
1454
  var wrapConfigsForWorker = function(cfgs) {
1329
1455
  return wrapConfigsWithWorker(cfgs, function(payload) {
1330
1456
  return runProcessor(payload);
1331
1457
  });
1332
1458
  };
1333
1459
  useDeepCompareEffect(function() {
1460
+ var _offConnectRef_current, _offDisconnectRef_current;
1334
1461
  if (!auth.currentUser) {
1335
1462
  return;
1336
1463
  }
1337
1464
  var subscribe = function() {
1338
- if (configs.length === 0) {
1465
+ var desiredNames = new Set(configs.map(function(c) {
1466
+ return c.collectionName;
1467
+ }));
1468
+ var key = JSON.stringify(Array.from(desiredNames).sort());
1469
+ if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
1470
+ if (activeSubscriptionKeyRef.current === key) return;
1471
+ if (cleanupSubscriptionsRef.current.length) {
1472
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1473
+ return cleanup();
1474
+ });
1475
+ cleanupSubscriptionsRef.current = [];
1476
+ }
1477
+ if (configs.length === 0) return;
1478
+ var disposer2 = socketServiceInstance.subscribeToCollections(wrapConfigsForWorker(configs));
1479
+ cleanupSubscriptionsRef.current.push(disposer2);
1480
+ activeCollectionsRef.current = new Set(desiredNames);
1481
+ activeSubscriptionKeyRef.current = key;
1482
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1483
+ console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
1484
+ return c.collectionName;
1485
+ }).join(", ")));
1486
+ }
1487
+ return;
1488
+ }
1489
+ var toAdd = Array.from(desiredNames).filter(function(name) {
1490
+ return !activeCollectionsRef.current.has(name);
1491
+ });
1492
+ if (toAdd.length === 0) {
1339
1493
  return;
1340
1494
  }
1341
- var disposer = socketServiceInstance.subscribeToCollections(wrapConfigsForWorker(configs));
1342
- setCleanupSubscriptions(function(prev) {
1343
- return _to_consumable_array(prev).concat([
1344
- disposer
1345
- ]);
1495
+ var configsToAdd = configs.filter(function(c) {
1496
+ return toAdd.includes(c.collectionName);
1497
+ });
1498
+ var disposer = socketServiceInstance.subscribeToCollections(wrapConfigsForWorker(configsToAdd));
1499
+ cleanupSubscriptionsRef.current.push(disposer);
1500
+ toAdd.forEach(function(n) {
1501
+ return activeCollectionsRef.current.add(n);
1346
1502
  });
1503
+ activeSubscriptionKeyRef.current = JSON.stringify(Array.from(activeCollectionsRef.current).sort());
1347
1504
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1348
- console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
1349
- return c.collectionName;
1350
- }).join(", ")));
1505
+ console.log("==> ".concat(label || "Cache snapshots", " appended subscriptions for ").concat(toAdd.join(", ")));
1351
1506
  }
1352
1507
  };
1353
1508
  if (socketServiceInstance.isConnected()) {
@@ -1360,24 +1515,42 @@ var useSocketSnapshots = function(configs, label, settings) {
1360
1515
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1361
1516
  console.log("==> ".concat(label || "Cache snapshots", " started... "));
1362
1517
  }
1518
+ }).catch(function(err) {
1519
+ socketStarted.current = false;
1520
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1521
+ console.error("==> ".concat(label || "Cache snapshots", " failed to acquire token:"), err);
1522
+ }
1363
1523
  });
1364
1524
  }
1365
- var offConnect = socketServiceInstance.onConnect(function() {
1525
+ (_offConnectRef_current = offConnectRef.current) === null || _offConnectRef_current === void 0 ? void 0 : _offConnectRef_current.call(offConnectRef);
1526
+ (_offDisconnectRef_current = offDisconnectRef.current) === null || _offDisconnectRef_current === void 0 ? void 0 : _offDisconnectRef_current.call(offDisconnectRef);
1527
+ offConnectRef.current = socketServiceInstance.onConnect(function() {
1366
1528
  setSocketConnected(true);
1367
1529
  socketStarted.current = false;
1368
1530
  subscribe();
1369
1531
  });
1370
- var offDisconnect = socketServiceInstance.onDisconnect(function() {
1532
+ offDisconnectRef.current = socketServiceInstance.onDisconnect(function() {
1371
1533
  setSocketConnected(false);
1372
- cleanupSubscriptions.forEach(function(cleanup) {
1534
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1373
1535
  return cleanup();
1374
1536
  });
1537
+ cleanupSubscriptionsRef.current = [];
1538
+ activeSubscriptionKeyRef.current = null;
1539
+ activeCollectionsRef.current = /* @__PURE__ */ new Set();
1375
1540
  });
1376
1541
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
1377
1542
  return function() {
1378
- cleanupSubscriptions.forEach(function(cleanup) {
1543
+ var _offConnectRef_current, _offDisconnectRef_current;
1544
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1379
1545
  return cleanup();
1380
1546
  });
1547
+ cleanupSubscriptionsRef.current = [];
1548
+ activeSubscriptionKeyRef.current = null;
1549
+ activeCollectionsRef.current = /* @__PURE__ */ new Set();
1550
+ (_offConnectRef_current = offConnectRef.current) === null || _offConnectRef_current === void 0 ? void 0 : _offConnectRef_current.call(offConnectRef);
1551
+ offConnectRef.current = null;
1552
+ (_offDisconnectRef_current = offDisconnectRef.current) === null || _offDisconnectRef_current === void 0 ? void 0 : _offDisconnectRef_current.call(offDisconnectRef);
1553
+ offDisconnectRef.current = null;
1381
1554
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1382
1555
  console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1383
1556
  }
@@ -1389,9 +1562,17 @@ var useSocketSnapshots = function(configs, label, settings) {
1389
1562
  ]);
1390
1563
  useEffect4(function() {
1391
1564
  return function() {
1392
- cleanupSubscriptions.forEach(function(cleanup) {
1565
+ var _offConnectRef_current, _offDisconnectRef_current;
1566
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1393
1567
  return cleanup();
1394
1568
  });
1569
+ cleanupSubscriptionsRef.current = [];
1570
+ activeSubscriptionKeyRef.current = null;
1571
+ activeCollectionsRef.current = /* @__PURE__ */ new Set();
1572
+ (_offConnectRef_current = offConnectRef.current) === null || _offConnectRef_current === void 0 ? void 0 : _offConnectRef_current.call(offConnectRef);
1573
+ offConnectRef.current = null;
1574
+ (_offDisconnectRef_current = offDisconnectRef.current) === null || _offDisconnectRef_current === void 0 ? void 0 : _offDisconnectRef_current.call(offDisconnectRef);
1575
+ offDisconnectRef.current = null;
1395
1576
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1396
1577
  console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1397
1578
  }
@@ -1401,5 +1582,5 @@ var useSocketSnapshots = function(configs, label, settings) {
1401
1582
  socketConnected: socketConnected
1402
1583
  };
1403
1584
  };
1404
- export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots };
1585
+ export { useDbSnapshots, useDeepCompareEffect, useDeepCompareMemo, useDocumentTitle, useSafeEffect, useSetUserCountry, useSmartSnapshots, useSocketSnapshots, useWebWorker };
1405
1586
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",