zustand-yjs
Version:
Zustand Stores with Yjs
33 lines (32 loc) • 1.35 kB
TypeScript
import * as Y from 'yjs';
import * as YProtocols from 'y-protocols';
export declare type ObserveFunc = (arg0: any, arg1: Y.Transaction) => void;
export declare type StopAwarenessFunction = () => void;
export declare type StartAwarenessFunction = (provider: typeof YProtocols) => StopAwarenessFunction;
export declare type UnMountFunction = () => void | void;
export declare type MountFunction = (doc: Y.Doc, startAwareness: StartAwarenessFunction) => UnMountFunction;
export declare enum YDocEnum {
GUID = 0,
DOC = 1,
MOUNT = 2,
UN_MOUNT = 3,
USE_CNT = 4
}
export declare enum ObserveEnum {
TYPE = 0,
OBSERVE = 1,
USE_CNT = 2
}
export declare type YStore = {
yDocs: [string, Y.Doc, MountFunction, UnMountFunction, number][];
yAwareness: [string, typeof YProtocols.awareness, unknown[]][];
observers: [Y.AbstractType<any>, ObserveFunc, number][];
data: [Y.AbstractType<any>, any][];
listenType(type: Y.AbstractType<any>, listen: ObserveFunc): void;
unListenType(type: Y.AbstractType<any>): void;
unMountYDoc(yDoc: Y.Doc): void;
mountYDoc(yDoc: Y.Doc, mount: MountFunction): void;
update(type: Y.AbstractType<any>, data: any): void;
};
export declare type AwarenessData<T> = T[];
export declare type AwarenessSetData<T> = (newState: Partial<T>) => void;