import { IChannelAttributes , IFluidDataStoreRuntime , Serializable } from "@fluidframework/datastore-definitions" ; import { SharedOT } from "@fluid-experimental/ot" ; import { Doc , type as Json1OTType , JSONOp , replaceOp , insertOp , moveOp , removeOp , Path } from "ot-json1" ; import { Json1Factory } from "./factory" ; export class SharedJson1 extends SharedOT < Doc , JSONOp > { public static create ( runtime , id ? ) { return runtime . createChannel ( id , Json1Factory . Type ) as SharedJson1 ; } public static getFactory ( ) { return new Json1Factory ( ) ; } constructor ( id , runtime , attributes ) { super ( id , runtime , attributes , null ) ; } public get ( ) { return this . state ; } public apply ( op ) { super . apply ( op ) ; } protected transform ( input , transform ) { return Json1OTType . transformNoConflict ( input , transform , "left" ) ; } protected applyCore ( state , op ) { return Json1OTType . apply ( state , op ) as Doc ; } public insert ( path , value ) { this . apply ( insertOp ( path , value as Doc ) ) ; } public move ( from , to ) { this . apply ( moveOp ( from , to ) ) ; } public remove ( path , value ? ) { this . apply ( removeOp ( path , value ) ) ; } public replace ( path , oldValue , newValue ) { this . apply ( replaceOp ( path , oldValue as Doc , newValue as Doc ) ) ; } }