indexeddbshim 12.0.0 → 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/CFG.d.ts +80 -0
- package/dist/CFG.d.ts.map +1 -0
- package/dist/DOMException.d.ts +71 -0
- package/dist/DOMException.d.ts.map +1 -0
- package/dist/DOMStringList.d.ts +20 -0
- package/dist/DOMStringList.d.ts.map +1 -0
- package/dist/Event.d.ts +21 -0
- package/dist/Event.d.ts.map +1 -0
- package/dist/IDBCursor.d.ts +288 -0
- package/dist/IDBCursor.d.ts.map +1 -0
- package/dist/IDBDatabase.d.ts +143 -0
- package/dist/IDBDatabase.d.ts.map +1 -0
- package/dist/IDBFactory.d.ts +96 -0
- package/dist/IDBFactory.d.ts.map +1 -0
- package/dist/IDBIndex.d.ts +243 -0
- package/dist/IDBIndex.d.ts.map +1 -0
- package/dist/IDBKeyRange.d.ts +79 -0
- package/dist/IDBKeyRange.d.ts.map +1 -0
- package/dist/IDBObjectStore.d.ts +273 -0
- package/dist/IDBObjectStore.d.ts.map +1 -0
- package/dist/IDBRequest.d.ts +88 -0
- package/dist/IDBRequest.d.ts.map +1 -0
- package/dist/IDBTransaction.d.ts +270 -0
- package/dist/IDBTransaction.d.ts.map +1 -0
- package/dist/IDBVersionChangeEvent.d.ts +22 -0
- package/dist/IDBVersionChangeEvent.d.ts.map +1 -0
- package/dist/Key.d.ts +214 -0
- package/dist/Key.d.ts.map +1 -0
- package/dist/Sca.d.ts +31 -0
- package/dist/Sca.d.ts.map +1 -0
- package/dist/UnicodeIdentifiers.d.ts +3 -0
- package/dist/UnicodeIdentifiers.d.ts.map +1 -0
- package/dist/browser-UnicodeIdentifiers.d.ts +2 -0
- package/dist/browser-UnicodeIdentifiers.d.ts.map +1 -0
- package/dist/browser-noninvasive.d.ts +3 -0
- package/dist/browser-noninvasive.d.ts.map +1 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/cmp.d.ts +9 -0
- package/dist/cmp.d.ts.map +1 -0
- package/dist/indexeddbshim-Key.js +553 -252
- 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 +17560 -1302
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +4367 -1604
- 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 +17556 -1302
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +4362 -1604
- 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 +4362 -1604
- 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 +8 -0
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/nodeWebSQL.d.ts +3 -0
- package/dist/nodeWebSQL.d.ts.map +1 -0
- package/dist/setGlobalVars.d.ts +79 -0
- package/dist/setGlobalVars.d.ts.map +1 -0
- package/dist/unicode-regex.d.ts +3 -0
- package/dist/unicode-regex.d.ts.map +1 -0
- package/dist/util.d.ts +174 -0
- package/dist/util.d.ts.map +1 -0
- package/index.html +1 -1
- package/package.json +51 -37
- package/src/CFG.js +89 -11
- package/src/DOMException.js +117 -31
- package/src/DOMStringList.js +93 -3
- package/src/Event.js +19 -4
- package/src/IDBCursor.js +350 -76
- package/src/IDBDatabase.js +88 -10
- package/src/IDBFactory.js +331 -61
- package/src/IDBIndex.js +393 -110
- package/src/IDBKeyRange.js +90 -17
- package/src/IDBObjectStore.js +347 -86
- package/src/IDBRequest.js +59 -1
- package/src/IDBTransaction.js +254 -46
- package/src/IDBVersionChangeEvent.js +28 -3
- package/src/Key.d.ts +1 -0
- package/src/Key.js +272 -162
- package/src/Sca.js +29 -4
- package/src/browser-UnicodeIdentifiers.js +5 -1
- package/src/cmp.js +5 -5
- package/src/node-UnicodeIdentifiers.js +9 -0
- package/src/node.js +5 -0
- package/src/nodeWebSQL.js +11 -5
- package/src/setGlobalVars.js +159 -22
- package/src/unicode-regex.js +2 -0
- package/src/util.js +229 -40
- package/typings/shimIndexedDB.d.ts +9 -0
package/src/IDBDatabase.js
CHANGED
|
@@ -9,17 +9,75 @@ import IDBTransaction from './IDBTransaction.js';
|
|
|
9
9
|
const listeners = ['onabort', 'onclose', 'onerror', 'onversionchange'];
|
|
10
10
|
const readonlyProperties = ['name', 'version', 'objectStoreNames'];
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {{
|
|
14
|
+
* name: string,
|
|
15
|
+
* keyPath: import('./Key.js').KeyPath,
|
|
16
|
+
* autoInc: boolean,
|
|
17
|
+
* indexList: {[key: string]: import('./IDBIndex.js').IDBIndexProperties},
|
|
18
|
+
* idbdb: IDBDatabaseFull,
|
|
19
|
+
* cursors?: (import('./IDBCursor.js').IDBCursorFull|
|
|
20
|
+
* import('./IDBCursor.js').IDBCursorWithValueFull)[],
|
|
21
|
+
* }} IDBObjectStoreProperties
|
|
22
|
+
*/
|
|
23
|
+
|
|
12
24
|
/**
|
|
13
25
|
* IDB Database Object.
|
|
14
26
|
* @see http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#database-interface
|
|
15
27
|
* @class
|
|
16
28
|
*/
|
|
17
29
|
function IDBDatabase () {
|
|
30
|
+
this.__versionTransaction = null;
|
|
31
|
+
this.__objectStores = null;
|
|
18
32
|
throw new TypeError('Illegal constructor');
|
|
19
33
|
}
|
|
20
34
|
const IDBDatabaseAlias = IDBDatabase;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {number} Integer
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {IDBDatabase & EventTarget & {
|
|
42
|
+
* createObjectStore: (storeName: string) => IDBObjectStore,
|
|
43
|
+
* deleteObjectStore: (storeName: string) => void,
|
|
44
|
+
* close: () => void,
|
|
45
|
+
* transaction: (storeNames: string|string[], mode: string) => IDBTransaction,
|
|
46
|
+
* throwIfUpgradeTransactionNull: () => void,
|
|
47
|
+
* objectStoreNames: import('./DOMStringList.js').DOMStringListFull,
|
|
48
|
+
* name: string,
|
|
49
|
+
* __forceClose: (msg: string) => void,
|
|
50
|
+
* __db: import('websql-configurable/lib/websql/WebSQLDatabase.js').default,
|
|
51
|
+
* __oldVersion: Integer,
|
|
52
|
+
* __version: Integer,
|
|
53
|
+
* __name: string,
|
|
54
|
+
* __upgradeTransaction: null|import('./IDBTransaction.js').IDBTransactionFull,
|
|
55
|
+
* __versionTransaction: import('./IDBTransaction.js').IDBTransactionFull,
|
|
56
|
+
* __transactions: import('./IDBTransaction.js').IDBTransactionFull[],
|
|
57
|
+
* __objectStores: {[key: string]: IDBObjectStore},
|
|
58
|
+
* __objectStoreNames: import('./DOMStringList.js').DOMStringListFull,
|
|
59
|
+
* __oldObjectStoreNames: import('./DOMStringList.js').DOMStringListFull,
|
|
60
|
+
* __unblocking: {
|
|
61
|
+
* check: () => void
|
|
62
|
+
* }
|
|
63
|
+
* }} IDBDatabaseFull
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {import('websql-configurable').default} db
|
|
68
|
+
* @param {string} name
|
|
69
|
+
* @param {Integer} oldVersion
|
|
70
|
+
* @param {Integer} version
|
|
71
|
+
* @param {SQLResultSet} storeProperties
|
|
72
|
+
* @returns {IDBDatabaseFull}
|
|
73
|
+
*/
|
|
21
74
|
IDBDatabase.__createInstance = function (db, name, oldVersion, version, storeProperties) {
|
|
75
|
+
/**
|
|
76
|
+
* @class
|
|
77
|
+
* @this {IDBDatabaseFull}
|
|
78
|
+
*/
|
|
22
79
|
function IDBDatabase () {
|
|
80
|
+
// @ts-expect-error It's ok
|
|
23
81
|
this[Symbol.toStringTag] = 'IDBDatabase';
|
|
24
82
|
util.defineReadonlyProperties(this, readonlyProperties);
|
|
25
83
|
this.__db = db;
|
|
@@ -29,13 +87,20 @@ IDBDatabase.__createInstance = function (db, name, oldVersion, version, storePro
|
|
|
29
87
|
this.__name = name;
|
|
30
88
|
this.__upgradeTransaction = null;
|
|
31
89
|
util.defineListenerProperties(this, listeners);
|
|
90
|
+
// @ts-expect-error Part of `ShimEventTarget`
|
|
32
91
|
this.__setOptions({
|
|
33
92
|
legacyOutputDidListenersThrowFlag: true // Event hook for IndexedB
|
|
34
93
|
});
|
|
35
94
|
|
|
36
95
|
this.__transactions = [];
|
|
96
|
+
|
|
97
|
+
/** @type {{[key: string]: IDBObjectStore}} */
|
|
37
98
|
this.__objectStores = {};
|
|
38
99
|
this.__objectStoreNames = DOMStringList.__createInstance();
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @type {IDBObjectStoreProperties}
|
|
103
|
+
*/
|
|
39
104
|
const itemCopy = {};
|
|
40
105
|
for (let i = 0; i < storeProperties.rows.length; i++) {
|
|
41
106
|
const item = storeProperties.rows.item(i);
|
|
@@ -49,9 +114,10 @@ IDBDatabase.__createInstance = function (db, name, oldVersion, version, storePro
|
|
|
49
114
|
// and should thus be parsed into a number here (0 or 1),
|
|
50
115
|
// `IDBObjectStore.__createInstance` will convert to a boolean
|
|
51
116
|
// when setting the store's `autoIncrement`.
|
|
52
|
-
['autoInc', 'indexList'].forEach(
|
|
117
|
+
/** @type {const} */ (['autoInc', 'indexList']).forEach((prop) => {
|
|
53
118
|
itemCopy[prop] = JSON.parse(item[prop]);
|
|
54
119
|
});
|
|
120
|
+
|
|
55
121
|
itemCopy.idbdb = this;
|
|
56
122
|
const store = IDBObjectStore.__createInstance(itemCopy);
|
|
57
123
|
this.__objectStores[store.name] = store;
|
|
@@ -60,21 +126,22 @@ IDBDatabase.__createInstance = function (db, name, oldVersion, version, storePro
|
|
|
60
126
|
this.__oldObjectStoreNames = this.objectStoreNames.clone();
|
|
61
127
|
}
|
|
62
128
|
IDBDatabase.prototype = IDBDatabaseAlias.prototype;
|
|
129
|
+
|
|
130
|
+
// @ts-expect-error It's ok
|
|
63
131
|
return new IDBDatabase();
|
|
64
132
|
};
|
|
65
133
|
|
|
134
|
+
// @ts-expect-error It's ok
|
|
66
135
|
IDBDatabase.prototype = EventTargetFactory.createInstance();
|
|
67
136
|
IDBDatabase.prototype[Symbol.toStringTag] = 'IDBDatabasePrototype';
|
|
68
137
|
|
|
69
|
-
/* eslint-disable jsdoc/check-param-names */
|
|
70
138
|
/**
|
|
71
139
|
* Creates a new object store.
|
|
72
140
|
* @param {string} storeName
|
|
73
|
-
* @
|
|
141
|
+
* @this {IDBDatabaseFull}
|
|
74
142
|
* @returns {IDBObjectStore}
|
|
75
143
|
*/
|
|
76
144
|
IDBDatabase.prototype.createObjectStore = function (storeName /* , createOptions */) {
|
|
77
|
-
/* eslint-enable jsdoc/check-param-names */
|
|
78
145
|
// eslint-disable-next-line prefer-rest-params
|
|
79
146
|
let createOptions = arguments[1];
|
|
80
147
|
storeName = String(storeName); // W3C test within IDBObjectStore.js seems to accept string conversion
|
|
@@ -104,7 +171,7 @@ IDBDatabase.prototype.createObjectStore = function (storeName /* , createOptions
|
|
|
104
171
|
throw createDOMException('InvalidAccessError', 'With autoIncrement set, the keyPath argument must not be an array or empty string.');
|
|
105
172
|
}
|
|
106
173
|
|
|
107
|
-
/** @
|
|
174
|
+
/** @type {IDBObjectStoreProperties} */
|
|
108
175
|
const storeProperties = {
|
|
109
176
|
name: storeName,
|
|
110
177
|
keyPath,
|
|
@@ -120,6 +187,7 @@ IDBDatabase.prototype.createObjectStore = function (storeName /* , createOptions
|
|
|
120
187
|
* Deletes an object store.
|
|
121
188
|
* @param {string} storeName
|
|
122
189
|
* @throws {TypeError|DOMException}
|
|
190
|
+
* @this {IDBDatabaseFull}
|
|
123
191
|
* @returns {void}
|
|
124
192
|
*/
|
|
125
193
|
IDBDatabase.prototype.deleteObjectStore = function (storeName) {
|
|
@@ -141,6 +209,11 @@ IDBDatabase.prototype.deleteObjectStore = function (storeName) {
|
|
|
141
209
|
IDBObjectStore.__deleteObjectStore(this, store);
|
|
142
210
|
};
|
|
143
211
|
|
|
212
|
+
/**
|
|
213
|
+
* @throws {TypeError}
|
|
214
|
+
* @this {IDBDatabaseFull}
|
|
215
|
+
* @returns {void}
|
|
216
|
+
*/
|
|
144
217
|
IDBDatabase.prototype.close = function () {
|
|
145
218
|
if (!(this instanceof IDBDatabase)) {
|
|
146
219
|
throw new TypeError('Illegal invocation');
|
|
@@ -151,15 +224,13 @@ IDBDatabase.prototype.close = function () {
|
|
|
151
224
|
}
|
|
152
225
|
};
|
|
153
226
|
|
|
154
|
-
/* eslint-disable jsdoc/check-param-names */
|
|
155
227
|
/**
|
|
156
228
|
* Starts a new transaction.
|
|
157
229
|
* @param {string|string[]} storeNames
|
|
158
|
-
* @
|
|
159
|
-
* @returns {IDBTransaction}
|
|
230
|
+
* @this {IDBDatabaseFull}
|
|
231
|
+
* @returns {import('./IDBTransaction.js').IDBTransactionFull}
|
|
160
232
|
*/
|
|
161
233
|
IDBDatabase.prototype.transaction = function (storeNames /* , mode */) {
|
|
162
|
-
/* eslint-enable jsdoc/check-param-names */
|
|
163
234
|
if (arguments.length === 0) {
|
|
164
235
|
throw new TypeError('You must supply a valid `storeNames` to `IDBDatabase.transaction`');
|
|
165
236
|
}
|
|
@@ -214,7 +285,12 @@ IDBDatabase.prototype.transaction = function (storeNames /* , mode */) {
|
|
|
214
285
|
return trans;
|
|
215
286
|
};
|
|
216
287
|
|
|
217
|
-
|
|
288
|
+
/**
|
|
289
|
+
* @see https://github.com/w3c/IndexedDB/issues/192
|
|
290
|
+
* @throws {DOMException}
|
|
291
|
+
* @this {IDBDatabaseFull}
|
|
292
|
+
* @returns {void}
|
|
293
|
+
*/
|
|
218
294
|
IDBDatabase.prototype.throwIfUpgradeTransactionNull = function () {
|
|
219
295
|
if (this.__upgradeTransaction === null) {
|
|
220
296
|
throw createDOMException('InvalidStateError', 'No upgrade transaction associated with database.');
|
|
@@ -225,6 +301,7 @@ IDBDatabase.prototype.throwIfUpgradeTransactionNull = function () {
|
|
|
225
301
|
/**
|
|
226
302
|
*
|
|
227
303
|
* @param {string} msg
|
|
304
|
+
* @this {IDBDatabaseFull}
|
|
228
305
|
* @returns {void}
|
|
229
306
|
*/
|
|
230
307
|
IDBDatabase.prototype.__forceClose = function (msg) {
|
|
@@ -232,6 +309,7 @@ IDBDatabase.prototype.__forceClose = function (msg) {
|
|
|
232
309
|
me.close();
|
|
233
310
|
let ct = 0;
|
|
234
311
|
me.__transactions.forEach(function (trans) {
|
|
312
|
+
// eslint-disable-next-line camelcase -- Clear API
|
|
235
313
|
trans.on__abort = function () {
|
|
236
314
|
ct++;
|
|
237
315
|
if (ct === me.__transactions.length) {
|