dexie 3.2.4-beta.1 → 3.2.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 3.2.4-beta.1, Tue May 30 2023
7
+ * Version 3.2.5, Thu Feb 08 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 3.2.4-beta.1, Tue May 30 2023
7
+ * Version 3.2.5, Thu Feb 08 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -136,7 +136,7 @@
136
136
  }
137
137
  }
138
138
  function getByKeyPath(obj, keyPath) {
139
- if (hasOwn(obj, keyPath))
139
+ if (typeof keyPath === 'string' && hasOwn(obj, keyPath))
140
140
  return obj[keyPath];
141
141
  if (!keyPath)
142
142
  return obj;
@@ -219,7 +219,7 @@
219
219
  function flatten(a) {
220
220
  return concat.apply([], a);
221
221
  }
222
- var intrinsicTypeNames = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
222
+ var intrinsicTypeNames = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
223
223
  .split(',').concat(flatten([8, 16, 32, 64].map(function (num) { return ["Int", "Uint", "Float"].map(function (t) { return t + num + "Array"; }); }))).filter(function (t) { return _global[t]; });
224
224
  var intrinsicTypes = intrinsicTypeNames.map(function (t) { return _global[t]; });
225
225
  arrayToObject(intrinsicTypeNames, function (x) { return [x, true]; });
@@ -1287,7 +1287,7 @@
1287
1287
  }
1288
1288
  }
1289
1289
 
1290
- var DEXIE_VERSION = '3.2.4-beta.1';
1290
+ var DEXIE_VERSION = '3.2.5';
1291
1291
  var maxString = String.fromCharCode(65535);
1292
1292
  var minKey = -Infinity;
1293
1293
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -1373,14 +1373,22 @@
1373
1373
  .where(keyPaths[0])
1374
1374
  .equals(indexOrCrit[keyPaths[0]]);
1375
1375
  var compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(function (ix) {
1376
- return ix.compound &&
1377
- keyPaths.every(function (keyPath) { return ix.keyPath.indexOf(keyPath) >= 0; }) &&
1378
- ix.keyPath.every(function (keyPath) { return keyPaths.indexOf(keyPath) >= 0; });
1379
- })[0];
1380
- if (compoundIndex && this.db._maxKey !== maxString)
1376
+ if (ix.compound &&
1377
+ keyPaths.every(function (keyPath) { return ix.keyPath.indexOf(keyPath) >= 0; })) {
1378
+ for (var i = 0; i < keyPaths.length; ++i) {
1379
+ if (keyPaths.indexOf(ix.keyPath[i]) === -1)
1380
+ return false;
1381
+ }
1382
+ return true;
1383
+ }
1384
+ return false;
1385
+ }).sort(function (a, b) { return a.keyPath.length - b.keyPath.length; })[0];
1386
+ if (compoundIndex && this.db._maxKey !== maxString) {
1387
+ var keyPathsInValidOrder = compoundIndex.keyPath.slice(0, keyPaths.length);
1381
1388
  return this
1382
- .where(compoundIndex.name)
1383
- .equals(compoundIndex.keyPath.map(function (kp) { return indexOrCrit[kp]; }));
1389
+ .where(keyPathsInValidOrder)
1390
+ .equals(keyPathsInValidOrder.map(function (kp) { return indexOrCrit[kp]; }));
1391
+ }
1384
1392
  if (!compoundIndex && debug)
1385
1393
  console.warn("The query " + JSON.stringify(indexOrCrit) + " on " + this.name + " would benefit of a " +
1386
1394
  ("compound index [" + keyPaths.join('+') + "]"));
@@ -3733,69 +3741,82 @@
3733
3741
  }
3734
3742
  var resolveDbReady = state.dbReadyResolve,
3735
3743
  upgradeTransaction = null, wasCreated = false;
3736
- return DexiePromise.race([openCanceller, (typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(function () { return new DexiePromise(function (resolve, reject) {
3737
- throwIfCancelled();
3738
- if (!indexedDB)
3739
- throw new exceptions.MissingAPI();
3740
- var dbName = db.name;
3741
- var req = state.autoSchema ?
3742
- indexedDB.open(dbName) :
3743
- indexedDB.open(dbName, Math.round(db.verno * 10));
3744
- if (!req)
3745
- throw new exceptions.MissingAPI();
3746
- req.onerror = eventRejectHandler(reject);
3747
- req.onblocked = wrap(db._fireOnBlocked);
3748
- req.onupgradeneeded = wrap(function (e) {
3749
- upgradeTransaction = req.transaction;
3750
- if (state.autoSchema && !db._options.allowEmptyDB) {
3751
- req.onerror = preventDefault;
3752
- upgradeTransaction.abort();
3753
- req.result.close();
3754
- var delreq = indexedDB.deleteDatabase(dbName);
3755
- delreq.onsuccess = delreq.onerror = wrap(function () {
3756
- reject(new exceptions.NoSuchDatabase("Database " + dbName + " doesnt exist"));
3757
- });
3758
- }
3759
- else {
3760
- upgradeTransaction.onerror = eventRejectHandler(reject);
3761
- var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion;
3762
- wasCreated = oldVer < 1;
3763
- db._novip.idbdb = req.result;
3764
- runUpgraders(db, oldVer / 10, upgradeTransaction, reject);
3765
- }
3766
- }, reject);
3767
- req.onsuccess = wrap(function () {
3768
- upgradeTransaction = null;
3769
- var idbdb = db._novip.idbdb = req.result;
3770
- var objectStoreNames = slice(idbdb.objectStoreNames);
3771
- if (objectStoreNames.length > 0)
3772
- try {
3773
- var tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), 'readonly');
3774
- if (state.autoSchema)
3775
- readGlobalSchema(db, idbdb, tmpTrans);
3776
- else {
3777
- adjustToExistingIndexNames(db, db._dbSchema, tmpTrans);
3778
- if (!verifyInstalledSchema(db, tmpTrans)) {
3779
- console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.");
3780
- }
3744
+ var tryOpenDB = function () { return new DexiePromise(function (resolve, reject) {
3745
+ throwIfCancelled();
3746
+ if (!indexedDB)
3747
+ throw new exceptions.MissingAPI();
3748
+ var dbName = db.name;
3749
+ var req = state.autoSchema ?
3750
+ indexedDB.open(dbName) :
3751
+ indexedDB.open(dbName, Math.round(db.verno * 10));
3752
+ if (!req)
3753
+ throw new exceptions.MissingAPI();
3754
+ req.onerror = eventRejectHandler(reject);
3755
+ req.onblocked = wrap(db._fireOnBlocked);
3756
+ req.onupgradeneeded = wrap(function (e) {
3757
+ upgradeTransaction = req.transaction;
3758
+ if (state.autoSchema && !db._options.allowEmptyDB) {
3759
+ req.onerror = preventDefault;
3760
+ upgradeTransaction.abort();
3761
+ req.result.close();
3762
+ var delreq = indexedDB.deleteDatabase(dbName);
3763
+ delreq.onsuccess = delreq.onerror = wrap(function () {
3764
+ reject(new exceptions.NoSuchDatabase("Database " + dbName + " doesnt exist"));
3765
+ });
3766
+ }
3767
+ else {
3768
+ upgradeTransaction.onerror = eventRejectHandler(reject);
3769
+ var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion;
3770
+ wasCreated = oldVer < 1;
3771
+ db._novip.idbdb = req.result;
3772
+ runUpgraders(db, oldVer / 10, upgradeTransaction, reject);
3773
+ }
3774
+ }, reject);
3775
+ req.onsuccess = wrap(function () {
3776
+ upgradeTransaction = null;
3777
+ var idbdb = db._novip.idbdb = req.result;
3778
+ var objectStoreNames = slice(idbdb.objectStoreNames);
3779
+ if (objectStoreNames.length > 0)
3780
+ try {
3781
+ var tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), 'readonly');
3782
+ if (state.autoSchema)
3783
+ readGlobalSchema(db, idbdb, tmpTrans);
3784
+ else {
3785
+ adjustToExistingIndexNames(db, db._dbSchema, tmpTrans);
3786
+ if (!verifyInstalledSchema(db, tmpTrans)) {
3787
+ console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.");
3781
3788
  }
3782
- generateMiddlewareStacks(db, tmpTrans);
3783
- }
3784
- catch (e) {
3785
3789
  }
3786
- connections.push(db);
3787
- idbdb.onversionchange = wrap(function (ev) {
3788
- state.vcFired = true;
3789
- db.on("versionchange").fire(ev);
3790
- });
3791
- idbdb.onclose = wrap(function (ev) {
3792
- db.on("close").fire(ev);
3793
- });
3794
- if (wasCreated)
3795
- _onDatabaseCreated(db._deps, dbName);
3796
- resolve();
3797
- }, reject);
3798
- }); })]).then(function () {
3790
+ generateMiddlewareStacks(db, tmpTrans);
3791
+ }
3792
+ catch (e) {
3793
+ }
3794
+ connections.push(db);
3795
+ idbdb.onversionchange = wrap(function (ev) {
3796
+ state.vcFired = true;
3797
+ db.on("versionchange").fire(ev);
3798
+ });
3799
+ idbdb.onclose = wrap(function (ev) {
3800
+ db.on("close").fire(ev);
3801
+ });
3802
+ if (wasCreated)
3803
+ _onDatabaseCreated(db._deps, dbName);
3804
+ resolve();
3805
+ }, reject);
3806
+ }).catch(function (err) {
3807
+ if (err && err.name === 'UnknownError' && state.PR1398_maxLoop > 0) {
3808
+ state.PR1398_maxLoop--;
3809
+ console.warn('Dexie: Workaround for Chrome UnknownError on open()');
3810
+ return tryOpenDB();
3811
+ }
3812
+ else {
3813
+ return DexiePromise.reject(err);
3814
+ }
3815
+ }); };
3816
+ return DexiePromise.race([
3817
+ openCanceller,
3818
+ (typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(tryOpenDB)
3819
+ ]).then(function () {
3799
3820
  throwIfCancelled();
3800
3821
  state.onReadyBeingFired = [];
3801
3822
  return DexiePromise.resolve(vip(function () { return db.on.ready.fire(db.vip); })).then(function fireRemainders() {