indexeddbshim 16.1.0 → 17.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 +3 -3
- package/badges/licenses-badge-dev.svg +1 -1
- package/badges/licenses-badge.svg +1 -1
- package/dist/CFG.d.ts.map +1 -1
- package/dist/DOMException.d.ts.map +1 -1
- package/dist/DOMStringList.d.ts.map +1 -1
- package/dist/IDBCursor.d.ts +3 -1
- package/dist/IDBCursor.d.ts.map +1 -1
- package/dist/IDBDatabase.d.ts +2 -1
- package/dist/IDBDatabase.d.ts.map +1 -1
- package/dist/IDBFactory.d.ts +2 -1
- package/dist/IDBFactory.d.ts.map +1 -1
- package/dist/IDBIndex.d.ts +2 -1
- package/dist/IDBIndex.d.ts.map +1 -1
- package/dist/IDBKeyRange.d.ts +1 -1
- package/dist/IDBKeyRange.d.ts.map +1 -1
- package/dist/IDBObjectStore.d.ts +2 -1
- package/dist/IDBObjectStore.d.ts.map +1 -1
- package/dist/IDBRequest.d.ts +5 -3
- package/dist/IDBRequest.d.ts.map +1 -1
- package/dist/IDBTransaction.d.ts +2 -1
- package/dist/IDBTransaction.d.ts.map +1 -1
- package/dist/Key.d.ts.map +1 -1
- package/dist/Sca.d.ts.map +1 -1
- package/dist/UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/browser-noninvasive.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +1844 -1669
- 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 +972 -1076
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +2704 -2034
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +9 -2
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +972 -1076
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +2703 -2033
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +9 -2
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +2676 -2014
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +9 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/node-UnicodeIdentifiers.d.ts +2 -2
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/package.json +111 -103
- package/src/CFG.js +2 -3
- package/src/DOMException.js +11 -9
- package/src/DOMStringList.js +8 -3
- package/src/Event.js +2 -0
- package/src/IDBCursor.js +16 -9
- package/src/IDBDatabase.js +9 -6
- package/src/IDBFactory.js +21 -14
- package/src/IDBIndex.js +82 -77
- package/src/IDBKeyRange.js +42 -35
- package/src/IDBObjectStore.js +83 -77
- package/src/IDBRequest.js +28 -15
- package/src/IDBTransaction.js +8 -4
- package/src/IDBVersionChangeEvent.js +2 -0
- package/src/Key.js +18 -12
- package/src/Sca.js +2 -1
- package/src/UnicodeIdentifiers.js +2 -2
- package/src/browser-UnicodeIdentifiers.js +0 -1
- package/src/browser-noninvasive.js +0 -1
- package/src/browser.js +0 -1
- package/src/node-UnicodeIdentifiers.js +1 -1
- package/src/node.js +1 -1
- package/src/setGlobalVars.js +13 -13
- package/src/util.js +13 -12
package/src/node.js
CHANGED
|
@@ -9,7 +9,7 @@ CFG.win = {openDatabase: nodeWebSQL};
|
|
|
9
9
|
/**
|
|
10
10
|
* @param {import('./setGlobalVars.js').ShimmedObject} idb
|
|
11
11
|
* @param {import('./CFG.js').default} initialConfig
|
|
12
|
-
* @returns {
|
|
12
|
+
* @returns {import('./setGlobalVars.js').ShimmedObject|Window}
|
|
13
13
|
*/
|
|
14
14
|
const __setGlobalVars = function (idb, initialConfig = {}) {
|
|
15
15
|
return setGlobalVars(idb, {fs, ...initialConfig});
|
package/src/setGlobalVars.js
CHANGED
|
@@ -40,7 +40,7 @@ function setConfig (prop, val) {
|
|
|
40
40
|
});
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
if (!(prop
|
|
43
|
+
if (!Object.hasOwn(CFG, prop)) {
|
|
44
44
|
throw new Error(prop + ' is not a valid configuration property');
|
|
45
45
|
}
|
|
46
46
|
// @ts-expect-error Should not be `never` here!
|
|
@@ -264,7 +264,7 @@ function setGlobalVars (idb, initialConfig) {
|
|
|
264
264
|
setFS(CFG.fs);
|
|
265
265
|
}
|
|
266
266
|
if (CFG.fullIDLSupport) {
|
|
267
|
-
// Slow per MDN so off by default! Though apparently needed for WebIDL:
|
|
267
|
+
// Slow per MDN so off by default! Though apparently needed for WebIDL: https://stackoverflow.com/questions/41927589/rationales-consequences-of-webidl-class-inheritance-requirements
|
|
268
268
|
|
|
269
269
|
Object.setPrototypeOf(IDB.IDBOpenDBRequest, IDB.IDBRequest);
|
|
270
270
|
Object.setPrototypeOf(IDB.IDBCursorWithValue, IDB.IDBCursor);
|
|
@@ -303,7 +303,7 @@ function setGlobalVars (idb, initialConfig) {
|
|
|
303
303
|
|
|
304
304
|
/** @type {GetConfig} */
|
|
305
305
|
IDB.shimIndexedDB.__getConfig = function (prop) {
|
|
306
|
-
if (!(prop
|
|
306
|
+
if (!Object.hasOwn(CFG, prop)) {
|
|
307
307
|
throw new Error(prop + ' is not a valid configuration property');
|
|
308
308
|
}
|
|
309
309
|
return CFG[prop];
|
|
@@ -332,16 +332,16 @@ function setGlobalVars (idb, initialConfig) {
|
|
|
332
332
|
|
|
333
333
|
// Workaround to prevent an error in Firefox
|
|
334
334
|
if (!('indexedDB' in IDB) && typeof window !== 'undefined') { // 2nd condition avoids problems in Node
|
|
335
|
-
IDB.indexedDB
|
|
335
|
+
IDB.indexedDB ||= /** @type {IDBFactory} */ (
|
|
336
336
|
('webkitIndexedDB' in IDB && IDB.webkitIndexedDB) ||
|
|
337
337
|
('mozIndexedDB' in IDB && IDB.mozIndexedDB) ||
|
|
338
338
|
('oIndexedDB' in IDB && IDB.oIndexedDB) ||
|
|
339
|
-
('msIndexedDB' in IDB && IDB.msIndexedDB)
|
|
339
|
+
('msIndexedDB' in IDB && IDB.msIndexedDB)
|
|
340
|
+
);
|
|
340
341
|
}
|
|
341
342
|
|
|
342
343
|
// Detect browsers with known IndexedDB issues (e.g. Android pre-4.4)
|
|
343
|
-
|
|
344
|
-
if (
|
|
344
|
+
const poorIndexedDbSupport = (
|
|
345
345
|
typeof navigator !== 'undefined' &&
|
|
346
346
|
// Not apparently defined in React Native
|
|
347
347
|
navigator.userAgent &&
|
|
@@ -353,17 +353,15 @@ function setGlobalVars (idb, initialConfig) {
|
|
|
353
353
|
) ||
|
|
354
354
|
(
|
|
355
355
|
// Bad non-Safari iOS9 support (see <https://github.com/axemclion/IndexedDBShim/issues/252>)
|
|
356
|
-
(!navigator.userAgent.includes('Safari') || navigator.userAgent.includes('Chrome')) && // Exclude genuine Safari:
|
|
357
|
-
// Detect iOS:
|
|
358
|
-
// and detect version 9:
|
|
356
|
+
(!navigator.userAgent.includes('Safari') || navigator.userAgent.includes('Chrome')) && // Exclude genuine Safari: https://stackoverflow.com/a/7768006/271577
|
|
357
|
+
// Detect iOS: https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885
|
|
358
|
+
// and detect version 9: https://stackoverflow.com/a/26363560/271577
|
|
359
359
|
(/(iPad|iPhone|iPod).* os 9_/ui).test(navigator.userAgent) &&
|
|
360
360
|
(typeof window !== 'undefined' &&
|
|
361
361
|
!('MSStream' in window)) // But avoid IE11
|
|
362
362
|
)
|
|
363
363
|
)
|
|
364
|
-
)
|
|
365
|
-
poorIndexedDbSupport = true;
|
|
366
|
-
}
|
|
364
|
+
);
|
|
367
365
|
if (!CFG.DEFAULT_DB_SIZE) {
|
|
368
366
|
CFG.DEFAULT_DB_SIZE = (
|
|
369
367
|
( // Safari currently requires larger size: (We don't need a larger size for Node as node-websql doesn't use this info)
|
|
@@ -385,6 +383,7 @@ function setGlobalVars (idb, initialConfig) {
|
|
|
385
383
|
) {
|
|
386
384
|
IDB.shimIndexedDB.__useShim();
|
|
387
385
|
} else {
|
|
386
|
+
/* eslint-disable unicorn/logical-assignment-operators -- TS */
|
|
388
387
|
IDB.IDBDatabase = IDB.IDBDatabase ||
|
|
389
388
|
('webkitIDBDatabase' in IDB && IDB.webkitIDBDatabase);
|
|
390
389
|
IDB.IDBTransaction = IDB.IDBTransaction ||
|
|
@@ -393,6 +392,7 @@ function setGlobalVars (idb, initialConfig) {
|
|
|
393
392
|
('webkitIDBCursor' in IDB && IDB.webkitIDBCursor);
|
|
394
393
|
IDB.IDBKeyRange = IDB.IDBKeyRange ||
|
|
395
394
|
('webkitIDBKeyRange' in IDB && IDB.webkitIDBKeyRange);
|
|
395
|
+
/* eslint-enable unicorn/logical-assignment-operators -- TS */
|
|
396
396
|
}
|
|
397
397
|
return /** @type {ShimmedObject} */ (IDB);
|
|
398
398
|
}
|
package/src/util.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable new-cap -- ToString is how it is defined */
|
|
2
|
-
/* eslint-disable sonarjs/no-control-regex -- Needed */
|
|
3
2
|
import CFG from './CFG.js';
|
|
4
3
|
import expandsOnNFD from './unicode-regex.js';
|
|
5
4
|
|
|
@@ -12,11 +11,11 @@ import expandsOnNFD from './unicode-regex.js';
|
|
|
12
11
|
* @returns {string}
|
|
13
12
|
*/
|
|
14
13
|
function escapeUnmatchedSurrogates (arg) {
|
|
15
|
-
//
|
|
14
|
+
// https://stackoverflow.com/a/6701665/271577
|
|
16
15
|
return arg.replaceAll(
|
|
17
16
|
/([\uD800-\uDBFF])(?![\uDC00-\uDFFF])|(^|[^\uD800-\uDBFF])([\uDC00-\uDFFF])/gu,
|
|
18
17
|
function (_, unmatchedHighSurrogate, precedingLow, unmatchedLowSurrogate) {
|
|
19
|
-
// Could add a corresponding surrogate for compatibility with `node-sqlite3`:
|
|
18
|
+
// Could add a corresponding surrogate for compatibility with `node-sqlite3`: https://bugs.python.org/issue12569 and https://stackoverflow.com/a/6701665/271577
|
|
20
19
|
// but Chrome having problems
|
|
21
20
|
if (unmatchedHighSurrogate) {
|
|
22
21
|
return '^2' + unmatchedHighSurrogate.codePointAt()
|
|
@@ -33,14 +32,14 @@ function escapeUnmatchedSurrogates (arg) {
|
|
|
33
32
|
* @returns {string}
|
|
34
33
|
*/
|
|
35
34
|
function escapeNameForSQLiteIdentifier (arg) {
|
|
36
|
-
//
|
|
35
|
+
// https://stackoverflow.com/a/6701665/271577
|
|
37
36
|
return '_' + // Prevent empty string
|
|
38
37
|
escapeUnmatchedSurrogates(
|
|
39
38
|
arg.replaceAll('^', '^^') // Escape our escape
|
|
40
|
-
//
|
|
39
|
+
// https://www.sqlite.org/src/tktview?name=57c971fc74
|
|
41
40
|
.replaceAll('\0', '^0')
|
|
42
41
|
// We need to avoid identifiers being treated as duplicates based on SQLite's ASCII-only case-insensitive table and column names
|
|
43
|
-
// (For SQL in general, however, see
|
|
42
|
+
// (For SQL in general, however, see https://stackoverflow.com/a/17215009/271577
|
|
44
43
|
// See also https://www.sqlite.org/faq.html#q18 re: Unicode (non-ASCII) case-insensitive not working
|
|
45
44
|
.replaceAll(/([A-Z])/gu, '^$1')
|
|
46
45
|
);
|
|
@@ -75,7 +74,7 @@ function unescapeSQLiteResponse (arg) {
|
|
|
75
74
|
*/
|
|
76
75
|
function sqlEscape (arg) {
|
|
77
76
|
// https://www.sqlite.org/lang_keywords.html
|
|
78
|
-
//
|
|
77
|
+
// https://stackoverflow.com/a/6701665/271577
|
|
79
78
|
// There is no need to escape ', `, or [], as
|
|
80
79
|
// we should always be within double quotes
|
|
81
80
|
// NUL should have already been stripped
|
|
@@ -114,7 +113,7 @@ function escapeDatabaseNameForSQLAndFiles (db) {
|
|
|
114
113
|
db = db.replace(
|
|
115
114
|
(CFG.databaseCharacterEscapeList
|
|
116
115
|
? new RegExp(CFG.databaseCharacterEscapeList, 'gu')
|
|
117
|
-
: /[\
|
|
116
|
+
: /[\u{0000}-\u{001F}\u{007F}"*/:<>?\\|]/gu), // eslint-disable-line no-control-regex -- Controls needed
|
|
118
117
|
function (n0) {
|
|
119
118
|
// eslint-disable-next-line unicorn/prefer-code-point -- Switch to `codePointAt`?
|
|
120
119
|
return '^1' + n0.charCodeAt(0).toString(16).padStart(2, '0');
|
|
@@ -302,7 +301,9 @@ function isBinary (obj) {
|
|
|
302
301
|
* @returns {boolean}
|
|
303
302
|
*/
|
|
304
303
|
function isIterable (obj) {
|
|
305
|
-
return isObj(obj) &&
|
|
304
|
+
return isObj(obj) &&
|
|
305
|
+
// eslint-disable-next-line unicorn/no-computed-property-existence-check -- May not be "own"
|
|
306
|
+
Symbol.iterator in obj &&
|
|
306
307
|
typeof obj[Symbol.iterator] === 'function';
|
|
307
308
|
}
|
|
308
309
|
|
|
@@ -398,7 +399,7 @@ function defineReadonlyProperties (obj, props, getter = null) {
|
|
|
398
399
|
props = typeof props === 'string' ? [props] : props;
|
|
399
400
|
props.forEach(function (prop) {
|
|
400
401
|
let o;
|
|
401
|
-
if (getter && prop
|
|
402
|
+
if (getter && Object.hasOwn(getter, prop)) {
|
|
402
403
|
o = getter[prop];
|
|
403
404
|
} else {
|
|
404
405
|
Object.defineProperty(obj, '__' + prop, {
|
|
@@ -438,7 +439,7 @@ function isIdentifier (item) {
|
|
|
438
439
|
// ID_Continue (includes Other_ID_Continue)
|
|
439
440
|
const UnicodeIDContinue = CFG.UnicodeIDContinue || '[$0-9A-Z_a-z]';
|
|
440
441
|
const IdentifierStart = '(?:' + UnicodeIDStart + '|[$_])';
|
|
441
|
-
const IdentifierPart = '(?:' + UnicodeIDContinue + '|[$_\
|
|
442
|
+
const IdentifierPart = '(?:' + UnicodeIDContinue + '|[$_\u{200C}\u{200D}])';
|
|
442
443
|
return (new RegExp('^' + IdentifierStart + IdentifierPart + '*$', 'u')).test(item);
|
|
443
444
|
}
|
|
444
445
|
|
|
@@ -462,7 +463,7 @@ function isValidKeyPathString (keyPathString) {
|
|
|
462
463
|
function isValidKeyPath (keyPath) {
|
|
463
464
|
return isValidKeyPathString(keyPath) || (
|
|
464
465
|
Array.isArray(keyPath) && Boolean(keyPath.length) &&
|
|
465
|
-
// Convert array from sparse to dense
|
|
466
|
+
// Convert array from sparse to dense https://www.2ality.com/2012/06/dense-arrays.html
|
|
466
467
|
// See also https://heycam.github.io/webidl/#idl-DOMString
|
|
467
468
|
[...keyPath].every((pathComponent) => {
|
|
468
469
|
return isValidKeyPathString(pathComponent);
|