indexeddbshim 13.0.0-pre.1 → 13.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 +1 -1
- package/badges/licenses-badge-dev.svg +1 -1
- package/dist/indexeddbshim-Key.js +90 -82
- 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 +824 -487
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +947 -774
- 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 +824 -487
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +947 -774
- 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 +947 -774
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/index.html +1 -1
- package/package.json +35 -34
- package/src/DOMException.js +3 -4
- package/src/DOMStringList.js +1 -1
- package/src/IDBCursor.js +19 -17
- package/src/IDBDatabase.js +1 -0
- package/src/IDBFactory.js +23 -16
- package/src/IDBIndex.js +17 -23
- package/src/IDBKeyRange.js +4 -4
- package/src/IDBObjectStore.js +29 -26
- package/src/IDBTransaction.js +7 -8
- package/src/Key.d.ts +1 -0
- package/src/Key.js +11 -12
- package/src/setGlobalVars.js +3 -1
- package/src/util.js +1 -0
package/index.html
CHANGED
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
ga.src = (document.location.protocol === 'https:' ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
115
115
|
const s = document.querySelector('script');
|
|
116
116
|
s.parentNode.insertBefore(ga, s);
|
|
117
|
-
}
|
|
117
|
+
}());
|
|
118
118
|
}
|
|
119
119
|
</script>
|
|
120
120
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "indexeddbshim",
|
|
3
|
-
"version": "13.0.0
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Parashuram <code@nparashuram.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"tsc": "tsc",
|
|
33
33
|
"tsc-prod": "tsc -p tsconfig-prod.json",
|
|
34
34
|
"build": "npm run rollup && npm run tsc-prod",
|
|
35
|
-
"prepublishOnly": "
|
|
35
|
+
"prepublishOnly": "npm run license-badges",
|
|
36
36
|
"license-badge": "license-badger --corrections --uncategorizedLicenseTemplate \"\\${license} (\\${name} (\\${version}))\" --filteredTypes=nonempty --textTemplate \"License types\n(project, deps, and bundled devDeps)\" --packageJson --production badges/licenses-badge.svg",
|
|
37
37
|
"license-badge-dev": "license-badger --corrections --filteredTypes=nonempty --textTemplate \"License types\n(all devDeps)\" --allDevelopment badges/licenses-badge-dev.svg",
|
|
38
38
|
"license-badges": "run-p license-badge license-badge-dev",
|
|
@@ -161,73 +161,74 @@
|
|
|
161
161
|
"canvas": "^2.11.2",
|
|
162
162
|
"eventtargeter": "0.9.0",
|
|
163
163
|
"sync-promise-expanded": "^1.0.0",
|
|
164
|
-
"typeson": "9.0.
|
|
165
|
-
"typeson-registry": "
|
|
164
|
+
"typeson": "9.0.3",
|
|
165
|
+
"typeson-registry": "9.2.1",
|
|
166
166
|
"websql-configurable": "^3.0.3"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|
|
169
|
-
"@babel/core": "^7.
|
|
170
|
-
"@babel/preset-env": "^7.
|
|
169
|
+
"@babel/core": "^7.23.5",
|
|
170
|
+
"@babel/preset-env": "^7.23.5",
|
|
171
171
|
"@brettz9/eslint-plugin": "^1.0.4",
|
|
172
172
|
"@brettz9/node-static": "^0.1.1",
|
|
173
173
|
"@es-joy/json-file-reporter": "^1.4.0",
|
|
174
|
-
"@rollup/plugin-babel": "^6.0.
|
|
175
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
176
|
-
"@rollup/plugin-json": "^6.0.
|
|
177
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
178
|
-
"@rollup/plugin-terser": "^0.4.
|
|
179
|
-
"@types/node": "^20.
|
|
180
|
-
"@types/websql": "^0.0.
|
|
181
|
-
"@unicode/unicode-13.0.0": "1.
|
|
174
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
175
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
176
|
+
"@rollup/plugin-json": "^6.0.1",
|
|
177
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
178
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
179
|
+
"@types/node": "^20.10.4",
|
|
180
|
+
"@types/websql": "^0.0.30",
|
|
181
|
+
"@unicode/unicode-13.0.0": "1.5.2",
|
|
182
182
|
"babel-plugin-add-module-exports": "1.0.4",
|
|
183
|
-
"bson": "^
|
|
183
|
+
"bson": "^6.2.0",
|
|
184
184
|
"builtin-modules": "^3.3.0",
|
|
185
|
-
"c8": "^
|
|
186
|
-
"chai": "4.3.
|
|
185
|
+
"c8": "^8.0.1",
|
|
186
|
+
"chai": "4.3.10",
|
|
187
187
|
"chokidar-cli": "^3.0.0",
|
|
188
188
|
"colors": "1.4.0",
|
|
189
189
|
"copyfiles": "^2.4.1",
|
|
190
|
-
"core-js-bundle": "^3.
|
|
190
|
+
"core-js-bundle": "^3.34.0",
|
|
191
191
|
"coveradge": "^0.8.2",
|
|
192
192
|
"cyclonejs": "1.1.4",
|
|
193
193
|
"delay-cli": "^2.0.0",
|
|
194
|
-
"eslint": "^8.
|
|
195
|
-
"eslint-config-ash-nazg": "^
|
|
194
|
+
"eslint": "^8.55.0",
|
|
195
|
+
"eslint-config-ash-nazg": "^35.1.0",
|
|
196
196
|
"eslint-config-standard": "^17.1.0",
|
|
197
|
-
"eslint-plugin-array-func": "^
|
|
198
|
-
"eslint-plugin-compat": "^4.
|
|
197
|
+
"eslint-plugin-array-func": "^4.0.0",
|
|
198
|
+
"eslint-plugin-compat": "^4.2.0",
|
|
199
199
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
200
200
|
"eslint-plugin-html": "^7.1.0",
|
|
201
|
-
"eslint-plugin-import": "^2.
|
|
202
|
-
"eslint-plugin-jsdoc": "^46.
|
|
203
|
-
"eslint-plugin-markdown": "^3.0.
|
|
204
|
-
"eslint-plugin-n": "^16.
|
|
201
|
+
"eslint-plugin-import": "^2.29.0",
|
|
202
|
+
"eslint-plugin-jsdoc": "^46.9.0",
|
|
203
|
+
"eslint-plugin-markdown": "^3.0.1",
|
|
204
|
+
"eslint-plugin-n": "^16.3.1",
|
|
205
205
|
"eslint-plugin-no-unsanitized": "^4.0.2",
|
|
206
206
|
"eslint-plugin-no-use-extend-native": "^0.5.0",
|
|
207
207
|
"eslint-plugin-promise": "^6.1.1",
|
|
208
|
-
"eslint-plugin-sonarjs": "^0.
|
|
208
|
+
"eslint-plugin-sonarjs": "^0.23.0",
|
|
209
209
|
"eslint-plugin-standard": "^4.1.0",
|
|
210
|
-
"eslint-plugin-unicorn": "^
|
|
210
|
+
"eslint-plugin-unicorn": "^49.0.0",
|
|
211
211
|
"got": "^13.0.0",
|
|
212
212
|
"is-date-object": "1.0.5",
|
|
213
213
|
"isomorphic-fetch": "^3.0.0",
|
|
214
|
-
"jsdom": "^
|
|
214
|
+
"jsdom": "^23.0.1",
|
|
215
215
|
"license-badger": "^0.21.1",
|
|
216
216
|
"local-xmlhttprequest": "2.0.0",
|
|
217
217
|
"mocha": "^10.2.0",
|
|
218
|
-
"mocha-badge-generator": "^0.
|
|
218
|
+
"mocha-badge-generator": "^0.11.0",
|
|
219
219
|
"mocha-multi-reporters": "^1.5.1",
|
|
220
220
|
"npm-run-all": "^4.1.5",
|
|
221
221
|
"open-cli": "^7.2.0",
|
|
222
|
-
"rimraf": "^5.0.
|
|
223
|
-
"rollup": "^
|
|
222
|
+
"rimraf": "^5.0.5",
|
|
223
|
+
"rollup": "^4.6.1",
|
|
224
224
|
"rollup-plugin-filesize": "^10.0.0",
|
|
225
225
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
226
226
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
227
|
-
"sinon": "^
|
|
227
|
+
"sinon": "^17.0.1",
|
|
228
228
|
"source-map-support": "0.5.21",
|
|
229
229
|
"sourcemap-transformer": "git+https://github.com/brettz9/sourcemap-transformer.git",
|
|
230
|
+
"typescript": "^5.3.3",
|
|
230
231
|
"w3c-blob": "0.0.1",
|
|
231
|
-
"ws": "^8.
|
|
232
|
+
"ws": "^8.14.2"
|
|
232
233
|
}
|
|
233
234
|
}
|
package/src/DOMException.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* globals DOMException */
|
|
2
1
|
import CFG from './CFG.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -267,7 +266,7 @@ function logError (name, message, error) {
|
|
|
267
266
|
|
|
268
267
|
const method = typeof (console.error) === 'function' ? 'error' : 'log';
|
|
269
268
|
console[method](name + ': ' + message + '. ' + (msg || ''));
|
|
270
|
-
console.trace
|
|
269
|
+
if (console.trace) { console.trace(); }
|
|
271
270
|
}
|
|
272
271
|
}
|
|
273
272
|
|
|
@@ -365,7 +364,7 @@ try {
|
|
|
365
364
|
} catch (e) {}
|
|
366
365
|
|
|
367
366
|
const createDOMException = useNativeDOMException
|
|
368
|
-
// eslint-disable-next-line operator-linebreak -- Need JSDoc
|
|
367
|
+
// eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
|
|
369
368
|
? /**
|
|
370
369
|
* @param {string} name
|
|
371
370
|
* @param {string} message
|
|
@@ -376,7 +375,7 @@ const createDOMException = useNativeDOMException
|
|
|
376
375
|
logError(name, message, error);
|
|
377
376
|
return createNativeDOMException(name, message);
|
|
378
377
|
}
|
|
379
|
-
// eslint-disable-next-line operator-linebreak -- Need JSDoc
|
|
378
|
+
// eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
|
|
380
379
|
: /**
|
|
381
380
|
* @param {string} name
|
|
382
381
|
* @param {string} message
|
package/src/DOMStringList.js
CHANGED
|
@@ -166,7 +166,7 @@ DOMStringList.prototype = {
|
|
|
166
166
|
// and particularly as some methods, e.g., `IDBDatabase.transaction`
|
|
167
167
|
// expect such sequence<DOMString> (or DOMString), we need an iterator (some of
|
|
168
168
|
// the Mocha tests rely on these)
|
|
169
|
-
*
|
|
169
|
+
*[Symbol.iterator] () {
|
|
170
170
|
let i = 0;
|
|
171
171
|
while (i < this._items.length) {
|
|
172
172
|
yield this._items[i++];
|
package/src/IDBCursor.js
CHANGED
|
@@ -238,7 +238,7 @@ IDBCursor.prototype.__findBasic = function (key, primaryKey, tx, success, error,
|
|
|
238
238
|
sql.push('LIMIT', String(recordsToLoad));
|
|
239
239
|
}
|
|
240
240
|
const sqlStr = sql.join(' ');
|
|
241
|
-
CFG.DEBUG
|
|
241
|
+
if (CFG.DEBUG) { console.log(sqlStr, sqlValues); }
|
|
242
242
|
|
|
243
243
|
tx.executeSql(sqlStr, sqlValues, function (tx, data) {
|
|
244
244
|
if (me.__count) {
|
|
@@ -246,18 +246,18 @@ IDBCursor.prototype.__findBasic = function (key, primaryKey, tx, success, error,
|
|
|
246
246
|
} else if (data.rows.length > 1) {
|
|
247
247
|
me.__prefetchedIndex = 0;
|
|
248
248
|
me.__prefetchedData = data.rows;
|
|
249
|
-
CFG.DEBUG
|
|
249
|
+
if (CFG.DEBUG) { console.log('Preloaded ' + me.__prefetchedData.length + ' records for cursor'); }
|
|
250
250
|
me.__decode(data.rows.item(0), success);
|
|
251
251
|
} else if (data.rows.length === 1) {
|
|
252
252
|
me.__decode(data.rows.item(0), success);
|
|
253
253
|
} else {
|
|
254
|
-
CFG.DEBUG
|
|
254
|
+
if (CFG.DEBUG) { console.log('Reached end of cursors'); }
|
|
255
255
|
success(undefined, undefined, undefined);
|
|
256
256
|
}
|
|
257
257
|
}, function (tx, err) {
|
|
258
|
-
CFG.DEBUG
|
|
258
|
+
if (CFG.DEBUG) { console.log('Could not execute Cursor.continue', sqlStr, sqlValues); }
|
|
259
259
|
error(err);
|
|
260
|
-
return
|
|
260
|
+
return false;
|
|
261
261
|
});
|
|
262
262
|
};
|
|
263
263
|
|
|
@@ -277,7 +277,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
277
277
|
const me = this;
|
|
278
278
|
|
|
279
279
|
if (me.__prefetchedData && me.__prefetchedData.length === me.__prefetchedIndex) {
|
|
280
|
-
CFG.DEBUG
|
|
280
|
+
if (CFG.DEBUG) { console.log('Reached end of multiEntry cursor'); }
|
|
281
281
|
success(undefined, undefined, undefined);
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
@@ -335,7 +335,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
const sqlStr = sql.join(' ');
|
|
338
|
-
CFG.DEBUG
|
|
338
|
+
if (CFG.DEBUG) { console.log(sqlStr, sqlValues); }
|
|
339
339
|
|
|
340
340
|
tx.executeSql(sqlStr, sqlValues, function (tx, data) {
|
|
341
341
|
if (data.rows.length > 0) {
|
|
@@ -401,23 +401,23 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
401
401
|
return this.data[index];
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
|
-
CFG.DEBUG
|
|
404
|
+
if (CFG.DEBUG) { console.log('Preloaded ' + me.__prefetchedData.length + ' records for multiEntry cursor'); }
|
|
405
405
|
me.__decode(rows[0], success);
|
|
406
406
|
} else if (rows.length === 1) {
|
|
407
|
-
CFG.DEBUG
|
|
407
|
+
if (CFG.DEBUG) { console.log('Reached end of multiEntry cursor'); }
|
|
408
408
|
me.__decode(rows[0], success);
|
|
409
409
|
} else {
|
|
410
|
-
CFG.DEBUG
|
|
410
|
+
if (CFG.DEBUG) { console.log('Reached end of multiEntry cursor'); }
|
|
411
411
|
success(undefined, undefined, undefined);
|
|
412
412
|
}
|
|
413
413
|
} else {
|
|
414
|
-
CFG.DEBUG
|
|
414
|
+
if (CFG.DEBUG) { console.log('Reached end of multiEntry cursor'); }
|
|
415
415
|
success(undefined, undefined, undefined);
|
|
416
416
|
}
|
|
417
417
|
}, function (tx, err) {
|
|
418
|
-
CFG.DEBUG
|
|
418
|
+
if (CFG.DEBUG) { console.log('Could not execute Cursor.continue', sqlStr, sqlValues); }
|
|
419
419
|
error(err);
|
|
420
|
-
return
|
|
420
|
+
return false;
|
|
421
421
|
});
|
|
422
422
|
};
|
|
423
423
|
|
|
@@ -514,7 +514,7 @@ IDBCursor.prototype.__decode = function (rowItem, callback) {
|
|
|
514
514
|
);
|
|
515
515
|
const val = me.__valueDecoder.decode(encVal);
|
|
516
516
|
const primaryKey = Key.decode(encPrimaryKey);
|
|
517
|
-
callback(key, val, primaryKey, encKey
|
|
517
|
+
callback(key, val, primaryKey, encKey /* , encVal, encPrimaryKey */);
|
|
518
518
|
};
|
|
519
519
|
|
|
520
520
|
/**
|
|
@@ -743,7 +743,9 @@ IDBCursor.prototype.advance = function (count) {
|
|
|
743
743
|
*/
|
|
744
744
|
IDBCursor.prototype.update = function (valueToUpdate) {
|
|
745
745
|
const me = this;
|
|
746
|
-
if (!arguments.length)
|
|
746
|
+
if (!arguments.length) {
|
|
747
|
+
throw new TypeError('A value must be passed to update()');
|
|
748
|
+
}
|
|
747
749
|
IDBTransaction.__assertActive(me.__store.transaction);
|
|
748
750
|
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (
|
|
749
751
|
me.__store.transaction
|
|
@@ -806,7 +808,7 @@ IDBCursor.prototype.delete = function () {
|
|
|
806
808
|
/** @type {KeySuccess} */
|
|
807
809
|
function (key, value, primaryKey) {
|
|
808
810
|
const sql = 'DELETE FROM ' + util.escapeStoreNameForSQL(me.__store.__currentName) + ' WHERE "key" = ?';
|
|
809
|
-
CFG.DEBUG
|
|
811
|
+
if (CFG.DEBUG) { console.log(sql, key, primaryKey); }
|
|
810
812
|
// Key.convertValueToKey(primaryKey); // Already checked when entered
|
|
811
813
|
tx.executeSql(sql, [util.escapeSQLiteStatement(
|
|
812
814
|
/** @type {string} */ (Key.encode(primaryKey))
|
|
@@ -821,7 +823,7 @@ IDBCursor.prototype.delete = function () {
|
|
|
821
823
|
}
|
|
822
824
|
}, function (tx, data) {
|
|
823
825
|
error(data);
|
|
824
|
-
return
|
|
826
|
+
return false;
|
|
825
827
|
});
|
|
826
828
|
}, error
|
|
827
829
|
);
|
package/src/IDBDatabase.js
CHANGED
|
@@ -309,6 +309,7 @@ IDBDatabase.prototype.__forceClose = function (msg) {
|
|
|
309
309
|
me.close();
|
|
310
310
|
let ct = 0;
|
|
311
311
|
me.__transactions.forEach(function (trans) {
|
|
312
|
+
// eslint-disable-next-line camelcase -- Clear API
|
|
312
313
|
trans.on__abort = function () {
|
|
313
314
|
ct++;
|
|
314
315
|
if (ct === me.__transactions.length) {
|
package/src/IDBFactory.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* globals location */
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import SyncPromise from 'sync-promise-expanded';
|
|
4
3
|
|
|
@@ -292,14 +291,14 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
|
|
|
292
291
|
deleteTables(i + 1);
|
|
293
292
|
}, function () {
|
|
294
293
|
deleteTables(i + 1);
|
|
295
|
-
return
|
|
294
|
+
return false;
|
|
296
295
|
});
|
|
297
296
|
}
|
|
298
297
|
}(0));
|
|
299
|
-
}, function (
|
|
298
|
+
}, function () {
|
|
300
299
|
// __sys__ table does not exist, but that does not mean delete did not happen
|
|
301
300
|
databaseDeleted();
|
|
302
|
-
return
|
|
301
|
+
return false;
|
|
303
302
|
});
|
|
304
303
|
});
|
|
305
304
|
}
|
|
@@ -325,7 +324,7 @@ function createSysDB (__openDatabase, success, failure) {
|
|
|
325
324
|
*/
|
|
326
325
|
function sysDbCreateError (tx, err) {
|
|
327
326
|
const er = webSQLErrback(/** @type {SQLError} */ (err) || tx);
|
|
328
|
-
CFG.DEBUG
|
|
327
|
+
if (CFG.DEBUG) { console.log('Error in sysdb transaction - when creating dbVersions', err); }
|
|
329
328
|
failure(er);
|
|
330
329
|
}
|
|
331
330
|
|
|
@@ -462,7 +461,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
462
461
|
*/
|
|
463
462
|
function dbCreateError (tx, err) {
|
|
464
463
|
if (calledDbCreateError) {
|
|
465
|
-
return
|
|
464
|
+
return false;
|
|
466
465
|
}
|
|
467
466
|
const er = err ? webSQLErrback(err) : /** @type {Error} */ (tx);
|
|
468
467
|
calledDbCreateError = true;
|
|
@@ -472,7 +471,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
472
471
|
req.__error = er;
|
|
473
472
|
req.__result = undefined; // Must be undefined if an error per `result` getter
|
|
474
473
|
req.dispatchEvent(evt);
|
|
475
|
-
return
|
|
474
|
+
return false;
|
|
476
475
|
}
|
|
477
476
|
|
|
478
477
|
/**
|
|
@@ -569,7 +568,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
569
568
|
connection.__upgradeTransaction = req.__transaction = req.__result.__versionTransaction = IDBTransaction.__createInstance(req.__result, req.__result.objectStoreNames, 'versionchange');
|
|
570
569
|
req.__done = true;
|
|
571
570
|
|
|
572
|
-
req.transaction.__addNonRequestToTransactionQueue(function onupgradeneeded (tx, args, finished, error) {
|
|
571
|
+
req.transaction.__addNonRequestToTransactionQueue(function onupgradeneeded (tx, args, finished /* , error */) {
|
|
573
572
|
req.dispatchEvent(e);
|
|
574
573
|
|
|
575
574
|
if (e.__legacyOutputDidListenersThrowError) {
|
|
@@ -579,6 +578,8 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
579
578
|
}
|
|
580
579
|
finished();
|
|
581
580
|
});
|
|
581
|
+
|
|
582
|
+
// eslint-disable-next-line camelcase -- Clear API
|
|
582
583
|
req.transaction.on__beforecomplete = function (ev) {
|
|
583
584
|
connection.__upgradeTransaction = null;
|
|
584
585
|
/** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
|
|
@@ -589,9 +590,11 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
589
590
|
ev.complete();
|
|
590
591
|
req.__transaction = null;
|
|
591
592
|
});
|
|
592
|
-
return
|
|
593
|
+
return false;
|
|
593
594
|
});
|
|
594
595
|
};
|
|
596
|
+
|
|
597
|
+
// eslint-disable-next-line camelcase -- Clear API
|
|
595
598
|
req.transaction.on__preabort = function () {
|
|
596
599
|
connection.__upgradeTransaction = null;
|
|
597
600
|
// We ensure any cache is deleted before any request error events fire and try to reopen
|
|
@@ -601,6 +604,8 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
601
604
|
}
|
|
602
605
|
}
|
|
603
606
|
};
|
|
607
|
+
|
|
608
|
+
// eslint-disable-next-line camelcase -- Clear API
|
|
604
609
|
req.transaction.on__abort = function () {
|
|
605
610
|
req.__transaction = null;
|
|
606
611
|
// `readyState` and `result` will be reset anyways by `dbCreateError` but we follow spec.
|
|
@@ -620,13 +625,15 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
620
625
|
// @ts-expect-error It's ok
|
|
621
626
|
reportError || dbCreateError
|
|
622
627
|
);
|
|
623
|
-
return
|
|
628
|
+
return false;
|
|
624
629
|
}
|
|
625
630
|
dbCreateError(err);
|
|
626
|
-
return
|
|
631
|
+
return false;
|
|
627
632
|
});
|
|
628
633
|
});
|
|
629
634
|
};
|
|
635
|
+
|
|
636
|
+
// eslint-disable-next-line camelcase -- Clear API
|
|
630
637
|
req.transaction.on__complete = function () {
|
|
631
638
|
if (/** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
|
|
632
639
|
req.__result
|
|
@@ -746,7 +753,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
746
753
|
}, dbCreateError);
|
|
747
754
|
}
|
|
748
755
|
|
|
749
|
-
addRequestToConnectionQueue(req, name, /* origin */ undefined, function (
|
|
756
|
+
addRequestToConnectionQueue(req, name, /* origin */ undefined, function () {
|
|
750
757
|
let latestCachedVersion;
|
|
751
758
|
if (useDatabaseCache) {
|
|
752
759
|
if (!(name in websqlDBCache)) {
|
|
@@ -834,7 +841,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
834
841
|
*/
|
|
835
842
|
function dbError (tx, err) {
|
|
836
843
|
if (calledDBError || err === true) {
|
|
837
|
-
return
|
|
844
|
+
return false;
|
|
838
845
|
}
|
|
839
846
|
const er = webSQLErrback(/** @type {SQLError} */ (err || tx));
|
|
840
847
|
sysdbFinishedCbDelete(true, function () {
|
|
@@ -846,7 +853,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
846
853
|
req.dispatchEvent(e);
|
|
847
854
|
calledDBError = true;
|
|
848
855
|
});
|
|
849
|
-
return
|
|
856
|
+
return false;
|
|
850
857
|
}
|
|
851
858
|
|
|
852
859
|
addRequestToConnectionQueue(req, name, /* origin */ undefined, function (req) {
|
|
@@ -973,12 +980,12 @@ IDBFactory.prototype.databases = function () {
|
|
|
973
980
|
*/
|
|
974
981
|
function dbGetDatabaseNamesError (tx, err) {
|
|
975
982
|
if (calledDbCreateError) {
|
|
976
|
-
return
|
|
983
|
+
return false;
|
|
977
984
|
}
|
|
978
985
|
const er = err ? webSQLErrback(/** @type {SQLError} */ (err)) : tx;
|
|
979
986
|
calledDbCreateError = true;
|
|
980
987
|
reject(er);
|
|
981
|
-
return
|
|
988
|
+
return false;
|
|
982
989
|
}
|
|
983
990
|
createSysDB(me.__openDatabase, function () {
|
|
984
991
|
sysdb.readTransaction(function (sysReadTx) {
|
package/src/IDBIndex.js
CHANGED
|
@@ -266,7 +266,7 @@ IDBIndex.__createIndex = function (store, index) {
|
|
|
266
266
|
IDBIndex.__updateIndexList(store, tx, function () {
|
|
267
267
|
// Add index entries for all existing records
|
|
268
268
|
tx.executeSql('SELECT "key", "value" FROM ' + util.escapeStoreNameForSQL(storeName), [], function (tx, data) {
|
|
269
|
-
CFG.DEBUG
|
|
269
|
+
if (CFG.DEBUG) { console.log('Adding existing ' + storeName + ' records to the ' + indexName + ' index'); }
|
|
270
270
|
addIndexEntry(0);
|
|
271
271
|
|
|
272
272
|
/**
|
|
@@ -303,7 +303,7 @@ IDBIndex.__createIndex = function (store, index) {
|
|
|
303
303
|
'UPDATE ' + util.escapeStoreNameForSQL(storeName) + ' SET ' +
|
|
304
304
|
util.escapeIndexNameForSQL(indexName) + ' = ? WHERE "key" = ?',
|
|
305
305
|
[util.escapeSQLiteStatement(indexKeyStr), data.rows.item(i).key],
|
|
306
|
-
function (
|
|
306
|
+
function () {
|
|
307
307
|
addIndexEntry(i + 1);
|
|
308
308
|
},
|
|
309
309
|
/** @type {SQLStatementErrorCallback} */ (error)
|
|
@@ -362,7 +362,7 @@ IDBIndex.__createIndex = function (store, index) {
|
|
|
362
362
|
} else {
|
|
363
363
|
// For a new index, add a new column to the object store, then apply the index
|
|
364
364
|
const sql = ['ALTER TABLE', escapedStoreNameSQL, 'ADD', escapedIndexNameSQL, 'BLOB'].join(' ');
|
|
365
|
-
CFG.DEBUG
|
|
365
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
366
366
|
tx.executeSql(
|
|
367
367
|
sql, [], addIndexSQL, /** @type {SQLStatementErrorCallback} */ (error)
|
|
368
368
|
);
|
|
@@ -465,7 +465,7 @@ IDBIndex.__updateIndexList = function (store, tx, success, failure) {
|
|
|
465
465
|
};
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
CFG.DEBUG
|
|
468
|
+
if (CFG.DEBUG) { console.log('Updating the index list for ' + store.__currentName, indexList); }
|
|
469
469
|
tx.executeSql('UPDATE __sys__ SET "indexList" = ? WHERE "name" = ?', [JSON.stringify(indexList), util.escapeSQLiteStatement(store.__currentName)], function () {
|
|
470
470
|
success(store);
|
|
471
471
|
}, /** @type {SQLStatementErrorCallback} */ (failure));
|
|
@@ -662,19 +662,19 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
662
662
|
// This approach has the advantage of auto-deleting indexes via the DROP TABLE
|
|
663
663
|
const sql = 'CREATE TABLE ' + escapedTmpStoreNameSQL +
|
|
664
664
|
'(' + listColInfoToPreserve + escapedNewIndexNameSQL + ' ' + newNameType + ')';
|
|
665
|
-
CFG.DEBUG
|
|
665
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
666
666
|
tx.executeSql(sql, [], function () {
|
|
667
667
|
const sql = 'INSERT INTO ' + escapedTmpStoreNameSQL + '(' +
|
|
668
668
|
listColsToPreserve + escapedNewIndexNameSQL +
|
|
669
669
|
') SELECT ' + listColsToPreserve + util.escapeIndexNameForSQL(oldName) + ' FROM ' + escapedStoreNameSQL;
|
|
670
|
-
CFG.DEBUG
|
|
670
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
671
671
|
tx.executeSql(sql, [], function () {
|
|
672
672
|
const sql = 'DROP TABLE ' + escapedStoreNameSQL;
|
|
673
|
-
CFG.DEBUG
|
|
673
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
674
674
|
tx.executeSql(sql, [], function () {
|
|
675
675
|
const sql = 'ALTER TABLE ' + escapedTmpStoreNameSQL + ' RENAME TO ' + escapedStoreNameSQL;
|
|
676
|
-
CFG.DEBUG
|
|
677
|
-
tx.executeSql(sql, [], function (tx
|
|
676
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
677
|
+
tx.executeSql(sql, [], function (tx) {
|
|
678
678
|
if (!CFG.useSQLiteIndexes) {
|
|
679
679
|
finish();
|
|
680
680
|
return;
|
|
@@ -686,21 +686,19 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
686
686
|
escapedStoreNameSQL.slice(1, -1) + '^5' + escapedIndexNameSQL.slice(1, -1)
|
|
687
687
|
);
|
|
688
688
|
// const sql = 'DROP INDEX IF EXISTS ' + escapedIndexToRecreate;
|
|
689
|
-
// CFG.DEBUG
|
|
689
|
+
// if (CFG.DEBUG) { console.log(sql); }
|
|
690
690
|
// tx.executeSql(sql, [], function () {
|
|
691
691
|
const sql = 'CREATE INDEX ' +
|
|
692
692
|
escapedIndexToRecreate + ' ON ' + escapedStoreNameSQL + '(' + escapedIndexNameSQL + ')';
|
|
693
|
-
CFG.DEBUG
|
|
693
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
694
694
|
tx.executeSql(
|
|
695
695
|
sql,
|
|
696
696
|
[],
|
|
697
697
|
resolve,
|
|
698
|
-
/* eslint-disable no-extra-parens -- TS */
|
|
699
698
|
/** @type {SQLStatementErrorCallback} */
|
|
700
699
|
(function (tx, err) {
|
|
701
700
|
reject(err);
|
|
702
701
|
})
|
|
703
|
-
/* eslint-enable no-extra-parens -- TS */
|
|
704
702
|
);
|
|
705
703
|
// }, function (tx, err) {
|
|
706
704
|
// reject(err);
|
|
@@ -711,26 +709,22 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
711
709
|
const escapedIndexToRecreate = util.sqlQuote('sk_' + escapedStoreNameSQL.slice(1, -1));
|
|
712
710
|
// Chrome erring here if not dropped first; Node does not
|
|
713
711
|
const sql = 'DROP INDEX IF EXISTS ' + escapedIndexToRecreate;
|
|
714
|
-
CFG.DEBUG
|
|
712
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
715
713
|
tx.executeSql(
|
|
716
714
|
sql, [], function () {
|
|
717
715
|
const sql = 'CREATE INDEX ' + escapedIndexToRecreate +
|
|
718
716
|
' ON ' + escapedStoreNameSQL + '("key")';
|
|
719
|
-
CFG.DEBUG
|
|
717
|
+
if (CFG.DEBUG) { console.log(sql); }
|
|
720
718
|
tx.executeSql(
|
|
721
719
|
sql, [], resolve,
|
|
722
|
-
/* eslint-disable no-extra-parens -- TS */
|
|
723
720
|
/** @type {SQLStatementErrorCallback} */
|
|
724
721
|
(function (tx, err) {
|
|
725
|
-
/* eslint-enable no-extra-parens -- TS */
|
|
726
722
|
reject(err);
|
|
727
723
|
})
|
|
728
724
|
);
|
|
729
725
|
},
|
|
730
|
-
/* eslint-disable no-extra-parens -- TS */
|
|
731
726
|
/** @type {SQLStatementErrorCallback} */
|
|
732
727
|
(function (tx, err) {
|
|
733
|
-
/* eslint-enable no-extra-parens -- TS */
|
|
734
728
|
reject(err);
|
|
735
729
|
})
|
|
736
730
|
);
|
|
@@ -803,14 +797,14 @@ function executeFetchIndexData (
|
|
|
803
797
|
sql.push('LIMIT', String(count));
|
|
804
798
|
}
|
|
805
799
|
const isCount = opType === 'count';
|
|
806
|
-
CFG.DEBUG
|
|
800
|
+
if (CFG.DEBUG) { console.log('Trying to fetch data for Index', sql.join(' '), sqlValues); }
|
|
807
801
|
tx.executeSql(sql.join(' '), sqlValues, function (tx, data) {
|
|
808
802
|
const records = [];
|
|
809
803
|
let recordCount = 0;
|
|
810
804
|
const decode = isCount
|
|
811
805
|
? () => { /* */ }
|
|
812
806
|
: (opType === 'key'
|
|
813
|
-
// eslint-disable-next-line operator-linebreak -- JSDoc
|
|
807
|
+
// eslint-disable-next-line @stylistic/operator-linebreak -- JSDoc
|
|
814
808
|
?
|
|
815
809
|
/**
|
|
816
810
|
* @param {{
|
|
@@ -822,7 +816,7 @@ function executeFetchIndexData (
|
|
|
822
816
|
// Key.convertValueToKey(record.key); // Already validated before storage
|
|
823
817
|
return Key.decode(util.unescapeSQLiteResponse(record.key));
|
|
824
818
|
}
|
|
825
|
-
// eslint-disable-next-line operator-linebreak -- JSDoc
|
|
819
|
+
// eslint-disable-next-line @stylistic/operator-linebreak -- JSDoc
|
|
826
820
|
:
|
|
827
821
|
/**
|
|
828
822
|
* @param {{
|
|
@@ -928,7 +922,7 @@ function buildFetchIndexDataSQL (
|
|
|
928
922
|
/** @type {import('./Key.js').KeyPathArray} */ (
|
|
929
923
|
range
|
|
930
924
|
).forEach((innerKey, i) => {
|
|
931
|
-
if (i > 0) sql.push('OR');
|
|
925
|
+
if (i > 0) { sql.push('OR'); }
|
|
932
926
|
sql.push(util.escapeIndexNameForSQL(index.name), "LIKE ? ESCAPE '^' ");
|
|
933
927
|
sqlValues.push('%' + util.sqlLIKEEscape(
|
|
934
928
|
/** @type {string} */ (Key.encode(innerKey, index.multiEntry))
|
package/src/IDBKeyRange.js
CHANGED
|
@@ -102,7 +102,7 @@ IDBKeyRange.only = function (value) {
|
|
|
102
102
|
* @param {import('./Key.js').Value} value
|
|
103
103
|
* @returns {globalThis.IDBKeyRange}
|
|
104
104
|
*/
|
|
105
|
-
IDBKeyRange.lowerBound = function (value
|
|
105
|
+
IDBKeyRange.lowerBound = function (value /* , open */) {
|
|
106
106
|
if (!arguments.length) {
|
|
107
107
|
throw new TypeError('IDBKeyRange.lowerBound requires a value argument');
|
|
108
108
|
}
|
|
@@ -114,7 +114,7 @@ IDBKeyRange.lowerBound = function (value /*, open */) {
|
|
|
114
114
|
* @param {import('./Key.js').Value} value
|
|
115
115
|
* @returns {globalThis.IDBKeyRange}
|
|
116
116
|
*/
|
|
117
|
-
IDBKeyRange.upperBound = function (value
|
|
117
|
+
IDBKeyRange.upperBound = function (value /* , open */) {
|
|
118
118
|
if (!arguments.length) {
|
|
119
119
|
throw new TypeError('IDBKeyRange.upperBound requires a value argument');
|
|
120
120
|
}
|
|
@@ -190,7 +190,7 @@ function setSQLForKeyRange (
|
|
|
190
190
|
range, quotedKeyColumnName, sql, sqlValues, addAnd, checkCached
|
|
191
191
|
) {
|
|
192
192
|
if (range && (range.lower !== undefined || range.upper !== undefined)) {
|
|
193
|
-
if (addAnd) sql.push('AND');
|
|
193
|
+
if (addAnd) { sql.push('AND'); }
|
|
194
194
|
let encodedLowerKey, encodedUpperKey;
|
|
195
195
|
const hasLower = range.lower !== undefined;
|
|
196
196
|
const hasUpper = range.upper !== undefined;
|
|
@@ -208,7 +208,7 @@ function setSQLForKeyRange (
|
|
|
208
208
|
}
|
|
209
209
|
sql.push(quotedKeyColumnName, (range.lowerOpen ? '>' : '>='), '?');
|
|
210
210
|
}
|
|
211
|
-
(hasLower && hasUpper)
|
|
211
|
+
if (hasLower && hasUpper) { sql.push('AND'); }
|
|
212
212
|
if (hasUpper) {
|
|
213
213
|
sql.push(quotedKeyColumnName, (range.upperOpen ? '<' : '<='), '?');
|
|
214
214
|
sqlValues.push(util.escapeSQLiteStatement(/** @type {string} */ (encodedUpperKey)));
|