indexeddbshim 19.0.3 → 19.0.5
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 +1 -6
- package/badges/coverage-badge.svg +1 -1
- package/badges/tests-badge.svg +1 -1
- package/dist/IDBTransaction.d.ts +15 -0
- package/dist/IDBTransaction.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +2 -2
- package/dist/indexeddbshim-Key.js.map +1 -1
- package/dist/indexeddbshim-Key.min.js +1 -1
- package/dist/indexeddbshim-Key.min.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +91 -25
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +89 -24
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +3 -3
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +89 -24
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +89 -24
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +2 -2
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +89 -24
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/setGlobalVars.d.ts.map +1 -1
- package/dist/util.d.ts +0 -6
- package/dist/util.d.ts.map +1 -1
- package/package.json +22 -18
- package/src/CFG.js +1 -1
- package/src/IDBTransaction.js +87 -23
- package/src/node-UnicodeIdentifiers.js +2 -1
- package/src/setGlobalVars.js +2 -1
- package/src/util.js +1 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! indexeddbshim - v19.0.
|
|
1
|
+
/*! indexeddbshim - v19.0.5 - 9/17/2026 */
|
|
2
2
|
|
|
3
3
|
(function (factory) {
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -1819,7 +1819,7 @@
|
|
|
1819
1819
|
'UnicodeIDStart',
|
|
1820
1820
|
// In the non-Unicode builds, defaults to /[$0-9A-Z_a-z]/
|
|
1821
1821
|
'UnicodeIDContinue',
|
|
1822
|
-
// Used by
|
|
1822
|
+
// Used by Sca.js for optional restructuring of typeson-registry
|
|
1823
1823
|
// Structured Cloning Algorithm; should only be needed for ensuring data
|
|
1824
1824
|
// created in 3.* versions of IndexedDBShim continue to work; see the
|
|
1825
1825
|
// library `typeson-registry-sca-reverter` to get a function to do this
|
|
@@ -5383,6 +5383,7 @@
|
|
|
5383
5383
|
* __requestsFinished: boolean,
|
|
5384
5384
|
* __transFinishedCb: (err: boolean, cb: ((bool?: boolean) => void)) => void,
|
|
5385
5385
|
* __callTransFinishedCb: (err: boolean, cb: ((bool?: boolean) => void)) => void,
|
|
5386
|
+
* __usesStandardDriver: () => boolean,
|
|
5386
5387
|
* __transactionEndCallback: (() => void)|undefined,
|
|
5387
5388
|
* __transactionFinished: boolean,
|
|
5388
5389
|
* __completed: boolean,
|
|
@@ -5522,6 +5523,27 @@
|
|
|
5522
5523
|
cb(Boolean(err));
|
|
5523
5524
|
};
|
|
5524
5525
|
|
|
5526
|
+
/**
|
|
5527
|
+
* A standard (3-argument) `transaction()`/`readTransaction()` implementation
|
|
5528
|
+
* (browser WebSQL, `cordova-plugin-sqlite-2`, etc.) never invokes the
|
|
5529
|
+
* non-standard 4th callback that installs the real `__transFinishedCb`,
|
|
5530
|
+
* and finalizes its own underlying SQL transaction synchronously, as soon
|
|
5531
|
+
* as it sees no further `executeSql` call already in flight or queued --
|
|
5532
|
+
* with no way for it to know a JS-level continuation (e.g. an
|
|
5533
|
+
* `await`-deferred follow-up request) is still coming. Detected via
|
|
5534
|
+
* arity, checking whichever of the two methods this transaction's own
|
|
5535
|
+
* mode actually uses.
|
|
5536
|
+
* @this {IDBTransactionFull}
|
|
5537
|
+
* @returns {boolean}
|
|
5538
|
+
*/
|
|
5539
|
+
IDBTransaction.prototype.__usesStandardDriver = function () {
|
|
5540
|
+
var me = this;
|
|
5541
|
+
var dbConn = me.db && me.db.__db;
|
|
5542
|
+
var dbMethodName = me.mode === 'readonly' ? 'readTransaction' : 'transaction';
|
|
5543
|
+
var supportsNonstandardTransCb = Boolean(dbConn && typeof dbConn[dbMethodName] === 'function' && dbConn[dbMethodName].length >= 4);
|
|
5544
|
+
return !supportsNonstandardTransCb;
|
|
5545
|
+
};
|
|
5546
|
+
|
|
5525
5547
|
/**
|
|
5526
5548
|
* In Node, the real (SQL-commit-capable) `__transFinishedCb` is only
|
|
5527
5549
|
* installed once the underlying WebSQL driver's own SQL-queue-idle check
|
|
@@ -5556,17 +5578,11 @@
|
|
|
5556
5578
|
return;
|
|
5557
5579
|
}
|
|
5558
5580
|
if (me.__transFinishedCb === IDBTransaction.prototype.__transFinishedCb) {
|
|
5559
|
-
//
|
|
5560
|
-
//
|
|
5561
|
-
//
|
|
5562
|
-
//
|
|
5563
|
-
|
|
5564
|
-
// actually uses -- see `__executeRequests`) and, if it's not supported,
|
|
5565
|
-
// just call the default (the driver auto-commits on its own).
|
|
5566
|
-
var dbConn = me.db && me.db.__db;
|
|
5567
|
-
var dbMethodName = me.mode === 'readonly' ? 'readTransaction' : 'transaction';
|
|
5568
|
-
var supportsNonstandardTransCb = Boolean(dbConn && typeof dbConn[dbMethodName] === 'function' && dbConn[dbMethodName].length >= 4);
|
|
5569
|
-
if (!supportsNonstandardTransCb) {
|
|
5581
|
+
// Waiting here for the non-standard 4th callback to install the real
|
|
5582
|
+
// `__transFinishedCb` would defer forever on a standard driver, which
|
|
5583
|
+
// never invokes it -- call the default instead (the driver auto-commits
|
|
5584
|
+
// on its own).
|
|
5585
|
+
if (me.__usesStandardDriver()) {
|
|
5570
5586
|
me.__transFinishedCbFired = true;
|
|
5571
5587
|
me.__transFinishedCb(err, cb);
|
|
5572
5588
|
return;
|
|
@@ -5605,10 +5621,56 @@
|
|
|
5605
5621
|
// `readTransaction` is optimized, at least in `node-websql`
|
|
5606
5622
|
function executeRequests(tx) {
|
|
5607
5623
|
me.__tx = tx;
|
|
5624
|
+
var isStandardDriver = me.__usesStandardDriver();
|
|
5608
5625
|
/** @type {RequestInfo} */
|
|
5609
5626
|
var q,
|
|
5610
5627
|
i = -1;
|
|
5611
5628
|
|
|
5629
|
+
// On a standard driver, `keepAliveAndWait` issues a SQL query, which
|
|
5630
|
+
// is a macrotask. Otherwise it issues ten microtasks.
|
|
5631
|
+
var keepAliveAttempts = isStandardDriver ? 1 : 10;
|
|
5632
|
+
|
|
5633
|
+
/**
|
|
5634
|
+
* A continuation that must still be able to observe the
|
|
5635
|
+
* transaction as safe to extend (e.g., re-checking whether an
|
|
5636
|
+
* `await`-based follow-up request has arrived yet, or giving a
|
|
5637
|
+
* same-tick microtask scheduled from a handler a chance to run
|
|
5638
|
+
* first) can normally just be deferred via `queueMicrotask`.
|
|
5639
|
+
* That alone isn't safe on a standard (3-argument) driver,
|
|
5640
|
+
* though: it finalizes its own underlying SQL transaction
|
|
5641
|
+
* synchronously, as soon as it sees no further `executeSql`
|
|
5642
|
+
* call already in flight or queued, and a microtask hop by
|
|
5643
|
+
* itself never issues one -- so the driver already considers
|
|
5644
|
+
* the transaction done by the time the deferred continuation
|
|
5645
|
+
* runs, silently dropping whatever it tries to do next. Issuing
|
|
5646
|
+
* a harmless `SELECT 1` instead keeps the driver's own queue
|
|
5647
|
+
* non-empty across that same gap, at the cost of a real SQL
|
|
5648
|
+
* round trip; Node's driver doesn't need this since its real
|
|
5649
|
+
* commit/rollback is already deferred separately, via
|
|
5650
|
+
* `nonstandardTransCb`.
|
|
5651
|
+
* @param {() => void} cb
|
|
5652
|
+
* @returns {void}
|
|
5653
|
+
*/
|
|
5654
|
+
function keepAliveAndWait(cb) {
|
|
5655
|
+
if (!isStandardDriver) {
|
|
5656
|
+
queueMicrotask(cb);
|
|
5657
|
+
return;
|
|
5658
|
+
}
|
|
5659
|
+
try {
|
|
5660
|
+
tx.executeSql('SELECT 1', [], function () {
|
|
5661
|
+
cb();
|
|
5662
|
+
}, function () {
|
|
5663
|
+
cb();
|
|
5664
|
+
return false; // Don't roll back the transaction over a keep-alive no-op
|
|
5665
|
+
});
|
|
5666
|
+
} catch (err) {
|
|
5667
|
+
// The driver has already finalized the transaction (or otherwise
|
|
5668
|
+
// rejected the call) -- nothing left to hold open. We explicitly
|
|
5669
|
+
// abort the transaction here.
|
|
5670
|
+
me.__abortTransaction(/** @type {Error|DOMException} */err);
|
|
5671
|
+
}
|
|
5672
|
+
}
|
|
5673
|
+
|
|
5612
5674
|
/**
|
|
5613
5675
|
* @typedef {unknown} IDBRequestResult
|
|
5614
5676
|
*/
|
|
@@ -5802,9 +5864,9 @@
|
|
|
5802
5864
|
* from a microtask -- so if the JS-level queue is merely found
|
|
5803
5865
|
* empty here, that doesn't yet mean no more work is coming, only
|
|
5804
5866
|
* that none has been queued *yet*. Re-check across a small, bounded
|
|
5805
|
-
* number of further
|
|
5806
|
-
* chain like `await store.put(...); await store.get(...)`
|
|
5807
|
-
* up) before finally concluding the transaction is genuinely done.
|
|
5867
|
+
* number of further turns (see `keepAliveAndWait`, letting a typical
|
|
5868
|
+
* `await` chain like `await store.put(...); await store.get(...)`
|
|
5869
|
+
* catch up) before finally concluding the transaction is genuinely done.
|
|
5808
5870
|
* Applies to `readonly` transactions too, not just `readwrite`/
|
|
5809
5871
|
* `versionchange`: a `readonly` transaction's `complete` event
|
|
5810
5872
|
* can otherwise fire synchronously, immediately after its last
|
|
@@ -5812,9 +5874,11 @@
|
|
|
5812
5874
|
* consumer of that same handler (e.g. one that resolves a
|
|
5813
5875
|
* promise from within `onsuccess` and only attaches `oncomplete`
|
|
5814
5876
|
* afterward) ever gets a turn to run, so it can miss `complete`
|
|
5815
|
-
*
|
|
5816
|
-
*
|
|
5817
|
-
*
|
|
5877
|
+
* afterward) ever gets a turn to run, so it can miss `complete`
|
|
5878
|
+
* entirely. On a non-standard driver, `readonly` requests don't hold
|
|
5879
|
+
* a real SQL transaction open, so there's no file-lock/connection
|
|
5880
|
+
* collision risk. On a standard driver, the wait now issues real SQL
|
|
5881
|
+
* inside the read transaction, so this does carry a slight risk.
|
|
5818
5882
|
* @param {number} attemptsLeft
|
|
5819
5883
|
* @returns {void}
|
|
5820
5884
|
*/
|
|
@@ -5834,7 +5898,7 @@
|
|
|
5834
5898
|
}
|
|
5835
5899
|
return;
|
|
5836
5900
|
}
|
|
5837
|
-
|
|
5901
|
+
keepAliveAndWait(function () {
|
|
5838
5902
|
checkQueueEntry(attemptsLeft - 1);
|
|
5839
5903
|
});
|
|
5840
5904
|
}
|
|
@@ -5849,7 +5913,7 @@
|
|
|
5849
5913
|
}
|
|
5850
5914
|
i++;
|
|
5851
5915
|
if (i >= me.__requests.length) {
|
|
5852
|
-
checkQueueEntry(
|
|
5916
|
+
checkQueueEntry(keepAliveAttempts);
|
|
5853
5917
|
return;
|
|
5854
5918
|
}
|
|
5855
5919
|
runQueuedRequest();
|
|
@@ -5886,10 +5950,10 @@
|
|
|
5886
5950
|
}
|
|
5887
5951
|
i++;
|
|
5888
5952
|
if (i >= me.__requests.length) {
|
|
5889
|
-
checkQueueEntry(
|
|
5953
|
+
checkQueueEntry(keepAliveAttempts);
|
|
5890
5954
|
return;
|
|
5891
5955
|
}
|
|
5892
|
-
|
|
5956
|
+
keepAliveAndWait(function () {
|
|
5893
5957
|
if (me.__errored || me.__requestsFinished) {
|
|
5894
5958
|
return;
|
|
5895
5959
|
}
|
|
@@ -13892,10 +13956,11 @@
|
|
|
13892
13956
|
setNonIDBGlobals();
|
|
13893
13957
|
}
|
|
13894
13958
|
}
|
|
13895
|
-
/*
|
|
13959
|
+
/* c8 ignore start -- TS guard */
|
|
13896
13960
|
if (!IDB.shimIndexedDB) {
|
|
13897
13961
|
return;
|
|
13898
13962
|
}
|
|
13963
|
+
/* c8 ignore stop -- TS guard */
|
|
13899
13964
|
IDB.shimIndexedDB.__setConnectionQueueOrigin();
|
|
13900
13965
|
}
|
|
13901
13966
|
};
|