dexie 3.2.0-rc.2 → 3.2.1-beta.2
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/CONTRIBUTING.md +1 -1
- package/README.md +54 -46
- package/dist/dexie.d.ts +42 -37
- package/dist/dexie.js +147 -73
- 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 +146 -73
- 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 +132 -64
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.mjs +7 -0
- package/import-wrapper.mjs +7 -0
- package/package.json +29 -4
package/dist/modern/dexie.mjs
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 3.2.
|
|
7
|
+
* Version 3.2.1-beta.2, Wed Jan 05 2022
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* https://dexie.org
|
|
10
10
|
*
|
|
11
11
|
* Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
|
|
12
12
|
*/
|
|
@@ -1221,8 +1221,14 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1221
1221
|
var trans = db._createTransaction(mode, storeNames, db._dbSchema);
|
|
1222
1222
|
try {
|
|
1223
1223
|
trans.create();
|
|
1224
|
+
db._state.PR1398_maxLoop = 3;
|
|
1224
1225
|
}
|
|
1225
1226
|
catch (ex) {
|
|
1227
|
+
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
|
|
1228
|
+
console.warn('Dexie: Need to reopen db');
|
|
1229
|
+
db._close();
|
|
1230
|
+
return db.open().then(() => tempTransaction(db, mode, storeNames, fn));
|
|
1231
|
+
}
|
|
1226
1232
|
return rejection(ex);
|
|
1227
1233
|
}
|
|
1228
1234
|
return trans._promise(mode, (resolve, reject) => {
|
|
@@ -1236,7 +1242,7 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1236
1242
|
}
|
|
1237
1243
|
}
|
|
1238
1244
|
|
|
1239
|
-
const DEXIE_VERSION = '3.2.
|
|
1245
|
+
const DEXIE_VERSION = '3.2.1-beta.2';
|
|
1240
1246
|
const maxString = String.fromCharCode(65535);
|
|
1241
1247
|
const minKey = -Infinity;
|
|
1242
1248
|
const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1258,37 +1264,11 @@ function combine(filter1, filter2) {
|
|
|
1258
1264
|
filter2;
|
|
1259
1265
|
}
|
|
1260
1266
|
|
|
1261
|
-
let domDeps;
|
|
1262
|
-
try {
|
|
1263
|
-
domDeps = {
|
|
1264
|
-
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
|
|
1265
|
-
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
|
|
1266
|
-
};
|
|
1267
|
-
}
|
|
1268
|
-
catch (e) {
|
|
1269
|
-
domDeps = { indexedDB: null, IDBKeyRange: null };
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
function safariMultiStoreFix(storeNames) {
|
|
1273
|
-
return storeNames.length === 1 ? storeNames[0] : storeNames;
|
|
1274
|
-
}
|
|
1275
|
-
let getMaxKey = (IdbKeyRange) => {
|
|
1276
|
-
try {
|
|
1277
|
-
IdbKeyRange.only([[]]);
|
|
1278
|
-
getMaxKey = () => [[]];
|
|
1279
|
-
return [[]];
|
|
1280
|
-
}
|
|
1281
|
-
catch (e) {
|
|
1282
|
-
getMaxKey = () => maxString;
|
|
1283
|
-
return maxString;
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
|
|
1287
1267
|
const AnyRange = {
|
|
1288
1268
|
type: 3 ,
|
|
1289
1269
|
lower: -Infinity,
|
|
1290
1270
|
lowerOpen: false,
|
|
1291
|
-
|
|
1271
|
+
upper: [[]],
|
|
1292
1272
|
upperOpen: false
|
|
1293
1273
|
};
|
|
1294
1274
|
|
|
@@ -1738,6 +1718,82 @@ function iterate(cursorPromise, filter, fn, valueMapper) {
|
|
|
1738
1718
|
});
|
|
1739
1719
|
}
|
|
1740
1720
|
|
|
1721
|
+
function cmp(a, b) {
|
|
1722
|
+
try {
|
|
1723
|
+
const ta = type(a);
|
|
1724
|
+
const tb = type(b);
|
|
1725
|
+
if (ta !== tb) {
|
|
1726
|
+
if (ta === 'Array')
|
|
1727
|
+
return 1;
|
|
1728
|
+
if (tb === 'Array')
|
|
1729
|
+
return -1;
|
|
1730
|
+
if (ta === 'binary')
|
|
1731
|
+
return 1;
|
|
1732
|
+
if (tb === 'binary')
|
|
1733
|
+
return -1;
|
|
1734
|
+
if (ta === 'string')
|
|
1735
|
+
return 1;
|
|
1736
|
+
if (tb === 'string')
|
|
1737
|
+
return -1;
|
|
1738
|
+
if (ta === 'Date')
|
|
1739
|
+
return 1;
|
|
1740
|
+
if (tb !== 'Date')
|
|
1741
|
+
return NaN;
|
|
1742
|
+
return -1;
|
|
1743
|
+
}
|
|
1744
|
+
switch (ta) {
|
|
1745
|
+
case 'number':
|
|
1746
|
+
case 'Date':
|
|
1747
|
+
case 'string':
|
|
1748
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
1749
|
+
case 'binary': {
|
|
1750
|
+
return compareUint8Arrays(getUint8Array(a), getUint8Array(b));
|
|
1751
|
+
}
|
|
1752
|
+
case 'Array':
|
|
1753
|
+
return compareArrays(a, b);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
catch (_a) { }
|
|
1757
|
+
return NaN;
|
|
1758
|
+
}
|
|
1759
|
+
function compareArrays(a, b) {
|
|
1760
|
+
const al = a.length;
|
|
1761
|
+
const bl = b.length;
|
|
1762
|
+
const l = al < bl ? al : bl;
|
|
1763
|
+
for (let i = 0; i < l; ++i) {
|
|
1764
|
+
const res = cmp(a[i], b[i]);
|
|
1765
|
+
if (res !== 0)
|
|
1766
|
+
return res;
|
|
1767
|
+
}
|
|
1768
|
+
return al === bl ? 0 : al < bl ? -1 : 1;
|
|
1769
|
+
}
|
|
1770
|
+
function compareUint8Arrays(a, b) {
|
|
1771
|
+
const al = a.length;
|
|
1772
|
+
const bl = b.length;
|
|
1773
|
+
const l = al < bl ? al : bl;
|
|
1774
|
+
for (let i = 0; i < l; ++i) {
|
|
1775
|
+
if (a[i] !== b[i])
|
|
1776
|
+
return a[i] < b[i] ? -1 : 1;
|
|
1777
|
+
}
|
|
1778
|
+
return al === bl ? 0 : al < bl ? -1 : 1;
|
|
1779
|
+
}
|
|
1780
|
+
function type(x) {
|
|
1781
|
+
const t = typeof x;
|
|
1782
|
+
if (t !== 'object')
|
|
1783
|
+
return t;
|
|
1784
|
+
if (ArrayBuffer.isView(x))
|
|
1785
|
+
return 'binary';
|
|
1786
|
+
const tsTag = toStringTag(x);
|
|
1787
|
+
return tsTag === 'ArrayBuffer' ? 'binary' : tsTag;
|
|
1788
|
+
}
|
|
1789
|
+
function getUint8Array(a) {
|
|
1790
|
+
if (a instanceof Uint8Array)
|
|
1791
|
+
return a;
|
|
1792
|
+
if (ArrayBuffer.isView(a))
|
|
1793
|
+
return new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
|
|
1794
|
+
return new Uint8Array(a);
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1741
1797
|
class Collection {
|
|
1742
1798
|
_read(fn, cb) {
|
|
1743
1799
|
var ctx = this._ctx;
|
|
@@ -2010,7 +2066,6 @@ class Collection {
|
|
|
2010
2066
|
const coreTable = ctx.table.core;
|
|
2011
2067
|
const { outbound, extractKey } = coreTable.schema.primaryKey;
|
|
2012
2068
|
const limit = this.db._options.modifyChunkSize || 200;
|
|
2013
|
-
const { cmp } = this.db.core;
|
|
2014
2069
|
const totalFailures = [];
|
|
2015
2070
|
let successCount = 0;
|
|
2016
2071
|
const failedKeys = [];
|
|
@@ -2752,6 +2807,21 @@ function createTableSchema(name, primKey, indexes) {
|
|
|
2752
2807
|
};
|
|
2753
2808
|
}
|
|
2754
2809
|
|
|
2810
|
+
function safariMultiStoreFix(storeNames) {
|
|
2811
|
+
return storeNames.length === 1 ? storeNames[0] : storeNames;
|
|
2812
|
+
}
|
|
2813
|
+
let getMaxKey = (IdbKeyRange) => {
|
|
2814
|
+
try {
|
|
2815
|
+
IdbKeyRange.only([[]]);
|
|
2816
|
+
getMaxKey = () => [[]];
|
|
2817
|
+
return [[]];
|
|
2818
|
+
}
|
|
2819
|
+
catch (e) {
|
|
2820
|
+
getMaxKey = () => maxString;
|
|
2821
|
+
return maxString;
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
|
|
2755
2825
|
function getKeyExtractor(keyPath) {
|
|
2756
2826
|
if (keyPath == null) {
|
|
2757
2827
|
return () => undefined;
|
|
@@ -2784,8 +2854,7 @@ function getKeyPathAlias(keyPath) {
|
|
|
2784
2854
|
keyPath :
|
|
2785
2855
|
`[${keyPath.join('+')}]`;
|
|
2786
2856
|
}
|
|
2787
|
-
function createDBCore(db,
|
|
2788
|
-
const cmp = indexedDB.cmp.bind(indexedDB);
|
|
2857
|
+
function createDBCore(db, IdbKeyRange, tmpTrans) {
|
|
2789
2858
|
function extractSchema(db, trans) {
|
|
2790
2859
|
const tables = arrayify(db.objectStoreNames);
|
|
2791
2860
|
return {
|
|
@@ -3114,7 +3183,6 @@ function createDBCore(db, indexedDB, IdbKeyRange, tmpTrans) {
|
|
|
3114
3183
|
throw new Error(`Table '${name}' not found`);
|
|
3115
3184
|
return tableMap[name];
|
|
3116
3185
|
},
|
|
3117
|
-
cmp,
|
|
3118
3186
|
MIN_KEY: -Infinity,
|
|
3119
3187
|
MAX_KEY: getMaxKey(IdbKeyRange),
|
|
3120
3188
|
schema
|
|
@@ -3125,7 +3193,7 @@ function createMiddlewareStack(stackImpl, middlewares) {
|
|
|
3125
3193
|
return middlewares.reduce((down, { create }) => ({ ...down, ...create(down) }), stackImpl);
|
|
3126
3194
|
}
|
|
3127
3195
|
function createMiddlewareStacks(middlewares, idbdb, { IDBKeyRange, indexedDB }, tmpTrans) {
|
|
3128
|
-
const dbcore = createMiddlewareStack(createDBCore(idbdb,
|
|
3196
|
+
const dbcore = createMiddlewareStack(createDBCore(idbdb, IDBKeyRange, tmpTrans), middlewares.dbcore);
|
|
3129
3197
|
return {
|
|
3130
3198
|
dbcore
|
|
3131
3199
|
};
|
|
@@ -3347,12 +3415,7 @@ function createMissingTables(newSchema, idbtrans) {
|
|
|
3347
3415
|
});
|
|
3348
3416
|
}
|
|
3349
3417
|
function deleteRemovedTables(newSchema, idbtrans) {
|
|
3350
|
-
|
|
3351
|
-
var storeName = idbtrans.db.objectStoreNames[i];
|
|
3352
|
-
if (newSchema[storeName] == null) {
|
|
3353
|
-
idbtrans.db.deleteObjectStore(storeName);
|
|
3354
|
-
}
|
|
3355
|
-
}
|
|
3418
|
+
[].slice.call(idbtrans.db.objectStoreNames).forEach(storeName => newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName));
|
|
3356
3419
|
}
|
|
3357
3420
|
function addIndex(store, idx) {
|
|
3358
3421
|
store.createIndex(idx.name, idx.keyPath, { unique: idx.unique, multiEntry: idx.multi });
|
|
@@ -3680,7 +3743,18 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
|
|
|
3680
3743
|
trans.idbtrans = parentTransaction.idbtrans;
|
|
3681
3744
|
}
|
|
3682
3745
|
else {
|
|
3683
|
-
|
|
3746
|
+
try {
|
|
3747
|
+
trans.create();
|
|
3748
|
+
db._state.PR1398_maxLoop = 3;
|
|
3749
|
+
}
|
|
3750
|
+
catch (ex) {
|
|
3751
|
+
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
|
|
3752
|
+
console.warn('Dexie: Need to reopen db');
|
|
3753
|
+
db._close();
|
|
3754
|
+
return db.open().then(() => enterTransactionScope(db, mode, storeNames, null, scopeFunc));
|
|
3755
|
+
}
|
|
3756
|
+
return rejection(ex);
|
|
3757
|
+
}
|
|
3684
3758
|
}
|
|
3685
3759
|
const scopeFuncIsAsync = isAsyncFunction(scopeFunc);
|
|
3686
3760
|
if (scopeFuncIsAsync) {
|
|
@@ -4026,24 +4100,6 @@ function getExistingValues(table, req, effectiveKeys) {
|
|
|
4026
4100
|
: table.getMany({ trans: req.trans, keys: effectiveKeys, cache: "immutable" });
|
|
4027
4101
|
}
|
|
4028
4102
|
|
|
4029
|
-
let _cmp;
|
|
4030
|
-
function cmp(a, b) {
|
|
4031
|
-
if (_cmp)
|
|
4032
|
-
return _cmp(a, b);
|
|
4033
|
-
const { indexedDB } = domDeps;
|
|
4034
|
-
if (!indexedDB)
|
|
4035
|
-
throw new exceptions.MissingAPI();
|
|
4036
|
-
_cmp = (a, b) => {
|
|
4037
|
-
try {
|
|
4038
|
-
return a == null || b == null ? NaN : indexedDB.cmp(a, b);
|
|
4039
|
-
}
|
|
4040
|
-
catch (_a) {
|
|
4041
|
-
return NaN;
|
|
4042
|
-
}
|
|
4043
|
-
};
|
|
4044
|
-
return _cmp(a, b);
|
|
4045
|
-
}
|
|
4046
|
-
|
|
4047
4103
|
function getFromTransactionCache(keys, cache, clone) {
|
|
4048
4104
|
try {
|
|
4049
4105
|
if (!cache)
|
|
@@ -4468,7 +4524,8 @@ class Dexie$1 {
|
|
|
4468
4524
|
dbReadyPromise: null,
|
|
4469
4525
|
cancelOpen: nop,
|
|
4470
4526
|
openCanceller: null,
|
|
4471
|
-
autoSchema: true
|
|
4527
|
+
autoSchema: true,
|
|
4528
|
+
PR1398_maxLoop: 3
|
|
4472
4529
|
};
|
|
4473
4530
|
state.dbReadyPromise = new DexiePromise(resolve => {
|
|
4474
4531
|
state.dbReadyResolve = resolve;
|
|
@@ -4731,7 +4788,7 @@ class Dexie$1 {
|
|
|
4731
4788
|
}
|
|
4732
4789
|
|
|
4733
4790
|
const symbolObservable = typeof Symbol !== "undefined" && "observable" in Symbol
|
|
4734
|
-
? Symbol
|
|
4791
|
+
? Symbol.observable
|
|
4735
4792
|
: "@@observable";
|
|
4736
4793
|
class Observable {
|
|
4737
4794
|
constructor(subscribe) {
|
|
@@ -4827,6 +4884,17 @@ function liveQuery(querier) {
|
|
|
4827
4884
|
});
|
|
4828
4885
|
}
|
|
4829
4886
|
|
|
4887
|
+
let domDeps;
|
|
4888
|
+
try {
|
|
4889
|
+
domDeps = {
|
|
4890
|
+
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
|
|
4891
|
+
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
catch (e) {
|
|
4895
|
+
domDeps = { indexedDB: null, IDBKeyRange: null };
|
|
4896
|
+
}
|
|
4897
|
+
|
|
4830
4898
|
const Dexie = Dexie$1;
|
|
4831
4899
|
props(Dexie, {
|
|
4832
4900
|
...fullNameExceptions,
|
|
@@ -4917,6 +4985,7 @@ props(Dexie, {
|
|
|
4917
4985
|
shallowClone: shallowClone,
|
|
4918
4986
|
deepClone: deepClone,
|
|
4919
4987
|
getObjectDiff: getObjectDiff,
|
|
4988
|
+
cmp,
|
|
4920
4989
|
asap: asap$1,
|
|
4921
4990
|
minKey: minKey,
|
|
4922
4991
|
addons: [],
|
|
@@ -5019,6 +5088,5 @@ function propagateMessageLocally({ data }) {
|
|
|
5019
5088
|
DexiePromise.rejectionMapper = mapError;
|
|
5020
5089
|
setDebug(debug, dexieStackFrameFilter);
|
|
5021
5090
|
|
|
5022
|
-
export
|
|
5023
|
-
export { Dexie$1 as Dexie, RangeSet, liveQuery, mergeRanges, rangesOverlap };
|
|
5091
|
+
export { Dexie$1 as Dexie, RangeSet, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap };
|
|
5024
5092
|
//# sourceMappingURL=dexie.mjs.map
|