init
This commit is contained in:
224
node_modules/matrix-js-sdk/lib/store/index.d.ts
generated
vendored
Normal file
224
node_modules/matrix-js-sdk/lib/store/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
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";
|
||||
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
|
||||
*/
|
||||
export interface IStore {
|
||||
readonly accountData: Map<string, MatrixEvent>;
|
||||
on?: (event: EventEmitterEvents | "degraded" | "closed", handler: (...args: any[]) => void) => void;
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
/**
|
||||
* Get the sync token.
|
||||
*/
|
||||
getSyncToken(): string | null;
|
||||
/**
|
||||
* Set the sync token.
|
||||
*/
|
||||
setSyncToken(token: string): void;
|
||||
/**
|
||||
* Store the given room.
|
||||
* @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.
|
||||
* @returns The room or null.
|
||||
*/
|
||||
getRoom(roomId: string): Room | null;
|
||||
/**
|
||||
* Retrieve all known rooms.
|
||||
* @returns A list of rooms, which may be empty.
|
||||
*/
|
||||
getRooms(): Room[];
|
||||
/**
|
||||
* Permanently delete a room.
|
||||
*/
|
||||
removeRoom(roomId: string): void;
|
||||
/**
|
||||
* Retrieve a summary of all the rooms.
|
||||
* @returns A summary of each room.
|
||||
*/
|
||||
getRoomSummaries(): RoomSummary[];
|
||||
/**
|
||||
* Store a User.
|
||||
* @param user - The user to store.
|
||||
*/
|
||||
storeUser(user: User): void;
|
||||
/**
|
||||
* Retrieve a User by its' user ID.
|
||||
* @param userId - The user ID.
|
||||
* @returns The user or null.
|
||||
*/
|
||||
getUser(userId: string): User | null;
|
||||
/**
|
||||
* Retrieve all known users.
|
||||
* @returns A list of users, which may be empty.
|
||||
*/
|
||||
getUsers(): User[];
|
||||
/**
|
||||
* Retrieve scrollback for this room.
|
||||
* @param room - The matrix room
|
||||
* @param limit - The max number of old events to retrieve.
|
||||
* @returns An array of objects which will be at most 'limit'
|
||||
* length and at least 0. The objects are the raw event JSON.
|
||||
*/
|
||||
scrollback(room: Room, limit: number): MatrixEvent[];
|
||||
/**
|
||||
* Store events for a room.
|
||||
* @param room - The room to store events for.
|
||||
* @param events - The events to store.
|
||||
* @param token - The token associated with these events.
|
||||
* @param toStart - True if these are paginated results.
|
||||
*/
|
||||
storeEvents(room: Room, events: MatrixEvent[], token: string | null, toStart: boolean): void;
|
||||
/**
|
||||
* Store a filter.
|
||||
*/
|
||||
storeFilter(filter: Filter): void;
|
||||
/**
|
||||
* Retrieve a filter.
|
||||
* @returns A filter or null.
|
||||
*/
|
||||
getFilter(userId: string, filterId: string): Filter | null;
|
||||
/**
|
||||
* Retrieve a filter ID with the given name.
|
||||
* @param filterName - The filter name.
|
||||
* @returns The filter ID or null.
|
||||
*/
|
||||
getFilterIdByName(filterName: string): string | null;
|
||||
/**
|
||||
* Set a filter name to ID mapping.
|
||||
*/
|
||||
setFilterIdByName(filterName: string, filterId?: string): void;
|
||||
/**
|
||||
* Store user-scoped account data events
|
||||
* @param events - The events to store.
|
||||
*/
|
||||
storeAccountDataEvents(events: MatrixEvent[]): void;
|
||||
/**
|
||||
* Get account data event by event type
|
||||
* @param eventType - The event type being queried
|
||||
*/
|
||||
getAccountData(eventType: EventType | string): MatrixEvent | undefined;
|
||||
/**
|
||||
* setSyncData does nothing as there is no backing data store.
|
||||
*
|
||||
* @param syncData - The sync data
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
setSyncData(syncData: ISyncResponse): Promise<void>;
|
||||
/**
|
||||
* We never want to save because we have nothing to save to.
|
||||
*
|
||||
* @returns If the store wants to save
|
||||
*/
|
||||
wantsSave(): boolean;
|
||||
/**
|
||||
* Save does nothing as there is no backing data store.
|
||||
*/
|
||||
save(force?: boolean): Promise<void>;
|
||||
/**
|
||||
* Startup does nothing.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
startup(): Promise<void>;
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync(): Promise<ISavedSync | null>;
|
||||
/**
|
||||
* @returns If there is a saved sync, the nextBatch token
|
||||
* for this sync, otherwise null.
|
||||
*/
|
||||
getSavedSyncToken(): Promise<string | null>;
|
||||
/**
|
||||
* Delete all data from this store. Does nothing since this store
|
||||
* doesn't store anything.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
deleteAllData(): Promise<void>;
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;
|
||||
clearOutOfBandMembers(roomId: string): Promise<void>;
|
||||
getClientOptions(): Promise<IStartClientOpts | undefined>;
|
||||
storeClientOptions(options: IStartClientOpts): Promise<void>;
|
||||
getPendingEvents(roomId: string): Promise<Partial<IEvent>[]>;
|
||||
setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void>;
|
||||
/**
|
||||
* Stores batches of outgoing to-device messages
|
||||
*/
|
||||
saveToDeviceBatches(batch: ToDeviceBatchWithTxnId[]): Promise<void>;
|
||||
/**
|
||||
* Fetches the oldest batch of to-device messages in the queue
|
||||
*/
|
||||
getOldestToDeviceBatch(): Promise<IndexedToDeviceBatch | null>;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
destroy(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/index.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,kCAAkC,CAAC;AAE3E,MAAM,WAAW,UAAU;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,aAAa,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,W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AE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B"}
|
||||
3
node_modules/matrix-js-sdk/lib/store/index.js
generated
vendored
Normal file
3
node_modules/matrix-js-sdk/lib/store/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export {};
|
||||
export {};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/index.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
28
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.d.ts
generated
vendored
Normal file
28
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
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";
|
||||
export interface IIndexedDBBackend {
|
||||
connect(onClose?: () => void): Promise<void>;
|
||||
syncToDatabase(userTuples: UserTuple[]): Promise<void>;
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
setSyncData(syncData: ISyncResponse): Promise<void>;
|
||||
getSavedSync(): Promise<ISavedSync | null>;
|
||||
getNextBatchToken(): Promise<string>;
|
||||
clearDatabase(): Promise<void>;
|
||||
getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;
|
||||
setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;
|
||||
clearOutOfBandMembers(roomId: string): Promise<void>;
|
||||
getUserPresenceEvents(): Promise<UserTuple[]>;
|
||||
getClientOptions(): Promise<IStoredClientOpts | undefined>;
|
||||
storeClientOptions(options: IStoredClientOpts): Promise<void>;
|
||||
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>];
|
||||
//# sourceMappingURL=indexeddb-backend.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,QAA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C,CAAC;CAC5B;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
||||
3
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js
generated
vendored
Normal file
3
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export {};
|
||||
export {};
|
||||
//# sourceMappingURL=indexeddb-backend.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js.map
generated
vendored
Normal file
@@ -0,0 +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":[]}
|
||||
133
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts
generated
vendored
Normal file
133
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
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";
|
||||
export declare class LocalIndexedDBStoreBackend implements IIndexedDBBackend {
|
||||
private readonly indexedDB;
|
||||
static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean>;
|
||||
private readonly dbName;
|
||||
private readonly syncAccumulator;
|
||||
private db?;
|
||||
private disconnected;
|
||||
private _isNewlyCreated;
|
||||
private syncToDatabasePromise?;
|
||||
private pendingUserPresenceData;
|
||||
/**
|
||||
* Does the actual reading from and writing to the indexeddb
|
||||
*
|
||||
* Construct a new Indexed Database store backend. This requires a call to
|
||||
* `connect()` before this store can be used.
|
||||
* @param indexedDB - The Indexed DB interface e.g
|
||||
* `window.indexedDB`
|
||||
* @param dbName - Optional database name. The same name must be used
|
||||
* to open the same database.
|
||||
*/
|
||||
constructor(indexedDB: IDBFactory, dbName?: string);
|
||||
/**
|
||||
* Attempt to connect to the database. This can fail if the user does not
|
||||
* grant permission.
|
||||
* @returns Promise which resolves if successfully connected.
|
||||
*/
|
||||
connect(onClose?: () => void): Promise<void>;
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
/**
|
||||
* Having connected, load initial data from the database and prepare for use
|
||||
* @returns Promise which resolves on success
|
||||
*/
|
||||
private init;
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
*/
|
||||
setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;
|
||||
clearOutOfBandMembers(roomId: string): Promise<void>;
|
||||
/**
|
||||
* Clear the entire database. This should be used when logging out of a client
|
||||
* to prevent mixing data between accounts. Closes the database.
|
||||
* @returns Resolved when the database is cleared.
|
||||
*/
|
||||
clearDatabase(): Promise<void>;
|
||||
/**
|
||||
* @param copy - If false, the data returned is from internal
|
||||
* buffers and must not be mutated. Otherwise, a copy is made before
|
||||
* returning such that the data can be safely mutated. Default: true.
|
||||
*
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync(copy?: boolean): Promise<ISavedSync | null>;
|
||||
getNextBatchToken(): Promise<string>;
|
||||
setSyncData(syncData: ISyncResponse): Promise<void>;
|
||||
/**
|
||||
* Sync users and all accumulated sync data to the database.
|
||||
* If a previous sync is in flight, the new data will be added to the
|
||||
* next sync and the current sync's promise will be returned.
|
||||
* @param userTuples - The user tuples
|
||||
* @returns Promise which resolves if the data was persisted.
|
||||
*/
|
||||
syncToDatabase(userTuples: UserTuple[]): Promise<void>;
|
||||
private doSyncToDatabase;
|
||||
/**
|
||||
* Persist rooms /sync data along with the next batch token.
|
||||
* @param nextBatch - The next_batch /sync value.
|
||||
* @param roomsData - The 'rooms' /sync data from a SyncAccumulator
|
||||
* @returns Promise which resolves if the data was persisted.
|
||||
*/
|
||||
private persistSyncData;
|
||||
/**
|
||||
* Persist a list of account data events. Events with the same 'type' will
|
||||
* be replaced.
|
||||
* @param accountData - An array of raw user-scoped account data events
|
||||
* @returns Promise which resolves if the events were persisted.
|
||||
*/
|
||||
private persistAccountData;
|
||||
/**
|
||||
* Persist a list of [user id, presence event] they are for.
|
||||
* Users with the same 'userId' will be replaced.
|
||||
* Presence events should be the event in its raw form (not the Event
|
||||
* object)
|
||||
* @param tuples - An array of [userid, event] tuples
|
||||
* @returns Promise which resolves if the users were persisted.
|
||||
*/
|
||||
private persistUserPresenceEvents;
|
||||
/**
|
||||
* Load all user presence events from the database. This is not cached.
|
||||
* FIXME: It would probably be more sensible to store the events in the
|
||||
* sync.
|
||||
* @returns A list of presence events in their raw form.
|
||||
*/
|
||||
getUserPresenceEvents(): Promise<UserTuple[]>;
|
||||
/**
|
||||
* Load all the account data events from the database. This is not cached.
|
||||
* @returns A list of raw global account events.
|
||||
*/
|
||||
private loadAccountData;
|
||||
/**
|
||||
* Load the sync data from the database.
|
||||
* @returns An object with "roomsData" and "nextBatch" keys.
|
||||
*/
|
||||
private loadSyncData;
|
||||
getClientOptions(): Promise<IStoredClientOpts | undefined>;
|
||||
storeClientOptions(options: IStoredClientOpts): Promise<void>;
|
||||
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
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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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;;OAKG;IACH,OAAO,CAAC,eAAe;IAgBvB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;IAcjC;;;;;OAKG;IACI,qBAAqB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAQnD;IAED;;;OAGG;IACH,OAAO,CAAC,eAAe;IAcvB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAiBb,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAQhE;IAEY,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQzE;IAEY,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjF;IAEY,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAc1E;IAEY,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1D;IAEY,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAQhF;IAEY,iBAAiB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxF;IAEY,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhE;IAEY,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQnF;IAKY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpC;CACJ"}
|
||||
605
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js
generated
vendored
Normal file
605
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js
generated
vendored
Normal file
@@ -0,0 +1,605 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
/*
|
||||
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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 { 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", {
|
||||
keyPath: ["userId"]
|
||||
});
|
||||
|
||||
// Make account data store, clobber based on event type.
|
||||
// (event.type property of MatrixEvent objects)
|
||||
db.createObjectStore("accountData", {
|
||||
keyPath: ["type"]
|
||||
});
|
||||
|
||||
// Make /sync store (sync tokens, room data, etc), always clobber (const key).
|
||||
db.createObjectStore("sync", {
|
||||
keyPath: ["clobber"]
|
||||
});
|
||||
}, db => {
|
||||
const oobMembersStore = db.createObjectStore("oob_membership_events", {
|
||||
keyPath: ["room_id", "state_key"]
|
||||
});
|
||||
oobMembersStore.createIndex("room", "room_id");
|
||||
}, db => {
|
||||
db.createObjectStore("client_options", {
|
||||
keyPath: ["clobber"]
|
||||
});
|
||||
}, db => {
|
||||
db.createObjectStore("to_device_queue", {
|
||||
autoIncrement: true
|
||||
});
|
||||
}, db => {
|
||||
db.createObjectStore("user_profile", {
|
||||
keyPath: ["userId"]
|
||||
});
|
||||
}
|
||||
// Expand as needed.
|
||||
];
|
||||
const VERSION = DB_MIGRATIONS.length;
|
||||
|
||||
/**
|
||||
* Helper method to collect results from a Cursor and promiseify it.
|
||||
* @param store - The store to perform openCursor on.
|
||||
* @param keyRange - Optional key range to apply on the cursor.
|
||||
* @param resultMapper - A function which is repeatedly called with a
|
||||
* Cursor.
|
||||
* 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
|
||||
}));
|
||||
};
|
||||
// collect results
|
||||
query.onsuccess = () => {
|
||||
const cursor = query.result;
|
||||
if (!cursor) {
|
||||
resolve(results);
|
||||
return; // end of results
|
||||
}
|
||||
results.push(resultMapper(cursor));
|
||||
cursor.continue();
|
||||
};
|
||||
});
|
||||
}
|
||||
function txnAsPromise(txn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
txn.oncomplete = function (event) {
|
||||
resolve(event);
|
||||
};
|
||||
txn.onerror = function () {
|
||||
reject(txn.error);
|
||||
};
|
||||
});
|
||||
}
|
||||
function reqAsEventPromise(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
req.onsuccess = function (event) {
|
||||
resolve(event);
|
||||
};
|
||||
req.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
});
|
||||
}
|
||||
function reqAsPromise(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
req.onsuccess = () => resolve(req);
|
||||
req.onerror = err => reject(err);
|
||||
});
|
||||
}
|
||||
function reqAsCursorPromise(req) {
|
||||
return reqAsEventPromise(req).then(event => req.result);
|
||||
}
|
||||
export class LocalIndexedDBStoreBackend {
|
||||
static exists(indexedDB, dbName) {
|
||||
dbName = "matrix-js-sdk:" + (dbName || "default");
|
||||
return idbExists(indexedDB, dbName);
|
||||
}
|
||||
/**
|
||||
* Does the actual reading from and writing to the indexeddb
|
||||
*
|
||||
* Construct a new Indexed Database store backend. This requires a call to
|
||||
* `connect()` before this store can be used.
|
||||
* @param indexedDB - The Indexed DB interface e.g
|
||||
* `window.indexedDB`
|
||||
* @param dbName - Optional database name. The same name must be used
|
||||
* 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;
|
||||
this.dbName = "matrix-js-sdk:" + dbName;
|
||||
this.syncAccumulator = new SyncAccumulator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to connect to the database. This can fail if the user does not
|
||||
* grant permission.
|
||||
* @returns Promise which resolves if successfully connected.
|
||||
*/
|
||||
connect(onClose) {
|
||||
if (!this.disconnected) {
|
||||
logger.log(`LocalIndexedDBStoreBackend.connect: already connected or connecting`);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.disconnected = false;
|
||||
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}`);
|
||||
if (oldVersion < 1) {
|
||||
// The database did not previously exist
|
||||
this._isNewlyCreated = true;
|
||||
}
|
||||
DB_MIGRATIONS.forEach((migration, index) => {
|
||||
if (oldVersion <= index) migration(db);
|
||||
});
|
||||
};
|
||||
req.onblocked = () => {
|
||||
logger.log(`can't yet open LocalIndexedDBStoreBackend because it is open elsewhere`);
|
||||
};
|
||||
logger.log(`LocalIndexedDBStoreBackend.connect: awaiting connection...`);
|
||||
return reqAsEventPromise(req).then(async () => {
|
||||
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
|
||||
this.disconnected = true;
|
||||
this.db = undefined;
|
||||
};
|
||||
this.db.onclose = () => {
|
||||
this.disconnected = true;
|
||||
this.db = undefined;
|
||||
onClose?.();
|
||||
};
|
||||
await this.init();
|
||||
});
|
||||
}
|
||||
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated() {
|
||||
return Promise.resolve(this._isNewlyCreated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Having connected, load initial data from the database and prepare for use
|
||||
* @returns Promise which resolves on success
|
||||
*/
|
||||
init() {
|
||||
return Promise.all([this.loadAccountData(), this.loadSyncData()]).then(([accountData, syncData]) => {
|
||||
logger.log(`LocalIndexedDBStoreBackend: loaded initial data`);
|
||||
this.syncAccumulator.accumulate({
|
||||
next_batch: syncData.nextBatch,
|
||||
rooms: syncData.roomsData,
|
||||
account_data: {
|
||||
events: accountData
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = this.db.transaction(["oob_membership_events"], "readonly");
|
||||
const store = tx.objectStore("oob_membership_events");
|
||||
const roomIndex = store.index("room");
|
||||
const range = IDBKeyRange.only(roomId);
|
||||
const request = roomIndex.openCursor(range);
|
||||
const membershipEvents = [];
|
||||
// did we encounter the oob_written marker object
|
||||
// amongst the results? That means OOB member
|
||||
// loading already happened for this room
|
||||
// but there were no members to persist as they
|
||||
// were all known already
|
||||
let oobWritten = false;
|
||||
request.onsuccess = () => {
|
||||
const cursor = request.result;
|
||||
if (!cursor) {
|
||||
// Unknown room
|
||||
if (!membershipEvents.length && !oobWritten) {
|
||||
return resolve(null);
|
||||
}
|
||||
return resolve(membershipEvents);
|
||||
}
|
||||
const record = cursor.value;
|
||||
if (record.oob_written) {
|
||||
oobWritten = true;
|
||||
} else {
|
||||
membershipEvents.push(record);
|
||||
}
|
||||
cursor.continue();
|
||||
};
|
||||
request.onerror = err => {
|
||||
reject(err);
|
||||
};
|
||||
}).then(events => {
|
||||
logger.log(`LL: got ${events?.length} membershipEvents from storage for room ${roomId} ...`);
|
||||
return events;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
*/
|
||||
async setOutOfBandMembers(roomId, membershipEvents) {
|
||||
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 => {
|
||||
store.put(e);
|
||||
});
|
||||
// aside from all the events, we also write a marker object to the store
|
||||
// to mark the fact that OOB members have been written for this room.
|
||||
// It's possible that 0 members need to be written as all where previously know
|
||||
// but we still need to know whether to return null or [] from getOutOfBandMembers
|
||||
// where null means out of band members haven't been stored yet for this room
|
||||
const markerObject = {
|
||||
room_id: roomId,
|
||||
oob_written: true,
|
||||
state_key: 0
|
||||
};
|
||||
store.put(markerObject);
|
||||
await txnAsPromise(tx);
|
||||
logger.log(`LL: backend done storing for ${roomId}!`);
|
||||
}
|
||||
async clearOutOfBandMembers(roomId) {
|
||||
// the approach to delete all members for a room
|
||||
// is to get the min and max state key from the index
|
||||
// for that room, and then delete between those
|
||||
// keys in the store.
|
||||
// this should be way faster than deleting every member
|
||||
// individually for a large room.
|
||||
const readTx = this.db.transaction(["oob_membership_events"], "readonly");
|
||||
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 [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]);
|
||||
await reqAsPromise(writeStore.delete(membersKeyRange));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the entire database. This should be used when logging out of a client
|
||||
* to prevent mixing data between accounts. Closes the database.
|
||||
* @returns Resolved when the database is cleared.
|
||||
*/
|
||||
clearDatabase() {
|
||||
return new Promise(resolve => {
|
||||
logger.log(`Removing indexeddb instance: ${this.dbName}`);
|
||||
|
||||
// Close the database first to avoid firing unexpected close events
|
||||
this.db?.close();
|
||||
const req = this.indexedDB.deleteDatabase(this.dbName);
|
||||
req.onblocked = () => {
|
||||
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}`);
|
||||
resolve();
|
||||
};
|
||||
req.onsuccess = () => {
|
||||
logger.log(`Removed indexeddb instance: ${this.dbName}`);
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param copy - If false, the data returned is from internal
|
||||
* buffers and must not be mutated. Otherwise, a copy is made before
|
||||
* returning such that the data can be safely mutated. Default: true.
|
||||
*
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync(copy = true) {
|
||||
const data = this.syncAccumulator.getJSON();
|
||||
if (!data.nextBatch) return Promise.resolve(null);
|
||||
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));
|
||||
} else {
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
}
|
||||
getNextBatchToken() {
|
||||
return Promise.resolve(this.syncAccumulator.getNextBatchToken());
|
||||
}
|
||||
setSyncData(syncData) {
|
||||
return Promise.resolve().then(() => {
|
||||
this.syncAccumulator.accumulate(syncData);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync users and all accumulated sync data to the database.
|
||||
* If a previous sync is in flight, the new data will be added to the
|
||||
* next sync and the current sync's promise will be returned.
|
||||
* @param userTuples - The user tuples
|
||||
* @returns Promise which resolves if the data was persisted.
|
||||
*/
|
||||
async syncToDatabase(userTuples) {
|
||||
if (this.syncToDatabasePromise) {
|
||||
logger.warn("Skipping syncToDatabase() as persist already in flight");
|
||||
this.pendingUserPresenceData.push(...userTuples);
|
||||
return this.syncToDatabasePromise;
|
||||
}
|
||||
userTuples.unshift(...this.pendingUserPresenceData);
|
||||
this.syncToDatabasePromise = this.doSyncToDatabase(userTuples);
|
||||
return this.syncToDatabasePromise;
|
||||
}
|
||||
async doSyncToDatabase(userTuples) {
|
||||
try {
|
||||
const syncData = this.syncAccumulator.getJSON(true);
|
||||
await Promise.all([this.persistUserPresenceEvents(userTuples), this.persistAccountData(syncData.accountData), this.persistSyncData(syncData.nextBatch, syncData.roomsData)]);
|
||||
} finally {
|
||||
this.syncToDatabasePromise = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist rooms /sync data along with the next batch token.
|
||||
* @param nextBatch - The next_batch /sync value.
|
||||
* @param roomsData - The 'rooms' /sync data from a SyncAccumulator
|
||||
* @returns Promise which resolves if the data was persisted.
|
||||
*/
|
||||
persistSyncData(nextBatch, roomsData) {
|
||||
logger.log("Persisting sync data up to", nextBatch);
|
||||
return promiseTry(() => {
|
||||
const txn = this.db.transaction(["sync"], "readwrite");
|
||||
const store = txn.objectStore("sync");
|
||||
store.put({
|
||||
clobber: "-",
|
||||
// constant key so will always clobber
|
||||
nextBatch,
|
||||
roomsData
|
||||
}); // put == UPSERT
|
||||
return txnAsPromise(txn).then(() => {
|
||||
logger.log("Persisted sync data up to", nextBatch);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a list of account data events. Events with the same 'type' will
|
||||
* be replaced.
|
||||
* @param accountData - An array of raw user-scoped account data events
|
||||
* @returns Promise which resolves if the events were persisted.
|
||||
*/
|
||||
persistAccountData(accountData) {
|
||||
return 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();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a list of [user id, presence event] they are for.
|
||||
* Users with the same 'userId' will be replaced.
|
||||
* Presence events should be the event in its raw form (not the Event
|
||||
* object)
|
||||
* @param tuples - An array of [userid, event] tuples
|
||||
* @returns Promise which resolves if the users were persisted.
|
||||
*/
|
||||
persistUserPresenceEvents(tuples) {
|
||||
return promiseTry(() => {
|
||||
const txn = this.db.transaction(["users"], "readwrite");
|
||||
const store = txn.objectStore("users");
|
||||
for (const tuple of tuples) {
|
||||
store.put({
|
||||
userId: tuple[0],
|
||||
event: tuple[1]
|
||||
}); // put == UPSERT
|
||||
}
|
||||
return txnAsPromise(txn).then();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all user presence events from the database. This is not cached.
|
||||
* FIXME: It would probably be more sensible to store the events in the
|
||||
* sync.
|
||||
* @returns A list of presence events in their raw form.
|
||||
*/
|
||||
getUserPresenceEvents() {
|
||||
return promiseTry(() => {
|
||||
const txn = this.db.transaction(["users"], "readonly");
|
||||
const store = txn.objectStore("users");
|
||||
return selectQuery(store, undefined, cursor => {
|
||||
return [cursor.value.userId, cursor.value.event];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the account data events from the database. This is not cached.
|
||||
* @returns A list of raw global account events.
|
||||
*/
|
||||
loadAccountData() {
|
||||
logger.log(`LocalIndexedDBStoreBackend: loading account data...`);
|
||||
return 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`);
|
||||
return result;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the sync data from the database.
|
||||
* @returns An object with "roomsData" and "nextBatch" keys.
|
||||
*/
|
||||
loadSyncData() {
|
||||
logger.log(`LocalIndexedDBStoreBackend: loading sync data...`);
|
||||
return 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`);
|
||||
if (results.length > 1) {
|
||||
logger.warn("loadSyncData: More than 1 sync row found.");
|
||||
}
|
||||
return results.length > 0 ? results[0] : {};
|
||||
});
|
||||
});
|
||||
}
|
||||
getClientOptions() {
|
||||
return Promise.resolve().then(() => {
|
||||
const txn = this.db.transaction(["client_options"], "readonly");
|
||||
const store = txn.objectStore("client_options");
|
||||
return selectQuery(store, undefined, cursor => {
|
||||
return cursor.value?.options;
|
||||
}).then(results => results[0]);
|
||||
});
|
||||
}
|
||||
async storeClientOptions(options) {
|
||||
const txn = this.db.transaction(["client_options"], "readwrite");
|
||||
const store = txn.objectStore("client_options");
|
||||
store.put({
|
||||
clobber: "-",
|
||||
// constant key so will always clobber
|
||||
options: options
|
||||
}); // put == UPSERT
|
||||
await txnAsPromise(txn);
|
||||
}
|
||||
async saveToDeviceBatches(batches) {
|
||||
const txn = this.db.transaction(["to_device_queue"], "readwrite");
|
||||
const store = txn.objectStore("to_device_queue");
|
||||
for (const batch of batches) {
|
||||
store.add(batch);
|
||||
}
|
||||
await txnAsPromise(txn);
|
||||
}
|
||||
async getOldestToDeviceBatch() {
|
||||
const txn = this.db.transaction(["to_device_queue"], "readonly");
|
||||
const store = txn.objectStore("to_device_queue");
|
||||
const cursor = await reqAsCursorPromise(store.openCursor());
|
||||
if (!cursor) return null;
|
||||
const resultBatch = cursor.value;
|
||||
return {
|
||||
id: cursor.key,
|
||||
txnId: resultBatch.txnId,
|
||||
eventType: resultBatch.eventType,
|
||||
batch: resultBatch.batch
|
||||
};
|
||||
}
|
||||
async removeToDeviceBatch(id) {
|
||||
const txn = this.db.transaction(["to_device_queue"], "readwrite");
|
||||
const store = txn.objectStore("to_device_queue");
|
||||
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();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-local-backend.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
85
node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts
generated
vendored
Normal file
85
node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
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";
|
||||
export declare class RemoteIndexedDBStoreBackend implements IIndexedDBBackend {
|
||||
private readonly workerFactory;
|
||||
private readonly dbName?;
|
||||
private worker?;
|
||||
private nextSeq;
|
||||
private inFlight;
|
||||
private startPromiseResolvers?;
|
||||
private onClose;
|
||||
/**
|
||||
* An IndexedDB store backend where the actual backend sits in a web
|
||||
* worker.
|
||||
*
|
||||
* Construct a new Indexed Database store backend. This requires a call to
|
||||
* `connect()` before this store can be used.
|
||||
* @param workerFactory - Factory which produces a Worker
|
||||
* @param dbName - Optional database name. The same name must be used
|
||||
* to open the same database.
|
||||
*/
|
||||
constructor(workerFactory: () => Worker, dbName?: string | undefined);
|
||||
/**
|
||||
* Attempt to connect to the database. This can fail if the user does not
|
||||
* grant permission.
|
||||
* @returns Promise which resolves if successfully connected.
|
||||
*/
|
||||
connect(onClose?: () => void): Promise<void>;
|
||||
/**
|
||||
* Clear the entire database. This should be used when logging out of a client
|
||||
* to prevent mixing data between accounts.
|
||||
* @returns Resolved when the database is cleared.
|
||||
*/
|
||||
clearDatabase(): Promise<void>;
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync(): Promise<ISavedSync>;
|
||||
getNextBatchToken(): Promise<string>;
|
||||
setSyncData(syncData: ISyncResponse): Promise<void>;
|
||||
syncToDatabase(userTuples: UserTuple[]): Promise<void>;
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;
|
||||
clearOutOfBandMembers(roomId: string): Promise<void>;
|
||||
getClientOptions(): Promise<IStoredClientOpts | undefined>;
|
||||
storeClientOptions(options: IStoredClientOpts): Promise<void>;
|
||||
/**
|
||||
* Load all user presence events from the database. This is not cached.
|
||||
* @returns A list of presence events in their raw form.
|
||||
*/
|
||||
getUserPresenceEvents(): Promise<UserTuple[]>;
|
||||
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>;
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-remote-backend.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,K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generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
/*
|
||||
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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 { logger } from "../logger.js";
|
||||
export class RemoteIndexedDBStoreBackend {
|
||||
// Callback for when the IndexedDB gets closed unexpectedly
|
||||
|
||||
/**
|
||||
* An IndexedDB store backend where the actual backend sits in a web
|
||||
* worker.
|
||||
*
|
||||
* Construct a new Indexed Database store backend. This requires a call to
|
||||
* `connect()` before this store can be used.
|
||||
* @param workerFactory - Factory which produces a Worker
|
||||
* @param dbName - Optional database name. The same name must be used
|
||||
* to open the same database.
|
||||
*/
|
||||
constructor(workerFactory, dbName) {
|
||||
_defineProperty(this, "worker", void 0);
|
||||
_defineProperty(this, "nextSeq", 0);
|
||||
// The currently in-flight requests to the actual backend
|
||||
_defineProperty(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 => {
|
||||
const msg = ev.data;
|
||||
if (msg.command == "closed") {
|
||||
this.onClose?.();
|
||||
} else if (msg.command == "cmd_success" || msg.command == "cmd_fail") {
|
||||
if (msg.seq === undefined) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
delete this.inFlight[msg.seq];
|
||||
if (msg.command == "cmd_success") {
|
||||
def.resolve(msg.result);
|
||||
} else {
|
||||
const error = new Error(msg.error.message);
|
||||
error.name = msg.error.name;
|
||||
def.reject(error);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Unrecognised message from worker: ", msg);
|
||||
}
|
||||
});
|
||||
this.workerFactory = workerFactory;
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to connect to the database. This can fail if the user does not
|
||||
* grant permission.
|
||||
* @returns Promise which resolves if successfully connected.
|
||||
*/
|
||||
connect(onClose) {
|
||||
this.onClose = onClose;
|
||||
return this.ensureStarted().then(() => this.doCmd("connect"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the entire database. This should be used when logging out of a client
|
||||
* to prevent mixing data between accounts.
|
||||
* @returns Resolved when the database is cleared.
|
||||
*/
|
||||
clearDatabase() {
|
||||
return this.ensureStarted().then(() => this.doCmd("clearDatabase"));
|
||||
}
|
||||
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated() {
|
||||
return this.doCmd("isNewlyCreated");
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync() {
|
||||
return this.doCmd("getSavedSync");
|
||||
}
|
||||
getNextBatchToken() {
|
||||
return this.doCmd("getNextBatchToken");
|
||||
}
|
||||
setSyncData(syncData) {
|
||||
return this.doCmd("setSyncData", [syncData]);
|
||||
}
|
||||
syncToDatabase(userTuples) {
|
||||
return this.doCmd("syncToDatabase", [userTuples]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId) {
|
||||
return this.doCmd("getOutOfBandMembers", [roomId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
setOutOfBandMembers(roomId, membershipEvents) {
|
||||
return this.doCmd("setOutOfBandMembers", [roomId, membershipEvents]);
|
||||
}
|
||||
clearOutOfBandMembers(roomId) {
|
||||
return this.doCmd("clearOutOfBandMembers", [roomId]);
|
||||
}
|
||||
getClientOptions() {
|
||||
return this.doCmd("getClientOptions");
|
||||
}
|
||||
storeClientOptions(options) {
|
||||
return this.doCmd("storeClientOptions", [options]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all user presence events from the database. This is not cached.
|
||||
* @returns A list of presence events in their raw form.
|
||||
*/
|
||||
getUserPresenceEvents() {
|
||||
return this.doCmd("getUserPresenceEvents");
|
||||
}
|
||||
async saveToDeviceBatches(batches) {
|
||||
return this.doCmd("saveToDeviceBatches", [batches]);
|
||||
}
|
||||
async getOldestToDeviceBatch() {
|
||||
return this.doCmd("getOldestToDeviceBatch");
|
||||
}
|
||||
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;
|
||||
}
|
||||
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();
|
||||
});
|
||||
}
|
||||
return this.startPromiseResolvers.promise;
|
||||
}
|
||||
doCmd(command, args) {
|
||||
// wrap in a q so if the postMessage throws,
|
||||
// the promise automatically gets rejected
|
||||
return Promise.resolve().then(() => {
|
||||
const seq = this.nextSeq++;
|
||||
const def = Promise.withResolvers();
|
||||
this.inFlight[seq] = def;
|
||||
this.worker?.postMessage({
|
||||
command,
|
||||
seq,
|
||||
args
|
||||
});
|
||||
return def.promise;
|
||||
});
|
||||
}
|
||||
/*
|
||||
* Destroy the web worker
|
||||
*/
|
||||
async destroy() {
|
||||
this.worker?.terminate();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-remote-backend.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
35
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.d.ts
generated
vendored
Normal file
35
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* This class lives in the webworker and drives a LocalIndexedDBStoreBackend
|
||||
* controlled by messages from the main process.
|
||||
*
|
||||
* @example
|
||||
* It should be instantiated by a web worker script provided by the application
|
||||
* in a script, for example:
|
||||
* ```
|
||||
* import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js';
|
||||
* const remoteWorker = new IndexedDBStoreWorker(postMessage);
|
||||
* onmessage = remoteWorker.onMessage;
|
||||
* ```
|
||||
*
|
||||
* Note that it is advisable to import this class by referencing the file directly to
|
||||
* avoid a dependency on the whole js-sdk.
|
||||
*
|
||||
*/
|
||||
export declare class IndexedDBStoreWorker {
|
||||
private readonly postMessage;
|
||||
private backend?;
|
||||
/**
|
||||
* @param postMessage - The web worker postMessage function that
|
||||
* should be used to communicate back to the main script.
|
||||
*/
|
||||
constructor(postMessage: InstanceType<typeof Worker>["postMessage"]);
|
||||
private onClose;
|
||||
/**
|
||||
* Passes a message event from the main script into the class. This method
|
||||
* can be directly assigned to the web worker `onmessage` variable.
|
||||
*
|
||||
* @param ev - The message event
|
||||
*/
|
||||
onMessage: (ev: MessageEvent) => void;
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-store-worker.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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"}
|
||||
155
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js
generated
vendored
Normal file
155
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
/*
|
||||
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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 { 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.
|
||||
*
|
||||
* @example
|
||||
* It should be instantiated by a web worker script provided by the application
|
||||
* in a script, for example:
|
||||
* ```
|
||||
* import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js';
|
||||
* const remoteWorker = new IndexedDBStoreWorker(postMessage);
|
||||
* onmessage = remoteWorker.onMessage;
|
||||
* ```
|
||||
*
|
||||
* Note that it is advisable to import this class by referencing the file directly to
|
||||
* avoid a dependency on the whole js-sdk.
|
||||
*
|
||||
*/
|
||||
export 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.call(null, {
|
||||
command: "closed"
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Passes a message event from the main script into the class. This method
|
||||
* can be directly assigned to the web worker `onmessage` variable.
|
||||
*
|
||||
* @param ev - The message event
|
||||
*/
|
||||
_defineProperty(this, "onMessage", ev => {
|
||||
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]);
|
||||
prom = Promise.resolve();
|
||||
break;
|
||||
case "connect":
|
||||
prom = this.backend?.connect(this.onClose);
|
||||
break;
|
||||
case "isNewlyCreated":
|
||||
prom = this.backend?.isNewlyCreated();
|
||||
break;
|
||||
case "clearDatabase":
|
||||
prom = this.backend?.clearDatabase();
|
||||
break;
|
||||
case "getSavedSync":
|
||||
prom = this.backend?.getSavedSync(false);
|
||||
break;
|
||||
case "setSyncData":
|
||||
prom = this.backend?.setSyncData(msg.args[0]);
|
||||
break;
|
||||
case "syncToDatabase":
|
||||
prom = this.backend?.syncToDatabase(msg.args[0]);
|
||||
break;
|
||||
case "getUserPresenceEvents":
|
||||
prom = this.backend?.getUserPresenceEvents();
|
||||
break;
|
||||
case "getNextBatchToken":
|
||||
prom = this.backend?.getNextBatchToken();
|
||||
break;
|
||||
case "getOutOfBandMembers":
|
||||
prom = this.backend?.getOutOfBandMembers(msg.args[0]);
|
||||
break;
|
||||
case "clearOutOfBandMembers":
|
||||
prom = this.backend?.clearOutOfBandMembers(msg.args[0]);
|
||||
break;
|
||||
case "setOutOfBandMembers":
|
||||
prom = this.backend?.setOutOfBandMembers(msg.args[0], msg.args[1]);
|
||||
break;
|
||||
case "getClientOptions":
|
||||
prom = this.backend?.getClientOptions();
|
||||
break;
|
||||
case "storeClientOptions":
|
||||
prom = this.backend?.storeClientOptions(msg.args[0]);
|
||||
break;
|
||||
case "saveToDeviceBatches":
|
||||
prom = this.backend?.saveToDeviceBatches(msg.args[0]);
|
||||
break;
|
||||
case "getOldestToDeviceBatch":
|
||||
prom = this.backend?.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]);
|
||||
break;
|
||||
}
|
||||
if (prom === undefined) {
|
||||
this.postMessage({
|
||||
command: "cmd_fail",
|
||||
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;
|
||||
}
|
||||
prom.then(ret => {
|
||||
this.postMessage.call(null, {
|
||||
command: "cmd_success",
|
||||
seq: msg.seq,
|
||||
result: ret
|
||||
});
|
||||
}, err => {
|
||||
logger.error("Error running command: " + msg.command, err);
|
||||
this.postMessage.call(null, {
|
||||
command: "cmd_fail",
|
||||
seq: msg.seq,
|
||||
// Just send a string because Error objects aren't cloneable
|
||||
error: {
|
||||
message: err.message,
|
||||
name: err.name
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
this.postMessage = postMessage;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=indexeddb-store-worker.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
148
node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts
generated
vendored
Normal file
148
node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
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";
|
||||
interface IOpts extends IBaseOpts {
|
||||
/** The Indexed DB interface e.g. `window.indexedDB` */
|
||||
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;
|
||||
}
|
||||
export declare class IndexedDBStore extends MemoryStore {
|
||||
private readonly opts;
|
||||
static exists(indexedDB: IDBFactory, dbName: string): Promise<boolean>;
|
||||
_backend: IIndexedDBBackend;
|
||||
private startedUp;
|
||||
private syncTs;
|
||||
private userModifiedMap;
|
||||
private emitter;
|
||||
/**
|
||||
* Construct a new Indexed Database store, which extends MemoryStore.
|
||||
*
|
||||
* This store functions like a MemoryStore except it periodically persists
|
||||
* the contents of the store to an IndexedDB backend.
|
||||
*
|
||||
* All data is still kept in-memory but can be loaded from disk by calling
|
||||
* `startup()`. This can make startup times quicker as a complete
|
||||
* sync from the server is not required. This does not reduce memory usage as all
|
||||
* the data is eagerly fetched when `startup()` is called.
|
||||
* ```
|
||||
* let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
|
||||
* let store = new IndexedDBStore(opts);
|
||||
* 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") {
|
||||
* console.log("Started up, now with go faster stripes!");
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @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;
|
||||
/**
|
||||
* @returns Resolved when loaded from indexed db.
|
||||
*/
|
||||
startup(): Promise<void>;
|
||||
destroy(): Promise<void>;
|
||||
private onClose;
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync: DegradableFn<[], ISavedSync | null>;
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated: DegradableFn<[], boolean>;
|
||||
/**
|
||||
* @returns If there is a saved sync, the nextBatch token
|
||||
* for this sync, otherwise null.
|
||||
*/
|
||||
getSavedSyncToken: DegradableFn<[], string | null>;
|
||||
/**
|
||||
* Delete all data from this store.
|
||||
* @returns Promise which resolves if the data was deleted from the database.
|
||||
*/
|
||||
deleteAllData: DegradableFn<[], void>;
|
||||
/**
|
||||
* Whether this store would like to save its data
|
||||
* Note that obviously whether the store wants to save or
|
||||
* not could change between calling this function and calling
|
||||
* save().
|
||||
*
|
||||
* @returns True if calling save() will actually save
|
||||
* (at the time this function is called).
|
||||
*/
|
||||
wantsSave(): boolean;
|
||||
/**
|
||||
* Possibly write data to the database.
|
||||
*
|
||||
* @param force - True to force a save to happen
|
||||
* @returns Promise resolves after the write completes
|
||||
* (or immediately if no write is performed)
|
||||
*/
|
||||
save(force?: boolean): Promise<void>;
|
||||
private reallySave;
|
||||
setSyncData: DegradableFn<[syncData: ISyncResponse], void>;
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers: DegradableFn<[roomId: string], IStateEventWithRoomId[] | null>;
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
setOutOfBandMembers: DegradableFn<[roomId: string, membershipEvents: IStateEventWithRoomId[]], void>;
|
||||
clearOutOfBandMembers: DegradableFn<[roomId: string], void>;
|
||||
getClientOptions: DegradableFn<[], IStoredClientOpts | undefined>;
|
||||
storeClientOptions: DegradableFn<[options: IStoredClientOpts], void>;
|
||||
/**
|
||||
* All member functions of `IndexedDBStore` that access the backend use this wrapper to
|
||||
* watch for failures after initial store startup, including `QuotaExceededError` as
|
||||
* free disk space changes, etc.
|
||||
*
|
||||
* When IndexedDB fails via any of these paths, we degrade this back to a `MemoryStore`
|
||||
* in place so that the current operation and all future ones are in-memory only.
|
||||
*
|
||||
* @param func - The degradable work to do.
|
||||
* @param fallback - The method name for fallback.
|
||||
* @returns A wrapped member function.
|
||||
*/
|
||||
private degradable;
|
||||
getPendingEvents(roomId: string): Promise<Partial<IEvent>[]>;
|
||||
setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void>;
|
||||
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 {};
|
||||
//# sourceMappingURL=indexeddb.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,oBAAoB,CAAC;AAE9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,kBAAkB,EAAqB,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAazD,UAAU,KAAM,SAAQ,SAAS;IAC7B,uDAAuD;IACvD,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;CAChC;AAWD,qBAAa,cAAe,SAAQ,WAAW;IA0CxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAzCxC,OAAc,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,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AM,CAAC,EAAE,CAAC,CAYxE;IAEY,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQtF;IAEM,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;IAEM,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAEpE;IAEM,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpD;IAEY,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAEhF;IAEY,iBAAiB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF;IAEY,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;CACJ;AAUD,KAAK,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
||||
349
node_modules/matrix-js-sdk/lib/store/indexeddb.js
generated
vendored
Normal file
349
node_modules/matrix-js-sdk/lib/store/indexeddb.js
generated
vendored
Normal file
@@ -0,0 +1,349 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
/*
|
||||
Copyright 2017 - 2021 Vector Creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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 { 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";
|
||||
/**
|
||||
* This is an internal module. See {@link IndexedDBStore} for the public class.
|
||||
*/
|
||||
|
||||
// If this value is too small we'll be writing very often which will cause
|
||||
// noticeable stop-the-world pauses. If this value is too big we'll be writing
|
||||
// so infrequently that the /sync size gets bigger on reload. Writing more
|
||||
// often does not affect the length of the pause since the entire /sync
|
||||
// response is persisted each time.
|
||||
const WRITE_DELAY_MS = 1000 * 60 * 5; // once every 5 minutes
|
||||
|
||||
export class IndexedDBStore extends MemoryStore {
|
||||
static exists(indexedDB, dbName) {
|
||||
return LocalIndexedDBStoreBackend.exists(indexedDB, dbName);
|
||||
}
|
||||
/**
|
||||
* Construct a new Indexed Database store, which extends MemoryStore.
|
||||
*
|
||||
* This store functions like a MemoryStore except it periodically persists
|
||||
* the contents of the store to an IndexedDB backend.
|
||||
*
|
||||
* All data is still kept in-memory but can be loaded from disk by calling
|
||||
* `startup()`. This can make startup times quicker as a complete
|
||||
* sync from the server is not required. This does not reduce memory usage as all
|
||||
* the data is eagerly fetched when `startup()` is called.
|
||||
* ```
|
||||
* let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
|
||||
* let store = new IndexedDBStore(opts);
|
||||
* 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") {
|
||||
* console.log("Started up, now with go faster stripes!");
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param opts - Options object.
|
||||
*/
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
_defineProperty(this, "_backend", void 0);
|
||||
_defineProperty(this, "startedUp", false);
|
||||
_defineProperty(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", {});
|
||||
// user_id : timestamp
|
||||
_defineProperty(this, "emitter", new TypedEventEmitter());
|
||||
_defineProperty(this, "onClose", () => {
|
||||
this.emitter.emit("closed");
|
||||
});
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
_defineProperty(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(() => {
|
||||
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(() => {
|
||||
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(() => {
|
||||
super.deleteAllData();
|
||||
return this.backend.clearDatabase().then(() => {
|
||||
logger.log("Deleted indexeddb data.");
|
||||
}, err => {
|
||||
logger.error(`Failed to delete indexeddb data: ${err}`);
|
||||
throw err;
|
||||
});
|
||||
}, null));
|
||||
_defineProperty(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
|
||||
// can't 'delete' users as they are just presence events).
|
||||
const userTuples = [];
|
||||
for (const u of this.getUsers()) {
|
||||
if (this.userModifiedMap[u.userId] === u.getLastModifiedTime()) continue;
|
||||
if (!u.events.presence) continue;
|
||||
userTuples.push([u.userId, u.events.presence.event]);
|
||||
|
||||
// note that we've saved this version of the user
|
||||
this.userModifiedMap[u.userId] = u.getLastModifiedTime();
|
||||
}
|
||||
return this.backend.syncToDatabase(userTuples);
|
||||
}, null));
|
||||
_defineProperty(this, "setSyncData", this.degradable(syncData => {
|
||||
return this.backend.setSyncData(syncData);
|
||||
}, "setSyncData"));
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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 => {
|
||||
return this.backend.getOutOfBandMembers(roomId);
|
||||
}, "getOutOfBandMembers"));
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
_defineProperty(this, "setOutOfBandMembers", this.degradable((roomId, membershipEvents) => {
|
||||
super.setOutOfBandMembers(roomId, membershipEvents);
|
||||
return this.backend.setOutOfBandMembers(roomId, membershipEvents);
|
||||
}, "setOutOfBandMembers"));
|
||||
_defineProperty(this, "clearOutOfBandMembers", this.degradable(roomId => {
|
||||
super.clearOutOfBandMembers(roomId);
|
||||
return this.backend.clearOutOfBandMembers(roomId);
|
||||
}, "clearOutOfBandMembers"));
|
||||
_defineProperty(this, "getClientOptions", this.degradable(() => {
|
||||
return this.backend.getClientOptions();
|
||||
}, "getClientOptions"));
|
||||
_defineProperty(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);
|
||||
} else {
|
||||
this._backend = new 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`);
|
||||
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`);
|
||||
return this.backend.getUserPresenceEvents();
|
||||
}).then(userPresenceEvents => {
|
||||
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);
|
||||
if (rawEvent) {
|
||||
u.setPresenceEvent(new MatrixEvent(rawEvent));
|
||||
}
|
||||
this.userModifiedMap[u.userId] = u.getLastModifiedTime();
|
||||
this.storeUser(u);
|
||||
});
|
||||
this.startedUp = true;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the database and destroy any associated workers
|
||||
*/
|
||||
destroy() {
|
||||
return this.backend.destroy();
|
||||
}
|
||||
/**
|
||||
* Whether this store would like to save its data
|
||||
* Note that obviously whether the store wants to save or
|
||||
* not could change between calling this function and calling
|
||||
* save().
|
||||
*
|
||||
* @returns True if calling save() will actually save
|
||||
* (at the time this function is called).
|
||||
*/
|
||||
wantsSave() {
|
||||
const now = Date.now();
|
||||
return now - this.syncTs > WRITE_DELAY_MS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possibly write data to the database.
|
||||
*
|
||||
* @param force - True to force a save to happen
|
||||
* @returns Promise resolves after the write completes
|
||||
* (or immediately if no write is performed)
|
||||
*/
|
||||
save(force = false) {
|
||||
if (force || this.wantsSave()) {
|
||||
return this.reallySave();
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
/**
|
||||
* All member functions of `IndexedDBStore` that access the backend use this wrapper to
|
||||
* watch for failures after initial store startup, including `QuotaExceededError` as
|
||||
* free disk space changes, etc.
|
||||
*
|
||||
* When IndexedDB fails via any of these paths, we degrade this back to a `MemoryStore`
|
||||
* in place so that the current operation and all future ones are in-memory only.
|
||||
*
|
||||
* @param func - The degradable work to do.
|
||||
* @param fallback - The method name for fallback.
|
||||
* @returns A wrapped member function.
|
||||
*/
|
||||
degradable(func, fallback) {
|
||||
const fallbackFn = fallback ? super[fallback] : null;
|
||||
return async (...args) => {
|
||||
try {
|
||||
return await func.call(this, ...args);
|
||||
} catch (e) {
|
||||
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");
|
||||
await this.backend.clearDatabase();
|
||||
logger.log("IndexedDBStore delete after degrading succeeded");
|
||||
} catch (e) {
|
||||
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
|
||||
// directly and skip IndexedDB entirely. This should be safe as
|
||||
// `IndexedDBStore` already extends from `MemoryStore`, so we are making the
|
||||
// store become its parent type in a way. The mutator methods of
|
||||
// `IndexedDBStore` also maintain the state that `MemoryStore` uses (many are
|
||||
// not overridden at all).
|
||||
if (fallbackFn) {
|
||||
return fallbackFn.call(this, ...args);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// XXX: ideally these would be stored in indexeddb as part of the room but,
|
||||
// we don't store rooms as such and instead accumulate entire sync responses atm.
|
||||
async getPendingEvents(roomId) {
|
||||
if (!this.localStorage) return super.getPendingEvents(roomId);
|
||||
const serialized = this.localStorage.getItem(pendingEventsKey(roomId));
|
||||
if (serialized) {
|
||||
try {
|
||||
return JSON.parse(serialized);
|
||||
} catch (e) {
|
||||
logger.error("Could not parse persisted pending events", e);
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
async setPendingEvents(roomId, events) {
|
||||
if (!this.localStorage) return super.setPendingEvents(roomId, events);
|
||||
if (events.length > 0) {
|
||||
this.localStorage.setItem(pendingEventsKey(roomId), JSON.stringify(events));
|
||||
} else {
|
||||
this.localStorage.removeItem(pendingEventsKey(roomId));
|
||||
}
|
||||
}
|
||||
saveToDeviceBatches(batches) {
|
||||
return this.backend.saveToDeviceBatches(batches);
|
||||
}
|
||||
getOldestToDeviceBatch() {
|
||||
return this.backend.getOldestToDeviceBatch();
|
||||
}
|
||||
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
|
||||
*/
|
||||
function pendingEventsKey(roomId) {
|
||||
return `mx_pending_events_${roomId}`;
|
||||
}
|
||||
//# sourceMappingURL=indexeddb.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/indexeddb.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/indexeddb.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
30
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.d.ts
generated
vendored
Normal file
30
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
|
||||
export declare enum LocalStorageErrors {
|
||||
Global = "Global",
|
||||
SetItemError = "setItem",
|
||||
GetItemError = "getItem",
|
||||
RemoveItemError = "removeItem",
|
||||
ClearError = "clear",
|
||||
QuotaExceededError = "QuotaExceededError"
|
||||
}
|
||||
type EventHandlerMap = {
|
||||
[LocalStorageErrors.Global]: (error: Error) => void;
|
||||
[LocalStorageErrors.SetItemError]: (error: Error) => void;
|
||||
[LocalStorageErrors.GetItemError]: (error: Error) => void;
|
||||
[LocalStorageErrors.RemoveItemError]: (error: Error) => void;
|
||||
[LocalStorageErrors.ClearError]: (error: Error) => void;
|
||||
[LocalStorageErrors.QuotaExceededError]: (error: Error) => void;
|
||||
};
|
||||
/**
|
||||
* 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.
|
||||
* This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them
|
||||
* and show some kind of a "It's dead Jim" modal to the users, telling them that hey,
|
||||
* 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
|
||||
*/
|
||||
declare class LocalStorageErrorsEventsEmitter extends TypedEventEmitter<LocalStorageErrors, EventHandlerMap> {
|
||||
}
|
||||
export declare const localStorageErrorsEventsEmitter: LocalStorageErrorsEventsEmitter;
|
||||
export {};
|
||||
//# sourceMappingURL=local-storage-events-emitter.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7D,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACxD,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnE,CAAC;AAEF;;;;;;;GAOG;AACH,cAAM,+BAAgC,SAAQ,iBAAiB,CAAC,kBAAkB,EAAE,eAAe,CAAC;CAAG;AACvG,eAAO,MAAM,+BAA+B,iCAAwC,CAAC"}
|
||||
37
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js
generated
vendored
Normal file
37
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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) {
|
||||
LocalStorageErrors["Global"] = "Global";
|
||||
LocalStorageErrors["SetItemError"] = "setItem";
|
||||
LocalStorageErrors["GetItemError"] = "getItem";
|
||||
LocalStorageErrors["RemoveItemError"] = "removeItem";
|
||||
LocalStorageErrors["ClearError"] = "clear";
|
||||
LocalStorageErrors["QuotaExceededError"] = "QuotaExceededError";
|
||||
return 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.
|
||||
* This store, as an event emitter, is used to re-emit local storage exceptions so that we can handle them
|
||||
* and show some kind of a "It's dead Jim" modal to the users, telling them that hey,
|
||||
* 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();
|
||||
//# sourceMappingURL=local-storage-events-emitter.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js.map
generated
vendored
Normal file
@@ -0,0 +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":[]}
|
||||
214
node_modules/matrix-js-sdk/lib/store/memory.d.ts
generated
vendored
Normal file
214
node_modules/matrix-js-sdk/lib/store/memory.d.ts
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* 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";
|
||||
export interface IOpts {
|
||||
/** The local storage instance to persist some forms of data such as tokens. Rooms will NOT be stored. */
|
||||
localStorage?: Storage;
|
||||
}
|
||||
export declare class MemoryStore implements IStore {
|
||||
private rooms;
|
||||
private users;
|
||||
private syncToken;
|
||||
private filters;
|
||||
accountData: Map<string, MatrixEvent>;
|
||||
protected readonly localStorage?: Storage;
|
||||
private oobMembers;
|
||||
private pendingEvents;
|
||||
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
|
||||
*/
|
||||
constructor(opts?: IOpts);
|
||||
/**
|
||||
* Retrieve the token to stream from.
|
||||
* @returns The token or null.
|
||||
*/
|
||||
getSyncToken(): string | null;
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
/**
|
||||
* Set the token to stream from.
|
||||
* @param token - The token to stream from.
|
||||
*/
|
||||
setSyncToken(token: string): void;
|
||||
/**
|
||||
* Store the given room.
|
||||
* @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.
|
||||
*/
|
||||
private onRoomMember;
|
||||
/**
|
||||
* Retrieve a room by its' room ID.
|
||||
* @param roomId - The room ID.
|
||||
* @returns The room or null.
|
||||
*/
|
||||
getRoom(roomId: string): Room | null;
|
||||
/**
|
||||
* Retrieve all known rooms.
|
||||
* @returns A list of rooms, which may be empty.
|
||||
*/
|
||||
getRooms(): Room[];
|
||||
/**
|
||||
* Permanently delete a room.
|
||||
*/
|
||||
removeRoom(roomId: string): void;
|
||||
/**
|
||||
* Retrieve a summary of all the rooms.
|
||||
* @returns A summary of each room.
|
||||
*/
|
||||
getRoomSummaries(): RoomSummary[];
|
||||
/**
|
||||
* Store a User.
|
||||
* @param user - The user to store.
|
||||
*/
|
||||
storeUser(user: User): void;
|
||||
/**
|
||||
* Retrieve a User by its' user ID.
|
||||
* @param userId - The user ID.
|
||||
* @returns The user or null.
|
||||
*/
|
||||
getUser(userId: string): User | null;
|
||||
/**
|
||||
* Retrieve all known users.
|
||||
* @returns A list of users, which may be empty.
|
||||
*/
|
||||
getUsers(): User[];
|
||||
/**
|
||||
* Retrieve scrollback for this room.
|
||||
* @param room - The matrix room
|
||||
* @param limit - The max number of old events to retrieve.
|
||||
* @returns An array of objects which will be at most 'limit'
|
||||
* length and at least 0. The objects are the raw event JSON.
|
||||
*/
|
||||
scrollback(room: Room, limit: number): MatrixEvent[];
|
||||
/**
|
||||
* Store events for a room. The events have already been added to the timeline
|
||||
* @param room - The room to store events for.
|
||||
* @param events - The events to store.
|
||||
* @param token - The token associated with these events.
|
||||
* @param toStart - True if these are paginated results.
|
||||
*/
|
||||
storeEvents(room: Room, events: MatrixEvent[], token: string | null, toStart: boolean): void;
|
||||
/**
|
||||
* Store a filter.
|
||||
*/
|
||||
storeFilter(filter: Filter): void;
|
||||
/**
|
||||
* Retrieve a filter.
|
||||
* @returns A filter or null.
|
||||
*/
|
||||
getFilter(userId: string, filterId: string): Filter | null;
|
||||
/**
|
||||
* Retrieve a filter ID with the given name.
|
||||
* @param filterName - The filter name.
|
||||
* @returns The filter ID or null.
|
||||
*/
|
||||
getFilterIdByName(filterName: string): string | null;
|
||||
/**
|
||||
* Set a filter name to ID mapping.
|
||||
*/
|
||||
setFilterIdByName(filterName: string, filterId?: string): void;
|
||||
/**
|
||||
* Store user-scoped account data events.
|
||||
* N.B. that account data only allows a single event per type, so multiple
|
||||
* events with the same type will replace each other.
|
||||
* @param events - The events to store.
|
||||
*/
|
||||
storeAccountDataEvents(events: MatrixEvent[]): void;
|
||||
/**
|
||||
* Get account data event by event type
|
||||
* @param eventType - The event type being queried
|
||||
* @returns the user account_data event of given type, if any
|
||||
*/
|
||||
getAccountData(eventType: EventType | string): MatrixEvent | undefined;
|
||||
/**
|
||||
* setSyncData does nothing as there is no backing data store.
|
||||
*
|
||||
* @param syncData - The sync data
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
setSyncData(syncData: ISyncResponse): Promise<void>;
|
||||
/**
|
||||
* We never want to save becase we have nothing to save to.
|
||||
*
|
||||
* @returns If the store wants to save
|
||||
*/
|
||||
wantsSave(): boolean;
|
||||
/**
|
||||
* Save does nothing as there is no backing data store.
|
||||
* @param force - True to force a save (but the memory
|
||||
* store still can't save anything)
|
||||
*/
|
||||
save(force: boolean): Promise<void>;
|
||||
/**
|
||||
* Startup does nothing as this store doesn't require starting up.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
startup(): Promise<void>;
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync(): Promise<ISavedSync | null>;
|
||||
/**
|
||||
* @returns If there is a saved sync, the nextBatch token
|
||||
* for this sync, otherwise null.
|
||||
*/
|
||||
getSavedSyncToken(): Promise<string | null>;
|
||||
/**
|
||||
* Delete all data from this store.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
deleteAllData(): Promise<void>;
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId: string): Promise<IStateEventWithRoomId[] | null>;
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;
|
||||
clearOutOfBandMembers(roomId: string): Promise<void>;
|
||||
getClientOptions(): Promise<IStoredClientOpts | undefined>;
|
||||
storeClientOptions(options: IStoredClientOpts): Promise<void>;
|
||||
getPendingEvents(roomId: string): Promise<Partial<IEvent>[]>;
|
||||
setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void>;
|
||||
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
|
||||
1
node_modules/matrix-js-sdk/lib/store/memory.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/memory.d.ts.map
generated
vendored
Normal file
@@ -0,0 +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,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;AAGnE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,M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EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtF;IAEM,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAU3E;IAEY,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAG1E;IAEM,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpD;IAEY,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAEhF;IAEY,iBAAiB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF;IAEY,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;IAEY,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;IAEY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpC;CACJ"}
|
||||
429
node_modules/matrix-js-sdk/lib/store/memory.js
generated
vendored
Normal file
429
node_modules/matrix-js-sdk/lib/store/memory.js
generated
vendored
Normal file
@@ -0,0 +1,429 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
/*
|
||||
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
/**
|
||||
* Construct a new in-memory data store for the Matrix Client.
|
||||
* @param opts - Config options
|
||||
*/
|
||||
constructor(opts = {}) {
|
||||
_defineProperty(this, "rooms", {});
|
||||
// roomId: Room
|
||||
_defineProperty(this, "users", {});
|
||||
// userId: User
|
||||
_defineProperty(this, "syncToken", null);
|
||||
// userId: {
|
||||
// filterId: Filter
|
||||
// }
|
||||
_defineProperty(this, "filters", new MapWithDefault(() => new Map()));
|
||||
_defineProperty(this, "accountData", new Map());
|
||||
// type: content
|
||||
_defineProperty(this, "localStorage", void 0);
|
||||
_defineProperty(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());
|
||||
/**
|
||||
* 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) {
|
||||
// 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);
|
||||
if (member.name) {
|
||||
user.setDisplayName(member.name);
|
||||
if (member.events.member) {
|
||||
user.setRawDisplayName(member.events.member.getDirectionalContent().displayname);
|
||||
}
|
||||
}
|
||||
if (member.events.member && member.events.member.getContent().avatar_url) {
|
||||
user.setAvatarUrl(member.events.member.getContent().avatar_url);
|
||||
}
|
||||
this.users[user.userId] = user;
|
||||
});
|
||||
this.localStorage = opts.localStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the token to stream from.
|
||||
* @returns The token or null.
|
||||
*/
|
||||
getSyncToken() {
|
||||
return this.syncToken;
|
||||
}
|
||||
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated() {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the token to stream from.
|
||||
* @param token - The token to stream from.
|
||||
*/
|
||||
setSyncToken(token) {
|
||||
this.syncToken = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the given room.
|
||||
* @param room - The room to be stored. All properties must be stored.
|
||||
*/
|
||||
storeRoom(room) {
|
||||
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);
|
||||
// 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.
|
||||
* @returns The room or null.
|
||||
*/
|
||||
getRoom(roomId) {
|
||||
return this.rooms[roomId] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all known rooms.
|
||||
* @returns A list of rooms, which may be empty.
|
||||
*/
|
||||
getRooms() {
|
||||
return Object.values(this.rooms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently delete a room.
|
||||
*/
|
||||
removeRoom(roomId) {
|
||||
if (this.rooms[roomId]) {
|
||||
this.rooms[roomId].currentState.removeListener(RoomStateEvent.Members, this.onRoomMember);
|
||||
}
|
||||
delete this.rooms[roomId];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a summary of all the rooms.
|
||||
* @returns A summary of each room.
|
||||
*/
|
||||
getRoomSummaries() {
|
||||
return Object.values(this.rooms).map(function (room) {
|
||||
return room.summary;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a User.
|
||||
* @param user - The user to store.
|
||||
*/
|
||||
storeUser(user) {
|
||||
this.users[user.userId] = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a User by its' user ID.
|
||||
* @param userId - The user ID.
|
||||
* @returns The user or null.
|
||||
*/
|
||||
getUser(userId) {
|
||||
return this.users[userId] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all known users.
|
||||
* @returns A list of users, which may be empty.
|
||||
*/
|
||||
getUsers() {
|
||||
return Object.values(this.users);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve scrollback for this room.
|
||||
* @param room - The matrix room
|
||||
* @param limit - The max number of old events to retrieve.
|
||||
* @returns An array of objects which will be at most 'limit'
|
||||
* length and at least 0. The objects are the raw event JSON.
|
||||
*/
|
||||
scrollback(room, limit) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store events for a room. The events have already been added to the timeline
|
||||
* @param room - The room to store events for.
|
||||
* @param events - The events to store.
|
||||
* @param token - The token associated with these events.
|
||||
* @param toStart - True if these are paginated results.
|
||||
*/
|
||||
storeEvents(room, events, token, toStart) {
|
||||
// no-op because they've already been added to the room instance.
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a filter.
|
||||
*/
|
||||
storeFilter(filter) {
|
||||
if (!filter?.userId || !filter?.filterId) return;
|
||||
this.filters.getOrCreate(filter.userId).set(filter.filterId, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a filter.
|
||||
* @returns A filter or null.
|
||||
*/
|
||||
getFilter(userId, filterId) {
|
||||
return this.filters.get(userId)?.get(filterId) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a filter ID with the given name.
|
||||
* @param filterName - The filter name.
|
||||
* @returns The filter ID or null.
|
||||
*/
|
||||
getFilterIdByName(filterName) {
|
||||
if (!this.localStorage) {
|
||||
return null;
|
||||
}
|
||||
const key = "mxjssdk_memory_filter_" + filterName;
|
||||
// XXX Storage.getItem doesn't throw ...
|
||||
// or are we using something different
|
||||
// than window.localStorage in some cases
|
||||
// that does throw?
|
||||
// that would be very naughty
|
||||
try {
|
||||
const value = this.localStorage.getItem(key);
|
||||
if (isValidFilterId(value)) {
|
||||
return value;
|
||||
}
|
||||
} catch {
|
||||
// Do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a filter name to ID mapping.
|
||||
*/
|
||||
setFilterIdByName(filterName, filterId) {
|
||||
if (!this.localStorage) {
|
||||
return;
|
||||
}
|
||||
const key = "mxjssdk_memory_filter_" + filterName;
|
||||
try {
|
||||
if (isValidFilterId(filterId)) {
|
||||
this.localStorage.setItem(key, filterId);
|
||||
} else {
|
||||
this.localStorage.removeItem(key);
|
||||
}
|
||||
} catch {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store user-scoped account data events.
|
||||
* N.B. that account data only allows a single event per type, so multiple
|
||||
* events with the same type will replace each other.
|
||||
* @param events - The events to store.
|
||||
*/
|
||||
storeAccountDataEvents(events) {
|
||||
events.forEach(event => {
|
||||
this.accountData.set(event.getType(), event);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account data event by event type
|
||||
* @param eventType - The event type being queried
|
||||
* @returns the user account_data event of given type, if any
|
||||
*/
|
||||
getAccountData(eventType) {
|
||||
return this.accountData.get(eventType);
|
||||
}
|
||||
|
||||
/**
|
||||
* setSyncData does nothing as there is no backing data store.
|
||||
*
|
||||
* @param syncData - The sync data
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
setSyncData(syncData) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* We never want to save becase we have nothing to save to.
|
||||
*
|
||||
* @returns If the store wants to save
|
||||
*/
|
||||
wantsSave() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save does nothing as there is no backing data store.
|
||||
* @param force - True to force a save (but the memory
|
||||
* store still can't save anything)
|
||||
*/
|
||||
save(force) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup does nothing as this store doesn't require starting up.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
startup() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns If there is a saved sync, the nextBatch token
|
||||
* for this sync, otherwise null.
|
||||
*/
|
||||
getSavedSyncToken() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data from this store.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
deleteAllData() {
|
||||
this.rooms = {
|
||||
// roomId: Room
|
||||
};
|
||||
this.users = {
|
||||
// userId: User
|
||||
};
|
||||
this.syncToken = null;
|
||||
this.filters = new MapWithDefault(() => new Map());
|
||||
this.accountData = new Map(); // type : content
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the out-of-band membership events for this room that
|
||||
* were previously loaded.
|
||||
* @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
|
||||
*/
|
||||
getOutOfBandMembers(roomId) {
|
||||
return Promise.resolve(this.oobMembers.get(roomId) || null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the out-of-band membership events for this room. Note that
|
||||
* it still makes sense to store an empty array as the OOB status for the room is
|
||||
* marked as fetched, and getOutOfBandMembers will return an empty array instead of null
|
||||
* @param membershipEvents - the membership events to store
|
||||
* @returns when all members have been stored
|
||||
*/
|
||||
setOutOfBandMembers(roomId, membershipEvents) {
|
||||
this.oobMembers.set(roomId, membershipEvents);
|
||||
return Promise.resolve();
|
||||
}
|
||||
clearOutOfBandMembers(roomId) {
|
||||
this.oobMembers.delete(roomId);
|
||||
return Promise.resolve();
|
||||
}
|
||||
getClientOptions() {
|
||||
return Promise.resolve(this.clientOptions);
|
||||
}
|
||||
storeClientOptions(options) {
|
||||
this.clientOptions = Object.assign({}, options);
|
||||
return Promise.resolve();
|
||||
}
|
||||
async getPendingEvents(roomId) {
|
||||
return this.pendingEvents[roomId] ?? [];
|
||||
}
|
||||
async setPendingEvents(roomId, events) {
|
||||
this.pendingEvents[roomId] = events;
|
||||
}
|
||||
saveToDeviceBatches(batches) {
|
||||
for (const batch of batches) {
|
||||
this.pendingToDeviceBatches.push({
|
||||
id: this.nextToDeviceBatchId++,
|
||||
eventType: batch.eventType,
|
||||
txnId: batch.txnId,
|
||||
batch: batch.batch
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
async getOldestToDeviceBatch() {
|
||||
if (this.pendingToDeviceBatches.length === 0) return null;
|
||||
return this.pendingToDeviceBatches[0];
|
||||
}
|
||||
removeToDeviceBatch(id) {
|
||||
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
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=memory.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/memory.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/memory.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
165
node_modules/matrix-js-sdk/lib/store/stub.d.ts
generated
vendored
Normal file
165
node_modules/matrix-js-sdk/lib/store/stub.d.ts
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* 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";
|
||||
/**
|
||||
* Construct a stub store. This does no-ops on most store methods.
|
||||
*/
|
||||
export declare class StubStore implements IStore {
|
||||
readonly accountData: Map<any, any>;
|
||||
private fromToken;
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
/**
|
||||
* Get the sync token.
|
||||
*/
|
||||
getSyncToken(): string | null;
|
||||
/**
|
||||
* Set the sync token.
|
||||
*/
|
||||
setSyncToken(token: string): void;
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
storeRoom(room: Room): void;
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
getRoom(roomId: string): Room | null;
|
||||
/**
|
||||
* No-op.
|
||||
* @returns An empty array.
|
||||
*/
|
||||
getRooms(): Room[];
|
||||
/**
|
||||
* Permanently delete a room.
|
||||
*/
|
||||
removeRoom(roomId: string): void;
|
||||
/**
|
||||
* No-op.
|
||||
* @returns An empty array.
|
||||
*/
|
||||
getRoomSummaries(): RoomSummary[];
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
storeUser(user: User): void;
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
getUser(userId: string): User | null;
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
getUsers(): User[];
|
||||
/**
|
||||
* 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.
|
||||
* @param events - The events to store.
|
||||
* @param token - The token associated with these events.
|
||||
* @param toStart - True if these are paginated results.
|
||||
*/
|
||||
storeEvents(room: Room, events: MatrixEvent[], token: string | null, toStart: boolean): void;
|
||||
/**
|
||||
* Store a filter.
|
||||
*/
|
||||
storeFilter(filter: Filter): void;
|
||||
/**
|
||||
* Retrieve a filter.
|
||||
* @returns A filter or null.
|
||||
*/
|
||||
getFilter(userId: string, filterId: string): Filter | null;
|
||||
/**
|
||||
* Retrieve a filter ID with the given name.
|
||||
* @param filterName - The filter name.
|
||||
* @returns The filter ID or null.
|
||||
*/
|
||||
getFilterIdByName(filterName: string): string | null;
|
||||
/**
|
||||
* Set a filter name to ID mapping.
|
||||
*/
|
||||
setFilterIdByName(filterName: string, filterId?: string): void;
|
||||
/**
|
||||
* Store user-scoped account data events
|
||||
* @param events - The events to store.
|
||||
*/
|
||||
storeAccountDataEvents(events: MatrixEvent[]): void;
|
||||
/**
|
||||
* Get account data event by event type
|
||||
* @param eventType - The event type being queried
|
||||
*/
|
||||
getAccountData(eventType: EventType | string): MatrixEvent | undefined;
|
||||
/**
|
||||
* setSyncData does nothing as there is no backing data store.
|
||||
*
|
||||
* @param syncData - The sync data
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
setSyncData(syncData: ISyncResponse): Promise<void>;
|
||||
/**
|
||||
* We never want to save because we have nothing to save to.
|
||||
*
|
||||
* @returns If the store wants to save
|
||||
*/
|
||||
wantsSave(): boolean;
|
||||
/**
|
||||
* Save does nothing as there is no backing data store.
|
||||
*/
|
||||
save(): Promise<void>;
|
||||
/**
|
||||
* Startup does nothing.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
startup(): Promise<void>;
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync(): Promise<ISavedSync | null>;
|
||||
/**
|
||||
* @returns If there is a saved sync, the nextBatch token
|
||||
* for this sync, otherwise null.
|
||||
*/
|
||||
getSavedSyncToken(): Promise<string | null>;
|
||||
/**
|
||||
* Delete all data from this store. Does nothing since this store
|
||||
* doesn't store anything.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
deleteAllData(): Promise<void>;
|
||||
getOutOfBandMembers(): Promise<IStateEventWithRoomId[] | null>;
|
||||
setOutOfBandMembers(roomId: string, membershipEvents: IStateEventWithRoomId[]): Promise<void>;
|
||||
clearOutOfBandMembers(): Promise<void>;
|
||||
getClientOptions(): Promise<IStoredClientOpts | undefined>;
|
||||
storeClientOptions(options: IStoredClientOpts): Promise<void>;
|
||||
getPendingEvents(roomId: string): Promise<Partial<IEvent>[]>;
|
||||
setPendingEvents(roomId: string, events: Partial<IEvent>[]): Promise<void>;
|
||||
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
|
||||
1
node_modules/matrix-js-sdk/lib/store/stub.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/stub.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stub.d.ts","sourceRoot":"","sources":["../../src/store/stub.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,qBAAa,SAAU,YAAW,MAAM;IACpC,SAAgB,WAAW,gBAAa;IACxC,OAAO,CAAC,SAAS,CAAuB;IAExC,8EAA8E;IACvE,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAExC;IAED;;OAEG;IACI,YAAY,IAAI,MAAM,GAAG,IAAI,CAEnC;IAED;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEvC;IAED;;OAEG;IACI,SAAS,CAAC,IAAI,EA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E;IAEM,sBAAsB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAEpE;IAEY,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IAEY,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC,CAEhD;IAEY,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9C;IAEY,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/C;IAEY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpC;IACY,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;CACJ"}
|
||||
273
node_modules/matrix-js-sdk/lib/store/stub.js
generated
vendored
Normal file
273
node_modules/matrix-js-sdk/lib/store/stub.js
generated
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
||||
/*
|
||||
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is an internal module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct a stub store. This does no-ops on most store methods.
|
||||
*/
|
||||
export class StubStore {
|
||||
constructor() {
|
||||
_defineProperty(this, "accountData", new Map());
|
||||
// stub
|
||||
_defineProperty(this, "fromToken", null);
|
||||
}
|
||||
/** @returns whether or not the database was newly created in this session. */
|
||||
isNewlyCreated() {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sync token.
|
||||
*/
|
||||
getSyncToken() {
|
||||
return this.fromToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sync token.
|
||||
*/
|
||||
setSyncToken(token) {
|
||||
this.fromToken = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
storeRoom(room) {}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
getRoom(roomId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
* @returns An empty array.
|
||||
*/
|
||||
getRooms() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently delete a room.
|
||||
*/
|
||||
removeRoom(roomId) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
* @returns An empty array.
|
||||
*/
|
||||
getRoomSummaries() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
storeUser(user) {}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
getUser(userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
getUsers() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
scrollback(room, limit) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*/
|
||||
setUserCreator(creator) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store events for a room.
|
||||
* @param room - The room to store events for.
|
||||
* @param events - The events to store.
|
||||
* @param token - The token associated with these events.
|
||||
* @param toStart - True if these are paginated results.
|
||||
*/
|
||||
storeEvents(room, events, token, toStart) {}
|
||||
|
||||
/**
|
||||
* Store a filter.
|
||||
*/
|
||||
storeFilter(filter) {}
|
||||
|
||||
/**
|
||||
* Retrieve a filter.
|
||||
* @returns A filter or null.
|
||||
*/
|
||||
getFilter(userId, filterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a filter ID with the given name.
|
||||
* @param filterName - The filter name.
|
||||
* @returns The filter ID or null.
|
||||
*/
|
||||
getFilterIdByName(filterName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a filter name to ID mapping.
|
||||
*/
|
||||
setFilterIdByName(filterName, filterId) {}
|
||||
|
||||
/**
|
||||
* Store user-scoped account data events
|
||||
* @param events - The events to store.
|
||||
*/
|
||||
storeAccountDataEvents(events) {}
|
||||
|
||||
/**
|
||||
* Get account data event by event type
|
||||
* @param eventType - The event type being queried
|
||||
*/
|
||||
getAccountData(eventType) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* setSyncData does nothing as there is no backing data store.
|
||||
*
|
||||
* @param syncData - The sync data
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
setSyncData(syncData) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* We never want to save because we have nothing to save to.
|
||||
*
|
||||
* @returns If the store wants to save
|
||||
*/
|
||||
wantsSave() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save does nothing as there is no backing data store.
|
||||
*/
|
||||
save() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup does nothing.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
startup() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Promise which resolves with a sync response to restore the
|
||||
* client state to where it was at the last save, or null if there
|
||||
* is no saved sync data.
|
||||
*/
|
||||
getSavedSync() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns If there is a saved sync, the nextBatch token
|
||||
* for this sync, otherwise null.
|
||||
*/
|
||||
getSavedSyncToken() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data from this store. Does nothing since this store
|
||||
* doesn't store anything.
|
||||
* @returns An immediately resolved promise.
|
||||
*/
|
||||
deleteAllData() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
getOutOfBandMembers() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
setOutOfBandMembers(roomId, membershipEvents) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
clearOutOfBandMembers() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
getClientOptions() {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
storeClientOptions(options) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
async getPendingEvents(roomId) {
|
||||
return [];
|
||||
}
|
||||
setPendingEvents(roomId, events) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
async saveToDeviceBatches(batch) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
getOldestToDeviceBatch() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=stub.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/store/stub.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/store/stub.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user