indexeddbshim 17.3.4 → 17.4.1
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 -146
- package/dist/CFG.d.ts +1 -0
- package/dist/CFG.d.ts.map +1 -1
- package/dist/DOMException.d.ts +4 -4
- package/dist/DOMException.d.ts.map +1 -1
- package/dist/IDBFactory.d.ts +4 -4
- package/dist/IDBFactory.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +3 -2
- 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 +52 -38
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +35 -35
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -2
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +52 -38
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +35 -35
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +2 -2
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +35 -35
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/node-UnicodeIdentifiers.d.ts +3 -3
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/node.d.ts +3 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/nodeSQLiteDatabase.d.ts.map +1 -1
- package/dist/nodeWebSQL.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/CFG.js +2 -0
- package/src/DOMException.js +21 -21
- package/src/IDBFactory.js +2 -2
- package/src/IDBObjectStore.js +1 -1
- package/src/node-UnicodeIdentifiers.js +2 -2
- package/src/node.js +2 -2
- package/src/nodeSQLiteDatabase.js +10 -1
- package/src/nodeWebSQL.js +3 -0
- package/src/setGlobalVars.js +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! indexeddbshim - v17.
|
|
1
|
+
/*! indexeddbshim - v17.4.1 - 8/29/2026 */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1389,6 +1389,7 @@ EventTarget.EventTargetFactory = EventTargetFactory;
|
|
|
1389
1389
|
* sqlBusyTimeout: number,
|
|
1390
1390
|
* sqlTrace: () => void,
|
|
1391
1391
|
* sqlProfile: () => void,
|
|
1392
|
+
* sqlMemoryQuota: number,
|
|
1392
1393
|
* escapeNULForSQLiteStatements: boolean,
|
|
1393
1394
|
* createIndexes: boolean
|
|
1394
1395
|
* }} ConfigValues
|
|
@@ -1545,7 +1546,7 @@ val => {
|
|
|
1545
1546
|
'sqlProfile',
|
|
1546
1547
|
// Callback not used by default
|
|
1547
1548
|
// Defaults to true except in Node builds where we can preserve literal NUL with better-sqlite3
|
|
1548
|
-
'escapeNULForSQLiteStatements', 'createIndexes'].forEach(prop => {
|
|
1549
|
+
'escapeNULForSQLiteStatements', 'sqlMemoryQuota', 'createIndexes'].forEach(prop => {
|
|
1549
1550
|
/** @type {(val: any) => void} */
|
|
1550
1551
|
let validator;
|
|
1551
1552
|
if (Array.isArray(prop)) {
|
|
@@ -2564,41 +2565,40 @@ function findError(args) {
|
|
|
2564
2565
|
* optional here and, in practice, always `undefined` today (the `case 4`/
|
|
2565
2566
|
* `case 7` branches below are effectively unreachable pending upstream
|
|
2566
2567
|
* support for surfacing a real error code).
|
|
2567
|
-
* @param {Error & {code?: number}} webSQLErr
|
|
2568
|
+
* @param {Error & {code?: number|string}} webSQLErr
|
|
2568
2569
|
* @returns {(DOMException|Error) & {
|
|
2569
|
-
* sqlError: Error & {code?: number}
|
|
2570
|
+
* sqlError: Error & {code?: number|string}
|
|
2570
2571
|
* }|QuotaExceededError}
|
|
2571
2572
|
*/
|
|
2572
2573
|
function webSQLErrback(webSQLErr) {
|
|
2573
2574
|
let name,
|
|
2574
2575
|
message,
|
|
2575
2576
|
useQuotaExceededError = false;
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
if (typeof QuotaExceededError !== 'undefined') {
|
|
2583
|
-
useQuotaExceededError = true;
|
|
2584
|
-
}
|
|
2585
|
-
break;
|
|
2586
|
-
}
|
|
2587
|
-
/*
|
|
2588
|
-
// Should a WebSQL timeout treat as IndexedDB `TransactionInactiveError` or `UnknownError`?
|
|
2589
|
-
case 7: { // SQLError.TIMEOUT_ERR
|
|
2590
|
-
// All transaction errors abort later, so no need to mark inactive
|
|
2591
|
-
name = 'TransactionInactiveError';
|
|
2592
|
-
message = 'A request was placed against a transaction which is currently not active, or which is finished (Internal SQL Timeout).';
|
|
2593
|
-
break;
|
|
2577
|
+
if (webSQLErr.code === 4 || webSQLErr.code === 'SQLITE_FULL') {
|
|
2578
|
+
// SQLError.QUOTA_ERR or better-sqlite3 SQLITE_FULL
|
|
2579
|
+
name = 'QuotaExceededError';
|
|
2580
|
+
message = 'The operation failed because there was not enough ' + 'remaining storage space, or the storage quota was reached ' + 'and the user declined to give more space to the database.';
|
|
2581
|
+
if (typeof QuotaExceededError !== 'undefined') {
|
|
2582
|
+
useQuotaExceededError = true;
|
|
2594
2583
|
}
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2584
|
+
} else {
|
|
2585
|
+
switch (webSQLErr.code) {
|
|
2586
|
+
/*
|
|
2587
|
+
// Should a WebSQL timeout treat as IndexedDB `TransactionInactiveError` or `UnknownError`?
|
|
2588
|
+
case 7: { // SQLError.TIMEOUT_ERR
|
|
2589
|
+
// All transaction errors abort later, so no need to mark inactive
|
|
2590
|
+
name = 'TransactionInactiveError';
|
|
2591
|
+
message = 'A request was placed against a transaction which is currently not active, or which is finished (Internal SQL Timeout).';
|
|
2592
|
+
break;
|
|
2601
2593
|
}
|
|
2594
|
+
*/
|
|
2595
|
+
default:
|
|
2596
|
+
{
|
|
2597
|
+
name = 'UnknownError';
|
|
2598
|
+
message = 'The operation failed for reasons unrelated to the database itself and not covered by any other errors.';
|
|
2599
|
+
break;
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
2602
|
}
|
|
2603
2603
|
message += ' (' + webSQLErr.message + ')--(' + webSQLErr.code + ')';
|
|
2604
2604
|
if (useQuotaExceededError) {
|
|
@@ -2607,7 +2607,7 @@ function webSQLErrback(webSQLErr) {
|
|
|
2607
2607
|
const err =
|
|
2608
2608
|
/**
|
|
2609
2609
|
* @type {(Error | DOMException) & {
|
|
2610
|
-
* sqlError: Error & {code?: number}
|
|
2610
|
+
* sqlError: Error & {code?: number|string}
|
|
2611
2611
|
* }}
|
|
2612
2612
|
*/
|
|
2613
2613
|
createDOMException(name, message);
|
|
@@ -8762,7 +8762,7 @@ IDBObjectStore.__createObjectStore = function (db, store) {
|
|
|
8762
8762
|
tx.executeSql('INSERT INTO __sys__ VALUES (?,?,?,?,?)', [escapeSQLiteStatement(storeName), encodedKeyPath,
|
|
8763
8763
|
// For why converting here, see comment and following
|
|
8764
8764
|
// discussion at:
|
|
8765
|
-
// https://github.com/
|
|
8765
|
+
// https://github.com/indexeddbshim/IndexedDBShim/issues/313#issuecomment-590086778
|
|
8766
8766
|
Number(store.autoIncrement), '{}', 1], function () {
|
|
8767
8767
|
delete store.__pendingCreate;
|
|
8768
8768
|
delete store.__deleted;
|
|
@@ -11150,8 +11150,8 @@ IDBFactory.prototype.cmp = function (key1, key2) {
|
|
|
11150
11150
|
* @see https://github.com/w3c/IndexedDB/pull/240/files
|
|
11151
11151
|
* @this {IDBFactoryFull}
|
|
11152
11152
|
* @returns {Promise<{
|
|
11153
|
-
* name
|
|
11154
|
-
* version
|
|
11153
|
+
* name?: string,
|
|
11154
|
+
* version?: Integer
|
|
11155
11155
|
* }[]>}
|
|
11156
11156
|
*/
|
|
11157
11157
|
IDBFactory.prototype.databases = function () {
|
|
@@ -12945,7 +12945,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12945
12945
|
// Ignore Node or other environments
|
|
12946
12946
|
// Bad non-Chrome Android support
|
|
12947
12947
|
/Android (?:2|3|4\.[0-3])/u.test(navigator.userAgent) && !navigator.userAgent.includes('Chrome') ||
|
|
12948
|
-
// Bad non-Safari iOS9 support (see <https://github.com/
|
|
12948
|
+
// Bad non-Safari iOS9 support (see <https://github.com/indexeddbshim/IndexedDBShim/issues/252>)
|
|
12949
12949
|
(!navigator.userAgent.includes('Safari') || navigator.userAgent.includes('Chrome')) &&
|
|
12950
12950
|
// Exclude genuine Safari: https://stackoverflow.com/a/7768006/271577
|
|
12951
12951
|
// Detect iOS: https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885
|
|
@@ -12955,8 +12955,8 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
12955
12955
|
if (!CFG.DEFAULT_DB_SIZE) {
|
|
12956
12956
|
CFG.DEFAULT_DB_SIZE = (
|
|
12957
12957
|
// Safari currently requires larger size: (We don't need a larger size for Node as node-websql doesn't use this info)
|
|
12958
|
-
// https://github.com/
|
|
12959
|
-
// https://github.com/
|
|
12958
|
+
// https://github.com/indexeddbshim/IndexedDBShim/issues/41
|
|
12959
|
+
// https://github.com/indexeddbshim/IndexedDBShim/issues/115
|
|
12960
12960
|
typeof navigator !== 'undefined' &&
|
|
12961
12961
|
// React Native
|
|
12962
12962
|
navigator.userAgent && navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') ? 25 : 4) * 1024 * 1024;
|
|
@@ -14742,7 +14742,7 @@ function SQLiteDatabase(name, opts = {}) {
|
|
|
14742
14742
|
_db: db,
|
|
14743
14743
|
/**
|
|
14744
14744
|
* Compatibility with node-sqlite3's configure API.
|
|
14745
|
-
* @param {'busyTimeout'|'trace'|'profile'} option
|
|
14745
|
+
* @param {'busyTimeout'|'trace'|'profile'|'memoryQuota'} option
|
|
14746
14746
|
* @param {number|((sql: string, duration?: number) => void)} value
|
|
14747
14747
|
* @returns {void}
|
|
14748
14748
|
*/
|
|
@@ -14757,6 +14757,17 @@ function SQLiteDatabase(name, opts = {}) {
|
|
|
14757
14757
|
}
|
|
14758
14758
|
if (option === 'profile') {
|
|
14759
14759
|
profile = /** @type {SQLProfileCallback} */value;
|
|
14760
|
+
return;
|
|
14761
|
+
}
|
|
14762
|
+
if (option === 'memoryQuota') {
|
|
14763
|
+
const bytes = Number(value);
|
|
14764
|
+
// `better-sqlite3` doesn't have a direct `sqlite3_quota_set` binding,
|
|
14765
|
+
// but we can limit the max pages:
|
|
14766
|
+
const pageSizeObj = db.pragma('page_size', {
|
|
14767
|
+
simple: true
|
|
14768
|
+
});
|
|
14769
|
+
const pageSize = Number(pageSizeObj);
|
|
14770
|
+
db.pragma('max_page_count = ' + Math.ceil(bytes / pageSize));
|
|
14760
14771
|
}
|
|
14761
14772
|
},
|
|
14762
14773
|
/**
|
|
@@ -14991,6 +15002,9 @@ function wrappedSQLiteDatabase(name) {
|
|
|
14991
15002
|
if (CFG.sqlProfile) {
|
|
14992
15003
|
db._db.configure('profile', CFG.sqlProfile);
|
|
14993
15004
|
}
|
|
15005
|
+
if (CFG.sqlMemoryQuota) {
|
|
15006
|
+
db._db.configure('memoryQuota', /** @type {number} */CFG.sqlMemoryQuota);
|
|
15007
|
+
}
|
|
14994
15008
|
return db;
|
|
14995
15009
|
}
|
|
14996
15010
|
|
|
@@ -15024,8 +15038,8 @@ CFG.win = {
|
|
|
15024
15038
|
};
|
|
15025
15039
|
|
|
15026
15040
|
/**
|
|
15027
|
-
* @param {import('./setGlobalVars.js').ShimmedObject} idb
|
|
15028
|
-
* @param {Partial<import('./CFG.js').ConfigValues>} initialConfig
|
|
15041
|
+
* @param {import('./setGlobalVars.js').ShimmedObject} [idb]
|
|
15042
|
+
* @param {Partial<import('./CFG.js').ConfigValues>} [initialConfig]
|
|
15029
15043
|
* @returns {import('./setGlobalVars.js').ShimmedObject|Window}
|
|
15030
15044
|
*/
|
|
15031
15045
|
const __setGlobalVars = function (idb, initialConfig = {}) {
|