feat: complete Ancestor quote bot with production-ready Docker support

This commit is contained in:
unfunny
2026-09-13 14:14:38 -04:00
parent f2016da05a
commit fe7351a7dc
1145 changed files with 30890 additions and 97684 deletions

View File

@@ -1,20 +1,19 @@
import { type EventType } from "../@types/event.ts";
import { type Room } from "../models/room.ts";
import { type SyncUserProfile, type User } from "../models/user.ts";
import { type IEvent, type MatrixEvent } from "../models/event.ts";
import { type Filter } from "../filter.ts";
import { type RoomSummary } from "../models/room-summary.ts";
import { type IMinimalEvent, type IRooms, type ISyncResponse } from "../sync-accumulator.ts";
import { type IStartClientOpts } from "../client.ts";
import { type IStateEventWithRoomId } from "../@types/search.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage.ts";
import { type EventEmitterEvents } from "../models/typed-event-emitter.ts";
import { EventType } from "../@types/event";
import { Room } from "../models/room";
import { User } from "../models/user";
import { IEvent, MatrixEvent } from "../models/event";
import { Filter } from "../filter";
import { RoomSummary } from "../models/room-summary";
import { IMinimalEvent, IRooms, ISyncResponse } from "../sync-accumulator";
import { IStartClientOpts } from "../client";
import { IStateEventWithRoomId } from "../@types/search";
import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage";
import { EventEmitterEvents } from "../models/typed-event-emitter";
export interface ISavedSync {
nextBatch: string;
roomsData: IRooms;
accountData: IMinimalEvent[];
}
export type UserCreator = (userId: string) => User;
/**
* A store for most of the data js-sdk needs to store, apart from crypto data
*/
@@ -36,11 +35,6 @@ export interface IStore {
* @param room - The room to be stored. All properties must be stored.
*/
storeRoom(room: Room): void;
/**
* Set the user creator which is used for creating User objects
* @param creator - A callback that accepts an user-id and returns an User object
*/
setUserCreator(creator: UserCreator): void;
/**
* Retrieve a room by its' room ID.
* @param roomId - The room ID.
@@ -193,29 +187,6 @@ export interface IStore {
* Removes a specific batch of to-device messages from the queue
*/
removeToDeviceBatch(id: number): Promise<void>;
/**
* Store user profile details from a sync. Existing profiles will be overwritten.
* @param userProfiles - A map of userIds to profiles.
*/
storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;
/**
* Delete stored profiles for the given users.
* @param userIds - The user IDs whose profiles should be deleted.
*/
removeUserProfiles(userIds: string[]): Promise<void>;
/**
* Retrieve a stored user profile for the given user ID, if it exists.
* @param userId - The user ID to retrieve the profile for.
* @returns The stored profile, or undefined if no profile is stored for this user ID.
*/
getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;
/**
* Remove all stored events matching the given IDs from the stored accumulated
* sync.
* @param roomId The target room.
* @param eventIds IDs of events to remove.
*/
removeEventsFromRoom(roomId: string, eventIds: string[]): Promise<void>;
/**
* Stop the store and perform any appropriate cleanup
*/

View File

@@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,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AC;IAErD,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IAE1D,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAE7D,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;OAEG;IACH,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAE/D;;OAEG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B"}

View File

@@ -1,3 +1,6 @@
export {};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,6 @@
import { type ISavedSync } from "./index.ts";
import { type IEvent, type IStateEventWithRoomId, type IStoredClientOpts, type ISyncResponse } from "../matrix.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage.ts";
import { type SyncUserProfile } from "../models/user.ts";
import { ISavedSync } from "./index";
import { IEvent, IStateEventWithRoomId, IStoredClientOpts, ISyncResponse } from "../matrix";
import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage";
export interface IIndexedDBBackend {
connect(onClose?: () => void): Promise<void>;
syncToDatabase(userTuples: UserTuple[]): Promise<void>;
@@ -19,9 +18,6 @@ export interface IIndexedDBBackend {
saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
removeToDeviceBatch(id: number): Promise<void>;
getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;
storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;
removeUserProfiles(userIds: string[]): Promise<void>;
destroy(): Promise<void>;
}
export type UserTuple = [userId: string, presenceEvent: Partial<IEvent>];

View File

@@ -1 +1 @@
{"version":3,"file":"indexeddb-backend.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb-backend.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAC9B,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,YAAY,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC3C,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,mBAAmB,CAAC,MAAM,EAAE,MAAM,G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C,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAC/D,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC"}

View File

@@ -1,3 +1,6 @@
export {};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=indexeddb-backend.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"indexeddb-backend.js","names":[],"sources":["../../src/store/indexeddb-backend.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type ISavedSync } from \"./index.ts\";\nimport { type IEvent, type IStateEventWithRoomId, type IStoredClientOpts, type ISyncResponse } from \"../matrix.ts\";\nimport { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from \"../models/ToDeviceMessage.ts\";\nimport { type SyncUserProfile } from \"../models/user.ts\";\n\nexport interface IIndexedDBBackend {\n connect(onClose?: () => void): Promise<void>;\n syncToDatabase(userTuples: UserTuple[]): Promise<void>;\n isNewlyCreated(): Promise<boolean>;\n setSyncData(syncData: ISyncResponse): Promise<void>;\n getSavedSync(): Promise<ISavedSync | null>;\n getNextBatchToken(): Promise<string>;\n clearDatabase(): Promise<void>;\n getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;\n setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;\n clearOutOfBandMembers(roomId: string): Promise<void>;\n getUserPresenceEvents(): Promise<UserTuple[]>;\n getClientOptions(): Promise<IStoredClientOpts | undefined>;\n storeClientOptions(options: IStoredClientOpts): Promise<void>;\n saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;\n getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;\n removeToDeviceBatch(id: number): Promise<void>;\n getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;\n storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;\n removeUserProfiles(userIds: string[]): Promise<void>;\n destroy(): Promise<void>;\n}\n\nexport type UserTuple = [userId: string, presenceEvent: Partial<IEvent>];\n"],"mappings":"","ignoreList":[]}
{"version":3,"file":"indexeddb-backend.js","names":[],"sources":["../../src/store/indexeddb-backend.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { ISavedSync } from \"./index\";\nimport { IEvent, IStateEventWithRoomId, IStoredClientOpts, ISyncResponse } from \"../matrix\";\nimport { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from \"../models/ToDeviceMessage\";\n\nexport interface IIndexedDBBackend {\n connect(onClose?: () => void): Promise<void>;\n syncToDatabase(userTuples: UserTuple[]): Promise<void>;\n isNewlyCreated(): Promise<boolean>;\n setSyncData(syncData: ISyncResponse): Promise<void>;\n getSavedSync(): Promise<ISavedSync | null>;\n getNextBatchToken(): Promise<string>;\n clearDatabase(): Promise<void>;\n getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;\n setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;\n clearOutOfBandMembers(roomId: string): Promise<void>;\n getUserPresenceEvents(): Promise<UserTuple[]>;\n getClientOptions(): Promise<IStoredClientOpts | undefined>;\n storeClientOptions(options: IStoredClientOpts): Promise<void>;\n saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;\n getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;\n removeToDeviceBatch(id: number): Promise<void>;\n destroy(): Promise<void>;\n}\n\nexport type UserTuple = [userId: string, presenceEvent: Partial<IEvent>];\n"],"mappings":""}

View File

@@ -1,8 +1,8 @@
import { type ISyncResponse } from "../sync-accumulator.ts";
import type { SyncUserProfile, IStateEventWithRoomId, IStoredClientOpts } from "../matrix.ts";
import { type ISavedSync } from "./index.ts";
import { type IIndexedDBBackend, type UserTuple } from "./indexeddb-backend.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage.ts";
import { ISyncResponse } from "../sync-accumulator";
import { IStateEventWithRoomId, IStoredClientOpts } from "../matrix";
import { ISavedSync } from "./index";
import { IIndexedDBBackend, UserTuple } from "./indexeddb-backend";
import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage";
export declare class LocalIndexedDBStoreBackend implements IIndexedDBBackend {
private readonly indexedDB;
static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean>;
@@ -124,10 +124,6 @@ export declare class LocalIndexedDBStoreBackend implements IIndexedDBBackend {
saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
removeToDeviceBatch(id: number): Promise<void>;
getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;
storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;
removeUserProfiles(userIds: string[]): Promise<void>;
removeEventsFromRoom(roomId: string, eventIds: string[]): Promise<void>;
destroy(): Promise<void>;
}
//# sourceMappingURL=indexeddb-local-backend.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"indexeddb-local-backend.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb-local-backend.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAsC,KAAK,aAAa,EAAmB,MAAM,wBAAwB,CAAC;AAIjH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAsGtG,qBAAa,0BAA2B,YAAW,iBAAiB;IAyB5D,OAAO,CAAC,QAAQ,CAAC,SAAS;IAxB9B,OAAc,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG5E;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,EAAE,CAAC,CAAc;IACzB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,qBAAqB,CAAC,CAAgB;IAC9C,OAAO,CAAC,uBAAuB,CAAmB;IAElD;;;;;;;;;OASG;IACH,YACqB,SAAS,EAAE,UAAU,EACtC,MAAM,SAAY,EAIrB;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA+ClD;IAED,8EAA8E;IACvE,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAExC;IAED;;;OAG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C,yBAAyB;IAcjC;;;;;OAKG;IACI,qBAAqB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAUpD;;;OAGG;IACH,OAAO,CAAC,eAAe;IAcvB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAiBb,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAUpD,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7D,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IASrE,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAgB9D,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}

View File

@@ -1,4 +1,15 @@
import _defineProperty from "@babel/runtime/helpers/defineProperty";
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LocalIndexedDBStoreBackend = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _syncAccumulator = require("../sync-accumulator");
var _utils = require("../utils");
var _indexeddbHelpers = require("../indexeddb-helpers");
var _logger = require("../logger");
/*
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
@@ -15,10 +26,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { SyncAccumulator } from "../sync-accumulator.js";
import { deepCopy, promiseTry } from "../utils.js";
import { exists as idbExists } from "../indexeddb-helpers.js";
import { logger } from "../logger.js";
const DB_MIGRATIONS = [db => {
// Make user store, clobber based on user ID. (userId property of User objects)
db.createObjectStore("users", {
@@ -48,13 +55,10 @@ const DB_MIGRATIONS = [db => {
db.createObjectStore("to_device_queue", {
autoIncrement: true
});
}, db => {
db.createObjectStore("user_profile", {
keyPath: ["userId"]
});
}
// Expand as needed.
];
const VERSION = DB_MIGRATIONS.length;
/**
@@ -66,16 +70,13 @@ const VERSION = DB_MIGRATIONS.length;
* Return the data you want to keep.
* @returns Promise which resolves to an array of whatever you returned from
* resultMapper.
* @throws If there was an error completing the query.
*/
function selectQuery(store, keyRange, resultMapper) {
const query = store.openCursor(keyRange);
return new Promise((resolve, reject) => {
const results = [];
query.onerror = () => {
reject(new Error(`selectQuery failed for ${store.name}`, {
cause: query.error
}));
reject(new Error("Query failed: " + query.error));
};
// collect results
query.onsuccess = () => {
@@ -84,6 +85,7 @@ function selectQuery(store, keyRange, resultMapper) {
resolve(results);
return; // end of results
}
results.push(resultMapper(cursor));
cursor.continue();
};
@@ -118,10 +120,10 @@ function reqAsPromise(req) {
function reqAsCursorPromise(req) {
return reqAsEventPromise(req).then(event => req.result);
}
export class LocalIndexedDBStoreBackend {
class LocalIndexedDBStoreBackend {
static exists(indexedDB, dbName) {
dbName = "matrix-js-sdk:" + (dbName || "default");
return idbExists(indexedDB, dbName);
return (0, _indexeddbHelpers.exists)(indexedDB, dbName);
}
/**
* Does the actual reading from and writing to the indexeddb
@@ -134,16 +136,16 @@ export class LocalIndexedDBStoreBackend {
* to open the same database.
*/
constructor(indexedDB, dbName = "default") {
_defineProperty(this, "dbName", void 0);
_defineProperty(this, "syncAccumulator", void 0);
_defineProperty(this, "db", void 0);
_defineProperty(this, "disconnected", true);
_defineProperty(this, "_isNewlyCreated", false);
_defineProperty(this, "syncToDatabasePromise", void 0);
_defineProperty(this, "pendingUserPresenceData", []);
this.indexedDB = indexedDB;
(0, _defineProperty2.default)(this, "dbName", void 0);
(0, _defineProperty2.default)(this, "syncAccumulator", void 0);
(0, _defineProperty2.default)(this, "db", void 0);
(0, _defineProperty2.default)(this, "disconnected", true);
(0, _defineProperty2.default)(this, "_isNewlyCreated", false);
(0, _defineProperty2.default)(this, "syncToDatabasePromise", void 0);
(0, _defineProperty2.default)(this, "pendingUserPresenceData", []);
this.dbName = "matrix-js-sdk:" + dbName;
this.syncAccumulator = new SyncAccumulator();
this.syncAccumulator = new _syncAccumulator.SyncAccumulator();
}
/**
@@ -153,16 +155,16 @@ export class LocalIndexedDBStoreBackend {
*/
connect(onClose) {
if (!this.disconnected) {
logger.log(`LocalIndexedDBStoreBackend.connect: already connected or connecting`);
_logger.logger.log(`LocalIndexedDBStoreBackend.connect: already connected or connecting`);
return Promise.resolve();
}
this.disconnected = false;
logger.log(`LocalIndexedDBStoreBackend.connect: connecting...`);
_logger.logger.log(`LocalIndexedDBStoreBackend.connect: connecting...`);
const req = this.indexedDB.open(this.dbName, VERSION);
req.onupgradeneeded = ev => {
const db = req.result;
const oldVersion = ev.oldVersion;
logger.log(`LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`);
_logger.logger.log(`LocalIndexedDBStoreBackend.connect: upgrading from ${oldVersion}`);
if (oldVersion < 1) {
// The database did not previously exist
this._isNewlyCreated = true;
@@ -172,24 +174,26 @@ export class LocalIndexedDBStoreBackend {
});
};
req.onblocked = () => {
logger.log(`can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`);
_logger.logger.log(`can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`);
};
logger.log(`LocalIndexedDBStoreBackend.connect: awaiting connection...`);
_logger.logger.log(`LocalIndexedDBStoreBackend.connect: awaiting connection...`);
return reqAsEventPromise(req).then(async () => {
logger.log(`LocalIndexedDBStoreBackend.connect: connected`);
_logger.logger.log(`LocalIndexedDBStoreBackend.connect: connected`);
this.db = req.result;
// add a poorly-named listener for when deleteDatabase is called
// so we can close our db connections.
this.db.onversionchange = () => {
this.db?.close(); // this does not call onclose
var _this$db;
(_this$db = this.db) === null || _this$db === void 0 ? void 0 : _this$db.close(); // this does not call onclose
this.disconnected = true;
this.db = undefined;
onClose === null || onClose === void 0 ? void 0 : onClose();
};
this.db.onclose = () => {
this.disconnected = true;
this.db = undefined;
onClose?.();
onClose === null || onClose === void 0 ? void 0 : onClose();
};
await this.init();
});
@@ -206,7 +210,7 @@ export class LocalIndexedDBStoreBackend {
*/
init() {
return Promise.all([this.loadAccountData(), this.loadSyncData()]).then(([accountData, syncData]) => {
logger.log(`LocalIndexedDBStoreBackend: loaded initial data`);
_logger.logger.log(`LocalIndexedDBStoreBackend: loaded initial data`);
this.syncAccumulator.accumulate({
next_batch: syncData.nextBatch,
rooms: syncData.roomsData,
@@ -258,7 +262,7 @@ export class LocalIndexedDBStoreBackend {
reject(err);
};
}).then(events => {
logger.log(`LL: got ${events?.length} membershipEvents from storage for room ${roomId} ...`);
_logger.logger.log(`LL: got ${events === null || events === void 0 ? void 0 : events.length} membershipEvents from storage for room ${roomId} ...`);
return events;
});
}
@@ -270,7 +274,7 @@ export class LocalIndexedDBStoreBackend {
* @param membershipEvents - the membership events to store
*/
async setOutOfBandMembers(roomId, membershipEvents) {
logger.log(`LL: backend about to store ${membershipEvents.length} members for ${roomId}`);
_logger.logger.log(`LL: backend about to store ${membershipEvents.length}` + ` members for ${roomId}`);
const tx = this.db.transaction(["oob_membership_events"], "readwrite");
const store = tx.objectStore("oob_membership_events");
membershipEvents.forEach(e => {
@@ -288,7 +292,7 @@ export class LocalIndexedDBStoreBackend {
};
store.put(markerObject);
await txnAsPromise(tx);
logger.log(`LL: backend done storing for ${roomId}!`);
_logger.logger.log(`LL: backend done storing for ${roomId}!`);
}
async clearOutOfBandMembers(roomId) {
// the approach to delete all members for a room
@@ -301,13 +305,13 @@ export class LocalIndexedDBStoreBackend {
const store = readTx.objectStore("oob_membership_events");
const roomIndex = store.index("room");
const roomRange = IDBKeyRange.only(roomId);
const minStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, "next")).then(cursor => cursor?.primaryKey?.[1]);
const maxStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, "prev")).then(cursor => cursor?.primaryKey?.[1]);
const minStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, "next")).then(cursor => (cursor === null || cursor === void 0 ? void 0 : cursor.primaryKey)[1]);
const maxStateKeyProm = reqAsCursorPromise(roomIndex.openKeyCursor(roomRange, "prev")).then(cursor => (cursor === null || cursor === void 0 ? void 0 : cursor.primaryKey)[1]);
const [minStateKey, maxStateKey] = await Promise.all([minStateKeyProm, maxStateKeyProm]);
const writeTx = this.db.transaction(["oob_membership_events"], "readwrite");
const writeStore = writeTx.objectStore("oob_membership_events");
const membersKeyRange = IDBKeyRange.bound([roomId, minStateKey], [roomId, maxStateKey]);
logger.log(`LL: Deleting all users + marker in storage for room ${roomId}, with key range:`, [roomId, minStateKey], [roomId, maxStateKey]);
_logger.logger.log(`LL: Deleting all users + marker in storage for room ${roomId}, with key range:`, [roomId, minStateKey], [roomId, maxStateKey]);
await reqAsPromise(writeStore.delete(membersKeyRange));
}
@@ -318,23 +322,24 @@ export class LocalIndexedDBStoreBackend {
*/
clearDatabase() {
return new Promise(resolve => {
logger.log(`Removing indexeddb instance: ${this.dbName}`);
var _this$db2;
_logger.logger.log(`Removing indexeddb instance: ${this.dbName}`);
// Close the database first to avoid firing unexpected close events
this.db?.close();
(_this$db2 = this.db) === null || _this$db2 === void 0 ? void 0 : _this$db2.close();
const req = this.indexedDB.deleteDatabase(this.dbName);
req.onblocked = () => {
logger.log(`can't yet delete indexeddb ${this.dbName} because it is open elsewhere`);
_logger.logger.log(`can't yet delete indexeddb ${this.dbName} because it is open elsewhere`);
};
req.onerror = () => {
// in firefox, with indexedDB disabled, this fails with a
// DOMError. We treat this as non-fatal, so that we can still
// use the app.
logger.warn(`unable to delete js-sdk store indexeddb: ${req.error?.name}`);
_logger.logger.warn(`unable to delete js-sdk store indexeddb: ${req.error}`);
resolve();
};
req.onsuccess = () => {
logger.log(`Removed indexeddb instance: ${this.dbName}`);
_logger.logger.log(`Removed indexeddb instance: ${this.dbName}`);
resolve();
};
});
@@ -355,7 +360,7 @@ export class LocalIndexedDBStoreBackend {
if (copy) {
// We must deep copy the stored data so that the /sync processing code doesn't
// corrupt the internal state of the sync accumulator (it adds non-clonable keys)
return Promise.resolve(deepCopy(data));
return Promise.resolve((0, _utils.deepCopy)(data));
} else {
return Promise.resolve(data);
}
@@ -378,7 +383,7 @@ export class LocalIndexedDBStoreBackend {
*/
async syncToDatabase(userTuples) {
if (this.syncToDatabasePromise) {
logger.warn("Skipping syncToDatabase() as persist already in flight");
_logger.logger.warn("Skipping syncToDatabase() as persist already in flight");
this.pendingUserPresenceData.push(...userTuples);
return this.syncToDatabasePromise;
}
@@ -402,8 +407,8 @@ export class LocalIndexedDBStoreBackend {
* @returns Promise which resolves if the data was persisted.
*/
persistSyncData(nextBatch, roomsData) {
logger.log("Persisting sync data up to", nextBatch);
return promiseTry(() => {
_logger.logger.log("Persisting sync data up to", nextBatch);
return (0, _utils.promiseTry)(() => {
const txn = this.db.transaction(["sync"], "readwrite");
const store = txn.objectStore("sync");
store.put({
@@ -413,7 +418,7 @@ export class LocalIndexedDBStoreBackend {
roomsData
}); // put == UPSERT
return txnAsPromise(txn).then(() => {
logger.log("Persisted sync data up to", nextBatch);
_logger.logger.log("Persisted sync data up to", nextBatch);
});
});
}
@@ -425,12 +430,13 @@ export class LocalIndexedDBStoreBackend {
* @returns Promise which resolves if the events were persisted.
*/
persistAccountData(accountData) {
return promiseTry(() => {
return (0, _utils.promiseTry)(() => {
const txn = this.db.transaction(["accountData"], "readwrite");
const store = txn.objectStore("accountData");
for (const event of accountData) {
store.put(event); // put == UPSERT
}
return txnAsPromise(txn).then();
});
}
@@ -444,7 +450,7 @@ export class LocalIndexedDBStoreBackend {
* @returns Promise which resolves if the users were persisted.
*/
persistUserPresenceEvents(tuples) {
return promiseTry(() => {
return (0, _utils.promiseTry)(() => {
const txn = this.db.transaction(["users"], "readwrite");
const store = txn.objectStore("users");
for (const tuple of tuples) {
@@ -453,6 +459,7 @@ export class LocalIndexedDBStoreBackend {
event: tuple[1]
}); // put == UPSERT
}
return txnAsPromise(txn).then();
});
}
@@ -464,7 +471,7 @@ export class LocalIndexedDBStoreBackend {
* @returns A list of presence events in their raw form.
*/
getUserPresenceEvents() {
return promiseTry(() => {
return (0, _utils.promiseTry)(() => {
const txn = this.db.transaction(["users"], "readonly");
const store = txn.objectStore("users");
return selectQuery(store, undefined, cursor => {
@@ -478,14 +485,14 @@ export class LocalIndexedDBStoreBackend {
* @returns A list of raw global account events.
*/
loadAccountData() {
logger.log(`LocalIndexedDBStoreBackend: loading account data...`);
return promiseTry(() => {
_logger.logger.log(`LocalIndexedDBStoreBackend: loading account data...`);
return (0, _utils.promiseTry)(() => {
const txn = this.db.transaction(["accountData"], "readonly");
const store = txn.objectStore("accountData");
return selectQuery(store, undefined, cursor => {
return cursor.value;
}).then(result => {
logger.log(`LocalIndexedDBStoreBackend: loaded account data`);
_logger.logger.log(`LocalIndexedDBStoreBackend: loaded account data`);
return result;
});
});
@@ -496,16 +503,16 @@ export class LocalIndexedDBStoreBackend {
* @returns An object with "roomsData" and "nextBatch" keys.
*/
loadSyncData() {
logger.log(`LocalIndexedDBStoreBackend: loading sync data...`);
return promiseTry(() => {
_logger.logger.log(`LocalIndexedDBStoreBackend: loading sync data...`);
return (0, _utils.promiseTry)(() => {
const txn = this.db.transaction(["sync"], "readonly");
const store = txn.objectStore("sync");
return selectQuery(store, undefined, cursor => {
return cursor.value;
}).then(results => {
logger.log(`LocalIndexedDBStoreBackend: loaded sync data`);
_logger.logger.log(`LocalIndexedDBStoreBackend: loaded sync data`);
if (results.length > 1) {
logger.warn("loadSyncData: More than 1 sync row found.");
_logger.logger.warn("loadSyncData: More than 1 sync row found.");
}
return results.length > 0 ? results[0] : {};
});
@@ -516,7 +523,8 @@ export class LocalIndexedDBStoreBackend {
const txn = this.db.transaction(["client_options"], "readonly");
const store = txn.objectStore("client_options");
return selectQuery(store, undefined, cursor => {
return cursor.value?.options;
var _cursor$value;
return (_cursor$value = cursor.value) === null || _cursor$value === void 0 ? void 0 : _cursor$value.options;
}).then(results => results[0]);
});
}
@@ -557,49 +565,14 @@ export class LocalIndexedDBStoreBackend {
store.delete(id);
await txnAsPromise(txn);
}
async getUserProfile(userId) {
return Promise.resolve().then(() => {
const txn = this.db.transaction(["user_profile"], "readonly");
const store = txn.objectStore("user_profile");
return selectQuery(store, [userId], cursor => {
return cursor.value?.profile;
}).then(results => results[0]);
});
}
async storeUserProfiles(userProfiles) {
const txn = this.db.transaction(["user_profile"], "readwrite");
const store = txn.objectStore("user_profile");
for (const [userId, profile] of userProfiles.entries()) {
store.put({
profile,
userId
});
}
await txnAsPromise(txn);
}
async removeUserProfiles(userIds) {
const txn = this.db.transaction(["user_profile"], "readwrite");
const store = txn.objectStore("user_profile");
for (const userId of userIds) {
store.delete([userId]);
}
await txnAsPromise(txn);
}
async removeEventsFromRoom(roomId, eventIds) {
try {
this.syncAccumulator.removeEventsFromRoom(roomId, eventIds);
const syncData = this.syncAccumulator.getJSON(true);
await this.persistSyncData(syncData.nextBatch, syncData.roomsData);
} finally {
this.syncToDatabasePromise = undefined;
}
}
/*
* Close the database
*/
async destroy() {
this.db?.close();
var _this$db3;
(_this$db3 = this.db) === null || _this$db3 === void 0 ? void 0 : _this$db3.close();
}
}
exports.LocalIndexedDBStoreBackend = LocalIndexedDBStoreBackend;
//# sourceMappingURL=indexeddb-local-backend.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +1,15 @@
import { type ISavedSync } from "./index.ts";
import { type IStoredClientOpts } from "../client.ts";
import { type IStateEventWithRoomId, type ISyncResponse } from "../matrix.ts";
import { type IIndexedDBBackend, type UserTuple } from "./indexeddb-backend.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage.ts";
import { type SyncUserProfile } from "../models/user.ts";
import { ISavedSync } from "./index";
import { IStoredClientOpts } from "../client";
import { IStateEventWithRoomId, ISyncResponse } from "../matrix";
import { IIndexedDBBackend, UserTuple } from "./indexeddb-backend";
import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage";
export declare class RemoteIndexedDBStoreBackend implements IIndexedDBBackend {
private readonly workerFactory;
private readonly dbName?;
private worker?;
private nextSeq;
private inFlight;
private startPromiseResolvers?;
private startPromise?;
private onClose;
/**
* An IndexedDB store backend where the actual backend sits in a web
@@ -72,13 +71,8 @@ export declare class RemoteIndexedDBStoreBackend implements IIndexedDBBackend {
saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
removeToDeviceBatch(id: number): Promise<void>;
getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;
storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;
removeUserProfiles(userIds: string[]): Promise<void>;
removeEventsFromRoom(roomId: string, eventIds: string[]): Promise<void>;
private ensureStarted;
private doCmd;
private onWorkerError;
private onWorkerMessage;
destroy(): Promise<void>;
}

View File

@@ -1 +1 @@
{"version":3,"file":"indexeddb-remote-backend.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb-remote-backend.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,qBAAa,2BAA4B,YAAW,iBAAiB;IAsB7D,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAtB5B,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,OAAO,CAAK;IAEpB,OAAO,CAAC,QAAQ,CA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AsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAI9D,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,eAAe,CA4BrB;IAKW,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}

View File

@@ -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.RemoteIndexedDBStoreBackend = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _logger = require("../logger");
var _utils = require("../utils");
/*
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
@@ -15,8 +24,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { logger } from "../logger.js";
export class RemoteIndexedDBStoreBackend {
class RemoteIndexedDBStoreBackend {
// Callback for when the IndexedDB gets closed unexpectedly
/**
@@ -30,30 +38,29 @@ export class RemoteIndexedDBStoreBackend {
* to open the same database.
*/
constructor(workerFactory, dbName) {
_defineProperty(this, "worker", void 0);
_defineProperty(this, "nextSeq", 0);
this.workerFactory = workerFactory;
this.dbName = dbName;
(0, _defineProperty2.default)(this, "worker", void 0);
(0, _defineProperty2.default)(this, "nextSeq", 0);
// The currently in-flight requests to the actual backend
_defineProperty(this, "inFlight", {});
(0, _defineProperty2.default)(this, "inFlight", {});
// seq: promise
// Once we start connecting, we keep the promise and re-use it
// if we try to connect again
_defineProperty(this, "startPromiseResolvers", void 0);
_defineProperty(this, "onWorkerError", ev => {
logger.error("IndexedDB worker failed to connect", ev);
this.startPromiseResolvers?.reject(ev.message ?? new Error("IndexedDB worker failed to connect"));
});
_defineProperty(this, "onWorkerMessage", ev => {
(0, _defineProperty2.default)(this, "startPromise", void 0);
(0, _defineProperty2.default)(this, "onWorkerMessage", ev => {
const msg = ev.data;
if (msg.command == "closed") {
this.onClose?.();
var _this$onClose;
(_this$onClose = this.onClose) === null || _this$onClose === void 0 ? void 0 : _this$onClose.call(this);
} else if (msg.command == "cmd_success" || msg.command == "cmd_fail") {
if (msg.seq === undefined) {
logger.error("Got reply from worker with no seq");
_logger.logger.error("Got reply from worker with no seq");
return;
}
const def = this.inFlight[msg.seq];
if (def === undefined) {
logger.error("Got reply for unknown seq " + msg.seq);
_logger.logger.error("Got reply for unknown seq " + msg.seq);
return;
}
delete this.inFlight[msg.seq];
@@ -65,11 +72,9 @@ export class RemoteIndexedDBStoreBackend {
def.reject(error);
}
} else {
logger.warn("Unrecognised message from worker: ", msg);
_logger.logger.warn("Unrecognised message from worker: ", msg);
}
});
this.workerFactory = workerFactory;
this.dbName = dbName;
}
/**
@@ -160,47 +165,27 @@ export class RemoteIndexedDBStoreBackend {
async removeToDeviceBatch(id) {
return this.doCmd("removeToDeviceBatch", [id]);
}
async getUserProfile(userId) {
return this.doCmd("getUserProfile", [userId]);
}
async storeUserProfiles(userProfiles) {
await this.doCmd("storeUserProfiles", [userProfiles]);
}
async removeUserProfiles(userIds) {
await this.doCmd("removeUserProfiles", [userIds]);
}
async removeEventsFromRoom(roomId, eventIds) {
await this.doCmd("removeEventsFromRoom", [roomId, eventIds]);
}
ensureStarted() {
if (!this.startPromiseResolvers) {
this.startPromiseResolvers = Promise.withResolvers();
try {
this.worker = this.workerFactory();
} catch (e) {
logger.error("IndexedDB worker failed to start", e);
this.startPromiseResolvers.reject(new Error("IndexedDB worker failed to start"));
return this.startPromiseResolvers.promise;
}
if (!this.startPromise) {
this.worker = this.workerFactory();
this.worker.onmessage = this.onWorkerMessage;
this.worker.onerror = this.onWorkerError;
// tell the worker the db name.
this.doCmd("setupWorker", [this.dbName]).then(() => {
logger.log("IndexedDB worker is ready");
this.startPromiseResolvers?.resolve();
this.startPromise = this.doCmd("setupWorker", [this.dbName]).then(() => {
_logger.logger.log("IndexedDB worker is ready");
});
}
return this.startPromiseResolvers.promise;
return this.startPromise;
}
doCmd(command, args) {
// wrap in a q so if the postMessage throws,
// the promise automatically gets rejected
return Promise.resolve().then(() => {
var _this$worker;
const seq = this.nextSeq++;
const def = Promise.withResolvers();
const def = (0, _utils.defer)();
this.inFlight[seq] = def;
this.worker?.postMessage({
(_this$worker = this.worker) === null || _this$worker === void 0 ? void 0 : _this$worker.postMessage({
command,
seq,
args
@@ -212,7 +197,9 @@ export class RemoteIndexedDBStoreBackend {
* Destroy the web worker
*/
async destroy() {
this.worker?.terminate();
var _this$worker2;
(_this$worker2 = this.worker) === null || _this$worker2 === void 0 ? void 0 : _this$worker2.terminate();
}
}
exports.RemoteIndexedDBStoreBackend = RemoteIndexedDBStoreBackend;
//# sourceMappingURL=indexeddb-remote-backend.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"indexeddb-store-worker.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb-store-worker.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAoB;IAOV,OAAO,CAAC,QAAQ,CAAC,WAAW;IAN/C,OAAO,CAAC,OAAO,CAAC,CAA6B;IAE7C;;;OAGG;IACH,YAAoC,WAAW,EAAE,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC,EAAI;IAE/F,OAAO,CAAC,OAAO,CAIb;IAEF;;;;;OAKG;IACI,SAAS,OAAQ,YAAY,KAAG,IAAI,CAsGzC;CACL"}
{"version":3,"file":"indexeddb-store-worker.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb-store-worker.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAoB;IAOV,OAAO,CAAC,QAAQ,CAAC,WAAW;IAN/C,OAAO,CAAC,OAAO,CAAC,CAA6B;IAE7C;;;OAGG;gBACiC,WAAW,EAAE,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC;IAE3F,OAAO,CAAC,OAAO,CAIb;IAEF;;;;;OAKG;IACI,SAAS,OAAQ,YAAY,KAAG,IAAI,CA4FzC;CACL"}

View File

@@ -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

File diff suppressed because one or more lines are too long

View File

@@ -1,25 +1,31 @@
import { MemoryStore, type IOpts as IBaseOpts } from "./memory.ts";
import { type IEvent } from "../models/event.ts";
import { type ISavedSync } from "./index.ts";
import { type IIndexedDBBackend } from "./indexeddb-backend.ts";
import { type ISyncResponse } from "../sync-accumulator.ts";
import { type EventEmitterEvents } from "../models/typed-event-emitter.ts";
import { type IStateEventWithRoomId } from "../@types/search.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage.ts";
import { type IStoredClientOpts } from "../client.ts";
import { type SyncUserProfile } from "../models/user.ts";
import { MemoryStore, IOpts as IBaseOpts } from "./memory";
import { IEvent } from "../models/event";
import { ISavedSync } from "./index";
import { IIndexedDBBackend } from "./indexeddb-backend";
import { ISyncResponse } from "../sync-accumulator";
import { TypedEventEmitter } from "../models/typed-event-emitter";
import { IStateEventWithRoomId } from "../@types/search";
import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage";
import { IStoredClientOpts } from "../client";
interface IOpts extends IBaseOpts {
/** The Indexed DB interface e.g. `window.indexedDB` */
indexedDB?: IDBFactory;
indexedDB: IDBFactory;
/** Optional database name. The same name must be used to open the same database. */
dbName?: string;
/** Optional factory to spin up a Worker to execute the IDB transactions within. */
workerFactory?: () => Worker;
}
type EventHandlerMap = {
degraded: (e: Error) => void;
closed: () => void;
};
export declare class IndexedDBStore extends MemoryStore {
private readonly opts;
static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean>;
_backend: IIndexedDBBackend;
/**
* The backend instance.
* Call through to this API if you need to perform specific indexeddb actions like deleting the database.
*/
readonly backend: IIndexedDBBackend;
private startedUp;
private syncTs;
private userModifiedMap;
@@ -37,10 +43,10 @@ export declare class IndexedDBStore extends MemoryStore {
* ```
* let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
* let store = new IndexedDBStore(opts);
* await store.startup(); // load from indexed db
* let client = sdk.createClient({
* store: store,
* });
* await store.startup(); // load from indexed db, must be called after createClient
* client.startClient();
* client.on("sync", function(state, prevState, data) {
* if (state === "PREPARED") {
@@ -52,13 +58,7 @@ export declare class IndexedDBStore extends MemoryStore {
* @param opts - Options object.
*/
constructor(opts: IOpts);
/**
* The backend instance.
* Call through to this API if you need to perform specific indexeddb actions like deleting the database.
*/
get backend(): IIndexedDBBackend;
/** Re-exports `TypedEventEmitter.on` */
on(event: EventEmitterEvents | "degraded" | "closed", handler: (...args: any[]) => void): void;
on: <T extends import("../models/typed-event-emitter").EventEmitterEvents | keyof EventHandlerMap>(event: T, listener: import("../models/typed-event-emitter").Listener<keyof EventHandlerMap, EventHandlerMap, T>) => TypedEventEmitter<keyof EventHandlerMap, EventHandlerMap, EventHandlerMap>;
/**
* @returns Resolved when loaded from indexed db.
*/
@@ -139,9 +139,6 @@ export declare class IndexedDBStore extends MemoryStore {
saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
removeToDeviceBatch(id: number): Promise<void>;
getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;
storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;
removeUserProfiles(userIds: string[]): Promise<void>;
}
type DegradableFn<A extends Array<any>, T> = (...args: A) => Promise<T>;
export {};

View File

@@ -1 +1 @@
{"version":3,"file":"indexeddb.d.ts","sourceRoot":"","sources":["../../src/store/indexeddb.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM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AM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhF,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAI9D,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxD;AAUD,KAAK,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC"}

View File

@@ -1,4 +1,18 @@
import _defineProperty from "@babel/runtime/helpers/defineProperty";
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.IndexedDBStore = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _memory = require("./memory");
var _indexeddbLocalBackend = require("./indexeddb-local-backend");
var _indexeddbRemoteBackend = require("./indexeddb-remote-backend");
var _user = require("../models/user");
var _event = require("../models/event");
var _logger = require("../logger");
var _typedEventEmitter = require("../models/typed-event-emitter");
/*
Copyright 2017 - 2021 Vector Creations Ltd
@@ -15,12 +29,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { MemoryStore } from "./memory.js";
import { LocalIndexedDBStoreBackend } from "./indexeddb-local-backend.js";
import { RemoteIndexedDBStoreBackend } from "./indexeddb-remote-backend.js";
import { MatrixEvent } from "../models/event.js";
import { logger } from "../logger.js";
import { TypedEventEmitter } from "../models/typed-event-emitter.js";
/* eslint-disable @babel/no-invalid-this */
/**
* This is an internal module. See {@link IndexedDBStore} for the public class.
*/
@@ -32,10 +42,16 @@ import { TypedEventEmitter } from "../models/typed-event-emitter.js";
// response is persisted each time.
const WRITE_DELAY_MS = 1000 * 60 * 5; // once every 5 minutes
export class IndexedDBStore extends MemoryStore {
class IndexedDBStore extends _memory.MemoryStore {
static exists(indexedDB, dbName) {
return LocalIndexedDBStoreBackend.exists(indexedDB, dbName);
return _indexeddbLocalBackend.LocalIndexedDBStoreBackend.exists(indexedDB, dbName);
}
/**
* The backend instance.
* Call through to this API if you need to perform specific indexeddb actions like deleting the database.
*/
/**
* Construct a new Indexed Database store, which extends MemoryStore.
*
@@ -49,10 +65,10 @@ export class IndexedDBStore extends MemoryStore {
* ```
* let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
* let store = new IndexedDBStore(opts);
* await store.startup(); // load from indexed db
* let client = sdk.createClient({
* store: store,
* });
* await store.startup(); // load from indexed db, must be called after createClient
* client.startClient();
* client.on("sync", function(state, prevState, data) {
* if (state === "PREPARED") {
@@ -65,16 +81,17 @@ export class IndexedDBStore extends MemoryStore {
*/
constructor(opts) {
super(opts);
_defineProperty(this, "_backend", void 0);
_defineProperty(this, "startedUp", false);
_defineProperty(this, "syncTs", 0);
(0, _defineProperty2.default)(this, "backend", void 0);
(0, _defineProperty2.default)(this, "startedUp", false);
(0, _defineProperty2.default)(this, "syncTs", 0);
// Records the last-modified-time of each user at the last point we saved
// the database, such that we can derive the set if users that have been
// modified since we last saved.
_defineProperty(this, "userModifiedMap", {});
(0, _defineProperty2.default)(this, "userModifiedMap", {});
// user_id : timestamp
_defineProperty(this, "emitter", new TypedEventEmitter());
_defineProperty(this, "onClose", () => {
(0, _defineProperty2.default)(this, "emitter", new _typedEventEmitter.TypedEventEmitter());
(0, _defineProperty2.default)(this, "on", this.emitter.on.bind(this.emitter));
(0, _defineProperty2.default)(this, "onClose", () => {
this.emitter.emit("closed");
});
/**
@@ -82,34 +99,34 @@ export class IndexedDBStore extends MemoryStore {
* client state to where it was at the last save, or null if there
* is no saved sync data.
*/
_defineProperty(this, "getSavedSync", this.degradable(() => {
(0, _defineProperty2.default)(this, "getSavedSync", this.degradable(() => {
return this.backend.getSavedSync();
}, "getSavedSync"));
/** @returns whether or not the database was newly created in this session. */
_defineProperty(this, "isNewlyCreated", this.degradable(() => {
(0, _defineProperty2.default)(this, "isNewlyCreated", this.degradable(() => {
return this.backend.isNewlyCreated();
}, "isNewlyCreated"));
/**
* @returns If there is a saved sync, the nextBatch token
* for this sync, otherwise null.
*/
_defineProperty(this, "getSavedSyncToken", this.degradable(() => {
(0, _defineProperty2.default)(this, "getSavedSyncToken", this.degradable(() => {
return this.backend.getNextBatchToken();
}, "getSavedSyncToken"));
/**
* Delete all data from this store.
* @returns Promise which resolves if the data was deleted from the database.
*/
_defineProperty(this, "deleteAllData", this.degradable(() => {
(0, _defineProperty2.default)(this, "deleteAllData", this.degradable(() => {
super.deleteAllData();
return this.backend.clearDatabase().then(() => {
logger.log("Deleted indexeddb data.");
_logger.logger.log("Deleted indexeddb data.");
}, err => {
logger.error(`Failed to delete indexeddb data: ${err}`);
_logger.logger.error(`Failed to delete indexeddb data: ${err}`);
throw err;
});
}, null));
_defineProperty(this, "reallySave", this.degradable(() => {
}));
(0, _defineProperty2.default)(this, "reallySave", this.degradable(() => {
this.syncTs = Date.now(); // set now to guard against multi-writes
// work out changed users (this doesn't handle deletions but you
@@ -124,8 +141,8 @@ export class IndexedDBStore extends MemoryStore {
this.userModifiedMap[u.userId] = u.getLastModifiedTime();
}
return this.backend.syncToDatabase(userTuples);
}, null));
_defineProperty(this, "setSyncData", this.degradable(syncData => {
}));
(0, _defineProperty2.default)(this, "setSyncData", this.degradable(syncData => {
return this.backend.setSyncData(syncData);
}, "setSyncData"));
/**
@@ -134,7 +151,7 @@ export class IndexedDBStore extends MemoryStore {
* @returns the events, potentially an empty array if OOB loading didn't yield any new members
* @returns in case the members for this room haven't been stored yet
*/
_defineProperty(this, "getOutOfBandMembers", this.degradable(roomId => {
(0, _defineProperty2.default)(this, "getOutOfBandMembers", this.degradable(roomId => {
return this.backend.getOutOfBandMembers(roomId);
}, "getOutOfBandMembers"));
/**
@@ -144,73 +161,48 @@ export class IndexedDBStore extends MemoryStore {
* @param membershipEvents - the membership events to store
* @returns when all members have been stored
*/
_defineProperty(this, "setOutOfBandMembers", this.degradable((roomId, membershipEvents) => {
(0, _defineProperty2.default)(this, "setOutOfBandMembers", this.degradable((roomId, membershipEvents) => {
super.setOutOfBandMembers(roomId, membershipEvents);
return this.backend.setOutOfBandMembers(roomId, membershipEvents);
}, "setOutOfBandMembers"));
_defineProperty(this, "clearOutOfBandMembers", this.degradable(roomId => {
(0, _defineProperty2.default)(this, "clearOutOfBandMembers", this.degradable(roomId => {
super.clearOutOfBandMembers(roomId);
return this.backend.clearOutOfBandMembers(roomId);
}, "clearOutOfBandMembers"));
_defineProperty(this, "getClientOptions", this.degradable(() => {
(0, _defineProperty2.default)(this, "getClientOptions", this.degradable(() => {
return this.backend.getClientOptions();
}, "getClientOptions"));
_defineProperty(this, "storeClientOptions", this.degradable(options => {
(0, _defineProperty2.default)(this, "storeClientOptions", this.degradable(options => {
super.storeClientOptions(options);
return this.backend.storeClientOptions(options);
}, "storeClientOptions"));
this.opts = opts;
if (!opts.indexedDB) {
throw new Error("Missing required option: indexedDB");
}
if (opts.workerFactory) {
this._backend = new RemoteIndexedDBStoreBackend(opts.workerFactory, opts.dbName);
this.backend = new _indexeddbRemoteBackend.RemoteIndexedDBStoreBackend(opts.workerFactory, opts.dbName);
} else {
this._backend = new LocalIndexedDBStoreBackend(opts.indexedDB, opts.dbName);
this.backend = new _indexeddbLocalBackend.LocalIndexedDBStoreBackend(opts.indexedDB, opts.dbName);
}
}
/**
* The backend instance.
* Call through to this API if you need to perform specific indexeddb actions like deleting the database.
*/
get backend() {
return this._backend;
}
/** Re-exports `TypedEventEmitter.on` */
on(event, handler) {
this.emitter.on(event, handler);
}
/**
* @returns Resolved when loaded from indexed db.
*/
startup() {
if (this.startedUp) {
logger.log(`IndexedDBStore.startup: already started`);
_logger.logger.log(`IndexedDBStore.startup: already started`);
return Promise.resolve();
}
logger.log(`IndexedDBStore.startup: connecting to backend`);
return this.backend.connect(this.onClose).catch(e => {
if (this.opts.workerFactory) {
logger.log("Falling back to local indexeddb backend");
this._backend = new LocalIndexedDBStoreBackend(this.opts.indexedDB, this.opts.dbName);
return this.backend.connect(this.onClose);
}
throw e;
}).then(() => {
logger.log(`IndexedDBStore.startup: loading presence events`);
_logger.logger.log(`IndexedDBStore.startup: connecting to backend`);
return this.backend.connect(this.onClose).then(() => {
_logger.logger.log(`IndexedDBStore.startup: loading presence events`);
return this.backend.getUserPresenceEvents();
}).then(userPresenceEvents => {
logger.log(`IndexedDBStore.startup: processing presence events`);
_logger.logger.log(`IndexedDBStore.startup: processing presence events`);
userPresenceEvents.forEach(([userId, rawEvent]) => {
if (!this.createUser) {
throw new Error("`IndexedDBStore.startup` must be called after assigning it to the client, not before!");
}
const u = this.createUser(userId);
const u = new _user.User(userId);
if (rawEvent) {
u.setPresenceEvent(new MatrixEvent(rawEvent));
u.setPresenceEvent(new _event.MatrixEvent(rawEvent));
}
this.userModifiedMap[u.userId] = u.getLastModifiedTime();
this.storeUser(u);
@@ -270,18 +262,18 @@ export class IndexedDBStore extends MemoryStore {
try {
return await func.call(this, ...args);
} catch (e) {
logger.error("IndexedDBStore failure, degrading to MemoryStore", e);
_logger.logger.error("IndexedDBStore failure, degrading to MemoryStore", e);
this.emitter.emit("degraded", e);
try {
// We try to delete IndexedDB after degrading since this store is only a
// cache (the app will still function correctly without the data).
// It's possible that deleting repair IndexedDB for the next app load,
// potentially by making a little more space available.
logger.log("IndexedDBStore trying to delete degraded data");
_logger.logger.log("IndexedDBStore trying to delete degraded data");
await this.backend.clearDatabase();
logger.log("IndexedDBStore delete after degrading succeeded");
_logger.logger.log("IndexedDBStore delete after degrading succeeded");
} catch (e) {
logger.warn("IndexedDBStore delete after degrading failed", e);
_logger.logger.warn("IndexedDBStore delete after degrading failed", e);
}
// Degrade the store from being an instance of `IndexedDBStore` to instead be
// an instance of `MemoryStore` so that future API calls use the memory path
@@ -306,7 +298,7 @@ export class IndexedDBStore extends MemoryStore {
try {
return JSON.parse(serialized);
} catch (e) {
logger.error("Could not parse persisted pending events", e);
_logger.logger.error("Could not parse persisted pending events", e);
}
}
return [];
@@ -328,21 +320,13 @@ export class IndexedDBStore extends MemoryStore {
removeToDeviceBatch(id) {
return this.backend.removeToDeviceBatch(id);
}
async getUserProfile(userId) {
return this.backend.getUserProfile(userId);
}
async storeUserProfiles(userProfiles) {
return this.backend.storeUserProfiles(userProfiles);
}
async removeUserProfiles(userIds) {
return this.backend.removeUserProfiles(userIds);
}
}
/**
* @param roomId - ID of the current room
* @returns Storage key to retrieve pending events
*/
exports.IndexedDBStore = IndexedDBStore;
function pendingEventsKey(roomId) {
return `mx_pending_events_${roomId}`;
}

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
import { TypedEventEmitter } from "../models/typed-event-emitter";
export declare enum LocalStorageErrors {
Global = "Global",
SetItemError = "setItem",

View File

@@ -1 +1 @@
{"version":3,"file":"local-storage-events-emitter.d.ts","sourceRoot":"","sources":["../../src/store/local-storage-events-emitter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,oBAAY,kBAAkB;IAC1B,MAAM,WAAW;IACjB,YAAY,YAAY;IACxB,YAAY,YAAY;IACxB,eAAe,eAAe;IAC9B,UAAU,UAAU;IACpB,kBAAkB,uBAAuB;CAC5C;AAED,KAAK,eAAe,GAAG;IACnB,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACpD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC1D,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC1D,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,CAAC,KAAK,EA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gC,SAAQ,iBAAiB,CAAC,kBAAkB,EAAE,eAAe,CAAC;CAAG;AACvG,eAAO,MAAM,+BAA+B,iCAAwC,CAAC"}

View File

@@ -1,3 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.localStorageErrorsEventsEmitter = exports.LocalStorageErrors = void 0;
var _typedEventEmitter = require("../models/typed-event-emitter");
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
@@ -13,9 +20,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { TypedEventEmitter } from "../models/typed-event-emitter.js";
export let LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
let LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
LocalStorageErrors["Global"] = "Global";
LocalStorageErrors["SetItemError"] = "setItem";
LocalStorageErrors["GetItemError"] = "getItem";
@@ -24,6 +29,7 @@ export let LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
LocalStorageErrors["QuotaExceededError"] = "QuotaExceededError";
return LocalStorageErrors;
}({});
exports.LocalStorageErrors = LocalStorageErrors;
/**
* Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible
* As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.
@@ -32,6 +38,7 @@ export let LocalStorageErrors = /*#__PURE__*/function (LocalStorageErrors) {
* maybe you should check out your disk, as it's probably dying and your session may die with it.
* See: https://github.com/vector-im/element-web/issues/18423
*/
class LocalStorageErrorsEventsEmitter extends TypedEventEmitter {}
export const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();
class LocalStorageErrorsEventsEmitter extends _typedEventEmitter.TypedEventEmitter {}
const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();
exports.localStorageErrorsEventsEmitter = localStorageErrorsEventsEmitter;
//# sourceMappingURL=local-storage-events-emitter.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"local-storage-events-emitter.js","names":[],"sources":["../../src/store/local-storage-events-emitter.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { TypedEventEmitter } from \"../models/typed-event-emitter.ts\";\n\nexport enum LocalStorageErrors {\n Global = \"Global\",\n SetItemError = \"setItem\",\n GetItemError = \"getItem\",\n RemoveItemError = \"removeItem\",\n ClearError = \"clear\",\n QuotaExceededError = \"QuotaExceededError\",\n}\n\ntype EventHandlerMap = {\n [LocalStorageErrors.Global]: (error: Error) => void;\n [LocalStorageErrors.SetItemError]: (error: Error) => void;\n [LocalStorageErrors.GetItemError]: (error: Error) => void;\n [LocalStorageErrors.RemoveItemError]: (error: Error) => void;\n [LocalStorageErrors.ClearError]: (error: Error) => void;\n [LocalStorageErrors.QuotaExceededError]: (error: Error) => void;\n};\n\n/**\n * Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible\n * As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.\n * This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them\n * and show some kind of a \"It's dead Jim\" modal to the users, telling them that hey,\n * maybe you should check out your disk, as it's probably dying and your session may die with it.\n * See: https://github.com/vector-im/element-web/issues/18423\n */\nclass LocalStorageErrorsEventsEmitter extends TypedEventEmitter<LocalStorageErrors, EventHandlerMap> {}\nexport const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAS,iBAAiB,QAAQ,kCAAkC;AAEpE,WAAY,kBAAkB,0BAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAlB,kBAAkB;EAAA,OAAlB,kBAAkB;AAAA;AAkB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,+BAA+B,SAAS,iBAAiB,CAAsC;AACrG,OAAO,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,CAAC,CAAC","ignoreList":[]}
{"version":3,"file":"local-storage-events-emitter.js","names":["_typedEventEmitter","require","LocalStorageErrors","exports","LocalStorageErrorsEventsEmitter","TypedEventEmitter","localStorageErrorsEventsEmitter"],"sources":["../../src/store/local-storage-events-emitter.ts"],"sourcesContent":["/*\nCopyright 2021 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { TypedEventEmitter } from \"../models/typed-event-emitter\";\n\nexport enum LocalStorageErrors {\n Global = \"Global\",\n SetItemError = \"setItem\",\n GetItemError = \"getItem\",\n RemoveItemError = \"removeItem\",\n ClearError = \"clear\",\n QuotaExceededError = \"QuotaExceededError\",\n}\n\ntype EventHandlerMap = {\n [LocalStorageErrors.Global]: (error: Error) => void;\n [LocalStorageErrors.SetItemError]: (error: Error) => void;\n [LocalStorageErrors.GetItemError]: (error: Error) => void;\n [LocalStorageErrors.RemoveItemError]: (error: Error) => void;\n [LocalStorageErrors.ClearError]: (error: Error) => void;\n [LocalStorageErrors.QuotaExceededError]: (error: Error) => void;\n};\n\n/**\n * Used in element-web as a temporary hack to handle all the localStorage errors on the highest level possible\n * As of 15.11.2021 (DD/MM/YYYY) we're not properly handling local storage exceptions anywhere.\n * This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them\n * and show some kind of a \"It's dead Jim\" modal to the users, telling them that hey,\n * maybe you should check out your disk, as it's probably dying and your session may die with it.\n * See: https://github.com/vector-im/element-web/issues/18423\n */\nclass LocalStorageErrorsEventsEmitter extends TypedEventEmitter<LocalStorageErrors, EventHandlerMap> {}\nexport const localStorageErrorsEventsEmitter = new LocalStorageErrorsEventsEmitter();\n"],"mappings":";;;;;;AAgBA,IAAAA,kBAAA,GAAAC,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdA,IAkBYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAAAC,OAAA,CAAAD,kBAAA,GAAAA,kBAAA;AAkB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,+BAA+B,SAASC,oCAAiB,CAAsC;AAC9F,MAAMC,+BAA+B,GAAG,IAAIF,+BAA+B,CAAC,CAAC;AAACD,OAAA,CAAAG,+BAAA,GAAAA,+BAAA"}

View File

@@ -1,17 +1,17 @@
/**
* This is an internal module. See {@link MemoryStore} for the public class.
*/
import { type EventType } from "../@types/event.ts";
import { type Room } from "../models/room.ts";
import { type SyncUserProfile, type User } from "../models/user.ts";
import { type IEvent, type MatrixEvent } from "../models/event.ts";
import { type Filter } from "../filter.ts";
import { type ISavedSync, type IStore, type UserCreator } from "./index.ts";
import { type RoomSummary } from "../models/room-summary.ts";
import { type ISyncResponse } from "../sync-accumulator.ts";
import { type IStateEventWithRoomId } from "../@types/search.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage.ts";
import { type IStoredClientOpts } from "../client.ts";
import { EventType } from "../@types/event";
import { Room } from "../models/room";
import { User } from "../models/user";
import { IEvent, MatrixEvent } from "../models/event";
import { Filter } from "../filter";
import { ISavedSync, IStore } from "./index";
import { RoomSummary } from "../models/room-summary";
import { ISyncResponse } from "../sync-accumulator";
import { IStateEventWithRoomId } from "../@types/search";
import { IndexedToDeviceBatch, ToDeviceBatchWithTxnId } from "../models/ToDeviceMessage";
import { IStoredClientOpts } from "../client";
export interface IOpts {
/** The local storage instance to persist some forms of data such as tokens. Rooms will NOT be stored. */
localStorage?: Storage;
@@ -28,8 +28,6 @@ export declare class MemoryStore implements IStore {
private clientOptions?;
private pendingToDeviceBatches;
private nextToDeviceBatchId;
protected createUser?: UserCreator;
readonly userProfiles: Map<string, SyncUserProfile>;
/**
* Construct a new in-memory data store for the Matrix Client.
* @param opts - Config options
@@ -52,7 +50,6 @@ export declare class MemoryStore implements IStore {
* @param room - The room to be stored. All properties must be stored.
*/
storeRoom(room: Room): void;
setUserCreator(creator: UserCreator): void;
/**
* Called when a room member in a room being tracked by this store has been
* updated.
@@ -205,10 +202,6 @@ export declare class MemoryStore implements IStore {
saveToDeviceBatches(batches: ToDeviceBatchWithTxnId[]): Promise<void>;
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
removeToDeviceBatch(id: number): Promise<void>;
getUserProfile(userId: string): Promise<SyncUserProfile | undefined>;
storeUserProfiles(userProfiles: Map<string, SyncUserProfile>): Promise<void>;
removeUserProfiles(userIds: string[]): Promise<void>;
removeEventsFromRoom(roomId: string, eventIds: string[]): Promise<void>;
destroy(): Promise<void>;
}
//# sourceMappingURL=memory.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/store/memory.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB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,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}

View File

@@ -1,4 +1,14 @@
import _defineProperty from "@babel/runtime/helpers/defineProperty";
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MemoryStore = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _user = require("../models/user");
var _roomState = require("../models/room-state");
var _utils = require("../utils");
/*
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
@@ -19,52 +29,47 @@ limitations under the License.
* This is an internal module. See {@link MemoryStore} for the public class.
*/
import { RoomStateEvent } from "../models/room-state.js";
import { MapWithDefault } from "../utils.js";
import { KnownMembership } from "../@types/membership.js";
function isValidFilterId(filterId) {
const isValidStr = typeof filterId === "string" && !!filterId && filterId !== "undefined" &&
// exclude these as we've serialized undefined in localStorage before
filterId !== "null";
return isValidStr || typeof filterId === "number";
}
export class MemoryStore {
class MemoryStore {
/**
* Construct a new in-memory data store for the Matrix Client.
* @param opts - Config options
*/
constructor(opts = {}) {
_defineProperty(this, "rooms", {});
(0, _defineProperty2.default)(this, "rooms", {});
// roomId: Room
_defineProperty(this, "users", {});
(0, _defineProperty2.default)(this, "users", {});
// userId: User
_defineProperty(this, "syncToken", null);
(0, _defineProperty2.default)(this, "syncToken", null);
// userId: {
// filterId: Filter
// }
_defineProperty(this, "filters", new MapWithDefault(() => new Map()));
_defineProperty(this, "accountData", new Map());
(0, _defineProperty2.default)(this, "filters", new _utils.MapWithDefault(() => new Map()));
(0, _defineProperty2.default)(this, "accountData", new Map());
// type: content
_defineProperty(this, "localStorage", void 0);
_defineProperty(this, "oobMembers", new Map());
(0, _defineProperty2.default)(this, "localStorage", void 0);
(0, _defineProperty2.default)(this, "oobMembers", new Map());
// roomId: [member events]
_defineProperty(this, "pendingEvents", {});
_defineProperty(this, "clientOptions", void 0);
_defineProperty(this, "pendingToDeviceBatches", []);
_defineProperty(this, "nextToDeviceBatchId", 0);
_defineProperty(this, "createUser", void 0);
_defineProperty(this, "userProfiles", new Map());
(0, _defineProperty2.default)(this, "pendingEvents", {});
(0, _defineProperty2.default)(this, "clientOptions", void 0);
(0, _defineProperty2.default)(this, "pendingToDeviceBatches", []);
(0, _defineProperty2.default)(this, "nextToDeviceBatchId", 0);
/**
* Called when a room member in a room being tracked by this store has been
* updated.
*/
_defineProperty(this, "onRoomMember", (event, state, member) => {
if (member.membership === KnownMembership.Invite) {
(0, _defineProperty2.default)(this, "onRoomMember", (event, state, member) => {
if (member.membership === "invite") {
// We do NOT add invited members because people love to typo user IDs
// which would then show up in these lists (!)
return;
}
const user = this.users[member.userId] || this.createUser?.(member.userId);
const user = this.users[member.userId] || new _user.User(member.userId);
if (member.name) {
user.setDisplayName(member.name);
if (member.events.member) {
@@ -108,15 +113,12 @@ export class MemoryStore {
this.rooms[room.roomId] = room;
// add listeners for room member changes so we can keep the room member
// map up-to-date.
room.currentState.on(RoomStateEvent.Members, this.onRoomMember);
room.currentState.on(_roomState.RoomStateEvent.Members, this.onRoomMember);
// add existing members
room.currentState.getMembers().forEach(m => {
this.onRoomMember(null, room.currentState, m);
});
}
setUserCreator(creator) {
this.createUser = creator;
}
/**
* Retrieve a room by its' room ID.
* @param roomId - The room ID.
@@ -139,7 +141,7 @@ export class MemoryStore {
*/
removeRoom(roomId) {
if (this.rooms[roomId]) {
this.rooms[roomId].currentState.removeListener(RoomStateEvent.Members, this.onRoomMember);
this.rooms[roomId].currentState.removeListener(_roomState.RoomStateEvent.Members, this.onRoomMember);
}
delete this.rooms[roomId];
}
@@ -205,7 +207,7 @@ export class MemoryStore {
* Store a filter.
*/
storeFilter(filter) {
if (!filter?.userId || !filter?.filterId) return;
if (!(filter !== null && filter !== void 0 && filter.userId) || !(filter !== null && filter !== void 0 && filter.filterId)) return;
this.filters.getOrCreate(filter.userId).set(filter.filterId, filter);
}
@@ -214,7 +216,8 @@ export class MemoryStore {
* @returns A filter or null.
*/
getFilter(userId, filterId) {
return this.filters.get(userId)?.get(filterId) || null;
var _this$filters$get;
return ((_this$filters$get = this.filters.get(userId)) === null || _this$filters$get === void 0 ? void 0 : _this$filters$get.get(filterId)) || null;
}
/**
@@ -237,9 +240,7 @@ export class MemoryStore {
if (isValidFilterId(value)) {
return value;
}
} catch {
// Do nothing
}
} catch (e) {}
return null;
}
@@ -257,9 +258,7 @@ export class MemoryStore {
} else {
this.localStorage.removeItem(key);
}
} catch {
// Do nothing
}
} catch (e) {}
}
/**
@@ -270,7 +269,13 @@ export class MemoryStore {
*/
storeAccountDataEvents(events) {
events.forEach(event => {
this.accountData.set(event.getType(), event);
// MSC3391: an event with content of {} should be interpreted as deleted
const isDeleted = !Object.keys(event.getContent()).length;
if (isDeleted) {
this.accountData.delete(event.getType());
} else {
this.accountData.set(event.getType(), event);
}
});
}
@@ -348,7 +353,7 @@ export class MemoryStore {
// userId: User
};
this.syncToken = null;
this.filters = new MapWithDefault(() => new Map());
this.filters = new _utils.MapWithDefault(() => new Map());
this.accountData = new Map(); // type : content
return Promise.resolve();
}
@@ -386,7 +391,8 @@ export class MemoryStore {
return Promise.resolve();
}
async getPendingEvents(roomId) {
return this.pendingEvents[roomId] ?? [];
var _this$pendingEvents$r;
return (_this$pendingEvents$r = this.pendingEvents[roomId]) !== null && _this$pendingEvents$r !== void 0 ? _this$pendingEvents$r : [];
}
async setPendingEvents(roomId, events) {
this.pendingEvents[roomId] = events;
@@ -410,20 +416,9 @@ export class MemoryStore {
this.pendingToDeviceBatches = this.pendingToDeviceBatches.filter(batch => batch.id !== id);
return Promise.resolve();
}
async getUserProfile(userId) {
return this.userProfiles.get(userId);
}
async storeUserProfiles(userProfiles) {
userProfiles.forEach((profile, userId) => this.userProfiles.set(userId, profile));
}
async removeUserProfiles(userIds) {
userIds.forEach(userId => this.userProfiles.delete(userId));
}
async removeEventsFromRoom(roomId, eventIds) {
// Can ignore as there is no backing store.
}
async destroy() {
// Nothing to do
}
}
exports.MemoryStore = MemoryStore;
//# sourceMappingURL=memory.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,17 +1,17 @@
/**
* This is an internal module.
*/
import { type EventType } from "../@types/event.ts";
import { type Room } from "../models/room.ts";
import { type User } from "../models/user.ts";
import { type IEvent, type MatrixEvent } from "../models/event.ts";
import { type Filter } from "../filter.ts";
import { type ISavedSync, type IStore, type UserCreator } from "./index.ts";
import { type RoomSummary } from "../models/room-summary.ts";
import { type ISyncResponse } from "../sync-accumulator.ts";
import { type IStateEventWithRoomId } from "../@types/search.ts";
import { type IndexedToDeviceBatch, type ToDeviceBatch } from "../models/ToDeviceMessage.ts";
import { type IStoredClientOpts } from "../client.ts";
import { EventType } from "../@types/event";
import { Room } from "../models/room";
import { User } from "../models/user";
import { IEvent, MatrixEvent } from "../models/event";
import { Filter } from "../filter";
import { ISavedSync, IStore } from "./index";
import { RoomSummary } from "../models/room-summary";
import { ISyncResponse } from "../sync-accumulator";
import { IStateEventWithRoomId } from "../@types/search";
import { IndexedToDeviceBatch, ToDeviceBatch } from "../models/ToDeviceMessage";
import { IStoredClientOpts } from "../client";
/**
* Construct a stub store. This does no-ops on most store methods.
*/
@@ -66,10 +66,6 @@ export declare class StubStore implements IStore {
* No-op.
*/
scrollback(room: Room, limit: number): MatrixEvent[];
/**
* No-op.
*/
setUserCreator(creator: UserCreator): void;
/**
* Store events for a room.
* @param room - The room to store events for.
@@ -156,10 +152,6 @@ export declare class StubStore implements IStore {
saveToDeviceBatches(batch: ToDeviceBatch[]): Promise<void>;
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
removeToDeviceBatch(id: number): Promise<void>;
getUserProfile(): Promise<undefined>;
storeUserProfiles(): Promise<void>;
removeUserProfiles(): Promise<void>;
destroy(): Promise<void>;
removeEventsFromRoom(roomId: string, eventIds: string[]): Promise<void>;
}
//# sourceMappingURL=stub.d.ts.map

View File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;IAI9C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}

View File

@@ -1,4 +1,11 @@
import _defineProperty from "@babel/runtime/helpers/defineProperty";
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StubStore = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
/*
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
@@ -22,11 +29,11 @@ limitations under the License.
/**
* Construct a stub store. This does no-ops on most store methods.
*/
export class StubStore {
class StubStore {
constructor() {
_defineProperty(this, "accountData", new Map());
(0, _defineProperty2.default)(this, "accountData", new Map());
// stub
_defineProperty(this, "fromToken", null);
(0, _defineProperty2.default)(this, "fromToken", null);
}
/** @returns whether or not the database was newly created in this session. */
isNewlyCreated() {
@@ -108,13 +115,6 @@ export class StubStore {
return [];
}
/**
* No-op.
*/
setUserCreator(creator) {
return;
}
/**
* Store events for a room.
* @param room - The room to store events for.
@@ -254,20 +254,9 @@ export class StubStore {
async removeToDeviceBatch(id) {
return Promise.resolve();
}
async getUserProfile() {
return undefined;
}
async storeUserProfiles() {
return;
}
async removeUserProfiles() {
return;
}
async destroy() {
// Nothing to do
}
async removeEventsFromRoom(roomId, eventIds) {
// Nothing to do
}
}
exports.StubStore = StubStore;
//# sourceMappingURL=stub.js.map

File diff suppressed because one or more lines are too long