dexie 3.2.4 → 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 +1 -1
- package/dist/dexie.js +93 -72
- package/dist/dexie.js.map +1 -1
- package/dist/dexie.min.js +1 -1
- package/dist/dexie.min.js.map +1 -1
- package/dist/dexie.mjs +93 -72
- package/dist/dexie.mjs.map +1 -1
- package/dist/modern/dexie.min.mjs +1 -1
- package/dist/modern/dexie.min.mjs.map +1 -1
- package/dist/modern/dexie.mjs +94 -71
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +4 -1
package/dist/modern/dexie.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 3.2.
|
|
7
|
+
* Version 3.2.5, Thu Feb 08 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -98,7 +98,7 @@ function tryCatch(fn, onerror, args) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
function getByKeyPath(obj, keyPath) {
|
|
101
|
-
if (hasOwn(obj, keyPath))
|
|
101
|
+
if (typeof keyPath === 'string' && hasOwn(obj, keyPath))
|
|
102
102
|
return obj[keyPath];
|
|
103
103
|
if (!keyPath)
|
|
104
104
|
return obj;
|
|
@@ -181,7 +181,7 @@ const concat = [].concat;
|
|
|
181
181
|
function flatten(a) {
|
|
182
182
|
return concat.apply([], a);
|
|
183
183
|
}
|
|
184
|
-
const intrinsicTypeNames = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
|
|
184
|
+
const intrinsicTypeNames = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey"
|
|
185
185
|
.split(',').concat(flatten([8, 16, 32, 64].map(num => ["Int", "Uint", "Float"].map(t => t + num + "Array")))).filter(t => _global[t]);
|
|
186
186
|
const intrinsicTypes = intrinsicTypeNames.map(t => _global[t]);
|
|
187
187
|
arrayToObject(intrinsicTypeNames, x => [x, true]);
|
|
@@ -1242,7 +1242,7 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
1244
1244
|
|
|
1245
|
-
const DEXIE_VERSION = '3.2.
|
|
1245
|
+
const DEXIE_VERSION = '3.2.5';
|
|
1246
1246
|
const maxString = String.fromCharCode(65535);
|
|
1247
1247
|
const minKey = -Infinity;
|
|
1248
1248
|
const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1324,13 +1324,23 @@ class Table {
|
|
|
1324
1324
|
return this
|
|
1325
1325
|
.where(keyPaths[0])
|
|
1326
1326
|
.equals(indexOrCrit[keyPaths[0]]);
|
|
1327
|
-
const compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(ix =>
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1327
|
+
const compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(ix => {
|
|
1328
|
+
if (ix.compound &&
|
|
1329
|
+
keyPaths.every(keyPath => ix.keyPath.indexOf(keyPath) >= 0)) {
|
|
1330
|
+
for (let i = 0; i < keyPaths.length; ++i) {
|
|
1331
|
+
if (keyPaths.indexOf(ix.keyPath[i]) === -1)
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
return true;
|
|
1335
|
+
}
|
|
1336
|
+
return false;
|
|
1337
|
+
}).sort((a, b) => a.keyPath.length - b.keyPath.length)[0];
|
|
1338
|
+
if (compoundIndex && this.db._maxKey !== maxString) {
|
|
1339
|
+
const keyPathsInValidOrder = compoundIndex.keyPath.slice(0, keyPaths.length);
|
|
1331
1340
|
return this
|
|
1332
|
-
.where(
|
|
1333
|
-
.equals(
|
|
1341
|
+
.where(keyPathsInValidOrder)
|
|
1342
|
+
.equals(keyPathsInValidOrder.map(kp => indexOrCrit[kp]));
|
|
1343
|
+
}
|
|
1334
1344
|
if (!compoundIndex && debug)
|
|
1335
1345
|
console.warn(`The query ${JSON.stringify(indexOrCrit)} on ${this.name} would benefit of a ` +
|
|
1336
1346
|
`compound index [${keyPaths.join('+')}]`);
|
|
@@ -3613,69 +3623,82 @@ function dexieOpen(db) {
|
|
|
3613
3623
|
}
|
|
3614
3624
|
let resolveDbReady = state.dbReadyResolve,
|
|
3615
3625
|
upgradeTransaction = null, wasCreated = false;
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
}
|
|
3626
|
+
const tryOpenDB = () => new DexiePromise((resolve, reject) => {
|
|
3627
|
+
throwIfCancelled();
|
|
3628
|
+
if (!indexedDB)
|
|
3629
|
+
throw new exceptions.MissingAPI();
|
|
3630
|
+
const dbName = db.name;
|
|
3631
|
+
const req = state.autoSchema ?
|
|
3632
|
+
indexedDB.open(dbName) :
|
|
3633
|
+
indexedDB.open(dbName, Math.round(db.verno * 10));
|
|
3634
|
+
if (!req)
|
|
3635
|
+
throw new exceptions.MissingAPI();
|
|
3636
|
+
req.onerror = eventRejectHandler(reject);
|
|
3637
|
+
req.onblocked = wrap(db._fireOnBlocked);
|
|
3638
|
+
req.onupgradeneeded = wrap(e => {
|
|
3639
|
+
upgradeTransaction = req.transaction;
|
|
3640
|
+
if (state.autoSchema && !db._options.allowEmptyDB) {
|
|
3641
|
+
req.onerror = preventDefault;
|
|
3642
|
+
upgradeTransaction.abort();
|
|
3643
|
+
req.result.close();
|
|
3644
|
+
const delreq = indexedDB.deleteDatabase(dbName);
|
|
3645
|
+
delreq.onsuccess = delreq.onerror = wrap(() => {
|
|
3646
|
+
reject(new exceptions.NoSuchDatabase(`Database ${dbName} doesnt exist`));
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3649
|
+
else {
|
|
3650
|
+
upgradeTransaction.onerror = eventRejectHandler(reject);
|
|
3651
|
+
var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion;
|
|
3652
|
+
wasCreated = oldVer < 1;
|
|
3653
|
+
db._novip.idbdb = req.result;
|
|
3654
|
+
runUpgraders(db, oldVer / 10, upgradeTransaction, reject);
|
|
3655
|
+
}
|
|
3656
|
+
}, reject);
|
|
3657
|
+
req.onsuccess = wrap(() => {
|
|
3658
|
+
upgradeTransaction = null;
|
|
3659
|
+
const idbdb = db._novip.idbdb = req.result;
|
|
3660
|
+
const objectStoreNames = slice(idbdb.objectStoreNames);
|
|
3661
|
+
if (objectStoreNames.length > 0)
|
|
3662
|
+
try {
|
|
3663
|
+
const tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), 'readonly');
|
|
3664
|
+
if (state.autoSchema)
|
|
3665
|
+
readGlobalSchema(db, idbdb, tmpTrans);
|
|
3666
|
+
else {
|
|
3667
|
+
adjustToExistingIndexNames(db, db._dbSchema, tmpTrans);
|
|
3668
|
+
if (!verifyInstalledSchema(db, tmpTrans)) {
|
|
3669
|
+
console.warn(`Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.`);
|
|
3661
3670
|
}
|
|
3662
|
-
generateMiddlewareStacks(db, tmpTrans);
|
|
3663
3671
|
}
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3672
|
+
generateMiddlewareStacks(db, tmpTrans);
|
|
3673
|
+
}
|
|
3674
|
+
catch (e) {
|
|
3675
|
+
}
|
|
3676
|
+
connections.push(db);
|
|
3677
|
+
idbdb.onversionchange = wrap(ev => {
|
|
3678
|
+
state.vcFired = true;
|
|
3679
|
+
db.on("versionchange").fire(ev);
|
|
3680
|
+
});
|
|
3681
|
+
idbdb.onclose = wrap(ev => {
|
|
3682
|
+
db.on("close").fire(ev);
|
|
3683
|
+
});
|
|
3684
|
+
if (wasCreated)
|
|
3685
|
+
_onDatabaseCreated(db._deps, dbName);
|
|
3686
|
+
resolve();
|
|
3687
|
+
}, reject);
|
|
3688
|
+
}).catch(err => {
|
|
3689
|
+
if (err && err.name === 'UnknownError' && state.PR1398_maxLoop > 0) {
|
|
3690
|
+
state.PR1398_maxLoop--;
|
|
3691
|
+
console.warn('Dexie: Workaround for Chrome UnknownError on open()');
|
|
3692
|
+
return tryOpenDB();
|
|
3693
|
+
}
|
|
3694
|
+
else {
|
|
3695
|
+
return DexiePromise.reject(err);
|
|
3696
|
+
}
|
|
3697
|
+
});
|
|
3698
|
+
return DexiePromise.race([
|
|
3699
|
+
openCanceller,
|
|
3700
|
+
(typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(tryOpenDB)
|
|
3701
|
+
]).then(() => {
|
|
3679
3702
|
throwIfCancelled();
|
|
3680
3703
|
state.onReadyBeingFired = [];
|
|
3681
3704
|
return DexiePromise.resolve(vip(() => db.on.ready.fire(db.vip))).then(function fireRemainders() {
|