dexie 3.2.1 → 4.0.0-alpha.3
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/README.md +2 -2
- package/SECURITY.md +3 -2
- package/dist/dexie.d.ts +188 -143
- package/dist/dexie.js +81 -36
- 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 +80 -37
- 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 +40 -19
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dexie.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version
|
|
7
|
+
* Version 4.0.0-alpha.3, Wed Apr 27 2022
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -29,6 +29,19 @@
|
|
|
29
29
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
30
30
|
PERFORMANCE OF THIS SOFTWARE.
|
|
31
31
|
***************************************************************************** */
|
|
32
|
+
var extendStatics = function(d, b) {
|
|
33
|
+
extendStatics = Object.setPrototypeOf ||
|
|
34
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
35
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
36
|
+
return extendStatics(d, b);
|
|
37
|
+
};
|
|
38
|
+
function __extends(d, b) {
|
|
39
|
+
if (typeof b !== "function" && b !== null)
|
|
40
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
41
|
+
extendStatics(d, b);
|
|
42
|
+
function __() { this.constructor = d; }
|
|
43
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
44
|
+
}
|
|
32
45
|
var __assign = function() {
|
|
33
46
|
__assign = Object.assign || function __assign(t) {
|
|
34
47
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -182,7 +195,7 @@
|
|
|
182
195
|
obj[currentKeyPath] = value;
|
|
183
196
|
else {
|
|
184
197
|
var innerObj = obj[currentKeyPath];
|
|
185
|
-
if (!innerObj)
|
|
198
|
+
if (!innerObj || !hasOwn(obj, currentKeyPath))
|
|
186
199
|
innerObj = (obj[currentKeyPath] = {});
|
|
187
200
|
setByKeyPath(innerObj, remainingKeyPath, value);
|
|
188
201
|
}
|
|
@@ -427,11 +440,11 @@
|
|
|
427
440
|
this.inner = null;
|
|
428
441
|
}
|
|
429
442
|
else if (typeof msgOrInner === 'string') {
|
|
430
|
-
this.message = ""
|
|
443
|
+
this.message = "".concat(msgOrInner).concat(!inner ? '' : '\n ' + inner);
|
|
431
444
|
this.inner = inner || null;
|
|
432
445
|
}
|
|
433
446
|
else if (typeof msgOrInner === 'object') {
|
|
434
|
-
this.message = msgOrInner.name
|
|
447
|
+
this.message = "".concat(msgOrInner.name, " ").concat(msgOrInner.message);
|
|
435
448
|
this.inner = msgOrInner;
|
|
436
449
|
}
|
|
437
450
|
}
|
|
@@ -1243,7 +1256,7 @@
|
|
|
1243
1256
|
catch (_) { }
|
|
1244
1257
|
}
|
|
1245
1258
|
if (debug && event && !event.defaultPrevented) {
|
|
1246
|
-
console.warn("Unhandled rejection: "
|
|
1259
|
+
console.warn("Unhandled rejection: ".concat(err.stack || err));
|
|
1247
1260
|
}
|
|
1248
1261
|
}
|
|
1249
1262
|
catch (e) { }
|
|
@@ -1287,7 +1300,7 @@
|
|
|
1287
1300
|
}
|
|
1288
1301
|
}
|
|
1289
1302
|
|
|
1290
|
-
var DEXIE_VERSION = '
|
|
1303
|
+
var DEXIE_VERSION = '4.0.0-alpha.3';
|
|
1291
1304
|
var maxString = String.fromCharCode(65535);
|
|
1292
1305
|
var minKey = -Infinity;
|
|
1293
1306
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1329,6 +1342,10 @@
|
|
|
1329
1342
|
: function (obj) { return obj; };
|
|
1330
1343
|
}
|
|
1331
1344
|
|
|
1345
|
+
function Entity() {
|
|
1346
|
+
throw exceptions.Type();
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1332
1349
|
var Table = (function () {
|
|
1333
1350
|
function Table() {
|
|
1334
1351
|
}
|
|
@@ -1366,7 +1383,7 @@
|
|
|
1366
1383
|
if (typeof indexOrCrit === 'string')
|
|
1367
1384
|
return new this.db.WhereClause(this, indexOrCrit);
|
|
1368
1385
|
if (isArray(indexOrCrit))
|
|
1369
|
-
return new this.db.WhereClause(this, "["
|
|
1386
|
+
return new this.db.WhereClause(this, "[".concat(indexOrCrit.join('+'), "]"));
|
|
1370
1387
|
var keyPaths = keys(indexOrCrit);
|
|
1371
1388
|
if (keyPaths.length === 1)
|
|
1372
1389
|
return this
|
|
@@ -1382,8 +1399,8 @@
|
|
|
1382
1399
|
.where(compoundIndex.name)
|
|
1383
1400
|
.equals(compoundIndex.keyPath.map(function (kp) { return indexOrCrit[kp]; }));
|
|
1384
1401
|
if (!compoundIndex && debug)
|
|
1385
|
-
console.warn("The query "
|
|
1386
|
-
|
|
1402
|
+
console.warn("The query ".concat(JSON.stringify(indexOrCrit), " on ").concat(this.name, " would benefit of a ") +
|
|
1403
|
+
"compound index [".concat(keyPaths.join('+'), "]"));
|
|
1387
1404
|
var idxByName = this.schema.idxByName;
|
|
1388
1405
|
var idb = this.db._deps.indexedDB;
|
|
1389
1406
|
function equals(a, b) {
|
|
@@ -1439,20 +1456,40 @@
|
|
|
1439
1456
|
};
|
|
1440
1457
|
Table.prototype.orderBy = function (index) {
|
|
1441
1458
|
return new this.db.Collection(new this.db.WhereClause(this, isArray(index) ?
|
|
1442
|
-
"["
|
|
1459
|
+
"[".concat(index.join('+'), "]") :
|
|
1443
1460
|
index));
|
|
1444
1461
|
};
|
|
1445
1462
|
Table.prototype.reverse = function () {
|
|
1446
1463
|
return this.toCollection().reverse();
|
|
1447
1464
|
};
|
|
1448
1465
|
Table.prototype.mapToClass = function (constructor) {
|
|
1466
|
+
var _a = this, db = _a.db, tableName = _a.name;
|
|
1449
1467
|
this.schema.mappedClass = constructor;
|
|
1468
|
+
if (constructor.prototype instanceof Entity) {
|
|
1469
|
+
constructor = (function (_super) {
|
|
1470
|
+
__extends(class_1, _super);
|
|
1471
|
+
function class_1() {
|
|
1472
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1473
|
+
}
|
|
1474
|
+
Object.defineProperty(class_1.prototype, "db", {
|
|
1475
|
+
get: function () { return db; },
|
|
1476
|
+
enumerable: false,
|
|
1477
|
+
configurable: true
|
|
1478
|
+
});
|
|
1479
|
+
class_1.prototype.table = function () { return tableName; };
|
|
1480
|
+
return class_1;
|
|
1481
|
+
}(constructor));
|
|
1482
|
+
}
|
|
1483
|
+
var inheritedProps = new Set();
|
|
1484
|
+
for (var proto = constructor.prototype; proto; proto = getProto(proto)) {
|
|
1485
|
+
Object.getOwnPropertyNames(proto).forEach(function (propName) { return inheritedProps.add(propName); });
|
|
1486
|
+
}
|
|
1450
1487
|
var readHook = function (obj) {
|
|
1451
1488
|
if (!obj)
|
|
1452
1489
|
return obj;
|
|
1453
1490
|
var res = Object.create(constructor.prototype);
|
|
1454
1491
|
for (var m in obj)
|
|
1455
|
-
if (
|
|
1492
|
+
if (!inheritedProps.has(m))
|
|
1456
1493
|
try {
|
|
1457
1494
|
res[m] = obj[m];
|
|
1458
1495
|
}
|
|
@@ -1574,7 +1611,7 @@
|
|
|
1574
1611
|
var result = wantResults ? results : lastResult;
|
|
1575
1612
|
if (numFailures === 0)
|
|
1576
1613
|
return result;
|
|
1577
|
-
throw new BulkError(_this.name
|
|
1614
|
+
throw new BulkError("".concat(_this.name, ".bulkAdd(): ").concat(numFailures, " of ").concat(numObjects, " operations failed"), failures);
|
|
1578
1615
|
});
|
|
1579
1616
|
});
|
|
1580
1617
|
};
|
|
@@ -1599,7 +1636,7 @@
|
|
|
1599
1636
|
var result = wantResults ? results : lastResult;
|
|
1600
1637
|
if (numFailures === 0)
|
|
1601
1638
|
return result;
|
|
1602
|
-
throw new BulkError(_this.name
|
|
1639
|
+
throw new BulkError("".concat(_this.name, ".bulkPut(): ").concat(numFailures, " of ").concat(numObjects, " operations failed"), failures);
|
|
1603
1640
|
});
|
|
1604
1641
|
});
|
|
1605
1642
|
};
|
|
@@ -1612,7 +1649,7 @@
|
|
|
1612
1649
|
var numFailures = _a.numFailures, lastResult = _a.lastResult, failures = _a.failures;
|
|
1613
1650
|
if (numFailures === 0)
|
|
1614
1651
|
return lastResult;
|
|
1615
|
-
throw new BulkError(_this.name
|
|
1652
|
+
throw new BulkError("".concat(_this.name, ".bulkDelete(): ").concat(numFailures, " of ").concat(numKeys, " operations failed"), failures);
|
|
1616
1653
|
});
|
|
1617
1654
|
};
|
|
1618
1655
|
return Table;
|
|
@@ -2946,7 +2983,7 @@
|
|
|
2946
2983
|
":id" :
|
|
2947
2984
|
typeof keyPath === 'string' ?
|
|
2948
2985
|
keyPath :
|
|
2949
|
-
"["
|
|
2986
|
+
"[".concat(keyPath.join('+'), "]");
|
|
2950
2987
|
}
|
|
2951
2988
|
function createDBCore(db, IdbKeyRange, tmpTrans) {
|
|
2952
2989
|
function extractSchema(db, trans) {
|
|
@@ -3280,7 +3317,7 @@
|
|
|
3280
3317
|
table: function (name) {
|
|
3281
3318
|
var result = tableMap[name];
|
|
3282
3319
|
if (!result)
|
|
3283
|
-
throw new Error("Table '"
|
|
3320
|
+
throw new Error("Table '".concat(name, "' not found"));
|
|
3284
3321
|
return tableMap[name];
|
|
3285
3322
|
},
|
|
3286
3323
|
MIN_KEY: -Infinity,
|
|
@@ -3753,7 +3790,7 @@
|
|
|
3753
3790
|
req.result.close();
|
|
3754
3791
|
var delreq = indexedDB.deleteDatabase(dbName);
|
|
3755
3792
|
delreq.onsuccess = delreq.onerror = wrap(function () {
|
|
3756
|
-
reject(new exceptions.NoSuchDatabase("Database "
|
|
3793
|
+
reject(new exceptions.NoSuchDatabase("Database ".concat(dbName, " doesnt exist")));
|
|
3757
3794
|
});
|
|
3758
3795
|
}
|
|
3759
3796
|
else {
|
|
@@ -4419,7 +4456,7 @@
|
|
|
4419
4456
|
var trans = req.trans;
|
|
4420
4457
|
var mutatedParts = trans.mutatedParts || (trans.mutatedParts = {});
|
|
4421
4458
|
var getRangeSet = function (indexName) {
|
|
4422
|
-
var part = "idb://"
|
|
4459
|
+
var part = "idb://".concat(dbName, "/").concat(tableName, "/").concat(indexName);
|
|
4423
4460
|
return (mutatedParts[part] ||
|
|
4424
4461
|
(mutatedParts[part] = new RangeSet()));
|
|
4425
4462
|
};
|
|
@@ -4480,7 +4517,7 @@
|
|
|
4480
4517
|
var subscr = PSD.subscr;
|
|
4481
4518
|
if (subscr) {
|
|
4482
4519
|
var getRangeSet = function (indexName) {
|
|
4483
|
-
var part = "idb://"
|
|
4520
|
+
var part = "idb://".concat(dbName, "/").concat(tableName, "/").concat(indexName);
|
|
4484
4521
|
return (subscr[part] ||
|
|
4485
4522
|
(subscr[part] = new RangeSet()));
|
|
4486
4523
|
};
|
|
@@ -4652,16 +4689,16 @@
|
|
|
4652
4689
|
this.WhereClause = createWhereClauseConstructor(this);
|
|
4653
4690
|
this.on("versionchange", function (ev) {
|
|
4654
4691
|
if (ev.newVersion > 0)
|
|
4655
|
-
console.warn("Another connection wants to upgrade database '"
|
|
4692
|
+
console.warn("Another connection wants to upgrade database '".concat(_this.name, "'. Closing db now to resume the upgrade."));
|
|
4656
4693
|
else
|
|
4657
|
-
console.warn("Another connection wants to delete database '"
|
|
4694
|
+
console.warn("Another connection wants to delete database '".concat(_this.name, "'. Closing db now to resume the delete request."));
|
|
4658
4695
|
_this.close();
|
|
4659
4696
|
});
|
|
4660
4697
|
this.on("blocked", function (ev) {
|
|
4661
4698
|
if (!ev.newVersion || ev.newVersion < ev.oldVersion)
|
|
4662
|
-
console.warn("Dexie.delete('"
|
|
4699
|
+
console.warn("Dexie.delete('".concat(_this.name, "') was blocked"));
|
|
4663
4700
|
else
|
|
4664
|
-
console.warn("Upgrade '"
|
|
4701
|
+
console.warn("Upgrade '".concat(_this.name, "' blocked by other connection holding version ").concat(ev.oldVersion / 10));
|
|
4665
4702
|
});
|
|
4666
4703
|
this._maxKey = getMaxKey(options.IDBKeyRange);
|
|
4667
4704
|
this._createTransaction = function (mode, storeNames, dbschema, parentTransaction) { return new _this.Transaction(mode, storeNames, dbschema, _this._options.chromeTransactionDurability, parentTransaction); };
|
|
@@ -4875,7 +4912,7 @@
|
|
|
4875
4912
|
};
|
|
4876
4913
|
Dexie.prototype.table = function (tableName) {
|
|
4877
4914
|
if (!hasOwn(this._allTables, tableName)) {
|
|
4878
|
-
throw new exceptions.InvalidTable("Table "
|
|
4915
|
+
throw new exceptions.InvalidTable("Table ".concat(tableName, " does not exist"));
|
|
4879
4916
|
}
|
|
4880
4917
|
return this._allTables[tableName];
|
|
4881
4918
|
};
|
|
@@ -4949,8 +4986,9 @@
|
|
|
4949
4986
|
}
|
|
4950
4987
|
};
|
|
4951
4988
|
var doQuery = function () {
|
|
4952
|
-
if (querying || closed)
|
|
4989
|
+
if (querying || closed) {
|
|
4953
4990
|
return;
|
|
4991
|
+
}
|
|
4954
4992
|
accumMuts = {};
|
|
4955
4993
|
var subscr = {};
|
|
4956
4994
|
var ret = execute(subscr);
|
|
@@ -4961,8 +4999,9 @@
|
|
|
4961
4999
|
querying = true;
|
|
4962
5000
|
Promise.resolve(ret).then(function (result) {
|
|
4963
5001
|
querying = false;
|
|
4964
|
-
if (closed)
|
|
5002
|
+
if (closed) {
|
|
4965
5003
|
return;
|
|
5004
|
+
}
|
|
4966
5005
|
if (shouldNotify()) {
|
|
4967
5006
|
doQuery();
|
|
4968
5007
|
}
|
|
@@ -4972,9 +5011,11 @@
|
|
|
4972
5011
|
observer.next && observer.next(result);
|
|
4973
5012
|
}
|
|
4974
5013
|
}, function (err) {
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
5014
|
+
if (!['DatabaseClosedError', 'AbortError'].includes(err === null || err === void 0 ? void 0 : err.name)) {
|
|
5015
|
+
querying = false;
|
|
5016
|
+
observer.error && observer.error(err);
|
|
5017
|
+
subscription.unsubscribe();
|
|
5018
|
+
}
|
|
4978
5019
|
});
|
|
4979
5020
|
};
|
|
4980
5021
|
doQuery();
|
|
@@ -5147,13 +5188,15 @@
|
|
|
5147
5188
|
}
|
|
5148
5189
|
catch (_a) { }
|
|
5149
5190
|
});
|
|
5150
|
-
addEventListener
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5191
|
+
if (typeof addEventListener !== 'undefined') {
|
|
5192
|
+
addEventListener('storage', function (ev) {
|
|
5193
|
+
if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {
|
|
5194
|
+
var data = JSON.parse(ev.newValue);
|
|
5195
|
+
if (data)
|
|
5196
|
+
propagateLocally(data.changedParts);
|
|
5197
|
+
}
|
|
5198
|
+
});
|
|
5199
|
+
}
|
|
5157
5200
|
var swContainer = self.document && navigator.serviceWorker;
|
|
5158
5201
|
if (swContainer) {
|
|
5159
5202
|
swContainer.addEventListener('message', propagateMessageLocally);
|
|
@@ -5173,6 +5216,8 @@
|
|
|
5173
5216
|
__proto__: null,
|
|
5174
5217
|
Dexie: Dexie$1,
|
|
5175
5218
|
liveQuery: liveQuery,
|
|
5219
|
+
Entity: Entity,
|
|
5220
|
+
cmp: cmp,
|
|
5176
5221
|
'default': Dexie$1,
|
|
5177
5222
|
RangeSet: RangeSet,
|
|
5178
5223
|
mergeRanges: mergeRanges,
|