indexeddbshim 17.2.2 → 17.3.0
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 +8 -5
- package/dist/CFG.d.ts +1 -1
- package/dist/CFG.d.ts.map +1 -1
- package/dist/DOMException.d.ts +21 -7
- package/dist/DOMException.d.ts.map +1 -1
- package/dist/DOMStringList.d.ts.map +1 -1
- package/dist/Event.d.ts +12 -6
- package/dist/Event.d.ts.map +1 -1
- package/dist/IDBCursor.d.ts +125 -7
- package/dist/IDBCursor.d.ts.map +1 -1
- package/dist/IDBDatabase.d.ts +17 -10
- package/dist/IDBDatabase.d.ts.map +1 -1
- package/dist/IDBFactory.d.ts +5 -0
- package/dist/IDBFactory.d.ts.map +1 -1
- package/dist/IDBIndex.d.ts +43 -13
- package/dist/IDBIndex.d.ts.map +1 -1
- package/dist/IDBKeyRange.d.ts +6 -2
- package/dist/IDBKeyRange.d.ts.map +1 -1
- package/dist/IDBObjectStore.d.ts +66 -17
- package/dist/IDBObjectStore.d.ts.map +1 -1
- package/dist/IDBRecord.d.ts +44 -0
- package/dist/IDBRecord.d.ts.map +1 -0
- package/dist/IDBRequest.d.ts +2 -2
- package/dist/IDBRequest.d.ts.map +1 -1
- package/dist/IDBTransaction.d.ts +43 -15
- package/dist/IDBTransaction.d.ts.map +1 -1
- package/dist/IDBVersionChangeEvent.d.ts +23 -12
- package/dist/IDBVersionChangeEvent.d.ts.map +1 -1
- package/dist/Key.d.ts +7 -6
- package/dist/Key.d.ts.map +1 -1
- package/dist/Sca.d.ts +15 -0
- package/dist/Sca.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +59 -23
- package/dist/indexeddbshim-Key.js.map +1 -1
- package/dist/indexeddbshim-Key.min.js +2 -2
- package/dist/indexeddbshim-Key.min.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +3058 -1167
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +2627 -986
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +4 -4
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +3058 -1167
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +2627 -986
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +4 -4
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +2627 -986
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +4 -4
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/node-UnicodeIdentifiers.d.ts +2 -2
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/nodeSQLiteDatabase.d.ts +13 -14
- package/dist/nodeSQLiteDatabase.d.ts.map +1 -1
- package/dist/nodeWebSQL.d.ts +17 -1
- package/dist/nodeWebSQL.d.ts.map +1 -1
- package/dist/setGlobalVars.d.ts +2 -2
- package/dist/setGlobalVars.d.ts.map +1 -1
- package/dist/util.d.ts +15 -0
- package/dist/util.d.ts.map +1 -1
- package/examples/IDBKeyUtils.html +0 -1
- package/package.json +27 -21
- package/src/CFG.js +2 -1
- package/src/DOMException.js +38 -12
- package/src/DOMStringList.js +21 -2
- package/src/Event.js +9 -4
- package/src/IDBCursor.js +346 -18
- package/src/IDBDatabase.js +33 -16
- package/src/IDBFactory.js +104 -57
- package/src/IDBIndex.js +78 -45
- package/src/IDBKeyRange.js +8 -2
- package/src/IDBObjectStore.js +89 -65
- package/src/IDBRecord.js +96 -0
- package/src/IDBRequest.js +7 -7
- package/src/IDBTransaction.js +335 -67
- package/src/IDBVersionChangeEvent.js +37 -30
- package/src/Key.js +36 -18
- package/src/Sca.js +22 -1
- package/src/browser-UnicodeIdentifiers.js +3 -1
- package/src/browser-noninvasive.js +3 -1
- package/src/browser.js +3 -1
- package/src/node-UnicodeIdentifiers.js +1 -1
- package/src/node.js +1 -1
- package/src/nodeSQLiteDatabase.js +67 -2
- package/src/nodeWebSQL.js +22 -2
- package/src/setGlobalVars.js +5 -5
- package/src/util.js +29 -1
- package/typings/shimIndexedDB.d.ts +1 -1
package/src/IDBFactory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable sonarjs/no-invariant-returns -- Convenient here */
|
|
2
2
|
// eslint-disable-next-line no-restricted-imports -- Can be polyfilled
|
|
3
|
-
import path from 'path';
|
|
3
|
+
import path from 'node:path';
|
|
4
4
|
import SyncPromise from 'sync-promise-expanded';
|
|
5
5
|
|
|
6
6
|
import {createEvent} from './Event.js';
|
|
@@ -18,6 +18,18 @@ import CFG from './CFG.js';
|
|
|
18
18
|
* @typedef {number} Integer
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} WebSQLTransaction
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {import('websql-configurable/lib/websql/WebSQLTransaction.js').SqlErrorCallback} SqlErrorCallback
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {import('websql-configurable/lib/websql/WebSQLResultSet.js').default} WebSQLResultSet
|
|
31
|
+
*/
|
|
32
|
+
|
|
21
33
|
/**
|
|
22
34
|
* @callback DatabaseDeleted
|
|
23
35
|
* @returns {void}
|
|
@@ -52,7 +64,7 @@ const hasNullOrigin = () => CFG.checkOrigin !== false && (getOrigin() === 'null'
|
|
|
52
64
|
* [key: string]: {
|
|
53
65
|
* [key: string]: {
|
|
54
66
|
* req: import('./IDBRequest.js').IDBOpenDBRequestFull,
|
|
55
|
-
* cb: (req: import('./IDBRequest.js').
|
|
67
|
+
* cb: (req: import('./IDBRequest.js').IDBOpenDBRequestFull) => void,
|
|
56
68
|
* }[]
|
|
57
69
|
* }
|
|
58
70
|
* }}
|
|
@@ -78,9 +90,13 @@ function processNextInConnectionQueue (name, origin = getOrigin()) {
|
|
|
78
90
|
queueItems.shift();
|
|
79
91
|
processNextInConnectionQueue(name, origin);
|
|
80
92
|
}
|
|
93
|
+
// Only a terminal (`success`/`error`) event advances the queue --
|
|
94
|
+
// `blocked` means this request is still pending (waiting on other
|
|
95
|
+
// connections to close), so later requests for the same database must
|
|
96
|
+
// keep waiting behind it rather than starting concurrently, per
|
|
97
|
+
// https://w3c.github.io/IndexedDB/#request-connection-queue.
|
|
81
98
|
req.addEventListener('success', removeFromQueue);
|
|
82
99
|
req.addEventListener('error', removeFromQueue);
|
|
83
|
-
req.addEventListener('blocked', removeFromQueue);
|
|
84
100
|
cb(req);
|
|
85
101
|
}
|
|
86
102
|
|
|
@@ -117,7 +133,7 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
|
|
|
117
133
|
// auto-close if unloading
|
|
118
134
|
|
|
119
135
|
/**
|
|
120
|
-
* @param {IDBDatabase} connection
|
|
136
|
+
* @param {import('./IDBDatabase.js').IDBDatabaseFull} connection
|
|
121
137
|
* @returns {boolean|undefined}
|
|
122
138
|
*/
|
|
123
139
|
const connectionIsClosed = (connection) => connection.__closePending;
|
|
@@ -134,6 +150,7 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
|
|
|
134
150
|
return undefined;
|
|
135
151
|
}
|
|
136
152
|
const e = /** @type {Event & IDBVersionChangeEvent} */ (
|
|
153
|
+
// @ts-ignore It's ok; needed under some TS versions
|
|
137
154
|
new IDBVersionChangeEvent('versionchange', {oldVersion, newVersion})
|
|
138
155
|
);
|
|
139
156
|
return new SyncPromise(function (resolve) {
|
|
@@ -156,6 +173,7 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
|
|
|
156
173
|
}
|
|
157
174
|
};
|
|
158
175
|
const e = /** @type {Event & IDBVersionChangeEvent} */ (
|
|
176
|
+
// @ts-ignore It's ok; needed under some TS versions
|
|
159
177
|
new IDBVersionChangeEvent('blocked', {oldVersion, newVersion})
|
|
160
178
|
);
|
|
161
179
|
setTimeout(() => {
|
|
@@ -163,7 +181,10 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
|
|
|
163
181
|
if (!connectionsClosed()) {
|
|
164
182
|
openConnections.forEach((connection) => {
|
|
165
183
|
if (!connectionIsClosed(connection)) {
|
|
166
|
-
|
|
184
|
+
// Several concurrently-blocked requests can each be
|
|
185
|
+
// waiting on this same connection, so append
|
|
186
|
+
// rather than overwrite -- see `IDBDatabase.close`.
|
|
187
|
+
connection.__unblocking.push(unblocking);
|
|
167
188
|
}
|
|
168
189
|
});
|
|
169
190
|
} else {
|
|
@@ -275,7 +296,7 @@ function closeCachedWebSQLConnections (name, cb) {
|
|
|
275
296
|
* @param {string} name
|
|
276
297
|
* @param {string} escapedDatabaseName
|
|
277
298
|
* @param {DatabaseDeleted} databaseDeleted
|
|
278
|
-
* @param {(tx:
|
|
299
|
+
* @param {(tx: WebSQLTransaction|Error|(Error & {code?: number}), err?: (Error & {code?: number})) => boolean} dbError
|
|
279
300
|
* @returns {void}
|
|
280
301
|
*/
|
|
281
302
|
function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, databaseDeleted, dbError) {
|
|
@@ -311,10 +332,11 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
|
|
|
311
332
|
closeCachedWebSQLConnections(name, () => {
|
|
312
333
|
fs.unlink(path.join(CFG.databaseBasePath || '', escapedDatabaseName), (err) => {
|
|
313
334
|
if (err && err.code !== 'ENOENT') { // Ignore if file is already deleted
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
335
|
+
const removalError = /** @type {Error & {code?: number}} */ (
|
|
336
|
+
new Error('Error removing database file: ' + escapedDatabaseName + ' ' + err)
|
|
337
|
+
);
|
|
338
|
+
removalError.code = 0;
|
|
339
|
+
dbError(removalError);
|
|
318
340
|
return;
|
|
319
341
|
}
|
|
320
342
|
databaseDeleted();
|
|
@@ -342,7 +364,7 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
|
|
|
342
364
|
// Delete all tables in this database, maintained in the sys table
|
|
343
365
|
tx.executeSql('DROP TABLE ' + util.escapeStoreNameForSQL(
|
|
344
366
|
util.unescapeSQLiteResponse( // Avoid double-escaping
|
|
345
|
-
tables.item(i).name
|
|
367
|
+
/** @type {{name: string}} */ (tables.item(i)).name
|
|
346
368
|
)
|
|
347
369
|
), [], function () {
|
|
348
370
|
deleteTables(i + 1);
|
|
@@ -369,18 +391,18 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
|
|
|
369
391
|
* Creates the sysDB to keep track of version numbers for databases.
|
|
370
392
|
* @param {OpenDatabase} __openDatabase
|
|
371
393
|
* @param {CreateSysDBSuccessCallback} success
|
|
372
|
-
* @param {(tx:
|
|
394
|
+
* @param {(tx: WebSQLTransaction|(Error & {code?: number})|Error, err?: (Error & {code?: number})) => void} failure
|
|
373
395
|
* @returns {void}
|
|
374
396
|
*/
|
|
375
397
|
function createSysDB (__openDatabase, success, failure) {
|
|
376
398
|
/**
|
|
377
399
|
*
|
|
378
|
-
* @param {boolean|
|
|
379
|
-
* @param {
|
|
400
|
+
* @param {boolean|WebSQLTransaction|(Error & {code?: number})} tx
|
|
401
|
+
* @param {(Error & {code?: number})} [err]
|
|
380
402
|
* @returns {void}
|
|
381
403
|
*/
|
|
382
404
|
function sysDbCreateError (tx, err) {
|
|
383
|
-
const er = webSQLErrback(/** @type {
|
|
405
|
+
const er = webSQLErrback(/** @type {(Error & {code?: number})} */ (err) || tx);
|
|
384
406
|
if (CFG.DEBUG) { console.log('Error in sysdb transaction - when creating dbVersions', err); }
|
|
385
407
|
failure(er);
|
|
386
408
|
}
|
|
@@ -412,9 +434,9 @@ function createSysDB (__openDatabase, success, failure) {
|
|
|
412
434
|
'CREATE INDEX IF NOT EXISTS dbvname ON dbVersions(name)',
|
|
413
435
|
[],
|
|
414
436
|
success,
|
|
415
|
-
/** @type {
|
|
437
|
+
/** @type {SqlErrorCallback} */ (sysDbCreateError)
|
|
416
438
|
);
|
|
417
|
-
}, /** @type {
|
|
439
|
+
}, /** @type {SqlErrorCallback} */ (sysDbCreateError));
|
|
418
440
|
}, sysDbCreateError);
|
|
419
441
|
}
|
|
420
442
|
}
|
|
@@ -440,7 +462,9 @@ function IDBFactory () {
|
|
|
440
462
|
* __openDatabase: OpenDatabase,
|
|
441
463
|
* __connections: {
|
|
442
464
|
* [key: string]: import('./IDBDatabase.js').IDBDatabaseFull[]
|
|
443
|
-
* }
|
|
465
|
+
* },
|
|
466
|
+
* __forceClose: (dbName: string, connIdx: Integer, msg: string) => void,
|
|
467
|
+
* __setConnectionQueueOrigin: (origin?: string) => void
|
|
444
468
|
* }} IDBFactoryFull
|
|
445
469
|
*/
|
|
446
470
|
|
|
@@ -451,8 +475,10 @@ const IDBFactoryAlias = IDBFactory;
|
|
|
451
475
|
IDBFactory.__createInstance = function () {
|
|
452
476
|
/**
|
|
453
477
|
* @class
|
|
478
|
+
* @this {IDBFactoryFull}
|
|
454
479
|
*/
|
|
455
480
|
function IDBFactory () {
|
|
481
|
+
// @ts-expect-error It's ok
|
|
456
482
|
this[Symbol.toStringTag] = 'IDBFactory';
|
|
457
483
|
this.__connections = {};
|
|
458
484
|
}
|
|
@@ -515,8 +541,8 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
515
541
|
|
|
516
542
|
/**
|
|
517
543
|
*
|
|
518
|
-
* @param {
|
|
519
|
-
* @param {
|
|
544
|
+
* @param {WebSQLTransaction|Error|(Error & {code?: number})} tx
|
|
545
|
+
* @param {(Error & {code?: number})} [err]
|
|
520
546
|
* @returns {boolean}
|
|
521
547
|
*/
|
|
522
548
|
function dbCreateError (tx, err) {
|
|
@@ -536,7 +562,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
536
562
|
|
|
537
563
|
/**
|
|
538
564
|
*
|
|
539
|
-
* @param {
|
|
565
|
+
* @param {WebSQLTransaction} tx
|
|
540
566
|
* @param {DatabaseFull} db
|
|
541
567
|
* @param {Integer} oldVersion
|
|
542
568
|
* @returns {void}
|
|
@@ -562,9 +588,9 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
562
588
|
// DB Upgrade in progress
|
|
563
589
|
/**
|
|
564
590
|
*
|
|
565
|
-
* @param {
|
|
566
|
-
* @param {boolean|
|
|
567
|
-
* @param {(tx?:
|
|
591
|
+
* @param {WebSQLTransaction} systx
|
|
592
|
+
* @param {boolean|(Error & {code?: number})|DOMException|Error} err
|
|
593
|
+
* @param {(tx?: WebSQLTransaction|(Error & {code?: number}), err?: (Error & {code?: number})|WebSQLResultSet) => boolean} cb
|
|
568
594
|
* @returns {void}
|
|
569
595
|
*/
|
|
570
596
|
let sysdbFinishedCb = function (systx, err, cb) {
|
|
@@ -622,37 +648,56 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
622
648
|
*/
|
|
623
649
|
function versionSet () {
|
|
624
650
|
const e = /** @type {import('eventtargeter').EventWithProps & Event & IDBVersionChangeEvent} */ (
|
|
651
|
+
// @ts-ignore It's ok; needed under some TS versions
|
|
625
652
|
new IDBVersionChangeEvent('upgradeneeded', {oldVersion, newVersion: version})
|
|
626
653
|
);
|
|
627
654
|
req.__result = connection;
|
|
628
655
|
connection.__upgradeTransaction = req.__transaction = req.__result.__versionTransaction = IDBTransaction.__createInstance(req.__result, req.__result.objectStoreNames, 'versionchange');
|
|
629
656
|
req.__done = true;
|
|
630
657
|
|
|
631
|
-
req.transaction.__addNonRequestToTransactionQueue(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
658
|
+
req.transaction.__addNonRequestToTransactionQueue(
|
|
659
|
+
/**
|
|
660
|
+
* @param {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} tx
|
|
661
|
+
* @param {ObjectArray} args
|
|
662
|
+
* @param {(result?: any, req?: import('./IDBRequest.js').IDBRequestFull) => void} finished
|
|
663
|
+
* @returns {void}
|
|
664
|
+
*/
|
|
665
|
+
function onupgradeneeded (tx, args, finished /* , error */) {
|
|
666
|
+
// Unlike ordinary requests, this dispatch doesn't go through
|
|
667
|
+
// `IDBTransaction`'s own `success`/`error` closures, so it must
|
|
668
|
+
// open/close the transaction's active-handler window itself.
|
|
669
|
+
req.transaction.__handlerActive = true;
|
|
670
|
+
req.dispatchEvent(e);
|
|
671
|
+
req.transaction.__handlerActive = false;
|
|
672
|
+
|
|
673
|
+
if (e.__legacyOutputDidListenersThrowError) {
|
|
674
|
+
logError('Error', 'An error occurred in an upgradeneeded handler attached to request chain', /** @type {Error} */ (e.__legacyOutputDidListenersThrowError)); // We do nothing else with this error as per spec
|
|
675
|
+
req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
finished();
|
|
638
679
|
}
|
|
639
|
-
|
|
640
|
-
});
|
|
680
|
+
);
|
|
641
681
|
|
|
642
682
|
// eslint-disable-next-line camelcase -- Clear API
|
|
643
|
-
req.transaction.on__beforecomplete =
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
req.
|
|
683
|
+
req.transaction.on__beforecomplete =
|
|
684
|
+
/**
|
|
685
|
+
* @param {Event & {complete: () => void}} ev
|
|
686
|
+
* @returns {void}
|
|
687
|
+
*/
|
|
688
|
+
function (ev) {
|
|
689
|
+
connection.__upgradeTransaction = null;
|
|
690
|
+
/** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
|
|
691
|
+
req.__result
|
|
692
|
+
).__versionTransaction = null;
|
|
693
|
+
sysdbFinishedCb(systx, false, function () {
|
|
694
|
+
req.transaction.__callTransFinishedCb(false, function () {
|
|
695
|
+
ev.complete();
|
|
696
|
+
req.__transaction = null;
|
|
697
|
+
});
|
|
698
|
+
return false;
|
|
652
699
|
});
|
|
653
|
-
|
|
654
|
-
});
|
|
655
|
-
};
|
|
700
|
+
};
|
|
656
701
|
|
|
657
702
|
// eslint-disable-next-line camelcase -- Clear API
|
|
658
703
|
req.transaction.on__preabort = function () {
|
|
@@ -779,12 +824,12 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
779
824
|
if ((useMemoryDatabase || useDatabaseCache) && Object.hasOwn(websqlDBCache, name) && Object.hasOwn(websqlDBCache[name], version)) {
|
|
780
825
|
db = websqlDBCache[name][version];
|
|
781
826
|
} else {
|
|
782
|
-
db = me.__openDatabase(
|
|
827
|
+
db = /** @type {DatabaseFull} */ (me.__openDatabase(
|
|
783
828
|
useMemoryDatabase ? CFG.memoryDatabase : path.join(CFG.databaseBasePath || '', escapedDatabaseName),
|
|
784
829
|
'1',
|
|
785
830
|
name,
|
|
786
831
|
CFG.DEFAULT_DB_SIZE
|
|
787
|
-
);
|
|
832
|
+
));
|
|
788
833
|
if (useDatabaseCache) {
|
|
789
834
|
if (!(Object.hasOwn(websqlDBCache, name))) {
|
|
790
835
|
websqlDBCache[name] = {};
|
|
@@ -818,7 +863,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
818
863
|
return;
|
|
819
864
|
}
|
|
820
865
|
tx.executeSql('CREATE INDEX IF NOT EXISTS sysname ON __sys__(name)', [], setup, dbCreateError);
|
|
821
|
-
}, /** @type {
|
|
866
|
+
}, /** @type {SqlErrorCallback} */ (dbCreateError));
|
|
822
867
|
}, dbCreateError);
|
|
823
868
|
}
|
|
824
869
|
|
|
@@ -840,7 +885,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
840
885
|
// Database with this name does not exist
|
|
841
886
|
openDB(0);
|
|
842
887
|
} else {
|
|
843
|
-
openDB(data.rows.item(0).version);
|
|
888
|
+
openDB(/** @type {{version: Integer}} */ (data.rows.item(0)).version);
|
|
844
889
|
}
|
|
845
890
|
}, dbCreateError);
|
|
846
891
|
}, dbCreateError);
|
|
@@ -904,8 +949,8 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
904
949
|
// `UnknownError` as we may require upon a SQL deletion error
|
|
905
950
|
/**
|
|
906
951
|
*
|
|
907
|
-
* @param {
|
|
908
|
-
* @param {
|
|
952
|
+
* @param {WebSQLTransaction|(Error & {code?: number})|Error} tx
|
|
953
|
+
* @param {(Error & {code?: number})|boolean} [err]
|
|
909
954
|
* @returns {boolean}
|
|
910
955
|
*/
|
|
911
956
|
function dbError (tx, err) {
|
|
@@ -920,7 +965,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
920
965
|
// transaction, corrupting that connection's task queue (see issue with unrelated `open()` calls
|
|
921
966
|
// failing/crashing after a `deleteDatabase` file-removal error).
|
|
922
967
|
calledDBError = true;
|
|
923
|
-
const er = webSQLErrback(/** @type {
|
|
968
|
+
const er = webSQLErrback(/** @type {(Error & {code?: number})} */ (err || tx));
|
|
924
969
|
sysdbFinishedCbDelete(true, function () {
|
|
925
970
|
req.__done = true;
|
|
926
971
|
req.__error = er;
|
|
@@ -944,6 +989,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
944
989
|
req.__result = undefined;
|
|
945
990
|
req.__done = true;
|
|
946
991
|
const e = /** @type {Event & IDBVersionChangeEvent} */ (
|
|
992
|
+
// @ts-ignore It's ok; needed under some TS versions
|
|
947
993
|
new IDBVersionChangeEvent('success', {oldVersion: version, newVersion: null})
|
|
948
994
|
);
|
|
949
995
|
req.dispatchEvent(e);
|
|
@@ -966,7 +1012,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
966
1012
|
completeDatabaseDelete();
|
|
967
1013
|
return undefined;
|
|
968
1014
|
}
|
|
969
|
-
({version} = data.rows.item(0));
|
|
1015
|
+
({version} = /** @type {{version: Integer}} */ (data.rows.item(0)));
|
|
970
1016
|
|
|
971
1017
|
const openConnections = me.__connections[name] || [];
|
|
972
1018
|
triggerAnyVersionChangeAndBlockedEvents(openConnections, req, version, null).then(function () {
|
|
@@ -1050,15 +1096,15 @@ IDBFactory.prototype.databases = function () {
|
|
|
1050
1096
|
}
|
|
1051
1097
|
/**
|
|
1052
1098
|
*
|
|
1053
|
-
* @param {true|
|
|
1054
|
-
* @param {
|
|
1099
|
+
* @param {true|WebSQLTransaction|(Error & {code?: number})|DOMException|Error} tx
|
|
1100
|
+
* @param {(Error & {code?: number})|DOMException|Error} [err]
|
|
1055
1101
|
* @returns {boolean}
|
|
1056
1102
|
*/
|
|
1057
1103
|
function dbGetDatabaseNamesError (tx, err) {
|
|
1058
1104
|
if (calledDbCreateError) {
|
|
1059
1105
|
return false;
|
|
1060
1106
|
}
|
|
1061
|
-
const er = err ? webSQLErrback(/** @type {
|
|
1107
|
+
const er = err ? webSQLErrback(/** @type {(Error & {code?: number})} */ (err)) : tx;
|
|
1062
1108
|
calledDbCreateError = true;
|
|
1063
1109
|
reject(er);
|
|
1064
1110
|
return false;
|
|
@@ -1068,7 +1114,7 @@ IDBFactory.prototype.databases = function () {
|
|
|
1068
1114
|
sysReadTx.executeSql('SELECT "name", "version" FROM dbVersions', [], function (sysReadTx, data) {
|
|
1069
1115
|
const dbNames = [];
|
|
1070
1116
|
for (let i = 0; i < data.rows.length; i++) {
|
|
1071
|
-
const {name, version} = data.rows.item(i);
|
|
1117
|
+
const {name, version} = /** @type {{name: string, version: Integer}} */ (data.rows.item(i));
|
|
1072
1118
|
dbNames.push({
|
|
1073
1119
|
name: util.unescapeSQLiteResponse(name),
|
|
1074
1120
|
version
|
|
@@ -1138,6 +1184,7 @@ IDBFactory.prototype.__setConnectionQueueOrigin = function (origin = getOrigin()
|
|
|
1138
1184
|
IDBFactory.prototype[Symbol.toStringTag] = 'IDBFactoryPrototype';
|
|
1139
1185
|
|
|
1140
1186
|
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
1187
|
+
util.setOperationNames(IDBFactory.prototype);
|
|
1141
1188
|
Object.defineProperty(IDBFactory, 'prototype', {
|
|
1142
1189
|
writable: false
|
|
1143
1190
|
});
|