chore: prohibit using mergeUpdates (#3701)

This commit is contained in:
Alex Yang
2023-08-11 11:55:17 -04:00
committed by GitHub
parent e9f4912665
commit 9639143df4
14 changed files with 142 additions and 94 deletions
+9 -1
View File
@@ -1,12 +1,20 @@
import type { IDBPDatabase } from 'idb';
import { openDB } from 'idb';
import { mergeUpdates } from 'yjs';
import { applyUpdate, Doc, encodeStateAsUpdate } from 'yjs';
import type { BlockSuiteBinaryDB, OldYjsDB, UpdateMessage } from './shared';
import { dbVersion, DEFAULT_DB_NAME, upgradeDB } from './shared';
let allDb: IDBDatabaseInfo[];
export function mergeUpdates(updates: Uint8Array[]) {
const doc = new Doc();
updates.forEach(update => {
applyUpdate(doc, update);
});
return encodeStateAsUpdate(doc);
}
async function databaseExists(name: string): Promise<boolean> {
return new Promise(resolve => {
const req = indexedDB.open(name);