UNPKG

mobx-bonsai-yjs

Version:

Y.js two-way binding for mobx-bonsai

25 lines (24 loc) 1.28 kB
import { _Primitive } from 'mobx-bonsai'; import { YjsValue } from '../yjsTypes/types'; import * as Y from "yjs"; /** * Converts a plain value to a Y.js value. * Objects are converted to Y.Maps, arrays to Y.Arrays, primitives are untouched. */ export declare function convertPlainToYjsValue<T extends _Primitive>(v: T): T; export declare function convertPlainToYjsValue(v: readonly any[]): Y.Array<YjsValue>; export declare function convertPlainToYjsValue(v: Readonly<Record<string, any>>): Y.Map<YjsValue>; /** * Applies a plain array to a Y.Array, using the convertPlainToYjsValue to convert the values. * * @param dest - The Y.js Array that will receive the converted values. * @param source - The plain JavaScript array whose values will be converted and pushed to the destination. */ export declare const applyPlainArrayToYArray: (dest: Y.Array<any>, source: readonly any[]) => void; /** * Applies a plain object to a Y.Map, using the convertPlainToYjsValue to convert the values. * * @param dest - The destination Y.Map where the properties will be set * @param source - The plain JavaScript object whose properties will be applied to the Y.Map */ export declare const applyPlainObjectToYMap: (dest: Y.Map<any>, source: Readonly<Record<string, any>>) => void;