dexie 4.1.0-alpha.4 → 4.1.0-alpha.5

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/dexie.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.1.0-alpha.4, Sun Oct 13 2024
7
+ * Version 4.1.0-alpha.5, Sun Oct 13 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
package/dist/dexie.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.1.0-alpha.4, Sun Oct 13 2024
7
+ * Version 4.1.0-alpha.5, Sun Oct 13 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1177,7 +1177,7 @@
1177
1177
  }
1178
1178
  }
1179
1179
 
1180
- var DEXIE_VERSION = '4.1.0-alpha.4';
1180
+ var DEXIE_VERSION = '4.1.0-alpha.5';
1181
1181
  var maxString = String.fromCharCode(65535);
1182
1182
  var minKey = -Infinity;
1183
1183
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -5755,7 +5755,10 @@
5755
5755
  return p.then(function () {
5756
5756
  return db.transaction('rw', updTbl, function () {
5757
5757
  return updTbl.get(0).then(function (current) {
5758
- return updTbl.put(__assign(__assign({}, current), { lastCompressed: Math.max(lastUpdateToCompress, (current === null || current === void 0 ? void 0 : current.lastCompressed) || 0) }));
5758
+ if (current && lastUpdateToCompress <= current.lastCompressed) {
5759
+ return;
5760
+ }
5761
+ return updTbl.put(__assign(__assign({}, current), { lastCompressed: lastUpdateToCompress }));
5759
5762
  });
5760
5763
  });
5761
5764
  });
@@ -5787,7 +5790,8 @@
5787
5790
  });
5788
5791
  }
5789
5792
 
5790
- var INTERVAL = 10000;
5793
+ var GC_DELAY = 10000;
5794
+ var GC_INTERVAL = 300000;
5791
5795
  function periodicGC(db) {
5792
5796
  var timer = null;
5793
5797
  db.on('ready', function (db) {
@@ -5795,13 +5799,15 @@
5795
5799
  var gc_1 = function () {
5796
5800
  if (!db.isOpen())
5797
5801
  return;
5798
- compressYDocs(db, INTERVAL).catch(function (err) {
5802
+ compressYDocs(db, GC_INTERVAL).catch(function (err) {
5803
+ if (err && err.name === 'DatabaseClosedError')
5804
+ return;
5799
5805
  console.debug('Error during periodic GC', err);
5800
5806
  }).then(function () {
5801
- timer = setTimeout(gc_1, INTERVAL);
5807
+ timer = setTimeout(gc_1, GC_INTERVAL);
5802
5808
  });
5803
5809
  };
5804
- timer = setTimeout(gc_1, INTERVAL);
5810
+ timer = setTimeout(gc_1, GC_DELAY);
5805
5811
  }
5806
5812
  }, true);
5807
5813
  db.on('close', function () {