@meshagent/meshagent 0.2.0 → 0.3.0
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/CHANGELOG.md
CHANGED
|
@@ -6237,7 +6237,6 @@ var ClientProtocol = class {
|
|
|
6237
6237
|
var protocols = new Map();
|
|
6238
6238
|
var documents = new Map();
|
|
6239
6239
|
function applyChanges(update) {
|
|
6240
|
-
console.log("applying", JSON.stringify(update.changes));
|
|
6241
6240
|
const server = documents.get(update.documentID);
|
|
6242
6241
|
if (!server) {
|
|
6243
6242
|
throw new Error("cannot apply changes, document was not registered " + update.documentID);
|
|
@@ -6273,14 +6272,11 @@ function applyBackendChanges(documentID, base64Changes) {
|
|
|
6273
6272
|
if (!server) {
|
|
6274
6273
|
throw new Error("cannot apply changes, document was not registered " + documentID);
|
|
6275
6274
|
}
|
|
6276
|
-
console.log("applying", JSON.stringify(base64Changes));
|
|
6277
6275
|
const buffer = Uint8Array.from(import_base_64.default.decode(base64Changes), (c) => c.charCodeAt(0));
|
|
6278
|
-
console.log("applying", Array.from(buffer));
|
|
6279
6276
|
server.applyBackendChanges(buffer);
|
|
6280
6277
|
const protocol = protocols.get(documentID);
|
|
6281
6278
|
if (protocol) {
|
|
6282
6279
|
const xmlRoot = protocol.doc.get("xml", YXmlElement);
|
|
6283
|
-
console.log(xmlRoot.toString());
|
|
6284
6280
|
}
|
|
6285
6281
|
}
|
|
6286
6282
|
function registerDocument(id2, base64Data, undo = false, sendUpdateToBackend, sendUpdateToClient) {
|
package/dist/browser/protocol.js
CHANGED
|
@@ -167,7 +167,6 @@ class Protocol {
|
|
|
167
167
|
delete this.handlers[type];
|
|
168
168
|
}
|
|
169
169
|
async handleMessage(messageId, type, data) {
|
|
170
|
-
console.log(this.handlers, Object.keys(this.handlers));
|
|
171
170
|
const handler = this.handlers[type] ?? this.handlers["*"];
|
|
172
171
|
await handler(this, messageId, type, data);
|
|
173
172
|
}
|
|
@@ -192,7 +191,6 @@ class Protocol {
|
|
|
192
191
|
this._iterator = this._send.stream();
|
|
193
192
|
for await (const message of this._iterator) {
|
|
194
193
|
if (message) {
|
|
195
|
-
console.log(`message recv on protocol ${message.id} ${message.type}`);
|
|
196
194
|
const packets = Math.ceil((message.data.length / 1024));
|
|
197
195
|
const header = new Uint8Array(4 * 4);
|
|
198
196
|
const dataView = new DataView(header.buffer);
|
|
@@ -212,10 +210,8 @@ class Protocol {
|
|
|
212
210
|
await this.channel.sendData(packet);
|
|
213
211
|
}
|
|
214
212
|
message.sent.resolve();
|
|
215
|
-
console.log(`message sent on protocol ${message.id} ${message.type}`);
|
|
216
213
|
}
|
|
217
214
|
}
|
|
218
|
-
console.log("protocol done");
|
|
219
215
|
})();
|
|
220
216
|
}
|
|
221
217
|
dispose() {
|
|
@@ -229,15 +225,12 @@ class Protocol {
|
|
|
229
225
|
const packet = dataView.getUint32(8, false);
|
|
230
226
|
if (packet != this._recvPacketId) {
|
|
231
227
|
this._recvState = "error";
|
|
232
|
-
console.log(dataPacket);
|
|
233
|
-
console.log(`received out of order packet got ${packet} expected ${this._recvPacketId}, total ${this._recvPacketTotal} message ID: ${messageId}`);
|
|
234
228
|
}
|
|
235
229
|
if (packet == 0) {
|
|
236
230
|
if (this._recvState == "ready" || this._recvState == "error") {
|
|
237
231
|
this._recvPacketTotal = dataView.getUint32(12, false);
|
|
238
232
|
this._recvMessageId = messageId;
|
|
239
233
|
this._recvType = utils_1.decoder.decode(dataPacket.subarray(16));
|
|
240
|
-
console.log(`recieved packet ${this._recvType}`);
|
|
241
234
|
if (this._recvPacketTotal == 0) {
|
|
242
235
|
try {
|
|
243
236
|
const merged = (0, utils_1.mergeUint8Arrays)(...this._recvPackets);
|
|
@@ -245,7 +238,6 @@ class Protocol {
|
|
|
245
238
|
this.handleMessage(messageId, this._recvType, merged);
|
|
246
239
|
}
|
|
247
240
|
finally {
|
|
248
|
-
console.log("expecting packet reset to 0");
|
|
249
241
|
this._recvState = "ready";
|
|
250
242
|
this._recvPacketId = 0;
|
|
251
243
|
this._recvType = "";
|
|
@@ -254,26 +246,22 @@ class Protocol {
|
|
|
254
246
|
}
|
|
255
247
|
else {
|
|
256
248
|
this._recvPacketId += 1;
|
|
257
|
-
console.log(`expecting packet ${this._recvPacketId}`);
|
|
258
249
|
this._recvState = "processing";
|
|
259
250
|
}
|
|
260
251
|
}
|
|
261
252
|
else {
|
|
262
253
|
this._recvState = "error";
|
|
263
254
|
this._recvPacketId = 0;
|
|
264
|
-
console.log("received packet 0 in invalid state");
|
|
265
255
|
}
|
|
266
256
|
}
|
|
267
257
|
else if (this._recvState != "processing") {
|
|
268
258
|
this._recvState = "error";
|
|
269
259
|
this._recvPacketId = 0;
|
|
270
|
-
console.log("received datapacket in invalid state");
|
|
271
260
|
}
|
|
272
261
|
else {
|
|
273
262
|
if (messageId != this._recvMessageId) {
|
|
274
263
|
this._recvState = "error";
|
|
275
264
|
this._recvPacketId = 0;
|
|
276
|
-
console.log("received packet from incorrect message");
|
|
277
265
|
}
|
|
278
266
|
this._recvPackets.push(dataPacket.subarray(12));
|
|
279
267
|
if (this._recvPacketTotal == this._recvPacketId) {
|
|
@@ -29,7 +29,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
29
29
|
this.client.protocol.start();
|
|
30
30
|
(async () => {
|
|
31
31
|
for await (const message of this._changesToSync.stream) {
|
|
32
|
-
console.log(`sending changes to backend ${message.base64}`);
|
|
33
32
|
await this.client.sendRequest("room.sync", { path: message.path }, utils_1.encoder.encode(message.base64));
|
|
34
33
|
}
|
|
35
34
|
})();
|
|
@@ -39,7 +38,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
39
38
|
this._changesToSync.close();
|
|
40
39
|
}
|
|
41
40
|
async _handleSync(protocol, messageId, data, bytes) {
|
|
42
|
-
console.log("GOT SYNC");
|
|
43
41
|
const headerStr = (0, utils_1.splitMessageHeader)(bytes || new Uint8Array());
|
|
44
42
|
const payload = (0, utils_1.splitMessagePayload)(bytes || new Uint8Array());
|
|
45
43
|
const header = JSON.parse(headerStr);
|
|
@@ -52,7 +50,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
52
50
|
const rc = this._connectedDocuments[path];
|
|
53
51
|
const doc = rc.ref;
|
|
54
52
|
const base64 = utils_1.decoder.decode(payload);
|
|
55
|
-
console.log(`GOT SYNC ${base64}`);
|
|
56
53
|
(0, runtime_1.applyBackendChanges)(doc.id, base64);
|
|
57
54
|
this.emit("synced", { type: "sync", doc });
|
|
58
55
|
if (!doc.isSynchronized) {
|
|
@@ -81,7 +78,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
81
78
|
try {
|
|
82
79
|
const result = (await this.client.sendRequest("room.connect", { path, create }));
|
|
83
80
|
const schema = schema_1.MeshSchema.fromJson(result.json["schema"]);
|
|
84
|
-
console.log(JSON.stringify(schema.toJson()));
|
|
85
81
|
const doc = new room_server_client_1.MeshDocument({
|
|
86
82
|
schema,
|
|
87
83
|
sendChangesToBackend: (base64Str) => {
|
package/dist/node/entrypoint.js
CHANGED
|
@@ -6237,7 +6237,6 @@ var ClientProtocol = class {
|
|
|
6237
6237
|
var protocols = new Map();
|
|
6238
6238
|
var documents = new Map();
|
|
6239
6239
|
function applyChanges(update) {
|
|
6240
|
-
console.log("applying", JSON.stringify(update.changes));
|
|
6241
6240
|
const server = documents.get(update.documentID);
|
|
6242
6241
|
if (!server) {
|
|
6243
6242
|
throw new Error("cannot apply changes, document was not registered " + update.documentID);
|
|
@@ -6273,14 +6272,11 @@ function applyBackendChanges(documentID, base64Changes) {
|
|
|
6273
6272
|
if (!server) {
|
|
6274
6273
|
throw new Error("cannot apply changes, document was not registered " + documentID);
|
|
6275
6274
|
}
|
|
6276
|
-
console.log("applying", JSON.stringify(base64Changes));
|
|
6277
6275
|
const buffer = Uint8Array.from(import_base_64.default.decode(base64Changes), (c) => c.charCodeAt(0));
|
|
6278
|
-
console.log("applying", Array.from(buffer));
|
|
6279
6276
|
server.applyBackendChanges(buffer);
|
|
6280
6277
|
const protocol = protocols.get(documentID);
|
|
6281
6278
|
if (protocol) {
|
|
6282
6279
|
const xmlRoot = protocol.doc.get("xml", YXmlElement);
|
|
6283
|
-
console.log(xmlRoot.toString());
|
|
6284
6280
|
}
|
|
6285
6281
|
}
|
|
6286
6282
|
function registerDocument(id2, base64Data, undo = false, sendUpdateToBackend, sendUpdateToClient) {
|
package/dist/node/protocol.js
CHANGED
|
@@ -167,7 +167,6 @@ class Protocol {
|
|
|
167
167
|
delete this.handlers[type];
|
|
168
168
|
}
|
|
169
169
|
async handleMessage(messageId, type, data) {
|
|
170
|
-
console.log(this.handlers, Object.keys(this.handlers));
|
|
171
170
|
const handler = this.handlers[type] ?? this.handlers["*"];
|
|
172
171
|
await handler(this, messageId, type, data);
|
|
173
172
|
}
|
|
@@ -192,7 +191,6 @@ class Protocol {
|
|
|
192
191
|
this._iterator = this._send.stream();
|
|
193
192
|
for await (const message of this._iterator) {
|
|
194
193
|
if (message) {
|
|
195
|
-
console.log(`message recv on protocol ${message.id} ${message.type}`);
|
|
196
194
|
const packets = Math.ceil((message.data.length / 1024));
|
|
197
195
|
const header = new Uint8Array(4 * 4);
|
|
198
196
|
const dataView = new DataView(header.buffer);
|
|
@@ -212,10 +210,8 @@ class Protocol {
|
|
|
212
210
|
await this.channel.sendData(packet);
|
|
213
211
|
}
|
|
214
212
|
message.sent.resolve();
|
|
215
|
-
console.log(`message sent on protocol ${message.id} ${message.type}`);
|
|
216
213
|
}
|
|
217
214
|
}
|
|
218
|
-
console.log("protocol done");
|
|
219
215
|
})();
|
|
220
216
|
}
|
|
221
217
|
dispose() {
|
|
@@ -229,15 +225,12 @@ class Protocol {
|
|
|
229
225
|
const packet = dataView.getUint32(8, false);
|
|
230
226
|
if (packet != this._recvPacketId) {
|
|
231
227
|
this._recvState = "error";
|
|
232
|
-
console.log(dataPacket);
|
|
233
|
-
console.log(`received out of order packet got ${packet} expected ${this._recvPacketId}, total ${this._recvPacketTotal} message ID: ${messageId}`);
|
|
234
228
|
}
|
|
235
229
|
if (packet == 0) {
|
|
236
230
|
if (this._recvState == "ready" || this._recvState == "error") {
|
|
237
231
|
this._recvPacketTotal = dataView.getUint32(12, false);
|
|
238
232
|
this._recvMessageId = messageId;
|
|
239
233
|
this._recvType = utils_1.decoder.decode(dataPacket.subarray(16));
|
|
240
|
-
console.log(`recieved packet ${this._recvType}`);
|
|
241
234
|
if (this._recvPacketTotal == 0) {
|
|
242
235
|
try {
|
|
243
236
|
const merged = (0, utils_1.mergeUint8Arrays)(...this._recvPackets);
|
|
@@ -245,7 +238,6 @@ class Protocol {
|
|
|
245
238
|
this.handleMessage(messageId, this._recvType, merged);
|
|
246
239
|
}
|
|
247
240
|
finally {
|
|
248
|
-
console.log("expecting packet reset to 0");
|
|
249
241
|
this._recvState = "ready";
|
|
250
242
|
this._recvPacketId = 0;
|
|
251
243
|
this._recvType = "";
|
|
@@ -254,26 +246,22 @@ class Protocol {
|
|
|
254
246
|
}
|
|
255
247
|
else {
|
|
256
248
|
this._recvPacketId += 1;
|
|
257
|
-
console.log(`expecting packet ${this._recvPacketId}`);
|
|
258
249
|
this._recvState = "processing";
|
|
259
250
|
}
|
|
260
251
|
}
|
|
261
252
|
else {
|
|
262
253
|
this._recvState = "error";
|
|
263
254
|
this._recvPacketId = 0;
|
|
264
|
-
console.log("received packet 0 in invalid state");
|
|
265
255
|
}
|
|
266
256
|
}
|
|
267
257
|
else if (this._recvState != "processing") {
|
|
268
258
|
this._recvState = "error";
|
|
269
259
|
this._recvPacketId = 0;
|
|
270
|
-
console.log("received datapacket in invalid state");
|
|
271
260
|
}
|
|
272
261
|
else {
|
|
273
262
|
if (messageId != this._recvMessageId) {
|
|
274
263
|
this._recvState = "error";
|
|
275
264
|
this._recvPacketId = 0;
|
|
276
|
-
console.log("received packet from incorrect message");
|
|
277
265
|
}
|
|
278
266
|
this._recvPackets.push(dataPacket.subarray(12));
|
|
279
267
|
if (this._recvPacketTotal == this._recvPacketId) {
|
package/dist/node/sync-client.js
CHANGED
|
@@ -29,7 +29,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
29
29
|
this.client.protocol.start();
|
|
30
30
|
(async () => {
|
|
31
31
|
for await (const message of this._changesToSync.stream) {
|
|
32
|
-
console.log(`sending changes to backend ${message.base64}`);
|
|
33
32
|
await this.client.sendRequest("room.sync", { path: message.path }, utils_1.encoder.encode(message.base64));
|
|
34
33
|
}
|
|
35
34
|
})();
|
|
@@ -39,7 +38,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
39
38
|
this._changesToSync.close();
|
|
40
39
|
}
|
|
41
40
|
async _handleSync(protocol, messageId, data, bytes) {
|
|
42
|
-
console.log("GOT SYNC");
|
|
43
41
|
const headerStr = (0, utils_1.splitMessageHeader)(bytes || new Uint8Array());
|
|
44
42
|
const payload = (0, utils_1.splitMessagePayload)(bytes || new Uint8Array());
|
|
45
43
|
const header = JSON.parse(headerStr);
|
|
@@ -52,7 +50,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
52
50
|
const rc = this._connectedDocuments[path];
|
|
53
51
|
const doc = rc.ref;
|
|
54
52
|
const base64 = utils_1.decoder.decode(payload);
|
|
55
|
-
console.log(`GOT SYNC ${base64}`);
|
|
56
53
|
(0, runtime_1.applyBackendChanges)(doc.id, base64);
|
|
57
54
|
this.emit("synced", { type: "sync", doc });
|
|
58
55
|
if (!doc.isSynchronized) {
|
|
@@ -81,7 +78,6 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
81
78
|
try {
|
|
82
79
|
const result = (await this.client.sendRequest("room.connect", { path, create }));
|
|
83
80
|
const schema = schema_1.MeshSchema.fromJson(result.json["schema"]);
|
|
84
|
-
console.log(JSON.stringify(schema.toJson()));
|
|
85
81
|
const doc = new room_server_client_1.MeshDocument({
|
|
86
82
|
schema,
|
|
87
83
|
sendChangesToBackend: (base64Str) => {
|