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.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
|
*/
|
|
@@ -33,10 +33,14 @@ var __assign = function() {
|
|
|
33
33
|
};
|
|
34
34
|
return __assign.apply(this, arguments);
|
|
35
35
|
};
|
|
36
|
-
function __spreadArray(to, from) {
|
|
37
|
-
for (var i = 0,
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
function __spreadArray(to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
var _global = typeof globalThis !== 'undefined' ? globalThis :
|
|
@@ -1256,8 +1260,14 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1256
1260
|
var trans = db._createTransaction(mode, storeNames, db._dbSchema);
|
|
1257
1261
|
try {
|
|
1258
1262
|
trans.create();
|
|
1263
|
+
db._state.PR1398_maxLoop = 3;
|
|
1259
1264
|
}
|
|
1260
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
|
+
}
|
|
1261
1271
|
return rejection(ex);
|
|
1262
1272
|
}
|
|
1263
1273
|
return trans._promise(mode, function (resolve, reject) {
|
|
@@ -1271,7 +1281,7 @@ function tempTransaction(db, mode, storeNames, fn) {
|
|
|
1271
1281
|
}
|
|
1272
1282
|
}
|
|
1273
1283
|
|
|
1274
|
-
var DEXIE_VERSION = '3.2.
|
|
1284
|
+
var DEXIE_VERSION = '3.2.1-beta.2';
|
|
1275
1285
|
var maxString = String.fromCharCode(65535);
|
|
1276
1286
|
var minKey = -Infinity;
|
|
1277
1287
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1293,37 +1303,11 @@ function combine(filter1, filter2) {
|
|
|
1293
1303
|
filter2;
|
|
1294
1304
|
}
|
|
1295
1305
|
|
|
1296
|
-
var domDeps;
|
|
1297
|
-
try {
|
|
1298
|
-
domDeps = {
|
|
1299
|
-
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
|
|
1300
|
-
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
catch (e) {
|
|
1304
|
-
domDeps = { indexedDB: null, IDBKeyRange: null };
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
function safariMultiStoreFix(storeNames) {
|
|
1308
|
-
return storeNames.length === 1 ? storeNames[0] : storeNames;
|
|
1309
|
-
}
|
|
1310
|
-
var getMaxKey = function (IdbKeyRange) {
|
|
1311
|
-
try {
|
|
1312
|
-
IdbKeyRange.only([[]]);
|
|
1313
|
-
getMaxKey = function () { return [[]]; };
|
|
1314
|
-
return [[]];
|
|
1315
|
-
}
|
|
1316
|
-
catch (e) {
|
|
1317
|
-
getMaxKey = function () { return maxString; };
|
|
1318
|
-
return maxString;
|
|
1319
|
-
}
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
1306
|
var AnyRange = {
|
|
1323
1307
|
type: 3 ,
|
|
1324
1308
|
lower: -Infinity,
|
|
1325
1309
|
lowerOpen: false,
|
|
1326
|
-
|
|
1310
|
+
upper: [[]],
|
|
1327
1311
|
upperOpen: false
|
|
1328
1312
|
};
|
|
1329
1313
|
|
|
@@ -1791,6 +1775,82 @@ function iterate(cursorPromise, filter, fn, valueMapper) {
|
|
|
1791
1775
|
});
|
|
1792
1776
|
}
|
|
1793
1777
|
|
|
1778
|
+
function cmp(a, b) {
|
|
1779
|
+
try {
|
|
1780
|
+
var ta = type(a);
|
|
1781
|
+
var tb = type(b);
|
|
1782
|
+
if (ta !== tb) {
|
|
1783
|
+
if (ta === 'Array')
|
|
1784
|
+
return 1;
|
|
1785
|
+
if (tb === 'Array')
|
|
1786
|
+
return -1;
|
|
1787
|
+
if (ta === 'binary')
|
|
1788
|
+
return 1;
|
|
1789
|
+
if (tb === 'binary')
|
|
1790
|
+
return -1;
|
|
1791
|
+
if (ta === 'string')
|
|
1792
|
+
return 1;
|
|
1793
|
+
if (tb === 'string')
|
|
1794
|
+
return -1;
|
|
1795
|
+
if (ta === 'Date')
|
|
1796
|
+
return 1;
|
|
1797
|
+
if (tb !== 'Date')
|
|
1798
|
+
return NaN;
|
|
1799
|
+
return -1;
|
|
1800
|
+
}
|
|
1801
|
+
switch (ta) {
|
|
1802
|
+
case 'number':
|
|
1803
|
+
case 'Date':
|
|
1804
|
+
case 'string':
|
|
1805
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
|
1806
|
+
case 'binary': {
|
|
1807
|
+
return compareUint8Arrays(getUint8Array(a), getUint8Array(b));
|
|
1808
|
+
}
|
|
1809
|
+
case 'Array':
|
|
1810
|
+
return compareArrays(a, b);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
catch (_a) { }
|
|
1814
|
+
return NaN;
|
|
1815
|
+
}
|
|
1816
|
+
function compareArrays(a, b) {
|
|
1817
|
+
var al = a.length;
|
|
1818
|
+
var bl = b.length;
|
|
1819
|
+
var l = al < bl ? al : bl;
|
|
1820
|
+
for (var i = 0; i < l; ++i) {
|
|
1821
|
+
var res = cmp(a[i], b[i]);
|
|
1822
|
+
if (res !== 0)
|
|
1823
|
+
return res;
|
|
1824
|
+
}
|
|
1825
|
+
return al === bl ? 0 : al < bl ? -1 : 1;
|
|
1826
|
+
}
|
|
1827
|
+
function compareUint8Arrays(a, b) {
|
|
1828
|
+
var al = a.length;
|
|
1829
|
+
var bl = b.length;
|
|
1830
|
+
var l = al < bl ? al : bl;
|
|
1831
|
+
for (var i = 0; i < l; ++i) {
|
|
1832
|
+
if (a[i] !== b[i])
|
|
1833
|
+
return a[i] < b[i] ? -1 : 1;
|
|
1834
|
+
}
|
|
1835
|
+
return al === bl ? 0 : al < bl ? -1 : 1;
|
|
1836
|
+
}
|
|
1837
|
+
function type(x) {
|
|
1838
|
+
var t = typeof x;
|
|
1839
|
+
if (t !== 'object')
|
|
1840
|
+
return t;
|
|
1841
|
+
if (ArrayBuffer.isView(x))
|
|
1842
|
+
return 'binary';
|
|
1843
|
+
var tsTag = toStringTag(x);
|
|
1844
|
+
return tsTag === 'ArrayBuffer' ? 'binary' : tsTag;
|
|
1845
|
+
}
|
|
1846
|
+
function getUint8Array(a) {
|
|
1847
|
+
if (a instanceof Uint8Array)
|
|
1848
|
+
return a;
|
|
1849
|
+
if (ArrayBuffer.isView(a))
|
|
1850
|
+
return new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
|
|
1851
|
+
return new Uint8Array(a);
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1794
1854
|
var Collection = (function () {
|
|
1795
1855
|
function Collection() {
|
|
1796
1856
|
}
|
|
@@ -2074,7 +2134,6 @@ var Collection = (function () {
|
|
|
2074
2134
|
var coreTable = ctx.table.core;
|
|
2075
2135
|
var _a = coreTable.schema.primaryKey, outbound = _a.outbound, extractKey = _a.extractKey;
|
|
2076
2136
|
var limit = _this.db._options.modifyChunkSize || 200;
|
|
2077
|
-
var cmp = _this.db.core.cmp;
|
|
2078
2137
|
var totalFailures = [];
|
|
2079
2138
|
var successCount = 0;
|
|
2080
2139
|
var failedKeys = [];
|
|
@@ -2836,6 +2895,21 @@ function createTableSchema(name, primKey, indexes) {
|
|
|
2836
2895
|
};
|
|
2837
2896
|
}
|
|
2838
2897
|
|
|
2898
|
+
function safariMultiStoreFix(storeNames) {
|
|
2899
|
+
return storeNames.length === 1 ? storeNames[0] : storeNames;
|
|
2900
|
+
}
|
|
2901
|
+
var getMaxKey = function (IdbKeyRange) {
|
|
2902
|
+
try {
|
|
2903
|
+
IdbKeyRange.only([[]]);
|
|
2904
|
+
getMaxKey = function () { return [[]]; };
|
|
2905
|
+
return [[]];
|
|
2906
|
+
}
|
|
2907
|
+
catch (e) {
|
|
2908
|
+
getMaxKey = function () { return maxString; };
|
|
2909
|
+
return maxString;
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2839
2913
|
function getKeyExtractor(keyPath) {
|
|
2840
2914
|
if (keyPath == null) {
|
|
2841
2915
|
return function () { return undefined; };
|
|
@@ -2868,8 +2942,7 @@ function getKeyPathAlias(keyPath) {
|
|
|
2868
2942
|
keyPath :
|
|
2869
2943
|
"[" + keyPath.join('+') + "]";
|
|
2870
2944
|
}
|
|
2871
|
-
function createDBCore(db,
|
|
2872
|
-
var cmp = indexedDB.cmp.bind(indexedDB);
|
|
2945
|
+
function createDBCore(db, IdbKeyRange, tmpTrans) {
|
|
2873
2946
|
function extractSchema(db, trans) {
|
|
2874
2947
|
var tables = arrayify(db.objectStoreNames);
|
|
2875
2948
|
return {
|
|
@@ -3204,7 +3277,6 @@ function createDBCore(db, indexedDB, IdbKeyRange, tmpTrans) {
|
|
|
3204
3277
|
throw new Error("Table '" + name + "' not found");
|
|
3205
3278
|
return tableMap[name];
|
|
3206
3279
|
},
|
|
3207
|
-
cmp: cmp,
|
|
3208
3280
|
MIN_KEY: -Infinity,
|
|
3209
3281
|
MAX_KEY: getMaxKey(IdbKeyRange),
|
|
3210
3282
|
schema: schema
|
|
@@ -3218,8 +3290,8 @@ function createMiddlewareStack(stackImpl, middlewares) {
|
|
|
3218
3290
|
}, stackImpl);
|
|
3219
3291
|
}
|
|
3220
3292
|
function createMiddlewareStacks(middlewares, idbdb, _a, tmpTrans) {
|
|
3221
|
-
var IDBKeyRange = _a.IDBKeyRange
|
|
3222
|
-
var dbcore = createMiddlewareStack(createDBCore(idbdb,
|
|
3293
|
+
var IDBKeyRange = _a.IDBKeyRange; _a.indexedDB;
|
|
3294
|
+
var dbcore = createMiddlewareStack(createDBCore(idbdb, IDBKeyRange, tmpTrans), middlewares.dbcore);
|
|
3223
3295
|
return {
|
|
3224
3296
|
dbcore: dbcore
|
|
3225
3297
|
};
|
|
@@ -3445,12 +3517,9 @@ function createMissingTables(newSchema, idbtrans) {
|
|
|
3445
3517
|
});
|
|
3446
3518
|
}
|
|
3447
3519
|
function deleteRemovedTables(newSchema, idbtrans) {
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
idbtrans.db.deleteObjectStore(storeName);
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3520
|
+
[].slice.call(idbtrans.db.objectStoreNames).forEach(function (storeName) {
|
|
3521
|
+
return newSchema[storeName] == null && idbtrans.db.deleteObjectStore(storeName);
|
|
3522
|
+
});
|
|
3454
3523
|
}
|
|
3455
3524
|
function addIndex(store, idx) {
|
|
3456
3525
|
store.createIndex(idx.name, idx.keyPath, { unique: idx.unique, multiEntry: idx.multi });
|
|
@@ -3788,7 +3857,18 @@ function enterTransactionScope(db, mode, storeNames, parentTransaction, scopeFun
|
|
|
3788
3857
|
trans.idbtrans = parentTransaction.idbtrans;
|
|
3789
3858
|
}
|
|
3790
3859
|
else {
|
|
3791
|
-
|
|
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
|
+
}
|
|
3792
3872
|
}
|
|
3793
3873
|
var scopeFuncIsAsync = isAsyncFunction(scopeFunc);
|
|
3794
3874
|
if (scopeFuncIsAsync) {
|
|
@@ -4017,9 +4097,9 @@ var hooksMiddleware = {
|
|
|
4017
4097
|
throw new Error("Keys missing");
|
|
4018
4098
|
req = req.type === 'add' || req.type === 'put' ? __assign(__assign({}, req), { keys: keys }) : __assign({}, req);
|
|
4019
4099
|
if (req.type !== 'delete')
|
|
4020
|
-
req.values = __spreadArray([], req.values);
|
|
4100
|
+
req.values = __spreadArray([], req.values, true);
|
|
4021
4101
|
if (req.keys)
|
|
4022
|
-
req.keys = __spreadArray([], req.keys);
|
|
4102
|
+
req.keys = __spreadArray([], req.keys, true);
|
|
4023
4103
|
return getExistingValues(downTable, req, keys).then(function (existingValues) {
|
|
4024
4104
|
var contexts = keys.map(function (key, i) {
|
|
4025
4105
|
var existingValue = existingValues[i];
|
|
@@ -4105,24 +4185,6 @@ function getExistingValues(table, req, effectiveKeys) {
|
|
|
4105
4185
|
: table.getMany({ trans: req.trans, keys: effectiveKeys, cache: "immutable" });
|
|
4106
4186
|
}
|
|
4107
4187
|
|
|
4108
|
-
var _cmp;
|
|
4109
|
-
function cmp(a, b) {
|
|
4110
|
-
if (_cmp)
|
|
4111
|
-
return _cmp(a, b);
|
|
4112
|
-
var indexedDB = domDeps.indexedDB;
|
|
4113
|
-
if (!indexedDB)
|
|
4114
|
-
throw new exceptions.MissingAPI();
|
|
4115
|
-
_cmp = function (a, b) {
|
|
4116
|
-
try {
|
|
4117
|
-
return a == null || b == null ? NaN : indexedDB.cmp(a, b);
|
|
4118
|
-
}
|
|
4119
|
-
catch (_a) {
|
|
4120
|
-
return NaN;
|
|
4121
|
-
}
|
|
4122
|
-
};
|
|
4123
|
-
return _cmp(a, b);
|
|
4124
|
-
}
|
|
4125
|
-
|
|
4126
4188
|
function getFromTransactionCache(keys, cache, clone) {
|
|
4127
4189
|
try {
|
|
4128
4190
|
if (!cache)
|
|
@@ -4538,7 +4600,8 @@ var Dexie$1 = (function () {
|
|
|
4538
4600
|
dbReadyPromise: null,
|
|
4539
4601
|
cancelOpen: nop,
|
|
4540
4602
|
openCanceller: null,
|
|
4541
|
-
autoSchema: true
|
|
4603
|
+
autoSchema: true,
|
|
4604
|
+
PR1398_maxLoop: 3
|
|
4542
4605
|
};
|
|
4543
4606
|
state.dbReadyPromise = new DexiePromise(function (resolve) {
|
|
4544
4607
|
state.dbReadyResolve = resolve;
|
|
@@ -4814,7 +4877,7 @@ var Dexie$1 = (function () {
|
|
|
4814
4877
|
}());
|
|
4815
4878
|
|
|
4816
4879
|
var symbolObservable = typeof Symbol !== "undefined" && "observable" in Symbol
|
|
4817
|
-
? Symbol
|
|
4880
|
+
? Symbol.observable
|
|
4818
4881
|
: "@@observable";
|
|
4819
4882
|
var Observable = (function () {
|
|
4820
4883
|
function Observable(subscribe) {
|
|
@@ -4913,6 +4976,17 @@ function liveQuery(querier) {
|
|
|
4913
4976
|
});
|
|
4914
4977
|
}
|
|
4915
4978
|
|
|
4979
|
+
var domDeps;
|
|
4980
|
+
try {
|
|
4981
|
+
domDeps = {
|
|
4982
|
+
indexedDB: _global.indexedDB || _global.mozIndexedDB || _global.webkitIndexedDB || _global.msIndexedDB,
|
|
4983
|
+
IDBKeyRange: _global.IDBKeyRange || _global.webkitIDBKeyRange
|
|
4984
|
+
};
|
|
4985
|
+
}
|
|
4986
|
+
catch (e) {
|
|
4987
|
+
domDeps = { indexedDB: null, IDBKeyRange: null };
|
|
4988
|
+
}
|
|
4989
|
+
|
|
4916
4990
|
var Dexie = Dexie$1;
|
|
4917
4991
|
props(Dexie, __assign(__assign({}, fullNameExceptions), {
|
|
4918
4992
|
delete: function (databaseName) {
|
|
@@ -4985,7 +5059,7 @@ props(Dexie, __assign(__assign({}, fullNameExceptions), {
|
|
|
4985
5059
|
},
|
|
4986
5060
|
derive: derive, extend: extend, props: props, override: override,
|
|
4987
5061
|
Events: Events, on: globalEvents, liveQuery: liveQuery, extendObservabilitySet: extendObservabilitySet,
|
|
4988
|
-
getByKeyPath: getByKeyPath, setByKeyPath: setByKeyPath, delByKeyPath: delByKeyPath, shallowClone: shallowClone, deepClone: deepClone, getObjectDiff: getObjectDiff, asap: asap$1,
|
|
5062
|
+
getByKeyPath: getByKeyPath, setByKeyPath: setByKeyPath, delByKeyPath: delByKeyPath, shallowClone: shallowClone, deepClone: deepClone, getObjectDiff: getObjectDiff, cmp: cmp, asap: asap$1,
|
|
4989
5063
|
minKey: minKey,
|
|
4990
5064
|
addons: [],
|
|
4991
5065
|
connections: connections,
|
|
@@ -5056,7 +5130,7 @@ else if (typeof self !== 'undefined' && typeof navigator !== 'undefined') {
|
|
|
5056
5130
|
}));
|
|
5057
5131
|
}
|
|
5058
5132
|
if (typeof self['clients'] === 'object') {
|
|
5059
|
-
__spreadArray([], self['clients'].matchAll({ includeUncontrolled: true })).forEach(function (client) {
|
|
5133
|
+
__spreadArray([], self['clients'].matchAll({ includeUncontrolled: true }), true).forEach(function (client) {
|
|
5060
5134
|
return client.postMessage({
|
|
5061
5135
|
type: STORAGE_MUTATED_DOM_EVENT_NAME,
|
|
5062
5136
|
changedParts: changedParts,
|
|
@@ -5089,6 +5163,5 @@ function propagateMessageLocally(_a) {
|
|
|
5089
5163
|
DexiePromise.rejectionMapper = mapError;
|
|
5090
5164
|
setDebug(debug, dexieStackFrameFilter);
|
|
5091
5165
|
|
|
5092
|
-
export
|
|
5093
|
-
export { Dexie$1 as Dexie, RangeSet, liveQuery, mergeRanges, rangesOverlap };
|
|
5166
|
+
export { Dexie$1 as Dexie, RangeSet, Dexie$1 as default, liveQuery, mergeRanges, rangesOverlap };
|
|
5094
5167
|
//# sourceMappingURL=dexie.mjs.map
|