import { Message } from '@bufbuild/protobuf'; import { Rule } from '@yorkie-js/schema'; import { Timestamp } from '@bufbuild/protobuf/wkt'; /** * `ActorID` is used to identify who is making changes to the document. * It is a hexadecimal string and should be generated by a unique value. */ export declare type ActorID = string; /** * `ActorID` is used to identify who is making changes to the document. * It is a hexadecimal string and should be generated by a unique value. */ declare type ActorID_2 = string; /** * `AddOpInfo` represents the information of the add operation. */ export declare type AddOpInfo = { type: 'add'; path: string; index: number; }; /** * `AddOpInfo` represents the information of the add operation. */ declare type AddOpInfo_2 = { type: 'add'; path: string; index: number; }; /** * `ArrayOpInfo` represents the OperationInfo for the JSONArray. */ export declare type ArrayOpInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo | ArraySetOpInfo_2; /** * `ArrayOpInfo` represents the OperationInfo for the JSONArray. */ declare type ArrayOpInfo_2 = | AddOpInfo_2 | RemoveOpInfo_2 | MoveOpInfo_2 | ArraySetOpInfo; /** * `ArraySetOpInfo` represents the information of the array set operation. */ declare type ArraySetOpInfo = { type: 'array-set'; path: string; }; /** * `ArraySetOpInfo` represents the information of the array set operation. */ declare type ArraySetOpInfo_2 = { type: 'array-set'; path: string; }; /** * `Attachable` is an interface for resources that can be attached to a client. */ declare interface Attachable { /** * `getKey` returns the key of this resource. */ getKey(): string; /** * `getStatus` returns the status of this resource. */ getStatus(): ResourceStatus; /** * `setActor` sets the actor ID into this resource. */ setActor(actorID: ActorID): void; /** * `hasLocalChanges` returns whether this resource has local changes to be synchronized. * Returns true for Document when there are uncommitted changes. * Returns false for Presence as it is server-managed. */ hasLocalChanges(): boolean; /** * `publish` publishes an event to notify observers about changes in this resource. */ publish(event: unknown): void; } /** * `AttachChannelOptions` are user-settable options used when attaching channels. */ export declare interface AttachChannelOptions { /** * `syncMode` selects how the channel keeps presence in sync with the server. * Default is `SyncMode.Realtime`. * - `SyncMode.Realtime`: open a watch stream and run the heartbeat. Required * to receive broadcast events. * - `SyncMode.Polling`: heartbeat-only. No watch stream is opened. The * heartbeat refreshes TTL and brings the latest sessionCount. Recommended * for large channels where broadcast is not needed. * - `SyncMode.Manual`: no automatic activity. Caller must invoke `sync()`. */ syncMode?: SyncMode; /** * `channelHeartbeatInterval` overrides the heartbeat interval (ms) for * this attachment. If unset, the client-level default * (`ClientOptions.channelHeartbeatInterval`, default 5000 ms) applies * to both Realtime and Polling modes. */ channelHeartbeatInterval?: number; } /** * `AttachOptions` are user-settable options used when attaching documents. */ export declare interface AttachOptions { /** * `initialRoot` is the initial root of the document. It is used to * initialize the document. It is used when the fields are not set in the * document. */ initialRoot?: R; /** * `initialPresence` is the initial presence of the client. */ initialPresence?: P; /** * `syncMode` defines the synchronization mode of the document. */ syncMode?: SyncMode; /** * `documentPollInterval` (ms) — only used when `syncMode` is `Polling`. * Default: 3000. */ documentPollInterval?: number; /** * `schema` is the schema of the document. It is used to validate the * document. */ schema?: string; /** * `disableGC` declares that this attachment will not produce or consume * tombstones. The server skips minVV tracking and omits the response * VersionVector for this client. Use only with Counter or primitive * workloads; misuse on a document that uses Tree, Text, or Array * deletions leads to undefined GC behavior on this client. * * This option controls the wire contract with the server. It is * distinct from any local-only GC toggle on the Document. */ disableGC?: boolean; /** * `disablePresence` declares that this document does not use presence. * The first client to attach a document sets the persisted server-side * flag — subsequent attaches inherit the fixated value regardless of * what they pass. The client uses the server response to gate * `Document.update`'s presence emits (silently dropped) and skips the * initial `presence.set(opts.initialPresence)` emitted on attach. * * If omitted, the resolved value is `doc.isPresenceDisabled()` (the * value seeded from `DocumentOptions.disablePresence`, then overwritten * by any previous attach response on the same Document instance), with * a final fallback of `false`. */ disablePresence?: boolean; } declare interface AuthErrorEvent extends BaseDocEvent { type: DocEventType_2.AuthError; value: { reason: string; method: 'PushPull' | 'Watch'; }; } declare interface AuthErrorEvent_2 extends BaseDocEvent_2 { type: DocEventType.AuthError; value: { reason: string; method: 'PushPull' | 'Watch'; }; } /** * `AuthErrorEvent` represents an authentication error event. */ declare interface AuthErrorEvent_3 { /** * `type` is the type of the event. */ type: ChannelEventType.AuthError; /** * `reason` is the reason for the authentication error. */ reason: string; /** * `method` is the method that caused the authentication error. */ method: string; } declare type BaseArray = JSONArray | Array; /** * `BaseCounter` is an internal base that holds the shared state and * initialization logic for Counter and DedupCounter. Not exported. */ declare class BaseCounter { protected valueType: CounterType; protected value: number | bigint; protected context?: ChangeContext; protected counter?: CRDTCounter; constructor(valueType: CounterType, value: number | bigint); /** * `initialize` links this proxy to a ChangeContext and CRDTCounter. */ initialize(context: ChangeContext, counter: CRDTCounter): void; /** * `getID` returns the ID of this counter. */ getID(): TimeTicket; /** * `getValueType` returns the value type of this counter. */ getValueType(): CounterType; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `ensureInitialized` throws if this counter has not been initialized. */ protected ensureInitialized(): void; } declare interface BaseDocEvent { type: DocEventType_2; } declare interface BaseDocEvent_2 { type: DocEventType; } declare type BaseObject = JSONObject | T; declare interface BroadcastEvent { type: ChannelEventType.Broadcast; clientID: ActorID; topic: string; payload: Json; options?: BroadcastOptions; } /** * `BroadcastOptions` are the options for broadcasting a message. */ declare interface BroadcastOptions { /** * `error` is called when an error occurs. */ error?: (error: Error) => void; /** * `maxRetries` is the maximum number of retries. */ maxRetries?: number; } /** * `bytesToChangeID` creates a ChangeID from the given bytes. */ declare function bytesToChangeID(bytes: Uint8Array): ChangeID; /** * `bytesToHex` creates an hex string from the given byte array. */ declare function bytesToHex(bytes?: Uint8Array): string; /** * `bytesToObject` creates an JSONObject from the given byte array. */ declare function bytesToObject(bytes?: Uint8Array): CRDTObject; /** * `bytesToOperation` creates an Operation from the given bytes. */ declare function bytesToOperation(bytes: Uint8Array): Operation; /** * `bytesToSnapshot` creates a Snapshot from the given byte array. */ declare function bytesToSnapshot

(bytes?: Uint8Array): { root: CRDTObject; presences: Map; }; /** * `Change` represents a unit of modification in the document. */ export declare class Change

{ private id; private operations; private presenceChange?; private message?; constructor({ id, operations, presenceChange, message, }: { id: ChangeID; operations?: Array; presenceChange?: PresenceChange

; message?: string; }); /** * `create` creates a new instance of Change. */ static create

({ id, operations, presenceChange, message, }: { id: ChangeID; operations?: Array; presenceChange?: PresenceChange

; message?: string; }): Change

; /** * `getID` returns the ID of this change. */ getID(): ChangeID; /** * `getMessage` returns the message of this change. */ getMessage(): string | undefined; /** * `hasOperations` returns whether this change has operations or not. */ hasOperations(): boolean; /** * `getOperations` returns the operations of this change. */ getOperations(): Array; /** * `setActor` sets the given actor. */ setActor(actorID: ActorID): void; /** * `hasPresenceChange` returns whether this change has presence change or not. */ hasPresenceChange(): boolean; /** * `getPresenceChange` returns the presence change of this change. */ getPresenceChange(): PresenceChange

| undefined; /** * `execute` executes the operations of this change to the given root. */ execute(root: CRDTRoot, presences: Map, source: OpSource): { operations: Array; opInfos: Array; reverseOps: Array>; }; /** * `toTestString` returns a string containing the meta data of this change. */ toTestString(): string; /** * `toStruct` returns the structure of this change. */ toStruct(): ChangeStruct_2

; /** * `fromStruct` creates a instance of Change from the struct. */ static fromStruct

(struct: ChangeStruct_2

): Change

; } /** * @generated from message yorkie.v1.Change */ declare type Change_2 = Message<"yorkie.v1.Change"> & { /** * @generated from field: yorkie.v1.ChangeID id = 1; */ id?: ChangeID_2; /** * @generated from field: string message = 2; */ message: string; /** * @generated from field: repeated yorkie.v1.Operation operations = 3; */ operations: Operation_2[]; /** * @generated from field: yorkie.v1.PresenceChange presence_change = 4; */ presenceChange?: PresenceChange_2; }; /** * `ChangeContext` is used to record the context of modification when editing * a document. Each time we add an operation, a new time ticket is issued. * Finally returns a Change after the modification has been completed. */ declare class ChangeContext

{ private prevID; private nextID; private delimiter; private message?; private root; private operations; private presenceChange?; /** * `previousPresence` stores the previous presence to be used for undoing * presence changes. */ private previousPresence; /** * `reversePresenceKeys` stores the keys of the presence to be used for undoing * presence changes. */ private reversePresenceKeys; constructor(prevID: ChangeID, root: CRDTRoot, presence: P, message?: string); /** * `create` creates a new instance of ChangeContext. */ static create

(prevID: ChangeID, root: CRDTRoot, presence: P, message?: string): ChangeContext

; /** * `push` pushes the given operation to this context. */ push(operation: Operation): void; /** * `registerElement` registers the given element to the root. */ registerElement(element: CRDTElement, parent: CRDTContainer): void; /** * `registerRemovedElement` register removed element for garbage collection. */ registerRemovedElement(deleted: CRDTElement): void; /** * `registerGCPair` registers the given pair to hash table. */ registerGCPair(pair: GCPair): void; /** * `getNextID` returns the next ID of this context. It will be set to the * document for the next change.returns the next ID of this context. */ getNextID(): ChangeID; /** * `toChange` creates a new instance of Change in this context. */ toChange(): Change

; /** * `isPresenceOnlyChange` returns whether this context is only for presence * change or not. */ isPresenceOnlyChange(): boolean; /** * `hasChange` returns whether this context has change or not. */ hasChange(): boolean; /** * `setPresenceChange` registers the presence change to this context. */ setPresenceChange(presenceChange: PresenceChange

): void; /** * `hasPresenceChange` returns whether a presence change was registered * during this context. Used by `Document.update` to detect a presence * emit when the document was attached with `disablePresence: true`. */ hasPresenceChange(): boolean; /** * `dropPresenceChange` clears any presence change registered during * this context. Used by `Document.update` to silently drop presence * emits on documents attached with `disablePresence: true`. After * dropping, the change carries only its operations (if any); when * the context was presence-only the resulting `hasChange()` returns * false and no `Change` is enqueued. */ dropPresenceChange(): void; /** * `setReversePresence` registers the previous presence to undo presence updates. */ setReversePresence(presence: Partial

, option?: { addToHistory: boolean; }): void; /** * `toReversePresence` returns the reverse presence of this context. */ getReversePresence(): Partial

| undefined; /** * `clearReversePresence` discards any reverse-presence keys recorded * during this context. Used by `Document.update` alongside * `dropPresenceChange` for documents attached with * `disablePresence: true`, so the dropped presence emit does not push * a no-op undo entry onto the history stack. */ clearReversePresence(): void; /** * `issueTimeTicket` creates a time ticket to be used to create a new operation. */ issueTimeTicket(): TimeTicket; /** * `getLastTimeTicket` returns the last time ticket issued in this context. */ getLastTimeTicket(): TimeTicket; /** * `acc` accumulates the given DataSize to Live size of the root. */ acc(diff: DataSize): void; } /** * `ChangeID` is for identifying the Change. This is immutable. */ declare class ChangeID { private clientSeq; private serverSeq?; private actor; private lamport; private versionVector; constructor(clientSeq: number, lamport: bigint, actor: ActorID, vector: VersionVector, serverSeq?: bigint); /** * `hasClocks` returns true if this ID has logical clocks. */ hasClocks(): boolean; /** * `of` creates a new instance of ChangeID. */ static of(clientSeq: number, lamport: bigint, actor: ActorID, vector: VersionVector, serverSeq?: bigint): ChangeID; /** * `next` creates a next ID of this ID. */ next(excludeClocks?: boolean): ChangeID; /** * `syncClocks` syncs logical clocks with the given ID. If the given ID * doesn't have logical clocks, this ID is returned. */ syncClocks(other: ChangeID): ChangeID; /** * `syncLamport` advances the lamport clock against the given ID without * merging its version vector into the receiver's. It is the counterpart * of `syncClocks` for attachments that have opted out of GC participation * (see docs/design/disable-gc-on-attach.md in the server repo): the * receiver does not need other actors' entries in its VV because it * never produces or consumes tombstones, and dropping them keeps each * subsequent local Change's VV at O(1) instead of O(num_actors). * Lamport must still advance so that TimeTickets produced locally * remain ordered against remote operations. */ syncLamport(other: ChangeID): ChangeID; /** * `setClocks` sets the given clocks to this ID. This is used when the snapshot * is given from the server. */ setClocks(otherLamport: bigint, vector: VersionVector): ChangeID; /** * `createTimeTicket` creates a ticket of the given delimiter. */ createTimeTicket(delimiter: number): TimeTicket; /** * `setActor` sets the given actor. */ setActor(actorID: ActorID): ChangeID; /** * `setLamport` sets the given lamport clock. */ setLamport(lamport: bigint): ChangeID; /** * `setVersionVector` sets the given version vector. */ setVersionVector(versionVector: VersionVector): ChangeID; /** * `getClientSeq` returns the client sequence of this ID. */ getClientSeq(): number; /** * `getServerSeq` returns the server sequence of this ID. */ getServerSeq(): string; /** * `getLamport` returns the lamport clock of this ID. */ getLamport(): bigint; /** * `getLamportAsString` returns the lamport clock of this ID as a string. */ getLamportAsString(): string; /** * `getActorID` returns the actor of this ID. */ getActorID(): string; /** * `getVersionVector` returns the version vector of this ID. */ getVersionVector(): VersionVector; /** * `toTestString` returns a string containing the meta data of this ID. */ toTestString(): string; } /** * @generated from message yorkie.v1.ChangeID */ declare type ChangeID_2 = Message<"yorkie.v1.ChangeID"> & { /** * @generated from field: uint32 client_seq = 1; */ clientSeq: number; /** * @generated from field: int64 server_seq = 2; */ serverSeq: bigint; /** * @generated from field: int64 lamport = 3; */ lamport: bigint; /** * @generated from field: bytes actor_id = 4; */ actorId: Uint8Array; /** * @generated from field: yorkie.v1.VersionVector version_vector = 5; */ versionVector?: VersionVector_2; }; /** * `ChangeInfo` represents the modifications made during a document update * and the message passed. */ export declare interface ChangeInfo { message: string; operations: Array; actor: ActorID; clientSeq: number; serverSeq: string; } /** * `ChangeInfo` represents the modifications made during a document update * and the message passed. */ declare interface ChangeInfo_2 { message: string; operations: Array; actor: ActorID_2; clientSeq: number; serverSeq: string; } /** * `ChangePack` is a unit for delivering changes in a document to the remote. * */ declare class ChangePack

{ /** * `documentKey` is the key of the document. */ private documentKey; /** * `Checkpoint` is used to determine the client received changes. */ private checkpoint; /** * `isRemoved` is a flag that indicates whether the document is removed. */ private isRemoved; private changes; /** * `snapshot` is a byte array that encodes the document. */ private snapshot?; /** * `versionVector` is the version vector current document */ private versionVector?; constructor(key: string, checkpoint: Checkpoint, isRemoved: boolean, changes: Array>, versionVector?: VersionVector, snapshot?: Uint8Array); /** * `create` creates a new instance of ChangePack. */ static create

(key: string, checkpoint: Checkpoint, isRemoved: boolean, changes: Array>, versionVector?: VersionVector, snapshot?: Uint8Array): ChangePack

; /** * `getDocumentKey` returns the document key of this pack. */ getDocumentKey(): string; /** * `getCheckpoint` returns the checkpoint of this pack. */ getCheckpoint(): Checkpoint; /** * `getIsRemoved` returns the whether this document is removed. */ getIsRemoved(): boolean; /** * `getChanges` returns the changes of this pack. */ getChanges(): Array>; /** * `hasChanges` returns the whether this pack has changes or not. */ hasChanges(): boolean; /** * `getChangeSize` returns the size of changes this pack has. */ getChangeSize(): number; /** * `hasSnapshot` returns the whether this pack has a snapshot or not. */ hasSnapshot(): boolean; /** * `getSnapshot` returns the snapshot of this pack. */ getSnapshot(): Uint8Array | undefined; /** * `getVersionVector` returns the document's version vector of this pack */ getVersionVector(): VersionVector | undefined; } /** * ChangePack is a message that contains all changes that occurred in a document. * It is used to synchronize changes between clients and servers. * * @generated from message yorkie.v1.ChangePack */ declare type ChangePack_2 = Message<"yorkie.v1.ChangePack"> & { /** * @generated from field: string document_key = 1; */ documentKey: string; /** * @generated from field: yorkie.v1.Checkpoint checkpoint = 2; */ checkpoint?: Checkpoint_2; /** * @generated from field: bytes snapshot = 3; */ snapshot: Uint8Array; /** * @generated from field: repeated yorkie.v1.Change changes = 4; */ changes: Change_2[]; /** * deprecated * * @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5; */ minSyncedTicket?: TimeTicket_2; /** * @generated from field: bool is_removed = 6; */ isRemoved: boolean; /** * @generated from field: yorkie.v1.VersionVector version_vector = 7; */ versionVector?: VersionVector_2; }; /** * `ChangeStruct` represents the structure of Change. * This is used to serialize and deserialize Change. */ declare type ChangeStruct

= { changeID: string; message?: string; operations?: Array; presenceChange?: { type: PresenceChangeType; presence?: P; }; }; /** * `ChangeStruct` represents the structure of Change. * This is used to serialize and deserialize Change. */ declare type ChangeStruct_2

= { changeID: string; message?: string; operations?: Array; presenceChange?: { type: PresenceChangeType_2; presence?: P; }; }; /** * `Channel` represents a lightweight channel for presence and messaging. */ export declare class Channel implements Observable_2, Attachable { private key; private status; private actorID?; private sessionID?; private sessionCount; private seq; private eventStream; private eventStreamObserver; /** * @param key - the key of the channel. */ constructor(key: string); /** * `getKey` returns the key of this channel. */ getKey(): string; /** * `getFirstKeyPath` returns the first key path to the presence count. */ getFirstKeyPath(): string; /** * `getStatus` returns the status of this channel. */ getStatus(): ChannelStatus; /** * `applyStatus` applies the channel status into this channel. */ applyStatus(status: ChannelStatus): void; /** * `isAttached` returns whether this channel is attached or not. */ isAttached(): boolean; /** * `getActorID` returns the actor ID of this channel. */ getActorID(): ActorID | undefined; /** * `setActor` sets the actor ID into this channel. */ setActor(actorID: ActorID): void; /** * `getSessionID` returns the session ID from the server. */ getSessionID(): string | undefined; /** * `setSessionID` sets the session ID from the server. */ setSessionID(sessionID: string): void; /** * `getSessionCount` returns the current channel online session count value. */ getSessionCount(): number; /** * `updateSessionCount` updates the session count and sequence number if the sequence is newer. * Returns true if the count was updated, false if the update was ignored. */ updateSessionCount(sessionCount: number, seq: number): boolean; /** * `hasLocalChanges` returns whether this channel has local changes or not. * Channel is server-managed, so it always returns false. */ hasLocalChanges(): boolean; /** * `subscribe` registers a callback to subscribe to events on the channel. * The callback will be called when the broadcast event is received from the remote client. */ subscribe(type: 'broadcast', next: ChannelEventCallbackMap['broadcast']): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the channel. * The callback will be called when the local client sends a broadcast event. */ subscribe(type: 'local-broadcast', next: ChannelEventCallbackMap['local-broadcast']): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the channel. * The callback will be called when an authentication error occurs. */ subscribe(type: 'auth-error', next: ChannelEventCallbackMap['auth-error']): Unsubscribe; /** * `subscribe` registers a callback to subscribe to non-recoverable sync * (RefreshChannel) errors. Subsequent successful events on the channel * imply recovery — there is no separate "recovered" event. */ subscribe(type: 'sync-error', next: ChannelEventCallbackMap['sync-error']): Unsubscribe; /** * `subscribe` registers a callback to subscribe to presence events on the channel. * The callback will be called when the presence count changes. */ subscribe(type: 'presence', next: ChannelEventCallbackMap['presence']): Unsubscribe; /** * `subscribe` registers a callback to subscribe to all events on the channel. */ subscribe(type: 'all', next: ChannelEventCallbackMap['all']): Unsubscribe; /** * `subscribe` registers a callback to subscribe to broadcast events for a specific topic. * The callback will be called when a broadcast event with the matching topic is received. */ subscribe(topic: string, next: NextFn): Unsubscribe; /** * `subscribe` registers an observer for all channel events. * Returns an unsubscribe function. */ subscribe(arg1: NextFn): Unsubscribe; /** * `publish` publishes an event to all registered handlers. */ publish(event: ChannelEvent): void; /** * `broadcast` sends a message to all clients watching this channel. */ broadcast(topic: string, payload: any, options?: BroadcastOptions): void; private validateChannelKey; } /** * `ChannelEvent` represents an event that occurs in the channel. */ export declare type ChannelEvent = PresenceEvent_3 | BroadcastEvent | LocalBroadcastEvent | AuthErrorEvent_3 | SyncErrorEvent; /** * `ChannelEventCallbackMap` represents a map of event types to callbacks. */ declare type ChannelEventCallbackMap = { broadcast: NextFn; 'local-broadcast': NextFn; 'auth-error': NextFn; 'sync-error': NextFn; presence: NextFn; all: NextFn; }; /** * `ChannelEventType` represents the type of channel event. */ export declare enum ChannelEventType { /** * `Changed` means that the presence has changed. */ PresenceChanged = "presence-changed", /** * `Initialized` means that the presence watch has been initialized. */ Initialized = "initialized", /** * `Broadcast` means that a broadcast message has been received. */ Broadcast = "broadcast", /** * `LocalBroadcast` means that a broadcast message has been sent by the local client. */ LocalBroadcast = "local-broadcast", /** * `AuthError` means that an authentication error has occurred. */ AuthError = "auth-error", /** * `SyncError` means that a non-recoverable sync (RefreshChannel) error * occurred. Subscribers can use this to render an error state in the UI * without polling internal SDK state. The SDK still retries via its sync * loop, so subsequent successful events (PresenceChanged/Initialized) can * be treated as recovery. */ SyncError = "sync-error" } /** * `PresenceStatus` represents the status of the presence. */ export declare enum ChannelStatus { /** * `Detached` means that the presence is not attached to the client. */ Detached = "detached", /** * `Attached` means that the presence is attached to the client. */ Attached = "attached", /** * `Removed` means that the presence is removed. */ Removed = "removed" } /** * `Checkpoint` is used to determine the changes sent and received by the * client. This is immutable. * **/ declare class Checkpoint { private serverSeq; private clientSeq; constructor(serverSeq: bigint, clientSeq: number); /** * `of` creates a new instance of Checkpoint. */ static of(serverSeq: bigint, clientSeq: number): Checkpoint; /** * `increaseClientSeq` creates a new instance with increased client sequence. */ increaseClientSeq(inc: number): Checkpoint; /** * `forward` creates a new instance with the given checkpoint if it is * greater than the values of internal properties. */ forward(other: Checkpoint): Checkpoint; /** * `getServerSeqAsString` returns the server seq of this checkpoint as a * string. */ getServerSeqAsString(): string; /** * `getClientSeq` returns the client seq of this checkpoint. */ getClientSeq(): number; /** * `getServerSeq` returns the server seq of this checkpoint. */ getServerSeq(): bigint; /** * `equals` returns whether the given checkpoint is equal to this checkpoint * or not. */ equals(other: Checkpoint): boolean; /** * `toTestString` returns a string containing the meta data of this * checkpoint. */ toTestString(): string; } /** * @generated from message yorkie.v1.Checkpoint */ declare type Checkpoint_2 = Message<"yorkie.v1.Checkpoint"> & { /** * @generated from field: int64 server_seq = 1; */ serverSeq: bigint; /** * @generated from field: uint32 client_seq = 2; */ clientSeq: number; }; /** * `Client` is a normal client that can communicate with the server. * It has documents and sends changes of the documents in local * to the server to synchronize with other replicas in remote. */ export declare class Client { private id?; private key; private metadata; private status; private attachmentMap; private apiKey; private authTokenInjector?; private conditions; private syncLoopDuration; private reconnectStreamDelay; private retrySyncLoopDelay; private channelHeartbeatInterval; private deactivateOnUnload; private rpcClient; private setAuthToken; private taskQueue; private processing; private keepalive; private deactivating; /** * @param rpcAddr - the address of the RPC server. * @param opts - the options of the client. */ constructor(opts?: ClientOptions); /** * `activate` activates this client. That is, it registers itself to the server * and receives a unique ID from the server. The given ID is used to * distinguish different clients. */ activate(): Promise; /** * `deactivate` deactivates this client. * * @param options - If keepalive is true, the client will request deactivation * immediately using `fetch` with the `keepalive` option enabled. This is * useful for ensuring the deactivation request completes even if the page is * being unloaded, such as in `beforeunload` or `unload` event listeners. * If synchronous is true, the server will wait for all pending operations to * complete before deactivating. */ deactivate(options?: DeactivateOptions): Promise; /** * `has` checks if the given resource is attached to this client. * @param key - the key of the resource. * @returns true if the resource is attached to this client. */ has(key: Key): boolean; /** * `attach` attaches a Document or Channel to this client. * Overloaded to support both types. */ attach(resource: Document_2, opts?: AttachOptions): Promise>; /** * `attach` attaches the given channel to this client. The channel is * registered locally and the server is notified on the next RefreshChannel * heartbeat. */ attach(resource: Channel, opts?: AttachChannelOptions): Promise; /** * `attach` attaches the given document to this client. It tells the server that * this client will synchronize the given document. */ private attachDocument; /** * `detach` detaches a Document or Channel from this client. * Overloaded to support both types. */ detach(resource: Document_2, opts?: { keepalive?: boolean; }): Promise>; /** * `detach` detaches the given channel from this client. The detach is a * local cleanup; the server reclaims the session via TTL when heartbeats * stop. */ detach(resource: Channel): Promise; /** * `detach` detaches the given document from this client. It tells the * server that this client will no longer synchronize the given document. * * To collect garbage things like CRDT tombstones left on the document, all * the changes should be applied to other replicas before GC time. For this, * if the document is no longer used by this client, it should be detached. */ private detachDocument; /** * `attachChannel` attaches the given channel to this client. The channel is * registered locally and the server is notified on the next RefreshChannel * heartbeat. */ attachChannel(channel: Channel, opts?: AttachChannelOptions): Promise; /** * `detachChannel` detaches the given channel from this client. The detach * is a local cleanup; the server reclaims the session via TTL when * heartbeats stop. */ detachChannel(channel: Channel): Promise; /** * `changeSyncMode` changes the synchronization mode of the given document. */ changeSyncMode(doc: Document_2, syncMode: SyncMode): Promise>; /** * `changeSyncMode` changes the synchronization mode of the given channel. */ changeSyncMode(channel: Channel, syncMode: SyncMode): Promise; private changeDocumentSyncMode; /** * `assertValidChannelSyncMode` rejects sync modes that are not valid for * channels. `RealtimePushOnly` and `RealtimeSyncOff` are document-only. */ private assertValidChannelSyncMode; private changeChannelSyncMode; /** * `sync` pushes local changes of the attached documents to the server and * receives changes of the remote replica from the server then apply them to * local documents. * * For Channel in manual mode, it refreshes the TTL by sending a heartbeat. */ sync(doc?: Document_2): Promise>>; /** * `sync` refreshes the TTL of the given channel by sending a heartbeat. * This is used for manual mode channel. */ sync(channel: Channel): Promise; /** * `remove` removes the given document. */ remove(doc: Document_2): Promise; /** * `getID` returns a ActorID of client. */ getID(): string | undefined; /** * `getKey` returns a key of client. */ getKey(): string; /** * `isActive` checks if the client is active. */ isActive(): boolean; /** * `getStatus` returns the status of this client. */ getStatus(): ClientStatus; /** * `getCondition` returns the condition of this client. */ getCondition(condition: ClientCondition): boolean; /** * `createRevision` creates a new revision for the given document. */ createRevision(doc: Document_2, label: string, description?: string): Promise; /** * `listRevisions` lists all revisions for the given document. */ listRevisions(doc: Document_2, options?: { pageSize?: number; offset?: number; isForward?: boolean; }): Promise>; /** * `getRevision` retrieves a specific revision by its ID with full snapshot data. */ getRevision(doc: Document_2, revisionID: string): Promise; /** * `restoreRevision` restores the document to the given revision. */ restoreRevision(doc: Document_2, revisionId: string): Promise; /** * `peekChannel` reads the current session count of a channel without * creating a session on the server. Use this when the caller only needs * to display the count (e.g. "N people writing") without contributing to * it and without receiving broadcasts. * * Unlike `attach({ readOnly: true })`, this does not occupy a `Session` * entry on the server, does not generate heartbeat RPCs, and does not * subscribe to channel events. Polling is the caller's responsibility. */ peekChannel(channelKey: string): Promise; /** * `broadcast` broadcasts the given payload to the given topic. */ broadcast(key: Key, topic: string, payload: any, options?: BroadcastOptions): Promise; /** * `runSyncLoop` runs the sync loop. The sync loop pushes local changes to * the server and pulls remote changes from the server. */ private runSyncLoop; /** * `runWatchLoop` runs the watch loop for the given resource (Document or Channel). * The watch loop listens to the events of the given resource from the server. */ private runWatchLoop; /* Excluded from this release type: createDocumentWatchStream */ /* Excluded from this release type: createChannelWatchStream */ /* Excluded from this release type: handleWatchChannelResponse */ private handleWatchDocumentResponse; private deactivateInternal; private detachInternal; private syncInternal; /** * `handleConnectError` handles the given error. If the given error can be * retried after handling, it returns true. */ private handleConnectError; /** * `enqueueTask` enqueues the given task to the task queue. */ private enqueueTask; /** * `processNext` processes the next task in the task queue. This method is * part of enqueueTask. */ private processNext; } /** * `Client` represents a client value in devtools. */ declare type Client_2 = { clientID: string; presence: Json_2; }; /** * `ClientCondition` represents the condition of the client. */ export declare enum ClientCondition { /** * `SyncLoop` is a key of the sync loop condition. */ SyncLoop = "SyncLoop", /** * `WatchLoop` is a key of the watch loop condition. */ WatchLoop = "WatchLoop" } /** * `ClientOptions` are user-settable options used when defining clients. */ export declare interface ClientOptions { /** * `rpcAddr` is the address of the RPC server. It is used to connect to * the server. */ rpcAddr?: string; /** * `key` is the client key. It is used to identify the client. * If not set, a random key is generated. */ key?: string; /** * `apiKey` is the API key of the project. It is used to identify the project. * If not set, API key of the default project is used. */ apiKey?: string; /** * `metadata` is the metadata of the client. It is used to store additional * information about the client. */ metadata?: Record; /** * `authTokenInjector` is a function that provides a token for the auth webhook. * When the webhook response status code is 401, this function is called to refresh the token. * The `reason` parameter is the reason from the webhook response. */ authTokenInjector?: (reason?: string) => Promise; /** * `syncLoopDuration` is the duration of the sync loop. After each sync loop, * the client waits for the duration to next sync. The default value is * `50`(ms). */ syncLoopDuration?: number; /** * `retrySyncLoopDelay` is the delay of the retry sync loop. If the sync loop * fails, the client waits for the delay to retry the sync loop. The default * value is `1000`(ms). */ retrySyncLoopDelay?: number; /** * `reconnectStreamDelay` is the delay of the reconnect stream. If the stream * is disconnected, the client waits for the delay to reconnect the stream. The * default value is `1000`(ms). */ reconnectStreamDelay?: number; /** * `channelHeartbeatInterval` is the interval of the channel heartbeat (ms). * The client sends a `RefreshChannel` heartbeat to refresh the channel * session TTL. The default value is `5000` (ms) — co-tuned to the server's * `ChannelSessionTTL` (15 s) at TTL/3. Values larger than the server TTL * risk premature session expiry. */ channelHeartbeatInterval?: number; /** * `userAgent` is the user agent of the client. It is used to identify the * client. */ userAgent?: string; /** * `useGrpcWebTransport` determines the transport protocol. * If true, uses gRPC-Web transport for backward compatibility. * If false (default), uses Connect Protocol transport. */ useGrpcWebTransport?: boolean; /** * `deactivateOnUnload` controls whether the client registers a * `beforeunload` listener during `activate()` that deactivates the client * when the page is unloaded. The default value is `true`. * * Setting this to `false` skips the listener registration. This is useful * for apps that don't need GC or presence cleanup on unload (for example, * `disableGC` documents without collaboration): the unload-time * deactivate becomes pure overhead and its `fetch({ keepalive: true })` * request can reject mid-flight during hard navigation, surfacing as an * unhandled `[unknown]` `ConnectError`. The server reaps the stale * client after its `clientDeactivateThreshold`, so opting out is safe. */ deactivateOnUnload?: boolean; } /** * `ClientStatus` represents the status of the client. */ export declare enum ClientStatus { /** * `Deactivated` means that the client is not activated. It is the initial * status of the client. If the client is deactivated, all `Document`s of the * client are also not used. */ Deactivated = "deactivated", /** * `Activated` means that the client is activated. If the client is activated, * all `Document`s of the client are also ready to be used. */ Activated = "activated" } declare type Comparator = (keyA: K, keyB: K) => number; export declare type CompleteFn = () => void; /** * `ConnectionChangedEvent` is an event that occurs when the stream connection state changes. */ export declare interface ConnectionChangedEvent extends BaseDocEvent_2 { type: DocEventType.ConnectionChanged; value: StreamConnectionStatus; } /** * `ConnectionChangedEvent` is an event that occurs when the stream connection state changes. */ declare interface ConnectionChangedEvent_2 extends BaseDocEvent { type: DocEventType_2.ConnectionChanged; value: StreamConnectionStatus_2; } /** * `ContainerValue` represents the result of `Array.toJSForTest()` and * `Object.toJSForTest()`. */ declare type ContainerValue = { [key: string]: JSONElement_2; }; /** * `converter` is a converter that converts the given model to protobuf format. * is also used to convert models to bytes and vice versa. */ export declare const converter: { fromPresence: typeof fromPresence; toChangePack: typeof toChangePack; fromChangePack: typeof fromChangePack; fromChanges: typeof fromChanges; toTreeNodes: typeof toTreeNodes; fromTreeNodes: typeof fromTreeNodes; objectToBytes: typeof objectToBytes; bytesToObject: typeof bytesToObject; bytesToSnapshot: typeof bytesToSnapshot; bytesToHex: typeof bytesToHex; hexToBytes: typeof hexToBytes; toHexString: typeof toHexString; toUint8Array: typeof toUint8Array; toOperation: typeof toOperation; toChangeID: typeof toChangeID; bytesToChangeID: typeof bytesToChangeID; bytesToOperation: typeof bytesToOperation; versionVectorToHex: typeof versionVectorToHex; hexToVersionVector: typeof hexToVersionVector; fromSchemaRules: typeof fromSchemaRules; toRevisionSummary: typeof toRevisionSummary; changeIDToBinary: (changeID: ChangeID) => Uint8Array; operationToBinary: (op: Operation) => Uint8Array; }; /** * `Counter` is a numeric counter that supports `increase()`. * For counting unique actors, use `DedupCounter` instead. * * ```typescript * // Type is inferred from value: * root.count = new Counter(0); // Int * root.count = new Counter(0n); // Long * ``` */ export declare class Counter extends BaseCounter { constructor(value: number | bigint); /** * `getValue` returns the value of this counter. */ getValue(): number | bigint; /** * `increase` increases numeric data. */ increase(v: number | bigint): Counter; } /** * `CounterOpInfo` represents the OperationInfo for the yorkie.Counter. */ export declare type CounterOpInfo = IncreaseOpInfo; /** * `CounterOpInfo` represents the OperationInfo for the yorkie.Counter. */ declare type CounterOpInfo_2 = IncreaseOpInfo_2; export declare enum CounterType { Int = 0, Long = 1, IntDedup = 2 } export declare type CounterValue = number | bigint; declare type CounterValue_2 = number | bigint; /** * * `CRDTContainer` represents CRDTArray or CRDtObject. */ declare abstract class CRDTContainer extends CRDTElement { constructor(createdAt: TimeTicket); /** * `subPathOf` returns the sub path of the given element. */ abstract subPathOf(createdAt: TimeTicket): string | undefined; abstract purge(element: CRDTElement): void; abstract delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement; abstract getDescendants(callback: (elem: CRDTElement, parent: CRDTContainer) => boolean): void; /** * `get` returns the element of the given key or index. This method is called * by users. So it should return undefined if the element is removed. */ abstract get(keyOrIndex: string | number): CRDTElement | undefined; /** * `getByID` returns the element of the given creation time. This method is * called by internal. So it should return the element even if the element is * removed. */ abstract getByID(createdAt: TimeTicket): CRDTElement | undefined; } /** * `CRDTCounter` is a CRDT implementation of a counter. It is used to represent * a number that can be incremented or decremented. */ declare class CRDTCounter extends CRDTElement { private valueType; private value; private hll?; constructor(valueType: CounterType, value: CounterValue, createdAt: TimeTicket); /** * `of` creates a new instance of Counter. */ static create(valueType: CounterType, value: CounterValue, createdAt: TimeTicket): CRDTCounter; /** * `valueFromBytes` parses the given bytes into value. */ static valueFromBytes(counterType: CounterType, bytes: Uint8Array): CounterValue; /** * `getDataSize` returns the data usage of this element. */ getDataSize(): DataSize; /** * `toJSON` returns the JSON encoding of the value. */ toJSON(): string; /** * `toSortedJSON` returns the sorted JSON encoding of the value. */ toSortedJSON(): string; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `deepcopy` copies itself deeply. */ deepcopy(): CRDTCounter; /** * `getType` returns the type of the value. */ getType(): CounterType; /** * `getCounterType` returns counter type of given value. */ static getCounterType(value: CounterValue): CounterType | undefined; /** * `isSupport` check if there is a counter type of given value. */ static isSupport(value: CounterValue): boolean; /** * `isInteger` checks if the num is integer. */ static isInteger(num: number): boolean; /** * `isNumericType` check numeric type by JSONCounter. */ isNumericType(): boolean; /** * `getValueType` get counter value type. */ getValueType(): CounterType; /** * `getValue` get counter value. */ getValue(): CounterValue; /** * `toBytes` creates an array representing the value. */ toBytes(): Uint8Array; /** * `isDedup` returns whether dedup mode is enabled (derived from ValueType). */ isDedup(): boolean; /** * `increaseDedup` increases the counter using HLL-based dedup. * Only updates the value if the actor is new (not seen before). */ increaseDedup(v: Primitive, actor: string): CRDTCounter; /** * `hllBytes` returns the HLL register bytes, or undefined if not in dedup mode. */ hllBytes(): Uint8Array | undefined; /** * `restoreHLL` restores the HLL state from serialized bytes. */ restoreHLL(data: Uint8Array): void; /** * `recomputeValue` updates the counter value from the HLL cardinality estimate. */ private recomputeValue; /** * `increase` increases numeric data. * Dedup counters must use increaseDedup() instead. */ increase(v: Primitive): CRDTCounter; } /** * `CRDTElement` represents an element that has `TimeTicket`s. */ declare abstract class CRDTElement { private createdAt; private movedAt?; private removedAt?; constructor(createdAt: TimeTicket); /** * `getCreatedAt` returns the creation time of this element. */ getCreatedAt(): TimeTicket; /** * `getID` returns the creation time of this element. */ getID(): TimeTicket; /** * `getMovedAt` returns the move time of this element. */ getMovedAt(): TimeTicket | undefined; /** * `getRemovedAt` returns the removal time of this element. */ getRemovedAt(): TimeTicket | undefined; /** * `getPositionedAt` returns the time of this element when it was positioned * in the document by undo/redo or move operation. */ getPositionedAt(): TimeTicket; /** * `setCreatedAt` sets the creation time of this element manually. */ setCreatedAt(createdAt: TimeTicket): void; /** * `setMovedAt` sets the move time of this element. */ setMovedAt(movedAt?: TimeTicket): boolean; /** * `setRemovedAt` sets the remove time of this element. */ setRemovedAt(removedAt?: TimeTicket): void; /** * `remove` removes this element. */ remove(removedAt?: TimeTicket): boolean; /** * `isRemoved` check if this element was removed. */ isRemoved(): boolean; /** * `getMetaUsage` returns the meta usage of this element. */ getMetaUsage(): number; /** * `getDataSize` returns the data usage of this element. */ abstract getDataSize(): DataSize; abstract toJSON(): string; abstract toSortedJSON(): string; abstract toJSForTest(): Devtools.JSONElement; abstract deepcopy(): CRDTElement; } /** * `CRDTElementPair` is a structure that represents a pair of element and its * parent. It is used to find the parent of a specific element to perform * garbage collection and to find the path of a specific element. */ declare interface CRDTElementPair { element: CRDTElement; parent?: CRDTContainer; } /** * `CRDTObject` represents an object data type, but unlike regular JSON, * it has `TimeTicket`s which are created by logical clock. * */ declare class CRDTObject extends CRDTContainer { private memberNodes; constructor(createdAt: TimeTicket, memberNodes: ElementRHT); /** * `create` creates a new instance of CRDTObject. */ static create(createdAt: TimeTicket, value?: { [key: string]: CRDTElement; }): CRDTObject; /** * `subPathOf` returns the sub path of the given element. */ subPathOf(createdAt: TimeTicket): string | undefined; /** * `purge` physically purges the given element. */ purge(value: CRDTElement): void; /** * `set` sets the given element of the given key. */ set(key: string, value: CRDTElement, executedAt: TimeTicket): CRDTElement | undefined; /** * `delete` deletes the element of the given key. */ delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement; /** * `deleteByKey` deletes the element of the given key and execution time. */ deleteByKey(key: string, executedAt: TimeTicket): CRDTElement | undefined; /** * `get` returns the value of the given key. */ get(key: string): CRDTElement | undefined; /** * `getByID` returns the element of the given createAt. */ getByID(createdAt: TimeTicket): CRDTElement | undefined; /** * `has` returns whether the element exists of the given key or not. */ has(key: string): boolean; /** * `getDataSize` returns the data usage of this element. */ getDataSize(): DataSize; /** * `toJSON` returns the JSON encoding of this object. */ toJSON(): string; /** * `toJS` returns the JavaScript object of this object. */ toJS(): any; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `getKeys` returns array of keys in this object. */ getKeys(): Array; /** * `toSortedJSON` returns the sorted JSON encoding of this object. */ toSortedJSON(): string; /** * `getRHT` RHTNodes returns the RHTPQMap nodes. */ getRHT(): ElementRHT; /** * `deepcopy` copies itself deeply. */ deepcopy(): CRDTObject; /** * `getDescendants` returns the descendants of this object by traversing. */ getDescendants(callback: (elem: CRDTElement, parent: CRDTContainer) => boolean): void; /** * `[Symbol.iterator]` returns an iterator for the entries in this object. */ [Symbol.iterator](): IterableIterator<[string, CRDTElement]>; } /** * `CRDTRoot` is a structure that represents the root. It has a hash table of * all elements to find a specific element when applying remote changes * received from server. * * Every element has a unique `TimeTicket` at creation, which allows us to find * a particular element. */ declare class CRDTRoot { /** * `rootObject` is the root object of the document. */ private rootObject; /** * `elementPairMapByCreatedAt` is a hash table that maps the creation time of * an element to the element itself and its parent. */ private elementPairMapByCreatedAt; /** * `gcElementSetByCreatedAt` is a hash set that contains the creation * time of the removed element. It is used to find the removed element when * executing garbage collection. */ private gcElementSetByCreatedAt; /** * `gcPairMap` is a hash table that maps the IDString of GCChild to the * element itself and its parent. */ private gcPairMap; /** * `docSize` is a structure that represents the size of the document. */ private docSize; constructor(rootObject: CRDTObject); /** * `create` creates a new instance of Root. */ static create(): CRDTRoot; /** * `findByCreatedAt` returns the element of given creation time. */ findByCreatedAt(createdAt: TimeTicket): CRDTElement | undefined; /** * `findElementPairByCreatedAt` returns the element and parent pair * of given creation time. */ findElementPairByCreatedAt(createdAt: TimeTicket): CRDTElementPair | undefined; /** * `createSubPaths` creates an array of the sub paths for the given element. */ createSubPaths(createdAt: TimeTicket): Array; /** * `createPath` creates path of the given element. */ createPath(createdAt: TimeTicket): string; /** * `registerElement` registers the given element and its descendants to hash table. */ registerElement(element: CRDTElement, parent?: CRDTContainer): void; /** * `deregisterElement` deregister the given element and its descendants from hash table. */ deregisterElement(element: CRDTElement): number; /** * `registerRemovedElement` registers the given element to the hash set. */ registerRemovedElement(element: CRDTElement): void; /** * `registerGCPair` registers the given pair to hash table. */ registerGCPair(pair: GCPair): void; /** * `getElementMapSize` returns the size of element map. */ getElementMapSize(): number; /** * `getGarbageElementSetSize()` returns the size of removed element set. */ getGarbageElementSetSize(): number; /** * `getObject` returns root object. */ getObject(): CRDTObject; /** * `getGarbageLen` returns length of nodes which can be garbage collected. */ getGarbageLen(): number; /** * `getDocSize` returns the size of the document. */ getDocSize(): DocSize; /** * `deepcopy` copies itself deeply. */ deepcopy(): CRDTRoot; /** * `garbageCollect` purges elements that were removed before the given time. */ garbageCollect(minSyncedVersionVector: VersionVector): number; /** * `toJSON` returns the JSON encoding of this root object. */ toJSON(): string; /** * `toSortedJSON` returns the sorted JSON encoding of this root object. */ toSortedJSON(): string; /** * `getStats` returns the current statistics of the root object. * This includes counts of various types of elements and structural information. */ getStats(): RootStats; /** * `acc` accumulates the given DataSize to Live. */ acc(diff: DataSize): void; /** * `getGCElementPairs` returns an iterator for all GC element pairs. * This is similar to Go's GCElementPairMap() functionality. */ getGCElementPairs(): IterableIterator; } /** * `CRDTText` is a custom CRDT data type to represent the contents of text editors. * */ declare class CRDTText extends CRDTElement { private rgaTreeSplit; constructor(rgaTreeSplit: RGATreeSplit, createdAt: TimeTicket); /** * `create` a instance of Text. */ static create(rgaTreeSplit: RGATreeSplit, createdAt: TimeTicket): CRDTText; /** * `edit` edits the given range with the given value and attributes. */ edit(range: RGATreeSplitPosRange, content: string, editedAt: TimeTicket, attributes?: Record, versionVector?: VersionVector): [ Array>, Array, DataSize, RGATreeSplitPosRange, Array ]; /** * `setStyle` applies the style of the given range. * 01. split nodes with from and to * 02. style nodes between from and to * * @param range - range of RGATreeSplitNode * @param attributes - style attributes * @param editedAt - edited time */ setStyle(range: RGATreeSplitPosRange, attributes: Record, editedAt: TimeTicket, versionVector?: VersionVector): [ Array, DataSize, Array>, Map, Array ]; /** * `removeStyle` removes the style attributes of the given range. * Returns previous attribute values (from first styled node) for reverse operation. */ removeStyle(range: RGATreeSplitPosRange, attributesToRemove: Array, editedAt: TimeTicket, versionVector?: VersionVector): [Array, DataSize, Array>, Map]; /** * `indexRangeToPosRange` returns the position range of the given index range. */ indexRangeToPosRange(fromIdx: number, toIdx: number): RGATreeSplitPosRange; /** * `length` returns size of RGATreeList. */ get length(): number; /** * `getTreeByIndex` returns the tree by index for debugging. */ getTreeByIndex(): SplayTree; /** * `getTreeByID` returns the tree by ID for debugging. */ getTreeByID(): LLRBTree>; /** * `refinePos` refines the given RGATreeSplitPos. */ refinePos(pos: RGATreeSplitPos): RGATreeSplitPos; /** * `normalizePos` normalizes the given RGATreeSplitPos. */ normalizePos(pos: RGATreeSplitPos): RGATreeSplitPos; /** * `getDataSize` returns the data usage of this element. */ getDataSize(): DataSize; /** * `toJSON` returns the JSON encoding of this text. */ toJSON(): string; /** * `toSortedJSON` returns the sorted JSON encoding of this text. */ toSortedJSON(): string; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `toString` returns the string representation of this text. */ toString(): string; /** * `values` returns the content-attributes pair array of this text. */ values(): Array>; /** * `getRGATreeSplit` returns rgaTreeSplit. */ getRGATreeSplit(): RGATreeSplit; /** * `toTestString` returns a String containing the meta data of this value * for debugging purpose. */ toTestString(): string; /** * `deepcopy` copies itself deeply. */ deepcopy(): CRDTText; /** * `findIndexesFromRange` returns pair of integer offsets of the given range. */ findIndexesFromRange(range: RGATreeSplitPosRange): [number, number]; /** * `posToIndex` converts the given position to index. */ posToIndex(pos: RGATreeSplitPos, preferToLeft?: boolean): number; /** * `getGCPairs` returns the pairs of GC. */ getGCPairs(): Array; } /** * `CRDTTextValue` is a value of Text * which has a attributes that expresses the text style. * Attributes are represented by RHT. * */ declare class CRDTTextValue { private attributes; private content; constructor(content: string); /** * `create` creates a instance of CRDTTextValue. */ static create(content: string): CRDTTextValue; /** * `length` returns the length of value. */ get length(): number; /** * `substring` returns a sub-string value of the given range. */ substring(indexStart: number, indexEnd: number): CRDTTextValue; /** * `setAttr` sets attribute of the given key, updated time and value. */ setAttr(key: string, content: string, updatedAt: TimeTicket): [RHTNode | undefined, RHTNode | undefined]; /** * `getAttr` returns the attributes of this value. */ getAttrs(): RHT; /** * `toString` returns the string representation of this value. */ toString(): string; /** * `getDataSize` returns the data usage of this value. */ getDataSize(): DataSize; /** * `toJSON` returns the JSON encoding of this value. */ toJSON(): string; /** * `getAttributes` returns the attributes of this value. */ getAttributes(): Record; /** * `getContent` returns the internal content. */ getContent(): string; /** * `purge` purges the given child node. */ purge(node: GCChild): void; /** * `getGCPairs` returns the pairs of GC. */ getGCPairs(): Array; } /** * `CRDTTree` is a CRDT implementation of a tree. */ declare class CRDTTree extends CRDTElement implements GCParent { private indexTree; private nodeMapByID; constructor(root: CRDTTreeNode, createdAt: TimeTicket); /** * `rebuildMergeState` reconstructs the `mergedInto` cache on source * parents from the persisted `mergedFrom` field on moved children. * For snapshots written before `mergedAt` was added to the proto, * it also falls back to the source's `removedAt` — an approximation * that may be wrong if the source was later overwritten by a * concurrent delete, but this is the best we can do without the * persisted merge ticket. */ private rebuildMergeState; /** * `create` creates a new instance of `CRDTTree`. */ static create(root: CRDTTreeNode, ticket: TimeTicket): CRDTTree; /** * `findFloorNode` finds node of given id. */ findFloorNode(id: CRDTTreeNodeID): CRDTTreeNode | undefined; /** * `advancePastUnknownSplitSiblings` follows the insNextID chain of the * given node, advancing past element-type split siblings that the editing * client did not know about (not in versionVector). */ private advancePastUnknownSplitSiblings; /** * `hasUnknownSplitSibling` checks whether the given element node has a * split sibling (via insNextID) whose creation the editor did not know * about. Used to prevent styling via End tokens when a concurrent split * extended the range into the split sibling. */ private hasUnknownSplitSibling; /** * `registerNode` registers the given node to the tree. */ registerNode(node: CRDTTreeNode): void; /** * `findNodesAndSplitText` finds `TreePos` of the given `CRDTTreeNodeID` and * splits nodes if the position is in the middle of a text node. * * The ids of the given `pos` are the ids of the node in the CRDT perspective. * This is different from `TreePos` which is a position of the tree in the * physical perspective. * * If `editedAt` is given, then it is used to find the appropriate left node * for concurrent insertion. */ findNodesAndSplitText(pos: CRDTTreePos, editedAt?: TimeTicket): [TreeNodePair, DataSize]; /** * `style` applies the given attributes of the given range. */ style(range: [CRDTTreePos, CRDTTreePos], attributes: { [key: string]: string; } | undefined, editedAt: TimeTicket, versionVector?: VersionVector): [ Array, Array, DataSize, Map, Array ]; /** * `removeStyle` removes the given attributes of the given range. */ removeStyle(range: [CRDTTreePos, CRDTTreePos], attributesToRemove: Array, editedAt: TimeTicket, versionVector?: VersionVector): [Array, Array, DataSize, Map]; /** * `edit` edits the tree with the given range and content. * If the content is undefined, the range will be removed. */ edit(range: [CRDTTreePos, CRDTTreePos], contents: Array | undefined, splitLevel: number, editedAt: TimeTicket, issueTimeTicket: (() => TimeTicket) | undefined, versionVector?: VersionVector): [ Array, Array, DataSize, Array, number, number, Set ]; /** * `editT` edits the given range with the given value. * This method uses indexes instead of a pair of TreePos for testing. */ editT(range: [number, number], contents: Array | undefined, splitLevel: number, editedAt: TimeTicket, issueTimeTicket: () => TimeTicket): [ Array, Array, DataSize, Array, number, number, Set ]; /** * `move` move the given source range to the given target range. */ move(target: [number, number], source: [number, number], ticket: TimeTicket): void; /** * `pathToTreePos` converts the given path of the node to the TreePos. */ pathToTreePos(path: Array): ReturnType; /** * `purge` physically purges the given node. */ purge(node: CRDTTreeNode): void; /** * `getGCPairs` returns the pairs of GC. */ getGCPairs(): Array; /** * `findPos` finds the position of the given index in the tree. */ findPos(index: number, preferText?: boolean): CRDTTreePos; /** * `pathToPosRange` converts the given path of the node to the range of the position. */ pathToPosRange(path: Array): [CRDTTreePos, CRDTTreePos]; /** * `pathToPos` finds the position of the given index in the tree by path. */ pathToPos(path: Array): CRDTTreePos; /** * `getRoot` returns the root node of the tree. */ getRoot(): CRDTTreeNode; /** * `getSize` returns the size of the tree. */ getSize(): number; /** * `getNodeSize` returns the size of the LLRBTree. */ getNodeSize(): number; /** * `getIndexTree` returns the index tree. */ getIndexTree(): IndexTree; /** * toXML returns the XML encoding of this tree. */ toXML(): string; /** * `getDataSize` returns the data usage of this element. */ getDataSize(): DataSize; /** * `toJSON` returns the JSON encoding of this tree. */ toJSON(): string; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `toJSInfoForTest` returns detailed TreeNode information for use in Devtools. */ toJSInfoForTest(): Devtools.TreeNodeInfo; /** * `getRootTreeNode` returns the converted value of this tree to TreeNode. */ getRootTreeNode(): TreeNode; /** * `toTestTreeNode` returns the JSON of this tree for debugging. */ toTestTreeNode(): TreeNodeForTest; /** * `toSortedJSON` returns the sorted JSON encoding of this tree. */ toSortedJSON(): string; /** * `deepcopy` copies itself deeply. */ deepcopy(): CRDTTree; /** * `toPath` converts the given CRDTTreeNodeID to the path of the tree. */ toPath(parentNode: CRDTTreeNode, leftNode: CRDTTreeNode): Array; /** * `toIndex` converts the given CRDTTreeNodeID to the index of the tree. * If includeRemoved is true, it includes removed nodes in the calculation. */ toIndex(parentNode: CRDTTreeNode, leftNode: CRDTTreeNode, includeRemoved?: boolean): number; /** * `indexToPath` converts the given tree index to path. */ indexToPath(index: number): Array; /** * `pathToIndex` converts the given path to index. */ pathToIndex(path: Array): number; /** * `indexRangeToPosRange` returns the position range from the given index range. */ indexRangeToPosRange(range: [number, number]): TreePosRange; /** * `indexRangeToPosStructRange` converts the integer index range into the Tree position range structure. */ indexRangeToPosStructRange(range: [number, number]): TreePosStructRange; /** * `posRangeToPathRange` converts the given position range to the path range. */ posRangeToPathRange(range: TreePosRange): [Array, Array]; /** * `posRangeToIndexRange` converts the given position range to the path range. */ posRangeToIndexRange(range: TreePosRange): [number, number]; /** * `traverseInPosRange` traverses the tree in the given position range. * If includeRemoved is true, it includes removed nodes in the calculation. */ private traverseInPosRange; /** * `toTreePos` converts the given nodes to the position of the IndexTree. * If includeRemoved is true, it includes removed nodes in the calculation. */ private toTreePos; /** * `makeDeletionChanges` converts nodes to be deleted to deletion changes. */ private makeDeletionChanges; /** * `findRightToken` returns the token to the right of the given token in the tree. */ private findRightToken; /** * `findLeftToken` returns the token to the left of the given token in the tree. */ private findLeftToken; } /** * `CRDTTreeNode` is a node of CRDTTree. It includes the logical clock and * links to other nodes to resolve conflicts. */ declare class CRDTTreeNode extends IndexTreeNode implements GCParent, GCChild { id: CRDTTreeNodeID; removedAt?: TimeTicket; attrs?: RHT; /** * `insPrevID` is the previous node id of this node after the node is split. */ insPrevID?: CRDTTreeNodeID; /** * `insNextID` is the previous node id of this node after the node is split. */ insNextID?: CRDTTreeNodeID; /** * `mergedFrom` records the source parent's ID when this node was moved * by a concurrent merge. Persisted in the snapshot encoding as the * witness of the merge relationship. */ mergedFrom?: CRDTTreeNodeID; /** * `mergedAt` records the immutable ticket of the merge operation. * Persisted alongside `mergedFrom` because the source parent's * `removedAt` may be overwritten by later LWW tombstones and thus * cannot serve as the merge-time causal boundary for splitElement's * Fix 8 version-vector check. */ mergedAt?: TimeTicket; /** * `mergedInto` is a runtime cache set on the source parent pointing * at the merge target. Set locally during merge execution and rebuilt * from `mergedFrom` on snapshot load. Used for the fast * "is this tombstoned parent a merge source?" check in * `FindTreeNodesWithSplitText`; the alternative (scanning * `nodeMapByID` on every position resolution) would be too expensive. */ mergedInto?: CRDTTreeNodeID; _value: string; constructor(id: CRDTTreeNodeID, type: string, opts?: string | Array, attributes?: RHT, removedAt?: TimeTicket); /** * `toIDString` returns the IDString of this node. */ toIDString(): string; /** * `getRemovedAt` returns the time when this node was removed. */ getRemovedAt(): TimeTicket | undefined; /** * `create` creates a new instance of CRDTTreeNode. */ static create(id: CRDTTreeNodeID, type: string, opts?: string | Array, attributes?: RHT): CRDTTreeNode; /** * `deepcopy` copies itself deeply. */ deepcopy(): CRDTTreeNode; /** * `value` returns the value of the node. */ get value(): string; /** * `value` sets the value of the node. */ set value(v: string); /** * `isRemoved` returns whether the node is removed or not. */ get isRemoved(): boolean; /** * `remove` marks the node as removed. */ remove(removedAt: TimeTicket): boolean; /** * `cloneText` clones this text node with the given offset. */ cloneText(offset: number): CRDTTreeNode; /** * `cloneElement` clones this element node with the given issueTimeTicket function. */ cloneElement(issueTimeTicket: () => TimeTicket): CRDTTreeNode; /** * `split` splits the given offset of this node. */ split(tree: CRDTTree, offset: number, issueTimeTicket?: () => TimeTicket, versionVector?: VersionVector): [CRDTTreeNode | undefined, DataSize]; /** * `getCreatedAt` returns the creation time of this element. */ getCreatedAt(): TimeTicket; /** * `getOffset` returns the offset of a pos. */ getOffset(): number; /** * `canDelete` checks if node is able to delete. */ canDelete(editedAt: TimeTicket, creationKnown: boolean, tombstoneKnown: boolean): boolean; /** * `canStyle` checks if node is able to style. */ canStyle(editedAt: TimeTicket, clientLamportAtChange: bigint): boolean; /** * `setAttrs` sets the attributes of the node. */ setAttrs(attrs: { [key: string]: string; }, editedAt: TimeTicket): Array<[RHTNode | undefined, RHTNode | undefined]>; /** * `purge` purges the given child node. */ purge(node: RHTNode): void; /** * `getDataSize` returns the data size of the node. */ getDataSize(): DataSize; /** * `getGCPairs` returns the pairs of GC. */ getGCPairs(): Array; } /** * `CRDTTreeNodeID` represent an ID of a node in the tree. It is used to * identify a node in the tree. It is composed of the creation time of the node * and the offset from the beginning of the node if the node is split. * * Some of replicas may have nodes that are not split yet. In this case, we can * use `map.floorEntry()` to find the adjacent node. */ declare class CRDTTreeNodeID { /** * `createdAt` is the creation time of the node. */ private createdAt; /** * `offset` is the distance from the beginning of the node if the node is * split. */ private offset; constructor(createdAt: TimeTicket, offset: number); /** * `of` creates a new instance of CRDTTreeNodeID. */ static of(createdAt: TimeTicket, offset: number): CRDTTreeNodeID; /** * `fromStruct` creates a new instance of CRDTTreeNodeID from the given struct. */ static fromStruct(struct: CRDTTreeNodeIDStruct): CRDTTreeNodeID; /** * `createComparator` creates a comparator for CRDTTreeNodeID. */ static createComparator(): Comparator; /** * `getCreatedAt` returns the creation time of the node. */ getCreatedAt(): TimeTicket; /** * `equals` returns whether given ID equals to this ID or not. */ equals(other: CRDTTreeNodeID): boolean; /** * `getOffset` returns returns the offset of the node. */ getOffset(): number; /** * `setOffset` sets the offset of the node. */ setOffset(offset: number): void; /** * `toStruct` returns the structure of this position. */ toStruct(): CRDTTreeNodeIDStruct; /** * `toIDString` returns a string that can be used as an ID for this position. */ toIDString(): string; /** * `toTestString` returns a string containing the meta data of the ticket * for debugging purpose. */ toTestString(): string; } /** * `CRDTTreeNodeIDStruct` represents the structure of CRDTTreeNodeID. * It is used to serialize and deserialize the CRDTTreeNodeID. */ export declare type CRDTTreeNodeIDStruct = { createdAt: TimeTicketStruct; offset: number; }; /** * `CRDTTreeNodeIDStruct` represents the structure of CRDTTreeNodeID. * It is used to serialize and deserialize the CRDTTreeNodeID. */ declare type CRDTTreeNodeIDStruct_2 = { createdAt: TimeTicketStruct_2; offset: number; }; /** * `CRDTTreePos` represent a position in the tree. It is used to identify a * position in the tree. It is composed of the parent ID and the left sibling * ID. If there's no left sibling in parent's children, then left sibling is * parent. */ declare class CRDTTreePos { private parentID; private leftSiblingID; constructor(parentID: CRDTTreeNodeID, leftSiblingID: CRDTTreeNodeID); /** * `of` creates a new instance of CRDTTreePos. */ static of(parentID: CRDTTreeNodeID, leftSiblingID: CRDTTreeNodeID): CRDTTreePos; /** * `fromTreePos` creates a new instance of CRDTTreePos from the given TreePos. */ static fromTreePos(pos: TreePos): CRDTTreePos; /** * `getParentID` returns the parent ID. */ getParentID(): CRDTTreeNodeID; /** * `fromStruct` creates a new instance of CRDTTreeNodeID from the given struct. */ static fromStruct(struct: CRDTTreePosStruct_2): CRDTTreePos; /** * `toStruct` returns the structure of this position. */ toStruct(): CRDTTreePosStruct_2; /** * `toTreeNodePair` converts the pos to parent and left sibling nodes. * If the position points to the middle of a node, then the left sibling node * is the node that contains the position. Otherwise, the left sibling node is * the node that is located at the left of the position. */ toTreeNodePair(tree: CRDTTree): TreeNodePair; /** * `getLeftSiblingID` returns the left sibling ID. */ getLeftSiblingID(): CRDTTreeNodeID; /** * `equals` returns whether the given pos equals to this or not. */ equals(other: CRDTTreePos): boolean; } /** * `CRDTTreePosStruct` represents the structure of CRDTTreePos. */ declare type CRDTTreePosStruct = { parentID: CRDTTreeNodeIDStruct_2; leftSiblingID: CRDTTreeNodeIDStruct_2; }; /** * `CRDTTreePosStruct` represents the structure of CRDTTreePos. */ declare type CRDTTreePosStruct_2 = { parentID: CRDTTreeNodeIDStruct; leftSiblingID: CRDTTreeNodeIDStruct; }; /** * `DataSize` represents the size of a resource in bytes. */ declare type DataSize = { /** * `data` is the size of the data in bytes. */ data: number; /** * `meta` is the size of the metadata in bytes. */ meta: number; }; /** * `DeactivateOptions` are user-settable options used when deactivating clients. */ declare interface DeactivateOptions { /** * `keepalive` is used to enable the keepalive option when deactivating. * If true, the client will request deactivation immediately using `fetch` * with the `keepalive` option enabled. This is useful for ensuring the * deactivation request completes even if the page is being unloaded. */ keepalive?: boolean; /** * `synchronous` is used to enable the synchronous option when deactivating. * If true, the server will wait for all pending operations to complete * before deactivating. */ synchronous?: boolean; } /** * `DecreasedDepthOf` represents the type of the decreased depth of the given depth. */ declare type DecreasedDepthOf = Depth extends 10 ? 9 : Depth extends 9 ? 8 : Depth extends 8 ? 7 : Depth extends 7 ? 6 : Depth extends 6 ? 5 : Depth extends 5 ? 4 : Depth extends 4 ? 3 : Depth extends 3 ? 2 : Depth extends 2 ? 1 : Depth extends 1 ? 0 : -1; /** * `DedupCounter` is a Counter that uses HyperLogLog to count unique actors. * Use `add(actor)` to record a unique visitor. Provides approximate counts * with ~2% error rate. * * ```typescript * doc.update((root) => { * root.uv = new yorkie.DedupCounter(); * root.uv.add(userId); * }); * ``` */ export declare class DedupCounter extends BaseCounter { constructor(); /** * `getValue` returns the value of this counter. Always a number since * DedupCounter only supports IntDedup. */ getValue(): number; /** * `add` records a unique actor in the dedup counter. If the actor has * already been counted, the call is ignored. */ add(actor: string): DedupCounter; } /** * The top-level yorkie namespace with additional properties. * * In production, this will be called exactly once and the result * assigned to the `yorkie` global. * * e.g) `new yorkie.Client(...);` */ declare const _default: { Client: typeof Client; Document: typeof Document_2; Primitive: typeof Primitive; Text: typeof Text_2; Counter: typeof Counter; DedupCounter: typeof DedupCounter; Tree: typeof Tree; Devtools: typeof Devtools; Channel: typeof Channel; ChannelEventType: typeof ChannelEventType; YSON: typeof YSON; LogLevel: typeof LogLevel; setLogLevel: typeof setLogLevel; }; export default _default; /** * `DefaultTextType` is the default type of the text node. * It is used when the type of the text node is not specified. */ declare const DefaultTextType = 'text'; /** * `DefaultTextType` is the default type of the text node. * It is used when the type of the text node is not specified. */ declare const DefaultTextType_2 = "text"; declare namespace Devtools { export { isDocEventForReplay, isDocEventsForReplay, Client_2 as Client, JSONElement_2 as JSONElement, ContainerValue, TreeNodeInfo, DocEventForReplay, DocEventsForReplay } } export { Devtools } /** * `DocEvent` is an event that occurs in `Document`. It can be delivered * using `Document.subscribe()`. */ export declare type DocEvent

= StatusChangedEvent_2 | ConnectionChangedEvent | SyncStatusChangedEvent | SnapshotEvent | LocalChangeEvent | RemoteChangeEvent | PresenceEvent_2

| AuthErrorEvent_2 | EpochMismatchEvent; /** * `DocEvent` is an event that occurs in `Document`. It can be delivered * using `Document.subscribe()`. */ declare type DocEvent_2

= | StatusChangedEvent | ConnectionChangedEvent_2 | SyncStatusChangedEvent_2 | SnapshotEvent_2 | LocalChangeEvent_2 | RemoteChangeEvent_2 | PresenceEvent

| AuthErrorEvent | EpochMismatchEvent_2; declare type DocEventCallbackMap

= { default: NextFn | RemoteChangeEvent | SnapshotEvent>; presence: NextFn>; 'my-presence': NextFn | PresenceChangedEvent

>; others: NextFn | UnwatchedEvent

| PresenceChangedEvent

>; connection: NextFn; status: NextFn; sync: NextFn; 'auth-error': NextFn; 'epoch-mismatch': NextFn; all: NextFn>; }; /** * `DocEventForReplay` is an event used to replay a document. */ declare type DocEventForReplay

= | StatusChangedEvent | SnapshotEvent_2 | LocalChangeEvent_2 | RemoteChangeEvent_2 | InitializedEvent_2

| WatchedEvent_2

| UnwatchedEvent_2

| PresenceChangedEvent_2

; /** * `DocEventForReplay` is an event used to replay a document. */ declare type DocEventForReplay_2

= StatusChangedEvent_2 | SnapshotEvent | LocalChangeEvent | RemoteChangeEvent | InitializedEvent

| WatchedEvent

| UnwatchedEvent

| PresenceChangedEvent

; /** * `DocEvents` represents document events that occur within * a single transaction (e.g., doc.update). */ export declare type DocEvents

= Array>; /** * `DocEventsForReplay` is a list of events used to replay a document. */ declare type DocEventsForReplay = Array; /** * `DocEventsForReplay` is a list of events used to replay a document. */ declare type DocEventsForReplay_2 = Array; /** * `DocEventType` represents the type of the event that occurs in `Document`. */ export declare enum DocEventType { /** * status changed event type */ StatusChanged = "status-changed", /** * `ConnectionChanged` means that the watch stream connection status has changed. */ ConnectionChanged = "connection-changed", /** * `SyncStatusChanged` means that the document sync status has changed. */ SyncStatusChanged = "sync-status-changed", /** * snapshot event type */ Snapshot = "snapshot", /** * local document change event type */ LocalChange = "local-change", /** * remote document change event type */ RemoteChange = "remote-change", /** * `Initialized` means that online clients have been loaded from the server. */ Initialized = "initialized", /** * `Watched` means that the client has established a connection with the server, * enabling real-time synchronization. */ Watched = "watched", /** * `Unwatched` means that the connection has been disconnected. */ Unwatched = "unwatched", /** * `PresenceChanged` means that the presences of the client has updated. */ PresenceChanged = "presence-changed", /** * `AuthError` indicates an authorization failure in syncLoop or watchLoop. */ AuthError = "auth-error", /** * `EpochMismatch` indicates the document was compacted on the server * and this client must detach and reattach to recover. */ EpochMismatch = "epoch-mismatch" } /** * `DocEventType` represents the type of the event that occurs in `Document`. */ declare enum DocEventType_2 { /** * status changed event type */ StatusChanged = 'status-changed', /** * `ConnectionChanged` means that the watch stream connection status has changed. */ ConnectionChanged = 'connection-changed', /** * `SyncStatusChanged` means that the document sync status has changed. */ SyncStatusChanged = 'sync-status-changed', /** * snapshot event type */ Snapshot = 'snapshot', /** * local document change event type */ LocalChange = 'local-change', /** * remote document change event type */ RemoteChange = 'remote-change', /** * `Initialized` means that online clients have been loaded from the server. */ Initialized = 'initialized', /** * `Watched` means that the client has established a connection with the server, * enabling real-time synchronization. */ Watched = 'watched', /** * `Unwatched` means that the connection has been disconnected. */ Unwatched = 'unwatched', /** * `PresenceChanged` means that the presences of the client has updated. */ PresenceChanged = 'presence-changed', /** * `AuthError` indicates an authorization failure in syncLoop or watchLoop. */ AuthError = 'auth-error', /** * `EpochMismatch` indicates the document was compacted on the server * and this client must detach and reattach to recover. */ EpochMismatch = 'epoch-mismatch', } /** * @generated from enum yorkie.v1.DocEventType */ declare enum DocEventType_3 { /** * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_CHANGED = 0; */ DOCUMENT_CHANGED = 0, /** * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_WATCHED = 1; */ DOCUMENT_WATCHED = 1, /** * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_UNWATCHED = 2; */ DOCUMENT_UNWATCHED = 2, /** * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_BROADCAST = 3; */ DOCUMENT_BROADCAST = 3 } /** * `DocSize` represents the size of a document in bytes. */ declare type DocSize = { /** * `live` is the size of the document in bytes. */ live: DataSize; /** * `gc` is the size of the garbage collected data in bytes. */ gc: DataSize; }; /** * `DocStatus` represents the status of the document. */ export declare enum DocStatus { /** * Detached means that the document is not attached to the client. * The actor of the ticket is created without being assigned. */ Detached = "detached", /** * Attached means that this document is attached to the client. * The actor of the ticket is created with being assigned by the client. */ Attached = "attached", /** * Removed means that this document is removed. If the document is removed, * it cannot be edited. */ Removed = "removed" } /** * `DocStatus` represents the status of the document. */ declare enum DocStatus_2 { /** * Detached means that the document is not attached to the client. * The actor of the ticket is created without being assigned. */ Detached = 'detached', /** * Attached means that this document is attached to the client. * The actor of the ticket is created with being assigned by the client. */ Attached = 'attached', /** * Removed means that this document is removed. If the document is removed, * it cannot be edited. */ Removed = 'removed', } /** * `DocSyncStatus` represents the result of synchronizing the document with the server. */ export declare enum DocSyncStatus { /** * `Synced` means that document synced successfully. */ Synced = "synced", /** * `SyncFiled` means that document synchronization has failed. */ SyncFailed = "sync-failed" } /** * `DocSyncStatus` represents the result of synchronizing the document with the server. */ declare enum DocSyncStatus_2 { /** * `Synced` means that document synced successfully. */ Synced = 'synced', /** * `SyncFiled` means that document synchronization has failed. */ SyncFailed = 'sync-failed', } /** * `Document` is a CRDT-based data type. We can represent the model * of the application and edit it even while offline. * It implements Attachable interface to be managed by Attachment. */ declare class Document_2 implements Attachable { private key; private status; private opts; private maxSizeLimit; private schemaRules; private changeID; private checkpoint; private localChanges; private root; private presences; private clone?; private internalHistory; private isUpdating; private onlineClients; private eventStream; private eventStreamObserver; private disableGC; private disablePresence; private presenceDropWarned; /** * `history` is exposed to the user to manage undo/redo operations. */ history: { canUndo: () => boolean; canRedo: () => boolean; undo: () => void; redo: () => void; }; constructor(key: string, opts?: DocumentOptions); /** * `update` executes the given updater to update this document. */ update(updater: (root: JSONObject, presence: Presence

) => void, message?: string): void; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the document is changed. */ subscribe(next: DocEventCallbackMap

['default'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the clients watching the document * establishe or update its presence. */ subscribe(type: 'presence', next: DocEventCallbackMap

['presence'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the current client establishes or updates its presence. */ subscribe(type: 'my-presence', next: DocEventCallbackMap

['my-presence'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the client establishes or terminates a connection, * or updates its presence. */ subscribe(type: 'others', next: DocEventCallbackMap

['others'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the stream connection status changes. */ subscribe(type: 'connection', next: DocEventCallbackMap

['connection'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the document status changes. */ subscribe(type: 'status', next: DocEventCallbackMap

['status'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the document is synced with the server. */ subscribe(type: 'sync', next: DocEventCallbackMap

['sync'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the targetPath or any of its nested values change. */ subscribe, TOpInfo extends OpInfoOf>(targetPath: TPath, next: NextFn | RemoteChangeEvent>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when the authentification error occurs. */ subscribe(type: 'auth-error', next: DocEventCallbackMap

['auth-error'], error?: ErrorFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. * The callback will be called when an epoch mismatch error occurs. */ subscribe(type: 'epoch-mismatch', next: DocEventCallbackMap

['epoch-mismatch'], error?: ErrorFn): Unsubscribe; /** * `subscribe` registers a callback to subscribe to events on the document. */ subscribe(type: 'all', next: DocEventCallbackMap

['all'], error?: ErrorFn, complete?: CompleteFn): Unsubscribe; /** * `publish` triggers an event in this document, which can be received by * callback functions from document.subscribe(). */ publish(events: DocEvents

): void; /** * `applyChangePack` applies the given change pack into this document. * 1. Remove local changes applied to server. * 2. Update the checkpoint. * 3. Do Garbage collection. */ applyChangePack(pack: ChangePack

): void; /** * `getCheckpoint` returns the checkpoint of this document. */ getCheckpoint(): Checkpoint; /** * `getChangeID` returns the change id of this document. */ getChangeID(): ChangeID; /** * `hasLocalChanges` returns whether this document has local changes or not. */ hasLocalChanges(): boolean; /** * `ensureClone` make a clone of root. */ ensureClone(): void; /** * `createChangePack` create change pack of the local changes to send to the * remote server. */ createChangePack(): ChangePack

; /** * `setActor` sets actor into this document. This is also applied in the local * changes the document has. */ setActor(actorID: ActorID): void; /** * `setDisableGC` records whether this document participates in GC. The * client calls this on attach so subsequent applyChange runs use the * lamport-only sync path. */ setDisableGC(disableGC: boolean): void; /** * `setDisablePresence` records the server-fixated presence-disabled state * of this document. The client calls this on attach (before * `applyChangePack`) so any subsequent `Document.update` invocation sees * the gating state already settled. Flipping the flag at runtime is * supported: the next `update` honours the new value. */ setDisablePresence(disablePresence: boolean): void; /** * `isPresenceDisabled` returns the current presence-disabled state of * this document. Reflects the server-fixated value once attached; * before attach it reflects the local construction option. */ isPresenceDisabled(): boolean; /** * `isEnableDevtools` returns whether devtools is enabled or not. */ isEnableDevtools(): boolean; /** * `getKey` returns the key of this document. */ getKey(): string; /** * `getStatus` returns the status of this document. */ getStatus(): DocStatus; /** * `getClone` returns this clone. */ getClone(): { root: CRDTRoot; presences: Map; } | undefined; /** * `getCloneRoot` returns clone object. */ getCloneRoot(): CRDTObject | undefined; /** * `getRoot` returns a new proxy of cloned root. */ getRoot(): JSONObject; /** * `getDocSize` returns the size of this document. */ getDocSize(): DocSize; /** * `getMaxSizePerDocument` gets the maximum size of this document. */ getMaxSizePerDocument(): number; /** * `setMaxSizePerDocument` sets the maximum size of this document. */ setMaxSizePerDocument(size: number): void; /** * `getSchemaRules` gets the schema rules of this document. */ getSchemaRules(): Rule[]; /** * `setSchemaRules` sets the schema rules of this document. */ setSchemaRules(rules: Array): void; /** * `garbageCollect` purges elements that were removed before the given time. */ garbageCollect(minSyncedVersionVector: VersionVector): number; /** * `getRootObject` returns root object. */ getRootObject(): CRDTObject; /** * `getGarbageLen` returns the length of elements should be purged. */ getGarbageLen(): number; /** * `getRootCRDT` returns the CRDTRoot for testing purposes. * This method is intended for internal testing only. */ getRootCRDT(): CRDTRoot; /** * `getGarbageLenFromClone` returns the length of elements should be purged from clone. */ getGarbageLenFromClone(): number; /** * `toJSON` returns the JSON encoding of this document. */ toJSON(): string; /** * `toSortedJSON` returns the sorted JSON encoding of this document. */ toSortedJSON(): string; /** * `getStats` returns the statistics of this document. */ getStats(): RootStats; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `applySnapshot` applies the given snapshot into this document. */ applySnapshot(serverSeq: bigint, snapshotVector: VersionVector, snapshot?: Uint8Array, clientSeq?: number): void; /** * `clearHistory` flushes both undo and redo stacks. This is used * after applying a snapshot or initialRoot so that setup operations * are not reachable via undo. */ clearHistory(): void; /** * `applyChanges` applies the given changes into this document. */ applyChanges(changes: Array>, source: OpSource): void; /** * `applyChange` applies the given change into this document. */ applyChange(change: Change

, source: OpSource): void; /** * `applyWatchInit` applies the watch initialization with the given client IDs. */ applyWatchInit(clientIDs: Array): void; /** * `applyDocEvent` applies the given doc event into this document. */ applyDocEvent(type: DocEventType_3, publisher: string): void; /** * `applyStatus` applies the document status into this document. */ applyStatus(status: DocStatus): void; /** * `applyDocEventsForReplay` applies the given events into this document. */ applyDocEventsForReplay(events: Array>): void; /** * `getValueByPath` returns the JSONElement corresponding to the given path. */ getValueByPath(path: string): JSONElement | undefined; /** * `setOnlineClients` sets the given online client set. */ setOnlineClients(onlineClients: Set): void; /** * `resetOnlineClients` resets the online client set. */ resetOnlineClients(): void; /** * `addOnlineClient` adds the given clientID into the online client set. */ addOnlineClient(clientID: ActorID): void; /** * `removeOnlineClient` removes the clientID from the online client set. */ removeOnlineClient(clientID: ActorID): void; /** * `reconcilePresence` compares the previous and current state of a client's * presence/online status and returns the appropriate event to emit. * * For remote clients, "online" means the client is in onlineClients. * For self, "online" means the document status is Attached. * * State transition table: * (!hadP || !wasOn) → (hasP && isOn) : watched (remote) or presence-changed (self) * (hadP && wasOn) → (hasP && isOn) : presence-changed * (hadP && wasOn) → (!hasP || !isOn): unwatched (remote only) * otherwise : no event (waiting) */ private reconcilePresence; /** * `hasPresence` returns whether the given clientID has a presence or not. */ hasPresence(clientID: ActorID): boolean; /** * `getMyPresence` returns the presence of the current client. */ getMyPresence(): P; /** * `getOthersPresences` returns the presences of all other clients. */ getOthersPresences(): Array<{ clientID: ActorID; presence: P; }>; /** * `getPresence` returns the presence of the given clientID. */ getPresence(clientID: ActorID): P | undefined; /** * `getPresences` returns the presences of online clients. */ getPresences(): Array<{ clientID: ActorID; presence: P; }>; /** * `getPresenceForTest` returns the presence of the given clientID * regardless of whether the client is online or not. */ getPresenceForTest(clientID: ActorID): P | undefined; /** * `getSelfForTest` returns the client that has attached this document. */ getSelfForTest(): { clientID: string; presence: P; }; /** * `getOthersForTest` returns all the other clients in online, sorted by clientID. */ getOthersForTest(): { clientID: ActorID; presence: P; }[]; /** * `getUndoStackForTest` returns the undo stack for test. */ getUndoStackForTest(): Array>>; /** * `getRedoStackForTest` returns the redo stack for test. */ getRedoStackForTest(): Array>>; /** * `getVersionVector` returns the version vector of document */ getVersionVector(): VersionVector; private isSameElementOrChildOf; /** * `removePushedLocalChanges` removes local changes that have been applied to * the server from the local changes. * * @param clientSeq - client sequence number to remove local changes before it */ private removePushedLocalChanges; /** * `executeUndoRedo` executes undo or redo operation with shared logic. */ private executeUndoRedo; } export { Document_2 as Document } /** * `DocumentOptions` are the options to create a new document. */ declare interface DocumentOptions { /** * `disableGC` disables garbage collection if true. */ disableGC?: boolean; /** * `disablePresence` declares that this document does not use presence. * When true, `Document.update`'s `presence.set` calls are silently * dropped and the server strips any presence that nonetheless reaches * it. The option is server-fixated on first attach — once a document * is created presenceless, subsequent attaches observe `true` from the * attach response regardless of the local option value. Use for * counter-only or other presence-free workloads where the per-client * presence map would otherwise leak memory in long-lived documents. */ disablePresence?: boolean; /** * `enableDevtools` enables devtools if true. */ enableDevtools?: boolean; } /** * `EditOpInfo` represents the information of the edit operation. */ export declare type EditOpInfo = { type: 'edit'; path: string; from: number; to: number; value: { attributes: Indexable; content: string; }; }; /** * `EditOpInfo` represents the information of the edit operation. */ declare type EditOpInfo_2 = { type: 'edit'; path: string; from: number; to: number; value: { attributes: Indexable_2; content: string; }; }; /** * `ElementNode` represents an element node. It has an attributes and children. */ export declare type ElementNode = { type: TreeNodeType_2; attributes?: A; children: Array; }; /** * `ElementNode` represents an element node. It has an attributes and children. */ declare type ElementNode_2 = { type: TreeNodeType; attributes?: A; children: Array; }; /** * ElementRHT is a hashtable with logical clock(Replicated hashtable) * */ declare class ElementRHT { private nodeMapByKey; private nodeMapByCreatedAt; constructor(); /** * `create` creates an instance of ElementRHT. */ static create(): ElementRHT; /** * `set` sets the value of the given key. */ set(key: string, value: CRDTElement, executedAt: TimeTicket): CRDTElement | undefined; /** * `delete` deletes the Element of the given key. */ delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement; /** * `subPathOf` returns the sub path of the given element. */ subPathOf(createdAt: TimeTicket): string | undefined; /** * `purge` physically purge child element. */ purge(element: CRDTElement): void; /** * `deleteByKey` deletes the Element of the given key and removed time. */ deleteByKey(key: string, removedAt: TimeTicket): CRDTElement | undefined; /** * `has` returns whether the element exists of the given key or not. */ has(key: string): boolean; /** * `getByID` returns the node of the given createdAt. */ getByID(createdAt: TimeTicket): ElementRHTNode | undefined; /** * `get` returns the node of the given key. */ get(key: string): ElementRHTNode | undefined; /** * `deepcopy` creates a deep copy of this ElementRHT. */ deepcopy(): ElementRHT; [Symbol.iterator](): IterableIterator; } /** * `ElementRHTNode` is a node of ElementRHT. */ declare class ElementRHTNode { private strKey; private value; constructor(strKey: string, value: CRDTElement); /** * `of` creates a instance of ElementRHTNode. */ static of(strKey: string, value: CRDTElement): ElementRHTNode; /** * `isRemoved` checks whether this value was removed. */ isRemoved(): boolean; /** * `getStrKey` returns the key of this node. */ getStrKey(): string; /** * `getValue` return the value(element) of this node */ getValue(): CRDTElement; /** * `remove` removes a value base on removing time. */ remove(removedAt: TimeTicket): boolean; } declare interface Entry { key: K; value: V; } export declare interface EpochMismatchEvent extends BaseDocEvent_2 { type: DocEventType.EpochMismatch; value: { method: 'PushPull'; }; } declare interface EpochMismatchEvent_2 extends BaseDocEvent { type: DocEventType_2.EpochMismatch; value: { method: 'PushPull'; }; } export declare type ErrorFn = (error: Error) => void; /** * `EventSourceDevPanel` is the name of the source representing messages * from the Devtools panel. */ export declare const EventSourceDevPanel = "yorkie-devtools-panel"; /** * `EventSourceSDK` is the name of the source representing messages * from the SDK. */ export declare const EventSourceSDK = "yorkie-devtools-sdk"; /** * `ExecutionResult` represents the result of operation execution. */ declare type ExecutionResult = { opInfos: Array; reverseOp?: Operation; }; declare type Executor = (observer: Observer) => void; /** * `fromChangePack` converts the given Protobuf format to model format. */ declare function fromChangePack

(pbPack: ChangePack_2): ChangePack

; /** * `fromChanges` converts the given Protobuf format to model format. */ declare function fromChanges

(pbChanges: Array): Array>; /** * `fromPresence` converts the given Protobuf format to model format. */ declare function fromPresence

(pbPresence: Presence_2): P; /** * `fromSchemaRules` converts the given Protobuf format to model format. */ declare function fromSchemaRules(pbRules: Array): Array; /** * `fromTreeNodes` converts the given Protobuf format to model format. */ declare function fromTreeNodes(pbTreeNodes: Array): CRDTTreeNode | undefined; export declare type FullPanelToSDKMessage = PanelToSDKMessage & { source: 'yorkie-devtools-panel'; }; export declare type FullSDKToPanelMessage = SDKToPanelMessage & { source: 'yorkie-devtools-sdk'; }; /** * `GCChild` is an interface for the child of the garbage collection target. */ declare interface GCChild { toIDString(): string; getRemovedAt(): TimeTicket | undefined; getDataSize(): DataSize; } /** * `GCPair` is a structure that represents a pair of parent and child for garbage * collection. */ declare type GCPair = { parent: GCParent; child: GCChild; }; /** * `GCParent` is an interface for the parent of the garbage collection target. */ declare interface GCParent { purge(node: GCChild): void; } /** * `hexToBytes` converts the given hex string to byte array. */ declare function hexToBytes(hex: string): Uint8Array; /** * `hexToVersionVector` creates a VersionVector from the given bytes. */ declare function hexToVersionVector(hex: string): VersionVector; /** * `HistoryOperation` is a type of history operation. */ declare type HistoryOperation

= Operation | { type: 'presence'; value: Partial

; }; /** * `IncreaseOpInfo` represents the information of the increase operation. */ export declare type IncreaseOpInfo = { type: 'increase'; path: string; value: number; }; /** * `IncreaseOpInfo` represents the information of the increase operation. */ declare type IncreaseOpInfo_2 = { type: 'increase'; path: string; value: number; }; /** * `Indexable` represents an object with string keys and Json values. It is * used to various places such as the presence or attributes of text elements * and etc. */ export declare type Indexable = Record; /** * `Indexable` represents an object with string keys and Json values. It is * used to various places such as the presence or attributes of text elements * and etc. */ declare type Indexable_2 = Record; /** * `IndexTree` is a tree structure for linear indexing. */ declare class IndexTree> { private root; constructor(root: T); /** * `tokensBetween` returns the tokens between the given range. * If includeRemoved is true, it includes removed nodes in the calculation. */ tokensBetween(from: number, to: number, callback: (token: TreeToken, ended: boolean) => void, includeRemoved?: boolean): void; /** * `traverse` traverses the tree with postorder traversal. */ traverse(callback: (node: T) => void): void; /** * `traverseAll` traverses the whole tree (include tombstones) with postorder traversal. */ traverseAll(callback: (node: T) => void): void; /** * findTreePos finds the position of the given index in the tree. */ findTreePos(index: number, preferText?: boolean): TreePos; /** * `treePosToPath` returns path from given treePos */ treePosToPath(treePos: TreePos): number[]; /** * `pathToIndex` returns index from given path */ pathToIndex(path: Array): number; /** * `pathToTreePos` returns treePos from given path */ pathToTreePos(path: Array): TreePos; /** * `getRoot` returns the root node of the tree. */ getRoot(): T; /** * `getSize` returns the size of the tree. */ get size(): number; /** * `findPostorderRight` finds right node of the given tree position with * postorder traversal. */ findPostorderRight(treePos: TreePos): T | undefined; /** * `indexOf` returns the index of the given tree position. * If includeRemoved is true, it includes removed nodes in the calculation. */ indexOf(pos: TreePos, includeRemoved?: boolean): number; /** * `indexToPath` returns the path of the given index. */ indexToPath(index: number): Array; } /** * `IndexTreeNode` is the node of IndexTree. It is used to represent the * document of text-based editors. */ declare abstract class IndexTreeNode> { type: TreeNodeType_2; parent?: T; _children: Array; visibleSize: number; totalSize: number; constructor(type: TreeNodeType_2, children?: Array); /** * `updateAncestorsSize` updates the size of the ancestors. * It is used when the size of the node is changed. * If includeRemoved is true, it updates ancestors totalSize including removed nodes. */ updateAncestorsSize(delta: number, includeRemoved?: boolean): void; /** * `UpdateDescendantsSize` updates the size of the descendants. It is used when * the tree is newly created and the size of the descendants is not calculated. * If includeRemoved is true, it includes removed nodes in the calculation. */ updateDescendantsSize(includeRemoved?: boolean): number; /** * `isText` returns true if the node is a text node. */ get isText(): boolean; /** * `paddedSize` returns the length of the node including padding. * If includeRemoved is true, it includes removed nodes in the calculation. */ paddedSize(includeRemoved?: boolean): number; /** * `isAncenstorOf` returns true if the node is an ancestor of the given node. */ isAncestorOf(node: T): boolean; /** * `nextSibling` returns the next sibling of the node. */ get nextSibling(): T | undefined; /** * `prevSibling` returns the previous sibling of the node. */ get prevSibling(): T | undefined; /** * `isRemoved` returns true if the node is removed. */ abstract get isRemoved(): boolean; /** * `cloneText` clones the text node with the given id and value. */ abstract cloneText(offset: number): T; /** * `cloneElement` clones the element node with the given issueTimeTicket * function and value. */ abstract cloneElement(issueTimeTicket: () => TimeTicket): T; /** * `value` returns the value of the node. */ abstract get value(): string; /** * `value` sets the value of the node. */ abstract set value(v: string); /** * `getDataSize` returns the size of the node. */ abstract getDataSize(): DataSize; /** * `splitText` splits the given node at the given offset. */ splitText(offset: number, absOffset: number): [T | undefined, DataSize]; /** * `children` returns the children of the node. */ get children(): Array; /** * `allChildren` returns all the children of the node including tombstone nodes. * It returns the shallow copy of the children. */ get allChildren(): Array; /** * `hasTextChild` returns true if the node's children consist of only text children. */ hasTextChild(): boolean; /** * `getChildrenText` returns text value of all text type children. */ getChildrenText(): string; /** * `append` appends the given nodes to the children. */ append(...newNode: Array): void; /** * `prepend` prepends the given nodes to the children. It is only used * for creating a new node from snapshot. */ prepend(...newNode: Array): void; /** * `insertBefore` inserts the given node before the given child. */ insertBefore(newNode: T, referenceNode: T): void; /** * `insertAfter` inserts the given node after the given child. */ insertAfter(newNode: T, referenceNode: T): void; /** * `insertAt` inserts the given node at the given offset. */ insertAt(newNode: T, offset: number): void; /** * `removeChild` removes the given child. * In this method, the child is physically removed from the tree. */ removeChild(child: T): void; /** * `detachChild` removes the given child from this node's children list * and updates both visibleSize and totalSize. Unlike `removeChild` which * is used for GC purge of tombstoned nodes, `detachChild` is used for * moving alive nodes between parents. */ detachChild(child: T): void; /** * `splitElement` splits the given element at the given offset. */ splitElement(offset: number, issueTimeTicket: () => TimeTicket, versionVector?: VersionVector): [T | undefined, DataSize]; /** * `insertAfterInternal` inserts the given node after the given child. * This method does not update the size of the ancestors. */ insertAfterInternal(newNode: T, referenceNode: T): void; /** * `insertAtInternal` inserts the given node at the given index. * This method does not update the size of the ancestors. */ insertAtInternal(newNode: T, offset: number): void; /** * findOffset returns the offset of the given node in the children. * If includeRemoved is true, it includes removed nodes in the calculation. */ findOffset(node: T, includeRemoved?: boolean): number; /** * `findBranchOffset` returns offset of the given descendant node in this node. * If the given node is not a descendant of this node, it returns -1. */ findBranchOffset(node: T): number; } export declare interface InitializedEvent

extends BaseDocEvent_2 { type: DocEventType.Initialized; source: OpSource.Local; value: Array<{ clientID: ActorID; presence: P; }>; } declare interface InitializedEvent_2

extends BaseDocEvent { type: DocEventType_2.Initialized; source: OpSource_2.Local; value: Array<{ clientID: ActorID_2; presence: P }>; } /** * `isBinData` checks if a value is a YSONBinData object. */ declare function isBinData(value: any): value is YSONBinData { return ( typeof value === 'object' && value !== null && value.type === 'BinData' && typeof value.value === 'string' ); } /** * `isCounter` checks if a value is a YSONCounter object. */ declare function isCounter(value: any): value is YSONCounter { return ( typeof value === 'object' && value !== null && value.type === 'Counter' && typeof value.value === 'object' ); } /** * `isDate` checks if a value is a YSONDate object. */ declare function isDate(value: any): value is YSONDate { return ( typeof value === 'object' && value !== null && value.type === 'Date' && typeof value.value === 'string' ); } /** * `isDedupCounter` checks if a value is a YSONDedupCounter object. */ declare function isDedupCounter(value: any): value is YSONDedupCounter { return ( typeof value === 'object' && value !== null && value.type === 'DedupCounter' && typeof value.value === 'object' && typeof value.registers === 'string' ); } /** * `isDocEventForReplay` checks if an event can be used to replay a document. */ declare function isDocEventForReplay( event: DocEvent_2, ): event is DocEventForReplay { const types = [ DocEventType.StatusChanged, DocEventType.Snapshot, DocEventType.LocalChange, DocEventType.RemoteChange, DocEventType.Initialized, DocEventType.Watched, DocEventType.Unwatched, DocEventType.PresenceChanged, ]; return types.includes(event.type); } /** * `isDocEventsForReplay` checks if a list of events can be used to replay a document. */ declare function isDocEventsForReplay( events: Array, ): events is DocEventsForReplay { return events.every(isDocEventForReplay); } /** * `isInt` checks if a value is a YSONInt object. */ declare function isInt(value: any): value is YSONInt { return ( typeof value === 'object' && value !== null && value.type === 'Int' && typeof value.value === 'number' ); } /** * `isLong` checks if a value is a YSONLong object. */ declare function isLong(value: any): value is YSONLong { return ( typeof value === 'object' && value !== null && value.type === 'Long' && typeof value.value === 'number' ); } /** * `isObject` checks if a value is a plain YSON object (not a special type). */ declare function isObject(value: any): value is { [key: string]: YSONValue } { return ( typeof value === 'object' && value !== null && !Array.isArray(value) && !isText(value) && !isTree(value) && !isInt(value) && !isLong(value) && !isDate(value) && !isBinData(value) && !isCounter(value) && !isDedupCounter(value) ); } /** * `isText` checks if a value is a YSONText object. */ declare function isText(value: any): value is YSONText { return ( typeof value === 'object' && value !== null && value.type === 'Text' && Array.isArray(value.nodes) ); } /** * `isTree` checks if a value is a YSONTree object. */ declare function isTree(value: any): value is YSONTree { return ( typeof value === 'object' && value !== null && value.type === 'Tree' && typeof value.root === 'object' ); } /** * `Json` represents the JSON data type. It is used to represent the data * structure of the document. */ export declare type Json = JsonPrimitive | JsonArray | JsonObject; /** * `Json` represents the JSON data type. It is used to represent the data * structure of the document. */ declare type Json_2 = JsonPrimitive_2 | JsonArray_2 | JsonObject_2; /** * `JSONArray` represents JSON array, but unlike regular JSON, it has time * tickets created by a logical clock to resolve conflicts. */ export declare type JSONArray = { /** * `getID` returns the ID, `TimeTicket` of this Object. */ getID(): TimeTicket; /** * `getElementByID` returns the element for the given ID. */ getElementByID(createdAt: TimeTicket): WrappedElement; /** * `getElementByIndex` returns the element for the given index. */ getElementByIndex(index: number): WrappedElement; /** * `getLast` returns the last element of this array. */ getLast(): WrappedElement; /** * `setValue` sets the given value at the given index. */ setValue(index: number, value: unknown): WrappedElement; /** * `delete` deletes the element of the given index. */ delete(index: number): WrappedElement; /** * `deleteByID` deletes the element of the given ID. */ deleteByID(createdAt: TimeTicket): WrappedElement; /** * `insertBefore` inserts a value before the given next element. */ insertBefore(nextID: TimeTicket, value: any): WrappedElement; /** * `insertAfter` inserts a value after the given previous element. */ insertAfter(prevID: TimeTicket, value: any): WrappedElement; /** * `insertIntegerAfter` inserts a value after the given index. */ insertIntegerAfter(index: number, value: number): WrappedElement; /** * `moveBefore` moves the element before the given next element. */ moveBefore(nextID: TimeTicket, id: TimeTicket): void; /** * `moveAfter` moves the element after the given previous element. */ moveAfter(prevID: TimeTicket, id: TimeTicket): void; /** * `moveAfterByIndex` moves the element after the given index. */ moveAfterByIndex(prevIndex: number, targetIndex: number): void; /** * `moveFront` moves the element before the first element. */ moveFront(id: TimeTicket): void; /** * `moveLast` moves the element after the last element. */ moveLast(id: TimeTicket): void; /** * `elements` returns an iterator of wrapped elements including CRDT metadata. */ elements(): IterableIterator>; /** * `toTestString` returns a String containing the meta data of the node * for debugging purpose. */ toTestString(): string; /** * `toJSForTest` returns the JSON object of this array for debugging. */ toJSForTest(): Devtools.JSONElement; } & Array; declare type JsonArray = Array; declare type JsonArray_2 = Array; /** * `JSONElement` is a wrapper for `CRDTElement` that provides users with an * easy-to-use interface for manipulating `Document`s. */ export declare type JSONElement = PrimitiveValue | JSONObject | JSONArray | Text_2 | Counter | DedupCounter | Tree; /** * `JSONElement` represents the result of `Element.toJSForTest()`. */ declare type JSONElement_2 = { type: JSONElementType; key?: string; value: JSONElementValue; createdAt: string; }; /** * @generated from message yorkie.v1.JSONElementSimple */ declare type JSONElementSimple = Message<"yorkie.v1.JSONElementSimple"> & { /** * @generated from field: yorkie.v1.TimeTicket created_at = 1; */ createdAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket moved_at = 2; */ movedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket removed_at = 3; */ removedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.ValueType type = 4; */ type: ValueType; /** * @generated from field: bytes value = 5; */ value: Uint8Array; }; declare type JSONElementType = | 'YORKIE_PRIMITIVE' | 'YORKIE_COUNTER' | 'YORKIE_OBJECT' | 'YORKIE_ARRAY' | 'YORKIE_TEXT' | 'YORKIE_TREE'; /** * `ElementValue` represents the result of `Element.toJSForTest()`. * * NOTE(chacha912): Json type is used to represent the result of * `Text.toJSForTest()` and `Tree.toJSForTest()`. */ declare type JSONElementValue = | PrimitiveValue_2 | CounterValue_2 | ContainerValue // Array | Object | Json_2; /** * `JSONObject` represents a JSON object, but unlike regular JSON, it has time * tickets created by a logical clock to resolve conflicts. */ export declare type JSONObject = { /** * `getID` returns the ID(time ticket) of this Object. */ getID(): TimeTicket; /** * `toJSON` returns the JSON encoding of this object. */ toJSON(): string; /** * `toJS` returns the JSON object of this object. */ toJS(): T; /** * `toJSForTest` returns the JSON object of this object for debugging. */ toJSForTest(): Devtools.JSONElement; } & T; declare type JsonObject = { [key: string]: Json | undefined; }; declare type JsonObject_2 = { [key: string]: Json_2 | undefined }; declare type JsonPrimitive = string | number | boolean | null; declare type JsonPrimitive_2 = string | number | boolean | null; /** * `Key` is a string representing the key of Document or Channel. */ declare type Key = string; declare type LeafElement = PrimitiveValue | Primitive | Text_2 | Counter | Tree; /** * `LLRBNode` is node of LLRBTree. */ declare class LLRBNode { key: K; value: V; left?: LLRBNode; right?: LLRBNode; isRed: boolean; constructor(key: K, value: V, isRed: boolean); } /** * LLRBTree is an implementation of Left-learning Red-Black Tree. * * Original paper on Left-leaning Red-Black Trees: * @see http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf * * Invariant 1: No red node has a red child * Invariant 2: Every leaf path has the same number of black nodes * Invariant 3: Only the left child can be red (left leaning) */ declare class LLRBTree { private root?; private comparator; private counter; constructor(comparator?: Comparator); /** * `put` puts the value of the given key. */ put(key: K, value: V): V; /** * `get` gets a value of the given key. */ get(key: K): V | undefined; /** * `remove` removes a element of key. */ remove(key: K): void; /** * `getIterator` returns a new instance of SortedMapIterator. */ getIterator(): SortedMapIterator; /** * `values` returns value array of LLRBTree. */ values(): Array; /** * `floorEntry` returns the entry for the greatest key less than or equal to the * given key. If there is no such key, returns `undefined`. */ floorEntry(key: K): Entry | undefined; /** * `lastEntry` returns last entry of LLRBTree. */ lastEntry(): Entry | undefined; /** * `size` is a size of LLRBTree. */ size(): number; /** * `isEmpty` checks if size is empty. */ isEmpty(): boolean; private getInternal; private putInternal; private removeInternal; private min; private removeMin; private fixUp; private moveRedLeft; private moveRedRight; private isRed; private rotateLeft; private rotateRight; private flipColors; } declare interface LocalBroadcastEvent { type: ChannelEventType.LocalBroadcast; clientID: ActorID; topic: string; payload: Json; options?: BroadcastOptions; } /** * `LocalChangeEvent` is an event that occurs when the document is changed * by local changes. */ export declare interface LocalChangeEvent extends BaseDocEvent_2 { type: DocEventType.LocalChange; source: OpSource.Local | OpSource.UndoRedo; value: ChangeInfo; rawChange?: ChangeStruct_2

; } /** * `LocalChangeEvent` is an event that occurs when the document is changed * by local changes. */ declare interface LocalChangeEvent_2< T = OpInfo_2, P extends Indexable_2 = Indexable_2, > extends BaseDocEvent { type: DocEventType_2.LocalChange; source: OpSource_2.Local | OpSource_2.UndoRedo; value: ChangeInfo_2; rawChange?: ChangeStruct

; } export declare enum LogLevel { Trivial = 0, Debug = 1, Info = 2, Warn = 3, Error = 4, Fatal = 5 } /** * `MoveOpInfo` represents the information of the move operation. */ export declare type MoveOpInfo = { type: 'move'; path: string; previousIndex: number; index: number; }; /** * `MoveOpInfo` represents the information of the move operation. */ declare type MoveOpInfo_2 = { type: 'move'; path: string; previousIndex: number; index: number; }; export declare type NextFn = (value: T) => void; /** * @generated from message yorkie.v1.NodeAttr */ declare type NodeAttr = Message<"yorkie.v1.NodeAttr"> & { /** * @generated from field: string value = 1; */ value: string; /** * @generated from field: yorkie.v1.TimeTicket updated_at = 2; */ updatedAt?: TimeTicket_2; /** * @generated from field: bool is_removed = 3; */ isRemoved: boolean; }; /** * `ObjectOpInfo` represents the OperationInfo for the JSONObject. */ export declare type ObjectOpInfo = SetOpInfo | RemoveOpInfo; /** * `ObjectOpInfo` represents the OperationInfo for the JSONObject. */ declare type ObjectOpInfo_2 = SetOpInfo_2 | RemoveOpInfo_2; /** * `objectToBytes` converts the given JSONObject to byte array. */ declare function objectToBytes(obj: CRDTObject): Uint8Array; export declare interface Observable { subscribe: SubscribeFn; getProxy?: () => ObserverProxy; } /** * Observable interface for subscribing to presence events. */ declare interface Observable_2 { subscribe(observer: (event: T) => void): Unsubscribe; } export declare interface Observer { next: NextFn; error?: ErrorFn; complete?: CompleteFn; } /** * `ObserverProxy` is proxy of `Observer`. */ declare class ObserverProxy implements Observer { finalized: boolean; private observers; private finalError?; constructor(executor: Executor); /** * `next` iterates next observer synchronously. */ next(value: T): void; /** * `error` invoke error. */ error(error: Error): void; /** * `complete` completes observer. */ complete(): void; /** * `subscribe` is a function for subscribing observer. */ subscribe(nextOrObserver: Observer | NextFn, error?: ErrorFn, complete?: CompleteFn): Unsubscribe; private unsubscribeOne; private forEachObserver; private sendOne; private close; } /** * `Operation` represents an operation to be executed on a document. */ declare abstract class Operation { private parentCreatedAt; private executedAt?; constructor(parentCreatedAt: TimeTicket, executedAt?: TimeTicket); /** * `getParentCreatedAt` returns the creation time of the target element to * execute the operation. */ getParentCreatedAt(): TimeTicket; /** * `getExecutedAt` returns execution time of this operation. */ getExecutedAt(): TimeTicket; /** * `setActor` sets the given actor to this operation. */ setActor(actorID: ActorID): void; /** * `setExecutedAt` sets the executedAt. */ setExecutedAt(executedAt: TimeTicket): void; /** * `getEffectedCreatedAt` returns the creation time of the effected element. */ abstract getEffectedCreatedAt(): TimeTicket; /** * `toTestString` returns a string containing the meta data for debugging purpose. */ abstract toTestString(): string; /** * `execute` executes this operation on the given `CRDTRoot`. */ abstract execute(root: CRDTRoot, source: OpSource, versionVector?: VersionVector): ExecutionResult | undefined; } /** * @generated from message yorkie.v1.Operation */ declare type Operation_2 = Message<"yorkie.v1.Operation"> & { /** * @generated from oneof yorkie.v1.Operation.body */ body: { /** * @generated from field: yorkie.v1.Operation.Set set = 1; */ value: Operation_Set; case: "set"; } | { /** * @generated from field: yorkie.v1.Operation.Add add = 2; */ value: Operation_Add; case: "add"; } | { /** * @generated from field: yorkie.v1.Operation.Move move = 3; */ value: Operation_Move; case: "move"; } | { /** * @generated from field: yorkie.v1.Operation.Remove remove = 4; */ value: Operation_Remove; case: "remove"; } | { /** * @generated from field: yorkie.v1.Operation.Edit edit = 5; */ value: Operation_Edit; case: "edit"; } | { /** * @generated from field: yorkie.v1.Operation.Style style = 7; */ value: Operation_Style; case: "style"; } | { /** * @generated from field: yorkie.v1.Operation.Increase increase = 8; */ value: Operation_Increase; case: "increase"; } | { /** * @generated from field: yorkie.v1.Operation.TreeEdit tree_edit = 9; */ value: Operation_TreeEdit; case: "treeEdit"; } | { /** * @generated from field: yorkie.v1.Operation.TreeStyle tree_style = 10; */ value: Operation_TreeStyle; case: "treeStyle"; } | { /** * @generated from field: yorkie.v1.Operation.ArraySet array_set = 11; */ value: Operation_ArraySet; case: "arraySet"; } | { case: undefined; value?: undefined; }; }; /** * @generated from message yorkie.v1.Operation.Add */ declare type Operation_Add = Message<"yorkie.v1.Operation.Add"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2; */ prevCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.JSONElementSimple value = 3; */ value?: JSONElementSimple; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 4; */ executedAt?: TimeTicket_2; }; /** * @generated from message yorkie.v1.Operation.ArraySet */ declare type Operation_ArraySet = Message<"yorkie.v1.Operation.ArraySet"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket created_at = 2; */ createdAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.JSONElementSimple value = 3; */ value?: JSONElementSimple; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 4; */ executedAt?: TimeTicket_2; }; /** * @generated from message yorkie.v1.Operation.Edit */ declare type Operation_Edit = Message<"yorkie.v1.Operation.Edit"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TextNodePos from = 2; */ from?: TextNodePos; /** * @generated from field: yorkie.v1.TextNodePos to = 3; */ to?: TextNodePos; /** * deprecated * * @generated from field: map created_at_map_by_actor = 4; */ createdAtMapByActor: { [key: string]: TimeTicket_2; }; /** * @generated from field: string content = 5; */ content: string; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 6; */ executedAt?: TimeTicket_2; /** * @generated from field: map attributes = 7; */ attributes: { [key: string]: string; }; }; /** * @generated from message yorkie.v1.Operation.Increase */ declare type Operation_Increase = Message<"yorkie.v1.Operation.Increase"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.JSONElementSimple value = 2; */ value?: JSONElementSimple; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 3; */ executedAt?: TimeTicket_2; /** * @generated from field: string actor = 4; */ actor: string; }; /** * @generated from message yorkie.v1.Operation.Move */ declare type Operation_Move = Message<"yorkie.v1.Operation.Move"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2; */ prevCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket created_at = 3; */ createdAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 4; */ executedAt?: TimeTicket_2; }; /** * @generated from message yorkie.v1.Operation.Remove */ declare type Operation_Remove = Message<"yorkie.v1.Operation.Remove"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket created_at = 2; */ createdAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 3; */ executedAt?: TimeTicket_2; }; /** * @generated from message yorkie.v1.Operation.Set */ declare type Operation_Set = Message<"yorkie.v1.Operation.Set"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: string key = 2; */ key: string; /** * @generated from field: yorkie.v1.JSONElementSimple value = 3; */ value?: JSONElementSimple; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 4; */ executedAt?: TimeTicket_2; }; /** * @generated from message yorkie.v1.Operation.Style */ declare type Operation_Style = Message<"yorkie.v1.Operation.Style"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TextNodePos from = 2; */ from?: TextNodePos; /** * @generated from field: yorkie.v1.TextNodePos to = 3; */ to?: TextNodePos; /** * @generated from field: map attributes = 4; */ attributes: { [key: string]: string; }; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 5; */ executedAt?: TimeTicket_2; /** * deprecated * * @generated from field: map created_at_map_by_actor = 6; */ createdAtMapByActor: { [key: string]: TimeTicket_2; }; /** * @generated from field: repeated string attributes_to_remove = 7; */ attributesToRemove: string[]; }; /** * @generated from message yorkie.v1.Operation.TreeEdit */ declare type Operation_TreeEdit = Message<"yorkie.v1.Operation.TreeEdit"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TreePos from = 2; */ from?: TreePos_2; /** * @generated from field: yorkie.v1.TreePos to = 3; */ to?: TreePos_2; /** * deprecated * * @generated from field: map created_at_map_by_actor = 4; */ createdAtMapByActor: { [key: string]: TimeTicket_2; }; /** * @generated from field: repeated yorkie.v1.TreeNodes contents = 5; */ contents: TreeNodes[]; /** * @generated from field: int32 split_level = 7; */ splitLevel: number; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 6; */ executedAt?: TimeTicket_2; }; /** * @generated from message yorkie.v1.Operation.TreeStyle */ declare type Operation_TreeStyle = Message<"yorkie.v1.Operation.TreeStyle"> & { /** * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1; */ parentCreatedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TreePos from = 2; */ from?: TreePos_2; /** * @generated from field: yorkie.v1.TreePos to = 3; */ to?: TreePos_2; /** * @generated from field: map attributes = 4; */ attributes: { [key: string]: string; }; /** * @generated from field: yorkie.v1.TimeTicket executed_at = 5; */ executedAt?: TimeTicket_2; /** * @generated from field: repeated string attributes_to_remove = 6; */ attributesToRemove: string[]; /** * deprecated * * @generated from field: map created_at_map_by_actor = 7; */ createdAtMapByActor: { [key: string]: TimeTicket_2; }; }; /** * `OpInfo` represents the information of an operation. * It is used to inform to the user what kind of operation was executed. */ export declare type OpInfo = TextOpInfo | CounterOpInfo | ArrayOpInfo | ObjectOpInfo | TreeOpInfo; /** * `OpInfo` represents the information of an operation. * It is used to inform to the user what kind of operation was executed. */ declare type OpInfo_2 = | TextOpInfo_2 | CounterOpInfo_2 | ArrayOpInfo_2 | ObjectOpInfo_2 | TreeOpInfo_2; /** * `OpInfoOf` represents the type of the operation info of the given * path in the Document.subscribe. It is used to remove the `$.` prefix. */ declare type OpInfoOf = TKey extends `$.${infer TPath}` ? OpInfoOfInner : OpInfoOfInner; /** * `OpInfoOfElement` represents the type of the operation info of the given element. */ declare type OpInfoOfElement = TElem extends Text_2 ? TextOpInfo : TElem extends Counter ? CounterOpInfo : TElem extends Tree ? TreeOpInfo : TElem extends BaseArray ? ArrayOpInfo : TElem extends BaseObject ? ObjectOpInfo : OpInfo; /** * `OpInfoOfInner` represents the type of the operation info of the * given path in the Document.subscribe. */ declare type OpInfoOfInner = TDepth extends 0 ? OpInfoOfElement : TKeyOrPath extends `${infer TFirst}.${infer TRest}` ? TFirst extends keyof TElem ? OpInfoOfInner> : OpInfo : TKeyOrPath extends keyof TElem ? OpInfoOfElement : OpInfo; /** * `OpSource` represents the source of the operation. It is used to handle * corner cases in the operations created by undo/redo allow the removed * elements when executing them. */ export declare enum OpSource { Local = "local", Remote = "remote", UndoRedo = "undoredo" } /** * `OpSource` represents the source of the operation. It is used to handle * corner cases in the operations created by undo/redo allow the removed * elements when executing them. */ declare enum OpSource_2 { Local = 'local', Remote = 'remote', UndoRedo = 'undoredo', } /** * PanelToSDKMessage is a message sent from the Devtools panel to the SDK. */ export declare type PanelToSDKMessage = /** * Informs the SDK that the panel is available. */ { msg: 'devtools::connect'; } /** * Informs the SDK that the panel is not available. */ | { msg: 'devtools::disconnect'; } /** * Informs the SDK that the panel is interested in receiving the "event" for the document, * starting with the initial "full sync" event. */ | { msg: 'devtools::subscribe'; docKey: string; }; /** * `parse` parses a YSON string into a typed JavaScript object. * * YSON extends JSON to support Yorkie CRDT types: * - `Text([...])` for Text CRDT * - `Tree(...)` for Tree CRDT * - Standard JSON for primitives, objects, and arrays * * @param yson - YSON formatted string * @returns Parsed YSONValue * @throws YorkieError if parsing fails * * @example * ```typescript * const data = parse('{"content":Text([{"val":"Hi"}])}'); * // { content: { type: 'Text', nodes: [{ val: 'Hi' }] } } * * // With type parameter: * const data = parse<{ content: YSONText }>('{"content":Text([{"val":"Hi"}])}'); * // data.content is now typed as YSONText * ``` */ declare function parse(yson: string): T { try { // Preprocess YSON string to handle special types const processed = preprocessYSON(yson); // Parse as JSON const parsed = JSON.parse(processed); // Post-process to restore type information return postprocessValue(parsed) as T; } catch (err) { throw new YorkieError( Code.ErrInvalidArgument, `Failed to parse YSON: ${err instanceof Error ? err.message : String(err)}`, ); } } /** * `PathOf` represents the type of all possible paths in the Document.subscribe. */ declare type PathOf = PathOfInner; /** * `PathOfInner` represents the type of the path of the given element. */ declare type PathOfInner = Depth extends 0 ? Prefix : TElem extends Record ? { [TKey in keyof TElem]: TElem[TKey] extends LeafElement ? `${Prefix}${TKey & string}` : TElem[TKey] extends BaseArray ? `${Prefix}${TKey & string}` | `${Prefix}${TKey & string}.${number}` | PathOfInner> : `${Prefix}${TKey & string}` | PathOfInner>; }[keyof TElem] : Prefix extends `${infer TRest}.` ? TRest : Prefix; /** * `Presence` represents a proxy for the Presence to be manipulated from the outside. */ export declare class Presence

{ private context; private presence; constructor(changeContext: ChangeContext, presence: P); /** * `set` updates the presence based on the partial presence. */ set(presence: Partial

, option?: { addToHistory: boolean; }): void; /** * `get` returns the presence value of the given key. */ get(key: K): P[K]; /** * `clear` clears the presence. */ clear(): void; } /** * @generated from message yorkie.v1.Presence */ declare type Presence_2 = Message<"yorkie.v1.Presence"> & { /** * @generated from field: map data = 1; */ data: { [key: string]: string; }; }; /** * `PresenceChange` represents the change of presence. */ declare type PresenceChange

= { type: PresenceChangeType_2.Put; presence: P; } | { type: PresenceChangeType_2.Clear; }; /** * @generated from message yorkie.v1.PresenceChange */ declare type PresenceChange_2 = Message<"yorkie.v1.PresenceChange"> & { /** * @generated from field: yorkie.v1.PresenceChange.ChangeType type = 1; */ type: PresenceChange_ChangeType; /** * @generated from field: yorkie.v1.Presence presence = 2; */ presence?: Presence_2; }; /** * @generated from enum yorkie.v1.PresenceChange.ChangeType */ declare enum PresenceChange_ChangeType { /** * @generated from enum value: CHANGE_TYPE_UNSPECIFIED = 0; */ UNSPECIFIED = 0, /** * @generated from enum value: CHANGE_TYPE_PUT = 1; */ PUT = 1, /** * @generated from enum value: CHANGE_TYPE_DELETE = 2; */ DELETE = 2, /** * @generated from enum value: CHANGE_TYPE_CLEAR = 3; */ CLEAR = 3 } export declare interface PresenceChangedEvent

extends BaseDocEvent_2 { type: DocEventType.PresenceChanged; source: OpSource; value: { clientID: ActorID; presence: P; }; } declare interface PresenceChangedEvent_2< P extends Indexable_2, > extends BaseDocEvent { type: DocEventType_2.PresenceChanged; source: OpSource_2; value: { clientID: ActorID_2; presence: P }; } /** * `PresenceChangeType` represents the type of presence change. */ declare enum PresenceChangeType { Put = 'put', Clear = 'clear', } /** * `PresenceChangeType` represents the type of presence change. */ declare enum PresenceChangeType_2 { Put = "put", Clear = "clear" } /** * `PresenceEvent` is an event that occurs when the presence of a client changes. */ declare type PresenceEvent

= | InitializedEvent_2

| WatchedEvent_2

| UnwatchedEvent_2

| PresenceChangedEvent_2

; /** * `PresenceEvent` is an event that occurs when the presence of a client changes. */ declare type PresenceEvent_2

= InitializedEvent

| WatchedEvent

| UnwatchedEvent

| PresenceChangedEvent

; /** * `PresenceEvent` represents a presence change event. */ declare interface PresenceEvent_3 { /** * `type` is the type of the event. */ type: ChannelEventType.PresenceChanged | ChannelEventType.Initialized; /** * `count` is the current count value. */ count: number; } /** * `Primitive` represents primitive data type including logical clock. * It has a type and a value. */ export declare class Primitive extends CRDTElement { private valueType; private value; constructor(value: PrimitiveValue, createdAt: TimeTicket); /** * `of` creates a new instance of Primitive. */ static of(value: PrimitiveValue, createdAt: TimeTicket): Primitive; /** * `valueFromBytes` parses the given bytes into value. */ static valueFromBytes(primitiveType: PrimitiveType, bytes: Uint8Array): PrimitiveValue; /** * `getValueSize` returns the size of the value. The size is similar to * the size of primitives in JavaScript. */ private getValueSize; /** * `getDataSize` returns the data usage of this element. */ getDataSize(): DataSize; /** * `toJSON` returns the JSON encoding of the value. */ toJSON(): string; /** * `toSortedJSON` returns the sorted JSON encoding of the value. */ toSortedJSON(): string; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `deepcopy` copies itself deeply. */ deepcopy(): Primitive; /** * `getType` returns the type of the value. */ getType(): PrimitiveType; /** * `getPrimitiveType` returns the primitive type of the value. */ static getPrimitiveType(value: unknown): PrimitiveType | undefined; /** * `isSupport` check if the given value is supported type. */ static isSupport(value: unknown): boolean; /** * `isInteger` checks if the given number is integer. */ static isInteger(num: number): boolean; /** * `isNumericType` checks numeric type by JSONPrimitive */ isNumericType(): boolean; /** * `getValue` returns the value of Primitive. */ getValue(): PrimitiveValue; /** * `toBytes` creates an array representing the value. */ toBytes(): Uint8Array; } declare enum PrimitiveType { Null = 0, Boolean = 1, Integer = 2, Long = 3, Double = 4, String = 5, Bytes = 6, Date = 7 } /** * `PrimitiveValue` represents a value of primitive type. Only values of type * included in `PrimitiveValue` can be set to the document. */ export declare type PrimitiveValue = null | boolean | number | bigint | string | Uint8Array | Date; /** * `PrimitiveValue` represents a value of primitive type. Only values of type * included in `PrimitiveValue` can be set to the document. */ declare type PrimitiveValue_2 = // eslint-disable-next-line @typescript-eslint/no-restricted-types null | boolean | number | bigint | string | Uint8Array | Date; /** * `RemoteChangeEvent` is an event that occurs when the document is changed * by remote changes. */ export declare interface RemoteChangeEvent extends BaseDocEvent_2 { type: DocEventType.RemoteChange; source: OpSource.Remote; value: ChangeInfo; rawChange?: ChangeStruct_2

; } /** * `RemoteChangeEvent` is an event that occurs when the document is changed * by remote changes. */ declare interface RemoteChangeEvent_2< T = OpInfo_2, P extends Indexable_2 = Indexable_2, > extends BaseDocEvent { type: DocEventType_2.RemoteChange; source: OpSource_2.Remote; value: ChangeInfo_2; rawChange?: ChangeStruct

; } /** * `RemoveOpInfo` represents the information of the remove operation. */ export declare type RemoveOpInfo = { type: 'remove'; path: string; key?: string; index?: number; }; /** * `RemoveOpInfo` represents the information of the remove operation. */ declare type RemoveOpInfo_2 = { type: 'remove'; path: string; key?: string; index?: number; }; /** * `ResourceStatus` represents the common status interface for attachable resources. */ declare type ResourceStatus = 'detached' | 'attached' | 'removed'; /** * `RevisionSummary` represents a document revision for version management. * It stores a snapshot of document content at a specific point in time, * enabling features like rollback, audit, and version history tracking. */ export declare interface RevisionSummary { /** * `id` is the unique identifier of the revision. */ id: string; /** * `label` is a user-friendly name for this revision. */ label: string; /** * `description` is a detailed explanation of this revision. */ description: string; /** * `snapshot` is the serialized document content in YSON format at this revision point. * * Use `YSON.parse()` to convert this string to a typed JavaScript object: * * ```javascript * import { YSON } from 'yorkie-js-sdk'; * const snapshot = YSON.parse(revision.snapshot); * ``` */ snapshot: string; /** * `createdAt` is the time when this revision was created. */ createdAt: Date; } /** * @generated from message yorkie.v1.RevisionSummary */ declare type RevisionSummary_2 = Message<"yorkie.v1.RevisionSummary"> & { /** * @generated from field: string id = 1; */ id: string; /** * @generated from field: string label = 2; */ label: string; /** * @generated from field: string description = 3; */ description: string; /** * @generated from field: string snapshot = 4; */ snapshot: string; /** * @generated from field: google.protobuf.Timestamp created_at = 5; */ createdAt?: Timestamp; }; /** * `RGATreeSplit` is a block-based list with improved index-based lookup in RGA. * The difference from RGATreeList is that it has data on a block basis to * reduce the size of CRDT metadata. When an edit occurs on a block, * the block is split. * */ declare class RGATreeSplit implements GCParent { private head; private treeByIndex; private treeByID; constructor(); /** * `create` creates a instance RGATreeSplit. */ static create(): RGATreeSplit; /** * `edit` does following steps * 1. split nodes with from and to * 2. delete between from and to * 3. insert a new node * 4. add removed node * @param range - range of RGATreeSplitNode * @param editedAt - edited time * @param value - value * @returns `[RGATreeSplitPos, Array, DataSize, Array>, Array]` */ edit(range: RGATreeSplitPosRange, editedAt: TimeTicket, value?: T, versionVector?: VersionVector): [ RGATreeSplitPos, Array, DataSize, Array>, Array ]; /** * `indexToPos` finds RGATreeSplitPos of given offset. */ indexToPos(idx: number): RGATreeSplitPos; /** * `findIndexesFromRange` finds indexes based on range. */ findIndexesFromRange(range: RGATreeSplitPosRange): [number, number]; /** * `posToIndex` converts the given position to index. */ posToIndex(pos: RGATreeSplitPos, preferToLeft: boolean): number; /** * `findNode` finds node of given id. */ findNode(id: RGATreeSplitNodeID): RGATreeSplitNode; /** * `length` returns size of RGATreeSplit. */ get length(): number; /** * `getTreeByIndex` returns the tree by index for debugging purpose. */ getTreeByIndex(): SplayTree; /** * `getTreeByID` returns the tree by ID for debugging purpose. */ getTreeByID(): LLRBTree>; /** * `toString` returns the string encoding of this RGATreeSplit. */ toString(): string; [Symbol.iterator](): IterableIterator>; /** * `getHead` returns head of RGATreeSplitNode. */ getHead(): RGATreeSplitNode; /** * `deepcopy` copies itself deeply. */ deepcopy(): RGATreeSplit; /** * `normalizePos` converts a local position `(id, rel)` into a single * absolute offset measured from the head `(0:0)` of the physical chain. */ normalizePos(pos: RGATreeSplitPos): RGATreeSplitPos; /** * `refinePos` remaps the given pos to the current split chain. * * - Traverses the physical `next` chain (not `insNext`). * - Counts only live characters: removed nodes are treated as length 0. * - If the given offset exceeds the length of the current node, * it moves forward through `next` nodes, subtracting lengths, * until the offset fits in a live node. * - If it runs out of nodes, it snaps to the end of the last node. * * Example: * Before split: ["12345"](1:2:0), pos = (1:2:0, rel=5) * After split : ["1"](1:2:0) - ["23"](1:2:1) - ["45"](1:2:3) * refinePos(pos) -> (1:2:3, rel=2) * * Example: * ["12"](1:2:0, live) and pos = (1:2:0, rel=4) * refinePos(pos) -> points two chars after "12", * i.e. advances into following nodes, skipping removed ones. */ refinePos(pos: RGATreeSplitPos): RGATreeSplitPos; /** * `toTestString` returns a String containing the meta data of the node * for debugging purpose. */ toTestString(): string; /** * `insertAfter` inserts the given node after the given previous node. */ insertAfter(prevNode: RGATreeSplitNode, newNode: RGATreeSplitNode): RGATreeSplitNode; /** * `findNodeWithSplit` splits and return nodes of the given position. */ findNodeWithSplit(pos: RGATreeSplitPos, editedAt: TimeTicket): [RGATreeSplitNode, DataSize, RGATreeSplitNode]; private findFloorNodePreferToLeft; private findFloorNode; /** * `findBetween` returns nodes between fromNode and toNode. */ findBetween(fromNode: RGATreeSplitNode, toNode: RGATreeSplitNode): Array>; private splitNode; private deleteNodes; /** * `findEdgesOfCandidates` finds the edges outside `candidates`, * (which has not already been deleted, or be undefined but not yet implemented) * right edge is undefined means `candidates` contains the end of text. */ private findEdgesOfCandidates; private makeChanges; /** * `deleteIndexNodes` clears the index nodes of the given deletion boundaries. * The boundaries mean the nodes that will not be deleted in the range. */ private deleteIndexNodes; /** * `purge` physically purges the given node from RGATreeSplit. */ purge(node: RGATreeSplitNode): void; } /** * `RGATreeSplitNode` is a node of RGATreeSplit. */ declare class RGATreeSplitNode extends SplayNode implements GCChild { private id; private removedAt?; private prev?; private next?; private insPrev?; private insNext?; constructor(id: RGATreeSplitNodeID, value?: T, removedAt?: TimeTicket); /** * `create` creates a instance of RGATreeSplitNode. */ static create(id: RGATreeSplitNodeID, value?: T): RGATreeSplitNode; /** * `createComparator` creates a function to compare two RGATreeSplitNodeID. */ static createComparator(): Comparator; /** * `getID` returns the ID of this RGATreeSplitNode. */ getID(): RGATreeSplitNodeID; /** * `getCreatedAt` returns creation time of the Id of RGATreeSplitNode. */ getCreatedAt(): TimeTicket; /** * `getLength` returns the length of this node. */ getLength(): number; /** * `getContentLength` returns the length of this value. */ getContentLength(): number; /** * `getPrev` returns a previous node of this node. */ getPrev(): RGATreeSplitNode | undefined; /** * `getNext` returns a next node of this node. */ getNext(): RGATreeSplitNode | undefined; /** * `getInsPrev` returns a previous node of this node insertion. */ getInsPrev(): RGATreeSplitNode | undefined; /** * `getInsNext` returns a next node of this node insertion. */ getInsNext(): RGATreeSplitNode | undefined; /** * `getInsPrevID` returns a ID of previous node insertion. */ getInsPrevID(): RGATreeSplitNodeID; /** * `setPrev` sets previous node of this node. */ setPrev(node?: RGATreeSplitNode): void; /** * `setNext` sets next node of this node. */ setNext(node?: RGATreeSplitNode): void; /** * `setInsPrev` sets previous node of this node insertion. */ setInsPrev(node?: RGATreeSplitNode): void; /** * `setInsNext` sets next node of this node insertion. */ setInsNext(node?: RGATreeSplitNode): void; /** * `hasNext` checks if next node exists. */ hasNext(): boolean; /** * `hasInsPrev` checks if previous insertion node exists. */ hasInsPrev(): boolean; /** * `isRemoved` checks if removed time exists. */ isRemoved(): boolean; /** * `getRemovedAt` returns the remove time of this node. */ getRemovedAt(): TimeTicket | undefined; /** * `split` creates a new split node of the given offset. */ split(offset: number): RGATreeSplitNode; /** * `canDelete` checks if node is able to delete. */ canRemove(editedAt: TimeTicket, creationKnown: boolean, tombstoneKnown: boolean): boolean; /** * `canStyle` checks if node is able to set style. */ canStyle(editedAt: TimeTicket, clientLamportAtChange: bigint): boolean; /** * `setRemovedAt` sets the remove time of this node. */ setRemovedAt(removedAt?: TimeTicket): void; /** * `remove` removes the node of the given edited time. */ remove(removedAt: TimeTicket): void; /** * `createRange` creates ranges of RGATreeSplitPos. */ createPosRange(): RGATreeSplitPosRange; /** * `getData` returns the data of this node. */ getDataSize(): DataSize; /** * `deepcopy` returns a new instance of this RGATreeSplitNode without structural info. */ deepcopy(): RGATreeSplitNode; /** * `toTestString` returns a String containing * the meta data of the node for debugging purpose. */ toTestString(): string; private splitValue; /** * `toIDString` returns a string that can be used as an ID for this position. */ toIDString(): string; } /** * `RGATreeSplitNodeID` is an ID of RGATreeSplitNode. */ declare class RGATreeSplitNodeID { private createdAt; private offset; constructor(createdAt: TimeTicket, offset: number); /** * `of` creates a instance of RGATreeSplitNodeID. */ static of(createdAt: TimeTicket, offset: number): RGATreeSplitNodeID; /** * `fromStruct` creates a instance of RGATreeSplitNodeID from the struct. */ static fromStruct(struct: RGATreeSplitNodeIDStruct): RGATreeSplitNodeID; /** * `getCreatedAt` returns the creation time of this ID. */ getCreatedAt(): TimeTicket; /** * `getOffset` returns returns the offset of this ID. */ getOffset(): number; /** * `equals` returns whether given ID equals to this ID or not. */ equals(other: RGATreeSplitNodeID): boolean; /** * `hasSameCreatedAt` returns whether given ID has same creation time with this ID. */ hasSameCreatedAt(other: RGATreeSplitNodeID): boolean; /** * `split` creates a new ID with an offset from this ID. */ split(offset: number): RGATreeSplitNodeID; /** * `toStruct` returns the structure of this node id. */ toStruct(): RGATreeSplitNodeIDStruct; /** * `toTestString` returns a String containing * the meta data of the node id for debugging purpose. */ toTestString(): string; /** * `toIDString` returns a string that can be used as an ID for this node id. */ toIDString(): string; } /** * `RGATreeSplitNodeIDStruct` is a structure represents the meta data of the node id. * It is used to serialize and deserialize the node id. */ declare type RGATreeSplitNodeIDStruct = { createdAt: TimeTicketStruct; offset: number; }; /** * `RGATreeSplitPos` is the position of the text inside the node. */ declare class RGATreeSplitPos { private id; private relativeOffset; constructor(id: RGATreeSplitNodeID, relativeOffset: number); /** * `of` creates a instance of RGATreeSplitPos. */ static of(id: RGATreeSplitNodeID, relativeOffset: number): RGATreeSplitPos; /** * `fromStruct` creates a instance of RGATreeSplitPos from the struct. */ static fromStruct(struct: RGATreeSplitPosStruct): RGATreeSplitPos; /** * `getID` returns the ID of this RGATreeSplitPos. */ getID(): RGATreeSplitNodeID; /** * `getRelativeOffset` returns the relative offset of this RGATreeSplitPos. */ getRelativeOffset(): number; /** * `getAbsoluteID` returns the absolute id of this RGATreeSplitPos. */ getAbsoluteID(): RGATreeSplitNodeID; /** *`toTestString` returns a String containing * the meta data of the position for debugging purpose. */ toTestString(): string; /** * `toStruct` returns the structure of this node pos. */ toStruct(): RGATreeSplitPosStruct; /** * `equals` returns whether given pos equal to this pos or not. */ equals(other: RGATreeSplitPos): boolean; } declare type RGATreeSplitPosRange = [RGATreeSplitPos, RGATreeSplitPos]; /** * `RGATreeSplitPosStruct` is a structure represents the meta data of the node pos. * It is used to serialize and deserialize the node pos. */ declare type RGATreeSplitPosStruct = { id: RGATreeSplitNodeIDStruct; relativeOffset: number; }; declare interface RGATreeSplitValue { length: number; substring(indexStart: number, indexEnd?: number): RGATreeSplitValue; getDataSize(): DataSize; } /** * RHT is replicated hash table by creation time. * For more details about RHT: @see http://csl.skku.edu/papers/jpdc11.pdf */ declare class RHT { private nodeMapByKey; private numberOfRemovedElement; constructor(); /** * `create` creates a new instance of RHT. */ static create(): RHT; /** * `getNodeMapByKey` returns the hashtable of RHT. */ getNodeMapByKey(): Map; /** * `set` sets the value of the given key. */ set(key: string, value: string, executedAt: TimeTicket): [RHTNode | undefined, RHTNode | undefined]; /** * SetInternal sets the value of the given key internally. */ setInternal(key: string, value: string, executedAt: TimeTicket, removed: boolean): void; /** * `remove` removes the Element of the given key. */ remove(key: string, executedAt: TimeTicket): Array; /** * `has` returns whether the element exists of the given key or not. */ has(key: string): boolean; /** * `get` returns the value of the given key. */ get(key: string): string | undefined; /** * `deepcopy` copies itself deeply. */ deepcopy(): RHT; /** * `toJSON` returns the JSON encoding of this hashtable. */ toJSON(): string; /** * `size` returns the size of RHT */ size(): number; /** * `toObject` returns the object of this hashtable. */ toObject(): Record; [Symbol.iterator](): IterableIterator; /** * `purge` purges the given child node. */ purge(child: RHTNode): void; } /** * `RHTNode` is a node of RHT(Replicated Hashtable). */ declare class RHTNode implements GCChild { private key; private value; private updatedAt; private _isRemoved; constructor(key: string, value: string, updatedAt: TimeTicket, isRemoved: boolean); /** * `of` creates a new instance of RHTNode. */ static of(key: string, value: string, createdAt: TimeTicket, isRemoved: boolean): RHTNode; /** * `getKey` returns a key of node. */ getKey(): string; /** * `getValue` returns a value of node. */ getValue(): string; /** * `getUpdatedAt` returns updated time of node. */ getUpdatedAt(): TimeTicket; /** * `isRemoved` returns whether the node has been removed or not. */ isRemoved(): boolean; /** * `toIDString` returns the IDString of this node. */ toIDString(): string; /** * `getRemovedAt` returns the time when this node was removed. */ getRemovedAt(): TimeTicket | undefined; /** * `getDataSize` returns the size of this node. */ getDataSize(): DataSize; } /** * `RootStats` is a structure that represents the statistics of the root object. */ declare interface RootStats { /** * `elements` is the number of elements in the root object. */ elements?: number; /** * `gcElements` is the number of elements that can be garbage collected. */ gcElements?: number; /** * `gcPairs` is the number of garbage collection pairs. */ gcPairs?: number; } /** * @generated from message yorkie.v1.Rule */ declare type Rule_2 = Message<"yorkie.v1.Rule"> & { /** * @generated from field: string path = 1; */ path: string; /** * @generated from field: string type = 2; */ type: string; /** * @generated from field: repeated yorkie.v1.TreeNodeRule tree_nodes = 3; */ treeNodes: TreeNodeRule[]; }; /** * Definition of all messages the SDK can send to the Devtools panel. */ export declare type SDKToPanelMessage = /** * Sent when the dev panel is already opened and listened, * before the sdk is loaded. If the panel receives this message, * it will replay its initial "connect" message. */ { msg: 'refresh-devtools'; } /** * Sent when the document is available for the panel to watch. */ | { msg: 'doc::available'; docKey: string; } /** * Sent initially, to synchronize the entire current state of the document. */ | { msg: 'doc::sync::full'; docKey: string; events: Array; } /** * Sent whenever the document is changed. */ | { msg: 'doc::sync::partial'; docKey: string; event: DocEventsForReplay_2; }; /** * `setLogLevel` sets log level. */ export declare function setLogLevel(l: LogLevel): void; /** * `SetOpInfo` represents the information of the set operation. */ export declare type SetOpInfo = { type: 'set'; path: string; key: string; }; /** * `SetOpInfo` represents the information of the set operation. */ declare type SetOpInfo_2 = { type: 'set'; path: string; key: string; }; /** * `SnapshotEvent` is an event that occurs when a snapshot is received from * the server. */ export declare interface SnapshotEvent extends BaseDocEvent_2 { type: DocEventType.Snapshot; source: OpSource.Remote; value: { snapshot: string | undefined; serverSeq: string; snapshotVector: string; }; } /** * `SnapshotEvent` is an event that occurs when a snapshot is received from * the server. */ declare interface SnapshotEvent_2 extends BaseDocEvent { type: DocEventType_2.Snapshot; source: OpSource_2.Remote; value: { snapshot: string | undefined; serverSeq: string; snapshotVector: string; }; } /** * `SortedMapIterator` is a interator for traversing LLRBTree. */ declare class SortedMapIterator { stack: Array>; constructor(root: LLRBNode); private traverseInorder; } /** * `SplayNode` is a node of SplayTree. */ declare abstract class SplayNode { protected value: V; private left?; private right?; private parent?; private weight; constructor(value: V); abstract getLength(): number; /** * `getNodeString` returns a string of weight and value of this node. */ getNodeString(): string; /** * `getValue` returns value of this node. */ getValue(): V; /** * `getLeftWeight` returns left weight of this node. */ getLeftWeight(): number; /** * `getRightWeight` returns right weight of this node. */ getRightWeight(): number; /** * `getWeight` returns weight of this node. */ getWeight(): number; /** * `getLeft` returns a left node. */ getLeft(): SplayNode | undefined; /** * `getRight` returns a right node. */ getRight(): SplayNode | undefined; /** * `getParent` returns parent of this node. */ getParent(): SplayNode | undefined; /** * `hasLeft` check if the left node exists */ hasLeft(): boolean; /** * `hasRight` check if the right node exists */ hasRight(): boolean; /** * `hasParent` check if the parent node exists */ hasParent(): boolean; /** * `setLeft` sets a left node. */ setLeft(left?: SplayNode): void; /** * `setRight` sets a right node. */ setRight(right?: SplayNode): void; /** * `setParent` sets a parent node. */ setParent(parent?: SplayNode): void; /** * `unlink` unlink parent, right and left node. */ unlink(): void; /** * `hasLinks` checks if parent, right and left node exists. */ hasLinks(): boolean; /** * `increaseWeight` increases weight. */ increaseWeight(weight: number): void; /** * `initWeight` sets initial weight of this node. */ initWeight(): void; } /** * SplayTree is weighted binary search tree which is based on Splay tree. * original paper on Splay Trees: * @see https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf */ declare class SplayTree { private root?; constructor(root?: SplayNode); /** * `length` returns the size of this tree. */ get length(): number; /** * `findForText` returns the Node and offset of the given position (cursor). * Used for Text where cursor placed between characters. */ findForText(pos: number): [SplayNode | undefined, number]; /** * `findForArray` returns the Node of the given position (index). * Used for Array where index points to the element. */ findForArray(idx: number): SplayNode | undefined; /** * Find the index of the given node in BST. * * @param node - the given node * @returns the index of given node */ indexOf(node: SplayNode): number; /** * `getRoot` returns root of this tree. */ getRoot(): SplayNode; /** * `insert` inserts the node at the last. */ insert(newNode: SplayNode): SplayNode; /** * `insertAfter` inserts the node after the given previous node. */ insertAfter(target: SplayNode | undefined, newNode: SplayNode): SplayNode; /** * `updateWeight` recalculates the weight of this node with the value and children. */ updateWeight(node: SplayNode): void; private updateTreeWeight; /** * `splayNode` moves the given node to the root. */ splayNode(node: SplayNode | undefined): void; /** * `delete` deletes target node of this tree. */ delete(node: SplayNode): void; /** * `deleteRange` separates the range between given 2 boundaries from this Tree. * This function separates the range to delete as a subtree * by splaying outer boundary nodes. * leftBoundary must exist because of 0-indexed initial dummy node of tree, * but rightBoundary can be nil means range to delete includes the end of tree. * Refer to the design document in https://github.com/yorkie-team/yorkie/tree/main/design */ deleteRange(leftBoundary: SplayNode, rightBoundary: SplayNode | undefined): void; private cutOffRight; /** * `toTestString` returns a string containing the meta data of the Node * for debugging purpose. */ toTestString(): string; /** * `checkWeight` returns false when there is an incorrect weight node. * for debugging purpose. */ checkWeight(): boolean; private getRightmost; private traverseInorder; private traversePostorder; private rotateLeft; private rotateRight; private isLeftChild; private isRightChild; } /** * `StatusChangedEvent` is an event that occurs when the status of a document changes. */ declare interface StatusChangedEvent extends BaseDocEvent { type: DocEventType_2.StatusChanged; source: OpSource_2; value: | { status: DocStatus_2.Attached; actorID: string } | { status: DocStatus_2.Detached } | { status: DocStatus_2.Removed }; } /** * `StatusChangedEvent` is an event that occurs when the status of a document changes. */ declare interface StatusChangedEvent_2 extends BaseDocEvent_2 { type: DocEventType.StatusChanged; source: OpSource; value: { status: DocStatus.Attached; actorID: string; } | { status: DocStatus.Detached; } | { status: DocStatus.Removed; }; } /** * `StreamConnectionStatus` represents whether the stream connection is connected or not. */ export declare enum StreamConnectionStatus { /** * `Connected` means that the stream connection is connected. */ Connected = "connected", /** * `Disconnected` means that the stream connection is disconnected. */ Disconnected = "disconnected" } /** * `StreamConnectionStatus` represents whether the stream connection is connected or not. */ declare enum StreamConnectionStatus_2 { /** * `Connected` means that the stream connection is connected. */ Connected = 'connected', /** * `Disconnected` means that the stream connection is disconnected. */ Disconnected = 'disconnected', } /** * `StyleOpInfo` represents the information of the style operation. */ export declare type StyleOpInfo = { type: 'style'; path: string; from: number; to: number; value: { attributes: Indexable; }; }; /** * `StyleOpInfo` represents the information of the style operation. */ declare type StyleOpInfo_2 = { type: 'style'; path: string; from: number; to: number; value: { attributes: Indexable_2; }; }; declare interface SubscribeFn { (next: Observer | NextFn, error?: ErrorFn, complete?: CompleteFn): Unsubscribe; (observer: Observer): Unsubscribe; } /** * `SyncErrorEvent` represents a non-recoverable sync (RefreshChannel) error. * It carries the underlying error object so subscribers can inspect codes * (e.g. via `isErrorCode`) without losing the original Error. */ declare interface SyncErrorEvent { /** * `type` is the type of the event. */ type: ChannelEventType.SyncError; /** * `error` is the underlying error thrown by the RPC call. */ error: unknown; /** * `method` is the RPC method that failed (e.g. `RefreshChannel`). */ method: string; } /** * `SyncMode` defines synchronization modes for the PushPullChanges API * (documents) and the RefreshChannel heartbeat (channels). */ export declare enum SyncMode { /** * `Manual` mode indicates that changes are not automatically pushed or pulled. */ Manual = "manual", /** * `Realtime` mode indicates that changes are automatically pushed and pulled. */ Realtime = "realtime", /** * `RealtimePushOnly` mode indicates that only local changes are automatically pushed. */ RealtimePushOnly = "realtime-pushonly", /** * `RealtimeSyncOff` mode indicates that changes are not automatically pushed or pulled, * but the watch stream is kept active. */ RealtimeSyncOff = "realtime-syncoff", /** * `Polling` mode runs the sync loop without opening a watch stream. * - For Channel: heartbeat refreshes TTL and brings sessionCount. * - For Document: PushPullChanges runs at the polling interval. Remote * changes arrive on the next tick (latency = interval). Not suitable * for collaborative editing — use Realtime for that. */ Polling = "polling" } /** * `SyncStatusChangedEvent` is an event that occurs when document is synced with the server. */ export declare interface SyncStatusChangedEvent extends BaseDocEvent_2 { type: DocEventType.SyncStatusChanged; value: DocSyncStatus; } /** * `SyncStatusChangedEvent` is an event that occurs when document is synced with the server. */ declare interface SyncStatusChangedEvent_2 extends BaseDocEvent { type: DocEventType_2.SyncStatusChanged; value: DocSyncStatus_2; } /** * `Text` is an extended data type for the contents of a text editor. */ declare class Text_2 { private context?; private text?; constructor(context?: ChangeContext, text?: CRDTText); /** * `initialize` initialize this text with context and internal text. */ initialize(context: ChangeContext, text: CRDTText): void; /** * `getID` returns the ID of this text. */ getID(): TimeTicket; /** * `edit` edits this text with the given content. */ edit(fromIdx: number, toIdx: number, content: string, attributes?: A): [number, number] | undefined; /** * `delete` deletes the text in the given range. */ delete(fromIdx: number, toIdx: number): [number, number] | undefined; /** * `empty` makes the text empty. */ empty(): [number, number] | undefined; /** * `setStyle` styles this text with the given attributes. */ setStyle(fromIdx: number, toIdx: number, attributes: A): boolean; /** * `indexRangeToPosRange` returns TextRangeStruct of the given index range. */ indexRangeToPosRange(range: [number, number]): TextPosStructRange; /** * `posRangeToIndexRange` returns indexes of the given TextRangeStruct. */ posRangeToIndexRange(range: TextPosStructRange): [number, number]; /** * `toTestString` returns a String containing the meta data of the node * for debugging purpose. */ toTestString(): string; /** * `values` returns values of this text. */ values(): Array>; /** * `length` returns size of RGATreeList. */ get length(): number; /** * `getTreeByIndex` returns IndexTree of the text for testing purpose. */ getTreeByIndex(): SplayTree; /** * `getTreeByID` returns IDTree of the text for testing purpose. */ getTreeByID(): LLRBTree>; /** * `toString` returns the string representation of this text. */ toString(): string; /** * `toJSON` returns the JSON string of this tree. */ toJSON(): string; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `createRangeForTest` returns pair of RGATreeSplitNodePos of the given indexes * for testing purpose. */ createRangeForTest(fromIdx: number, toIdx: number): RGATreeSplitPosRange; } export { Text_2 as Text } /** * `TextChange` represents the changes to the text * when executing the edit, setstyle methods. */ declare interface TextChange extends ValueChange> { type: TextChangeType; } /** * `TextChangeType` is the type of TextChange. * */ declare enum TextChangeType { Content = "content", Style = "style" } /** * `TextNode` represents a text node. It has a string value. */ export declare type TextNode = { type: typeof DefaultTextType_2; value: string; }; /** * `TextNode` represents a text node. It has a string value. */ declare type TextNode_2 = { type: typeof DefaultTextType; value: string; }; /** * @generated from message yorkie.v1.TextNodePos */ declare type TextNodePos = Message<"yorkie.v1.TextNodePos"> & { /** * @generated from field: yorkie.v1.TimeTicket created_at = 1; */ createdAt?: TimeTicket_2; /** * @generated from field: int32 offset = 2; */ offset: number; /** * @generated from field: int32 relative_offset = 3; */ relativeOffset: number; }; /** * `TextOpInfo` represents the OperationInfo for the yorkie.Text. */ export declare type TextOpInfo = EditOpInfo | StyleOpInfo; /** * `TextOpInfo` represents the OperationInfo for the yorkie.Text. */ declare type TextOpInfo_2 = EditOpInfo_2 | StyleOpInfo_2; /** * `TextPosStruct` represents the structure of RGATreeSplitPos. * It is used to serialize and deserialize the RGATreeSplitPos. */ export declare type TextPosStruct = { id: { createdAt: TimeTicketStruct; offset: number; }; relativeOffset: number; }; /** * `TextPosStructRange` represents the structure of RGATreeSplitPosRange. * It is used to serialize and deserialize the RGATreeSplitPosRange. */ export declare type TextPosStructRange = [TextPosStruct, TextPosStruct]; /** * `textToString` extracts plain text content from YSONText. * * @param text - YSONText object * @returns Plain text string * * @example * ```typescript * const text = { type: 'Text', nodes: [{val: 'H'}, {val: 'i'}] }; * textToString(text); // "Hi" * ``` */ declare function textToString(text: YSONText): string { return text.nodes.map((node) => node.val).join(''); } /** * `TextValueType` is a value of Text * which has a attributes that expresses the text style. */ declare interface TextValueType { attributes?: A; content?: string; } /** * `TimeTicket` is a timestamp of the logical clock. Ticket is immutable. * It is created by `ChangeID`. */ export declare class TimeTicket { private lamport; private delimiter; private actorID; constructor(lamport: bigint, delimiter: number, actorID: string); /** * `of` creates an instance of Ticket. */ static of(lamport: bigint, delimiter: number, actorID: string): TimeTicket; /** * `fromStruct` creates an instance of Ticket from the struct. */ static fromStruct(struct: TimeTicketStruct): TimeTicket; /** * `toIDString` returns the lamport string for this Ticket. */ toIDString(): string; /** * `toStruct` returns the structure of this Ticket. */ toStruct(): TimeTicketStruct; /** * `toTestString` returns a string containing the meta data of the ticket * for debugging purpose. */ toTestString(): string; /** * `setActor` creates a new instance of Ticket with the given actorID. */ setActor(actorID: ActorID): TimeTicket; /** * `getLamportAsString` returns the lamport string. */ getLamportAsString(): string; /** * `getLamport` returns the lamport. */ getLamport(): bigint; /** * `getDelimiter` returns delimiter. */ getDelimiter(): number; /** * `getActorID` returns actorID. */ getActorID(): string; /** * `after` returns whether the given ticket was created later. */ after(other: TimeTicket): boolean; /** * `equals` returns whether the given ticket was created. */ equals(other: TimeTicket): boolean; /** * `compare` returns an integer comparing two Ticket. * The result will be 0 if id==other, -1 if `id < other`, and +1 if `id > other`. * If the receiver or argument is nil, it would panic at runtime. */ compare(other: TimeTicket): number; } /** * @generated from message yorkie.v1.TimeTicket */ declare type TimeTicket_2 = Message<"yorkie.v1.TimeTicket"> & { /** * @generated from field: int64 lamport = 1; */ lamport: bigint; /** * @generated from field: uint32 delimiter = 2; */ delimiter: number; /** * @generated from field: bytes actor_id = 3; */ actorId: Uint8Array; }; /** * `TimeTicketStruct` is a structure represents the meta data of the ticket. * It is used to serialize and deserialize the ticket. */ export declare type TimeTicketStruct = { lamport: string; delimiter: number; actorID: ActorID; }; /** * `TimeTicketStruct` is a structure represents the meta data of the ticket. * It is used to serialize and deserialize the ticket. */ declare type TimeTicketStruct_2 = { lamport: string; delimiter: number; actorID: ActorID_2; }; /** * `toChangeID` converts the given model to Protobuf format. */ declare function toChangeID(changeID: ChangeID): ChangeID_2; /** * `toChangePack` converts the given model to Protobuf format. */ declare function toChangePack(pack: ChangePack): ChangePack_2; /** * `toHexString` converts the given byte array to hex string. */ declare function toHexString(bytes: Uint8Array): string; /** * `TokenType` represents the type of token in XML representation. */ declare enum TokenType { /** * `Start` represents that the start token type. */ Start = "Start", /** * `End` represents that the end token type. */ End = "End", /** * `Text` represents that the text token type. */ Text = "Text" } /** * `toOperation` converts the given model to Protobuf format. */ declare function toOperation(operation: Operation): Operation_2; /** * `toRevisionSummary` converts a protobuf RevisionSummary to a RevisionSummary. */ declare function toRevisionSummary(pbRevision: RevisionSummary_2): RevisionSummary; /** * `toTreeNodes` converts the given model to Protobuf format. */ declare function toTreeNodes(node: CRDTTreeNode): Array; /** * `toUnit8Array` converts the given hex string to byte array. */ declare function toUint8Array(hex: string): Uint8Array; /** * `Tree` is a CRDT-based tree structure that is used to represent the document * tree of text-based editor such as ProseMirror. */ export declare class Tree { private initialRoot?; private context?; private tree?; constructor(initialRoot?: ElementNode); /** * `initialize` initialize this tree with context and internal tree. */ initialize(context: ChangeContext, tree: CRDTTree): void; /** * `getID` returns the ID of this tree. */ getID(): TimeTicket; /** * `buildRoot` builds the root of this tree with the given initial root * which set by the user. */ buildRoot(context: ChangeContext): CRDTTreeNode; /** * `getSize` returns the size of this tree. */ getSize(): number; /** * `getNodeSize` returns the node size of this tree. */ getNodeSize(): number; /** * `getIndexTree` returns the index tree of this tree. */ getIndexTree(): IndexTree; /** * `splitByPath` splits the tree by the given path. */ splitByPath(path: Array): void; /** * `mergeByPath` merges the tree by the given path. */ mergeByPath(path: Array): void; /** * `styleByPath` sets the attributes to the element at the given * path. */ styleByPath(path: Array, attributes: { [key: string]: any; }): void; /** * `styleByPath` sets the attributes to the elements in the given * path range. */ styleByPath(fromPath: Array, toPath: Array, attributes: { [key: string]: any; }): void; /** * `style` sets the attributes to the elements of the given range. */ style(fromIdx: number, toIdx: number, attributes: { [key: string]: any; }): void; /** * `removeStyle` removes the attributes to the elements of the given range. */ removeStyle(fromIdx: number, toIdx: number, attributesToRemove: Array): void; /** * `removeStyleByPath` removes the attributes of the elements in * the given path range. */ removeStyleByPath(fromPath: Array, toPath: Array, attributesToRemove: Array): void; private editInternal; /** * `editByPath` edits this tree with the given node and path. */ editByPath(fromPath: Array, toPath: Array, content?: TreeNode, splitLevel?: number): boolean; /** * `editBulkByPath` edits this tree with the given node and path. */ editBulkByPath(fromPath: Array, toPath: Array, contents: Array, splitLevel?: number): boolean; /** * `edit` edits this tree with the given nodes. */ edit(fromIdx: number, toIdx: number, content?: TreeNode, splitLevel?: number): boolean; /** * `editBulk` edits this tree with the given nodes. */ editBulk(fromIdx: number, toIdx: number, contents: Array, splitLevel?: number): boolean; /** * `toXML` returns the XML string of this tree. */ toXML(): string; /** * `toJSON` returns the JSON string of this tree. */ toJSON(): string; /** * `toJSForTest` returns value with meta data for testing. */ toJSForTest(): Devtools.JSONElement; /** * `toJSInfoForTest` returns detailed TreeNode information for use in Devtools. */ toJSInfoForTest(): Devtools.TreeNodeInfo; /** * `getRootTreeNode` returns TreeNode of this tree. */ getRootTreeNode(): TreeNode; /** * `indexToPath` returns the path of the given index. */ indexToPath(index: number): Array; /** * `pathToIndex` returns the index of given path. */ pathToIndex(path: Array): number; /** * `pathRangeToPosRange` converts the path range into the position range. */ pathRangeToPosRange(range: [Array, Array]): TreePosStructRange; /** * `indexRangeToPosRange` converts the index range into the position range. */ indexRangeToPosRange(range: [number, number]): TreePosStructRange; /** * `posRangeToIndexRange` converts the position range into the index range. */ posRangeToIndexRange(range: TreePosStructRange): [number, number]; /** * `posRangeToPathRange` converts the position range into the path range. */ posRangeToPathRange(range: TreePosStructRange): [Array, Array]; } /** * `TreeChange` represents the change in the tree. */ export declare type TreeChange = { actor: ActorID; type: TreeChangeType.Content; from: number; to: number; fromPath: Array; toPath: Array; value?: Array; splitLevel?: number; } | { actor: ActorID; type: TreeChangeType.Style; from: number; to: number; fromPath: Array; toPath: Array; value: { [key: string]: string; }; splitLevel?: number; } | { actor: ActorID; type: TreeChangeType.RemoveStyle; from: number; to: number; fromPath: Array; toPath: Array; value?: Array; splitLevel?: number; }; /** * `TreeChangeType` represents the type of change in the tree. */ export declare enum TreeChangeType { Content = "content", Style = "style", RemoveStyle = "removeStyle" } /** * `TreeEditOpInfo` represents the information of the tree edit operation. */ export declare type TreeEditOpInfo = { type: 'tree-edit'; path: string; from: number; to: number; value?: Array; splitLevel?: number; fromPath: Array; toPath: Array; }; /** * `TreeEditOpInfo` represents the information of the tree edit operation. */ declare type TreeEditOpInfo_2 = { type: 'tree-edit'; path: string; from: number; to: number; value?: Array; splitLevel?: number; fromPath: Array; toPath: Array; }; /** * `TreeNode` represents a node in the tree. */ export declare type TreeNode = TextNode | ElementNode; /** * `TreeNode` represents a node in the tree. */ declare type TreeNode_2 = TextNode_2 | ElementNode_2; /** * @generated from message yorkie.v1.TreeNode */ declare type TreeNode_3 = Message<"yorkie.v1.TreeNode"> & { /** * @generated from field: yorkie.v1.TreeNodeID id = 1; */ id?: TreeNodeID; /** * @generated from field: string type = 2; */ type: string; /** * @generated from field: string value = 3; */ value: string; /** * @generated from field: yorkie.v1.TimeTicket removed_at = 4; */ removedAt?: TimeTicket_2; /** * @generated from field: yorkie.v1.TreeNodeID ins_prev_id = 5; */ insPrevId?: TreeNodeID; /** * @generated from field: yorkie.v1.TreeNodeID ins_next_id = 6; */ insNextId?: TreeNodeID; /** * @generated from field: int32 depth = 7; */ depth: number; /** * @generated from field: map attributes = 8; */ attributes: { [key: string]: NodeAttr; }; /** * merged_from is set when this node was moved to a new parent by a * concurrent merge. It points to the source parent's ID. * * @generated from field: yorkie.v1.TreeNodeID merged_from = 9; */ mergedFrom?: TreeNodeID; /** * merged_at records the immutable ticket of the merge operation. * Stored alongside merged_from because the source parent's removed_at * may be overwritten by later LWW tombstones and thus cannot serve as * the merge-time causal boundary for SplitElement. * * @generated from field: yorkie.v1.TimeTicket merged_at = 10; */ mergedAt?: TimeTicket_2; }; /** * `TreeNodeForTest` represents the JSON representation of a node in the tree. * It is used for testing. */ declare type TreeNodeForTest = TreeNode & { children?: Array; visibleSize: number; isRemoved: boolean; }; /** * @generated from message yorkie.v1.TreeNodeID */ declare type TreeNodeID = Message<"yorkie.v1.TreeNodeID"> & { /** * @generated from field: yorkie.v1.TimeTicket created_at = 1; */ createdAt?: TimeTicket_2; /** * @generated from field: int32 offset = 2; */ offset: number; }; /** * `TreeNodeInfo` represents the crdt tree node information in devtools. */ declare type TreeNodeInfo = { id: string; type: string; parent?: string; size: number; value?: string; removedAt?: string; isRemoved: boolean; insPrev?: string; insNext?: string; children: Array; attributes?: object; // TODO(chacha912): Specify the type accurately. depth: number; index?: number; path?: Array; pos?: CRDTTreePosStruct; }; /** * `TreeNodePair` represents a pair of CRDTTreeNode. It represents the position * of the node in the tree with the left and parent nodes. */ declare type TreeNodePair = [CRDTTreeNode, CRDTTreeNode]; /** * @generated from message yorkie.v1.TreeNodeRule */ declare type TreeNodeRule = Message<"yorkie.v1.TreeNodeRule"> & { /** * @generated from field: string node_type = 1; */ nodeType: string; /** * @generated from field: string content = 2; */ content: string; /** * @generated from field: string marks = 3; */ marks: string; /** * @generated from field: string group = 4; */ group: string; }; /** * @generated from message yorkie.v1.TreeNodes */ declare type TreeNodes = Message<"yorkie.v1.TreeNodes"> & { /** * @generated from field: repeated yorkie.v1.TreeNode content = 1; */ content: TreeNode_3[]; }; /** * `NoteType` is the type of a node in the tree. */ declare type TreeNodeType = string; /** * `NoteType` is the type of a node in the tree. */ declare type TreeNodeType_2 = string; /** * `TreeOpInfo` represents the OperationInfo for the yorkie.Tree. */ export declare type TreeOpInfo = TreeEditOpInfo | TreeStyleOpInfo; /** * `TreeOpInfo` represents the OperationInfo for the yorkie.Tree. */ declare type TreeOpInfo_2 = TreeEditOpInfo_2 | TreeStyleOpInfo_2; /** * `TreePos` is the position of a node in the tree. * * `offset` is the position of node's token. For example, if the node is an * element node, the offset is the index of the child node. If the node is a * text node, the offset is the index of the character. */ declare type TreePos> = { node: T; offset: number; }; /** * @generated from message yorkie.v1.TreePos */ declare type TreePos_2 = Message<"yorkie.v1.TreePos"> & { /** * @generated from field: yorkie.v1.TreeNodeID parent_id = 1; */ parentId?: TreeNodeID; /** * @generated from field: yorkie.v1.TreeNodeID left_sibling_id = 2; */ leftSiblingId?: TreeNodeID; }; /** * `TreePosRange` represents a pair of CRDTTreePos. */ declare type TreePosRange = [CRDTTreePos, CRDTTreePos]; /** * `TreePosStructRange` represents the structure of TreeRange. * It is used to serialize and deserialize the TreeRange. */ export declare type TreePosStructRange = [CRDTTreePosStruct_2, CRDTTreePosStruct_2]; /** * `TreeStyleOpInfo` represents the information of the tree style operation. */ export declare type TreeStyleOpInfo = { type: 'tree-style'; path: string; from: number; to: number; fromPath: Array; toPath: Array; value: { attributes?: Indexable; attributesToRemove?: Array; }; }; /** * `TreeStyleOpInfo` represents the information of the tree style operation. */ declare type TreeStyleOpInfo_2 = { type: 'tree-style'; path: string; from: number; to: number; fromPath: Array; toPath: Array; value: { attributes?: Indexable_2; attributesToRemove?: Array; }; }; /** * `TreeToken` represents the token of the tree in XML representation. */ declare type TreeToken = [T, TokenType]; /** * `treeToXML` converts YSONTree to XML string representation. * * @param tree - YSONTree object * @returns XML string */ declare function treeToXML(tree: YSONTree): string { return treeNodeToXML(tree.root); } export declare type Unsubscribe = () => void; export declare interface UnwatchedEvent

extends BaseDocEvent_2 { type: DocEventType.Unwatched; source: OpSource.Remote; value: { clientID: ActorID; presence: P; }; } declare interface UnwatchedEvent_2

extends BaseDocEvent { type: DocEventType_2.Unwatched; source: OpSource_2.Remote; value: { clientID: ActorID_2; presence: P }; } declare interface ValueChange { actor: ActorID; from: number; to: number; value?: T; } /** * @generated from enum yorkie.v1.ValueType */ declare enum ValueType { /** * @generated from enum value: VALUE_TYPE_NULL = 0; */ NULL = 0, /** * @generated from enum value: VALUE_TYPE_BOOLEAN = 1; */ BOOLEAN = 1, /** * @generated from enum value: VALUE_TYPE_INTEGER = 2; */ INTEGER = 2, /** * @generated from enum value: VALUE_TYPE_LONG = 3; */ LONG = 3, /** * @generated from enum value: VALUE_TYPE_DOUBLE = 4; */ DOUBLE = 4, /** * @generated from enum value: VALUE_TYPE_STRING = 5; */ STRING = 5, /** * @generated from enum value: VALUE_TYPE_BYTES = 6; */ BYTES = 6, /** * @generated from enum value: VALUE_TYPE_DATE = 7; */ DATE = 7, /** * @generated from enum value: VALUE_TYPE_JSON_OBJECT = 8; */ JSON_OBJECT = 8, /** * @generated from enum value: VALUE_TYPE_JSON_ARRAY = 9; */ JSON_ARRAY = 9, /** * @generated from enum value: VALUE_TYPE_TEXT = 10; */ TEXT = 10, /** * @generated from enum value: VALUE_TYPE_INTEGER_CNT = 11; */ INTEGER_CNT = 11, /** * @generated from enum value: VALUE_TYPE_LONG_CNT = 12; */ LONG_CNT = 12, /** * @generated from enum value: VALUE_TYPE_TREE = 13; */ TREE = 13, /** * @generated from enum value: VALUE_TYPE_INTEGER_DEDUP_CNT = 14; */ INTEGER_DEDUP_CNT = 14 } /** * `VersionVector` is a vector clock that is used to detect the relationship * between changes whether they are causally related or concurrent. It is * similar to vector clocks, but it is synced with lamport timestamp of the * change. */ export declare class VersionVector { private vector; constructor(vector?: Map); /** * `set` sets the lamport timestamp of the given actor. */ set(actorID: string, lamport: bigint): void; /** * `unset` removes the version for the given actor from the VersionVector. */ unset(actorID: string): void; /** * `get` gets the lamport timestamp of the given actor. */ get(actorID: string): bigint | undefined; /** * `has` checks if the given actor exists in the VersionVector. */ has(actorID: string): boolean; /** * `maxLamport` returns max lamport value from vector */ maxLamport(): bigint; /** * `max` returns new version vector which consists of max value of each vector */ max(other: VersionVector): VersionVector; /** * `afterOrEqual` returns vector[other.actorID] is greaterOrEqual than given ticket's lamport */ afterOrEqual(other: TimeTicket): boolean; /** * `deepcopy` returns a deep copy of this `VersionVector`. */ deepcopy(): VersionVector; /** * `filter` returns new version vector consist of filter's actorID. */ filter(versionVector: VersionVector): VersionVector; /** * `size` returns size of version vector */ size(): number; [Symbol.iterator](): IterableIterator<[string, bigint]>; } /** * @generated from message yorkie.v1.VersionVector */ declare type VersionVector_2 = Message<"yorkie.v1.VersionVector"> & { /** * @generated from field: map vector = 1; */ vector: { [key: string]: bigint; }; }; /** * `versionVectorToHex` converts the given VersionVector to bytes. */ declare function versionVectorToHex(vector: VersionVector): string; export declare interface WatchedEvent

extends BaseDocEvent_2 { type: DocEventType.Watched; source: OpSource.Remote; value: { clientID: ActorID; presence: P; }; } declare interface WatchedEvent_2

extends BaseDocEvent { type: DocEventType_2.Watched; source: OpSource_2.Remote; value: { clientID: ActorID_2; presence: P }; } /** * `WrappedElement` is a wrapper of JSONElement that provides `getID()`. */ export declare type WrappedElement = Primitive | JSONObject | JSONArray | Text_2 | Counter | DedupCounter | Tree; declare namespace YSON { export { YSONValue, YSONText as Text, YSONTree as Tree, YSONTextNode as TextNode, YSONTreeNode as TreeNode, YSONInt as Int, YSONLong as Long, YSONDate as Date, YSONBinData as BinData, YSONCounter as Counter, YSONDedupCounter as DedupCounter, isText, isTree, isInt, isLong, isDate, isBinData, isCounter, isDedupCounter, isObject, parse, textToString, treeToXML } } export { YSON } /** * `YSONBinData` represents Base64-encoded binary data. * * @example * ```typescript * { type: 'BinData', value: 'AQID' } * ``` */ declare interface YSONBinData { type: 'BinData'; value: string; } /** * `YSONCounter` represents a Counter CRDT for collaborative counting. * * @example * ```typescript * { type: 'Counter', value: { type: 'Int', value: 10 } } * ``` */ declare interface YSONCounter { type: 'Counter'; value: YSONInt | YSONLong; } /** * `YSONDate` represents an ISO 8601 timestamp. * * @example * ```typescript * { type: 'Date', value: '2025-01-02T15:04:05.058Z' } * ``` */ declare interface YSONDate { type: 'Date'; value: string; } /** * `YSONDedupCounter` represents a DedupCounter CRDT that uses HyperLogLog * to count unique actors. * * @example * ```typescript * { type: 'DedupCounter', value: { type: 'Int', value: 15 }, registers: 'AQID...' } * ``` */ declare interface YSONDedupCounter { type: 'DedupCounter'; value: YSONInt; registers: string; } /** * `YSONInt` represents a 32-bit integer. * * @example * ```typescript * { type: 'Int', value: 42 } * ``` */ declare interface YSONInt { type: 'Int'; value: number; } /** * `YSONLong` represents a 64-bit integer. * * @example * ```typescript * { type: 'Long', value: 64 } * ``` */ declare interface YSONLong { type: 'Long'; value: number; } /** * `YSONText` represents a Text CRDT structure. * * @example * ```typescript * { * type: 'Text', * nodes: [ * { val: 'H' }, * { val: 'i' } * ] * } * ``` */ declare interface YSONText { type: 'Text'; nodes: Array; } /** * `YSONTextNode` represents a single character in a Text CRDT. * * @example * ```typescript * { val: 'H', attrs: { bold: true } } * ``` */ declare interface YSONTextNode { /** * The character value */ val: string; /** * Optional attributes (e.g., formatting) */ attrs?: Record; } /** * `YSONTree` represents a Tree CRDT structure. * * @example * ```typescript * { * type: 'Tree', * root: { * type: 'doc', * children: [ * { type: 'p', children: [{ type: 'text', value: 'Hello' }] } * ] * } * } * ``` */ declare interface YSONTree { type: 'Tree'; root: YSONTreeNode; } /** * `YSONTreeNode` represents a node in a Tree CRDT. * * For text nodes: `{ type: 'text', value: 'content' }` * For element nodes: `{ type: 'p', children: [...] }` */ declare interface YSONTreeNode { /** * Node type (e.g., 'text', 'p', 'div') */ type: string; /** * Text content (for text nodes) */ value?: string; /** * Attributes (for element nodes) */ attrs?: Record; /** * Child nodes (for element nodes) */ children?: Array; } /** * `YSONValue` represents any valid YSON value. * * Can be: * - Primitives: string, number, boolean, null * - Collections: arrays, objects * - CRDT types: Text, Tree, Counter * - Special types: Int, Long, Date, BinData */ declare type YSONValue = | string | number | boolean // eslint-disable-next-line @typescript-eslint/no-restricted-types | null | YSONText | YSONTree | YSONInt | YSONLong | YSONDate | YSONBinData | YSONCounter | YSONDedupCounter | { [key: string]: YSONValue } | Array; export { }