fake-indexeddb 6.2.0 → 6.2.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/build/cjs/FDBDatabase.js
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _FDBTransaction = _interopRequireDefault(require("./FDBTransaction.js"));
|
|
8
8
|
var _errors = require("./lib/errors.js");
|
|
9
9
|
var _FakeDOMStringList = _interopRequireDefault(require("./lib/FakeDOMStringList.js"));
|
|
10
10
|
var _FakeEventTarget = _interopRequireDefault(require("./lib/FakeEventTarget.js"));
|
|
11
11
|
var _ObjectStore = _interopRequireDefault(require("./lib/ObjectStore.js"));
|
|
12
|
-
var _scheduling = require("./lib/scheduling.js");
|
|
13
12
|
var _validateKeyPath = _interopRequireDefault(require("./lib/validateKeyPath.js"));
|
|
14
|
-
var
|
|
13
|
+
var _closeConnection = _interopRequireDefault(require("./lib/closeConnection.js"));
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
const confirmActiveVersionchangeTransaction = database => {
|
|
17
16
|
if (!database._runningVersionchangeTransaction) {
|
|
@@ -32,34 +31,7 @@ const confirmActiveVersionchangeTransaction = database => {
|
|
|
32
31
|
return transaction;
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#database-closing-steps
|
|
36
|
-
const closeConnection = (connection, forced = false) => {
|
|
37
|
-
connection._closePending = true;
|
|
38
|
-
const transactionsComplete = connection._rawDatabase.transactions.every(transaction => {
|
|
39
|
-
return transaction._state === "finished";
|
|
40
|
-
});
|
|
41
|
-
if (transactionsComplete) {
|
|
42
|
-
connection._closed = true;
|
|
43
|
-
connection._rawDatabase.connections = connection._rawDatabase.connections.filter(otherConnection => {
|
|
44
|
-
return connection !== otherConnection;
|
|
45
|
-
});
|
|
46
|
-
if (forced) {
|
|
47
|
-
const event = new _FakeEvent.default("close", {
|
|
48
|
-
bubbles: false,
|
|
49
|
-
cancelable: false
|
|
50
|
-
});
|
|
51
|
-
event.eventPath = [];
|
|
52
|
-
connection.dispatchEvent(event);
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
(0, _scheduling.queueTask)(() => {
|
|
56
|
-
closeConnection(connection, forced);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
34
|
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#database-interface
|
|
62
|
-
exports.closeConnection = closeConnection;
|
|
63
35
|
class FDBDatabase extends _FakeEventTarget.default {
|
|
64
36
|
_closePending = false;
|
|
65
37
|
_closed = false;
|
|
@@ -172,10 +144,11 @@ class FDBDatabase extends _FakeEventTarget.default {
|
|
|
172
144
|
return tx;
|
|
173
145
|
}
|
|
174
146
|
close() {
|
|
175
|
-
|
|
147
|
+
(0, _closeConnection.default)(this);
|
|
176
148
|
}
|
|
177
149
|
get [Symbol.toStringTag]() {
|
|
178
150
|
return "IDBDatabase";
|
|
179
151
|
}
|
|
180
152
|
}
|
|
181
|
-
var _default = exports.default = FDBDatabase;
|
|
153
|
+
var _default = exports.default = FDBDatabase;
|
|
154
|
+
module.exports = exports.default;
|
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = forceCloseDatabase;
|
|
7
|
-
var
|
|
7
|
+
var _closeConnection = _interopRequireDefault(require("./lib/closeConnection.js"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
/**
|
|
9
10
|
* Forcibly closes a database. This simulates a database being closed due to abnormal reasons, such as
|
|
10
11
|
* using DevTools to clear data while a database is open. Spec-wise, this is equivalent to
|
|
@@ -23,6 +24,6 @@ var _FDBDatabase = require("./FDBDatabase.js");
|
|
|
23
24
|
* @param db
|
|
24
25
|
*/
|
|
25
26
|
function forceCloseDatabase(db) {
|
|
26
|
-
(0,
|
|
27
|
+
(0, _closeConnection.default)(db, true);
|
|
27
28
|
}
|
|
28
29
|
module.exports = exports.default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _FakeEvent = _interopRequireDefault(require("./FakeEvent.js"));
|
|
8
|
+
var _scheduling = require("./scheduling.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#database-closing-steps
|
|
11
|
+
const closeConnection = (connection, forced = false) => {
|
|
12
|
+
connection._closePending = true;
|
|
13
|
+
const transactionsComplete = connection._rawDatabase.transactions.every(transaction => {
|
|
14
|
+
return transaction._state === "finished";
|
|
15
|
+
});
|
|
16
|
+
if (transactionsComplete) {
|
|
17
|
+
connection._closed = true;
|
|
18
|
+
connection._rawDatabase.connections = connection._rawDatabase.connections.filter(otherConnection => {
|
|
19
|
+
return connection !== otherConnection;
|
|
20
|
+
});
|
|
21
|
+
if (forced) {
|
|
22
|
+
const event = new _FakeEvent.default("close", {
|
|
23
|
+
bubbles: false,
|
|
24
|
+
cancelable: false
|
|
25
|
+
});
|
|
26
|
+
event.eventPath = [];
|
|
27
|
+
connection.dispatchEvent(event);
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
(0, _scheduling.queueTask)(() => {
|
|
31
|
+
closeConnection(connection, forced);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var _default = exports.default = closeConnection;
|
|
36
|
+
module.exports = exports.default;
|
package/build/esm/FDBDatabase.js
CHANGED
|
@@ -3,9 +3,8 @@ import { ConstraintError, InvalidAccessError, InvalidStateError, NotFoundError,
|
|
|
3
3
|
import FakeDOMStringList from "./lib/FakeDOMStringList.js";
|
|
4
4
|
import FakeEventTarget from "./lib/FakeEventTarget.js";
|
|
5
5
|
import ObjectStore from "./lib/ObjectStore.js";
|
|
6
|
-
import { queueTask } from "./lib/scheduling.js";
|
|
7
6
|
import validateKeyPath from "./lib/validateKeyPath.js";
|
|
8
|
-
import
|
|
7
|
+
import closeConnection from "./lib/closeConnection.js";
|
|
9
8
|
const confirmActiveVersionchangeTransaction = database => {
|
|
10
9
|
if (!database._runningVersionchangeTransaction) {
|
|
11
10
|
throw new InvalidStateError();
|
|
@@ -25,32 +24,6 @@ const confirmActiveVersionchangeTransaction = database => {
|
|
|
25
24
|
return transaction;
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#database-closing-steps
|
|
29
|
-
export const closeConnection = (connection, forced = false) => {
|
|
30
|
-
connection._closePending = true;
|
|
31
|
-
const transactionsComplete = connection._rawDatabase.transactions.every(transaction => {
|
|
32
|
-
return transaction._state === "finished";
|
|
33
|
-
});
|
|
34
|
-
if (transactionsComplete) {
|
|
35
|
-
connection._closed = true;
|
|
36
|
-
connection._rawDatabase.connections = connection._rawDatabase.connections.filter(otherConnection => {
|
|
37
|
-
return connection !== otherConnection;
|
|
38
|
-
});
|
|
39
|
-
if (forced) {
|
|
40
|
-
const event = new FakeEvent("close", {
|
|
41
|
-
bubbles: false,
|
|
42
|
-
cancelable: false
|
|
43
|
-
});
|
|
44
|
-
event.eventPath = [];
|
|
45
|
-
connection.dispatchEvent(event);
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
queueTask(() => {
|
|
49
|
-
closeConnection(connection, forced);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
27
|
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#database-interface
|
|
55
28
|
class FDBDatabase extends FakeEventTarget {
|
|
56
29
|
_closePending = false;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import FakeEvent from "./FakeEvent.js";
|
|
2
|
+
import { queueTask } from "./scheduling.js";
|
|
3
|
+
// http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#database-closing-steps
|
|
4
|
+
const closeConnection = (connection, forced = false) => {
|
|
5
|
+
connection._closePending = true;
|
|
6
|
+
const transactionsComplete = connection._rawDatabase.transactions.every(transaction => {
|
|
7
|
+
return transaction._state === "finished";
|
|
8
|
+
});
|
|
9
|
+
if (transactionsComplete) {
|
|
10
|
+
connection._closed = true;
|
|
11
|
+
connection._rawDatabase.connections = connection._rawDatabase.connections.filter(otherConnection => {
|
|
12
|
+
return connection !== otherConnection;
|
|
13
|
+
});
|
|
14
|
+
if (forced) {
|
|
15
|
+
const event = new FakeEvent("close", {
|
|
16
|
+
bubbles: false,
|
|
17
|
+
cancelable: false
|
|
18
|
+
});
|
|
19
|
+
event.eventPath = [];
|
|
20
|
+
connection.dispatchEvent(event);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
queueTask(() => {
|
|
24
|
+
closeConnection(connection, forced);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export default closeConnection;
|
package/package.json
CHANGED