11import { EphemeralStore } from "loro-crdt" ;
2- import {
3- CrdtType ,
4- MessageType ,
5- JoinResponseOk ,
6- } from "loro-protocol" ;
2+ import { CrdtType , MessageType , JoinResponseOk } from "loro-protocol" ;
73import type { CrdtServerAdaptor } from "../types" ;
84
95export interface LoroPersistentStoreServerAdaptorConfig {
@@ -29,8 +25,8 @@ export class LoroPersistentStoreServerAdaptor implements CrdtServerAdaptor {
2925
3026 handleJoinRequest (
3127 documentData : Uint8Array ,
32- _clientVersion : Uint8Array ,
33- ) : { response : JoinResponseOk , updates ?: Uint8Array [ ] } {
28+ _clientVersion : Uint8Array
29+ ) : { response : JoinResponseOk ; updates ?: Uint8Array [ ] } {
3430 const response : JoinResponseOk = {
3531 type : MessageType . JoinResponseOk ,
3632 crdt : this . crdtType ,
@@ -43,13 +39,9 @@ export class LoroPersistentStoreServerAdaptor implements CrdtServerAdaptor {
4339 return { response, updates } ;
4440 }
4541
46- applyUpdates (
47- documentData : Uint8Array ,
48- updates : Uint8Array [ ] ,
49- ) : Uint8Array {
42+ applyUpdates ( documentData : Uint8Array , updates : Uint8Array [ ] ) : Uint8Array {
5043 const store = new EphemeralStore ( this . timeout ) ;
5144 try {
52-
5345 if ( documentData . length > 0 ) {
5446 store . apply ( documentData ) ;
5547 }
@@ -62,7 +54,8 @@ export class LoroPersistentStoreServerAdaptor implements CrdtServerAdaptor {
6254 const newDocumentData = store . encodeAll ( ) ;
6355 return newDocumentData ;
6456 } finally {
65- store . inner . free ( )
57+ store . destroy ( ) ;
58+ store . inner . free ( ) ;
6659 }
6760 }
6861
@@ -85,4 +78,3 @@ export class LoroPersistentStoreServerAdaptor implements CrdtServerAdaptor {
8578 }
8679 }
8780}
88-
0 commit comments