summaryrefslogtreecommitdiff
path: root/src/main/otTypes.ts
blob: e4f0d079a0eb7005868e8fae9164bc77306a86e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2026 Yuren Hao
// Licensed under AGPL-3.0 - see LICENSE file

// OT type definitions for main process (mirror of renderer types)

export interface InsertOp {
  i: string
  p: number
}

export interface DeleteOp {
  d: string
  p: number
}

export interface CommentOp {
  c: string
  p: number
  t: string
}

export type OtOp = InsertOp | DeleteOp | CommentOp

export function isInsert(op: OtOp): op is InsertOp {
  return 'i' in op
}

export function isDelete(op: OtOp): op is DeleteOp {
  return 'd' in op
}

export function isComment(op: OtOp): op is CommentOp {
  return 'c' in op
}