y-partyserver 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-C0xms8kb.cjs +34 -0
- package/dist/provider/index.cjs +489 -0
- package/dist/provider/index.cjs.map +1 -0
- package/dist/provider/index.d.cts +133 -0
- package/dist/provider/index.js +422 -285
- package/dist/provider/react.cjs +34 -0
- package/dist/provider/react.cjs.map +1 -0
- package/dist/provider/react.d.cts +15 -0
- package/dist/provider/react.js +24 -13
- package/dist/server/index.cjs +366 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +48 -0
- package/dist/server/index.d.ts +13 -41
- package/dist/server/index.js +333 -227
- package/dist/server/index.js.map +1 -1
- package/package.json +23 -11
package/dist/server/index.js
CHANGED
|
@@ -4,7 +4,16 @@ import debounce from "lodash.debounce";
|
|
|
4
4
|
import { Server } from "partyserver";
|
|
5
5
|
import * as awarenessProtocol from "y-protocols/awareness";
|
|
6
6
|
import * as syncProtocol from "y-protocols/sync";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Doc,
|
|
9
|
+
UndoManager,
|
|
10
|
+
XmlElement,
|
|
11
|
+
XmlFragment,
|
|
12
|
+
XmlText,
|
|
13
|
+
applyUpdate,
|
|
14
|
+
encodeStateAsUpdate,
|
|
15
|
+
encodeStateVector
|
|
16
|
+
} from "yjs";
|
|
8
17
|
|
|
9
18
|
//#region src/server/index.ts
|
|
10
19
|
const snapshotOrigin = Symbol("snapshot-origin");
|
|
@@ -13,243 +22,340 @@ const wsReadyStateOpen = 1;
|
|
|
13
22
|
const messageSync = 0;
|
|
14
23
|
const messageAwareness = 1;
|
|
15
24
|
/**
|
|
16
|
-
* Internal key used in connection.setState() to track which awareness
|
|
17
|
-
* client IDs are controlled by each connection. This survives hibernation
|
|
18
|
-
* because connection state is persisted to WebSocket attachments.
|
|
19
|
-
*/
|
|
25
|
+
* Internal key used in connection.setState() to track which awareness
|
|
26
|
+
* client IDs are controlled by each connection. This survives hibernation
|
|
27
|
+
* because connection state is persisted to WebSocket attachments.
|
|
28
|
+
*/
|
|
20
29
|
const AWARENESS_IDS_KEY = "__ypsAwarenessIds";
|
|
21
30
|
function getAwarenessIds(conn) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
try {
|
|
32
|
+
return conn.state?.[AWARENESS_IDS_KEY] ?? [];
|
|
33
|
+
} catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
37
|
function setAwarenessIds(conn, ids) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
try {
|
|
39
|
+
conn.setState((prev) => ({
|
|
40
|
+
...prev,
|
|
41
|
+
[AWARENESS_IDS_KEY]: ids
|
|
42
|
+
}));
|
|
43
|
+
} catch {}
|
|
35
44
|
}
|
|
36
45
|
var WSSharedDoc = class extends Doc {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
awareness;
|
|
47
|
+
constructor() {
|
|
48
|
+
super({ gc: true });
|
|
49
|
+
this.awareness = new awarenessProtocol.Awareness(this);
|
|
50
|
+
this.awareness.setLocalState(null);
|
|
51
|
+
clearInterval(this.awareness._checkInterval);
|
|
52
|
+
}
|
|
44
53
|
};
|
|
45
54
|
const CALLBACK_DEFAULTS = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
debounceWait: 2e3,
|
|
56
|
+
debounceMaxWait: 1e4,
|
|
57
|
+
timeout: 5e3
|
|
49
58
|
};
|
|
50
|
-
function readSyncMessage(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
function readSyncMessage(
|
|
60
|
+
decoder,
|
|
61
|
+
encoder,
|
|
62
|
+
doc,
|
|
63
|
+
transactionOrigin,
|
|
64
|
+
readOnly = false
|
|
65
|
+
) {
|
|
66
|
+
const messageType = decoding.readVarUint(decoder);
|
|
67
|
+
switch (messageType) {
|
|
68
|
+
case syncProtocol.messageYjsSyncStep1:
|
|
69
|
+
syncProtocol.readSyncStep1(decoder, encoder, doc);
|
|
70
|
+
break;
|
|
71
|
+
case syncProtocol.messageYjsSyncStep2:
|
|
72
|
+
if (!readOnly)
|
|
73
|
+
syncProtocol.readSyncStep2(decoder, doc, transactionOrigin);
|
|
74
|
+
break;
|
|
75
|
+
case syncProtocol.messageYjsUpdate:
|
|
76
|
+
if (!readOnly) syncProtocol.readUpdate(decoder, doc, transactionOrigin);
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
throw new Error("Unknown message type");
|
|
80
|
+
}
|
|
81
|
+
return messageType;
|
|
65
82
|
}
|
|
66
83
|
function send(conn, m) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
if (
|
|
85
|
+
conn.readyState !== void 0 &&
|
|
86
|
+
conn.readyState !== wsReadyStateConnecting &&
|
|
87
|
+
conn.readyState !== wsReadyStateOpen
|
|
88
|
+
)
|
|
89
|
+
return;
|
|
90
|
+
try {
|
|
91
|
+
conn.send(m);
|
|
92
|
+
} catch {}
|
|
71
93
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
94
|
+
function withYjs(Base) {
|
|
95
|
+
class YjsMixin extends Base {
|
|
96
|
+
static callbackOptions = {};
|
|
97
|
+
document = new WSSharedDoc();
|
|
98
|
+
async onLoad() {}
|
|
99
|
+
async onSave() {}
|
|
100
|
+
/**
|
|
101
|
+
* Replaces the document with a different state using Yjs UndoManager key remapping.
|
|
102
|
+
*
|
|
103
|
+
* @param snapshotUpdate - The snapshot update to replace the document with.
|
|
104
|
+
* @param getMetadata (optional) - A function that returns the type of the root for a given key.
|
|
105
|
+
*/
|
|
106
|
+
unstable_replaceDocument(snapshotUpdate, getMetadata = () => "Map") {
|
|
107
|
+
try {
|
|
108
|
+
const doc = this.document;
|
|
109
|
+
const snapshotDoc = new Doc();
|
|
110
|
+
applyUpdate(snapshotDoc, snapshotUpdate, snapshotOrigin);
|
|
111
|
+
const currentStateVector = encodeStateVector(doc);
|
|
112
|
+
const changesSinceSnapshotUpdate = encodeStateAsUpdate(
|
|
113
|
+
doc,
|
|
114
|
+
encodeStateVector(snapshotDoc)
|
|
115
|
+
);
|
|
116
|
+
const undoManager = new UndoManager(
|
|
117
|
+
[...snapshotDoc.share.keys()].map((key) => {
|
|
118
|
+
const type = getMetadata(key);
|
|
119
|
+
if (type === "Text") return snapshotDoc.getText(key);
|
|
120
|
+
else if (type === "Map") return snapshotDoc.getMap(key);
|
|
121
|
+
else if (type === "Array") return snapshotDoc.getArray(key);
|
|
122
|
+
else if (type === "XmlText") return snapshotDoc.get(key, XmlText);
|
|
123
|
+
else if (type === "XmlElement")
|
|
124
|
+
return snapshotDoc.get(key, XmlElement);
|
|
125
|
+
else if (type === "XmlFragment")
|
|
126
|
+
return snapshotDoc.get(key, XmlFragment);
|
|
127
|
+
throw new Error(`Unknown root type: ${type} for key: ${key}`);
|
|
128
|
+
}),
|
|
129
|
+
{ trackedOrigins: new Set([snapshotOrigin]) }
|
|
130
|
+
);
|
|
131
|
+
applyUpdate(snapshotDoc, changesSinceSnapshotUpdate, snapshotOrigin);
|
|
132
|
+
undoManager.undo();
|
|
133
|
+
const documentChangesSinceSnapshotUpdate = encodeStateAsUpdate(
|
|
134
|
+
snapshotDoc,
|
|
135
|
+
currentStateVector
|
|
136
|
+
);
|
|
137
|
+
applyUpdate(this.document, documentChangesSinceSnapshotUpdate);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`Failed to replace document: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async onStart() {
|
|
145
|
+
const src = await this.onLoad();
|
|
146
|
+
if (src != null) {
|
|
147
|
+
const state = encodeStateAsUpdate(src);
|
|
148
|
+
applyUpdate(this.document, state);
|
|
149
|
+
}
|
|
150
|
+
this.document.on("update", (update) => {
|
|
151
|
+
const encoder = encoding.createEncoder();
|
|
152
|
+
encoding.writeVarUint(encoder, messageSync);
|
|
153
|
+
syncProtocol.writeUpdate(encoder, update);
|
|
154
|
+
const message = encoding.toUint8Array(encoder);
|
|
155
|
+
for (const conn of this.getConnections()) send(conn, message);
|
|
156
|
+
});
|
|
157
|
+
this.document.awareness.on(
|
|
158
|
+
"update",
|
|
159
|
+
({ added, updated, removed }, conn) => {
|
|
160
|
+
if (conn !== null)
|
|
161
|
+
try {
|
|
162
|
+
const currentIds = new Set(getAwarenessIds(conn));
|
|
163
|
+
for (const clientID of added) currentIds.add(clientID);
|
|
164
|
+
for (const clientID of removed) currentIds.delete(clientID);
|
|
165
|
+
setAwarenessIds(conn, [...currentIds]);
|
|
166
|
+
} catch (_e) {}
|
|
167
|
+
else {
|
|
168
|
+
const changedClients = added.concat(updated, removed);
|
|
169
|
+
const encoder = encoding.createEncoder();
|
|
170
|
+
encoding.writeVarUint(encoder, messageAwareness);
|
|
171
|
+
encoding.writeVarUint8Array(
|
|
172
|
+
encoder,
|
|
173
|
+
awarenessProtocol.encodeAwarenessUpdate(
|
|
174
|
+
this.document.awareness,
|
|
175
|
+
changedClients
|
|
176
|
+
)
|
|
177
|
+
);
|
|
178
|
+
const buff = encoding.toUint8Array(encoder);
|
|
179
|
+
for (const c of this.getConnections()) send(c, buff);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
const ctor = this.constructor;
|
|
184
|
+
this.document.on(
|
|
185
|
+
"update",
|
|
186
|
+
debounce(
|
|
187
|
+
(_update, _origin, _doc) => {
|
|
188
|
+
try {
|
|
189
|
+
this.onSave().catch((err) => {
|
|
190
|
+
console.error("failed to persist:", err);
|
|
191
|
+
});
|
|
192
|
+
} catch (err) {
|
|
193
|
+
console.error("failed to persist:", err);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
ctor.callbackOptions.debounceWait || CALLBACK_DEFAULTS.debounceWait,
|
|
197
|
+
{
|
|
198
|
+
maxWait:
|
|
199
|
+
ctor.callbackOptions.debounceMaxWait ||
|
|
200
|
+
CALLBACK_DEFAULTS.debounceMaxWait
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
const syncEncoder = encoding.createEncoder();
|
|
205
|
+
encoding.writeVarUint(syncEncoder, messageSync);
|
|
206
|
+
syncProtocol.writeSyncStep1(syncEncoder, this.document);
|
|
207
|
+
const syncMessage = encoding.toUint8Array(syncEncoder);
|
|
208
|
+
for (const conn of this.getConnections()) send(conn, syncMessage);
|
|
209
|
+
}
|
|
210
|
+
isReadOnly(connection) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Handle custom string messages from the client.
|
|
215
|
+
* Override this method to implement custom message handling.
|
|
216
|
+
* @param connection - The connection that sent the message
|
|
217
|
+
* @param message - The custom message string (without the __YPS: prefix)
|
|
218
|
+
*/
|
|
219
|
+
onCustomMessage(connection, message) {
|
|
220
|
+
console.warn(
|
|
221
|
+
`Received custom message but onCustomMessage is not implemented in ${this.constructor.name}:`,
|
|
222
|
+
message
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Send a custom string message to a specific connection.
|
|
227
|
+
* @param connection - The connection to send the message to
|
|
228
|
+
* @param message - The custom message string to send
|
|
229
|
+
*/
|
|
230
|
+
sendCustomMessage(connection, message) {
|
|
231
|
+
if (
|
|
232
|
+
connection.readyState !== void 0 &&
|
|
233
|
+
connection.readyState !== wsReadyStateConnecting &&
|
|
234
|
+
connection.readyState !== wsReadyStateOpen
|
|
235
|
+
)
|
|
236
|
+
return;
|
|
237
|
+
try {
|
|
238
|
+
connection.send(`__YPS:${message}`);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
console.warn("Failed to send custom message", e);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Broadcast a custom string message to all connected clients.
|
|
245
|
+
* @param message - The custom message string to broadcast
|
|
246
|
+
* @param excludeConnection - Optional connection to exclude from the broadcast
|
|
247
|
+
*/
|
|
248
|
+
broadcastCustomMessage(message, excludeConnection) {
|
|
249
|
+
const formattedMessage = `__YPS:${message}`;
|
|
250
|
+
for (const conn of this.getConnections()) {
|
|
251
|
+
if (excludeConnection && conn === excludeConnection) continue;
|
|
252
|
+
if (
|
|
253
|
+
conn.readyState !== void 0 &&
|
|
254
|
+
conn.readyState !== wsReadyStateConnecting &&
|
|
255
|
+
conn.readyState !== wsReadyStateOpen
|
|
256
|
+
)
|
|
257
|
+
continue;
|
|
258
|
+
try {
|
|
259
|
+
conn.send(formattedMessage);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
console.warn("Failed to broadcast custom message", e);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
handleMessage(connection, message) {
|
|
266
|
+
if (typeof message === "string") {
|
|
267
|
+
if (message.startsWith("__YPS:")) {
|
|
268
|
+
const customMessage = message.slice(6);
|
|
269
|
+
this.onCustomMessage(connection, customMessage);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
console.warn(
|
|
273
|
+
`Received non-prefixed string message. Custom messages should be sent using sendMessage() on the provider.`
|
|
274
|
+
);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
const encoder = encoding.createEncoder();
|
|
279
|
+
const uint8Array =
|
|
280
|
+
message instanceof Uint8Array
|
|
281
|
+
? message
|
|
282
|
+
: message instanceof ArrayBuffer
|
|
283
|
+
? new Uint8Array(message)
|
|
284
|
+
: new Uint8Array(
|
|
285
|
+
message.buffer,
|
|
286
|
+
message.byteOffset,
|
|
287
|
+
message.byteLength
|
|
288
|
+
);
|
|
289
|
+
const decoder = decoding.createDecoder(uint8Array);
|
|
290
|
+
switch (decoding.readVarUint(decoder)) {
|
|
291
|
+
case messageSync:
|
|
292
|
+
encoding.writeVarUint(encoder, messageSync);
|
|
293
|
+
readSyncMessage(
|
|
294
|
+
decoder,
|
|
295
|
+
encoder,
|
|
296
|
+
this.document,
|
|
297
|
+
connection,
|
|
298
|
+
this.isReadOnly(connection)
|
|
299
|
+
);
|
|
300
|
+
if (encoding.length(encoder) > 1)
|
|
301
|
+
send(connection, encoding.toUint8Array(encoder));
|
|
302
|
+
break;
|
|
303
|
+
case messageAwareness: {
|
|
304
|
+
const awarenessData = decoding.readVarUint8Array(decoder);
|
|
305
|
+
awarenessProtocol.applyAwarenessUpdate(
|
|
306
|
+
this.document.awareness,
|
|
307
|
+
awarenessData,
|
|
308
|
+
connection
|
|
309
|
+
);
|
|
310
|
+
const awarenessEncoder = encoding.createEncoder();
|
|
311
|
+
encoding.writeVarUint(awarenessEncoder, messageAwareness);
|
|
312
|
+
encoding.writeVarUint8Array(awarenessEncoder, awarenessData);
|
|
313
|
+
const awarenessBuff = encoding.toUint8Array(awarenessEncoder);
|
|
314
|
+
for (const c of this.getConnections()) send(c, awarenessBuff);
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
} catch (err) {
|
|
319
|
+
console.error(err);
|
|
320
|
+
this.document.emit("error", [err]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
onMessage(conn, message) {
|
|
324
|
+
this.handleMessage(conn, message);
|
|
325
|
+
}
|
|
326
|
+
onClose(connection, _code, _reason, _wasClean) {
|
|
327
|
+
const controlledIds = getAwarenessIds(connection);
|
|
328
|
+
if (controlledIds.length > 0)
|
|
329
|
+
awarenessProtocol.removeAwarenessStates(
|
|
330
|
+
this.document.awareness,
|
|
331
|
+
controlledIds,
|
|
332
|
+
null
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
onConnect(conn, _ctx) {
|
|
336
|
+
const encoder = encoding.createEncoder();
|
|
337
|
+
encoding.writeVarUint(encoder, messageSync);
|
|
338
|
+
syncProtocol.writeSyncStep1(encoder, this.document);
|
|
339
|
+
send(conn, encoding.toUint8Array(encoder));
|
|
340
|
+
const awarenessStates = this.document.awareness.getStates();
|
|
341
|
+
if (awarenessStates.size > 0) {
|
|
342
|
+
const encoder = encoding.createEncoder();
|
|
343
|
+
encoding.writeVarUint(encoder, messageAwareness);
|
|
344
|
+
encoding.writeVarUint8Array(
|
|
345
|
+
encoder,
|
|
346
|
+
awarenessProtocol.encodeAwarenessUpdate(
|
|
347
|
+
this.document.awareness,
|
|
348
|
+
Array.from(awarenessStates.keys())
|
|
349
|
+
)
|
|
350
|
+
);
|
|
351
|
+
send(conn, encoding.toUint8Array(encoder));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return YjsMixin;
|
|
356
|
+
}
|
|
357
|
+
const YServer = withYjs(Server);
|
|
252
358
|
|
|
253
359
|
//#endregion
|
|
254
|
-
export { YServer };
|
|
255
|
-
//# sourceMappingURL=index.js.map
|
|
360
|
+
export { YServer, withYjs };
|
|
361
|
+
//# sourceMappingURL=index.js.map
|