dexie 4.0.1-alpha.23 → 4.0.1-alpha.25

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-alpha.23, Tue Jul 04 2023
7
+ * Version 4.0.1-alpha.25, Sun Jul 16 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
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.23, Tue Jul 04 2023
7
+ * Version 4.0.1-alpha.25, Sun Jul 16 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -612,21 +612,9 @@
612
612
  var NativePromise = resolvedNativePromise && resolvedNativePromise.constructor;
613
613
  var patchGlobalPromise = !!resolvedGlobalPromise;
614
614
  var stack_being_generated = false;
615
- var schedulePhysicalTick = resolvedGlobalPromise ?
616
- function () { resolvedGlobalPromise.then(physicalTick); }
617
- :
618
- _global.setImmediate ?
619
- setImmediate.bind(null, physicalTick) :
620
- _global.MutationObserver ?
621
- function () {
622
- var hiddenDiv = document.createElement("div");
623
- (new MutationObserver(function () {
624
- physicalTick();
625
- hiddenDiv = null;
626
- })).observe(hiddenDiv, { attributes: true });
627
- hiddenDiv.setAttribute('i', '1');
628
- } :
629
- function () { setTimeout(physicalTick, 0); };
615
+ function schedulePhysicalTick() {
616
+ queueMicrotask(physicalTick);
617
+ }
630
618
  var asap = function (callback, args) {
631
619
  microtickQueue.push([callback, args]);
632
620
  if (needsNewPhysicalTick) {
@@ -1003,7 +991,9 @@
1003
991
  }
1004
992
  }
1005
993
  function physicalTick() {
1006
- beginMicroTickScope() && endMicroTickScope();
994
+ usePSD(globalPSD, function () {
995
+ beginMicroTickScope() && endMicroTickScope();
996
+ });
1007
997
  }
1008
998
  function beginMicroTickScope() {
1009
999
  var wasRootExec = isOutsideMicroTick;
@@ -1166,7 +1156,7 @@
1166
1156
  function switchToZone(targetZone, bEnteringZone) {
1167
1157
  var currentZone = PSD;
1168
1158
  if (bEnteringZone ? task.echoes && (!zoneEchoes++ || targetZone !== PSD) : zoneEchoes && (!--zoneEchoes || targetZone !== PSD)) {
1169
- enqueueNativeMicroTask(bEnteringZone ? zoneEnterEcho.bind(null, targetZone) : zoneLeaveEcho);
1159
+ queueMicrotask(bEnteringZone ? zoneEnterEcho.bind(null, targetZone) : zoneLeaveEcho);
1170
1160
  }
1171
1161
  if (targetZone === PSD)
1172
1162
  return;
@@ -1216,9 +1206,6 @@
1216
1206
  switchToZone(outerScope, false);
1217
1207
  }
1218
1208
  }
1219
- function enqueueNativeMicroTask(job) {
1220
- nativePromiseThen.call(resolvedNativePromise, job);
1221
- }
1222
1209
  function nativeAwaitCompatibleWrap(fn, zone, possibleAwait, cleanup) {
1223
1210
  return typeof fn !== 'function' ? fn : function () {
1224
1211
  var outerZone = PSD;
@@ -1231,7 +1218,7 @@
1231
1218
  finally {
1232
1219
  switchToZone(outerZone, false);
1233
1220
  if (cleanup)
1234
- enqueueNativeMicroTask(decrementExpectedAwaits);
1221
+ queueMicrotask(decrementExpectedAwaits);
1235
1222
  }
1236
1223
  };
1237
1224
  }
@@ -1284,7 +1271,7 @@
1284
1271
  }
1285
1272
  }
1286
1273
 
1287
- var DEXIE_VERSION = '4.0.1-alpha.23';
1274
+ var DEXIE_VERSION = '4.0.1-alpha.25';
1288
1275
  var maxString = String.fromCharCode(65535);
1289
1276
  var minKey = -Infinity;
1290
1277
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -3374,8 +3361,7 @@
3374
3361
  dbcore: dbcore
3375
3362
  };
3376
3363
  }
3377
- function generateMiddlewareStacks(_a, tmpTrans) {
3378
- var db = _a._novip;
3364
+ function generateMiddlewareStacks(db, tmpTrans) {
3379
3365
  var idbdb = tmpTrans.db;
3380
3366
  var stacks = createMiddlewareStacks(db._middlewares, idbdb, db._deps, tmpTrans);
3381
3367
  db.core = stacks.dbcore;
@@ -3390,8 +3376,7 @@
3390
3376
  });
3391
3377
  }
3392
3378
 
3393
- function setApiOnPlace(_a, objs, tableNames, dbschema) {
3394
- var db = _a._novip;
3379
+ function setApiOnPlace(db, objs, tableNames, dbschema) {
3395
3380
  tableNames.forEach(function (tableName) {
3396
3381
  var schema = dbschema[tableName];
3397
3382
  objs.forEach(function (obj) {
@@ -3412,8 +3397,7 @@
3412
3397
  });
3413
3398
  });
3414
3399
  }
3415
- function removeTablesApi(_a, objs) {
3416
- var db = _a._novip;
3400
+ function removeTablesApi(db, objs) {
3417
3401
  objs.forEach(function (obj) {
3418
3402
  for (var key in obj) {
3419
3403
  if (obj[key] instanceof db.Table)
@@ -3445,8 +3429,7 @@
3445
3429
  updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans).catch(rejectTransaction);
3446
3430
  });
3447
3431
  }
3448
- function updateTablesAndIndexes(_a, oldVersion, trans, idbUpgradeTrans) {
3449
- var db = _a._novip;
3432
+ function updateTablesAndIndexes(db, oldVersion, trans, idbUpgradeTrans) {
3450
3433
  var queue = [];
3451
3434
  var versions = db._versions;
3452
3435
  var globalSchema = db._dbSchema = buildGlobalSchema(db, db.idbdb, idbUpgradeTrans);
@@ -3620,8 +3603,7 @@
3620
3603
  });
3621
3604
  return globalSchema;
3622
3605
  }
3623
- function readGlobalSchema(_a, idbdb, tmpTrans) {
3624
- var db = _a._novip;
3606
+ function readGlobalSchema(db, idbdb, tmpTrans) {
3625
3607
  db.verno = idbdb.version / 10;
3626
3608
  var globalSchema = db._dbSchema = buildGlobalSchema(db, idbdb, tmpTrans);
3627
3609
  db._storeNames = slice(idbdb.objectStoreNames, 0);
@@ -3632,8 +3614,7 @@
3632
3614
  var diff = getSchemaDiff(installedSchema, db._dbSchema);
3633
3615
  return !(diff.add.length || diff.change.some(function (ch) { return ch.add.length || ch.change.length; }));
3634
3616
  }
3635
- function adjustToExistingIndexNames(_a, schema, idbtrans) {
3636
- var db = _a._novip;
3617
+ function adjustToExistingIndexNames(db, schema, idbtrans) {
3637
3618
  var storeNames = idbtrans.db.objectStoreNames;
3638
3619
  for (var i = 0; i < storeNames.length; ++i) {
3639
3620
  var storeName = storeNames[i];
@@ -4063,13 +4044,13 @@
4063
4044
  upgradeTransaction.onerror = eventRejectHandler(reject);
4064
4045
  var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion;
4065
4046
  wasCreated = oldVer < 1;
4066
- db._novip.idbdb = req.result;
4047
+ db.idbdb = req.result;
4067
4048
  runUpgraders(db, oldVer / 10, upgradeTransaction, reject);
4068
4049
  }
4069
4050
  }, reject);
4070
4051
  req.onsuccess = wrap(function () {
4071
4052
  upgradeTransaction = null;
4072
- var idbdb = db._novip.idbdb = req.result;
4053
+ var idbdb = db.idbdb = req.result;
4073
4054
  var objectStoreNames = slice(idbdb.objectStoreNames);
4074
4055
  if (objectStoreNames.length > 0)
4075
4056
  try {
@@ -5129,6 +5110,16 @@
5129
5110
  },
5130
5111
  };
5131
5112
 
5113
+ function vipify(target, vipDb) {
5114
+ return new Proxy(target, {
5115
+ get: function (target, prop, receiver) {
5116
+ if (prop === 'db')
5117
+ return vipDb;
5118
+ return Reflect.get(target, prop, receiver);
5119
+ }
5120
+ });
5121
+ }
5122
+
5132
5123
  var Dexie$1 = (function () {
5133
5124
  function Dexie(name, options) {
5134
5125
  var _this = this;
@@ -5229,7 +5220,26 @@
5229
5220
  this.use(observabilityMiddleware);
5230
5221
  this.use(virtualIndexMiddleware);
5231
5222
  this.use(hooksMiddleware);
5232
- this.vip = Object.create(this, { _vip: { value: true } });
5223
+ var vipDB = new Proxy(this, {
5224
+ get: function (_, prop, receiver) {
5225
+ if (prop === '_vip')
5226
+ return true;
5227
+ if (prop === 'table')
5228
+ return function (tableName) { return vipify(_this.table(tableName), vipDB); };
5229
+ var rv = Reflect.get(_, prop, receiver);
5230
+ if (rv instanceof Table)
5231
+ return vipify(rv, vipDB);
5232
+ if (prop === 'tables')
5233
+ return rv.map(function (t) { return vipify(t, vipDB); });
5234
+ if (prop === '_createTransaction')
5235
+ return function () {
5236
+ var tx = rv.apply(this, arguments);
5237
+ return vipify(tx, vipDB);
5238
+ };
5239
+ return rv;
5240
+ }
5241
+ });
5242
+ this.vip = vipDB;
5233
5243
  addons.forEach(function (addon) { return addon(_this); });
5234
5244
  }
5235
5245
  Dexie.prototype.version = function (versionNumber) {
@@ -5301,7 +5311,7 @@
5301
5311
  this.idbdb.close();
5302
5312
  }
5303
5313
  catch (e) { }
5304
- this._novip.idbdb = null;
5314
+ this.idbdb = null;
5305
5315
  }
5306
5316
  state.dbReadyPromise = new DexiePromise(function (resolve) {
5307
5317
  state.dbReadyResolve = resolve;
@@ -5473,14 +5483,20 @@
5473
5483
  var observable = new Observable(function (observer) {
5474
5484
  var scopeFuncIsAsync = isAsyncFunction(querier);
5475
5485
  function execute(ctx) {
5476
- if (scopeFuncIsAsync) {
5477
- incrementExpectedAwaits();
5486
+ var wasRootExec = beginMicroTickScope();
5487
+ try {
5488
+ if (scopeFuncIsAsync) {
5489
+ incrementExpectedAwaits();
5490
+ }
5491
+ var rv = newScope(querier, ctx);
5492
+ if (scopeFuncIsAsync) {
5493
+ rv.finally(decrementExpectedAwaits);
5494
+ }
5495
+ return rv;
5478
5496
  }
5479
- var rv = newScope(querier, ctx);
5480
- if (scopeFuncIsAsync) {
5481
- rv.finally(decrementExpectedAwaits);
5497
+ finally {
5498
+ wasRootExec && endMicroTickScope();
5482
5499
  }
5483
- return rv;
5484
5500
  }
5485
5501
  var closed = false;
5486
5502
  var abortController;