feat: complete Ancestor quote bot with production-ready Docker support
This commit is contained in:
71
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js
generated
vendored
71
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js
generated
vendored
@@ -1,4 +1,13 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.IndexedDBStoreWorker = void 0;
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var _indexeddbLocalBackend = require("./indexeddb-local-backend");
|
||||
var _logger = require("../logger");
|
||||
/*
|
||||
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
@@ -15,8 +24,6 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { LocalIndexedDBStoreBackend } from "./indexeddb-local-backend.js";
|
||||
import { logger } from "../logger.js";
|
||||
/**
|
||||
* This class lives in the webworker and drives a LocalIndexedDBStoreBackend
|
||||
* controlled by messages from the main process.
|
||||
@@ -34,14 +41,15 @@ import { logger } from "../logger.js";
|
||||
* avoid a dependency on the whole js-sdk.
|
||||
*
|
||||
*/
|
||||
export class IndexedDBStoreWorker {
|
||||
class IndexedDBStoreWorker {
|
||||
/**
|
||||
* @param postMessage - The web worker postMessage function that
|
||||
* should be used to communicate back to the main script.
|
||||
*/
|
||||
constructor(postMessage) {
|
||||
_defineProperty(this, "backend", void 0);
|
||||
_defineProperty(this, "onClose", () => {
|
||||
this.postMessage = postMessage;
|
||||
(0, _defineProperty2.default)(this, "backend", void 0);
|
||||
(0, _defineProperty2.default)(this, "onClose", () => {
|
||||
this.postMessage.call(null, {
|
||||
command: "closed"
|
||||
});
|
||||
@@ -52,72 +60,64 @@ export class IndexedDBStoreWorker {
|
||||
*
|
||||
* @param ev - The message event
|
||||
*/
|
||||
_defineProperty(this, "onMessage", ev => {
|
||||
(0, _defineProperty2.default)(this, "onMessage", ev => {
|
||||
var _this$backend, _this$backend2, _this$backend3, _this$backend4, _this$backend5, _this$backend6, _this$backend7, _this$backend8, _this$backend9, _this$backend10, _this$backend11, _this$backend12, _this$backend13, _this$backend14, _this$backend15, _this$backend16;
|
||||
const msg = ev.data;
|
||||
let prom;
|
||||
switch (msg.command) {
|
||||
case "setupWorker":
|
||||
// this is the 'indexedDB' global (where global != window
|
||||
// because it's a web worker and there is no window).
|
||||
this.backend = new LocalIndexedDBStoreBackend(indexedDB, msg.args[0]);
|
||||
this.backend = new _indexeddbLocalBackend.LocalIndexedDBStoreBackend(indexedDB, msg.args[0]);
|
||||
prom = Promise.resolve();
|
||||
break;
|
||||
case "connect":
|
||||
prom = this.backend?.connect(this.onClose);
|
||||
prom = (_this$backend = this.backend) === null || _this$backend === void 0 ? void 0 : _this$backend.connect(this.onClose);
|
||||
break;
|
||||
case "isNewlyCreated":
|
||||
prom = this.backend?.isNewlyCreated();
|
||||
prom = (_this$backend2 = this.backend) === null || _this$backend2 === void 0 ? void 0 : _this$backend2.isNewlyCreated();
|
||||
break;
|
||||
case "clearDatabase":
|
||||
prom = this.backend?.clearDatabase();
|
||||
prom = (_this$backend3 = this.backend) === null || _this$backend3 === void 0 ? void 0 : _this$backend3.clearDatabase();
|
||||
break;
|
||||
case "getSavedSync":
|
||||
prom = this.backend?.getSavedSync(false);
|
||||
prom = (_this$backend4 = this.backend) === null || _this$backend4 === void 0 ? void 0 : _this$backend4.getSavedSync(false);
|
||||
break;
|
||||
case "setSyncData":
|
||||
prom = this.backend?.setSyncData(msg.args[0]);
|
||||
prom = (_this$backend5 = this.backend) === null || _this$backend5 === void 0 ? void 0 : _this$backend5.setSyncData(msg.args[0]);
|
||||
break;
|
||||
case "syncToDatabase":
|
||||
prom = this.backend?.syncToDatabase(msg.args[0]);
|
||||
prom = (_this$backend6 = this.backend) === null || _this$backend6 === void 0 ? void 0 : _this$backend6.syncToDatabase(msg.args[0]);
|
||||
break;
|
||||
case "getUserPresenceEvents":
|
||||
prom = this.backend?.getUserPresenceEvents();
|
||||
prom = (_this$backend7 = this.backend) === null || _this$backend7 === void 0 ? void 0 : _this$backend7.getUserPresenceEvents();
|
||||
break;
|
||||
case "getNextBatchToken":
|
||||
prom = this.backend?.getNextBatchToken();
|
||||
prom = (_this$backend8 = this.backend) === null || _this$backend8 === void 0 ? void 0 : _this$backend8.getNextBatchToken();
|
||||
break;
|
||||
case "getOutOfBandMembers":
|
||||
prom = this.backend?.getOutOfBandMembers(msg.args[0]);
|
||||
prom = (_this$backend9 = this.backend) === null || _this$backend9 === void 0 ? void 0 : _this$backend9.getOutOfBandMembers(msg.args[0]);
|
||||
break;
|
||||
case "clearOutOfBandMembers":
|
||||
prom = this.backend?.clearOutOfBandMembers(msg.args[0]);
|
||||
prom = (_this$backend10 = this.backend) === null || _this$backend10 === void 0 ? void 0 : _this$backend10.clearOutOfBandMembers(msg.args[0]);
|
||||
break;
|
||||
case "setOutOfBandMembers":
|
||||
prom = this.backend?.setOutOfBandMembers(msg.args[0], msg.args[1]);
|
||||
prom = (_this$backend11 = this.backend) === null || _this$backend11 === void 0 ? void 0 : _this$backend11.setOutOfBandMembers(msg.args[0], msg.args[1]);
|
||||
break;
|
||||
case "getClientOptions":
|
||||
prom = this.backend?.getClientOptions();
|
||||
prom = (_this$backend12 = this.backend) === null || _this$backend12 === void 0 ? void 0 : _this$backend12.getClientOptions();
|
||||
break;
|
||||
case "storeClientOptions":
|
||||
prom = this.backend?.storeClientOptions(msg.args[0]);
|
||||
prom = (_this$backend13 = this.backend) === null || _this$backend13 === void 0 ? void 0 : _this$backend13.storeClientOptions(msg.args[0]);
|
||||
break;
|
||||
case "saveToDeviceBatches":
|
||||
prom = this.backend?.saveToDeviceBatches(msg.args[0]);
|
||||
prom = (_this$backend14 = this.backend) === null || _this$backend14 === void 0 ? void 0 : _this$backend14.saveToDeviceBatches(msg.args[0]);
|
||||
break;
|
||||
case "getOldestToDeviceBatch":
|
||||
prom = this.backend?.getOldestToDeviceBatch();
|
||||
prom = (_this$backend15 = this.backend) === null || _this$backend15 === void 0 ? void 0 : _this$backend15.getOldestToDeviceBatch();
|
||||
break;
|
||||
case "removeToDeviceBatch":
|
||||
prom = this.backend?.removeToDeviceBatch(msg.args[0]);
|
||||
break;
|
||||
case "getUserProfile":
|
||||
prom = this.backend?.getUserProfile(msg.args[0]);
|
||||
break;
|
||||
case "storeUserProfiles":
|
||||
prom = this.backend?.storeUserProfiles(msg.args[0]);
|
||||
break;
|
||||
case "removeUserProfiles":
|
||||
prom = this.backend?.removeUserProfiles(msg.args[0]);
|
||||
prom = (_this$backend16 = this.backend) === null || _this$backend16 === void 0 ? void 0 : _this$backend16.removeToDeviceBatch(msg.args[0]);
|
||||
break;
|
||||
}
|
||||
if (prom === undefined) {
|
||||
@@ -126,7 +126,6 @@ export class IndexedDBStoreWorker {
|
||||
seq: msg.seq,
|
||||
// Can't be an Error because they're not structured cloneable
|
||||
error: "Unrecognised command"
|
||||
// oxlint-disable-next-line unicorn/require-post-message-target-origin
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -137,7 +136,7 @@ export class IndexedDBStoreWorker {
|
||||
result: ret
|
||||
});
|
||||
}, err => {
|
||||
logger.error("Error running command: " + msg.command, err);
|
||||
_logger.logger.error("Error running command: " + msg.command, err);
|
||||
this.postMessage.call(null, {
|
||||
command: "cmd_fail",
|
||||
seq: msg.seq,
|
||||
@@ -149,7 +148,7 @@ export class IndexedDBStoreWorker {
|
||||
});
|
||||
});
|
||||
});
|
||||
this.postMessage = postMessage;
|
||||
}
|
||||
}
|
||||
exports.IndexedDBStoreWorker = IndexedDBStoreWorker;
|
||||
//# sourceMappingURL=indexeddb-store-worker.js.map
|
||||
Reference in New Issue
Block a user