indexeddbshim 17.7.0 → 19.0.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 +13 -3
- package/dist/DOMException.d.ts +5 -9
- package/dist/DOMException.d.ts.map +1 -1
- package/dist/DOMStringList.d.ts +1 -2
- package/dist/DOMStringList.d.ts.map +1 -1
- package/dist/IDBCursor.d.ts +106 -52
- package/dist/IDBCursor.d.ts.map +1 -1
- package/dist/IDBFactory.d.ts.map +1 -1
- package/dist/IDBIndex.d.ts +8 -7
- package/dist/IDBIndex.d.ts.map +1 -1
- package/dist/IDBKeyRange.d.ts +3 -3
- package/dist/IDBKeyRange.d.ts.map +1 -1
- package/dist/IDBObjectStore.d.ts +12 -12
- package/dist/IDBObjectStore.d.ts.map +1 -1
- package/dist/IDBRequest.d.ts +2 -2
- package/dist/IDBRequest.d.ts.map +1 -1
- package/dist/IDBTransaction.d.ts +13 -13
- package/dist/IDBTransaction.d.ts.map +1 -1
- package/dist/Key.d.ts +14 -15
- package/dist/Key.d.ts.map +1 -1
- package/dist/Sca.d.ts +2 -2
- package/dist/Sca.d.ts.map +1 -1
- package/dist/cmp.d.ts +3 -3
- package/dist/cmp.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +37 -46
- 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 +254 -215
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +251 -450
- 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 +254 -215
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +251 -450
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +3 -3
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +251 -450
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +3 -3
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/nodeWebSQL.d.ts +2 -2
- package/dist/nodeWebSQL.d.ts.map +1 -1
- package/dist/setGlobalVars.d.ts +1 -2
- package/dist/setGlobalVars.d.ts.map +1 -1
- package/dist/util.d.ts +35 -22
- package/dist/util.d.ts.map +1 -1
- package/package.json +1 -4
- package/src/CFG.js +1 -1
- package/src/DOMException.js +9 -11
- package/src/DOMStringList.js +6 -11
- package/src/Event.js +1 -4
- package/src/IDBCursor.js +98 -47
- package/src/IDBFactory.js +12 -11
- package/src/IDBIndex.js +10 -12
- package/src/IDBKeyRange.js +6 -5
- package/src/IDBObjectStore.js +32 -27
- package/src/IDBRequest.js +1 -1
- package/src/IDBTransaction.js +11 -11
- package/src/IDBVersionChangeEvent.js +1 -4
- package/src/Key.js +32 -31
- package/src/Sca.js +1 -1
- package/src/cmp.js +2 -2
- package/src/nodeWebSQL.js +5 -2
- package/src/setGlobalVars.js +8 -19
- package/src/util.js +42 -17
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/*! indexeddbshim -
|
|
1
|
+
/*! indexeddbshim - v19.0.0 - 9/3/2026 */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var fs$1 = require('node:fs');
|
|
6
|
-
var path = require('node:path');
|
|
7
6
|
var customOpenDatabase = require('websql-configurable/custom/index.js');
|
|
8
7
|
var SQLiteDatabase = require('websql-configurable/lib/sqlite/SQLiteDatabase.js');
|
|
9
8
|
|
|
@@ -1546,7 +1545,7 @@ val => {
|
|
|
1546
1545
|
// Callback not used by default
|
|
1547
1546
|
// Defaults to true except in Node builds where we can preserve literal NUL with better-sqlite3
|
|
1548
1547
|
'escapeNULForSQLiteStatements', 'sqlMemoryQuota', 'createIndexes'].forEach(prop => {
|
|
1549
|
-
/** @type {(val:
|
|
1548
|
+
/** @type {(val: ConfigValue) => void} */
|
|
1550
1549
|
let validator;
|
|
1551
1550
|
if (Array.isArray(prop)) {
|
|
1552
1551
|
[prop, validator] = prop;
|
|
@@ -1745,8 +1744,32 @@ function sqlLIKEEscape(str) {
|
|
|
1745
1744
|
}
|
|
1746
1745
|
|
|
1747
1746
|
/**
|
|
1748
|
-
*
|
|
1747
|
+
* Minimal replacement for `path.join(base, name)` covering our only use case:
|
|
1748
|
+
* `name` is always a bare file name (no separators and no `.`/`..`), and
|
|
1749
|
+
* `base` is a directory path expected to be absolute and normalized (an
|
|
1750
|
+
* empty string means the current working directory). Unlike `path.join`,
|
|
1751
|
+
* this performs no `.`/`..` resolution. It reuses the separator style of
|
|
1752
|
+
* `base` (backslash only when `base` uses backslashes and no forward
|
|
1753
|
+
* slashes, i.e. a Windows path), otherwise `/`; Node's `fs`, SQLite, and
|
|
1754
|
+
* `websql-configurable` accept either separator on Windows regardless.
|
|
1755
|
+
* Avoiding `node:path` keeps browser bundles free of a path polyfill.
|
|
1756
|
+
* @param {string} base
|
|
1757
|
+
* @param {string} name
|
|
1758
|
+
* @returns {string}
|
|
1759
|
+
*/
|
|
1760
|
+
function joinPath(base, name) {
|
|
1761
|
+
if (!base) {
|
|
1762
|
+
return name;
|
|
1763
|
+
}
|
|
1764
|
+
const sep = base.includes('\\') && !base.includes('/') ? '\\' : '/';
|
|
1765
|
+
return base.replace(/[/\\]+$/u, '') + sep + name;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/* eslint-disable jsdoc/valid-types -- Bug */
|
|
1769
|
+
/**
|
|
1770
|
+
* @typedef {{[Symbol.hasInstance]: (value: unknown) => boolean}} AnyClass
|
|
1749
1771
|
*/
|
|
1772
|
+
/* eslint-enable jsdoc/valid-types -- Bug */
|
|
1750
1773
|
|
|
1751
1774
|
// Babel doesn't seem to provide a means of using the `instanceof` operator with Symbol.hasInstance (yet?)
|
|
1752
1775
|
/**
|
|
@@ -1770,7 +1793,7 @@ function isObj(obj) {
|
|
|
1770
1793
|
|
|
1771
1794
|
/**
|
|
1772
1795
|
*
|
|
1773
|
-
* @param {
|
|
1796
|
+
* @param {AnyValue} obj
|
|
1774
1797
|
* @returns {boolean}
|
|
1775
1798
|
*/
|
|
1776
1799
|
function isDate(obj) {
|
|
@@ -1779,7 +1802,7 @@ function isDate(obj) {
|
|
|
1779
1802
|
|
|
1780
1803
|
/**
|
|
1781
1804
|
*
|
|
1782
|
-
* @param {
|
|
1805
|
+
* @param {AnyValue} obj
|
|
1783
1806
|
* @returns {boolean}
|
|
1784
1807
|
*/
|
|
1785
1808
|
function isBlob(obj) {
|
|
@@ -1788,7 +1811,7 @@ function isBlob(obj) {
|
|
|
1788
1811
|
|
|
1789
1812
|
/**
|
|
1790
1813
|
*
|
|
1791
|
-
* @param {
|
|
1814
|
+
* @param {AnyValue} obj
|
|
1792
1815
|
* @returns {boolean}
|
|
1793
1816
|
*/
|
|
1794
1817
|
function isFile(obj) {
|
|
@@ -1810,7 +1833,7 @@ function isBinary(obj) {
|
|
|
1810
1833
|
/**
|
|
1811
1834
|
*
|
|
1812
1835
|
* @param {AnyValue} obj
|
|
1813
|
-
* @returns {
|
|
1836
|
+
* @returns {obj is Iterable<unknown>}
|
|
1814
1837
|
*/
|
|
1815
1838
|
function isIterable(obj) {
|
|
1816
1839
|
return isObj(obj) &&
|
|
@@ -1862,9 +1885,7 @@ function defineReadonlyOuterInterface(obj, props) {
|
|
|
1862
1885
|
|
|
1863
1886
|
/**
|
|
1864
1887
|
*
|
|
1865
|
-
* @param {object
|
|
1866
|
-
* [key: string]: any
|
|
1867
|
-
* }} obj
|
|
1888
|
+
* @param {object} obj
|
|
1868
1889
|
* @param {string[]} listeners
|
|
1869
1890
|
* @returns {void}
|
|
1870
1891
|
*/
|
|
@@ -1873,13 +1894,13 @@ function defineListenerProperties(obj, listeners) {
|
|
|
1873
1894
|
listeners.forEach(listener => {
|
|
1874
1895
|
const o = {
|
|
1875
1896
|
get [listener]() {
|
|
1876
|
-
return obj
|
|
1897
|
+
return Reflect.get(obj, '__' + listener);
|
|
1877
1898
|
},
|
|
1878
1899
|
/**
|
|
1879
1900
|
* @param {AnyValue} val
|
|
1880
1901
|
*/
|
|
1881
1902
|
set [listener](val) {
|
|
1882
|
-
obj
|
|
1903
|
+
Reflect.set(obj, '__' + listener, val);
|
|
1883
1904
|
}
|
|
1884
1905
|
};
|
|
1885
1906
|
const desc = /** @type {PropertyDescriptor} */
|
|
@@ -1889,7 +1910,7 @@ function defineListenerProperties(obj, listeners) {
|
|
|
1889
1910
|
Object.defineProperty(obj, listener, desc);
|
|
1890
1911
|
});
|
|
1891
1912
|
listeners.forEach(l => {
|
|
1892
|
-
obj
|
|
1913
|
+
Reflect.set(obj, l, null);
|
|
1893
1914
|
});
|
|
1894
1915
|
}
|
|
1895
1916
|
|
|
@@ -1898,7 +1919,7 @@ function defineListenerProperties(obj, listeners) {
|
|
|
1898
1919
|
* @param {object} obj
|
|
1899
1920
|
* @param {string|string[]} props
|
|
1900
1921
|
* @param {null|{
|
|
1901
|
-
* [key: string]:
|
|
1922
|
+
* [key: string]: unknown
|
|
1902
1923
|
* }} getter
|
|
1903
1924
|
* @returns {void}
|
|
1904
1925
|
*/
|
|
@@ -2035,7 +2056,7 @@ function enforceRange(number, type) {
|
|
|
2035
2056
|
}
|
|
2036
2057
|
|
|
2037
2058
|
/**
|
|
2038
|
-
* @typedef {
|
|
2059
|
+
* @typedef {unknown} AnyValue
|
|
2039
2060
|
*/
|
|
2040
2061
|
|
|
2041
2062
|
/**
|
|
@@ -2053,8 +2074,11 @@ function convertToDOMString(v, treatNullAs) {
|
|
|
2053
2074
|
*/
|
|
2054
2075
|
function ToString(o) {
|
|
2055
2076
|
// Todo: See `es-abstract/es7`
|
|
2056
|
-
// `String()` will not throw with Symbols
|
|
2057
|
-
|
|
2077
|
+
// `String()` will not throw with Symbols, but the unchecked `+ ''`
|
|
2078
|
+
// coercion deliberately does (Web IDL requires converting a symbol
|
|
2079
|
+
// to `DOMString` to throw a `TypeError`); the assertion only tells
|
|
2080
|
+
// the compiler to allow the coercion it cannot model.
|
|
2081
|
+
return '' + (/** @type {string} */o); // eslint-disable-line no-implicit-coercion -- Need to throw with symbols
|
|
2058
2082
|
}
|
|
2059
2083
|
|
|
2060
2084
|
/**
|
|
@@ -2161,12 +2185,9 @@ function createEvent(type, debug, evInit) {
|
|
|
2161
2185
|
// We don't add within polyfill repo as might not always be the desired implementation
|
|
2162
2186
|
Object.defineProperty(ShimEvent, Symbol.hasInstance, {
|
|
2163
2187
|
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
2164
|
-
/**
|
|
2165
|
-
* @typedef {any} AnyValue
|
|
2166
|
-
*/
|
|
2167
2188
|
value:
|
|
2168
2189
|
/**
|
|
2169
|
-
* @param {
|
|
2190
|
+
* @param {unknown} obj
|
|
2170
2191
|
* @returns {boolean}
|
|
2171
2192
|
*/
|
|
2172
2193
|
obj => isObj(obj) && 'target' in obj && 'bubbles' in obj && typeof obj.bubbles === 'boolean'
|
|
@@ -2234,12 +2255,9 @@ readonlyProperties$7.forEach(prop => {
|
|
|
2234
2255
|
Object.defineProperty(IDBVersionChangeEvent.prototype, prop, desc);
|
|
2235
2256
|
});
|
|
2236
2257
|
Object.defineProperty(IDBVersionChangeEvent, Symbol.hasInstance, {
|
|
2237
|
-
/**
|
|
2238
|
-
* @typedef {any} AnyValue
|
|
2239
|
-
*/
|
|
2240
2258
|
value:
|
|
2241
2259
|
/**
|
|
2242
|
-
* @param {
|
|
2260
|
+
* @param {unknown} obj
|
|
2243
2261
|
* @returns {boolean}
|
|
2244
2262
|
*/
|
|
2245
2263
|
obj => isObj(obj) && 'oldVersion' in obj && 'defaultPrevented' in obj && typeof obj.defaultPrevented === 'boolean'
|
|
@@ -2495,7 +2513,7 @@ function createNonNativeDOMException(name, message) {
|
|
|
2495
2513
|
|
|
2496
2514
|
/**
|
|
2497
2515
|
* @typedef {{
|
|
2498
|
-
* message: string
|
|
2516
|
+
* message: string
|
|
2499
2517
|
* }} ErrorLike
|
|
2500
2518
|
*/
|
|
2501
2519
|
|
|
@@ -2519,25 +2537,20 @@ function logError(name, message, error) {
|
|
|
2519
2537
|
}
|
|
2520
2538
|
|
|
2521
2539
|
/**
|
|
2522
|
-
* @
|
|
2523
|
-
*/
|
|
2524
|
-
|
|
2525
|
-
/**
|
|
2526
|
-
* @param {ArbitraryValue} obj
|
|
2540
|
+
* @param {unknown} obj
|
|
2527
2541
|
* @returns {boolean}
|
|
2528
2542
|
*/
|
|
2529
2543
|
function isErrorOrDOMErrorOrDOMException(obj) {
|
|
2530
|
-
return obj && typeof obj === 'object' &&
|
|
2531
2544
|
// We don't use util.isObj here as mutual dependency causing problems in Babel with browser
|
|
2532
|
-
typeof obj.name === 'string';
|
|
2545
|
+
return typeof obj === 'object' && obj !== null && 'name' in obj && typeof obj.name === 'string';
|
|
2533
2546
|
}
|
|
2534
2547
|
|
|
2535
2548
|
/**
|
|
2536
2549
|
* Finds the error argument. This is useful because some WebSQL callbacks
|
|
2537
2550
|
* pass the error as the first argument, and some pass it as the second
|
|
2538
2551
|
* argument.
|
|
2539
|
-
* @param {
|
|
2540
|
-
* @returns {
|
|
2552
|
+
* @param {unknown[]} args
|
|
2553
|
+
* @returns {unknown}
|
|
2541
2554
|
*/
|
|
2542
2555
|
function findError(args) {
|
|
2543
2556
|
let err;
|
|
@@ -2549,7 +2562,7 @@ function findError(args) {
|
|
|
2549
2562
|
if (isErrorOrDOMErrorOrDOMException(arg)) {
|
|
2550
2563
|
return arg;
|
|
2551
2564
|
}
|
|
2552
|
-
if (arg && typeof arg.message === 'string') {
|
|
2565
|
+
if (typeof arg === 'object' && arg !== null && 'message' in arg && typeof arg.message === 'string') {
|
|
2553
2566
|
err = arg;
|
|
2554
2567
|
}
|
|
2555
2568
|
}
|
|
@@ -2669,7 +2682,7 @@ function IDBRequest() {
|
|
|
2669
2682
|
* @typedef {IDBRequest & EventTarget & import('eventtargeter').EventTargetInstance & {
|
|
2670
2683
|
* transaction: import('./IDBTransaction.js').IDBTransactionFull,
|
|
2671
2684
|
* __done: boolean,
|
|
2672
|
-
* __result:
|
|
2685
|
+
* __result: unknown,
|
|
2673
2686
|
* __error: null|DOMException|Error,
|
|
2674
2687
|
* __source: null|import('./IDBDatabase.js').IDBDatabaseFull|
|
|
2675
2688
|
* import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
@@ -3125,8 +3138,8 @@ class SyncPromise {
|
|
|
3125
3138
|
|
|
3126
3139
|
/**
|
|
3127
3140
|
* Compares two keys.
|
|
3128
|
-
* @param {import('./Key.js').Key} first
|
|
3129
|
-
* @param {import('./Key.js').Key} second
|
|
3141
|
+
* @param {import('./Key.js').Key|null|undefined} first
|
|
3142
|
+
* @param {import('./Key.js').Key|null|undefined} second
|
|
3130
3143
|
* @returns {0|1|-1}
|
|
3131
3144
|
*/
|
|
3132
3145
|
function cmp(first, second) {
|
|
@@ -3200,12 +3213,11 @@ const safePush = (arr, val) => setArrayValue(arr, arr.length, val);
|
|
|
3200
3213
|
*/
|
|
3201
3214
|
|
|
3202
3215
|
/**
|
|
3203
|
-
* @typedef {
|
|
3216
|
+
* @typedef {unknown} Value
|
|
3204
3217
|
*/
|
|
3205
3218
|
|
|
3206
3219
|
/**
|
|
3207
|
-
* @typedef {
|
|
3208
|
-
* @todo Specify possible value more precisely
|
|
3220
|
+
* @typedef {IDBValidKey} Key
|
|
3209
3221
|
*/
|
|
3210
3222
|
|
|
3211
3223
|
/**
|
|
@@ -3272,15 +3284,11 @@ const encodedCharToKeyType = keyTypes.reduce((o, k) => {
|
|
|
3272
3284
|
*/
|
|
3273
3285
|
const signValues = ['negativeInfinity', 'bigNegative', 'smallNegative', 'smallPositive', 'bigPositive', 'positiveInfinity'];
|
|
3274
3286
|
|
|
3275
|
-
/**
|
|
3276
|
-
* @typedef {any} AnyValue
|
|
3277
|
-
*/
|
|
3278
|
-
|
|
3279
3287
|
/**
|
|
3280
3288
|
* @type {{
|
|
3281
3289
|
* [key: string]: {
|
|
3282
|
-
* encode
|
|
3283
|
-
* decode
|
|
3290
|
+
* encode(param: unknown, inArray?: boolean): string,
|
|
3291
|
+
* decode(param: string, inArray?: boolean): ValueType|undefined
|
|
3284
3292
|
* }
|
|
3285
3293
|
* }}
|
|
3286
3294
|
*/
|
|
@@ -3612,7 +3620,7 @@ function negate(s) {
|
|
|
3612
3620
|
}
|
|
3613
3621
|
|
|
3614
3622
|
/**
|
|
3615
|
-
* @param {
|
|
3623
|
+
* @param {Value} key
|
|
3616
3624
|
* @returns {KeyType|"invalid"}
|
|
3617
3625
|
*/
|
|
3618
3626
|
function getKeyType(key) {
|
|
@@ -3756,7 +3764,7 @@ function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
|
3756
3764
|
case 'array':
|
|
3757
3765
|
{
|
|
3758
3766
|
// May throw (from binary)
|
|
3759
|
-
const arr = /** @type {
|
|
3767
|
+
const arr = /** @type {unknown[]} */input;
|
|
3760
3768
|
const len = arr.length;
|
|
3761
3769
|
safePush(seen, input);
|
|
3762
3770
|
|
|
@@ -3784,7 +3792,7 @@ function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
|
3784
3792
|
message: 'Bad array entry value-to-key conversion'
|
|
3785
3793
|
};
|
|
3786
3794
|
}
|
|
3787
|
-
if (!multiEntry || !fullKeys && keys.every(k => cmp(k, key.value) !== 0) || fullKeys && keys.every(k => cmp(k, key) !== 0)) {
|
|
3795
|
+
if (!multiEntry || !fullKeys && keys.every(k => cmp(/** @type {Key} */k, /** @type {Key} */key.value) !== 0) || fullKeys && keys.every(k => cmp(/** @type {Key} */k, /** @type {Key} */ /** @type {unknown} */key) !== 0)) {
|
|
3788
3796
|
safePush(keys, fullKeys ? key : key.value);
|
|
3789
3797
|
}
|
|
3790
3798
|
} catch (err) {
|
|
@@ -3834,7 +3842,7 @@ function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
|
3834
3842
|
|
|
3835
3843
|
/**
|
|
3836
3844
|
*
|
|
3837
|
-
* @param {
|
|
3845
|
+
* @param {Value} key
|
|
3838
3846
|
* @param {boolean} [fullKeys]
|
|
3839
3847
|
* @returns {KeyValueObject}
|
|
3840
3848
|
* @todo Document other allowable `key`?
|
|
@@ -3949,7 +3957,7 @@ function evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, fullKe
|
|
|
3949
3957
|
}
|
|
3950
3958
|
if (keyPath === '') {
|
|
3951
3959
|
return {
|
|
3952
|
-
value
|
|
3960
|
+
value: (/** @type {KeyPathEvaluateValueValue} */value)
|
|
3953
3961
|
};
|
|
3954
3962
|
}
|
|
3955
3963
|
const identifiers = keyPath.split('.');
|
|
@@ -3983,13 +3991,13 @@ function evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, fullKe
|
|
|
3983
3991
|
}) ? {
|
|
3984
3992
|
failure: true
|
|
3985
3993
|
} : {
|
|
3986
|
-
value
|
|
3994
|
+
value: (/** @type {KeyPathEvaluateValueValue} */value)
|
|
3987
3995
|
};
|
|
3988
3996
|
}
|
|
3989
3997
|
|
|
3990
3998
|
/**
|
|
3991
3999
|
* Sets the inline key value.
|
|
3992
|
-
* @param {{[key: string]:
|
|
4000
|
+
* @param {{[key: string]: Value}} value
|
|
3993
4001
|
* @param {Key} key
|
|
3994
4002
|
* @param {string} keyPath
|
|
3995
4003
|
* @returns {void}
|
|
@@ -4007,7 +4015,7 @@ function injectKeyIntoValueUsingKeyPath(value, key, keyPath) {
|
|
|
4007
4015
|
configurable: true
|
|
4008
4016
|
});
|
|
4009
4017
|
}
|
|
4010
|
-
value = value[identifier];
|
|
4018
|
+
value = /** @type {{[key: string]: Value}} */value[identifier];
|
|
4011
4019
|
});
|
|
4012
4020
|
Object.defineProperty(value, /** @type {string} */last, {
|
|
4013
4021
|
value: key,
|
|
@@ -4083,7 +4091,7 @@ function isMultiEntryMatch(encodedEntry, encodedKey) {
|
|
|
4083
4091
|
* @returns {Key[]}
|
|
4084
4092
|
*/
|
|
4085
4093
|
function findMultiEntryMatches(keyEntry, range) {
|
|
4086
|
-
/** @type {
|
|
4094
|
+
/** @type {Key[]} */
|
|
4087
4095
|
const matches = [];
|
|
4088
4096
|
if (Array.isArray(keyEntry)) {
|
|
4089
4097
|
for (let key of keyEntry) {
|
|
@@ -4113,7 +4121,7 @@ function findMultiEntryMatches(keyEntry, range) {
|
|
|
4113
4121
|
|
|
4114
4122
|
/**
|
|
4115
4123
|
* Not currently in use but keeping for spec parity.
|
|
4116
|
-
* @param {
|
|
4124
|
+
* @param {KeyValueObject} key
|
|
4117
4125
|
* @throws {Error} Upon a "bad key"
|
|
4118
4126
|
* @returns {ValueType}
|
|
4119
4127
|
*/
|
|
@@ -4126,16 +4134,17 @@ function convertKeyToValue(key) {
|
|
|
4126
4134
|
case 'number':
|
|
4127
4135
|
case 'string':
|
|
4128
4136
|
{
|
|
4129
|
-
return value;
|
|
4137
|
+
return /** @type {number|string} */value;
|
|
4130
4138
|
}
|
|
4131
4139
|
case 'array':
|
|
4132
4140
|
{
|
|
4133
4141
|
/** @type {ValueType[]} */
|
|
4134
4142
|
const array = [];
|
|
4135
|
-
const
|
|
4143
|
+
const arrValue = /** @type {KeyValueObject[]} */value;
|
|
4144
|
+
const len = arrValue.length;
|
|
4136
4145
|
let index = 0;
|
|
4137
4146
|
while (index < len) {
|
|
4138
|
-
const entry = convertKeyToValue(
|
|
4147
|
+
const entry = convertKeyToValue(arrValue[index]);
|
|
4139
4148
|
setArrayValue(array, index, entry);
|
|
4140
4149
|
index++;
|
|
4141
4150
|
}
|
|
@@ -4143,18 +4152,18 @@ function convertKeyToValue(key) {
|
|
|
4143
4152
|
}
|
|
4144
4153
|
case 'date':
|
|
4145
4154
|
{
|
|
4146
|
-
return new Date(value);
|
|
4155
|
+
return new Date(/** @type {number} */value);
|
|
4147
4156
|
}
|
|
4148
4157
|
case 'binary':
|
|
4149
4158
|
{
|
|
4150
|
-
const
|
|
4159
|
+
const binValue = /** @type {Uint8Array} */value;
|
|
4160
|
+
const len = binValue.length;
|
|
4151
4161
|
const buffer = new ArrayBuffer(len);
|
|
4152
4162
|
// Set the entries in buffer's [[ArrayBufferData]] to those in `value`
|
|
4153
|
-
const uint8 = new Uint8Array(buffer,
|
|
4154
|
-
uint8.set(
|
|
4163
|
+
const uint8 = new Uint8Array(buffer, binValue.byteOffset || 0, binValue.byteLength);
|
|
4164
|
+
uint8.set(binValue);
|
|
4155
4165
|
return buffer;
|
|
4156
4166
|
}
|
|
4157
|
-
case 'invalid':
|
|
4158
4167
|
default:
|
|
4159
4168
|
throw new Error('Bad key');
|
|
4160
4169
|
}
|
|
@@ -4162,7 +4171,7 @@ function convertKeyToValue(key) {
|
|
|
4162
4171
|
|
|
4163
4172
|
/**
|
|
4164
4173
|
*
|
|
4165
|
-
* @param {
|
|
4174
|
+
* @param {Value} key
|
|
4166
4175
|
* @param {boolean} [inArray]
|
|
4167
4176
|
* @returns {string|null}
|
|
4168
4177
|
*/
|
|
@@ -4177,7 +4186,7 @@ function encode$1(key, inArray) {
|
|
|
4177
4186
|
|
|
4178
4187
|
/**
|
|
4179
4188
|
*
|
|
4180
|
-
* @param {
|
|
4189
|
+
* @param {string|null} key
|
|
4181
4190
|
* @param {boolean} [inArray]
|
|
4182
4191
|
* @throws {Error} Invalid number
|
|
4183
4192
|
* @returns {undefined|ValueType}
|
|
@@ -4191,7 +4200,7 @@ function decode$1(key, inArray) {
|
|
|
4191
4200
|
|
|
4192
4201
|
/**
|
|
4193
4202
|
*
|
|
4194
|
-
* @param {
|
|
4203
|
+
* @param {Value} key
|
|
4195
4204
|
* @param {boolean} [inArray]
|
|
4196
4205
|
* @returns {undefined|ValueType}
|
|
4197
4206
|
*/
|
|
@@ -4409,8 +4418,8 @@ function IDBKeyRange() {
|
|
|
4409
4418
|
const IDBKeyRangeAlias = IDBKeyRange;
|
|
4410
4419
|
|
|
4411
4420
|
/**
|
|
4412
|
-
* @param {import('./Key.js').
|
|
4413
|
-
* @param {import('./Key.js').
|
|
4421
|
+
* @param {import('./Key.js').Value} lower
|
|
4422
|
+
* @param {import('./Key.js').Value} upper
|
|
4414
4423
|
* @param {boolean} lowerOpen
|
|
4415
4424
|
* @param {boolean} upperOpen
|
|
4416
4425
|
* @returns {import('./IDBKeyRange.js').IDBKeyRangeFull}
|
|
@@ -4613,10 +4622,11 @@ function setSQLForKeyRange(range, quotedKeyColumnName, sql, sqlValues, addAnd, c
|
|
|
4613
4622
|
function convertValueToKeyRange(value, nullDisallowed) {
|
|
4614
4623
|
if (instanceOf(value, IDBKeyRange)) {
|
|
4615
4624
|
// We still need to validate IDBKeyRange-like objects (the above check is based on loose duck-typing)
|
|
4616
|
-
|
|
4617
|
-
|
|
4625
|
+
const range = /** @type {IDBKeyRangeFull} */value;
|
|
4626
|
+
if (range.toString() !== '[object IDBKeyRange]') {
|
|
4627
|
+
return IDBKeyRange.__createInstance(range.lower, range.upper, range.lowerOpen, range.upperOpen);
|
|
4618
4628
|
}
|
|
4619
|
-
return
|
|
4629
|
+
return range;
|
|
4620
4630
|
}
|
|
4621
4631
|
if (isNullish(value)) {
|
|
4622
4632
|
if (nullDisallowed) {
|
|
@@ -4643,7 +4653,7 @@ function convertValueToKeyRange(value, nullDisallowed) {
|
|
|
4643
4653
|
* clone: () => DOMStringListFull,
|
|
4644
4654
|
* contains: (str: string) => boolean,
|
|
4645
4655
|
* indexOf: (str: string) => Integer,
|
|
4646
|
-
* splice: (index: Integer, howmany: Integer, ...args:
|
|
4656
|
+
* splice: (index: Integer, howmany: Integer, ...args: string[]) => void
|
|
4647
4657
|
* length: Integer
|
|
4648
4658
|
* }} DOMStringListFull
|
|
4649
4659
|
*/
|
|
@@ -4760,9 +4770,10 @@ DOMStringList.prototype = {
|
|
|
4760
4770
|
},
|
|
4761
4771
|
/**
|
|
4762
4772
|
* @this {DOMStringListFull}
|
|
4763
|
-
* @
|
|
4773
|
+
* @template T
|
|
4774
|
+
* @param {(value: string, i: Integer, arr: string[]) => T} cb
|
|
4764
4775
|
* @param {object} thisArg
|
|
4765
|
-
* @returns {
|
|
4776
|
+
* @returns {T[]}
|
|
4766
4777
|
*/
|
|
4767
4778
|
map(cb, thisArg) {
|
|
4768
4779
|
// eslint-disable-next-line unicorn/no-array-callback-reference, unicorn/no-array-method-this-argument -- Convenient
|
|
@@ -4787,10 +4798,7 @@ DOMStringList.prototype = {
|
|
|
4787
4798
|
this.sortList();
|
|
4788
4799
|
},
|
|
4789
4800
|
/**
|
|
4790
|
-
* @
|
|
4791
|
-
*/
|
|
4792
|
-
/**
|
|
4793
|
-
* @param {[index: Integer, howmany: Integer, ...args: any]} args
|
|
4801
|
+
* @param {[index: Integer, howmany: Integer, ...args: string[]]} args
|
|
4794
4802
|
* @this {DOMStringListFull}
|
|
4795
4803
|
* @returns {void}
|
|
4796
4804
|
*/
|
|
@@ -4824,12 +4832,9 @@ DOMStringList.prototype = {
|
|
|
4824
4832
|
};
|
|
4825
4833
|
|
|
4826
4834
|
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
4827
|
-
/**
|
|
4828
|
-
* @typedef {any} AnyValue
|
|
4829
|
-
*/
|
|
4830
4835
|
Object.defineProperty(DOMStringList, Symbol.hasInstance, {
|
|
4831
4836
|
/**
|
|
4832
|
-
* @param {
|
|
4837
|
+
* @param {unknown} obj
|
|
4833
4838
|
* @returns {boolean}
|
|
4834
4839
|
*/
|
|
4835
4840
|
value(obj) {
|
|
@@ -4910,7 +4915,7 @@ const readonlyProperties$4 = ['objectStoreNames', 'mode', 'durability', 'db', 'e
|
|
|
4910
4915
|
/**
|
|
4911
4916
|
* @typedef {{
|
|
4912
4917
|
* op: SQLCallback,
|
|
4913
|
-
* args:
|
|
4918
|
+
* args: unknown[],
|
|
4914
4919
|
* req: import('./IDBRequest.js').IDBRequestFull|null
|
|
4915
4920
|
* }} RequestInfo
|
|
4916
4921
|
*/
|
|
@@ -4962,17 +4967,17 @@ const readonlyProperties$4 = ['objectStoreNames', 'mode', 'durability', 'db', 'e
|
|
|
4962
4967
|
* __pushToQueue: (
|
|
4963
4968
|
* request: import('./IDBRequest.js').IDBRequestFull|null,
|
|
4964
4969
|
* callback: SQLCallback,
|
|
4965
|
-
* args?:
|
|
4970
|
+
* args?: unknown[]
|
|
4966
4971
|
* ) => void,
|
|
4967
4972
|
* __assertActive: () => void,
|
|
4968
4973
|
* commit: () => void,
|
|
4969
4974
|
* __addNonRequestToTransactionQueue: (
|
|
4970
4975
|
* callback: SQLCallback,
|
|
4971
|
-
* args?:
|
|
4976
|
+
* args?: unknown[]
|
|
4972
4977
|
* ) => void
|
|
4973
4978
|
* __addToTransactionQueue: (
|
|
4974
4979
|
* callback: SQLCallback,
|
|
4975
|
-
* args:
|
|
4980
|
+
* args: unknown[]|undefined,
|
|
4976
4981
|
* source: import('./IDBDatabase.js').IDBDatabaseFull|
|
|
4977
4982
|
* import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
4978
4983
|
* import('./IDBIndex.js').IDBIndexFull|
|
|
@@ -5172,7 +5177,7 @@ IDBTransaction.prototype.__executeRequests = function () {
|
|
|
5172
5177
|
i = -1;
|
|
5173
5178
|
|
|
5174
5179
|
/**
|
|
5175
|
-
* @typedef {
|
|
5180
|
+
* @typedef {unknown} IDBRequestResult
|
|
5176
5181
|
*/
|
|
5177
5182
|
|
|
5178
5183
|
/**
|
|
@@ -5603,8 +5608,8 @@ IDBTransaction.prototype.__createRequest = function (source) {
|
|
|
5603
5608
|
/**
|
|
5604
5609
|
* @typedef {(
|
|
5605
5610
|
* tx: import('websql-configurable/lib/websql/WebSQLTransaction.js').default,
|
|
5606
|
-
* args:
|
|
5607
|
-
* success: (result?:
|
|
5611
|
+
* args: unknown[],
|
|
5612
|
+
* success: (result?: unknown, req?: import('./IDBRequest.js').IDBRequestFull) => void,
|
|
5608
5613
|
* error: (
|
|
5609
5614
|
* tx: import('websql-configurable/lib/websql/WebSQLTransaction.js').default|Error|DOMException,
|
|
5610
5615
|
* err?: Error & {code?: number}
|
|
@@ -5616,7 +5621,7 @@ IDBTransaction.prototype.__createRequest = function (source) {
|
|
|
5616
5621
|
/**
|
|
5617
5622
|
* Adds a callback function to the transaction queue.
|
|
5618
5623
|
* @param {SQLCallback} callback
|
|
5619
|
-
* @param {
|
|
5624
|
+
* @param {unknown[]} args
|
|
5620
5625
|
* @param {import('./IDBDatabase.js').IDBDatabaseFull|
|
|
5621
5626
|
* import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
5622
5627
|
* import('./IDBIndex.js').IDBIndexFull} source
|
|
@@ -5633,7 +5638,7 @@ IDBTransaction.prototype.__addToTransactionQueue = function (callback, args, sou
|
|
|
5633
5638
|
* Adds a callback function to the transaction queue without generating a
|
|
5634
5639
|
* request.
|
|
5635
5640
|
* @param {SQLCallback} callback
|
|
5636
|
-
* @param {
|
|
5641
|
+
* @param {unknown[]} args
|
|
5637
5642
|
* @this {IDBTransactionFull}
|
|
5638
5643
|
* @returns {void}
|
|
5639
5644
|
*/
|
|
@@ -5645,7 +5650,7 @@ IDBTransaction.prototype.__addNonRequestToTransactionQueue = function (callback,
|
|
|
5645
5650
|
* Adds an IDBRequest to the transaction queue.
|
|
5646
5651
|
* @param {import('./IDBRequest.js').IDBRequestFull|null} request
|
|
5647
5652
|
* @param {SQLCallback} callback
|
|
5648
|
-
* @param {
|
|
5653
|
+
* @param {unknown[]} args
|
|
5649
5654
|
* @this {IDBTransactionFull}
|
|
5650
5655
|
* @returns {void}
|
|
5651
5656
|
*/
|
|
@@ -5814,7 +5819,7 @@ IDBTransaction.prototype.__abortTransaction = function (err) {
|
|
|
5814
5819
|
bubbles: true,
|
|
5815
5820
|
cancelable: true
|
|
5816
5821
|
});
|
|
5817
|
-
return new SyncPromise(/** @type {(resolve: (value?:
|
|
5822
|
+
return new SyncPromise(/** @type {(resolve: (value?: unknown) => void) => void} */
|
|
5818
5823
|
resolve => {
|
|
5819
5824
|
setTimeout(() => {
|
|
5820
5825
|
if (!q.req) {
|
|
@@ -7629,7 +7634,7 @@ function encode(obj, func) {
|
|
|
7629
7634
|
}
|
|
7630
7635
|
|
|
7631
7636
|
/**
|
|
7632
|
-
* @typedef {
|
|
7637
|
+
* @typedef {import('./Key.js').Value} AnyValue
|
|
7633
7638
|
*/
|
|
7634
7639
|
|
|
7635
7640
|
/**
|
|
@@ -7739,7 +7744,7 @@ const IDBIndexAlias = IDBIndex;
|
|
|
7739
7744
|
* __keyPath: import('./Key.js').KeyPath,
|
|
7740
7745
|
* __recreated?: boolean,
|
|
7741
7746
|
* __fetchIndexData: (
|
|
7742
|
-
* range:
|
|
7747
|
+
* range: Query,
|
|
7743
7748
|
* opType: "value"|"key"|"count",
|
|
7744
7749
|
* nullDisallowed: boolean,
|
|
7745
7750
|
* count?: number
|
|
@@ -8115,7 +8120,7 @@ IDBIndex.__updateIndexList = function (store, tx, success, failure) {
|
|
|
8115
8120
|
};
|
|
8116
8121
|
|
|
8117
8122
|
/**
|
|
8118
|
-
* @typedef {
|
|
8123
|
+
* @typedef {import('./Key.js').Value|IDBKeyRange} Query
|
|
8119
8124
|
*/
|
|
8120
8125
|
|
|
8121
8126
|
/**
|
|
@@ -8388,7 +8393,7 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
8388
8393
|
reject(err);
|
|
8389
8394
|
});
|
|
8390
8395
|
}));
|
|
8391
|
-
SyncPromise.all(indexCreations).then(finish).catch(/** @type {(reason:
|
|
8396
|
+
SyncPromise.all(indexCreations).then(finish).catch(/** @type {(reason: unknown) => PromiseLike<never>} */
|
|
8392
8397
|
error).catch(err => {
|
|
8393
8398
|
console.log('Index rename error');
|
|
8394
8399
|
throw err;
|
|
@@ -8400,14 +8405,10 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
8400
8405
|
});
|
|
8401
8406
|
};
|
|
8402
8407
|
|
|
8403
|
-
/**
|
|
8404
|
-
* @typedef {any} AnyValue
|
|
8405
|
-
*/
|
|
8406
|
-
|
|
8407
8408
|
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
8408
8409
|
Object.defineProperty(IDBIndex, Symbol.hasInstance, {
|
|
8409
8410
|
/**
|
|
8410
|
-
* @param {
|
|
8411
|
+
* @param {unknown} obj
|
|
8411
8412
|
* @returns {boolean}
|
|
8412
8413
|
*/
|
|
8413
8414
|
value: obj => isObj(obj) && 'openCursor' in obj && typeof obj.openCursor === 'function' && 'multiEntry' in obj && typeof obj.multiEntry === 'boolean'
|
|
@@ -8433,7 +8434,9 @@ Object.defineProperty(IDBIndex, 'prototype', {
|
|
|
8433
8434
|
* @param {string[]} sqlValues
|
|
8434
8435
|
* @param {WebSQLTransaction} tx
|
|
8435
8436
|
* @param {null|undefined} args
|
|
8436
|
-
* @param {(
|
|
8437
|
+
* @param {(
|
|
8438
|
+
* result: number|undefined|[]|import('./Key.js').Value|import('./Key.js').Value[]
|
|
8439
|
+
* ) => void} success
|
|
8437
8440
|
* @param {(tx: WebSQLTransaction, err: (Error & {code?: number})) => void} error
|
|
8438
8441
|
* @returns {void}
|
|
8439
8442
|
*/
|
|
@@ -8470,7 +8473,7 @@ function executeFetchIndexData(count, unboundedDisallowed, index, hasKey, range,
|
|
|
8470
8473
|
* @param {{
|
|
8471
8474
|
* value: string
|
|
8472
8475
|
* }} record
|
|
8473
|
-
* @returns {
|
|
8476
|
+
* @returns {import('./Key.js').Value}
|
|
8474
8477
|
*/
|
|
8475
8478
|
record => {
|
|
8476
8479
|
// when opType is value
|
|
@@ -8484,9 +8487,9 @@ function executeFetchIndexData(count, unboundedDisallowed, index, hasKey, range,
|
|
|
8484
8487
|
const rowKey = /** @type {import('./Key.js').ValueTypeArray} */
|
|
8485
8488
|
decode$1(row[escapedIndexNameForKeyCol]);
|
|
8486
8489
|
let record;
|
|
8487
|
-
if (hasKey && (multiChecks && range.some(
|
|
8490
|
+
if (hasKey && (multiChecks && /** @type {import('./Key.js').ValueType[]} */range.some(
|
|
8488
8491
|
/**
|
|
8489
|
-
* @param {
|
|
8492
|
+
* @param {import('./Key.js').ValueType} check
|
|
8490
8493
|
* @returns {boolean}
|
|
8491
8494
|
*/
|
|
8492
8495
|
check => rowKey.includes(check)) ||
|
|
@@ -8632,14 +8635,14 @@ const IDBObjectStoreAlias = IDBObjectStore;
|
|
|
8632
8635
|
* __idbdb: import('./IDBDatabase.js').IDBDatabaseFull,
|
|
8633
8636
|
* __validateKeyAndValueAndCloneValue: (
|
|
8634
8637
|
* value: import('./Key.js').Value,
|
|
8635
|
-
* key: import('./Key.js').Key,
|
|
8638
|
+
* key: import('./Key.js').Key|undefined,
|
|
8636
8639
|
* cursorUpdate: boolean
|
|
8637
8640
|
* ) => KeyValueArray,
|
|
8638
8641
|
* __deriveKey: (
|
|
8639
8642
|
* tx: WebSQLTransaction,
|
|
8640
8643
|
* value: import('./Key.js').Value,
|
|
8641
|
-
* key: import('./Key.js').Key,
|
|
8642
|
-
* success: (key: import('./Key.js').
|
|
8644
|
+
* key: import('./Key.js').Key|undefined,
|
|
8645
|
+
* success: (key: import('./Key.js').Value, cn?: Integer) => void,
|
|
8643
8646
|
* failCb: import('./Key.js').SQLFailureCallback
|
|
8644
8647
|
* ) => void,
|
|
8645
8648
|
* __checkIndexConstraints: (
|
|
@@ -8950,7 +8953,7 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
|
|
|
8950
8953
|
};
|
|
8951
8954
|
|
|
8952
8955
|
/**
|
|
8953
|
-
* @typedef {[import('./Key.js').Key, import('./Key.js').Value]} KeyValueArray
|
|
8956
|
+
* @typedef {[import('./Key.js').Key|undefined, import('./Key.js').Value]} KeyValueArray
|
|
8954
8957
|
*/
|
|
8955
8958
|
|
|
8956
8959
|
// Todo: Although we may end up needing to do cloning genuinely asynchronously (for Blobs and FileLists),
|
|
@@ -8965,7 +8968,7 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
|
|
|
8965
8968
|
* Determines whether the given inline or out-of-line key is valid,
|
|
8966
8969
|
* according to the object store's schema.
|
|
8967
8970
|
* @param {import('./Key.js').Value} value Used for inline keys
|
|
8968
|
-
* @param {import('./Key.js').Key} key Used for out-of-line keys
|
|
8971
|
+
* @param {import('./Key.js').Key|undefined} key Used for out-of-line keys
|
|
8969
8972
|
* @param {boolean} cursorUpdate
|
|
8970
8973
|
* @throws {DOMException}
|
|
8971
8974
|
* @this {IDBObjectStoreFull}
|
|
@@ -8981,11 +8984,11 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
|
|
|
8981
8984
|
// occurs sync; then can make cloning and this method without callbacks (except where ok
|
|
8982
8985
|
// to be async)
|
|
8983
8986
|
const clonedValue = cloneWithInactiveTransaction(/** @type {import('./IDBTransaction.js').IDBTransactionFull} */me.transaction, value);
|
|
8984
|
-
|
|
8985
|
-
if (
|
|
8987
|
+
const extractedKey = extractKeyValueDecodedFromValueUsingKeyPath(clonedValue, me.keyPath); // May throw so "rethrow"
|
|
8988
|
+
if ('invalid' in extractedKey && extractedKey.invalid) {
|
|
8986
8989
|
throw createDOMException('DataError', 'KeyPath was specified, but key was invalid.');
|
|
8987
8990
|
}
|
|
8988
|
-
if (
|
|
8991
|
+
if ('failure' in extractedKey && extractedKey.failure) {
|
|
8989
8992
|
if (!cursorUpdate) {
|
|
8990
8993
|
if (!me.autoIncrement) {
|
|
8991
8994
|
throw createDOMException('DataError', 'Could not evaluate a key from keyPath and there is no key generator');
|
|
@@ -9000,14 +9003,13 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
|
|
|
9000
9003
|
throw createDOMException('DataError', 'Could not evaluate a key from keyPath');
|
|
9001
9004
|
}
|
|
9002
9005
|
// An `IDBCursor.update` call will also throw if not equal to the cursor’s effective key
|
|
9003
|
-
return [
|
|
9006
|
+
return [(/** @type {import('./Key.js').Key} */extractedKey.value), clonedValue];
|
|
9004
9007
|
}
|
|
9005
9008
|
if (key === undefined) {
|
|
9006
9009
|
if (!me.autoIncrement) {
|
|
9007
9010
|
throw createDOMException('DataError', 'The object store uses out-of-line keys and has no key generator and the key parameter was not provided.');
|
|
9008
9011
|
}
|
|
9009
9012
|
// A key will be generated
|
|
9010
|
-
key = undefined;
|
|
9011
9013
|
} else {
|
|
9012
9014
|
convertValueToKeyRethrowingAndIfInvalid(key);
|
|
9013
9015
|
}
|
|
@@ -9022,8 +9024,8 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
|
|
|
9022
9024
|
* a keyPath leading to a valid but non-numeric or < 1 key).
|
|
9023
9025
|
* @param {WebSQLTransaction} tx
|
|
9024
9026
|
* @param {import('./Key.js').Value} value
|
|
9025
|
-
* @param {import('./Key.js').Key} key
|
|
9026
|
-
* @param {(key: import('./Key.js').
|
|
9027
|
+
* @param {import('./Key.js').Key|undefined} key
|
|
9028
|
+
* @param {(key: import('./Key.js').Value, cn?: Integer) => void} success
|
|
9027
9029
|
* @param {import('./Key.js').SQLFailureCallback} failCb
|
|
9028
9030
|
* @this {IDBObjectStoreFull}
|
|
9029
9031
|
* @returns {void}
|
|
@@ -9038,9 +9040,8 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
|
|
|
9038
9040
|
*/
|
|
9039
9041
|
function keyCloneThenSuccess(oldCn) {
|
|
9040
9042
|
// We want to return the original key, so we don't need to accept an argument here
|
|
9041
|
-
encode(key, function (
|
|
9042
|
-
|
|
9043
|
-
success(key, oldCn);
|
|
9043
|
+
encode(key, function (encodedKey) {
|
|
9044
|
+
success(decode(encodedKey), oldCn);
|
|
9044
9045
|
});
|
|
9045
9046
|
}
|
|
9046
9047
|
if (me.autoIncrement) {
|
|
@@ -9054,7 +9055,7 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
|
|
|
9054
9055
|
if (me.keyPath !== null) {
|
|
9055
9056
|
// Should not throw now as checked earlier
|
|
9056
9057
|
// Todo: Could this not be an array here?
|
|
9057
|
-
injectKeyIntoValueUsingKeyPath(value, key, /** @type {string} */me.keyPath);
|
|
9058
|
+
injectKeyIntoValueUsingKeyPath(/** @type {{[key: string]: import('./Key.js').Value}} */value, /** @type {import('./Key.js').Key} */key, /** @type {string} */me.keyPath);
|
|
9058
9059
|
}
|
|
9059
9060
|
success(key, oldCn);
|
|
9060
9061
|
}, failCb);
|
|
@@ -9111,15 +9112,15 @@ IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeK
|
|
|
9111
9112
|
resolve(undefined);
|
|
9112
9113
|
return;
|
|
9113
9114
|
}
|
|
9114
|
-
|
|
9115
|
-
if (
|
|
9115
|
+
const indexKeyValue = indexKey.value;
|
|
9116
|
+
if (indexKeyValue === undefined) {
|
|
9116
9117
|
resolve(undefined);
|
|
9117
9118
|
return;
|
|
9118
9119
|
}
|
|
9119
|
-
const multiCheck = index.multiEntry && Array.isArray(
|
|
9120
|
-
const fetchArgs = buildFetchIndexDataSQL(true, index,
|
|
9120
|
+
const multiCheck = index.multiEntry && Array.isArray(indexKeyValue);
|
|
9121
|
+
const fetchArgs = buildFetchIndexDataSQL(true, index, indexKeyValue, 'key', multiCheck);
|
|
9121
9122
|
executeFetchIndexData(null, ...fetchArgs, tx, null, function success(key) {
|
|
9122
|
-
if (key === undefined || excludeKey !== undefined && cmp(key, excludeKey) === 0) {
|
|
9123
|
+
if (key === undefined || excludeKey !== undefined && cmp(/** @type {import('./Key.js').Key} */key, excludeKey) === 0) {
|
|
9123
9124
|
resolve(undefined);
|
|
9124
9125
|
return;
|
|
9125
9126
|
}
|
|
@@ -9192,21 +9193,21 @@ IDBObjectStore.prototype.__insertData = function (tx, encoded, value, clonedKeyO
|
|
|
9192
9193
|
resolve(undefined);
|
|
9193
9194
|
return;
|
|
9194
9195
|
}
|
|
9195
|
-
|
|
9196
|
+
const indexKeyValue = indexKey.value;
|
|
9196
9197
|
/**
|
|
9197
9198
|
* @param {import('./IDBIndex.js').IDBIndexFull} index
|
|
9198
9199
|
* @returns {void}
|
|
9199
9200
|
*/
|
|
9200
9201
|
function setIndexInfo(index) {
|
|
9201
|
-
if (
|
|
9202
|
+
if (indexKeyValue === undefined) {
|
|
9202
9203
|
return;
|
|
9203
9204
|
}
|
|
9204
9205
|
paramMap[index.__currentName] = /** @type {string} */
|
|
9205
|
-
encode$1(
|
|
9206
|
+
encode$1(indexKeyValue, index.multiEntry);
|
|
9206
9207
|
}
|
|
9207
9208
|
if (index.unique) {
|
|
9208
|
-
const multiCheck = index.multiEntry && Array.isArray(
|
|
9209
|
-
const fetchArgs = buildFetchIndexDataSQL(true, index,
|
|
9209
|
+
const multiCheck = index.multiEntry && Array.isArray(indexKeyValue);
|
|
9210
|
+
const fetchArgs = buildFetchIndexDataSQL(true, index, indexKeyValue, 'key', multiCheck);
|
|
9210
9211
|
executeFetchIndexData(null, ...fetchArgs, tx, null, function success(key) {
|
|
9211
9212
|
if (key === undefined) {
|
|
9212
9213
|
setIndexInfo(index);
|
|
@@ -9365,7 +9366,9 @@ IDBObjectStore.__storingRecordObjectStore = function (request, store, invalidate
|
|
|
9365
9366
|
const key = arguments[5];
|
|
9366
9367
|
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
9367
9368
|
store.transaction.__pushToQueue(request, function (tx, args, success, error) {
|
|
9368
|
-
store.__deriveKey(tx, value, key, function (
|
|
9369
|
+
store.__deriveKey(tx, value, key, function (clonedKeyOrCurrentNumberRaw, oldCn) {
|
|
9370
|
+
const clonedKeyOrCurrentNumber = /** @type {import('./Key.js').Key|Integer} */
|
|
9371
|
+
clonedKeyOrCurrentNumberRaw;
|
|
9369
9372
|
encode(value, function (encoded) {
|
|
9370
9373
|
/**
|
|
9371
9374
|
* @param {WebSQLTransaction} tx
|
|
@@ -10128,7 +10131,6 @@ Object.defineProperty(IDBDatabase, 'prototype', {
|
|
|
10128
10131
|
});
|
|
10129
10132
|
|
|
10130
10133
|
/* eslint-disable sonarjs/no-invariant-returns -- Convenient here */
|
|
10131
|
-
// eslint-disable-next-line no-restricted-imports -- Can be polyfilled
|
|
10132
10134
|
|
|
10133
10135
|
/**
|
|
10134
10136
|
* @typedef {number} Integer
|
|
@@ -10488,7 +10490,7 @@ function cleanupDatabaseResources(__openDatabase, name, escapedDatabaseName, dat
|
|
|
10488
10490
|
}
|
|
10489
10491
|
if (fs && CFG.deleteDatabaseFiles !== false) {
|
|
10490
10492
|
closeCachedWebSQLConnections(name, () => {
|
|
10491
|
-
fs.unlink(
|
|
10493
|
+
fs.unlink(joinPath(CFG.databaseBasePath || '', escapedDatabaseName), err => {
|
|
10492
10494
|
if (err && err.code !== 'ENOENT') {
|
|
10493
10495
|
// Ignore if file is already deleted
|
|
10494
10496
|
const removalError = /** @type {Error & {code?: number}} */
|
|
@@ -10502,7 +10504,7 @@ function cleanupDatabaseResources(__openDatabase, name, escapedDatabaseName, dat
|
|
|
10502
10504
|
});
|
|
10503
10505
|
return;
|
|
10504
10506
|
}
|
|
10505
|
-
const sqliteDB = __openDatabase(
|
|
10507
|
+
const sqliteDB = __openDatabase(joinPath(CFG.databaseBasePath || '', escapedDatabaseName), '1', name, CFG.DEFAULT_DB_SIZE);
|
|
10506
10508
|
sqliteDB.transaction(function (tx) {
|
|
10507
10509
|
tx.executeSql('SELECT "name" FROM __sys__', [], function (tx, data) {
|
|
10508
10510
|
const tables = data.rows;
|
|
@@ -10563,7 +10565,7 @@ function createSysDB(__openDatabase, success, failure) {
|
|
|
10563
10565
|
success();
|
|
10564
10566
|
} else {
|
|
10565
10567
|
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Necessary?
|
|
10566
|
-
sysdb = __openDatabase(typeof CFG.memoryDatabase === 'string' ? CFG.memoryDatabase :
|
|
10568
|
+
sysdb = __openDatabase(typeof CFG.memoryDatabase === 'string' ? CFG.memoryDatabase : joinPath(typeof CFG.sysDatabaseBasePath === 'string' ? CFG.sysDatabaseBasePath : CFG.databaseBasePath || '', '__sysdb__' + (CFG.addSQLiteExtension !== false ? '.sqlite' : '')), '1', 'System Database', CFG.DEFAULT_DB_SIZE);
|
|
10567
10569
|
sysdb.transaction(function (systx) {
|
|
10568
10570
|
systx.executeSql('CREATE TABLE IF NOT EXISTS dbVersions (name BLOB, version INT);', [], function (systx) {
|
|
10569
10571
|
if (!CFG.useSQLiteIndexes) {
|
|
@@ -10743,7 +10745,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
10743
10745
|
let sysdbFinishedCb = function (systx, err, cb) {
|
|
10744
10746
|
if (err) {
|
|
10745
10747
|
/**
|
|
10746
|
-
* @param {
|
|
10748
|
+
* @param {unknown} [errorToShow]
|
|
10747
10749
|
* @returns {void}
|
|
10748
10750
|
*/
|
|
10749
10751
|
const manualRevert = function (errorToShow) {
|
|
@@ -10767,7 +10769,9 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
10767
10769
|
cb(sqlErr); // eslint-disable-line promise/no-callback-in-promise -- Convenient
|
|
10768
10770
|
}, function () {
|
|
10769
10771
|
isRevertingSysdb = false;
|
|
10770
|
-
|
|
10772
|
+
// eslint-disable-next-line promise/no-callback-in-promise -- Convenient
|
|
10773
|
+
cb(/** @type {(Error & {code?: number})|undefined} */
|
|
10774
|
+
errorToShow || reportError);
|
|
10771
10775
|
});
|
|
10772
10776
|
};
|
|
10773
10777
|
try {
|
|
@@ -10800,13 +10804,13 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
10800
10804
|
newVersion: version
|
|
10801
10805
|
});
|
|
10802
10806
|
req.__result = connection;
|
|
10803
|
-
connection.__upgradeTransaction = req.__transaction =
|
|
10807
|
+
connection.__upgradeTransaction = req.__transaction = connection.__versionTransaction = IDBTransaction.__createInstance(connection, connection.objectStoreNames, 'versionchange');
|
|
10804
10808
|
req.__done = true;
|
|
10805
10809
|
req.transaction.__addNonRequestToTransactionQueue(
|
|
10806
10810
|
/**
|
|
10807
10811
|
* @param {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} tx
|
|
10808
|
-
* @param {
|
|
10809
|
-
* @param {(result?:
|
|
10812
|
+
* @param {unknown[]} args
|
|
10813
|
+
* @param {(result?: unknown, req?: import('./IDBRequest.js').IDBRequestFull) => void} finished
|
|
10810
10814
|
* @returns {void}
|
|
10811
10815
|
*/
|
|
10812
10816
|
function onupgradeneeded(tx, args, finished /* , error */) {
|
|
@@ -11019,7 +11023,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
11019
11023
|
if ((useMemoryDatabase || useDatabaseCache) && Object.hasOwn(websqlDBCache, name) && Object.hasOwn(websqlDBCache[name], version)) {
|
|
11020
11024
|
db = websqlDBCache[name][version];
|
|
11021
11025
|
} else {
|
|
11022
|
-
db = /** @type {DatabaseFull} */me.__openDatabase(useMemoryDatabase ? CFG.memoryDatabase :
|
|
11026
|
+
db = /** @type {DatabaseFull} */me.__openDatabase(useMemoryDatabase ? CFG.memoryDatabase : joinPath(CFG.databaseBasePath || '', escapedDatabaseName), '1', name, CFG.DEFAULT_DB_SIZE);
|
|
11023
11027
|
if (useDatabaseCache) {
|
|
11024
11028
|
if (!Object.hasOwn(websqlDBCache, name)) {
|
|
11025
11029
|
websqlDBCache[name] = {};
|
|
@@ -11513,16 +11517,16 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11513
11517
|
|
|
11514
11518
|
/**
|
|
11515
11519
|
* @typedef {IDBCursor & {
|
|
11516
|
-
* primaryKey: import('./Key.js').Key,
|
|
11517
|
-
* key: import('./Key.js').Key,
|
|
11520
|
+
* primaryKey: import('./Key.js').Key|null|undefined,
|
|
11521
|
+
* key: import('./Key.js').Key|null|undefined,
|
|
11518
11522
|
* direction: string,
|
|
11519
11523
|
* source: import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
11520
11524
|
* import('./IDBIndex.js').IDBIndexFull,
|
|
11521
11525
|
* __request: import('./IDBRequest.js').IDBRequestFull,
|
|
11522
11526
|
* __advanceCount: Integer|undefined,
|
|
11523
11527
|
* __indexSource: boolean,
|
|
11524
|
-
* __key: import('./Key.js').Key,
|
|
11525
|
-
* __primaryKey: import('./Key.js').Key,
|
|
11528
|
+
* __key: import('./Key.js').Key|null|undefined,
|
|
11529
|
+
* __primaryKey: import('./Key.js').Key|null|undefined,
|
|
11526
11530
|
* __value: import('./Key.js').Value,
|
|
11527
11531
|
* __store: import('./IDBObjectStore.js').IDBObjectStoreFull,
|
|
11528
11532
|
* __range: import('./IDBKeyRange.js').IDBKeyRangeFull|undefined,
|
|
@@ -11530,11 +11534,14 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11530
11534
|
* __valueColumnName: string,
|
|
11531
11535
|
* __keyOnly: boolean,
|
|
11532
11536
|
* __valueDecoder: {
|
|
11533
|
-
* decode: (str: string) =>
|
|
11537
|
+
* decode: (str: string) => import('./Key.js').Value,
|
|
11534
11538
|
* },
|
|
11535
11539
|
* __count: boolean,
|
|
11536
11540
|
* __prefetchedIndex: Integer,
|
|
11537
|
-
* __prefetchedData: null|
|
|
11541
|
+
* __prefetchedData: null|{
|
|
11542
|
+
* length: number;
|
|
11543
|
+
* item(index: number): unknown;
|
|
11544
|
+
* }|{
|
|
11538
11545
|
* data: RowItemNonNull[],
|
|
11539
11546
|
* length: Integer,
|
|
11540
11547
|
* item: (index: Integer) => RowItemNonNull
|
|
@@ -11548,7 +11555,14 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11548
11555
|
* __multiEntryExhausted: boolean,
|
|
11549
11556
|
* __invalidateCache: () => void,
|
|
11550
11557
|
* __gotValue: boolean,
|
|
11551
|
-
* __find: (
|
|
11558
|
+
* __find: (
|
|
11559
|
+
* key: import('./Key.js').Key|undefined,
|
|
11560
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
11561
|
+
* tx: WebSQLTransaction,
|
|
11562
|
+
* success: KeySuccess,
|
|
11563
|
+
* error: FindError,
|
|
11564
|
+
* recordsToLoad?: Integer
|
|
11565
|
+
* ) => void,
|
|
11552
11566
|
* __findBasic: (
|
|
11553
11567
|
* key: import('./Key.js').Key|undefined,
|
|
11554
11568
|
* primaryKey: import('./Key.js').Key|undefined,
|
|
@@ -11569,17 +11583,17 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11569
11583
|
* __decode: (
|
|
11570
11584
|
* rowItem: RowItemNonNull,
|
|
11571
11585
|
* callback: (
|
|
11572
|
-
* key: import('./Key.js').Key,
|
|
11586
|
+
* key: import('./Key.js').Key|undefined,
|
|
11573
11587
|
* val: import('./Key.js').Value,
|
|
11574
|
-
* primaryKey: import('./Key.js').Key,
|
|
11588
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
11575
11589
|
* encKey?: string
|
|
11576
11590
|
* ) => void
|
|
11577
11591
|
* ) => void,
|
|
11578
11592
|
* __sourceOrEffectiveObjStoreDeleted: () => void,
|
|
11579
11593
|
* __continue: (key?: import('./Key.js').Key, advanceContinue?: boolean) => void,
|
|
11580
11594
|
* __continueFinish: (
|
|
11581
|
-
* key: import('./Key.js').Key,
|
|
11582
|
-
* primaryKey: import('./Key.js').Key,
|
|
11595
|
+
* key: import('./Key.js').Key|undefined,
|
|
11596
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
11583
11597
|
* advanceState: boolean
|
|
11584
11598
|
* ) => void
|
|
11585
11599
|
* }} IDBCursorFull
|
|
@@ -11612,7 +11626,7 @@ const IDBCursorAlias = IDBCursor;
|
|
|
11612
11626
|
* import('./IDBIndex.js').IDBIndexFull} source
|
|
11613
11627
|
* @param {string} keyColumnName
|
|
11614
11628
|
* @param {string} valueColumnName
|
|
11615
|
-
* @param {boolean} count
|
|
11629
|
+
* @param {boolean} [count]
|
|
11616
11630
|
* @this {IDBCursorFull}
|
|
11617
11631
|
* @returns {void}
|
|
11618
11632
|
*/
|
|
@@ -11653,7 +11667,7 @@ IDBCursor.__super = function IDBCursor(query, direction, store, source, keyColum
|
|
|
11653
11667
|
this.__valueColumnName = valueColumnName;
|
|
11654
11668
|
this.__keyOnly = valueColumnName === 'key';
|
|
11655
11669
|
this.__valueDecoder = this.__keyOnly ? Key : Sca;
|
|
11656
|
-
this.__count = count;
|
|
11670
|
+
this.__count = Boolean(count);
|
|
11657
11671
|
this.__prefetchedIndex = -1;
|
|
11658
11672
|
this.__continuationKey = undefined;
|
|
11659
11673
|
this.__continuationPrimaryKey = undefined;
|
|
@@ -11672,25 +11686,36 @@ IDBCursor.__super = function IDBCursor(query, direction, store, source, keyColum
|
|
|
11672
11686
|
|
|
11673
11687
|
/**
|
|
11674
11688
|
*
|
|
11675
|
-
* @param {
|
|
11689
|
+
* @param {IDBKeyRange} query
|
|
11690
|
+
* @param {string} direction
|
|
11691
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
11692
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
11693
|
+
* import('./IDBIndex.js').IDBIndexFull} source
|
|
11694
|
+
* @param {string} keyColumnName
|
|
11695
|
+
* @param {string} valueColumnName
|
|
11696
|
+
* @param {boolean} [count]
|
|
11676
11697
|
* @returns {IDBCursorFull}
|
|
11677
11698
|
*/
|
|
11678
|
-
IDBCursor.__createInstance = function (
|
|
11699
|
+
IDBCursor.__createInstance = function (query, direction, store, source, keyColumnName, valueColumnName, count) {
|
|
11679
11700
|
const IDBCursor = IDBCursorAlias.__super;
|
|
11680
11701
|
IDBCursor.prototype = IDBCursorAlias.prototype;
|
|
11681
11702
|
|
|
11682
11703
|
// @ts-expect-error It's ok
|
|
11683
|
-
return new IDBCursor(
|
|
11704
|
+
return new IDBCursor(query, direction, store, source, keyColumnName, valueColumnName, count);
|
|
11684
11705
|
};
|
|
11685
11706
|
|
|
11686
11707
|
/**
|
|
11687
11708
|
*
|
|
11688
|
-
* @param {
|
|
11709
|
+
* @param {import('./Key.js').Key|undefined} key
|
|
11710
|
+
* @param {import('./Key.js').Key|undefined} primaryKey
|
|
11711
|
+
* @param {WebSQLTransaction} tx
|
|
11712
|
+
* @param {KeySuccess} success
|
|
11713
|
+
* @param {FindError} error
|
|
11714
|
+
* @param {Integer} [recordsToLoad]
|
|
11689
11715
|
* @this {IDBCursorFull}
|
|
11690
11716
|
* @returns {void}
|
|
11691
11717
|
*/
|
|
11692
|
-
IDBCursor.prototype.__find = function (
|
|
11693
|
-
const [key, primaryKey, tx, success, error, recordsToLoad] = args;
|
|
11718
|
+
IDBCursor.prototype.__find = function (key, primaryKey, tx, success, error, recordsToLoad) {
|
|
11694
11719
|
if (this.__multiEntryIndex) {
|
|
11695
11720
|
this.__findMultiEntry(key, primaryKey, tx, success, error, recordsToLoad);
|
|
11696
11721
|
} else {
|
|
@@ -11700,9 +11725,9 @@ IDBCursor.prototype.__find = function (...args /* key, tx, success, error, recor
|
|
|
11700
11725
|
|
|
11701
11726
|
/**
|
|
11702
11727
|
* @typedef {(
|
|
11703
|
-
* k: import('./Key.js').Key,
|
|
11728
|
+
* k: import('./Key.js').Key|undefined,
|
|
11704
11729
|
* val: import('./Key.js').Value,
|
|
11705
|
-
* primKey: import('./Key.js').Key
|
|
11730
|
+
* primKey: import('./Key.js').Key|undefined
|
|
11706
11731
|
* ) => void} KeySuccess
|
|
11707
11732
|
*/
|
|
11708
11733
|
|
|
@@ -11799,7 +11824,7 @@ IDBCursor.prototype.__findBasic = function (key, primaryKey, tx, success, error,
|
|
|
11799
11824
|
me.__prefetchedIndex = 0;
|
|
11800
11825
|
me.__prefetchedData = data.rows;
|
|
11801
11826
|
if (CFG.DEBUG) {
|
|
11802
|
-
console.log('Preloaded ' +
|
|
11827
|
+
console.log('Preloaded ' + data.rows.length + ' records for cursor');
|
|
11803
11828
|
}
|
|
11804
11829
|
me.__decode(/** @type {RowItemNonNull} */data.rows.item(0), success);
|
|
11805
11830
|
} else if (data.rows.length === 1) {
|
|
@@ -11923,7 +11948,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
11923
11948
|
for (let i = 0; i < data.rows.length; i++) {
|
|
11924
11949
|
const rowItem = /** @type {RowItemNonNull} */data.rows.item(i);
|
|
11925
11950
|
const rowKey = decode$1(rowItem[me.__keyColumnName], true);
|
|
11926
|
-
const matches = findMultiEntryMatches(rowKey, me.__range);
|
|
11951
|
+
const matches = findMultiEntryMatches(/** @type {import('./Key.js').Key} */rowKey, me.__range);
|
|
11927
11952
|
ct += matches.length;
|
|
11928
11953
|
}
|
|
11929
11954
|
success(undefined, ct, undefined);
|
|
@@ -11943,7 +11968,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
11943
11968
|
for (let i = 0; i < data.rows.length; i++) {
|
|
11944
11969
|
const rowItem = /** @type {RowItemNonNull} */data.rows.item(i);
|
|
11945
11970
|
const rowKey = decode$1(rowItem[me.__keyColumnName], true);
|
|
11946
|
-
const matches = findMultiEntryMatches(rowKey, me.__range);
|
|
11971
|
+
const matches = findMultiEntryMatches(/** @type {import('./Key.js').Key} */rowKey, me.__range);
|
|
11947
11972
|
for (const matchingKey of matches) {
|
|
11948
11973
|
/**
|
|
11949
11974
|
* @type {RowItemNonNull}
|
|
@@ -12017,11 +12042,11 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
12017
12042
|
};
|
|
12018
12043
|
|
|
12019
12044
|
/**
|
|
12020
|
-
* @typedef {
|
|
12045
|
+
* @typedef {import('./Key.js').Value} StructuredCloneValue
|
|
12021
12046
|
*/
|
|
12022
12047
|
|
|
12023
12048
|
/**
|
|
12024
|
-
* @typedef {
|
|
12049
|
+
* @typedef {import('./Key.js').Key} IndexedDBKey
|
|
12025
12050
|
*/
|
|
12026
12051
|
|
|
12027
12052
|
/**
|
|
@@ -12033,9 +12058,9 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
12033
12058
|
|
|
12034
12059
|
/**
|
|
12035
12060
|
* @callback SuccessCallback
|
|
12036
|
-
* @param {IndexedDBKey} key
|
|
12061
|
+
* @param {IndexedDBKey|undefined} key
|
|
12037
12062
|
* @param {StructuredCloneValue} value
|
|
12038
|
-
* @param {IndexedDBKey} primaryKey
|
|
12063
|
+
* @param {IndexedDBKey|undefined} primaryKey
|
|
12039
12064
|
* @returns {void}
|
|
12040
12065
|
*/
|
|
12041
12066
|
|
|
@@ -12075,9 +12100,9 @@ IDBCursor.prototype.__onsuccess = function (success) {
|
|
|
12075
12100
|
*
|
|
12076
12101
|
* @param {RowItemNonNull} rowItem
|
|
12077
12102
|
* @param {(
|
|
12078
|
-
* key: import('./Key.js').Key,
|
|
12103
|
+
* key: import('./Key.js').Key|undefined,
|
|
12079
12104
|
* val: import('./Key.js').Value,
|
|
12080
|
-
* primaryKey: import('./Key.js').Key,
|
|
12105
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
12081
12106
|
* encKey?: string
|
|
12082
12107
|
* ) => void} callback
|
|
12083
12108
|
* @this {IDBCursorFull}
|
|
@@ -12152,8 +12177,8 @@ IDBCursor.prototype.__continue = function (key, advanceContinue) {
|
|
|
12152
12177
|
|
|
12153
12178
|
/**
|
|
12154
12179
|
*
|
|
12155
|
-
* @param {import('./Key.js').Key} key
|
|
12156
|
-
* @param {import('./Key.js').Key} primaryKey
|
|
12180
|
+
* @param {import('./Key.js').Key|undefined} key
|
|
12181
|
+
* @param {import('./Key.js').Key|undefined} primaryKey
|
|
12157
12182
|
* @param {boolean} advanceState
|
|
12158
12183
|
* @this {IDBCursorFull}
|
|
12159
12184
|
* @returns {void}
|
|
@@ -12167,9 +12192,9 @@ IDBCursor.prototype.__continueFinish = function (key, primaryKey, advanceState)
|
|
|
12167
12192
|
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
12168
12193
|
me.__store.transaction.__pushToQueue(me.__request, function cursorContinue(tx, args, success, error, executeNextRequest) {
|
|
12169
12194
|
/**
|
|
12170
|
-
* @param {import('./Key.js').Key} k
|
|
12195
|
+
* @param {import('./Key.js').Key|undefined} k
|
|
12171
12196
|
* @param {import('./Key.js').Value} val
|
|
12172
|
-
* @param {import('./Key.js').Key} primKey
|
|
12197
|
+
* @param {import('./Key.js').Key|undefined} primKey
|
|
12173
12198
|
* @returns {void}
|
|
12174
12199
|
*/
|
|
12175
12200
|
function triggerSuccess(k, val, primKey) {
|
|
@@ -12213,7 +12238,7 @@ IDBCursor.prototype.__continueFinish = function (key, primaryKey, advanceState)
|
|
|
12213
12238
|
// We have pre-loaded data for the cursor
|
|
12214
12239
|
me.__prefetchedIndex++;
|
|
12215
12240
|
if (me.__prefetchedIndex < me.__prefetchedData.length) {
|
|
12216
|
-
me.__decode(me.__prefetchedData.item(me.__prefetchedIndex), function (k, val, primKey, encKey) {
|
|
12241
|
+
me.__decode(/** @type {RowItemNonNull} */me.__prefetchedData.item(me.__prefetchedIndex), function (k, val, primKey, encKey) {
|
|
12217
12242
|
/**
|
|
12218
12243
|
* @returns {void}
|
|
12219
12244
|
*/
|
|
@@ -12348,12 +12373,18 @@ IDBCursor.prototype.advance = function (count) {
|
|
|
12348
12373
|
};
|
|
12349
12374
|
|
|
12350
12375
|
/**
|
|
12351
|
-
*
|
|
12376
|
+
* The `{query, count, direction}` options shape shared by
|
|
12377
|
+
* `getAll`/`getAllKeys`/`getAllRecords`.
|
|
12378
|
+
* @typedef {{
|
|
12379
|
+
* query?: import('./Key.js').Value,
|
|
12380
|
+
* count?: Integer,
|
|
12381
|
+
* direction?: string
|
|
12382
|
+
* }} GetAllOptions
|
|
12352
12383
|
*/
|
|
12353
12384
|
|
|
12354
12385
|
/**
|
|
12355
12386
|
*
|
|
12356
|
-
* @param {
|
|
12387
|
+
* @param {import('./Key.js').Value} valueToUpdate
|
|
12357
12388
|
* @this {IDBCursorFull}
|
|
12358
12389
|
* @returns {IDBRequest}
|
|
12359
12390
|
*/
|
|
@@ -12476,16 +12507,22 @@ Object.defineProperty(IDBCursorWithValue.prototype, 'constructor', {
|
|
|
12476
12507
|
const IDBCursorWithValueAlias = IDBCursorWithValue;
|
|
12477
12508
|
/**
|
|
12478
12509
|
*
|
|
12479
|
-
* @param {
|
|
12510
|
+
* @param {IDBKeyRange} query
|
|
12511
|
+
* @param {string} direction
|
|
12512
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
12513
|
+
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
12514
|
+
* import('./IDBIndex.js').IDBIndexFull} source
|
|
12515
|
+
* @param {string} keyColumnName
|
|
12516
|
+
* @param {string} valueColumnName
|
|
12517
|
+
* @param {boolean} [count]
|
|
12480
12518
|
* @returns {IDBCursorWithValueFull}
|
|
12481
12519
|
*/
|
|
12482
|
-
IDBCursorWithValue.__createInstance = function (
|
|
12520
|
+
IDBCursorWithValue.__createInstance = function (query, direction, store, source, keyColumnName, valueColumnName, count) {
|
|
12483
12521
|
/**
|
|
12484
12522
|
* @class
|
|
12485
12523
|
* @this {IDBCursorWithValueFull}
|
|
12486
12524
|
*/
|
|
12487
12525
|
function IDBCursorWithValue() {
|
|
12488
|
-
const [query, direction, store, source, keyColumnName, valueColumnName, count] = args;
|
|
12489
12526
|
IDBCursor.__super.call(this, query, direction, store, source, keyColumnName, valueColumnName, count);
|
|
12490
12527
|
// @ts-expect-error It's ok
|
|
12491
12528
|
this[Symbol.toStringTag] = 'IDBCursorWithValue';
|
|
@@ -12508,16 +12545,20 @@ Object.defineProperty(IDBCursorWithValue, 'prototype', {
|
|
|
12508
12545
|
/**
|
|
12509
12546
|
* Validates `direction` and fills in defaults for the `{query, count,
|
|
12510
12547
|
* direction}` shape shared by `getAll`/`getAllKeys`/`getAllRecords`.
|
|
12511
|
-
* @param {
|
|
12548
|
+
* @param {unknown} options
|
|
12512
12549
|
* @throws {TypeError}
|
|
12513
|
-
* @returns {{
|
|
12550
|
+
* @returns {{
|
|
12551
|
+
* query: import('./Key.js').Value|undefined,
|
|
12552
|
+
* count: Integer|undefined,
|
|
12553
|
+
* direction: string
|
|
12554
|
+
* }}
|
|
12514
12555
|
*/
|
|
12515
12556
|
function normalizeGetAllOptions(options) {
|
|
12516
12557
|
const {
|
|
12517
12558
|
query,
|
|
12518
12559
|
count,
|
|
12519
12560
|
direction = 'next'
|
|
12520
|
-
} = /** @type {
|
|
12561
|
+
} = /** @type {GetAllOptions} */options ?? {};
|
|
12521
12562
|
if (!cursorDirections.includes(direction)) {
|
|
12522
12563
|
throw new TypeError('`' + direction + '` is not a valid direction');
|
|
12523
12564
|
}
|
|
@@ -12542,7 +12583,11 @@ function normalizeGetAllOptions(options) {
|
|
|
12542
12583
|
* first argument wins regardless of how many arguments were actually passed.
|
|
12543
12584
|
* @param {IArguments} args
|
|
12544
12585
|
* @throws {TypeError}
|
|
12545
|
-
* @returns {{
|
|
12586
|
+
* @returns {{
|
|
12587
|
+
* query: import('./Key.js').Value|undefined,
|
|
12588
|
+
* count: Integer|undefined,
|
|
12589
|
+
* direction: string
|
|
12590
|
+
* }}
|
|
12546
12591
|
*/
|
|
12547
12592
|
function parseGetAllArgs(args) {
|
|
12548
12593
|
const arg0 = args[0];
|
|
@@ -12563,7 +12608,11 @@ function parseGetAllArgs(args) {
|
|
|
12563
12608
|
* form to disambiguate against.
|
|
12564
12609
|
* @param {IArguments} args
|
|
12565
12610
|
* @throws {TypeError}
|
|
12566
|
-
* @returns {{
|
|
12611
|
+
* @returns {{
|
|
12612
|
+
* query: import('./Key.js').Value|undefined,
|
|
12613
|
+
* count: Integer|undefined,
|
|
12614
|
+
* direction: string
|
|
12615
|
+
* }}
|
|
12567
12616
|
*/
|
|
12568
12617
|
function parseGetAllRecordsArgs(args) {
|
|
12569
12618
|
return normalizeGetAllOptions(args[0]);
|
|
@@ -12670,7 +12719,7 @@ function collectAll(source, query, count, direction, mode) {
|
|
|
12670
12719
|
value: direction
|
|
12671
12720
|
});
|
|
12672
12721
|
return tx.__addToTransactionQueue(function collectAllOp(sqlTx, args, success, error) {
|
|
12673
|
-
/** @type {
|
|
12722
|
+
/** @type {unknown[]} */
|
|
12674
12723
|
const results = [];
|
|
12675
12724
|
const recordsToLoad = count || CFG.cursorPreloadPackSize || 100;
|
|
12676
12725
|
|
|
@@ -12710,7 +12759,7 @@ function collectAll(source, query, count, direction, mode) {
|
|
|
12710
12759
|
if (state.__prefetchedData) {
|
|
12711
12760
|
state.__prefetchedIndex++;
|
|
12712
12761
|
if (state.__prefetchedIndex < state.__prefetchedData.length) {
|
|
12713
|
-
IDBCursor.prototype.__decode.call(state, state.__prefetchedData.item(state.__prefetchedIndex),
|
|
12762
|
+
IDBCursor.prototype.__decode.call(state, /** @type {RowItemNonNull} */state.__prefetchedData.item(state.__prefetchedIndex),
|
|
12714
12763
|
/**
|
|
12715
12764
|
* @param {import('./Key.js').Key} k
|
|
12716
12765
|
* @param {import('./Key.js').Value} val
|
|
@@ -12740,15 +12789,11 @@ function collectAll(source, query, count, direction, mode) {
|
|
|
12740
12789
|
}, undefined, source);
|
|
12741
12790
|
}
|
|
12742
12791
|
|
|
12743
|
-
/**
|
|
12744
|
-
* @typedef {any} AnyValue
|
|
12745
|
-
*/
|
|
12746
|
-
|
|
12747
12792
|
/**
|
|
12748
12793
|
* @callback SetConfig
|
|
12749
12794
|
* @param {import('./CFG.js').KeyofConfigValues|
|
|
12750
12795
|
* Partial<import('./CFG.js').ConfigValues>} prop
|
|
12751
|
-
* @param {
|
|
12796
|
+
* @param {import('./CFG.js').ConfigValue} [val]
|
|
12752
12797
|
* @throws {Error}
|
|
12753
12798
|
* @returns {void}
|
|
12754
12799
|
*/
|
|
@@ -12833,18 +12878,9 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12833
12878
|
}
|
|
12834
12879
|
const IDB = /** @type {ShimmedObject & {[key: string]: unknown}} */
|
|
12835
12880
|
/** @type {unknown} */idb || globalThis || {};
|
|
12836
|
-
/**
|
|
12837
|
-
* @typedef {any} AnyClass
|
|
12838
|
-
*/
|
|
12839
|
-
/**
|
|
12840
|
-
* @typedef {any} AnyValue
|
|
12841
|
-
*/
|
|
12842
|
-
/**
|
|
12843
|
-
* @typedef {Function} AnyFunction
|
|
12844
|
-
*/
|
|
12845
12881
|
/**
|
|
12846
12882
|
* @param {string} name
|
|
12847
|
-
* @param {
|
|
12883
|
+
* @param {unknown} value
|
|
12848
12884
|
* @param {PropertyDescriptor & {
|
|
12849
12885
|
* shimNS?: object
|
|
12850
12886
|
* }|undefined} [propDesc]
|
|
@@ -12873,10 +12909,10 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12873
12909
|
} else {
|
|
12874
12910
|
const o = {
|
|
12875
12911
|
/**
|
|
12876
|
-
* @returns {
|
|
12912
|
+
* @returns {unknown}
|
|
12877
12913
|
*/
|
|
12878
12914
|
get [name]() {
|
|
12879
|
-
return /** @type {
|
|
12915
|
+
return /** @type {() => unknown} */(/** @type {PropertyDescriptor} */propDesc.get).call(this);
|
|
12880
12916
|
}
|
|
12881
12917
|
};
|
|
12882
12918
|
desc = /** @type {PropertyDescriptor} */
|
|
@@ -12950,7 +12986,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12950
12986
|
return shimIndexedDB;
|
|
12951
12987
|
}
|
|
12952
12988
|
});
|
|
12953
|
-
/** @type {[string,
|
|
12989
|
+
/** @type {[string, unknown][]} */
|
|
12954
12990
|
[['IDBFactory', shimIDBFactory], ['IDBDatabase', IDBDatabase], ['IDBObjectStore', IDBObjectStore], ['IDBIndex', IDBIndex], ['IDBTransaction', IDBTransaction], ['IDBCursor', IDBCursor], ['IDBCursorWithValue', IDBCursorWithValue], ['IDBRecord', IDBRecord], ['IDBKeyRange', IDBKeyRange], ['IDBRequest', IDBRequest], ['IDBOpenDBRequest', IDBOpenDBRequest], ['IDBVersionChangeEvent', IDBVersionChangeEvent]].forEach(([prop, obj]) => {
|
|
12955
12991
|
shim(prop, obj, {
|
|
12956
12992
|
enumerable: false,
|
|
@@ -13037,7 +13073,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
13037
13073
|
IDB.shimIndexedDB = /** @type {ShimIndexedDB} */{};
|
|
13038
13074
|
/** @type {const} */
|
|
13039
13075
|
['__useShim', '__debug', '__setConfig', '__getConfig', '__setUnicodeIdentifiers'].forEach(prop => {
|
|
13040
|
-
/** @type {
|
|
13076
|
+
/** @type {{[key: string]: () => void}} */(/** @type {unknown} */IDB.shimIndexedDB)[prop] = function () {
|
|
13041
13077
|
console.warn('This browser does not have WebSQL to shim.');
|
|
13042
13078
|
};
|
|
13043
13079
|
});
|
|
@@ -13088,7 +13124,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
13088
13124
|
|
|
13089
13125
|
/**
|
|
13090
13126
|
* @typedef {{
|
|
13091
|
-
* _db:
|
|
13127
|
+
* _db: unknown,
|
|
13092
13128
|
* exec: typeof SQLiteDatabase['prototype']['exec']
|
|
13093
13129
|
* }} SQLiteDatabaseInstance
|
|
13094
13130
|
*/
|
|
@@ -13102,7 +13138,10 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
13102
13138
|
* object yields that object as the `new` expression's result, overriding
|
|
13103
13139
|
* the default "return `this`" behavior), not something TypeScript can
|
|
13104
13140
|
* verify structurally.
|
|
13105
|
-
* @typedef {new (
|
|
13141
|
+
* @typedef {new (
|
|
13142
|
+
* name: string,
|
|
13143
|
+
* opts?: import('websql-configurable/lib/sqlite/SQLiteDatabase.js').SQLiteDatabaseOptions
|
|
13144
|
+
* ) => SQLiteDatabaseInstance} SQLiteDatabaseConstructor
|
|
13106
13145
|
*/
|
|
13107
13146
|
|
|
13108
13147
|
/**
|