dexie 3.2.0-rc.3 → 3.2.1

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.mjs CHANGED
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 3.2.0-rc.3, Thu Oct 28 2021
7
+ * Version 3.2.1, Wed Feb 16 2022
8
8
  *
9
- * http://dexie.org
9
+ * https://dexie.org
10
10
  *
11
11
  * Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
12
12
  */
@@ -1260,8 +1260,14 @@ function tempTransaction(db, mode, storeNames, fn) {
1260
1260
  var trans = db._createTransaction(mode, storeNames, db._dbSchema);
1261
1261
  try {
1262
1262
  trans.create();
1263
+ db._state.PR1398_maxLoop = 3;
1263
1264
  }
1264
1265
  catch (ex) {
1266
+ if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
1267
+ console.warn('Dexie: Need to reopen db');
1268
+ db._close();
1269
+ return db.open().then(function () { return tempTransaction(db, mode, storeNames, fn); });
1270
+ }
1265
1271
  return rejection(ex);
1266
1272
  }
1267
1273
  return trans._promise(mode, function (resolve, reject) {
@@ -1275,7 +1281,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1275
1281
  }
1276
1282
  }
1277
1283
 
1278
- var DEXIE_VERSION = '3.2.0-rc.3';
1284
+ var DEXIE_VERSION = '3.2.1';
1279
1285
  var maxString = String.fromCharCode(65535);
1280
1286
  var minKey = -Infinity;
1281
1287
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -3851,7 +3857,18 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
3851
3857
  trans.idbtrans = parentTransaction.idbtrans;
3852
3858
  }
3853
3859
  else {
3854
- trans.create();
3860
+ try {
3861
+ trans.create();
3862
+ db._state.PR1398_maxLoop = 3;
3863
+ }
3864
+ catch (ex) {
3865
+ if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
3866
+ console.warn('Dexie: Need to reopen db');
3867
+ db._close();
3868
+ return db.open().then(function () { return enterTransactionScope(db, mode, storeNames, null, scopeFunc); });
3869
+ }
3870
+ return rejection(ex);
3871
+ }
3855
3872
  }
3856
3873
  var scopeFuncIsAsync = isAsyncFunction(scopeFunc);
3857
3874
  if (scopeFuncIsAsync) {
@@ -4583,7 +4600,8 @@ var Dexie$1 = (function () {
4583
4600
  dbReadyPromise: null,
4584
4601
  cancelOpen: nop,
4585
4602
  openCanceller: null,
4586
- autoSchema: true
4603
+ autoSchema: true,
4604
+ PR1398_maxLoop: 3
4587
4605
  };
4588
4606
  state.dbReadyPromise = new DexiePromise(function (resolve) {
4589
4607
  state.dbReadyResolve = resolve;