-
Notifications
You must be signed in to change notification settings - Fork 160
/
types.ts
69 lines (63 loc) · 1.64 KB
/
types.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
export { Text } from "./text.js"
import { Text } from "./text.js"
export { Counter } from "./counter.js"
export { Int, Uint, Float64 } from "./numbers.js"
import { Counter } from "./counter.js"
import type { Patch } from "@automerge/automerge-wasm"
export type {
Cursor,
MapObjType,
MarkSet,
Mark,
MarkRange,
MarkPatch,
Patch,
} from "@automerge/automerge-wasm"
export type AutomergeValue =
| ScalarValue
| { [key: string]: AutomergeValue }
| Array<AutomergeValue>
| Text
export type MapValue = { [key: string]: AutomergeValue }
export type ListValue = Array<AutomergeValue>
export type ScalarValue =
| string
| number
| null
| boolean
| Date
| Counter
| Uint8Array
export type MarkValue = string | number | null | boolean | Date | Uint8Array
/**
* An automerge document.
* @typeParam T - The type of the value contained in this document
*
* Note that this provides read only access to the fields of the value. To
* modify the value use {@link change}
*/
export type Doc<T> = { readonly [P in keyof T]: T[P] }
export type PatchSource =
| "from"
| "emptyChange"
| "change"
| "changeAt"
| "merge"
| "loadIncremental"
| "applyChanges"
| "receiveSyncMessage"
export type PatchInfo<T> = {
before: Doc<T>
after: Doc<T>
source: PatchSource
}
/**
* Callback which is called by various methods in this library to notify the
* user of what changes have been made.
* @param patch - A description of the changes made
* @param info - An object that has the "before" and "after" document state, and the "from" and "to" heads
*/
export type PatchCallback<T> = (
patches: Array<Patch>,
info: PatchInfo<T>,
) => void