dexie 4.0.0-alpha.2 → 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/SECURITY.md CHANGED
@@ -4,14 +4,15 @@
4
4
 
5
5
  | Version | Supported | Branch
6
6
  | ------- | ------------------ | --------
7
- | 3.x | :white_check_mark: | master
7
+ | 4.x | :white_check_mark: | master
8
+ | 3.x | :white_check_mark: | master-3
8
9
  | 2.0.x | :thinking: | master-2
9
10
  | 1.5.x | :x: | master-1
10
11
  | < 1.5.1 | :x: |
11
12
 
12
13
  ## Reporting a Vulnerability
13
14
 
14
- To report a security vulnerability in Dexie.js, just file an issue in this repo.
15
+ To report a security vulnerability in Dexie.js, please send an email to code@dexie.org describing the vulnerability and how to reproduce it.
15
16
 
16
17
  If we find an issue to be regarded as a security vulnerability, we will patch and release a new version in all the supported versions as soon as possible.
17
18
  Keep in mind though that this is an uncommercial open source project which means that sometimes you might have to be the one that
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.2, Sun Apr 10 2022
7
+ * Version 4.0.0-alpha.3, Wed Apr 27 2022
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -772,7 +772,6 @@ export interface Dexie {
772
772
  readonly name: string;
773
773
  readonly tables: Table[];
774
774
  readonly verno: number;
775
- /** The 'vip' instance - passed to db.on('ready') and allows usage before db.on('ready') completes. */
776
775
  readonly vip: Dexie;
777
776
  readonly _allTables: {
778
777
  [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.2, Sun Apr 10 2022
7
+ * Version 4.0.0-alpha.3, Wed Apr 27 2022
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -195,7 +195,7 @@
195
195
  obj[currentKeyPath] = value;
196
196
  else {
197
197
  var innerObj = obj[currentKeyPath];
198
- if (!innerObj)
198
+ if (!innerObj || !hasOwn(obj, currentKeyPath))
199
199
  innerObj = (obj[currentKeyPath] = {});
200
200
  setByKeyPath(innerObj, remainingKeyPath, value);
201
201
  }
@@ -1300,7 +1300,7 @@
1300
1300
  }
1301
1301
  }
1302
1302
 
1303
- var DEXIE_VERSION = '4.0.0-alpha.2';
1303
+ var DEXIE_VERSION = '4.0.0-alpha.3';
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,19 +3349,20 @@
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 = db.vip[tableName].core = table.core;
3352
+ db[tableName].core = table.core;
3353
3353
  }
3354
3354
  }
3355
3355
  });
3356
3356
  }
3357
3357
 
3358
- function setApiOnPlace(objs, tableNames, dbschema) {
3358
+ function setApiOnPlace(_a, objs, tableNames, dbschema) {
3359
+ var db = _a._novip;
3359
3360
  tableNames.forEach(function (tableName) {
3360
3361
  var schema = dbschema[tableName];
3361
3362
  objs.forEach(function (obj) {
3362
3363
  var propDesc = getPropertyDescriptor(obj, tableName);
3363
- if (!propDesc || ("value" in propDesc && (propDesc.value === undefined || propDesc.value instanceof Table))) {
3364
- if (obj instanceof Transaction) {
3364
+ if (!propDesc || ("value" in propDesc && propDesc.value === undefined)) {
3365
+ if (obj === db.Transaction.prototype || obj instanceof db.Transaction) {
3365
3366
  setProp(obj, tableName, {
3366
3367
  get: function () { return this.table(tableName); },
3367
3368
  set: function (value) {
@@ -3369,22 +3370,20 @@
3369
3370
  }
3370
3371
  });
3371
3372
  }
3372
- else if (obj instanceof Dexie$1) {
3373
- obj._allTables[tableName] = obj[tableName] = new obj.Table(tableName, schema);
3373
+ else {
3374
+ obj[tableName] = new db.Table(tableName, schema);
3374
3375
  }
3375
3376
  }
3376
3377
  });
3377
3378
  });
3378
3379
  }
3379
- function removeTablesApi(objs) {
3380
+ function removeTablesApi(_a, objs) {
3381
+ var db = _a._novip;
3380
3382
  objs.forEach(function (obj) {
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
- });
3383
+ for (var key in obj) {
3384
+ if (obj[key] instanceof db.Table)
3385
+ delete obj[key];
3386
+ }
3388
3387
  });
3389
3388
  }
3390
3389
  function lowerVersionFirst(a, b) {
@@ -3452,8 +3451,8 @@
3452
3451
  diff.del.forEach(function (table) {
3453
3452
  upgradeSchema_1[table] = oldSchema[table];
3454
3453
  });
3455
- removeTablesApi([db.Transaction.prototype]);
3456
- setApiOnPlace([db.Transaction.prototype], keys(upgradeSchema_1), upgradeSchema_1);
3454
+ removeTablesApi(db, [db.Transaction.prototype]);
3455
+ setApiOnPlace(db, [db.Transaction.prototype], keys(upgradeSchema_1), upgradeSchema_1);
3457
3456
  trans.schema = upgradeSchema_1;
3458
3457
  var contentUpgradeIsAsync_1 = isAsyncFunction(contentUpgrade);
3459
3458
  if (contentUpgradeIsAsync_1) {
@@ -3478,8 +3477,8 @@
3478
3477
  var newSchema = version._cfg.dbschema;
3479
3478
  deleteRemovedTables(newSchema, idbtrans);
3480
3479
  }
3481
- removeTablesApi([db.Transaction.prototype]);
3482
- setApiOnPlace([db.Transaction.prototype], db._storeNames, db._dbSchema);
3480
+ removeTablesApi(db, [db.Transaction.prototype]);
3481
+ setApiOnPlace(db, [db.Transaction.prototype], db._storeNames, db._dbSchema);
3483
3482
  trans.schema = db._dbSchema;
3484
3483
  });
3485
3484
  });
@@ -3591,7 +3590,7 @@
3591
3590
  db.verno = idbdb.version / 10;
3592
3591
  var globalSchema = db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans);
3593
3592
  db._storeNames = slice(idbdb.objectStoreNames, 0);
3594
- setApiOnPlace([db, db.vip], keys(globalSchema), globalSchema);
3593
+ setApiOnPlace(db, [db._allTables], keys(globalSchema), globalSchema);
3595
3594
  }
3596
3595
  function verifyInstalledSchema(db, tmpTrans) {
3597
3596
  var installedSchema = buildGlobalSchema(db, db.idbdb, tmpTrans);
@@ -3656,7 +3655,7 @@
3656
3655
  });
3657
3656
  };
3658
3657
  Version.prototype.stores = function (stores) {
3659
- var db = this.db._novip;
3658
+ var db = this.db;
3660
3659
  this._cfg.storesSource = this._cfg.storesSource ?
3661
3660
  extend(this._cfg.storesSource, stores) :
3662
3661
  stores;
@@ -3669,8 +3668,8 @@
3669
3668
  version._parseStoresSpec(storesSpec, dbschema);
3670
3669
  });
3671
3670
  db._dbSchema = dbschema;
3672
- removeTablesApi([db, db.vip, db.Transaction.prototype]);
3673
- setApiOnPlace([db, db.vip, db.Transaction.prototype], keys(dbschema), dbschema);
3671
+ removeTablesApi(db, [db._allTables, db, db.Transaction.prototype]);
3672
+ setApiOnPlace(db, [db._allTables, db, db.Transaction.prototype, this._cfg.tables], keys(dbschema), dbschema);
3674
3673
  db._storeNames = keys(dbschema);
3675
3674
  return this;
3676
3675
  };
@@ -3688,6 +3687,7 @@
3688
3687
  version: versionNumber,
3689
3688
  storesSource: null,
3690
3689
  dbschema: {},
3690
+ tables: {},
3691
3691
  contentUpgrade: null
3692
3692
  };
3693
3693
  });
@@ -4712,11 +4712,7 @@
4712
4712
  this.use(hooksMiddleware);
4713
4713
  this.use(observabilityMiddleware);
4714
4714
  this.use(cacheExistingValuesMiddleware);
4715
- var vipDexie = Object.create(this);
4716
- vipDexie._vip = true;
4717
- vipDexie.Table = createTableConstructor(vipDexie);
4718
- vipDexie._allTables = {};
4719
- this.vip = vipDexie;
4715
+ this.vip = Object.create(this, { _vip: { value: true } });
4720
4716
  addons.forEach(function (addon) { return addon(_this); });
4721
4717
  }
4722
4718
  Dexie.prototype.version = function (versionNumber) {
@@ -5192,13 +5188,15 @@
5192
5188
  }
5193
5189
  catch (_a) { }
5194
5190
  });
5195
- addEventListener('storage', function (ev) {
5196
- if (ev.key === STORAGE_MUTATED_DOM_EVENT_NAME) {
5197
- var data = JSON.parse(ev.newValue);
5198
- if (data)
5199
- propagateLocally(data.changedParts);
5200
- }
5201
- });
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
+ }
5202
5200
  var swContainer = self.document && navigator.serviceWorker;
5203
5201
  if (swContainer) {
5204
5202
  swContainer.addEventListener('message', propagateMessageLocally);