indexeddbshim 17.7.0 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +13 -3
  2. package/dist/DOMException.d.ts +5 -9
  3. package/dist/DOMException.d.ts.map +1 -1
  4. package/dist/DOMStringList.d.ts +1 -2
  5. package/dist/DOMStringList.d.ts.map +1 -1
  6. package/dist/IDBCursor.d.ts +106 -52
  7. package/dist/IDBCursor.d.ts.map +1 -1
  8. package/dist/IDBFactory.d.ts.map +1 -1
  9. package/dist/IDBIndex.d.ts +8 -7
  10. package/dist/IDBIndex.d.ts.map +1 -1
  11. package/dist/IDBKeyRange.d.ts +3 -3
  12. package/dist/IDBKeyRange.d.ts.map +1 -1
  13. package/dist/IDBObjectStore.d.ts +12 -12
  14. package/dist/IDBObjectStore.d.ts.map +1 -1
  15. package/dist/IDBRequest.d.ts +2 -2
  16. package/dist/IDBRequest.d.ts.map +1 -1
  17. package/dist/IDBTransaction.d.ts +13 -13
  18. package/dist/IDBTransaction.d.ts.map +1 -1
  19. package/dist/Key.d.ts +14 -15
  20. package/dist/Key.d.ts.map +1 -1
  21. package/dist/Sca.d.ts +2 -2
  22. package/dist/Sca.d.ts.map +1 -1
  23. package/dist/cmp.d.ts +3 -3
  24. package/dist/cmp.d.ts.map +1 -1
  25. package/dist/indexeddbshim-Key.js +37 -46
  26. package/dist/indexeddbshim-Key.js.map +1 -1
  27. package/dist/indexeddbshim-Key.min.js +2 -2
  28. package/dist/indexeddbshim-Key.min.js.map +1 -1
  29. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +254 -215
  30. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  31. package/dist/indexeddbshim-UnicodeIdentifiers.js +251 -450
  32. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  33. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +3 -3
  34. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  35. package/dist/indexeddbshim-node.cjs +254 -215
  36. package/dist/indexeddbshim-node.cjs.map +1 -1
  37. package/dist/indexeddbshim-noninvasive.js +251 -450
  38. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  39. package/dist/indexeddbshim-noninvasive.min.js +3 -3
  40. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  41. package/dist/indexeddbshim.js +251 -450
  42. package/dist/indexeddbshim.js.map +1 -1
  43. package/dist/indexeddbshim.min.js +3 -3
  44. package/dist/indexeddbshim.min.js.map +1 -1
  45. package/dist/nodeWebSQL.d.ts +2 -2
  46. package/dist/nodeWebSQL.d.ts.map +1 -1
  47. package/dist/setGlobalVars.d.ts +1 -2
  48. package/dist/setGlobalVars.d.ts.map +1 -1
  49. package/dist/util.d.ts +35 -22
  50. package/dist/util.d.ts.map +1 -1
  51. package/package.json +1 -4
  52. package/src/CFG.js +1 -1
  53. package/src/DOMException.js +9 -11
  54. package/src/DOMStringList.js +6 -11
  55. package/src/Event.js +1 -4
  56. package/src/IDBCursor.js +98 -47
  57. package/src/IDBFactory.js +12 -11
  58. package/src/IDBIndex.js +10 -12
  59. package/src/IDBKeyRange.js +6 -5
  60. package/src/IDBObjectStore.js +32 -27
  61. package/src/IDBRequest.js +1 -1
  62. package/src/IDBTransaction.js +11 -11
  63. package/src/IDBVersionChangeEvent.js +1 -4
  64. package/src/Key.js +32 -31
  65. package/src/Sca.js +1 -1
  66. package/src/cmp.js +2 -2
  67. package/src/nodeWebSQL.js +5 -2
  68. package/src/setGlobalVars.js +8 -19
  69. package/src/util.js +42 -17
package/src/util.js CHANGED
@@ -230,8 +230,32 @@ function sqlLIKEEscape (str) {
230
230
  }
231
231
 
232
232
  /**
233
- * @typedef {Function} AnyClass
233
+ * Minimal replacement for `path.join(base, name)` covering our only use case:
234
+ * `name` is always a bare file name (no separators and no `.`/`..`), and
235
+ * `base` is a directory path expected to be absolute and normalized (an
236
+ * empty string means the current working directory). Unlike `path.join`,
237
+ * this performs no `.`/`..` resolution. It reuses the separator style of
238
+ * `base` (backslash only when `base` uses backslashes and no forward
239
+ * slashes, i.e. a Windows path), otherwise `/`; Node's `fs`, SQLite, and
240
+ * `websql-configurable` accept either separator on Windows regardless.
241
+ * Avoiding `node:path` keeps browser bundles free of a path polyfill.
242
+ * @param {string} base
243
+ * @param {string} name
244
+ * @returns {string}
245
+ */
246
+ function joinPath (base, name) {
247
+ if (!base) {
248
+ return name;
249
+ }
250
+ const sep = base.includes('\\') && !base.includes('/') ? '\\' : '/';
251
+ return base.replace(/[/\\]+$/u, '') + sep + name;
252
+ }
253
+
254
+ /* eslint-disable jsdoc/valid-types -- Bug */
255
+ /**
256
+ * @typedef {{[Symbol.hasInstance]: (value: unknown) => boolean}} AnyClass
234
257
  */
258
+ /* eslint-enable jsdoc/valid-types -- Bug */
235
259
 
236
260
  // Babel doesn't seem to provide a means of using the `instanceof` operator with Symbol.hasInstance (yet?)
237
261
  /**
@@ -255,7 +279,7 @@ function isObj (obj) {
255
279
 
256
280
  /**
257
281
  *
258
- * @param {object} obj
282
+ * @param {AnyValue} obj
259
283
  * @returns {boolean}
260
284
  */
261
285
  function isDate (obj) {
@@ -264,7 +288,7 @@ function isDate (obj) {
264
288
 
265
289
  /**
266
290
  *
267
- * @param {object} obj
291
+ * @param {AnyValue} obj
268
292
  * @returns {boolean}
269
293
  */
270
294
  function isBlob (obj) {
@@ -274,7 +298,7 @@ function isBlob (obj) {
274
298
 
275
299
  /**
276
300
  *
277
- * @param {object} obj
301
+ * @param {AnyValue} obj
278
302
  * @returns {boolean}
279
303
  */
280
304
  function isRegExp (obj) {
@@ -284,7 +308,7 @@ function isRegExp (obj) {
284
308
 
285
309
  /**
286
310
  *
287
- * @param {object} obj
311
+ * @param {AnyValue} obj
288
312
  * @returns {boolean}
289
313
  */
290
314
  function isFile (obj) {
@@ -307,7 +331,7 @@ function isBinary (obj) {
307
331
  /**
308
332
  *
309
333
  * @param {AnyValue} obj
310
- * @returns {boolean}
334
+ * @returns {obj is Iterable<unknown>}
311
335
  */
312
336
  function isIterable (obj) {
313
337
  return isObj(obj) &&
@@ -362,9 +386,7 @@ function defineReadonlyOuterInterface (obj, props) {
362
386
 
363
387
  /**
364
388
  *
365
- * @param {object & {
366
- * [key: string]: any
367
- * }} obj
389
+ * @param {object} obj
368
390
  * @param {string[]} listeners
369
391
  * @returns {void}
370
392
  */
@@ -373,13 +395,13 @@ function defineListenerProperties (obj, listeners) {
373
395
  listeners.forEach((listener) => {
374
396
  const o = {
375
397
  get [listener] () {
376
- return obj['__' + listener];
398
+ return Reflect.get(obj, '__' + listener);
377
399
  },
378
400
  /**
379
401
  * @param {AnyValue} val
380
402
  */
381
403
  set [listener] (val) {
382
- obj['__' + listener] = val;
404
+ Reflect.set(obj, '__' + listener, val);
383
405
  }
384
406
  };
385
407
  const desc = /** @type {PropertyDescriptor} */ (
@@ -390,7 +412,7 @@ function defineListenerProperties (obj, listeners) {
390
412
  Object.defineProperty(obj, listener, desc);
391
413
  });
392
414
  listeners.forEach((l) => {
393
- obj[l] = null;
415
+ Reflect.set(obj, l, null);
394
416
  });
395
417
  }
396
418
 
@@ -399,7 +421,7 @@ function defineListenerProperties (obj, listeners) {
399
421
  * @param {object} obj
400
422
  * @param {string|string[]} props
401
423
  * @param {null|{
402
- * [key: string]: any
424
+ * [key: string]: unknown
403
425
  * }} getter
404
426
  * @returns {void}
405
427
  */
@@ -539,7 +561,7 @@ function enforceRange (number, type) {
539
561
  }
540
562
 
541
563
  /**
542
- * @typedef {any} AnyValue
564
+ * @typedef {unknown} AnyValue
543
565
  */
544
566
 
545
567
  /**
@@ -556,8 +578,11 @@ function convertToDOMString (v, treatNullAs) {
556
578
  * @returns {string}
557
579
  */
558
580
  function ToString (o) { // Todo: See `es-abstract/es7`
559
- // `String()` will not throw with Symbols
560
- return '' + o; // eslint-disable-line no-implicit-coercion -- Need to throw with symbols
581
+ // `String()` will not throw with Symbols, but the unchecked `+ ''`
582
+ // coercion deliberately does (Web IDL requires converting a symbol
583
+ // to `DOMString` to throw a `TypeError`); the assertion only tells
584
+ // the compiler to allow the coercion it cannot model.
585
+ return '' + /** @type {string} */ (o); // eslint-disable-line no-implicit-coercion -- Need to throw with symbols
561
586
  }
562
587
 
563
588
  /**
@@ -637,7 +662,7 @@ function runContinuationSafely (fn) {
637
662
  export {escapeSQLiteStatement, unescapeSQLiteResponse,
638
663
  escapeDatabaseNameForSQLAndFiles, unescapeDatabaseNameForSQLAndFiles,
639
664
  escapeStoreNameForSQL, escapeIndexNameForSQL, escapeIndexNameForSQLKeyColumn,
640
- sqlLIKEEscape, sqlQuote,
665
+ sqlLIKEEscape, sqlQuote, joinPath,
641
666
  instanceOf,
642
667
  isObj, isDate, isBlob, isRegExp, isFile, isBinary, isIterable,
643
668
  defineOuterInterface, defineReadonlyOuterInterface,