indexeddbshim 18.0.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/dist/DOMException.d.ts +3 -7
- 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 +100 -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 +36 -45
- 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 +224 -208
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +221 -235
- 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 +224 -208
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +221 -235
- 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 +221 -235
- 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 +20 -22
- package/dist/util.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CFG.js +1 -1
- package/src/DOMException.js +8 -10
- package/src/DOMStringList.js +6 -11
- package/src/Event.js +1 -4
- package/src/IDBCursor.js +95 -47
- package/src/IDBFactory.js +8 -5
- 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 +19 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! indexeddbshim -
|
|
1
|
+
/*! indexeddbshim - v19.0.0 - 9/3/2026 */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1545,7 +1545,7 @@ val => {
|
|
|
1545
1545
|
// Callback not used by default
|
|
1546
1546
|
// Defaults to true except in Node builds where we can preserve literal NUL with better-sqlite3
|
|
1547
1547
|
'escapeNULForSQLiteStatements', 'sqlMemoryQuota', 'createIndexes'].forEach(prop => {
|
|
1548
|
-
/** @type {(val:
|
|
1548
|
+
/** @type {(val: ConfigValue) => void} */
|
|
1549
1549
|
let validator;
|
|
1550
1550
|
if (Array.isArray(prop)) {
|
|
1551
1551
|
[prop, validator] = prop;
|
|
@@ -1765,9 +1765,11 @@ function joinPath(base, name) {
|
|
|
1765
1765
|
return base.replace(/[/\\]+$/u, '') + sep + name;
|
|
1766
1766
|
}
|
|
1767
1767
|
|
|
1768
|
+
/* eslint-disable jsdoc/valid-types -- Bug */
|
|
1768
1769
|
/**
|
|
1769
|
-
* @typedef {
|
|
1770
|
+
* @typedef {{[Symbol.hasInstance]: (value: unknown) => boolean}} AnyClass
|
|
1770
1771
|
*/
|
|
1772
|
+
/* eslint-enable jsdoc/valid-types -- Bug */
|
|
1771
1773
|
|
|
1772
1774
|
// Babel doesn't seem to provide a means of using the `instanceof` operator with Symbol.hasInstance (yet?)
|
|
1773
1775
|
/**
|
|
@@ -1791,7 +1793,7 @@ function isObj(obj) {
|
|
|
1791
1793
|
|
|
1792
1794
|
/**
|
|
1793
1795
|
*
|
|
1794
|
-
* @param {
|
|
1796
|
+
* @param {AnyValue} obj
|
|
1795
1797
|
* @returns {boolean}
|
|
1796
1798
|
*/
|
|
1797
1799
|
function isDate(obj) {
|
|
@@ -1800,7 +1802,7 @@ function isDate(obj) {
|
|
|
1800
1802
|
|
|
1801
1803
|
/**
|
|
1802
1804
|
*
|
|
1803
|
-
* @param {
|
|
1805
|
+
* @param {AnyValue} obj
|
|
1804
1806
|
* @returns {boolean}
|
|
1805
1807
|
*/
|
|
1806
1808
|
function isBlob(obj) {
|
|
@@ -1809,7 +1811,7 @@ function isBlob(obj) {
|
|
|
1809
1811
|
|
|
1810
1812
|
/**
|
|
1811
1813
|
*
|
|
1812
|
-
* @param {
|
|
1814
|
+
* @param {AnyValue} obj
|
|
1813
1815
|
* @returns {boolean}
|
|
1814
1816
|
*/
|
|
1815
1817
|
function isFile(obj) {
|
|
@@ -1831,7 +1833,7 @@ function isBinary(obj) {
|
|
|
1831
1833
|
/**
|
|
1832
1834
|
*
|
|
1833
1835
|
* @param {AnyValue} obj
|
|
1834
|
-
* @returns {
|
|
1836
|
+
* @returns {obj is Iterable<unknown>}
|
|
1835
1837
|
*/
|
|
1836
1838
|
function isIterable(obj) {
|
|
1837
1839
|
return isObj(obj) &&
|
|
@@ -1883,9 +1885,7 @@ function defineReadonlyOuterInterface(obj, props) {
|
|
|
1883
1885
|
|
|
1884
1886
|
/**
|
|
1885
1887
|
*
|
|
1886
|
-
* @param {object
|
|
1887
|
-
* [key: string]: any
|
|
1888
|
-
* }} obj
|
|
1888
|
+
* @param {object} obj
|
|
1889
1889
|
* @param {string[]} listeners
|
|
1890
1890
|
* @returns {void}
|
|
1891
1891
|
*/
|
|
@@ -1894,13 +1894,13 @@ function defineListenerProperties(obj, listeners) {
|
|
|
1894
1894
|
listeners.forEach(listener => {
|
|
1895
1895
|
const o = {
|
|
1896
1896
|
get [listener]() {
|
|
1897
|
-
return obj
|
|
1897
|
+
return Reflect.get(obj, '__' + listener);
|
|
1898
1898
|
},
|
|
1899
1899
|
/**
|
|
1900
1900
|
* @param {AnyValue} val
|
|
1901
1901
|
*/
|
|
1902
1902
|
set [listener](val) {
|
|
1903
|
-
obj
|
|
1903
|
+
Reflect.set(obj, '__' + listener, val);
|
|
1904
1904
|
}
|
|
1905
1905
|
};
|
|
1906
1906
|
const desc = /** @type {PropertyDescriptor} */
|
|
@@ -1910,7 +1910,7 @@ function defineListenerProperties(obj, listeners) {
|
|
|
1910
1910
|
Object.defineProperty(obj, listener, desc);
|
|
1911
1911
|
});
|
|
1912
1912
|
listeners.forEach(l => {
|
|
1913
|
-
obj
|
|
1913
|
+
Reflect.set(obj, l, null);
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
1916
1916
|
|
|
@@ -1919,7 +1919,7 @@ function defineListenerProperties(obj, listeners) {
|
|
|
1919
1919
|
* @param {object} obj
|
|
1920
1920
|
* @param {string|string[]} props
|
|
1921
1921
|
* @param {null|{
|
|
1922
|
-
* [key: string]:
|
|
1922
|
+
* [key: string]: unknown
|
|
1923
1923
|
* }} getter
|
|
1924
1924
|
* @returns {void}
|
|
1925
1925
|
*/
|
|
@@ -2056,7 +2056,7 @@ function enforceRange(number, type) {
|
|
|
2056
2056
|
}
|
|
2057
2057
|
|
|
2058
2058
|
/**
|
|
2059
|
-
* @typedef {
|
|
2059
|
+
* @typedef {unknown} AnyValue
|
|
2060
2060
|
*/
|
|
2061
2061
|
|
|
2062
2062
|
/**
|
|
@@ -2074,8 +2074,11 @@ function convertToDOMString(v, treatNullAs) {
|
|
|
2074
2074
|
*/
|
|
2075
2075
|
function ToString(o) {
|
|
2076
2076
|
// Todo: See `es-abstract/es7`
|
|
2077
|
-
// `String()` will not throw with Symbols
|
|
2078
|
-
|
|
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
|
|
2079
2082
|
}
|
|
2080
2083
|
|
|
2081
2084
|
/**
|
|
@@ -2182,12 +2185,9 @@ function createEvent(type, debug, evInit) {
|
|
|
2182
2185
|
// We don't add within polyfill repo as might not always be the desired implementation
|
|
2183
2186
|
Object.defineProperty(ShimEvent, Symbol.hasInstance, {
|
|
2184
2187
|
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
2185
|
-
/**
|
|
2186
|
-
* @typedef {any} AnyValue
|
|
2187
|
-
*/
|
|
2188
2188
|
value:
|
|
2189
2189
|
/**
|
|
2190
|
-
* @param {
|
|
2190
|
+
* @param {unknown} obj
|
|
2191
2191
|
* @returns {boolean}
|
|
2192
2192
|
*/
|
|
2193
2193
|
obj => isObj(obj) && 'target' in obj && 'bubbles' in obj && typeof obj.bubbles === 'boolean'
|
|
@@ -2255,12 +2255,9 @@ readonlyProperties$7.forEach(prop => {
|
|
|
2255
2255
|
Object.defineProperty(IDBVersionChangeEvent.prototype, prop, desc);
|
|
2256
2256
|
});
|
|
2257
2257
|
Object.defineProperty(IDBVersionChangeEvent, Symbol.hasInstance, {
|
|
2258
|
-
/**
|
|
2259
|
-
* @typedef {any} AnyValue
|
|
2260
|
-
*/
|
|
2261
2258
|
value:
|
|
2262
2259
|
/**
|
|
2263
|
-
* @param {
|
|
2260
|
+
* @param {unknown} obj
|
|
2264
2261
|
* @returns {boolean}
|
|
2265
2262
|
*/
|
|
2266
2263
|
obj => isObj(obj) && 'oldVersion' in obj && 'defaultPrevented' in obj && typeof obj.defaultPrevented === 'boolean'
|
|
@@ -2540,25 +2537,20 @@ function logError(name, message, error) {
|
|
|
2540
2537
|
}
|
|
2541
2538
|
|
|
2542
2539
|
/**
|
|
2543
|
-
* @
|
|
2544
|
-
*/
|
|
2545
|
-
|
|
2546
|
-
/**
|
|
2547
|
-
* @param {ArbitraryValue} obj
|
|
2540
|
+
* @param {unknown} obj
|
|
2548
2541
|
* @returns {boolean}
|
|
2549
2542
|
*/
|
|
2550
2543
|
function isErrorOrDOMErrorOrDOMException(obj) {
|
|
2551
|
-
return obj && typeof obj === 'object' &&
|
|
2552
2544
|
// We don't use util.isObj here as mutual dependency causing problems in Babel with browser
|
|
2553
|
-
typeof obj.name === 'string';
|
|
2545
|
+
return typeof obj === 'object' && obj !== null && 'name' in obj && typeof obj.name === 'string';
|
|
2554
2546
|
}
|
|
2555
2547
|
|
|
2556
2548
|
/**
|
|
2557
2549
|
* Finds the error argument. This is useful because some WebSQL callbacks
|
|
2558
2550
|
* pass the error as the first argument, and some pass it as the second
|
|
2559
2551
|
* argument.
|
|
2560
|
-
* @param {
|
|
2561
|
-
* @returns {
|
|
2552
|
+
* @param {unknown[]} args
|
|
2553
|
+
* @returns {unknown}
|
|
2562
2554
|
*/
|
|
2563
2555
|
function findError(args) {
|
|
2564
2556
|
let err;
|
|
@@ -2570,7 +2562,7 @@ function findError(args) {
|
|
|
2570
2562
|
if (isErrorOrDOMErrorOrDOMException(arg)) {
|
|
2571
2563
|
return arg;
|
|
2572
2564
|
}
|
|
2573
|
-
if (arg && typeof arg.message === 'string') {
|
|
2565
|
+
if (typeof arg === 'object' && arg !== null && 'message' in arg && typeof arg.message === 'string') {
|
|
2574
2566
|
err = arg;
|
|
2575
2567
|
}
|
|
2576
2568
|
}
|
|
@@ -2690,7 +2682,7 @@ function IDBRequest() {
|
|
|
2690
2682
|
* @typedef {IDBRequest & EventTarget & import('eventtargeter').EventTargetInstance & {
|
|
2691
2683
|
* transaction: import('./IDBTransaction.js').IDBTransactionFull,
|
|
2692
2684
|
* __done: boolean,
|
|
2693
|
-
* __result:
|
|
2685
|
+
* __result: unknown,
|
|
2694
2686
|
* __error: null|DOMException|Error,
|
|
2695
2687
|
* __source: null|import('./IDBDatabase.js').IDBDatabaseFull|
|
|
2696
2688
|
* import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
@@ -3146,8 +3138,8 @@ class SyncPromise {
|
|
|
3146
3138
|
|
|
3147
3139
|
/**
|
|
3148
3140
|
* Compares two keys.
|
|
3149
|
-
* @param {import('./Key.js').Key} first
|
|
3150
|
-
* @param {import('./Key.js').Key} second
|
|
3141
|
+
* @param {import('./Key.js').Key|null|undefined} first
|
|
3142
|
+
* @param {import('./Key.js').Key|null|undefined} second
|
|
3151
3143
|
* @returns {0|1|-1}
|
|
3152
3144
|
*/
|
|
3153
3145
|
function cmp(first, second) {
|
|
@@ -3221,12 +3213,11 @@ const safePush = (arr, val) => setArrayValue(arr, arr.length, val);
|
|
|
3221
3213
|
*/
|
|
3222
3214
|
|
|
3223
3215
|
/**
|
|
3224
|
-
* @typedef {
|
|
3216
|
+
* @typedef {unknown} Value
|
|
3225
3217
|
*/
|
|
3226
3218
|
|
|
3227
3219
|
/**
|
|
3228
|
-
* @typedef {
|
|
3229
|
-
* @todo Specify possible value more precisely
|
|
3220
|
+
* @typedef {IDBValidKey} Key
|
|
3230
3221
|
*/
|
|
3231
3222
|
|
|
3232
3223
|
/**
|
|
@@ -3293,15 +3284,11 @@ const encodedCharToKeyType = keyTypes.reduce((o, k) => {
|
|
|
3293
3284
|
*/
|
|
3294
3285
|
const signValues = ['negativeInfinity', 'bigNegative', 'smallNegative', 'smallPositive', 'bigPositive', 'positiveInfinity'];
|
|
3295
3286
|
|
|
3296
|
-
/**
|
|
3297
|
-
* @typedef {any} AnyValue
|
|
3298
|
-
*/
|
|
3299
|
-
|
|
3300
3287
|
/**
|
|
3301
3288
|
* @type {{
|
|
3302
3289
|
* [key: string]: {
|
|
3303
|
-
* encode
|
|
3304
|
-
* decode
|
|
3290
|
+
* encode(param: unknown, inArray?: boolean): string,
|
|
3291
|
+
* decode(param: string, inArray?: boolean): ValueType|undefined
|
|
3305
3292
|
* }
|
|
3306
3293
|
* }}
|
|
3307
3294
|
*/
|
|
@@ -3633,7 +3620,7 @@ function negate(s) {
|
|
|
3633
3620
|
}
|
|
3634
3621
|
|
|
3635
3622
|
/**
|
|
3636
|
-
* @param {
|
|
3623
|
+
* @param {Value} key
|
|
3637
3624
|
* @returns {KeyType|"invalid"}
|
|
3638
3625
|
*/
|
|
3639
3626
|
function getKeyType(key) {
|
|
@@ -3777,7 +3764,7 @@ function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
|
3777
3764
|
case 'array':
|
|
3778
3765
|
{
|
|
3779
3766
|
// May throw (from binary)
|
|
3780
|
-
const arr = /** @type {
|
|
3767
|
+
const arr = /** @type {unknown[]} */input;
|
|
3781
3768
|
const len = arr.length;
|
|
3782
3769
|
safePush(seen, input);
|
|
3783
3770
|
|
|
@@ -3805,7 +3792,7 @@ function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
|
3805
3792
|
message: 'Bad array entry value-to-key conversion'
|
|
3806
3793
|
};
|
|
3807
3794
|
}
|
|
3808
|
-
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)) {
|
|
3809
3796
|
safePush(keys, fullKeys ? key : key.value);
|
|
3810
3797
|
}
|
|
3811
3798
|
} catch (err) {
|
|
@@ -3855,7 +3842,7 @@ function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
|
3855
3842
|
|
|
3856
3843
|
/**
|
|
3857
3844
|
*
|
|
3858
|
-
* @param {
|
|
3845
|
+
* @param {Value} key
|
|
3859
3846
|
* @param {boolean} [fullKeys]
|
|
3860
3847
|
* @returns {KeyValueObject}
|
|
3861
3848
|
* @todo Document other allowable `key`?
|
|
@@ -3970,7 +3957,7 @@ function evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, fullKe
|
|
|
3970
3957
|
}
|
|
3971
3958
|
if (keyPath === '') {
|
|
3972
3959
|
return {
|
|
3973
|
-
value
|
|
3960
|
+
value: (/** @type {KeyPathEvaluateValueValue} */value)
|
|
3974
3961
|
};
|
|
3975
3962
|
}
|
|
3976
3963
|
const identifiers = keyPath.split('.');
|
|
@@ -4004,13 +3991,13 @@ function evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, fullKe
|
|
|
4004
3991
|
}) ? {
|
|
4005
3992
|
failure: true
|
|
4006
3993
|
} : {
|
|
4007
|
-
value
|
|
3994
|
+
value: (/** @type {KeyPathEvaluateValueValue} */value)
|
|
4008
3995
|
};
|
|
4009
3996
|
}
|
|
4010
3997
|
|
|
4011
3998
|
/**
|
|
4012
3999
|
* Sets the inline key value.
|
|
4013
|
-
* @param {{[key: string]:
|
|
4000
|
+
* @param {{[key: string]: Value}} value
|
|
4014
4001
|
* @param {Key} key
|
|
4015
4002
|
* @param {string} keyPath
|
|
4016
4003
|
* @returns {void}
|
|
@@ -4028,7 +4015,7 @@ function injectKeyIntoValueUsingKeyPath(value, key, keyPath) {
|
|
|
4028
4015
|
configurable: true
|
|
4029
4016
|
});
|
|
4030
4017
|
}
|
|
4031
|
-
value = value[identifier];
|
|
4018
|
+
value = /** @type {{[key: string]: Value}} */value[identifier];
|
|
4032
4019
|
});
|
|
4033
4020
|
Object.defineProperty(value, /** @type {string} */last, {
|
|
4034
4021
|
value: key,
|
|
@@ -4104,7 +4091,7 @@ function isMultiEntryMatch(encodedEntry, encodedKey) {
|
|
|
4104
4091
|
* @returns {Key[]}
|
|
4105
4092
|
*/
|
|
4106
4093
|
function findMultiEntryMatches(keyEntry, range) {
|
|
4107
|
-
/** @type {
|
|
4094
|
+
/** @type {Key[]} */
|
|
4108
4095
|
const matches = [];
|
|
4109
4096
|
if (Array.isArray(keyEntry)) {
|
|
4110
4097
|
for (let key of keyEntry) {
|
|
@@ -4134,7 +4121,7 @@ function findMultiEntryMatches(keyEntry, range) {
|
|
|
4134
4121
|
|
|
4135
4122
|
/**
|
|
4136
4123
|
* Not currently in use but keeping for spec parity.
|
|
4137
|
-
* @param {
|
|
4124
|
+
* @param {KeyValueObject} key
|
|
4138
4125
|
* @throws {Error} Upon a "bad key"
|
|
4139
4126
|
* @returns {ValueType}
|
|
4140
4127
|
*/
|
|
@@ -4147,16 +4134,17 @@ function convertKeyToValue(key) {
|
|
|
4147
4134
|
case 'number':
|
|
4148
4135
|
case 'string':
|
|
4149
4136
|
{
|
|
4150
|
-
return value;
|
|
4137
|
+
return /** @type {number|string} */value;
|
|
4151
4138
|
}
|
|
4152
4139
|
case 'array':
|
|
4153
4140
|
{
|
|
4154
4141
|
/** @type {ValueType[]} */
|
|
4155
4142
|
const array = [];
|
|
4156
|
-
const
|
|
4143
|
+
const arrValue = /** @type {KeyValueObject[]} */value;
|
|
4144
|
+
const len = arrValue.length;
|
|
4157
4145
|
let index = 0;
|
|
4158
4146
|
while (index < len) {
|
|
4159
|
-
const entry = convertKeyToValue(
|
|
4147
|
+
const entry = convertKeyToValue(arrValue[index]);
|
|
4160
4148
|
setArrayValue(array, index, entry);
|
|
4161
4149
|
index++;
|
|
4162
4150
|
}
|
|
@@ -4164,18 +4152,18 @@ function convertKeyToValue(key) {
|
|
|
4164
4152
|
}
|
|
4165
4153
|
case 'date':
|
|
4166
4154
|
{
|
|
4167
|
-
return new Date(value);
|
|
4155
|
+
return new Date(/** @type {number} */value);
|
|
4168
4156
|
}
|
|
4169
4157
|
case 'binary':
|
|
4170
4158
|
{
|
|
4171
|
-
const
|
|
4159
|
+
const binValue = /** @type {Uint8Array} */value;
|
|
4160
|
+
const len = binValue.length;
|
|
4172
4161
|
const buffer = new ArrayBuffer(len);
|
|
4173
4162
|
// Set the entries in buffer's [[ArrayBufferData]] to those in `value`
|
|
4174
|
-
const uint8 = new Uint8Array(buffer,
|
|
4175
|
-
uint8.set(
|
|
4163
|
+
const uint8 = new Uint8Array(buffer, binValue.byteOffset || 0, binValue.byteLength);
|
|
4164
|
+
uint8.set(binValue);
|
|
4176
4165
|
return buffer;
|
|
4177
4166
|
}
|
|
4178
|
-
case 'invalid':
|
|
4179
4167
|
default:
|
|
4180
4168
|
throw new Error('Bad key');
|
|
4181
4169
|
}
|
|
@@ -4183,7 +4171,7 @@ function convertKeyToValue(key) {
|
|
|
4183
4171
|
|
|
4184
4172
|
/**
|
|
4185
4173
|
*
|
|
4186
|
-
* @param {
|
|
4174
|
+
* @param {Value} key
|
|
4187
4175
|
* @param {boolean} [inArray]
|
|
4188
4176
|
* @returns {string|null}
|
|
4189
4177
|
*/
|
|
@@ -4198,7 +4186,7 @@ function encode$1(key, inArray) {
|
|
|
4198
4186
|
|
|
4199
4187
|
/**
|
|
4200
4188
|
*
|
|
4201
|
-
* @param {
|
|
4189
|
+
* @param {string|null} key
|
|
4202
4190
|
* @param {boolean} [inArray]
|
|
4203
4191
|
* @throws {Error} Invalid number
|
|
4204
4192
|
* @returns {undefined|ValueType}
|
|
@@ -4212,7 +4200,7 @@ function decode$1(key, inArray) {
|
|
|
4212
4200
|
|
|
4213
4201
|
/**
|
|
4214
4202
|
*
|
|
4215
|
-
* @param {
|
|
4203
|
+
* @param {Value} key
|
|
4216
4204
|
* @param {boolean} [inArray]
|
|
4217
4205
|
* @returns {undefined|ValueType}
|
|
4218
4206
|
*/
|
|
@@ -4430,8 +4418,8 @@ function IDBKeyRange() {
|
|
|
4430
4418
|
const IDBKeyRangeAlias = IDBKeyRange;
|
|
4431
4419
|
|
|
4432
4420
|
/**
|
|
4433
|
-
* @param {import('./Key.js').
|
|
4434
|
-
* @param {import('./Key.js').
|
|
4421
|
+
* @param {import('./Key.js').Value} lower
|
|
4422
|
+
* @param {import('./Key.js').Value} upper
|
|
4435
4423
|
* @param {boolean} lowerOpen
|
|
4436
4424
|
* @param {boolean} upperOpen
|
|
4437
4425
|
* @returns {import('./IDBKeyRange.js').IDBKeyRangeFull}
|
|
@@ -4634,10 +4622,11 @@ function setSQLForKeyRange(range, quotedKeyColumnName, sql, sqlValues, addAnd, c
|
|
|
4634
4622
|
function convertValueToKeyRange(value, nullDisallowed) {
|
|
4635
4623
|
if (instanceOf(value, IDBKeyRange)) {
|
|
4636
4624
|
// We still need to validate IDBKeyRange-like objects (the above check is based on loose duck-typing)
|
|
4637
|
-
|
|
4638
|
-
|
|
4625
|
+
const range = /** @type {IDBKeyRangeFull} */value;
|
|
4626
|
+
if (range.toString() !== '[object IDBKeyRange]') {
|
|
4627
|
+
return IDBKeyRange.__createInstance(range.lower, range.upper, range.lowerOpen, range.upperOpen);
|
|
4639
4628
|
}
|
|
4640
|
-
return
|
|
4629
|
+
return range;
|
|
4641
4630
|
}
|
|
4642
4631
|
if (isNullish(value)) {
|
|
4643
4632
|
if (nullDisallowed) {
|
|
@@ -4664,7 +4653,7 @@ function convertValueToKeyRange(value, nullDisallowed) {
|
|
|
4664
4653
|
* clone: () => DOMStringListFull,
|
|
4665
4654
|
* contains: (str: string) => boolean,
|
|
4666
4655
|
* indexOf: (str: string) => Integer,
|
|
4667
|
-
* splice: (index: Integer, howmany: Integer, ...args:
|
|
4656
|
+
* splice: (index: Integer, howmany: Integer, ...args: string[]) => void
|
|
4668
4657
|
* length: Integer
|
|
4669
4658
|
* }} DOMStringListFull
|
|
4670
4659
|
*/
|
|
@@ -4781,9 +4770,10 @@ DOMStringList.prototype = {
|
|
|
4781
4770
|
},
|
|
4782
4771
|
/**
|
|
4783
4772
|
* @this {DOMStringListFull}
|
|
4784
|
-
* @
|
|
4773
|
+
* @template T
|
|
4774
|
+
* @param {(value: string, i: Integer, arr: string[]) => T} cb
|
|
4785
4775
|
* @param {object} thisArg
|
|
4786
|
-
* @returns {
|
|
4776
|
+
* @returns {T[]}
|
|
4787
4777
|
*/
|
|
4788
4778
|
map(cb, thisArg) {
|
|
4789
4779
|
// eslint-disable-next-line unicorn/no-array-callback-reference, unicorn/no-array-method-this-argument -- Convenient
|
|
@@ -4808,10 +4798,7 @@ DOMStringList.prototype = {
|
|
|
4808
4798
|
this.sortList();
|
|
4809
4799
|
},
|
|
4810
4800
|
/**
|
|
4811
|
-
* @
|
|
4812
|
-
*/
|
|
4813
|
-
/**
|
|
4814
|
-
* @param {[index: Integer, howmany: Integer, ...args: any]} args
|
|
4801
|
+
* @param {[index: Integer, howmany: Integer, ...args: string[]]} args
|
|
4815
4802
|
* @this {DOMStringListFull}
|
|
4816
4803
|
* @returns {void}
|
|
4817
4804
|
*/
|
|
@@ -4845,12 +4832,9 @@ DOMStringList.prototype = {
|
|
|
4845
4832
|
};
|
|
4846
4833
|
|
|
4847
4834
|
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
4848
|
-
/**
|
|
4849
|
-
* @typedef {any} AnyValue
|
|
4850
|
-
*/
|
|
4851
4835
|
Object.defineProperty(DOMStringList, Symbol.hasInstance, {
|
|
4852
4836
|
/**
|
|
4853
|
-
* @param {
|
|
4837
|
+
* @param {unknown} obj
|
|
4854
4838
|
* @returns {boolean}
|
|
4855
4839
|
*/
|
|
4856
4840
|
value(obj) {
|
|
@@ -4931,7 +4915,7 @@ const readonlyProperties$4 = ['objectStoreNames', 'mode', 'durability', 'db', 'e
|
|
|
4931
4915
|
/**
|
|
4932
4916
|
* @typedef {{
|
|
4933
4917
|
* op: SQLCallback,
|
|
4934
|
-
* args:
|
|
4918
|
+
* args: unknown[],
|
|
4935
4919
|
* req: import('./IDBRequest.js').IDBRequestFull|null
|
|
4936
4920
|
* }} RequestInfo
|
|
4937
4921
|
*/
|
|
@@ -4983,17 +4967,17 @@ const readonlyProperties$4 = ['objectStoreNames', 'mode', 'durability', 'db', 'e
|
|
|
4983
4967
|
* __pushToQueue: (
|
|
4984
4968
|
* request: import('./IDBRequest.js').IDBRequestFull|null,
|
|
4985
4969
|
* callback: SQLCallback,
|
|
4986
|
-
* args?:
|
|
4970
|
+
* args?: unknown[]
|
|
4987
4971
|
* ) => void,
|
|
4988
4972
|
* __assertActive: () => void,
|
|
4989
4973
|
* commit: () => void,
|
|
4990
4974
|
* __addNonRequestToTransactionQueue: (
|
|
4991
4975
|
* callback: SQLCallback,
|
|
4992
|
-
* args?:
|
|
4976
|
+
* args?: unknown[]
|
|
4993
4977
|
* ) => void
|
|
4994
4978
|
* __addToTransactionQueue: (
|
|
4995
4979
|
* callback: SQLCallback,
|
|
4996
|
-
* args:
|
|
4980
|
+
* args: unknown[]|undefined,
|
|
4997
4981
|
* source: import('./IDBDatabase.js').IDBDatabaseFull|
|
|
4998
4982
|
* import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
4999
4983
|
* import('./IDBIndex.js').IDBIndexFull|
|
|
@@ -5193,7 +5177,7 @@ IDBTransaction.prototype.__executeRequests = function () {
|
|
|
5193
5177
|
i = -1;
|
|
5194
5178
|
|
|
5195
5179
|
/**
|
|
5196
|
-
* @typedef {
|
|
5180
|
+
* @typedef {unknown} IDBRequestResult
|
|
5197
5181
|
*/
|
|
5198
5182
|
|
|
5199
5183
|
/**
|
|
@@ -5624,8 +5608,8 @@ IDBTransaction.prototype.__createRequest = function (source) {
|
|
|
5624
5608
|
/**
|
|
5625
5609
|
* @typedef {(
|
|
5626
5610
|
* tx: import('websql-configurable/lib/websql/WebSQLTransaction.js').default,
|
|
5627
|
-
* args:
|
|
5628
|
-
* success: (result?:
|
|
5611
|
+
* args: unknown[],
|
|
5612
|
+
* success: (result?: unknown, req?: import('./IDBRequest.js').IDBRequestFull) => void,
|
|
5629
5613
|
* error: (
|
|
5630
5614
|
* tx: import('websql-configurable/lib/websql/WebSQLTransaction.js').default|Error|DOMException,
|
|
5631
5615
|
* err?: Error & {code?: number}
|
|
@@ -5637,7 +5621,7 @@ IDBTransaction.prototype.__createRequest = function (source) {
|
|
|
5637
5621
|
/**
|
|
5638
5622
|
* Adds a callback function to the transaction queue.
|
|
5639
5623
|
* @param {SQLCallback} callback
|
|
5640
|
-
* @param {
|
|
5624
|
+
* @param {unknown[]} args
|
|
5641
5625
|
* @param {import('./IDBDatabase.js').IDBDatabaseFull|
|
|
5642
5626
|
* import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
5643
5627
|
* import('./IDBIndex.js').IDBIndexFull} source
|
|
@@ -5654,7 +5638,7 @@ IDBTransaction.prototype.__addToTransactionQueue = function (callback, args, sou
|
|
|
5654
5638
|
* Adds a callback function to the transaction queue without generating a
|
|
5655
5639
|
* request.
|
|
5656
5640
|
* @param {SQLCallback} callback
|
|
5657
|
-
* @param {
|
|
5641
|
+
* @param {unknown[]} args
|
|
5658
5642
|
* @this {IDBTransactionFull}
|
|
5659
5643
|
* @returns {void}
|
|
5660
5644
|
*/
|
|
@@ -5666,7 +5650,7 @@ IDBTransaction.prototype.__addNonRequestToTransactionQueue = function (callback,
|
|
|
5666
5650
|
* Adds an IDBRequest to the transaction queue.
|
|
5667
5651
|
* @param {import('./IDBRequest.js').IDBRequestFull|null} request
|
|
5668
5652
|
* @param {SQLCallback} callback
|
|
5669
|
-
* @param {
|
|
5653
|
+
* @param {unknown[]} args
|
|
5670
5654
|
* @this {IDBTransactionFull}
|
|
5671
5655
|
* @returns {void}
|
|
5672
5656
|
*/
|
|
@@ -5835,7 +5819,7 @@ IDBTransaction.prototype.__abortTransaction = function (err) {
|
|
|
5835
5819
|
bubbles: true,
|
|
5836
5820
|
cancelable: true
|
|
5837
5821
|
});
|
|
5838
|
-
return new SyncPromise(/** @type {(resolve: (value?:
|
|
5822
|
+
return new SyncPromise(/** @type {(resolve: (value?: unknown) => void) => void} */
|
|
5839
5823
|
resolve => {
|
|
5840
5824
|
setTimeout(() => {
|
|
5841
5825
|
if (!q.req) {
|
|
@@ -7650,7 +7634,7 @@ function encode(obj, func) {
|
|
|
7650
7634
|
}
|
|
7651
7635
|
|
|
7652
7636
|
/**
|
|
7653
|
-
* @typedef {
|
|
7637
|
+
* @typedef {import('./Key.js').Value} AnyValue
|
|
7654
7638
|
*/
|
|
7655
7639
|
|
|
7656
7640
|
/**
|
|
@@ -7760,7 +7744,7 @@ const IDBIndexAlias = IDBIndex;
|
|
|
7760
7744
|
* __keyPath: import('./Key.js').KeyPath,
|
|
7761
7745
|
* __recreated?: boolean,
|
|
7762
7746
|
* __fetchIndexData: (
|
|
7763
|
-
* range:
|
|
7747
|
+
* range: Query,
|
|
7764
7748
|
* opType: "value"|"key"|"count",
|
|
7765
7749
|
* nullDisallowed: boolean,
|
|
7766
7750
|
* count?: number
|
|
@@ -8136,7 +8120,7 @@ IDBIndex.__updateIndexList = function (store, tx, success, failure) {
|
|
|
8136
8120
|
};
|
|
8137
8121
|
|
|
8138
8122
|
/**
|
|
8139
|
-
* @typedef {
|
|
8123
|
+
* @typedef {import('./Key.js').Value|IDBKeyRange} Query
|
|
8140
8124
|
*/
|
|
8141
8125
|
|
|
8142
8126
|
/**
|
|
@@ -8409,7 +8393,7 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
8409
8393
|
reject(err);
|
|
8410
8394
|
});
|
|
8411
8395
|
}));
|
|
8412
|
-
SyncPromise.all(indexCreations).then(finish).catch(/** @type {(reason:
|
|
8396
|
+
SyncPromise.all(indexCreations).then(finish).catch(/** @type {(reason: unknown) => PromiseLike<never>} */
|
|
8413
8397
|
error).catch(err => {
|
|
8414
8398
|
console.log('Index rename error');
|
|
8415
8399
|
throw err;
|
|
@@ -8421,14 +8405,10 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
8421
8405
|
});
|
|
8422
8406
|
};
|
|
8423
8407
|
|
|
8424
|
-
/**
|
|
8425
|
-
* @typedef {any} AnyValue
|
|
8426
|
-
*/
|
|
8427
|
-
|
|
8428
8408
|
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
8429
8409
|
Object.defineProperty(IDBIndex, Symbol.hasInstance, {
|
|
8430
8410
|
/**
|
|
8431
|
-
* @param {
|
|
8411
|
+
* @param {unknown} obj
|
|
8432
8412
|
* @returns {boolean}
|
|
8433
8413
|
*/
|
|
8434
8414
|
value: obj => isObj(obj) && 'openCursor' in obj && typeof obj.openCursor === 'function' && 'multiEntry' in obj && typeof obj.multiEntry === 'boolean'
|
|
@@ -8454,7 +8434,9 @@ Object.defineProperty(IDBIndex, 'prototype', {
|
|
|
8454
8434
|
* @param {string[]} sqlValues
|
|
8455
8435
|
* @param {WebSQLTransaction} tx
|
|
8456
8436
|
* @param {null|undefined} args
|
|
8457
|
-
* @param {(
|
|
8437
|
+
* @param {(
|
|
8438
|
+
* result: number|undefined|[]|import('./Key.js').Value|import('./Key.js').Value[]
|
|
8439
|
+
* ) => void} success
|
|
8458
8440
|
* @param {(tx: WebSQLTransaction, err: (Error & {code?: number})) => void} error
|
|
8459
8441
|
* @returns {void}
|
|
8460
8442
|
*/
|
|
@@ -8491,7 +8473,7 @@ function executeFetchIndexData(count, unboundedDisallowed, index, hasKey, range,
|
|
|
8491
8473
|
* @param {{
|
|
8492
8474
|
* value: string
|
|
8493
8475
|
* }} record
|
|
8494
|
-
* @returns {
|
|
8476
|
+
* @returns {import('./Key.js').Value}
|
|
8495
8477
|
*/
|
|
8496
8478
|
record => {
|
|
8497
8479
|
// when opType is value
|
|
@@ -8505,9 +8487,9 @@ function executeFetchIndexData(count, unboundedDisallowed, index, hasKey, range,
|
|
|
8505
8487
|
const rowKey = /** @type {import('./Key.js').ValueTypeArray} */
|
|
8506
8488
|
decode$1(row[escapedIndexNameForKeyCol]);
|
|
8507
8489
|
let record;
|
|
8508
|
-
if (hasKey && (multiChecks && range.some(
|
|
8490
|
+
if (hasKey && (multiChecks && /** @type {import('./Key.js').ValueType[]} */range.some(
|
|
8509
8491
|
/**
|
|
8510
|
-
* @param {
|
|
8492
|
+
* @param {import('./Key.js').ValueType} check
|
|
8511
8493
|
* @returns {boolean}
|
|
8512
8494
|
*/
|
|
8513
8495
|
check => rowKey.includes(check)) ||
|
|
@@ -8653,14 +8635,14 @@ const IDBObjectStoreAlias = IDBObjectStore;
|
|
|
8653
8635
|
* __idbdb: import('./IDBDatabase.js').IDBDatabaseFull,
|
|
8654
8636
|
* __validateKeyAndValueAndCloneValue: (
|
|
8655
8637
|
* value: import('./Key.js').Value,
|
|
8656
|
-
* key: import('./Key.js').Key,
|
|
8638
|
+
* key: import('./Key.js').Key|undefined,
|
|
8657
8639
|
* cursorUpdate: boolean
|
|
8658
8640
|
* ) => KeyValueArray,
|
|
8659
8641
|
* __deriveKey: (
|
|
8660
8642
|
* tx: WebSQLTransaction,
|
|
8661
8643
|
* value: import('./Key.js').Value,
|
|
8662
|
-
* key: import('./Key.js').Key,
|
|
8663
|
-
* success: (key: import('./Key.js').
|
|
8644
|
+
* key: import('./Key.js').Key|undefined,
|
|
8645
|
+
* success: (key: import('./Key.js').Value, cn?: Integer) => void,
|
|
8664
8646
|
* failCb: import('./Key.js').SQLFailureCallback
|
|
8665
8647
|
* ) => void,
|
|
8666
8648
|
* __checkIndexConstraints: (
|
|
@@ -8971,7 +8953,7 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
|
|
|
8971
8953
|
};
|
|
8972
8954
|
|
|
8973
8955
|
/**
|
|
8974
|
-
* @typedef {[import('./Key.js').Key, import('./Key.js').Value]} KeyValueArray
|
|
8956
|
+
* @typedef {[import('./Key.js').Key|undefined, import('./Key.js').Value]} KeyValueArray
|
|
8975
8957
|
*/
|
|
8976
8958
|
|
|
8977
8959
|
// Todo: Although we may end up needing to do cloning genuinely asynchronously (for Blobs and FileLists),
|
|
@@ -8986,7 +8968,7 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
|
|
|
8986
8968
|
* Determines whether the given inline or out-of-line key is valid,
|
|
8987
8969
|
* according to the object store's schema.
|
|
8988
8970
|
* @param {import('./Key.js').Value} value Used for inline keys
|
|
8989
|
-
* @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
|
|
8990
8972
|
* @param {boolean} cursorUpdate
|
|
8991
8973
|
* @throws {DOMException}
|
|
8992
8974
|
* @this {IDBObjectStoreFull}
|
|
@@ -9002,11 +8984,11 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
|
|
|
9002
8984
|
// occurs sync; then can make cloning and this method without callbacks (except where ok
|
|
9003
8985
|
// to be async)
|
|
9004
8986
|
const clonedValue = cloneWithInactiveTransaction(/** @type {import('./IDBTransaction.js').IDBTransactionFull} */me.transaction, value);
|
|
9005
|
-
|
|
9006
|
-
if (
|
|
8987
|
+
const extractedKey = extractKeyValueDecodedFromValueUsingKeyPath(clonedValue, me.keyPath); // May throw so "rethrow"
|
|
8988
|
+
if ('invalid' in extractedKey && extractedKey.invalid) {
|
|
9007
8989
|
throw createDOMException('DataError', 'KeyPath was specified, but key was invalid.');
|
|
9008
8990
|
}
|
|
9009
|
-
if (
|
|
8991
|
+
if ('failure' in extractedKey && extractedKey.failure) {
|
|
9010
8992
|
if (!cursorUpdate) {
|
|
9011
8993
|
if (!me.autoIncrement) {
|
|
9012
8994
|
throw createDOMException('DataError', 'Could not evaluate a key from keyPath and there is no key generator');
|
|
@@ -9021,14 +9003,13 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
|
|
|
9021
9003
|
throw createDOMException('DataError', 'Could not evaluate a key from keyPath');
|
|
9022
9004
|
}
|
|
9023
9005
|
// An `IDBCursor.update` call will also throw if not equal to the cursor’s effective key
|
|
9024
|
-
return [
|
|
9006
|
+
return [(/** @type {import('./Key.js').Key} */extractedKey.value), clonedValue];
|
|
9025
9007
|
}
|
|
9026
9008
|
if (key === undefined) {
|
|
9027
9009
|
if (!me.autoIncrement) {
|
|
9028
9010
|
throw createDOMException('DataError', 'The object store uses out-of-line keys and has no key generator and the key parameter was not provided.');
|
|
9029
9011
|
}
|
|
9030
9012
|
// A key will be generated
|
|
9031
|
-
key = undefined;
|
|
9032
9013
|
} else {
|
|
9033
9014
|
convertValueToKeyRethrowingAndIfInvalid(key);
|
|
9034
9015
|
}
|
|
@@ -9043,8 +9024,8 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
|
|
|
9043
9024
|
* a keyPath leading to a valid but non-numeric or < 1 key).
|
|
9044
9025
|
* @param {WebSQLTransaction} tx
|
|
9045
9026
|
* @param {import('./Key.js').Value} value
|
|
9046
|
-
* @param {import('./Key.js').Key} key
|
|
9047
|
-
* @param {(key: import('./Key.js').
|
|
9027
|
+
* @param {import('./Key.js').Key|undefined} key
|
|
9028
|
+
* @param {(key: import('./Key.js').Value, cn?: Integer) => void} success
|
|
9048
9029
|
* @param {import('./Key.js').SQLFailureCallback} failCb
|
|
9049
9030
|
* @this {IDBObjectStoreFull}
|
|
9050
9031
|
* @returns {void}
|
|
@@ -9059,9 +9040,8 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
|
|
|
9059
9040
|
*/
|
|
9060
9041
|
function keyCloneThenSuccess(oldCn) {
|
|
9061
9042
|
// We want to return the original key, so we don't need to accept an argument here
|
|
9062
|
-
encode(key, function (
|
|
9063
|
-
|
|
9064
|
-
success(key, oldCn);
|
|
9043
|
+
encode(key, function (encodedKey) {
|
|
9044
|
+
success(decode(encodedKey), oldCn);
|
|
9065
9045
|
});
|
|
9066
9046
|
}
|
|
9067
9047
|
if (me.autoIncrement) {
|
|
@@ -9075,7 +9055,7 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
|
|
|
9075
9055
|
if (me.keyPath !== null) {
|
|
9076
9056
|
// Should not throw now as checked earlier
|
|
9077
9057
|
// Todo: Could this not be an array here?
|
|
9078
|
-
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);
|
|
9079
9059
|
}
|
|
9080
9060
|
success(key, oldCn);
|
|
9081
9061
|
}, failCb);
|
|
@@ -9132,15 +9112,15 @@ IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeK
|
|
|
9132
9112
|
resolve(undefined);
|
|
9133
9113
|
return;
|
|
9134
9114
|
}
|
|
9135
|
-
|
|
9136
|
-
if (
|
|
9115
|
+
const indexKeyValue = indexKey.value;
|
|
9116
|
+
if (indexKeyValue === undefined) {
|
|
9137
9117
|
resolve(undefined);
|
|
9138
9118
|
return;
|
|
9139
9119
|
}
|
|
9140
|
-
const multiCheck = index.multiEntry && Array.isArray(
|
|
9141
|
-
const fetchArgs = buildFetchIndexDataSQL(true, index,
|
|
9120
|
+
const multiCheck = index.multiEntry && Array.isArray(indexKeyValue);
|
|
9121
|
+
const fetchArgs = buildFetchIndexDataSQL(true, index, indexKeyValue, 'key', multiCheck);
|
|
9142
9122
|
executeFetchIndexData(null, ...fetchArgs, tx, null, function success(key) {
|
|
9143
|
-
if (key === undefined || excludeKey !== undefined && cmp(key, excludeKey) === 0) {
|
|
9123
|
+
if (key === undefined || excludeKey !== undefined && cmp(/** @type {import('./Key.js').Key} */key, excludeKey) === 0) {
|
|
9144
9124
|
resolve(undefined);
|
|
9145
9125
|
return;
|
|
9146
9126
|
}
|
|
@@ -9213,21 +9193,21 @@ IDBObjectStore.prototype.__insertData = function (tx, encoded, value, clonedKeyO
|
|
|
9213
9193
|
resolve(undefined);
|
|
9214
9194
|
return;
|
|
9215
9195
|
}
|
|
9216
|
-
|
|
9196
|
+
const indexKeyValue = indexKey.value;
|
|
9217
9197
|
/**
|
|
9218
9198
|
* @param {import('./IDBIndex.js').IDBIndexFull} index
|
|
9219
9199
|
* @returns {void}
|
|
9220
9200
|
*/
|
|
9221
9201
|
function setIndexInfo(index) {
|
|
9222
|
-
if (
|
|
9202
|
+
if (indexKeyValue === undefined) {
|
|
9223
9203
|
return;
|
|
9224
9204
|
}
|
|
9225
9205
|
paramMap[index.__currentName] = /** @type {string} */
|
|
9226
|
-
encode$1(
|
|
9206
|
+
encode$1(indexKeyValue, index.multiEntry);
|
|
9227
9207
|
}
|
|
9228
9208
|
if (index.unique) {
|
|
9229
|
-
const multiCheck = index.multiEntry && Array.isArray(
|
|
9230
|
-
const fetchArgs = buildFetchIndexDataSQL(true, index,
|
|
9209
|
+
const multiCheck = index.multiEntry && Array.isArray(indexKeyValue);
|
|
9210
|
+
const fetchArgs = buildFetchIndexDataSQL(true, index, indexKeyValue, 'key', multiCheck);
|
|
9231
9211
|
executeFetchIndexData(null, ...fetchArgs, tx, null, function success(key) {
|
|
9232
9212
|
if (key === undefined) {
|
|
9233
9213
|
setIndexInfo(index);
|
|
@@ -9386,7 +9366,9 @@ IDBObjectStore.__storingRecordObjectStore = function (request, store, invalidate
|
|
|
9386
9366
|
const key = arguments[5];
|
|
9387
9367
|
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
9388
9368
|
store.transaction.__pushToQueue(request, function (tx, args, success, error) {
|
|
9389
|
-
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;
|
|
9390
9372
|
encode(value, function (encoded) {
|
|
9391
9373
|
/**
|
|
9392
9374
|
* @param {WebSQLTransaction} tx
|
|
@@ -10763,7 +10745,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
10763
10745
|
let sysdbFinishedCb = function (systx, err, cb) {
|
|
10764
10746
|
if (err) {
|
|
10765
10747
|
/**
|
|
10766
|
-
* @param {
|
|
10748
|
+
* @param {unknown} [errorToShow]
|
|
10767
10749
|
* @returns {void}
|
|
10768
10750
|
*/
|
|
10769
10751
|
const manualRevert = function (errorToShow) {
|
|
@@ -10787,7 +10769,9 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
10787
10769
|
cb(sqlErr); // eslint-disable-line promise/no-callback-in-promise -- Convenient
|
|
10788
10770
|
}, function () {
|
|
10789
10771
|
isRevertingSysdb = false;
|
|
10790
|
-
|
|
10772
|
+
// eslint-disable-next-line promise/no-callback-in-promise -- Convenient
|
|
10773
|
+
cb(/** @type {(Error & {code?: number})|undefined} */
|
|
10774
|
+
errorToShow || reportError);
|
|
10791
10775
|
});
|
|
10792
10776
|
};
|
|
10793
10777
|
try {
|
|
@@ -10820,13 +10804,13 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
10820
10804
|
newVersion: version
|
|
10821
10805
|
});
|
|
10822
10806
|
req.__result = connection;
|
|
10823
|
-
connection.__upgradeTransaction = req.__transaction =
|
|
10807
|
+
connection.__upgradeTransaction = req.__transaction = connection.__versionTransaction = IDBTransaction.__createInstance(connection, connection.objectStoreNames, 'versionchange');
|
|
10824
10808
|
req.__done = true;
|
|
10825
10809
|
req.transaction.__addNonRequestToTransactionQueue(
|
|
10826
10810
|
/**
|
|
10827
10811
|
* @param {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} tx
|
|
10828
|
-
* @param {
|
|
10829
|
-
* @param {(result?:
|
|
10812
|
+
* @param {unknown[]} args
|
|
10813
|
+
* @param {(result?: unknown, req?: import('./IDBRequest.js').IDBRequestFull) => void} finished
|
|
10830
10814
|
* @returns {void}
|
|
10831
10815
|
*/
|
|
10832
10816
|
function onupgradeneeded(tx, args, finished /* , error */) {
|
|
@@ -11533,16 +11517,16 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11533
11517
|
|
|
11534
11518
|
/**
|
|
11535
11519
|
* @typedef {IDBCursor & {
|
|
11536
|
-
* primaryKey: import('./Key.js').Key,
|
|
11537
|
-
* key: import('./Key.js').Key,
|
|
11520
|
+
* primaryKey: import('./Key.js').Key|null|undefined,
|
|
11521
|
+
* key: import('./Key.js').Key|null|undefined,
|
|
11538
11522
|
* direction: string,
|
|
11539
11523
|
* source: import('./IDBObjectStore.js').IDBObjectStoreFull|
|
|
11540
11524
|
* import('./IDBIndex.js').IDBIndexFull,
|
|
11541
11525
|
* __request: import('./IDBRequest.js').IDBRequestFull,
|
|
11542
11526
|
* __advanceCount: Integer|undefined,
|
|
11543
11527
|
* __indexSource: boolean,
|
|
11544
|
-
* __key: import('./Key.js').Key,
|
|
11545
|
-
* __primaryKey: import('./Key.js').Key,
|
|
11528
|
+
* __key: import('./Key.js').Key|null|undefined,
|
|
11529
|
+
* __primaryKey: import('./Key.js').Key|null|undefined,
|
|
11546
11530
|
* __value: import('./Key.js').Value,
|
|
11547
11531
|
* __store: import('./IDBObjectStore.js').IDBObjectStoreFull,
|
|
11548
11532
|
* __range: import('./IDBKeyRange.js').IDBKeyRangeFull|undefined,
|
|
@@ -11550,13 +11534,13 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11550
11534
|
* __valueColumnName: string,
|
|
11551
11535
|
* __keyOnly: boolean,
|
|
11552
11536
|
* __valueDecoder: {
|
|
11553
|
-
* decode: (str: string) =>
|
|
11537
|
+
* decode: (str: string) => import('./Key.js').Value,
|
|
11554
11538
|
* },
|
|
11555
11539
|
* __count: boolean,
|
|
11556
11540
|
* __prefetchedIndex: Integer,
|
|
11557
11541
|
* __prefetchedData: null|{
|
|
11558
11542
|
* length: number;
|
|
11559
|
-
* item(index: number):
|
|
11543
|
+
* item(index: number): unknown;
|
|
11560
11544
|
* }|{
|
|
11561
11545
|
* data: RowItemNonNull[],
|
|
11562
11546
|
* length: Integer,
|
|
@@ -11571,7 +11555,14 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11571
11555
|
* __multiEntryExhausted: boolean,
|
|
11572
11556
|
* __invalidateCache: () => void,
|
|
11573
11557
|
* __gotValue: boolean,
|
|
11574
|
-
* __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,
|
|
11575
11566
|
* __findBasic: (
|
|
11576
11567
|
* key: import('./Key.js').Key|undefined,
|
|
11577
11568
|
* primaryKey: import('./Key.js').Key|undefined,
|
|
@@ -11592,17 +11583,17 @@ const cursorDirections = ['next', 'prev', 'nextunique', 'prevunique'];
|
|
|
11592
11583
|
* __decode: (
|
|
11593
11584
|
* rowItem: RowItemNonNull,
|
|
11594
11585
|
* callback: (
|
|
11595
|
-
* key: import('./Key.js').Key,
|
|
11586
|
+
* key: import('./Key.js').Key|undefined,
|
|
11596
11587
|
* val: import('./Key.js').Value,
|
|
11597
|
-
* primaryKey: import('./Key.js').Key,
|
|
11588
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
11598
11589
|
* encKey?: string
|
|
11599
11590
|
* ) => void
|
|
11600
11591
|
* ) => void,
|
|
11601
11592
|
* __sourceOrEffectiveObjStoreDeleted: () => void,
|
|
11602
11593
|
* __continue: (key?: import('./Key.js').Key, advanceContinue?: boolean) => void,
|
|
11603
11594
|
* __continueFinish: (
|
|
11604
|
-
* key: import('./Key.js').Key,
|
|
11605
|
-
* primaryKey: import('./Key.js').Key,
|
|
11595
|
+
* key: import('./Key.js').Key|undefined,
|
|
11596
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
11606
11597
|
* advanceState: boolean
|
|
11607
11598
|
* ) => void
|
|
11608
11599
|
* }} IDBCursorFull
|
|
@@ -11635,7 +11626,7 @@ const IDBCursorAlias = IDBCursor;
|
|
|
11635
11626
|
* import('./IDBIndex.js').IDBIndexFull} source
|
|
11636
11627
|
* @param {string} keyColumnName
|
|
11637
11628
|
* @param {string} valueColumnName
|
|
11638
|
-
* @param {boolean} count
|
|
11629
|
+
* @param {boolean} [count]
|
|
11639
11630
|
* @this {IDBCursorFull}
|
|
11640
11631
|
* @returns {void}
|
|
11641
11632
|
*/
|
|
@@ -11676,7 +11667,7 @@ IDBCursor.__super = function IDBCursor(query, direction, store, source, keyColum
|
|
|
11676
11667
|
this.__valueColumnName = valueColumnName;
|
|
11677
11668
|
this.__keyOnly = valueColumnName === 'key';
|
|
11678
11669
|
this.__valueDecoder = this.__keyOnly ? Key : Sca;
|
|
11679
|
-
this.__count = count;
|
|
11670
|
+
this.__count = Boolean(count);
|
|
11680
11671
|
this.__prefetchedIndex = -1;
|
|
11681
11672
|
this.__continuationKey = undefined;
|
|
11682
11673
|
this.__continuationPrimaryKey = undefined;
|
|
@@ -11695,25 +11686,36 @@ IDBCursor.__super = function IDBCursor(query, direction, store, source, keyColum
|
|
|
11695
11686
|
|
|
11696
11687
|
/**
|
|
11697
11688
|
*
|
|
11698
|
-
* @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]
|
|
11699
11697
|
* @returns {IDBCursorFull}
|
|
11700
11698
|
*/
|
|
11701
|
-
IDBCursor.__createInstance = function (
|
|
11699
|
+
IDBCursor.__createInstance = function (query, direction, store, source, keyColumnName, valueColumnName, count) {
|
|
11702
11700
|
const IDBCursor = IDBCursorAlias.__super;
|
|
11703
11701
|
IDBCursor.prototype = IDBCursorAlias.prototype;
|
|
11704
11702
|
|
|
11705
11703
|
// @ts-expect-error It's ok
|
|
11706
|
-
return new IDBCursor(
|
|
11704
|
+
return new IDBCursor(query, direction, store, source, keyColumnName, valueColumnName, count);
|
|
11707
11705
|
};
|
|
11708
11706
|
|
|
11709
11707
|
/**
|
|
11710
11708
|
*
|
|
11711
|
-
* @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]
|
|
11712
11715
|
* @this {IDBCursorFull}
|
|
11713
11716
|
* @returns {void}
|
|
11714
11717
|
*/
|
|
11715
|
-
IDBCursor.prototype.__find = function (
|
|
11716
|
-
const [key, primaryKey, tx, success, error, recordsToLoad] = args;
|
|
11718
|
+
IDBCursor.prototype.__find = function (key, primaryKey, tx, success, error, recordsToLoad) {
|
|
11717
11719
|
if (this.__multiEntryIndex) {
|
|
11718
11720
|
this.__findMultiEntry(key, primaryKey, tx, success, error, recordsToLoad);
|
|
11719
11721
|
} else {
|
|
@@ -11723,9 +11725,9 @@ IDBCursor.prototype.__find = function (...args /* key, tx, success, error, recor
|
|
|
11723
11725
|
|
|
11724
11726
|
/**
|
|
11725
11727
|
* @typedef {(
|
|
11726
|
-
* k: import('./Key.js').Key,
|
|
11728
|
+
* k: import('./Key.js').Key|undefined,
|
|
11727
11729
|
* val: import('./Key.js').Value,
|
|
11728
|
-
* primKey: import('./Key.js').Key
|
|
11730
|
+
* primKey: import('./Key.js').Key|undefined
|
|
11729
11731
|
* ) => void} KeySuccess
|
|
11730
11732
|
*/
|
|
11731
11733
|
|
|
@@ -11822,7 +11824,7 @@ IDBCursor.prototype.__findBasic = function (key, primaryKey, tx, success, error,
|
|
|
11822
11824
|
me.__prefetchedIndex = 0;
|
|
11823
11825
|
me.__prefetchedData = data.rows;
|
|
11824
11826
|
if (CFG.DEBUG) {
|
|
11825
|
-
console.log('Preloaded ' +
|
|
11827
|
+
console.log('Preloaded ' + data.rows.length + ' records for cursor');
|
|
11826
11828
|
}
|
|
11827
11829
|
me.__decode(/** @type {RowItemNonNull} */data.rows.item(0), success);
|
|
11828
11830
|
} else if (data.rows.length === 1) {
|
|
@@ -11946,7 +11948,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
11946
11948
|
for (let i = 0; i < data.rows.length; i++) {
|
|
11947
11949
|
const rowItem = /** @type {RowItemNonNull} */data.rows.item(i);
|
|
11948
11950
|
const rowKey = decode$1(rowItem[me.__keyColumnName], true);
|
|
11949
|
-
const matches = findMultiEntryMatches(rowKey, me.__range);
|
|
11951
|
+
const matches = findMultiEntryMatches(/** @type {import('./Key.js').Key} */rowKey, me.__range);
|
|
11950
11952
|
ct += matches.length;
|
|
11951
11953
|
}
|
|
11952
11954
|
success(undefined, ct, undefined);
|
|
@@ -11966,7 +11968,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
11966
11968
|
for (let i = 0; i < data.rows.length; i++) {
|
|
11967
11969
|
const rowItem = /** @type {RowItemNonNull} */data.rows.item(i);
|
|
11968
11970
|
const rowKey = decode$1(rowItem[me.__keyColumnName], true);
|
|
11969
|
-
const matches = findMultiEntryMatches(rowKey, me.__range);
|
|
11971
|
+
const matches = findMultiEntryMatches(/** @type {import('./Key.js').Key} */rowKey, me.__range);
|
|
11970
11972
|
for (const matchingKey of matches) {
|
|
11971
11973
|
/**
|
|
11972
11974
|
* @type {RowItemNonNull}
|
|
@@ -12040,11 +12042,11 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
12040
12042
|
};
|
|
12041
12043
|
|
|
12042
12044
|
/**
|
|
12043
|
-
* @typedef {
|
|
12045
|
+
* @typedef {import('./Key.js').Value} StructuredCloneValue
|
|
12044
12046
|
*/
|
|
12045
12047
|
|
|
12046
12048
|
/**
|
|
12047
|
-
* @typedef {
|
|
12049
|
+
* @typedef {import('./Key.js').Key} IndexedDBKey
|
|
12048
12050
|
*/
|
|
12049
12051
|
|
|
12050
12052
|
/**
|
|
@@ -12056,9 +12058,9 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
12056
12058
|
|
|
12057
12059
|
/**
|
|
12058
12060
|
* @callback SuccessCallback
|
|
12059
|
-
* @param {IndexedDBKey} key
|
|
12061
|
+
* @param {IndexedDBKey|undefined} key
|
|
12060
12062
|
* @param {StructuredCloneValue} value
|
|
12061
|
-
* @param {IndexedDBKey} primaryKey
|
|
12063
|
+
* @param {IndexedDBKey|undefined} primaryKey
|
|
12062
12064
|
* @returns {void}
|
|
12063
12065
|
*/
|
|
12064
12066
|
|
|
@@ -12098,9 +12100,9 @@ IDBCursor.prototype.__onsuccess = function (success) {
|
|
|
12098
12100
|
*
|
|
12099
12101
|
* @param {RowItemNonNull} rowItem
|
|
12100
12102
|
* @param {(
|
|
12101
|
-
* key: import('./Key.js').Key,
|
|
12103
|
+
* key: import('./Key.js').Key|undefined,
|
|
12102
12104
|
* val: import('./Key.js').Value,
|
|
12103
|
-
* primaryKey: import('./Key.js').Key,
|
|
12105
|
+
* primaryKey: import('./Key.js').Key|undefined,
|
|
12104
12106
|
* encKey?: string
|
|
12105
12107
|
* ) => void} callback
|
|
12106
12108
|
* @this {IDBCursorFull}
|
|
@@ -12175,8 +12177,8 @@ IDBCursor.prototype.__continue = function (key, advanceContinue) {
|
|
|
12175
12177
|
|
|
12176
12178
|
/**
|
|
12177
12179
|
*
|
|
12178
|
-
* @param {import('./Key.js').Key} key
|
|
12179
|
-
* @param {import('./Key.js').Key} primaryKey
|
|
12180
|
+
* @param {import('./Key.js').Key|undefined} key
|
|
12181
|
+
* @param {import('./Key.js').Key|undefined} primaryKey
|
|
12180
12182
|
* @param {boolean} advanceState
|
|
12181
12183
|
* @this {IDBCursorFull}
|
|
12182
12184
|
* @returns {void}
|
|
@@ -12190,9 +12192,9 @@ IDBCursor.prototype.__continueFinish = function (key, primaryKey, advanceState)
|
|
|
12190
12192
|
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
12191
12193
|
me.__store.transaction.__pushToQueue(me.__request, function cursorContinue(tx, args, success, error, executeNextRequest) {
|
|
12192
12194
|
/**
|
|
12193
|
-
* @param {import('./Key.js').Key} k
|
|
12195
|
+
* @param {import('./Key.js').Key|undefined} k
|
|
12194
12196
|
* @param {import('./Key.js').Value} val
|
|
12195
|
-
* @param {import('./Key.js').Key} primKey
|
|
12197
|
+
* @param {import('./Key.js').Key|undefined} primKey
|
|
12196
12198
|
* @returns {void}
|
|
12197
12199
|
*/
|
|
12198
12200
|
function triggerSuccess(k, val, primKey) {
|
|
@@ -12236,7 +12238,7 @@ IDBCursor.prototype.__continueFinish = function (key, primaryKey, advanceState)
|
|
|
12236
12238
|
// We have pre-loaded data for the cursor
|
|
12237
12239
|
me.__prefetchedIndex++;
|
|
12238
12240
|
if (me.__prefetchedIndex < me.__prefetchedData.length) {
|
|
12239
|
-
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) {
|
|
12240
12242
|
/**
|
|
12241
12243
|
* @returns {void}
|
|
12242
12244
|
*/
|
|
@@ -12371,12 +12373,18 @@ IDBCursor.prototype.advance = function (count) {
|
|
|
12371
12373
|
};
|
|
12372
12374
|
|
|
12373
12375
|
/**
|
|
12374
|
-
*
|
|
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
|
|
12375
12383
|
*/
|
|
12376
12384
|
|
|
12377
12385
|
/**
|
|
12378
12386
|
*
|
|
12379
|
-
* @param {
|
|
12387
|
+
* @param {import('./Key.js').Value} valueToUpdate
|
|
12380
12388
|
* @this {IDBCursorFull}
|
|
12381
12389
|
* @returns {IDBRequest}
|
|
12382
12390
|
*/
|
|
@@ -12499,16 +12507,22 @@ Object.defineProperty(IDBCursorWithValue.prototype, 'constructor', {
|
|
|
12499
12507
|
const IDBCursorWithValueAlias = IDBCursorWithValue;
|
|
12500
12508
|
/**
|
|
12501
12509
|
*
|
|
12502
|
-
* @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]
|
|
12503
12518
|
* @returns {IDBCursorWithValueFull}
|
|
12504
12519
|
*/
|
|
12505
|
-
IDBCursorWithValue.__createInstance = function (
|
|
12520
|
+
IDBCursorWithValue.__createInstance = function (query, direction, store, source, keyColumnName, valueColumnName, count) {
|
|
12506
12521
|
/**
|
|
12507
12522
|
* @class
|
|
12508
12523
|
* @this {IDBCursorWithValueFull}
|
|
12509
12524
|
*/
|
|
12510
12525
|
function IDBCursorWithValue() {
|
|
12511
|
-
const [query, direction, store, source, keyColumnName, valueColumnName, count] = args;
|
|
12512
12526
|
IDBCursor.__super.call(this, query, direction, store, source, keyColumnName, valueColumnName, count);
|
|
12513
12527
|
// @ts-expect-error It's ok
|
|
12514
12528
|
this[Symbol.toStringTag] = 'IDBCursorWithValue';
|
|
@@ -12531,16 +12545,20 @@ Object.defineProperty(IDBCursorWithValue, 'prototype', {
|
|
|
12531
12545
|
/**
|
|
12532
12546
|
* Validates `direction` and fills in defaults for the `{query, count,
|
|
12533
12547
|
* direction}` shape shared by `getAll`/`getAllKeys`/`getAllRecords`.
|
|
12534
|
-
* @param {
|
|
12548
|
+
* @param {unknown} options
|
|
12535
12549
|
* @throws {TypeError}
|
|
12536
|
-
* @returns {{
|
|
12550
|
+
* @returns {{
|
|
12551
|
+
* query: import('./Key.js').Value|undefined,
|
|
12552
|
+
* count: Integer|undefined,
|
|
12553
|
+
* direction: string
|
|
12554
|
+
* }}
|
|
12537
12555
|
*/
|
|
12538
12556
|
function normalizeGetAllOptions(options) {
|
|
12539
12557
|
const {
|
|
12540
12558
|
query,
|
|
12541
12559
|
count,
|
|
12542
12560
|
direction = 'next'
|
|
12543
|
-
} = /** @type {
|
|
12561
|
+
} = /** @type {GetAllOptions} */options ?? {};
|
|
12544
12562
|
if (!cursorDirections.includes(direction)) {
|
|
12545
12563
|
throw new TypeError('`' + direction + '` is not a valid direction');
|
|
12546
12564
|
}
|
|
@@ -12565,7 +12583,11 @@ function normalizeGetAllOptions(options) {
|
|
|
12565
12583
|
* first argument wins regardless of how many arguments were actually passed.
|
|
12566
12584
|
* @param {IArguments} args
|
|
12567
12585
|
* @throws {TypeError}
|
|
12568
|
-
* @returns {{
|
|
12586
|
+
* @returns {{
|
|
12587
|
+
* query: import('./Key.js').Value|undefined,
|
|
12588
|
+
* count: Integer|undefined,
|
|
12589
|
+
* direction: string
|
|
12590
|
+
* }}
|
|
12569
12591
|
*/
|
|
12570
12592
|
function parseGetAllArgs(args) {
|
|
12571
12593
|
const arg0 = args[0];
|
|
@@ -12586,7 +12608,11 @@ function parseGetAllArgs(args) {
|
|
|
12586
12608
|
* form to disambiguate against.
|
|
12587
12609
|
* @param {IArguments} args
|
|
12588
12610
|
* @throws {TypeError}
|
|
12589
|
-
* @returns {{
|
|
12611
|
+
* @returns {{
|
|
12612
|
+
* query: import('./Key.js').Value|undefined,
|
|
12613
|
+
* count: Integer|undefined,
|
|
12614
|
+
* direction: string
|
|
12615
|
+
* }}
|
|
12590
12616
|
*/
|
|
12591
12617
|
function parseGetAllRecordsArgs(args) {
|
|
12592
12618
|
return normalizeGetAllOptions(args[0]);
|
|
@@ -12693,7 +12719,7 @@ function collectAll(source, query, count, direction, mode) {
|
|
|
12693
12719
|
value: direction
|
|
12694
12720
|
});
|
|
12695
12721
|
return tx.__addToTransactionQueue(function collectAllOp(sqlTx, args, success, error) {
|
|
12696
|
-
/** @type {
|
|
12722
|
+
/** @type {unknown[]} */
|
|
12697
12723
|
const results = [];
|
|
12698
12724
|
const recordsToLoad = count || CFG.cursorPreloadPackSize || 100;
|
|
12699
12725
|
|
|
@@ -12733,7 +12759,7 @@ function collectAll(source, query, count, direction, mode) {
|
|
|
12733
12759
|
if (state.__prefetchedData) {
|
|
12734
12760
|
state.__prefetchedIndex++;
|
|
12735
12761
|
if (state.__prefetchedIndex < state.__prefetchedData.length) {
|
|
12736
|
-
IDBCursor.prototype.__decode.call(state, state.__prefetchedData.item(state.__prefetchedIndex),
|
|
12762
|
+
IDBCursor.prototype.__decode.call(state, /** @type {RowItemNonNull} */state.__prefetchedData.item(state.__prefetchedIndex),
|
|
12737
12763
|
/**
|
|
12738
12764
|
* @param {import('./Key.js').Key} k
|
|
12739
12765
|
* @param {import('./Key.js').Value} val
|
|
@@ -12763,15 +12789,11 @@ function collectAll(source, query, count, direction, mode) {
|
|
|
12763
12789
|
}, undefined, source);
|
|
12764
12790
|
}
|
|
12765
12791
|
|
|
12766
|
-
/**
|
|
12767
|
-
* @typedef {any} AnyValue
|
|
12768
|
-
*/
|
|
12769
|
-
|
|
12770
12792
|
/**
|
|
12771
12793
|
* @callback SetConfig
|
|
12772
12794
|
* @param {import('./CFG.js').KeyofConfigValues|
|
|
12773
12795
|
* Partial<import('./CFG.js').ConfigValues>} prop
|
|
12774
|
-
* @param {
|
|
12796
|
+
* @param {import('./CFG.js').ConfigValue} [val]
|
|
12775
12797
|
* @throws {Error}
|
|
12776
12798
|
* @returns {void}
|
|
12777
12799
|
*/
|
|
@@ -12856,18 +12878,9 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12856
12878
|
}
|
|
12857
12879
|
const IDB = /** @type {ShimmedObject & {[key: string]: unknown}} */
|
|
12858
12880
|
/** @type {unknown} */idb || globalThis || {};
|
|
12859
|
-
/**
|
|
12860
|
-
* @typedef {any} AnyClass
|
|
12861
|
-
*/
|
|
12862
|
-
/**
|
|
12863
|
-
* @typedef {any} AnyValue
|
|
12864
|
-
*/
|
|
12865
|
-
/**
|
|
12866
|
-
* @typedef {Function} AnyFunction
|
|
12867
|
-
*/
|
|
12868
12881
|
/**
|
|
12869
12882
|
* @param {string} name
|
|
12870
|
-
* @param {
|
|
12883
|
+
* @param {unknown} value
|
|
12871
12884
|
* @param {PropertyDescriptor & {
|
|
12872
12885
|
* shimNS?: object
|
|
12873
12886
|
* }|undefined} [propDesc]
|
|
@@ -12896,10 +12909,10 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12896
12909
|
} else {
|
|
12897
12910
|
const o = {
|
|
12898
12911
|
/**
|
|
12899
|
-
* @returns {
|
|
12912
|
+
* @returns {unknown}
|
|
12900
12913
|
*/
|
|
12901
12914
|
get [name]() {
|
|
12902
|
-
return /** @type {
|
|
12915
|
+
return /** @type {() => unknown} */(/** @type {PropertyDescriptor} */propDesc.get).call(this);
|
|
12903
12916
|
}
|
|
12904
12917
|
};
|
|
12905
12918
|
desc = /** @type {PropertyDescriptor} */
|
|
@@ -12973,7 +12986,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12973
12986
|
return shimIndexedDB;
|
|
12974
12987
|
}
|
|
12975
12988
|
});
|
|
12976
|
-
/** @type {[string,
|
|
12989
|
+
/** @type {[string, unknown][]} */
|
|
12977
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]) => {
|
|
12978
12991
|
shim(prop, obj, {
|
|
12979
12992
|
enumerable: false,
|
|
@@ -13060,7 +13073,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
13060
13073
|
IDB.shimIndexedDB = /** @type {ShimIndexedDB} */{};
|
|
13061
13074
|
/** @type {const} */
|
|
13062
13075
|
['__useShim', '__debug', '__setConfig', '__getConfig', '__setUnicodeIdentifiers'].forEach(prop => {
|
|
13063
|
-
/** @type {
|
|
13076
|
+
/** @type {{[key: string]: () => void}} */(/** @type {unknown} */IDB.shimIndexedDB)[prop] = function () {
|
|
13064
13077
|
console.warn('This browser does not have WebSQL to shim.');
|
|
13065
13078
|
};
|
|
13066
13079
|
});
|
|
@@ -13111,7 +13124,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
13111
13124
|
|
|
13112
13125
|
/**
|
|
13113
13126
|
* @typedef {{
|
|
13114
|
-
* _db:
|
|
13127
|
+
* _db: unknown,
|
|
13115
13128
|
* exec: typeof SQLiteDatabase['prototype']['exec']
|
|
13116
13129
|
* }} SQLiteDatabaseInstance
|
|
13117
13130
|
*/
|
|
@@ -13125,7 +13138,10 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
13125
13138
|
* object yields that object as the `new` expression's result, overriding
|
|
13126
13139
|
* the default "return `this`" behavior), not something TypeScript can
|
|
13127
13140
|
* verify structurally.
|
|
13128
|
-
* @typedef {new (
|
|
13141
|
+
* @typedef {new (
|
|
13142
|
+
* name: string,
|
|
13143
|
+
* opts?: import('websql-configurable/lib/sqlite/SQLiteDatabase.js').SQLiteDatabaseOptions
|
|
13144
|
+
* ) => SQLiteDatabaseInstance} SQLiteDatabaseConstructor
|
|
13129
13145
|
*/
|
|
13130
13146
|
|
|
13131
13147
|
/**
|