dexie 4.0.1-alpha.11 → 4.0.1-alpha.12
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.d.ts +3 -1
- package/dist/dexie.js +57 -26
- 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 +57 -26
- 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 +57 -26
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dexie.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.1-alpha.
|
|
7
|
+
* Version 4.0.1-alpha.12, Tue May 30 2023
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -987,6 +987,8 @@ export interface Unsubscribable {
|
|
|
987
987
|
export interface Observable<T = any> {
|
|
988
988
|
subscribe(observerOrNext?: Observer<T> | ((value: T) => void)): Subscription;
|
|
989
989
|
subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
|
|
990
|
+
getValue?(): T;
|
|
991
|
+
hasValue?(): boolean;
|
|
990
992
|
[Symbol.observable]: () => Subscribable<T>;
|
|
991
993
|
}
|
|
992
994
|
export interface Subscription {
|
package/dist/dexie.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.1-alpha.
|
|
7
|
+
* Version 4.0.1-alpha.12, Tue May 30 2023
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -282,6 +282,12 @@
|
|
|
282
282
|
var i;
|
|
283
283
|
return x != null && (i = x[iteratorSymbol]) && i.apply(x);
|
|
284
284
|
} : function () { return null; };
|
|
285
|
+
function delArrayItem(a, x) {
|
|
286
|
+
var i = a.indexOf(x);
|
|
287
|
+
if (i >= 0)
|
|
288
|
+
a.splice(i, 1);
|
|
289
|
+
return i >= 0;
|
|
290
|
+
}
|
|
285
291
|
var NO_CHAR_ARRAY = {};
|
|
286
292
|
function getArrayOf(arrayLike) {
|
|
287
293
|
var i, a, x, it;
|
|
@@ -1254,13 +1260,17 @@
|
|
|
1254
1260
|
return fn(resolve, reject, trans);
|
|
1255
1261
|
});
|
|
1256
1262
|
}).then(function (result) {
|
|
1257
|
-
|
|
1263
|
+
if (mode === 'readwrite')
|
|
1264
|
+
try {
|
|
1265
|
+
trans.idbtrans.commit();
|
|
1266
|
+
}
|
|
1267
|
+
catch (_a) { }
|
|
1258
1268
|
return mode === 'readonly' ? result : trans._completion.then(function () { return result; });
|
|
1259
1269
|
});
|
|
1260
1270
|
}
|
|
1261
1271
|
}
|
|
1262
1272
|
|
|
1263
|
-
var DEXIE_VERSION = '4.0.1-alpha.
|
|
1273
|
+
var DEXIE_VERSION = '4.0.1-alpha.12';
|
|
1264
1274
|
var maxString = String.fromCharCode(65535);
|
|
1265
1275
|
var minKey = -Infinity;
|
|
1266
1276
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -4882,9 +4892,7 @@
|
|
|
4882
4892
|
function enqueForDeletion(cacheEntry, container) {
|
|
4883
4893
|
setTimeout(function () {
|
|
4884
4894
|
if (cacheEntry.subscribers.size === 0) {
|
|
4885
|
-
|
|
4886
|
-
if (pos > -1)
|
|
4887
|
-
container.splice(pos, 1);
|
|
4895
|
+
delArrayItem(container, cacheEntry);
|
|
4888
4896
|
}
|
|
4889
4897
|
}, 3000);
|
|
4890
4898
|
}
|
|
@@ -4895,7 +4903,7 @@
|
|
|
4895
4903
|
name: 'Cache',
|
|
4896
4904
|
create: function (core) {
|
|
4897
4905
|
var dbName = core.schema.name;
|
|
4898
|
-
|
|
4906
|
+
var coreMW = __assign(__assign({}, core), { transaction: function (stores, mode, options) {
|
|
4899
4907
|
var idbtrans = core.transaction(stores, mode, options);
|
|
4900
4908
|
var txs = PSD.txs;
|
|
4901
4909
|
if (txs || mode === 'readwrite') {
|
|
@@ -4904,11 +4912,8 @@
|
|
|
4904
4912
|
var ac_1 = new AbortController();
|
|
4905
4913
|
var signal = ac_1.signal;
|
|
4906
4914
|
var endTransaction = function (wasCommitted) { return function () {
|
|
4907
|
-
if (txs)
|
|
4908
|
-
|
|
4909
|
-
if (idx > -1)
|
|
4910
|
-
txs.splice(idx, 1);
|
|
4911
|
-
}
|
|
4915
|
+
if (txs)
|
|
4916
|
+
delArrayItem(txs, idbtrans);
|
|
4912
4917
|
ac_1.abort();
|
|
4913
4918
|
if (mode === 'readwrite') {
|
|
4914
4919
|
for (var _i = 0, stores_1 = stores; _i < stores_1.length; _i++) {
|
|
@@ -4930,7 +4935,7 @@
|
|
|
4930
4935
|
var freezeResults = Object.isFrozen(entry.res);
|
|
4931
4936
|
var modRes = applyOptimisticOps(entry.res, entry.req, ops, table, entry, freezeResults);
|
|
4932
4937
|
if (entry.dirty) {
|
|
4933
|
-
|
|
4938
|
+
delArrayItem(entries, entry);
|
|
4934
4939
|
entry.subscribers.forEach(function (requery) { return requery(); });
|
|
4935
4940
|
}
|
|
4936
4941
|
else if (modRes !== entry.res) {
|
|
@@ -4940,7 +4945,7 @@
|
|
|
4940
4945
|
}
|
|
4941
4946
|
else {
|
|
4942
4947
|
if (entry.dirty) {
|
|
4943
|
-
|
|
4948
|
+
delArrayItem(entries, entry);
|
|
4944
4949
|
}
|
|
4945
4950
|
entry.subscribers.forEach(function (requery) { return requery(); });
|
|
4946
4951
|
}
|
|
@@ -4966,7 +4971,7 @@
|
|
|
4966
4971
|
}, table: function (tableName) {
|
|
4967
4972
|
var downTable = core.table(tableName);
|
|
4968
4973
|
var primKey = downTable.schema.primaryKey;
|
|
4969
|
-
|
|
4974
|
+
var tableMW = __assign(__assign({}, downTable), { mutate: function (req) {
|
|
4970
4975
|
if (primKey.outbound ||
|
|
4971
4976
|
PSD.trans.db._options.cache === 'disabled'
|
|
4972
4977
|
) {
|
|
@@ -4993,7 +4998,7 @@
|
|
|
4993
4998
|
tblCache.optimisticOps.push(req);
|
|
4994
4999
|
signalSubscribers(tblCache, req.mutatedParts);
|
|
4995
5000
|
promise.catch(function () {
|
|
4996
|
-
|
|
5001
|
+
delArrayItem(tblCache.optimisticOps, req);
|
|
4997
5002
|
signalSubscribers(tblCache, req.mutatedParts);
|
|
4998
5003
|
});
|
|
4999
5004
|
}
|
|
@@ -5021,10 +5026,20 @@
|
|
|
5021
5026
|
res.result = deepClone(result);
|
|
5022
5027
|
}
|
|
5023
5028
|
return res;
|
|
5029
|
+
}).catch(function (error) {
|
|
5030
|
+
if (container && cacheEntry)
|
|
5031
|
+
delArrayItem(container, cacheEntry);
|
|
5032
|
+
return Promise.reject(error);
|
|
5024
5033
|
});
|
|
5025
5034
|
cacheEntry = {
|
|
5026
5035
|
obsSet: req.obsSet,
|
|
5027
|
-
promise: promise
|
|
5036
|
+
promise: promise.catch(function (error) {
|
|
5037
|
+
if (req.trans.aborted) {
|
|
5038
|
+
var trans = coreMW.transaction([tableName], 'readonly');
|
|
5039
|
+
return tableMW.query(__assign(__assign({}, req), { trans: trans }));
|
|
5040
|
+
}
|
|
5041
|
+
return Promise.reject(error);
|
|
5042
|
+
}),
|
|
5028
5043
|
subscribers: new Set(),
|
|
5029
5044
|
type: 'query',
|
|
5030
5045
|
req: req,
|
|
@@ -5056,7 +5071,9 @@
|
|
|
5056
5071
|
};
|
|
5057
5072
|
});
|
|
5058
5073
|
} });
|
|
5074
|
+
return tableMW;
|
|
5059
5075
|
} });
|
|
5076
|
+
return coreMW;
|
|
5060
5077
|
},
|
|
5061
5078
|
};
|
|
5062
5079
|
|
|
@@ -5394,7 +5411,9 @@
|
|
|
5394
5411
|
}
|
|
5395
5412
|
|
|
5396
5413
|
function liveQuery(querier) {
|
|
5397
|
-
|
|
5414
|
+
var hasValue = false;
|
|
5415
|
+
var currentValue = undefined;
|
|
5416
|
+
var observable = new Observable(function (observer) {
|
|
5398
5417
|
var scopeFuncIsAsync = isAsyncFunction(querier);
|
|
5399
5418
|
function execute(ctx) {
|
|
5400
5419
|
if (scopeFuncIsAsync) {
|
|
@@ -5420,10 +5439,13 @@
|
|
|
5420
5439
|
if (abortController)
|
|
5421
5440
|
abortController.abort();
|
|
5422
5441
|
globalEvents.storagemutated.unsubscribe(mutationListener);
|
|
5423
|
-
txs.forEach(function (idbtrans) {
|
|
5424
|
-
idbtrans.
|
|
5425
|
-
|
|
5426
|
-
|
|
5442
|
+
txs.forEach(function (idbtrans) {
|
|
5443
|
+
idbtrans.aborted = true;
|
|
5444
|
+
try {
|
|
5445
|
+
idbtrans.abort();
|
|
5446
|
+
}
|
|
5447
|
+
catch (_a) { }
|
|
5448
|
+
});
|
|
5427
5449
|
},
|
|
5428
5450
|
};
|
|
5429
5451
|
observer.start && observer.start(subscription);
|
|
@@ -5449,10 +5471,13 @@
|
|
|
5449
5471
|
abortController.abort();
|
|
5450
5472
|
abortController = new AbortController();
|
|
5451
5473
|
if (txs.length) {
|
|
5452
|
-
txs.forEach(function (idbtrans) {
|
|
5453
|
-
idbtrans.
|
|
5454
|
-
|
|
5455
|
-
|
|
5474
|
+
txs.forEach(function (idbtrans) {
|
|
5475
|
+
idbtrans.aborted = true;
|
|
5476
|
+
try {
|
|
5477
|
+
idbtrans.abort();
|
|
5478
|
+
}
|
|
5479
|
+
catch (_a) { }
|
|
5480
|
+
});
|
|
5456
5481
|
txs.length = 0;
|
|
5457
5482
|
}
|
|
5458
5483
|
var ctx = {
|
|
@@ -5468,6 +5493,8 @@
|
|
|
5468
5493
|
startedListening = true;
|
|
5469
5494
|
}
|
|
5470
5495
|
Promise.resolve(ret).then(function (result) {
|
|
5496
|
+
hasValue = true;
|
|
5497
|
+
currentValue = result;
|
|
5471
5498
|
if (closed || ctx.signal.aborted) {
|
|
5472
5499
|
return;
|
|
5473
5500
|
}
|
|
@@ -5475,6 +5502,7 @@
|
|
|
5475
5502
|
currentObs = subscr;
|
|
5476
5503
|
observer.next && observer.next(result);
|
|
5477
5504
|
}, function (err) {
|
|
5505
|
+
hasValue = false;
|
|
5478
5506
|
if (!['DatabaseClosedError', 'AbortError'].includes(err === null || err === void 0 ? void 0 : err.name)) {
|
|
5479
5507
|
if (closed)
|
|
5480
5508
|
return;
|
|
@@ -5485,6 +5513,9 @@
|
|
|
5485
5513
|
doQuery();
|
|
5486
5514
|
return subscription;
|
|
5487
5515
|
});
|
|
5516
|
+
observable.hasValue = function () { return hasValue; };
|
|
5517
|
+
observable.getValue = function () { return currentValue; };
|
|
5518
|
+
return observable;
|
|
5488
5519
|
}
|
|
5489
5520
|
|
|
5490
5521
|
var Dexie = Dexie$1;
|