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/dexie.js
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
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
16
16
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
17
17
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dexie = factory());
|
|
18
|
-
}(this, (function () { 'use strict';
|
|
18
|
+
})(this, (function () { 'use strict';
|
|
19
19
|
|
|
20
20
|
/*! *****************************************************************************
|
|
21
21
|
Copyright (c) Microsoft Corporation.
|
|
@@ -39,10 +39,14 @@
|
|
|
39
39
|
};
|
|
40
40
|
return __assign.apply(this, arguments);
|
|
41
41
|
};
|
|
42
|
-
function __spreadArray(to, from) {
|
|
43
|
-
for (var i = 0,
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
function __spreadArray(to, from, pack) {
|
|
43
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
44
|
+
if (ar || !(i in from)) {
|
|
45
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
46
|
+
ar[i] = from[i];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
var _global = typeof globalThis !== 'undefined' ? globalThis :
|
|
@@ -1262,8 +1266,14 @@
|
|
|
1262
1266
|
var trans = db._createTransaction(mode, storeNames, db._dbSchema);
|
|
1263
1267
|
try {
|
|
1264
1268
|
trans.create();
|
|
1269
|
+
db._state.PR1398_maxLoop = 3;
|
|
1265
1270
|
}
|
|
1266
1271
|
catch (ex) {
|
|
1272
|
+
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
|
|
1273
|
+
console.warn('Dexie: Need to reopen db');
|
|
1274
|
+
db._close();
|
|
1275
|
+
return db.open().then(function () { return tempTransaction(db, mode, storeNames, fn); });
|
|
1276
|
+
}
|
|
1267
1277
|
return rejection(ex);
|
|
1268
1278
|
}
|
|
1269
1279
|
return trans._promise(mode, function (resolve, reject) {
|
|
@@ -1277,7 +1287,7 @@
|
|
|
1277
1287
|
}
|
|
1278
1288
|
}
|
|
1279
1289
|
|
|
1280
|
-
var DEXIE_VERSION = '3.2.
|
|
1290
|
+
var DEXIE_VERSION = '3.2.1-beta.2';
|
|
1281
1291
|
var maxString = String.fromCharCode(65535);
|
|
1282
1292
|
var minKey = -Infinity;
|
|
1283
1293
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1299,37 +1309,11 @@
|
|
|
1299
1309
|
filter2;
|
|
1300
1310
|
}
|
|
1301
1311
|
|
|
1302
|
-
var domDeps;
|
|
1303
|
-
try {
|
|
1304
|
-
domDeps = {
|
|
1305
|
-
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
|
|
1306
|
-
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
catch (e) {
|
|
1310
|
-
domDeps = { indexedDB: null, IDBKeyRange: null };
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
function safariMultiStoreFix(storeNames) {
|
|
1314
|
-
return storeNames.length === 1 ? storeNames[0] : storeNames;
|
|
1315
|
-
}
|
|
1316
|
-
var getMaxKey = function (IdbKeyRange) {
|
|
1317
|
-
try {
|
|
1318
|
-
IdbKeyRange.only([[]]);
|
|
1319
|
-
getMaxKey = function () { return [[]]; };
|
|
1320
|
-
return [[]];
|
|
1321
|
-
}
|
|
1322
|
-
catch (e) {
|
|
1323
|
-
getMaxKey = function () { return maxString; };
|
|
1324
|
-
return maxString;
|
|
1325
|
-
}
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
1312
|
var AnyRange = {
|
|
1329
1313
|
type: 3 ,
|
|
1330
1314
|
lower: -Infinity,
|
|
1331
1315
|
lowerOpen: false,
|
|
1332
|
-
|
|
1316
|
+
upper: [[]],
|
|
1333
1317
|
upperOpen: false
|
|
1334
1318
|
};
|
|
1335
1319
|
|
|
@@ -1797,6 +1781,82 @@
|
|
|
1797
1781
|
});
|
|
1798
1782
|
}
|
|
1799
1783
|
|
|
1784
|
+
function cmp(a, b) {
|
|
1785
|
+
try {
|
|
1786
|
+
var ta = type(a);
|
|
1787
|
+
var tb = type(b);
|
|
1788
|
+
if (ta !== tb) {
|
|
1789
|
+
if (ta === 'Array')
|
|
1790
|
+
return 1;
|
|
1791
|
+
if (tb === 'Array')
|
|
1792
|
+
return -1;
|
|
1793
|
+
if (ta === 'binary')
|
|
1794
|
+
return 1;
|
|
1795
|
+
if (tb === 'binary')
|
|
1796
|
+
return -1;
|
|
1797
|
+
if (ta === 'string')
|
|
1798
|
+
return 1;
|
|
1799
|
+
if (tb === 'string')
|
|
1800
|
+
return -1;
|
|
1801
|
+
if (ta === 'Date')
|
|
1802
|
+
return 1;
|
|
1803
|
+
if (tb !== 'Date')
|
|
1804
|
+
return NaN;
|
|
1805
|
+
return -1;
|
|
1806
|
+
}
|
|
1807
|
+
switch (ta) {
|
|
1808
|
+
case 'number':
|
|
1809
|
+
case 'Date':
|
|
1810
|
+
case 'string':
|
|
1811
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
1812
|
+
case 'binary': {
|
|
1813
|
+
return compareUint8Arrays(getUint8Array(a), getUint8Array(b));
|
|
1814
|
+
}
|
|
1815
|
+
case 'Array':
|
|
1816
|
+
return compareArrays(a, b);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
catch (_a) { }
|
|
1820
|
+
return NaN;
|
|
1821
|
+
}
|
|
1822
|
+
function compareArrays(a, b) {
|
|
1823
|
+
var al = a.length;
|
|
1824
|
+
var bl = b.length;
|
|
1825
|
+
var l = al < bl ? al : bl;
|
|
1826
|
+
for (var i = 0; i < l; ++i) {
|
|
1827
|
+
var res = cmp(a[i], b[i]);
|
|
1828
|
+
if (res !== 0)
|
|
1829
|
+
return res;
|
|
1830
|
+
}
|
|
1831
|
+
return al === bl ? 0 : al < bl ? -1 : 1;
|
|
1832
|
+
}
|
|
1833
|
+
function compareUint8Arrays(a, b) {
|
|
1834
|
+
var al = a.length;
|
|
1835
|
+
var bl = b.length;
|
|
1836
|
+
var l = al < bl ? al : bl;
|
|
1837
|
+
for (var i = 0; i < l; ++i) {
|
|
1838
|
+
if (a[i] !== b[i])
|
|
1839
|
+
return a[i] < b[i] ? -1 : 1;
|
|
1840
|
+
}
|
|
1841
|
+
return al === bl ? 0 : al < bl ? -1 : 1;
|
|
1842
|
+
}
|
|
1843
|
+
function type(x) {
|
|
1844
|
+
var t = typeof x;
|
|
1845
|
+
if (t !== 'object')
|
|
1846
|
+
return t;
|
|
1847
|
+
if (ArrayBuffer.isView(x))
|
|
1848
|
+
return 'binary';
|
|
1849
|
+
var tsTag = toStringTag(x);
|
|
1850
|
+
return tsTag === 'ArrayBuffer' ? 'binary' : tsTag;
|
|
1851
|
+
}
|
|
1852
|
+
function getUint8Array(a) {
|
|
1853
|
+
if (a instanceof Uint8Array)
|
|
1854
|
+
return a;
|
|
1855
|
+
if (ArrayBuffer.isView(a))
|
|
1856
|
+
return new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
|
|
1857
|
+
return new Uint8Array(a);
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1800
1860
|
var Collection = (function () {
|
|
1801
1861
|
function Collection() {
|
|
1802
1862
|
}
|
|
@@ -2080,7 +2140,6 @@
|
|
|
2080
2140
|
var coreTable = ctx.table.core;
|
|
2081
2141
|
var _a = coreTable.schema.primaryKey, outbound = _a.outbound, extractKey = _a.extractKey;
|
|
2082
2142
|
var limit = _this.db._options.modifyChunkSize || 200;
|
|
2083
|
-
var cmp = _this.db.core.cmp;
|
|
2084
2143
|
var totalFailures = [];
|
|
2085
2144
|
var successCount = 0;
|
|
2086
2145
|
var failedKeys = [];
|
|
@@ -2842,6 +2901,21 @@
|
|
|
2842
2901
|
};
|
|
2843
2902
|
}
|
|
2844
2903
|
|
|
2904
|
+
function safariMultiStoreFix(storeNames) {
|
|
2905
|
+
return storeNames.length === 1 ? storeNames[0] : storeNames;
|
|
2906
|
+
}
|
|
2907
|
+
var getMaxKey = function (IdbKeyRange) {
|
|
2908
|
+
try {
|
|
2909
|
+
IdbKeyRange.only([[]]);
|
|
2910
|
+
getMaxKey = function () { return [[]]; };
|
|
2911
|
+
return [[]];
|
|
2912
|
+
}
|
|
2913
|
+
catch (e) {
|
|
2914
|
+
getMaxKey = function () { return maxString; };
|
|
2915
|
+
return maxString;
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
|
|
2845
2919
|
function getKeyExtractor(keyPath) {
|
|
2846
2920
|
if (keyPath == null) {
|
|
2847
2921
|
return function () { return undefined; };
|
|
@@ -2874,8 +2948,7 @@
|
|
|
2874
2948
|
keyPath :
|
|
2875
2949
|
"[" + keyPath.join('+') + "]";
|
|
2876
2950
|
}
|
|
2877
|
-
function createDBCore(db,
|
|
2878
|
-
var cmp = indexedDB.cmp.bind(indexedDB);
|
|
2951
|
+
function createDBCore(db, IdbKeyRange, tmpTrans) {
|
|
2879
2952
|
function extractSchema(db, trans) {
|
|
2880
2953
|
var tables = arrayify(db.objectStoreNames);
|
|
2881
2954
|
return {
|
|
@@ -3210,7 +3283,6 @@
|
|
|
3210
3283
|
throw new Error("Table '" + name + "' not found");
|
|
3211
3284
|
return tableMap[name];
|
|
3212
3285
|
},
|
|
3213
|
-
cmp: cmp,
|
|
3214
3286
|
MIN_KEY: -Infinity,
|
|
3215
3287
|
MAX_KEY: getMaxKey(IdbKeyRange),
|
|
3216
3288
|
schema: schema
|
|
@@ -3224,8 +3296,8 @@
|
|
|
3224
3296
|
}, stackImpl);
|
|
3225
3297
|
}
|
|
3226
3298
|
function createMiddlewareStacks(middlewares, idbdb, _a, tmpTrans) {
|
|
3227
|
-
var IDBKeyRange = _a.IDBKeyRange
|
|
3228
|
-
var dbcore = createMiddlewareStack(createDBCore(idbdb,
|
|
3299
|
+
var IDBKeyRange = _a.IDBKeyRange; _a.indexedDB;
|
|
3300
|
+
var dbcore = createMiddlewareStack(createDBCore(idbdb, IDBKeyRange, tmpTrans), middlewares.dbcore);
|
|
3229
3301
|
return {
|
|
3230
3302
|
dbcore: dbcore
|
|
3231
3303
|
};
|
|
@@ -3451,12 +3523,9 @@
|
|
|
3451
3523
|
});
|
|
3452
3524
|
}
|
|
3453
3525
|
function deleteRemovedTables(newSchema, idbtrans) {
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
idbtrans.db.deleteObjectStore(storeName);
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3526
|
+
[].slice.call(idbtrans.db.objectStoreNames).forEach(function (storeName) {
|
|
3527
|
+
return newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName);
|
|
3528
|
+
});
|
|
3460
3529
|
}
|
|
3461
3530
|
function addIndex(store, idx) {
|
|
3462
3531
|
store.createIndex(idx.name, idx.keyPath, { unique: idx.unique, multiEntry: idx.multi });
|
|
@@ -3794,7 +3863,18 @@
|
|
|
3794
3863
|
trans.idbtrans = parentTransaction.idbtrans;
|
|
3795
3864
|
}
|
|
3796
3865
|
else {
|
|
3797
|
-
|
|
3866
|
+
try {
|
|
3867
|
+
trans.create();
|
|
3868
|
+
db._state.PR1398_maxLoop = 3;
|
|
3869
|
+
}
|
|
3870
|
+
catch (ex) {
|
|
3871
|
+
if (ex.name === errnames.InvalidState && db.isOpen() && --db._state.PR1398_maxLoop > 0) {
|
|
3872
|
+
console.warn('Dexie: Need to reopen db');
|
|
3873
|
+
db._close();
|
|
3874
|
+
return db.open().then(function () { return enterTransactionScope(db, mode, storeNames, null, scopeFunc); });
|
|
3875
|
+
}
|
|
3876
|
+
return rejection(ex);
|
|
3877
|
+
}
|
|
3798
3878
|
}
|
|
3799
3879
|
var scopeFuncIsAsync = isAsyncFunction(scopeFunc);
|
|
3800
3880
|
if (scopeFuncIsAsync) {
|
|
@@ -4023,9 +4103,9 @@
|
|
|
4023
4103
|
throw new Error("Keys missing");
|
|
4024
4104
|
req = req.type === 'add' || req.type === 'put' ? __assign(__assign({}, req), { keys: keys }) : __assign({}, req);
|
|
4025
4105
|
if (req.type !== 'delete')
|
|
4026
|
-
req.values = __spreadArray([], req.values);
|
|
4106
|
+
req.values = __spreadArray([], req.values, true);
|
|
4027
4107
|
if (req.keys)
|
|
4028
|
-
req.keys = __spreadArray([], req.keys);
|
|
4108
|
+
req.keys = __spreadArray([], req.keys, true);
|
|
4029
4109
|
return getExistingValues(downTable, req, keys).then(function (existingValues) {
|
|
4030
4110
|
var contexts = keys.map(function (key, i) {
|
|
4031
4111
|
var existingValue = existingValues[i];
|
|
@@ -4111,24 +4191,6 @@
|
|
|
4111
4191
|
: table.getMany({ trans: req.trans, keys: effectiveKeys, cache: "immutable" });
|
|
4112
4192
|
}
|
|
4113
4193
|
|
|
4114
|
-
var _cmp;
|
|
4115
|
-
function cmp(a, b) {
|
|
4116
|
-
if (_cmp)
|
|
4117
|
-
return _cmp(a, b);
|
|
4118
|
-
var indexedDB = domDeps.indexedDB;
|
|
4119
|
-
if (!indexedDB)
|
|
4120
|
-
throw new exceptions.MissingAPI();
|
|
4121
|
-
_cmp = function (a, b) {
|
|
4122
|
-
try {
|
|
4123
|
-
return a == null || b == null ? NaN : indexedDB.cmp(a, b);
|
|
4124
|
-
}
|
|
4125
|
-
catch (_a) {
|
|
4126
|
-
return NaN;
|
|
4127
|
-
}
|
|
4128
|
-
};
|
|
4129
|
-
return _cmp(a, b);
|
|
4130
|
-
}
|
|
4131
|
-
|
|
4132
4194
|
function getFromTransactionCache(keys, cache, clone) {
|
|
4133
4195
|
try {
|
|
4134
4196
|
if (!cache)
|
|
@@ -4544,7 +4606,8 @@
|
|
|
4544
4606
|
dbReadyPromise: null,
|
|
4545
4607
|
cancelOpen: nop,
|
|
4546
4608
|
openCanceller: null,
|
|
4547
|
-
autoSchema: true
|
|
4609
|
+
autoSchema: true,
|
|
4610
|
+
PR1398_maxLoop: 3
|
|
4548
4611
|
};
|
|
4549
4612
|
state.dbReadyPromise = new DexiePromise(function (resolve) {
|
|
4550
4613
|
state.dbReadyResolve = resolve;
|
|
@@ -4820,7 +4883,7 @@
|
|
|
4820
4883
|
}());
|
|
4821
4884
|
|
|
4822
4885
|
var symbolObservable = typeof Symbol !== "undefined" && "observable" in Symbol
|
|
4823
|
-
? Symbol
|
|
4886
|
+
? Symbol.observable
|
|
4824
4887
|
: "@@observable";
|
|
4825
4888
|
var Observable = (function () {
|
|
4826
4889
|
function Observable(subscribe) {
|
|
@@ -4919,6 +4982,17 @@
|
|
|
4919
4982
|
});
|
|
4920
4983
|
}
|
|
4921
4984
|
|
|
4985
|
+
var domDeps;
|
|
4986
|
+
try {
|
|
4987
|
+
domDeps = {
|
|
4988
|
+
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
|
|
4989
|
+
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
|
|
4990
|
+
};
|
|
4991
|
+
}
|
|
4992
|
+
catch (e) {
|
|
4993
|
+
domDeps = { indexedDB: null, IDBKeyRange: null };
|
|
4994
|
+
}
|
|
4995
|
+
|
|
4922
4996
|
var Dexie = Dexie$1;
|
|
4923
4997
|
props(Dexie, __assign(__assign({}, fullNameExceptions), {
|
|
4924
4998
|
delete: function (databaseName) {
|
|
@@ -4991,7 +5065,7 @@
|
|
|
4991
5065
|
},
|
|
4992
5066
|
derive: derive, extend: extend, props: props, override: override,
|
|
4993
5067
|
Events: Events, on: globalEvents, liveQuery: liveQuery, extendObservabilitySet: extendObservabilitySet,
|
|
4994
|
-
getByKeyPath: getByKeyPath, setByKeyPath: setByKeyPath, delByKeyPath: delByKeyPath, shallowClone: shallowClone, deepClone: deepClone, getObjectDiff: getObjectDiff, asap: asap$1,
|
|
5068
|
+
getByKeyPath: getByKeyPath, setByKeyPath: setByKeyPath, delByKeyPath: delByKeyPath, shallowClone: shallowClone, deepClone: deepClone, getObjectDiff: getObjectDiff, cmp: cmp, asap: asap$1,
|
|
4995
5069
|
minKey: minKey,
|
|
4996
5070
|
addons: [],
|
|
4997
5071
|
connections: connections,
|
|
@@ -5062,7 +5136,7 @@
|
|
|
5062
5136
|
}));
|
|
5063
5137
|
}
|
|
5064
5138
|
if (typeof self['clients'] === 'object') {
|
|
5065
|
-
__spreadArray([], self['clients'].matchAll({ includeUncontrolled: true })).forEach(function (client) {
|
|
5139
|
+
__spreadArray([], self['clients'].matchAll({ includeUncontrolled: true }), true).forEach(function (client) {
|
|
5066
5140
|
return client.postMessage({
|
|
5067
5141
|
type: STORAGE_MUTATED_DOM_EVENT_NAME,
|
|
5068
5142
|
changedParts: changedParts,
|
|
@@ -5109,5 +5183,5 @@
|
|
|
5109
5183
|
|
|
5110
5184
|
return Dexie$1;
|
|
5111
5185
|
|
|
5112
|
-
}))
|
|
5186
|
+
}));
|
|
5113
5187
|
//# sourceMappingURL=dexie.js.map
|