feat: sync to keck

This commit is contained in:
DarkSky
2022-09-14 17:39:24 +08:00
parent 3ff0dbe781
commit f8544fedd4
5 changed files with 34 additions and 27 deletions
+7 -7
View File
@@ -120,13 +120,13 @@ async function _initYjsDatabase(
[name]: p,
};
}),
// p({
// awareness,
// doc: binaries,
// token,
// workspace: `${workspace}_binaries`,
// emitState,
// }).then(p => ({ [`${name}_binaries`]: p })),
p({
awareness,
doc: binaries,
token,
workspace: `${workspace}_binaries`,
emitState,
}).then(p => ({ [`${name}_binaries`]: p })),
])
);
}
+4 -3
View File
@@ -3,6 +3,7 @@ import { Doc } from 'yjs';
import {
IndexedDBProvider,
KeckProvider,
SQLiteProvider,
WebsocketProvider,
} from '@toeverything/datasource/jwt-rpc';
@@ -22,7 +23,7 @@ export type YjsProvider = (
instances: YjsDefaultInstances
) => Promise<unknown | undefined>;
type ProviderType = 'idb' | 'sqlite' | 'ws';
type ProviderType = 'idb' | 'sqlite' | 'ws' | 'keck';
export type YjsProviderOptions = {
enabled: ProviderType[];
@@ -100,9 +101,9 @@ export const getYjsProviders = (
}
},
keck: async (instances: YjsDefaultInstances) => {
if (options.enabled.includes('ws')) {
if (options.enabled.includes('keck')) {
if (instances.token) {
const ws = new WebsocketProvider(
const ws = new KeckProvider(
instances.token,
options.backend,
instances.workspace,