MCPcopy Create free account
hub / github.com/editablejs/editable / readSyncMessage

Function readSyncMessage

packages/yjs-protocols/src/sync.ts:104–127  ·  view source on GitHub ↗
(
  decoder: decoding.Decoder,
  encoder: encoding.Encoder,
  doc: Y.Doc,
  transactionOrigin: unknown,
  writeCallback?: () => void,
)

Source from the content-addressed store, hash-verified

102export const readUpdate = readSyncStep2
103
104export const readSyncMessage = (
105 decoder: decoding.Decoder,
106 encoder: encoding.Encoder,
107 doc: Y.Doc,
108 transactionOrigin: unknown,
109 writeCallback?: () => void,
110) => {
111 const messageType = decoding.readVarUint(decoder)
112 switch (messageType) {
113 case messageYjsSyncStep1:
114 if (writeCallback) writeCallback()
115 readSyncStep1(decoder, encoder, doc)
116 break
117 case messageYjsSyncStep2:
118 readSyncStep2(decoder, doc, transactionOrigin)
119 break
120 case messageYjsUpdate:
121 readUpdate(decoder, doc, transactionOrigin)
122 break
123 default:
124 throw new Error('Unknown message type')
125 }
126 return messageType
127}

Callers

nothing calls this directly

Calls 2

readSyncStep1Function · 0.85
readSyncStep2Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…