dexie 4.0.1-beta.5 → 4.0.1-beta.7
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 +3 -0
- package/dist/dexie.d.ts +3 -3
- package/dist/dexie.js +60 -79
- 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 +60 -79
- 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 +50 -66
- package/dist/modern/dexie.mjs.map +1 -1
- package/import-wrapper-prod.mjs +2 -2
- package/import-wrapper.mjs +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -250,6 +250,9 @@ Watch
|
|
|
250
250
|
pnpm run watch
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
+
<br/>
|
|
254
|
+
|
|
255
|
+
[](https://www.lambdatest.com/)
|
|
253
256
|
|
|
254
257
|
[npm-image]: https://img.shields.io/npm/v/dexie.svg?style=flat
|
|
255
258
|
[npm-url]: https://npmjs.org/package/dexie
|
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-beta.
|
|
7
|
+
* Version 4.0.1-beta.7, Wed Jan 31 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1120,7 +1120,7 @@ export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps
|
|
|
1120
1120
|
export type IDType<T, TKeyPropNameOrKeyType> = IsStrictlyAny<T> extends true ? TKeyPropNameOrKeyType : TKeyPropNameOrKeyType extends string ? TKeyPropNameOrKeyType extends keyof T ? T[TKeyPropNameOrKeyType] : TKeyPropNameOrKeyType : TKeyPropNameOrKeyType;
|
|
1121
1121
|
export type EntityTable<T, TKeyPropName extends keyof T = never, TInsertType = InsertType<T, TKeyPropName>> = Table<T, IDType<T, TKeyPropName>, TInsertType>;
|
|
1122
1122
|
export declare var Dexie: DexieConstructor;
|
|
1123
|
-
export interface _Table<T, TKey> extends Table<T, TKey> {
|
|
1123
|
+
export interface _Table<T, TKey, TInsertType> extends Table<T, TKey, TInsertType> {
|
|
1124
1124
|
}
|
|
1125
1125
|
export interface _Collection<T, TKey> extends Collection<T, TKey> {
|
|
1126
1126
|
}
|
|
@@ -1128,7 +1128,7 @@ export declare module Dexie {
|
|
|
1128
1128
|
// The "Dexie.Promise" type.
|
|
1129
1129
|
type Promise<T = any> = PromiseExtended<T>; // Because many samples have been Dexie.Promise.
|
|
1130
1130
|
// The "Dexie.Table" interface. Same as named exported interface Table.
|
|
1131
|
-
interface Table<T = any, Key = any> extends _Table<T, Key> {
|
|
1131
|
+
interface Table<T = any, Key = any, TInsertType = T> extends _Table<T, Key, TInsertType> {
|
|
1132
1132
|
} // Because all samples have been Dexie.Table<...>
|
|
1133
1133
|
// The "Dexie.Collection" interface. Same as named exported interface Collection.
|
|
1134
1134
|
interface Collection<T = any, Key = any> extends _Collection<T, Key> {
|
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-beta.
|
|
7
|
+
* Version 4.0.1-beta.7, Wed Jan 31 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1083,7 +1083,7 @@
|
|
|
1083
1083
|
psd.ref = 0;
|
|
1084
1084
|
psd.global = false;
|
|
1085
1085
|
psd.id = ++zone_id_counter;
|
|
1086
|
-
|
|
1086
|
+
globalPSD.env;
|
|
1087
1087
|
psd.env = patchGlobalPromise ? {
|
|
1088
1088
|
Promise: DexiePromise,
|
|
1089
1089
|
PromiseProp: { value: DexiePromise, configurable: true, writable: true },
|
|
@@ -1093,8 +1093,6 @@
|
|
|
1093
1093
|
any: DexiePromise.any,
|
|
1094
1094
|
resolve: DexiePromise.resolve,
|
|
1095
1095
|
reject: DexiePromise.reject,
|
|
1096
|
-
nthen: getPatchedPromiseThen(globalEnv.nthen, psd),
|
|
1097
|
-
gthen: getPatchedPromiseThen(globalEnv.gthen, psd)
|
|
1098
1096
|
} : {};
|
|
1099
1097
|
if (props)
|
|
1100
1098
|
extend(psd, props);
|
|
@@ -1162,20 +1160,18 @@
|
|
|
1162
1160
|
if (currentZone === globalPSD)
|
|
1163
1161
|
globalPSD.env = snapShot();
|
|
1164
1162
|
if (patchGlobalPromise) {
|
|
1165
|
-
var
|
|
1163
|
+
var GlobalPromise = globalPSD.env.Promise;
|
|
1166
1164
|
var targetEnv = targetZone.env;
|
|
1167
|
-
nativePromiseProto.then = targetEnv.nthen;
|
|
1168
|
-
GlobalPromise_1.prototype.then = targetEnv.gthen;
|
|
1169
1165
|
if (currentZone.global || targetZone.global) {
|
|
1170
1166
|
Object.defineProperty(_global, 'Promise', targetEnv.PromiseProp);
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1167
|
+
GlobalPromise.all = targetEnv.all;
|
|
1168
|
+
GlobalPromise.race = targetEnv.race;
|
|
1169
|
+
GlobalPromise.resolve = targetEnv.resolve;
|
|
1170
|
+
GlobalPromise.reject = targetEnv.reject;
|
|
1175
1171
|
if (targetEnv.allSettled)
|
|
1176
|
-
|
|
1172
|
+
GlobalPromise.allSettled = targetEnv.allSettled;
|
|
1177
1173
|
if (targetEnv.any)
|
|
1178
|
-
|
|
1174
|
+
GlobalPromise.any = targetEnv.any;
|
|
1179
1175
|
}
|
|
1180
1176
|
}
|
|
1181
1177
|
}
|
|
@@ -1190,8 +1186,6 @@
|
|
|
1190
1186
|
any: GlobalPromise.any,
|
|
1191
1187
|
resolve: GlobalPromise.resolve,
|
|
1192
1188
|
reject: GlobalPromise.reject,
|
|
1193
|
-
nthen: nativePromiseProto.then,
|
|
1194
|
-
gthen: GlobalPromise.prototype.then
|
|
1195
1189
|
} : {};
|
|
1196
1190
|
}
|
|
1197
1191
|
function usePSD(psd, fn, a1, a2, a3) {
|
|
@@ -1220,11 +1214,6 @@
|
|
|
1220
1214
|
}
|
|
1221
1215
|
};
|
|
1222
1216
|
}
|
|
1223
|
-
function getPatchedPromiseThen(origThen, zone) {
|
|
1224
|
-
return function (onResolved, onRejected) {
|
|
1225
|
-
return origThen.call(this, nativeAwaitCompatibleWrap(onResolved, zone), nativeAwaitCompatibleWrap(onRejected, zone));
|
|
1226
|
-
};
|
|
1227
|
-
}
|
|
1228
1217
|
function execInGlobalContext(cb) {
|
|
1229
1218
|
if (Promise === NativePromise && task.echoes === 0) {
|
|
1230
1219
|
if (zoneEchoes === 0) {
|
|
@@ -1282,7 +1271,7 @@
|
|
|
1282
1271
|
}
|
|
1283
1272
|
}
|
|
1284
1273
|
|
|
1285
|
-
var DEXIE_VERSION = '4.0.1-beta.
|
|
1274
|
+
var DEXIE_VERSION = '4.0.1-beta.7';
|
|
1286
1275
|
var maxString = String.fromCharCode(65535);
|
|
1287
1276
|
var minKey = -Infinity;
|
|
1288
1277
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -1465,7 +1454,7 @@
|
|
|
1465
1454
|
.equals(keyPathsInValidOrder.map(function (kp) { return indexOrCrit[kp]; }));
|
|
1466
1455
|
}
|
|
1467
1456
|
if (!compoundIndex && debug)
|
|
1468
|
-
console.warn("The query ".concat(JSON.stringify(indexOrCrit), " on ").concat(this.name, " would benefit
|
|
1457
|
+
console.warn("The query ".concat(JSON.stringify(indexOrCrit), " on ").concat(this.name, " would benefit from a ") +
|
|
1469
1458
|
"compound index [".concat(keyPaths.join('+'), "]"));
|
|
1470
1459
|
var idxByName = this.schema.idxByName;
|
|
1471
1460
|
var idb = this.db._deps.indexedDB;
|
|
@@ -3602,7 +3591,7 @@
|
|
|
3602
3591
|
dbStoreNames.forEach(function (storeName) {
|
|
3603
3592
|
var store = tmpTrans.objectStore(storeName);
|
|
3604
3593
|
var keyPath = store.keyPath;
|
|
3605
|
-
var primKey = createIndexSpec(nameFromKeyPath(keyPath), keyPath || "",
|
|
3594
|
+
var primKey = createIndexSpec(nameFromKeyPath(keyPath), keyPath || "", true, false, !!store.autoIncrement, keyPath && typeof keyPath !== "string", true);
|
|
3606
3595
|
var indexes = [];
|
|
3607
3596
|
for (var j = 0; j < store.indexNames.length; ++j) {
|
|
3608
3597
|
var idbindex = store.index(store.indexNames[j]);
|
|
@@ -3669,6 +3658,7 @@
|
|
|
3669
3658
|
if (stores[tableName] !== null) {
|
|
3670
3659
|
var indexes = parseIndexSyntax(stores[tableName]);
|
|
3671
3660
|
var primKey = indexes.shift();
|
|
3661
|
+
primKey.unique = true;
|
|
3672
3662
|
if (primKey.multi)
|
|
3673
3663
|
throw new exceptions.Schema("Primary key cannot be multi-valued");
|
|
3674
3664
|
indexes.forEach(function (idx) {
|
|
@@ -3952,7 +3942,7 @@
|
|
|
3952
3942
|
}
|
|
3953
3943
|
|
|
3954
3944
|
function obsSetsOverlap(os1, os2) {
|
|
3955
|
-
return Object.keys(os1).some(function (key) { return os2[key] && rangesOverlap(os2[key], os1[key]); });
|
|
3945
|
+
return os1.all || os2.all || Object.keys(os1).some(function (key) { return os2[key] && rangesOverlap(os2[key], os1[key]); });
|
|
3956
3946
|
}
|
|
3957
3947
|
|
|
3958
3948
|
var cache = {};
|
|
@@ -3974,13 +3964,21 @@
|
|
|
3974
3964
|
function signalSubscribersNow(updatedParts, deleteAffectedCacheEntries) {
|
|
3975
3965
|
if (deleteAffectedCacheEntries === void 0) { deleteAffectedCacheEntries = false; }
|
|
3976
3966
|
var queriesToSignal = new Set();
|
|
3977
|
-
|
|
3978
|
-
var
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3967
|
+
if (updatedParts.all) {
|
|
3968
|
+
for (var _i = 0, _a = Object.values(cache); _i < _a.length; _i++) {
|
|
3969
|
+
var tblCache = _a[_i];
|
|
3970
|
+
signalTableSubscribersNow(tblCache, updatedParts, queriesToSignal, deleteAffectedCacheEntries);
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
else {
|
|
3974
|
+
for (var key in updatedParts) {
|
|
3975
|
+
var parts = /^idb\:\/\/(.*)\/(.*)\//.exec(key);
|
|
3976
|
+
if (parts) {
|
|
3977
|
+
var dbName = parts[1], tableName = parts[2];
|
|
3978
|
+
var tblCache = cache["idb://".concat(dbName, "/").concat(tableName)];
|
|
3979
|
+
if (tblCache)
|
|
3980
|
+
signalTableSubscribersNow(tblCache, updatedParts, queriesToSignal, deleteAffectedCacheEntries);
|
|
3981
|
+
}
|
|
3984
3982
|
}
|
|
3985
3983
|
}
|
|
3986
3984
|
queriesToSignal.forEach(function (requery) { return requery(); });
|
|
@@ -4822,6 +4820,8 @@
|
|
|
4822
4820
|
if (!ops || ops.length === 0)
|
|
4823
4821
|
return result;
|
|
4824
4822
|
var index = req.query.index;
|
|
4823
|
+
var multiEntry = index.multiEntry;
|
|
4824
|
+
var queryRange = req.query.range;
|
|
4825
4825
|
var primaryKey = table.schema.primaryKey;
|
|
4826
4826
|
var extractPrimKey = primaryKey.extractKey;
|
|
4827
4827
|
var extractIndex = index.extractKey;
|
|
@@ -4830,7 +4830,10 @@
|
|
|
4830
4830
|
var modifedResult = result;
|
|
4831
4831
|
var includedValues = op.type === 'add' || op.type === 'put'
|
|
4832
4832
|
? op.values.filter(function (v) {
|
|
4833
|
-
|
|
4833
|
+
var key = extractIndex(v);
|
|
4834
|
+
return multiEntry && isArray(key)
|
|
4835
|
+
? key.some(function (k) { return isWithinRange(k, queryRange); })
|
|
4836
|
+
: isWithinRange(key, queryRange);
|
|
4834
4837
|
}).map(function (v) {
|
|
4835
4838
|
v = deepClone(v);
|
|
4836
4839
|
if (immutable)
|
|
@@ -5760,62 +5763,40 @@
|
|
|
5760
5763
|
}
|
|
5761
5764
|
var propagatingLocally = false;
|
|
5762
5765
|
|
|
5766
|
+
var bc;
|
|
5767
|
+
var createBC = function () { };
|
|
5763
5768
|
if (typeof BroadcastChannel !== 'undefined') {
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5769
|
+
createBC = function () {
|
|
5770
|
+
bc = new BroadcastChannel(STORAGE_MUTATED_DOM_EVENT_NAME);
|
|
5771
|
+
bc.onmessage = function (ev) { return ev.data && propagateLocally(ev.data); };
|
|
5772
|
+
};
|
|
5773
|
+
createBC();
|
|
5774
|
+
if (typeof bc.unref === 'function') {
|
|
5775
|
+
bc.unref();
|
|
5767
5776
|
}
|
|
5768
5777
|
globalEvents(DEXIE_STORAGE_MUTATED_EVENT_NAME, function (changedParts) {
|
|
5769
5778
|
if (!propagatingLocally) {
|
|
5770
|
-
|
|
5779
|
+
bc.postMessage(changedParts);
|
|
5771
5780
|
}
|
|
5772
5781
|
});
|
|
5773
|
-
bc_1.onmessage = function (ev) {
|
|
5774
|
-
if (ev.data)
|
|
5775
|
-
propagateLocally(ev.data);
|
|
5776
|
-
};
|
|
5777
5782
|
}
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
});
|
|
5794
|
-
});
|
|
5795
|
-
}
|
|
5796
|
-
}
|
|
5783
|
+
|
|
5784
|
+
if (typeof addEventListener !== 'undefined') {
|
|
5785
|
+
addEventListener('pagehide', function (event) {
|
|
5786
|
+
if (event.persisted) {
|
|
5787
|
+
bc === null || bc === void 0 ? void 0 : bc.close();
|
|
5788
|
+
}
|
|
5789
|
+
for (var _i = 0, connections_1 = connections; _i < connections_1.length; _i++) {
|
|
5790
|
+
var db = connections_1[_i];
|
|
5791
|
+
db.close({ disableAutoOpen: false });
|
|
5792
|
+
}
|
|
5793
|
+
});
|
|
5794
|
+
addEventListener('pageshow', function (event) {
|
|
5795
|
+
if (event.persisted) {
|
|
5796
|
+
createBC();
|
|
5797
|
+
propagateLocally({ all: new RangeSet(-Infinity, [[]]) });
|
|
5797
5798
|
}
|
|
5798
|
-
catch (_a) { }
|
|
5799
5799
|
});
|
|
5800
|
-
if (typeof addEventListener !== 'undefined') {
|
|
5801
|
-
addEventListener('storage', function (ev) {
|
|
5802
|
-
if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {
|
|
5803
|
-
var data = JSON.parse(ev.newValue);
|
|
5804
|
-
if (data)
|
|
5805
|
-
propagateLocally(data.changedParts);
|
|
5806
|
-
}
|
|
5807
|
-
});
|
|
5808
|
-
}
|
|
5809
|
-
var swContainer = self.document && navigator.serviceWorker;
|
|
5810
|
-
if (swContainer) {
|
|
5811
|
-
swContainer.addEventListener('message', propagateMessageLocally);
|
|
5812
|
-
}
|
|
5813
|
-
}
|
|
5814
|
-
function propagateMessageLocally(_a) {
|
|
5815
|
-
var data = _a.data;
|
|
5816
|
-
if (data && data.type === STORAGE_MUTATED_DOM_EVENT_NAME) {
|
|
5817
|
-
propagateLocally(data.changedParts);
|
|
5818
|
-
}
|
|
5819
5800
|
}
|
|
5820
5801
|
|
|
5821
5802
|
DexiePromise.rejectionMapper = mapError;
|