dexie 4.1.0-alpha.4 → 4.1.0-alpha.6

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.6, Tue Oct 15 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.6, Tue Oct 15 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.6';
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 () {
@@ -6553,14 +6559,6 @@
6553
6559
  this.refCount = 1;
6554
6560
  this.cleanupHandlers = [];
6555
6561
  this.destroyed = false;
6556
- var _a = (doc || {}).meta, db = _a.db, parentTable = _a.parentTable, parentId = _a.parentId, updatesTable = _a.updatesTable;
6557
- if (!db || !parentTable || !updatesTable)
6558
- throw new Error('Y.Doc not generated by Dexie');
6559
- if (!db.table(parentTable) || !db.table(updatesTable)) {
6560
- throw new Error("Table ".concat(parentTable, " or ").concat(updatesTable, " not found in db"));
6561
- }
6562
- throwIfDestroyed(doc);
6563
- var Y = getYLibrary(db);
6564
6562
  this.on = createEvents();
6565
6563
  this.doc = doc;
6566
6564
  this.off = function (name, f) { var _a; return (_a = _this.on[name]) === null || _a === void 0 ? void 0 : _a.unsubscribe(f); };
@@ -6573,13 +6571,22 @@
6573
6571
  _this.on('error', reject);
6574
6572
  });
6575
6573
  if ('dispose' in Symbol) {
6576
- this[Symbol.dispose] = this.dispose;
6574
+ this[Symbol.dispose] =
6575
+ function () { return DexieYProvider.release(doc); };
6577
6576
  }
6578
- this.stopObserving = observeYDocUpdates(this, doc, db, parentTable, updatesTable, parentId, Y);
6579
6577
  doc.on('load', function () { return _this.on('load').fire(); });
6580
6578
  doc.on('sync', function (sync) { return sync !== false && _this.on('sync').fire(); });
6581
6579
  doc.on('destroy', this.destroy.bind(this));
6582
- db.on.y.fire(this, Y);
6580
+ var _a = doc.meta || {}, db = _a.db, parentTable = _a.parentTable, parentId = _a.parentId, updatesTable = _a.updatesTable;
6581
+ if (db && parentTable && updatesTable) {
6582
+ if (!db.table(parentTable) || !db.table(updatesTable)) {
6583
+ throw new Error("Table ".concat(parentTable, " or ").concat(updatesTable, " not found in db"));
6584
+ }
6585
+ throwIfDestroyed(doc);
6586
+ var Y = getYLibrary(db);
6587
+ this.stopObserving = observeYDocUpdates(this, doc, db, parentTable, updatesTable, parentId, Y);
6588
+ db.on.y.fire(this, Y);
6589
+ }
6583
6590
  }
6584
6591
  DexieYProvider.load = function (doc) {
6585
6592
  var p = wm.get(doc);