indexeddbshim 17.2.1 → 17.3.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 (92) hide show
  1. package/README.md +8 -5
  2. package/dist/CFG.d.ts +1 -1
  3. package/dist/CFG.d.ts.map +1 -1
  4. package/dist/DOMException.d.ts +21 -7
  5. package/dist/DOMException.d.ts.map +1 -1
  6. package/dist/DOMStringList.d.ts.map +1 -1
  7. package/dist/Event.d.ts +12 -6
  8. package/dist/Event.d.ts.map +1 -1
  9. package/dist/IDBCursor.d.ts +125 -7
  10. package/dist/IDBCursor.d.ts.map +1 -1
  11. package/dist/IDBDatabase.d.ts +17 -10
  12. package/dist/IDBDatabase.d.ts.map +1 -1
  13. package/dist/IDBFactory.d.ts +5 -0
  14. package/dist/IDBFactory.d.ts.map +1 -1
  15. package/dist/IDBIndex.d.ts +43 -13
  16. package/dist/IDBIndex.d.ts.map +1 -1
  17. package/dist/IDBKeyRange.d.ts +6 -2
  18. package/dist/IDBKeyRange.d.ts.map +1 -1
  19. package/dist/IDBObjectStore.d.ts +66 -17
  20. package/dist/IDBObjectStore.d.ts.map +1 -1
  21. package/dist/IDBRecord.d.ts +44 -0
  22. package/dist/IDBRecord.d.ts.map +1 -0
  23. package/dist/IDBRequest.d.ts +2 -2
  24. package/dist/IDBRequest.d.ts.map +1 -1
  25. package/dist/IDBTransaction.d.ts +43 -15
  26. package/dist/IDBTransaction.d.ts.map +1 -1
  27. package/dist/IDBVersionChangeEvent.d.ts +23 -12
  28. package/dist/IDBVersionChangeEvent.d.ts.map +1 -1
  29. package/dist/Key.d.ts +7 -6
  30. package/dist/Key.d.ts.map +1 -1
  31. package/dist/Sca.d.ts +15 -0
  32. package/dist/Sca.d.ts.map +1 -1
  33. package/dist/indexeddbshim-Key.js +59 -23
  34. package/dist/indexeddbshim-Key.js.map +1 -1
  35. package/dist/indexeddbshim-Key.min.js +2 -2
  36. package/dist/indexeddbshim-Key.min.js.map +1 -1
  37. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +3123 -1169
  38. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  39. package/dist/indexeddbshim-UnicodeIdentifiers.js +2683 -979
  40. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  41. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +4 -4
  42. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  43. package/dist/indexeddbshim-node.cjs +3123 -1169
  44. package/dist/indexeddbshim-node.cjs.map +1 -1
  45. package/dist/indexeddbshim-noninvasive.js +2683 -979
  46. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  47. package/dist/indexeddbshim-noninvasive.min.js +4 -4
  48. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  49. package/dist/indexeddbshim.js +2683 -979
  50. package/dist/indexeddbshim.js.map +1 -1
  51. package/dist/indexeddbshim.min.js +4 -4
  52. package/dist/indexeddbshim.min.js.map +1 -1
  53. package/dist/node-UnicodeIdentifiers.d.ts +2 -2
  54. package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
  55. package/dist/node.d.ts +2 -2
  56. package/dist/node.d.ts.map +1 -1
  57. package/dist/nodeSQLiteDatabase.d.ts +13 -14
  58. package/dist/nodeSQLiteDatabase.d.ts.map +1 -1
  59. package/dist/nodeWebSQL.d.ts +17 -1
  60. package/dist/nodeWebSQL.d.ts.map +1 -1
  61. package/dist/setGlobalVars.d.ts +2 -2
  62. package/dist/setGlobalVars.d.ts.map +1 -1
  63. package/dist/util.d.ts +15 -0
  64. package/dist/util.d.ts.map +1 -1
  65. package/examples/IDBKeyUtils.html +0 -1
  66. package/package.json +28 -21
  67. package/src/CFG.js +2 -1
  68. package/src/DOMException.js +38 -12
  69. package/src/DOMStringList.js +21 -2
  70. package/src/Event.js +9 -4
  71. package/src/IDBCursor.js +346 -18
  72. package/src/IDBDatabase.js +33 -16
  73. package/src/IDBFactory.js +162 -62
  74. package/src/IDBIndex.js +78 -45
  75. package/src/IDBKeyRange.js +8 -2
  76. package/src/IDBObjectStore.js +89 -65
  77. package/src/IDBRecord.js +96 -0
  78. package/src/IDBRequest.js +7 -7
  79. package/src/IDBTransaction.js +342 -61
  80. package/src/IDBVersionChangeEvent.js +37 -30
  81. package/src/Key.js +36 -18
  82. package/src/Sca.js +22 -1
  83. package/src/browser-UnicodeIdentifiers.js +3 -1
  84. package/src/browser-noninvasive.js +3 -1
  85. package/src/browser.js +3 -1
  86. package/src/node-UnicodeIdentifiers.js +1 -1
  87. package/src/node.js +1 -1
  88. package/src/nodeSQLiteDatabase.js +67 -2
  89. package/src/nodeWebSQL.js +22 -2
  90. package/src/setGlobalVars.js +5 -5
  91. package/src/util.js +29 -1
  92. package/typings/shimIndexedDB.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import SyncPromise from 'sync-promise-expanded';
2
2
  import {createDOMException} from './DOMException.js';
3
- import {IDBCursor, IDBCursorWithValue} from './IDBCursor.js';
3
+ import {IDBCursor, IDBCursorWithValue, parseGetAllArgs, parseGetAllRecordsArgs, collectAll} from './IDBCursor.js';
4
4
  import {setSQLForKeyRange, convertValueToKeyRange} from './IDBKeyRange.js';
5
5
  import DOMStringList from './DOMStringList.js';
6
6
  import * as util from './util.js';
@@ -16,6 +16,10 @@ const readonlyProperties = ['keyPath', 'indexNames', 'transaction', 'autoIncreme
16
16
  * @typedef {number} Integer
17
17
  */
18
18
 
19
+ /**
20
+ * @typedef {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} WebSQLTransaction
21
+ */
22
+
19
23
  /**
20
24
  * IndexedDB Object Store.
21
25
  * @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBObjectStore
@@ -31,7 +35,7 @@ const IDBObjectStoreAlias = IDBObjectStore;
31
35
  * @typedef {IDBObjectStore & {
32
36
  * name: string,
33
37
  * keyPath: import('./Key.js').KeyPath,
34
- * transaction?: import('./IDBTransaction.js').IDBTransactionFull,
38
+ * transaction?: import('./IDBTransaction.js').IDBTransactionFull|null,
35
39
  * indexNames: import('./DOMStringList.js').DOMStringListFull,
36
40
  * autoIncrement: boolean,
37
41
  * __autoIncrement: boolean,
@@ -39,7 +43,7 @@ const IDBObjectStoreAlias = IDBObjectStore;
39
43
  * __indexHandles: {[key: string]: import('./IDBIndex.js').IDBIndexFull},
40
44
  * __indexNames: import('./DOMStringList.js').DOMStringListFull,
41
45
  * __oldIndexNames: import('./DOMStringList.js').DOMStringListFull,
42
- * __transaction?: import('./IDBTransaction.js').IDBTransactionFull,
46
+ * __transaction?: import('./IDBTransaction.js').IDBTransactionFull|null,
43
47
  * __name: string,
44
48
  * __keyPath: import('./Key.js').KeyPath,
45
49
  * __originalName: string,
@@ -53,13 +57,46 @@ const IDBObjectStoreAlias = IDBObjectStore;
53
57
  * import('./IDBCursor.js').IDBCursorWithValueFull
54
58
  * )[],
55
59
  * __idbdb: import('./IDBDatabase.js').IDBDatabaseFull,
60
+ * __validateKeyAndValueAndCloneValue: (
61
+ * value: import('./Key.js').Value,
62
+ * key: import('./Key.js').Key,
63
+ * cursorUpdate: boolean
64
+ * ) => KeyValueArray,
65
+ * __deriveKey: (
66
+ * tx: WebSQLTransaction,
67
+ * value: import('./Key.js').Value,
68
+ * key: import('./Key.js').Key,
69
+ * success: (key: import('./Key.js').Key, cn?: Integer) => void,
70
+ * failCb: import('./Key.js').SQLFailureCallback
71
+ * ) => void,
72
+ * __insertData: (
73
+ * tx: WebSQLTransaction,
74
+ * encoded: string,
75
+ * value: import('./Key.js').Value,
76
+ * clonedKeyOrCurrentNumber: import('./Key.js').Key|Integer,
77
+ * oldCn: Integer|undefined,
78
+ * success: (clonedKeyOrCurrentNumber: import('./Key.js').Key|Integer) => void,
79
+ * error: (err: Error|DOMException) => void
80
+ * ) => SyncPromise,
81
+ * __overwrite: (
82
+ * tx: WebSQLTransaction,
83
+ * key: import('./Key.js').Key,
84
+ * cb: (tx: WebSQLTransaction) => void,
85
+ * error: (err: (Error & {code?: number})) => void
86
+ * ) => void,
87
+ * __get: (
88
+ * query: import('./Key.js').Value,
89
+ * getKey?: boolean,
90
+ * getAll?: boolean,
91
+ * count?: Integer
92
+ * ) => import('./IDBRequest.js').IDBRequestFull,
56
93
  * }} IDBObjectStoreFull
57
94
  */
58
95
 
59
96
  /**
60
97
  *
61
98
  * @param {import('./IDBDatabase.js').IDBObjectStoreProperties} storeProperties
62
- * @param {import('./IDBTransaction.js').IDBTransactionFull} [transaction]
99
+ * @param {import('./IDBTransaction.js').IDBTransactionFull|null} [transaction]
63
100
  * @returns {IDBObjectStoreFull}
64
101
  */
65
102
  IDBObjectStore.__createInstance = function (storeProperties, transaction) {
@@ -254,8 +291,8 @@ IDBObjectStore.__createObjectStore = function (db, store) {
254
291
 
255
292
  transaction.__addNonRequestToTransactionQueue(function createObjectStore (tx, args, success, failure) {
256
293
  /**
257
- * @param {SQLTransaction} tx
258
- * @param {SQLError} [err]
294
+ * @param {WebSQLTransaction} tx
295
+ * @param {(Error & {code?: number})} [err]
259
296
  * @returns {boolean}
260
297
  */
261
298
  function error (tx, err) {
@@ -315,20 +352,20 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
315
352
 
316
353
  db.objectStoreNames.splice(db.objectStoreNames.indexOf(store.__currentName), 1);
317
354
 
318
- const storeHandle = db.__versionTransaction.__storeHandles[store.__currentName];
355
+ const transaction = /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (
356
+ db.__versionTransaction
357
+ );
358
+ const storeHandle = transaction.__storeHandles[store.__currentName];
319
359
  if (storeHandle) {
320
360
  storeHandle.__indexNames = DOMStringList.__createInstance();
321
361
  storeHandle.__pendingDelete = true;
322
362
  }
323
363
 
324
364
  // Remove the object store from WebSQL
325
- const transaction = /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (
326
- db.__versionTransaction
327
- );
328
365
  transaction.__addNonRequestToTransactionQueue(function deleteObjectStore (tx, args, success, failure) {
329
366
  /**
330
- * @param {SQLTransaction} tx
331
- * @param {SQLError} [err]
367
+ * @param {WebSQLTransaction} tx
368
+ * @param {(Error & {code?: number})} [err]
332
369
  * @returns {boolean}
333
370
  */
334
371
  function error (tx, err) {
@@ -386,7 +423,10 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
386
423
  // Todo Binary: Avoid blobs loading async to ensure cloning (and errors therein)
387
424
  // occurs sync; then can make cloning and this method without callbacks (except where ok
388
425
  // to be async)
389
- const clonedValue = Sca.clone(value);
426
+ const clonedValue = Sca.cloneWithInactiveTransaction(
427
+ /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (me.transaction),
428
+ value
429
+ );
390
430
  key = Key.extractKeyValueDecodedFromValueUsingKeyPath(clonedValue, me.keyPath); // May throw so "rethrow"
391
431
  if (key.invalid) {
392
432
  throw createDOMException('DataError', 'KeyPath was specified, but key was invalid.');
@@ -417,7 +457,10 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
417
457
  } else {
418
458
  Key.convertValueToKeyRethrowingAndIfInvalid(key);
419
459
  }
420
- const clonedValue = Sca.clone(value);
460
+ const clonedValue = Sca.cloneWithInactiveTransaction(
461
+ /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (me.transaction),
462
+ value
463
+ );
421
464
  return [key, clonedValue];
422
465
  };
423
466
 
@@ -426,7 +469,7 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
426
469
  * the object store
427
470
  * If the table has auto increment, get the current number (unless it has
428
471
  * a keyPath leading to a valid but non-numeric or < 1 key).
429
- * @param {SQLTransaction} tx
472
+ * @param {WebSQLTransaction} tx
430
473
  * @param {import('./Key.js').Value} value
431
474
  * @param {import('./Key.js').Key} key
432
475
  * @param {(key: import('./Key.js').Key, cn?: Integer) => void} success
@@ -477,7 +520,7 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
477
520
 
478
521
  /**
479
522
  *
480
- * @param {SQLTransaction} tx
523
+ * @param {WebSQLTransaction} tx
481
524
  * @param {string} encoded
482
525
  * @param {import('./Key.js').Value} value
483
526
  * @param {import('./Key.js').Key|Integer} clonedKeyOrCurrentNumber
@@ -658,6 +701,7 @@ IDBObjectStore.prototype.add = function (value /* , key */) {
658
701
  me.transaction
659
702
  ).__createRequest(me);
660
703
  const [ky, clonedValue] = me.__validateKeyAndValueAndCloneValue(value, key, false);
704
+ // @ts-ignore -- Private API
661
705
  IDBObjectStore.__storingRecordObjectStore(request, me, true, clonedValue, true, ky);
662
706
  return request;
663
707
  };
@@ -689,16 +733,17 @@ IDBObjectStore.prototype.put = function (value /* , key */) {
689
733
  me.transaction
690
734
  ).__createRequest(me);
691
735
  const [ky, clonedValue] = me.__validateKeyAndValueAndCloneValue(value, key, false);
736
+ // @ts-ignore -- Private API
692
737
  IDBObjectStore.__storingRecordObjectStore(request, me, true, clonedValue, false, ky);
693
738
  return request;
694
739
  };
695
740
 
696
741
  /**
697
742
  *
698
- * @param {SQLTransaction} tx
743
+ * @param {WebSQLTransaction} tx
699
744
  * @param {import('./Key.js').Key} key
700
- * @param {(tx: SQLTransaction) => void} cb
701
- * @param {(err: SQLError) => void} error
745
+ * @param {(tx: WebSQLTransaction) => void} cb
746
+ * @param {(err: (Error & {code?: number})) => void} error
702
747
  * @this {IDBObjectStoreFull}
703
748
  * @returns {void}
704
749
  */
@@ -735,7 +780,7 @@ IDBObjectStore.__storingRecordObjectStore = function (request, store, invalidate
735
780
  store.__deriveKey(tx, value, key, function (clonedKeyOrCurrentNumber, oldCn) {
736
781
  Sca.encode(value, function (encoded) {
737
782
  /**
738
- * @param {SQLTransaction} tx
783
+ * @param {WebSQLTransaction} tx
739
784
  * @returns {void}
740
785
  */
741
786
  function insert (tx) {
@@ -762,20 +807,15 @@ IDBObjectStore.__storingRecordObjectStore = function (request, store, invalidate
762
807
  *
763
808
  * @param {import('./Key.js').Value} query
764
809
  * @param {boolean} [getKey]
765
- * @param {boolean} [getAll]
766
- * @param {Integer} [count]
767
810
  * @this {IDBObjectStoreFull}
768
811
  * @returns {import('./IDBRequest.js').IDBRequestFull}
769
812
  */
770
- IDBObjectStore.prototype.__get = function (query, getKey, getAll, count) {
813
+ IDBObjectStore.prototype.__get = function (query, getKey) {
771
814
  const me = this;
772
- if (count !== undefined) {
773
- count = util.enforceRange(count, 'unsigned long');
774
- }
775
815
  IDBObjectStore.__invalidStateIfDeleted(me);
776
816
  IDBTransaction.__assertActive(me.transaction);
777
817
 
778
- const range = convertValueToKeyRange(query, !getAll);
818
+ const range = convertValueToKeyRange(query, true);
779
819
 
780
820
  const col = getKey ? 'key' : 'value';
781
821
  const sql = ['SELECT', util.sqlQuote(col), 'FROM', util.escapeStoreNameForSQL(me.__currentName)];
@@ -785,15 +825,7 @@ IDBObjectStore.prototype.__get = function (query, getKey, getAll, count) {
785
825
  sql.push('WHERE');
786
826
  setSQLForKeyRange(range, util.sqlQuote('key'), sql, sqlValues);
787
827
  }
788
- if (!getAll) {
789
- count = 1;
790
- }
791
- if (count) {
792
- if (!Number.isFinite(count)) {
793
- throw new TypeError('The count parameter must be a finite number');
794
- }
795
- sql.push('LIMIT', String(count));
796
- }
828
+ sql.push('LIMIT', '1');
797
829
  const sqlStr = sql.join(' ');
798
830
  return /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (
799
831
  me.transaction
@@ -805,31 +837,12 @@ IDBObjectStore.prototype.__get = function (query, getKey, getAll, count) {
805
837
  try {
806
838
  // Opera can't deal with the try-catch here.
807
839
  if (data.rows.length === 0) {
808
- if (getAll) {
809
- success([]);
810
- } else {
811
- success();
812
- }
840
+ success();
813
841
  return;
814
842
  }
815
- ret = [];
816
- if (getKey) {
817
- for (let i = 0; i < data.rows.length; i++) {
818
- // Key.convertValueToKey(data.rows.item(i).key); // Already validated before storage
819
- ret.push(
820
- Key.decode(util.unescapeSQLiteResponse(data.rows.item(i).key), false)
821
- );
822
- }
823
- } else {
824
- for (let i = 0; i < data.rows.length; i++) {
825
- ret.push(
826
- Sca.decode(util.unescapeSQLiteResponse(data.rows.item(i).value))
827
- );
828
- }
829
- }
830
- if (!getAll) {
831
- ret = ret[0];
832
- }
843
+ ret = getKey
844
+ ? Key.decode(util.unescapeSQLiteResponse(/** @type {{key: string}} */ (data.rows.item(0)).key), false)
845
+ : Sca.decode(util.unescapeSQLiteResponse(/** @type {{value: string}} */ (data.rows.item(0)).value));
833
846
  } catch (e) {
834
847
  // If no result is returned, or error occurs when parsing JSON
835
848
  if (CFG.DEBUG) { console.log(e); }
@@ -873,20 +886,30 @@ IDBObjectStore.prototype.getKey = function (query) {
873
886
  * @this {IDBObjectStoreFull}
874
887
  * @returns {import('./IDBRequest.js').IDBRequestFull}
875
888
  */
876
- IDBObjectStore.prototype.getAll = function (/* query, count */) {
889
+ IDBObjectStore.prototype.getAll = function (/* queryOrOptions, count */) {
890
+ // eslint-disable-next-line prefer-rest-params -- API
891
+ const {query, count, direction} = parseGetAllArgs(arguments);
892
+ return collectAll(this, query, count, direction, 'value');
893
+ };
894
+
895
+ /**
896
+ * @this {IDBObjectStoreFull}
897
+ * @returns {import('./IDBRequest.js').IDBRequestFull}
898
+ */
899
+ IDBObjectStore.prototype.getAllKeys = function (/* queryOrOptions, count */) {
877
900
  // eslint-disable-next-line prefer-rest-params -- API
878
- const [query, count] = arguments;
879
- return this.__get(query, false, true, count);
901
+ const {query, count, direction} = parseGetAllArgs(arguments);
902
+ return collectAll(this, query, count, direction, 'key');
880
903
  };
881
904
 
882
905
  /**
883
906
  * @this {IDBObjectStoreFull}
884
907
  * @returns {import('./IDBRequest.js').IDBRequestFull}
885
908
  */
886
- IDBObjectStore.prototype.getAllKeys = function (/* query, count */) {
909
+ IDBObjectStore.prototype.getAllRecords = function (/* options */) {
887
910
  // eslint-disable-next-line prefer-rest-params -- API
888
- const [query, count] = arguments;
889
- return this.__get(query, true, true, count);
911
+ const {query, count, direction} = parseGetAllRecordsArgs(arguments);
912
+ return collectAll(this, query, count, direction, 'record');
890
913
  };
891
914
 
892
915
  /**
@@ -1128,6 +1151,7 @@ IDBObjectStore.prototype.deleteIndex = function (name) {
1128
1151
  /* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
1129
1152
  util.defineReadonlyOuterInterface(IDBObjectStore.prototype, readonlyProperties);
1130
1153
  util.defineOuterInterface(IDBObjectStore.prototype, ['name']);
1154
+ util.setOperationNames(IDBObjectStore.prototype);
1131
1155
 
1132
1156
  IDBObjectStore.prototype[Symbol.toStringTag] = 'IDBObjectStorePrototype';
1133
1157
 
@@ -0,0 +1,96 @@
1
+ import * as util from './util.js';
2
+
3
+ const readonlyProperties = /** @type {const} */ (['key', 'primaryKey', 'value']);
4
+
5
+ /* eslint-disable jsdoc/valid-types -- pratt parser bug */
6
+ /**
7
+ * @typedef {{
8
+ * [Symbol.toStringTag]: 'IDBRecord',
9
+ * __key: import('./Key.js').Key,
10
+ * __primaryKey: import('./Key.js').Key,
11
+ * __value: import('./Key.js').Value,
12
+ * key: import('./Key.js').Key,
13
+ * primaryKey: import('./Key.js').Key,
14
+ * value: import('./Key.js').Value
15
+ * }} IDBRecordFull
16
+ */
17
+ /* eslint-enable jsdoc/valid-types -- pratt parser bug */
18
+
19
+ /**
20
+ * The record type returned by `IDBObjectStore`/`IDBIndex#getAllRecords()`
21
+ * (IndexedDB 3.0). Structured the same way as `IDBCursor` -- a public
22
+ * constructor that always throws, with real instances only ever produced
23
+ * internally via `__createInstance` -- so a record can't be directly
24
+ * instantiated by script.
25
+ * @see https://w3c.github.io/IndexedDB/#record-interface
26
+ * @throws {TypeError}
27
+ * @class
28
+ */
29
+ function IDBRecord () {
30
+ throw new TypeError('Illegal constructor');
31
+ }
32
+ const IDBRecordAlias = IDBRecord;
33
+
34
+ /**
35
+ * @param {import('./Key.js').Key} key
36
+ * @param {import('./Key.js').Key} primaryKey
37
+ * @param {import('./Key.js').Value} value
38
+ * @returns {IDBRecordFull}
39
+ */
40
+ IDBRecord.__createInstance = function (key, primaryKey, value) {
41
+ /**
42
+ * @class
43
+ * @this {IDBRecordFull}
44
+ */
45
+ function IDBRecord () {
46
+ // @ts-ignore Should be ok
47
+ this[Symbol.toStringTag] = 'IDBRecord';
48
+ this.__key = key;
49
+ this.__primaryKey = primaryKey;
50
+ this.__value = value;
51
+ }
52
+ IDBRecord.prototype = IDBRecordAlias.prototype;
53
+
54
+ // @ts-expect-error Properties added below on the shared prototype
55
+ return new IDBRecord();
56
+ };
57
+
58
+ IDBRecord.prototype[Symbol.toStringTag] = 'IDBRecordPrototype';
59
+
60
+ /* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
61
+ util.setOperationNames(IDBRecord.prototype);
62
+ util.setOperationNames(IDBRecord);
63
+
64
+ // Defined once on the shared prototype (rather than per-instance, as
65
+ // `util.defineReadonlyProperties` would) since WPT's `assert_idl_attribute`
66
+ // specifically requires these to be inherited, not own, properties.
67
+ readonlyProperties.forEach((prop) => {
68
+ Object.defineProperty(IDBRecord.prototype, '__' + prop, {
69
+ enumerable: false,
70
+ configurable: false,
71
+ writable: true
72
+ });
73
+ // We must resort to this to get "get <name>" as the function `name` for
74
+ // proper IDL.
75
+ const o = {
76
+ /**
77
+ * @returns {import('./Key.js').Key|import('./Key.js').Value}
78
+ */
79
+ get [prop] () {
80
+ return this['__' + prop];
81
+ }
82
+ };
83
+ const desc = /** @type {PropertyDescriptor} */ (
84
+ Object.getOwnPropertyDescriptor(o, prop)
85
+ );
86
+ Object.defineProperty(IDBRecord.prototype, prop, desc);
87
+ });
88
+
89
+ Object.defineProperty(IDBRecord, 'prototype', {
90
+ writable: false
91
+ });
92
+ /* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
93
+
94
+ export {IDBRecord};
95
+
96
+ export default IDBRecord;
package/src/IDBRequest.js CHANGED
@@ -17,7 +17,7 @@ function IDBRequest () {
17
17
  }
18
18
 
19
19
  /**
20
- * @typedef {IDBRequest & EventTarget & import('eventtargeter').ShimEventTarget & {
20
+ * @typedef {IDBRequest & EventTarget & import('eventtargeter').EventTargetInstance & {
21
21
  * transaction: import('./IDBTransaction.js').IDBTransactionFull,
22
22
  * __done: boolean,
23
23
  * __result: import('./IDBDatabase.js').IDBDatabaseFull|undefined,
@@ -42,9 +42,9 @@ function IDBRequest () {
42
42
  * @this {IDBRequestFull}
43
43
  */
44
44
  IDBRequest.__super = function IDBRequest () {
45
- // @ts-expect-error It's ok
45
+ // @ts-ignore It's ok
46
46
  this[Symbol.toStringTag] = 'IDBRequest';
47
- // @ts-expect-error Part of `ShimEventTarget`
47
+ // @ts-ignore Part of `ShimEventTarget`
48
48
  this.__setOptions({
49
49
  legacyOutputDidListenersThrowFlag: true // Event hook for IndexedB
50
50
  });
@@ -73,11 +73,11 @@ IDBRequest.__super = function IDBRequest () {
73
73
  util.defineReadonlyProperties(this, readonlyProperties, {
74
74
  readyState: {
75
75
  /**
76
- * @this {IDBRequestFull}
77
76
  * @returns {"done"|"pending"}
78
77
  */
79
78
  get readyState () {
80
- return this.__done ? 'done' : 'pending';
79
+ const me = /** @type {IDBRequestFull} */ (/** @type {unknown} */ (this));
80
+ return me.__done ? 'done' : 'pending';
81
81
  }
82
82
  }
83
83
  });
@@ -171,9 +171,9 @@ IDBOpenDBRequest.__createInstance = function () {
171
171
  function IDBOpenDBRequest () {
172
172
  IDBRequest.__super.call(this);
173
173
 
174
- // @ts-expect-error It's ok
174
+ // @ts-ignore It's ok
175
175
  this[Symbol.toStringTag] = 'IDBOpenDBRequest';
176
- // @ts-expect-error It's ok
176
+ // @ts-ignore It's ok
177
177
  this.__setOptions({
178
178
  legacyOutputDidListenersThrowFlag: true, // Event hook for IndexedB
179
179
  extraProperties: ['oldVersion', 'newVersion', 'debug']