dexie 4.0.0-alpha.1 → 4.0.0-alpha.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/README.md +2 -2
- package/dist/dexie.d.ts +29 -3
- package/dist/dexie.js +29 -25
- 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 +29 -25
- 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 +29 -23
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Dexie.js
|
|
2
2
|
========
|
|
3
3
|
|
|
4
|
-
[![NPM Version][npm-image]][npm-url] [](https://travis-ci.com/dexie/Dexie.js)[](https://www.browserstack.com)
|
|
5
5
|
|
|
6
6
|
Dexie.js is a wrapper library for indexedDB - the standard database in the browser. https://dexie.org
|
|
7
7
|
|
|
@@ -191,7 +191,7 @@ Samples
|
|
|
191
191
|
-------
|
|
192
192
|
https://dexie.org/docs/Samples
|
|
193
193
|
|
|
194
|
-
https://github.com/
|
|
194
|
+
https://github.com/dexie/Dexie.js/tree/master/samples
|
|
195
195
|
|
|
196
196
|
Knowledge Base
|
|
197
197
|
-----
|
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.0-alpha.
|
|
7
|
+
* Version 4.0.0-alpha.2, Sun Apr 10 2022
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -701,9 +701,34 @@ export interface DbEvents extends DexieEventSet {
|
|
|
701
701
|
versionchange: DexieVersionChangeEvent;
|
|
702
702
|
close: DexieCloseEvent;
|
|
703
703
|
}
|
|
704
|
+
/** Set of mutated parts of the database
|
|
705
|
+
*/
|
|
704
706
|
export type ObservabilitySet = {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
+
/** Database part having been mutated.
|
|
708
|
+
*
|
|
709
|
+
* This structure is produced in observability-middleware.ts
|
|
710
|
+
* and consumed in live-query.ts.
|
|
711
|
+
*
|
|
712
|
+
* Format of 'part':
|
|
713
|
+
*
|
|
714
|
+
* `idb://${dbName}/${tableName}/${indexName}`
|
|
715
|
+
*
|
|
716
|
+
* * dbName is the database name
|
|
717
|
+
* * tableName is the table name
|
|
718
|
+
* * indexName is any of:
|
|
719
|
+
* 1. An empty string - represents the primary keys of the affected objs
|
|
720
|
+
* 2. ":dels" - represents primary keys of deleted objects in the table
|
|
721
|
+
* 3. The keyPath of an index, such as "name", "age" or "address.city" -
|
|
722
|
+
* represents indexes that, if used in a query, might affect the
|
|
723
|
+
* result of that query.
|
|
724
|
+
*
|
|
725
|
+
* IntervalTree
|
|
726
|
+
* * See definition of IntervalTree type in rangeset.d.ts
|
|
727
|
+
* * See rangesOverlap() in rangeset.ts that can be used to compare two
|
|
728
|
+
* IntervalTrees and detect collissions.
|
|
729
|
+
* * See RangeSet class that can be used to create an IntervalTree and add
|
|
730
|
+
* ranges to it.
|
|
731
|
+
*/
|
|
707
732
|
[part: string]: IntervalTree;
|
|
708
733
|
};
|
|
709
734
|
export interface DexieOnStorageMutatedEvent {
|
|
@@ -747,6 +772,7 @@ export interface Dexie {
|
|
|
747
772
|
readonly name: string;
|
|
748
773
|
readonly tables: Table[];
|
|
749
774
|
readonly verno: number;
|
|
775
|
+
/** The 'vip' instance - passed to db.on('ready') and allows usage before db.on('ready') completes. */
|
|
750
776
|
readonly vip: Dexie;
|
|
751
777
|
readonly _allTables: {
|
|
752
778
|
[name: string]: Table<any, IndexableType>;
|
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.0-alpha.
|
|
7
|
+
* Version 4.0.0-alpha.2, Sun Apr 10 2022
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1300,7 +1300,7 @@
|
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
1302
|
|
|
1303
|
-
var DEXIE_VERSION = '4.0.0-alpha.
|
|
1303
|
+
var DEXIE_VERSION = '4.0.0-alpha.2';
|
|
1304
1304
|
var maxString = String.fromCharCode(65535);
|
|
1305
1305
|
var minKey = -Infinity;
|
|
1306
1306
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -3349,20 +3349,19 @@
|
|
|
3349
3349
|
if (db.core.schema.tables.some(function (tbl) { return tbl.name === tableName; })) {
|
|
3350
3350
|
table.core = db.core.table(tableName);
|
|
3351
3351
|
if (db[tableName] instanceof db.Table) {
|
|
3352
|
-
db[tableName].core = table.core;
|
|
3352
|
+
db[tableName].core = db.vip[tableName].core = table.core;
|
|
3353
3353
|
}
|
|
3354
3354
|
}
|
|
3355
3355
|
});
|
|
3356
3356
|
}
|
|
3357
3357
|
|
|
3358
|
-
function setApiOnPlace(
|
|
3359
|
-
var db = _a._novip;
|
|
3358
|
+
function setApiOnPlace(objs, tableNames, dbschema) {
|
|
3360
3359
|
tableNames.forEach(function (tableName) {
|
|
3361
3360
|
var schema = dbschema[tableName];
|
|
3362
3361
|
objs.forEach(function (obj) {
|
|
3363
3362
|
var propDesc = getPropertyDescriptor(obj, tableName);
|
|
3364
|
-
if (!propDesc || ("value" in propDesc && propDesc.value === undefined)) {
|
|
3365
|
-
if (obj
|
|
3363
|
+
if (!propDesc || ("value" in propDesc && (propDesc.value === undefined || propDesc.value instanceof Table))) {
|
|
3364
|
+
if (obj instanceof Transaction) {
|
|
3366
3365
|
setProp(obj, tableName, {
|
|
3367
3366
|
get: function () { return this.table(tableName); },
|
|
3368
3367
|
set: function (value) {
|
|
@@ -3370,20 +3369,22 @@
|
|
|
3370
3369
|
}
|
|
3371
3370
|
});
|
|
3372
3371
|
}
|
|
3373
|
-
else {
|
|
3374
|
-
obj[tableName] = new
|
|
3372
|
+
else if (obj instanceof Dexie$1) {
|
|
3373
|
+
obj._allTables[tableName] = obj[tableName] = new obj.Table(tableName, schema);
|
|
3375
3374
|
}
|
|
3376
3375
|
}
|
|
3377
3376
|
});
|
|
3378
3377
|
});
|
|
3379
3378
|
}
|
|
3380
|
-
function removeTablesApi(
|
|
3381
|
-
var db = _a._novip;
|
|
3379
|
+
function removeTablesApi(objs) {
|
|
3382
3380
|
objs.forEach(function (obj) {
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3381
|
+
(obj instanceof Dexie$1 ? [obj, obj._allTables] : [obj]).forEach(function (obj) {
|
|
3382
|
+
for (var key in obj) {
|
|
3383
|
+
if (obj[key] instanceof Table) {
|
|
3384
|
+
delete obj[key];
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
});
|
|
3387
3388
|
});
|
|
3388
3389
|
}
|
|
3389
3390
|
function lowerVersionFirst(a, b) {
|
|
@@ -3451,8 +3452,8 @@
|
|
|
3451
3452
|
diff.del.forEach(function (table) {
|
|
3452
3453
|
upgradeSchema_1[table] = oldSchema[table];
|
|
3453
3454
|
});
|
|
3454
|
-
removeTablesApi(
|
|
3455
|
-
setApiOnPlace(
|
|
3455
|
+
removeTablesApi([db.Transaction.prototype]);
|
|
3456
|
+
setApiOnPlace([db.Transaction.prototype], keys(upgradeSchema_1), upgradeSchema_1);
|
|
3456
3457
|
trans.schema = upgradeSchema_1;
|
|
3457
3458
|
var contentUpgradeIsAsync_1 = isAsyncFunction(contentUpgrade);
|
|
3458
3459
|
if (contentUpgradeIsAsync_1) {
|
|
@@ -3477,8 +3478,8 @@
|
|
|
3477
3478
|
var newSchema = version._cfg.dbschema;
|
|
3478
3479
|
deleteRemovedTables(newSchema, idbtrans);
|
|
3479
3480
|
}
|
|
3480
|
-
removeTablesApi(
|
|
3481
|
-
setApiOnPlace(
|
|
3481
|
+
removeTablesApi([db.Transaction.prototype]);
|
|
3482
|
+
setApiOnPlace([db.Transaction.prototype], db._storeNames, db._dbSchema);
|
|
3482
3483
|
trans.schema = db._dbSchema;
|
|
3483
3484
|
});
|
|
3484
3485
|
});
|
|
@@ -3590,7 +3591,7 @@
|
|
|
3590
3591
|
db.verno = idbdb.version / 10;
|
|
3591
3592
|
var globalSchema = db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans);
|
|
3592
3593
|
db._storeNames = slice(idbdb.objectStoreNames, 0);
|
|
3593
|
-
setApiOnPlace(db,
|
|
3594
|
+
setApiOnPlace([db, db.vip], keys(globalSchema), globalSchema);
|
|
3594
3595
|
}
|
|
3595
3596
|
function verifyInstalledSchema(db, tmpTrans) {
|
|
3596
3597
|
var installedSchema = buildGlobalSchema(db, db.idbdb, tmpTrans);
|
|
@@ -3655,7 +3656,7 @@
|
|
|
3655
3656
|
});
|
|
3656
3657
|
};
|
|
3657
3658
|
Version.prototype.stores = function (stores) {
|
|
3658
|
-
var db = this.db;
|
|
3659
|
+
var db = this.db._novip;
|
|
3659
3660
|
this._cfg.storesSource = this._cfg.storesSource ?
|
|
3660
3661
|
extend(this._cfg.storesSource, stores) :
|
|
3661
3662
|
stores;
|
|
@@ -3668,8 +3669,8 @@
|
|
|
3668
3669
|
version._parseStoresSpec(storesSpec, dbschema);
|
|
3669
3670
|
});
|
|
3670
3671
|
db._dbSchema = dbschema;
|
|
3671
|
-
removeTablesApi(db,
|
|
3672
|
-
setApiOnPlace(db,
|
|
3672
|
+
removeTablesApi([db, db.vip, db.Transaction.prototype]);
|
|
3673
|
+
setApiOnPlace([db, db.vip, db.Transaction.prototype], keys(dbschema), dbschema);
|
|
3673
3674
|
db._storeNames = keys(dbschema);
|
|
3674
3675
|
return this;
|
|
3675
3676
|
};
|
|
@@ -3687,7 +3688,6 @@
|
|
|
3687
3688
|
version: versionNumber,
|
|
3688
3689
|
storesSource: null,
|
|
3689
3690
|
dbschema: {},
|
|
3690
|
-
tables: {},
|
|
3691
3691
|
contentUpgrade: null
|
|
3692
3692
|
};
|
|
3693
3693
|
});
|
|
@@ -4712,7 +4712,11 @@
|
|
|
4712
4712
|
this.use(hooksMiddleware);
|
|
4713
4713
|
this.use(observabilityMiddleware);
|
|
4714
4714
|
this.use(cacheExistingValuesMiddleware);
|
|
4715
|
-
|
|
4715
|
+
var vipDexie = Object.create(this);
|
|
4716
|
+
vipDexie._vip = true;
|
|
4717
|
+
vipDexie.Table = createTableConstructor(vipDexie);
|
|
4718
|
+
vipDexie._allTables = {};
|
|
4719
|
+
this.vip = vipDexie;
|
|
4716
4720
|
addons.forEach(function (addon) { return addon(_this); });
|
|
4717
4721
|
}
|
|
4718
4722
|
Dexie.prototype.version = function (versionNumber) {
|