1
- /*! indexeddbshim - v14 .0.0 - 7/16 /2024 */
1
+ /*! indexeddbshim - v15 .0.0 - 8/3 /2024 */
2
2
3
3
'use strict' ;
4
4
@@ -2679,6 +2679,14 @@ const signValues = ['negativeInfinity', 'bigNegative', 'smallNegative', 'smallPo
2679
2679
* @typedef {any } AnyValue
2680
2680
*/
2681
2681
2682
+ /**
2683
+ * @type {{
2684
+ * [key: string]: {
2685
+ * encode: (param: any, inArray?: boolean) => string,
2686
+ * decode: (param: string, inArray?: boolean) => any
2687
+ * }
2688
+ * }}
2689
+ */
2682
2690
const types$1 = {
2683
2691
invalid : {
2684
2692
/**
@@ -3534,7 +3542,6 @@ function encode$1(key, inArray) {
3534
3542
return null ;
3535
3543
}
3536
3544
// array, date, number, string, binary (should already have detected "invalid")
3537
- // @ts -expect-error Argument may be ignored
3538
3545
return types$1 [ getKeyType ( key ) ] . encode ( key , inArray ) ;
3539
3546
}
3540
3547
@@ -5077,7 +5084,7 @@ function _toPropertyKey(e) {
5077
5084
if ( "object" != typeof e || null === e ) return e ;
5078
5085
var r = e [ Symbol . toPrimitive ] ;
5079
5086
if ( void 0 !== r ) {
5080
- var n = r . call ( e , t ) ;
5087
+ var n = r . call ( e , t ) ;
5081
5088
if ( "object" != typeof n ) return n ;
5082
5089
throw new TypeError ( "@@toPrimitive must return a primitive value." ) ;
5083
5090
}
@@ -5133,7 +5140,7 @@ e.__typeson__type__ = "TypesonPromise", "undefined" != typeof Symbol && Object.d
5133
5140
var t = Object . hasOwn ,
5134
5141
r = Object . getPrototypeOf ;
5135
5142
function isThenable ( e , t ) {
5136
- return isObject ( e ) && "function" == typeof e . then && ( ! t ) ;
5143
+ return isObject ( e ) && "function" == typeof e . then && ( ! t ) ;
5137
5144
}
5138
5145
function toStringTag ( e ) {
5139
5146
return Object . prototype . toString . call ( e ) . slice ( 8 , - 1 ) ;
@@ -8310,6 +8317,8 @@ const readonlyProperties = ['name', 'version', 'objectStoreNames'];
8310
8317
function IDBDatabase ( ) {
8311
8318
this . __versionTransaction = null ;
8312
8319
this . __objectStores = null ;
8320
+ /** @type {import('./IDBTransaction.js').IDBTransactionFull[] } */
8321
+ this . __transactions = [ ] ;
8313
8322
throw new TypeError ( 'Illegal constructor' ) ;
8314
8323
}
8315
8324
const IDBDatabaseAlias = IDBDatabase ;
@@ -8372,6 +8381,8 @@ IDBDatabase.__createInstance = function (db, name, oldVersion, version, storePro
8372
8381
this . __setOptions ( {
8373
8382
legacyOutputDidListenersThrowFlag : true // Event hook for IndexedB
8374
8383
} ) ;
8384
+
8385
+ /** @type {import('./IDBTransaction.js').IDBTransactionFull[] } */
8375
8386
this . __transactions = [ ] ;
8376
8387
8377
8388
/** @type {{[key: string]: IDBObjectStore} } */
@@ -8501,6 +8512,7 @@ IDBDatabase.prototype.close = function () {
8501
8512
if ( this . __unblocking ) {
8502
8513
this . __unblocking . check ( ) ;
8503
8514
}
8515
+ this . __transactions = [ ] ;
8504
8516
} ;
8505
8517
8506
8518
/**
@@ -8598,6 +8610,7 @@ IDBDatabase.prototype.__forceClose = function (msg) {
8598
8610
} ;
8599
8611
trans . __abortTransaction ( createDOMException ( 'AbortError' , 'The connection was force-closed: ' + ( msg || '' ) ) ) ;
8600
8612
} ) ;
8613
+ me . __transactions = [ ] ;
8601
8614
} ;
8602
8615
defineOuterInterface ( IDBDatabase . prototype , listeners ) ;
8603
8616
defineReadonlyOuterInterface ( IDBDatabase . prototype , readonlyProperties ) ;
@@ -9197,6 +9210,10 @@ IDBFactory.prototype.open = function (name /* , version */) {
9197
9210
9198
9211
// eslint-disable-next-line camelcase -- Clear API
9199
9212
req . transaction . on__complete = function ( ) {
9213
+ const pos = connection . __transactions . indexOf ( req . transaction ) ;
9214
+ if ( pos > - 1 ) {
9215
+ connection . __transactions . splice ( pos , 1 ) ;
9216
+ }
9200
9217
if ( /** @type {import('./IDBDatabase.js').IDBDatabaseFull } */ req . __result . __closePending ) {
9201
9218
req . __transaction = null ;
9202
9219
const err = createDOMException ( 'AbortError' , 'The connection has been closed.' ) ;
@@ -9581,9 +9598,10 @@ IDBFactory.prototype.__forceClose = function (dbName, connIdx, msg) {
9581
9598
conn . __forceClose ( msg ) ;
9582
9599
}
9583
9600
if ( isNullish ( dbName ) ) {
9584
- Object . values ( me . __connections ) . forEach ( conn => {
9585
- // @ts -expect-error It's ok
9586
- forceClose ( conn ) ;
9601
+ Object . values ( me . __connections ) . forEach ( connections => {
9602
+ connections . forEach ( connection => {
9603
+ forceClose ( connection ) ;
9604
+ } ) ;
9587
9605
} ) ;
9588
9606
} else if ( ! me . __connections [ dbName ] ) {
9589
9607
console . log ( 'No database connections with that name to force close' ) ;
@@ -9592,7 +9610,7 @@ IDBFactory.prototype.__forceClose = function (dbName, connIdx, msg) {
9592
9610
forceClose ( conn ) ;
9593
9611
} ) ;
9594
9612
} else if ( ! Number . isInteger ( connIdx ) || connIdx < 0 || connIdx > me . __connections [ dbName ] . length - 1 ) {
9595
- throw new TypeError ( 'If providing an argument, __forceClose must be called with a ' + 'numeric index to indicate a specific connection to lose ' ) ;
9613
+ throw new TypeError ( 'If providing an argument, __forceClose must be called with a ' + 'numeric index to indicate a specific connection to close ' ) ;
9596
9614
} else {
9597
9615
forceClose ( me . __connections [ dbName ] [ connIdx ] ) ;
9598
9616
}
0 commit comments