dexie 4.1.0-alpha.5 → 4.1.0-alpha.7

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.5, Sun Oct 13 2024
7
+ * Version 4.1.0-alpha.7, 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.5, Sun Oct 13 2024
7
+ * Version 4.1.0-alpha.7, 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.5';
1180
+ var DEXIE_VERSION = '4.1.0-alpha.7';
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>.";
@@ -6559,14 +6559,6 @@
6559
6559
  this.refCount = 1;
6560
6560
  this.cleanupHandlers = [];
6561
6561
  this.destroyed = false;
6562
- var _a = (doc || {}).meta, db = _a.db, parentTable = _a.parentTable, parentId = _a.parentId, updatesTable = _a.updatesTable;
6563
- if (!db || !parentTable || !updatesTable)
6564
- throw new Error('Y.Doc not generated by Dexie');
6565
- if (!db.table(parentTable) || !db.table(updatesTable)) {
6566
- throw new Error("Table ".concat(parentTable, " or ").concat(updatesTable, " not found in db"));
6567
- }
6568
- throwIfDestroyed(doc);
6569
- var Y = getYLibrary(db);
6570
6562
  this.on = createEvents();
6571
6563
  this.doc = doc;
6572
6564
  this.off = function (name, f) { var _a; return (_a = _this.on[name]) === null || _a === void 0 ? void 0 : _a.unsubscribe(f); };
@@ -6579,13 +6571,22 @@
6579
6571
  _this.on('error', reject);
6580
6572
  });
6581
6573
  if ('dispose' in Symbol) {
6582
- this[Symbol.dispose] = this.dispose;
6574
+ this[Symbol.dispose] =
6575
+ function () { return DexieYProvider.release(doc); };
6583
6576
  }
6584
- this.stopObserving = observeYDocUpdates(this, doc, db, parentTable, updatesTable, parentId, Y);
6585
6577
  doc.on('load', function () { return _this.on('load').fire(); });
6586
6578
  doc.on('sync', function (sync) { return sync !== false && _this.on('sync').fire(); });
6587
6579
  doc.on('destroy', this.destroy.bind(this));
6588
- 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
+ }
6589
6590
  }
6590
6591
  DexieYProvider.load = function (doc) {
6591
6592
  var p = wm.get(doc);
@@ -6602,8 +6603,8 @@
6602
6603
  if (destroyedDocs.has(doc))
6603
6604
  return;
6604
6605
  var p = wm.get(doc);
6605
- if (!p) {
6606
- if (--p.refCount === 0) {
6606
+ if (p) {
6607
+ if (--p.refCount <= 0) {
6607
6608
  if (isNaN(options === null || options === void 0 ? void 0 : options.gracePeriod)) {
6608
6609
  doc.destroy();
6609
6610
  }