dexie 4.0.1-alpha.19 → 4.0.1-alpha.21

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.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-alpha.19, Wed Jun 07 2023
7
+ * Version 4.0.1-alpha.21+test1, Wed Jun 14 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1278,7 +1278,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1278
1278
  }
1279
1279
  }
1280
1280
 
1281
- var DEXIE_VERSION = '4.0.1-alpha.19';
1281
+ var DEXIE_VERSION = '4.0.1-alpha.21+test1';
1282
1282
  var maxString = String.fromCharCode(65535);
1283
1283
  var minKey = -Infinity;
1284
1284
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -1444,14 +1444,22 @@ var Table = (function () {
1444
1444
  .where(keyPaths[0])
1445
1445
  .equals(indexOrCrit[keyPaths[0]]);
1446
1446
  var compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(function (ix) {
1447
- return ix.compound &&
1448
- keyPaths.every(function (keyPath) { return ix.keyPath.indexOf(keyPath) >= 0; }) &&
1449
- ix.keyPath.every(function (keyPath) { return keyPaths.indexOf(keyPath) >= 0; });
1450
- })[0];
1451
- if (compoundIndex && this.db._maxKey !== maxString)
1447
+ if (ix.compound &&
1448
+ keyPaths.every(function (keyPath) { return ix.keyPath.indexOf(keyPath) >= 0; })) {
1449
+ for (var i = 0; i < keyPaths.length; ++i) {
1450
+ if (keyPaths.indexOf(ix.keyPath[i]) === -1)
1451
+ return false;
1452
+ }
1453
+ return true;
1454
+ }
1455
+ return false;
1456
+ }).sort(function (a, b) { return a.keyPath.length - b.keyPath.length; })[0];
1457
+ if (compoundIndex && this.db._maxKey !== maxString) {
1458
+ var keyPathsInValidOrder = compoundIndex.keyPath.slice(0, keyPaths.length);
1452
1459
  return this
1453
- .where(compoundIndex.name)
1454
- .equals(compoundIndex.keyPath.map(function (kp) { return indexOrCrit[kp]; }));
1460
+ .where(keyPathsInValidOrder)
1461
+ .equals(keyPathsInValidOrder.map(function (kp) { return indexOrCrit[kp]; }));
1462
+ }
1455
1463
  if (!compoundIndex && debug)
1456
1464
  console.warn("The query ".concat(JSON.stringify(indexOrCrit), " on ").concat(this.name, " would benefit of a ") +
1457
1465
  "compound index [".concat(keyPaths.join('+'), "]"));
@@ -4587,9 +4595,6 @@ var observabilityMiddleware = {
4587
4595
  ? req.obsSet = {}
4588
4596
  : subscr;
4589
4597
  if (isLiveQuery) {
4590
- var signal = PSD.signal;
4591
- if (signal && signal.aborted)
4592
- throw new exceptions.Abort();
4593
4598
  var getRangeSet = function (indexName) {
4594
4599
  var part = "idb://".concat(dbName, "/").concat(tableName, "/").concat(indexName);
4595
4600
  return (obsSet[part] ||
@@ -4942,15 +4947,10 @@ var cacheMiddleware = {
4942
4947
  var dbName = core.schema.name;
4943
4948
  var coreMW = __assign(__assign({}, core), { transaction: function (stores, mode, options) {
4944
4949
  var idbtrans = core.transaction(stores, mode, options);
4945
- var txs = PSD.txs;
4946
- if (txs || mode === 'readwrite') {
4947
- if (txs)
4948
- txs.push(idbtrans);
4950
+ if (mode === 'readwrite') {
4949
4951
  var ac_1 = new AbortController();
4950
4952
  var signal = ac_1.signal;
4951
4953
  var endTransaction = function (wasCommitted) { return function () {
4952
- if (txs)
4953
- delArrayItem(txs, idbtrans);
4954
4954
  ac_1.abort();
4955
4955
  if (mode === 'readwrite') {
4956
4956
  var affectedSubscribers_1 = new Set();
@@ -5072,13 +5072,7 @@ var cacheMiddleware = {
5072
5072
  });
5073
5073
  cacheEntry = {
5074
5074
  obsSet: req.obsSet,
5075
- promise: promise.catch(function (error) {
5076
- if (req.trans.aborted) {
5077
- var trans = coreMW.transaction([tableName], 'readonly');
5078
- return tableMW.query(__assign(__assign({}, req), { trans: trans }));
5079
- }
5080
- return Promise.reject(error);
5081
- }),
5075
+ promise: promise,
5082
5076
  subscribers: new Set(),
5083
5077
  type: 'query',
5084
5078
  req: req,
@@ -5468,7 +5462,6 @@ function liveQuery(querier) {
5468
5462
  }
5469
5463
  var closed = false;
5470
5464
  var abortController;
5471
- var txs = [];
5472
5465
  var accumMuts = {};
5473
5466
  var currentObs = {};
5474
5467
  var subscription = {
@@ -5483,13 +5476,6 @@ function liveQuery(querier) {
5483
5476
  abortController.abort();
5484
5477
  if (startedListening)
5485
5478
  globalEvents.storagemutated.unsubscribe(mutationListener);
5486
- txs.forEach(function (idbtrans) {
5487
- idbtrans.aborted = true;
5488
- try {
5489
- idbtrans.abort();
5490
- }
5491
- catch (_a) { }
5492
- });
5493
5479
  },
5494
5480
  };
5495
5481
  observer.start && observer.start(subscription);
@@ -5514,19 +5500,8 @@ function liveQuery(querier) {
5514
5500
  if (abortController)
5515
5501
  abortController.abort();
5516
5502
  abortController = new AbortController();
5517
- if (txs.length) {
5518
- txs.forEach(function (idbtrans) {
5519
- idbtrans.aborted = true;
5520
- try {
5521
- idbtrans.abort();
5522
- }
5523
- catch (_a) { }
5524
- });
5525
- txs.length = 0;
5526
- }
5527
5503
  var ctx = {
5528
5504
  subscr: subscr,
5529
- txs: txs,
5530
5505
  signal: abortController.signal,
5531
5506
  requery: doQuery,
5532
5507
  trans: null