1 export enum YjsOperationType {
2 SyncStep1 = 'SyncStep1',
3 SyncStep2 = 'SyncStep2',
4 DocumentUpdate = 'DocumentUpdate',
5 Awareness = 'Awareness',
9 /** https://github.com/yjs/y-protocols/blob/master/PROTOCOL.md#handling-read-only-users */
10 export function GetYjsOperationType(buf: ArrayBuffer): YjsOperationType {
11 const byteArray = new Uint8Array(buf)
12 const firstByte = byteArray[0]
13 const secondByte = byteArray[1]
15 if (firstByte === 0) {
16 if (secondByte === 0) {
17 return YjsOperationType.SyncStep1
19 if (secondByte === 1) {
20 return YjsOperationType.SyncStep2
22 if (secondByte === 2) {
23 return YjsOperationType.DocumentUpdate
25 } else if (firstByte === 1) {
26 return YjsOperationType.Awareness
29 return YjsOperationType.Unknown