99 Awareness , EphemeralStore
1010} from './generated/loro' ;
1111
12- import type { ChangeAncestorsTraveler , ChangeMeta } from './generated/loro' ;
12+ import type { ChangeAncestorsTraveler , ChangeMeta , JsonPathSubscriber } from './generated/loro' ;
1313
1414export type Value =
1515 | ContainerId
@@ -38,6 +38,7 @@ declare module "./generated/loro" {
3838 subscribeLocalUpdate ( cb : ( update : ArrayBuffer ) => void ) : SubscriptionInterface ;
3939 subscribeFirstCommitFromPeer ( cb : ( payload : FirstCommitFromPeerPayload ) => void ) : SubscriptionInterface ;
4040 subscribePreCommit ( cb : ( payload : PreCommitCallbackPayload ) => void ) : SubscriptionInterface ;
41+ subscribeJsonpath ( path : string , cb : ( ) => void ) : SubscriptionInterface ;
4142 toJSON ( ) : any ;
4243 oplogVersion ( ) : VersionVector ;
4344 version ( ) : VersionVector ;
@@ -168,6 +169,14 @@ LoroDoc.prototype.export = function (mode: ExportMode): ArrayBuffer {
168169 }
169170}
170171
172+ const _subscribeJsonpathRaw = LoroDoc . prototype . subscribeJsonpath ;
173+ LoroDoc . prototype . subscribeJsonpath = function ( path : string , cb : ( ) => void ) : SubscriptionInterface {
174+ const listener : JsonPathSubscriber = {
175+ onJsonpathMaybeChanged : cb ,
176+ } ;
177+ return _subscribeJsonpathRaw . call ( this , path , listener ) ;
178+ } ;
179+
171180const originalGetText = LoroDoc . prototype . getText ;
172181LoroDoc . prototype . getText = function ( id : ContainerId | string ) : LoroText {
173182 if ( typeof id === 'string' ) {
@@ -681,4 +690,4 @@ EphemeralStore.prototype.subscribeLocalUpdate = function (cb: (update: ArrayBuff
681690const originalEphemeralStoreSubscribe = EphemeralStore . prototype . subscribe ;
682691EphemeralStore . prototype . subscribe = function ( cb : ( event : EphemeralStoreEvent ) => void ) : SubscriptionInterface {
683692 return originalEphemeralStoreSubscribe . call ( this , { onEphemeralEvent : cb } )
684- }
693+ }
0 commit comments