playsocketjs 1.1.5 → 1.1.6

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.
@@ -1735,7 +1735,7 @@ function requireCrdtManager () {
1735
1735
  this.#vectorClock = new Map(vectorClock); // Rebuild the vector clock map
1736
1736
  if (!this.#vectorClock.has(this.#replicaId)) this.#vectorClock.set(this.#replicaId, 0); // Add own vector clock if it wasn't present in the imported state
1737
1737
 
1738
- // Map operation uuids to timestamp
1738
+ // Map all operation uuids to current timestamp
1739
1739
  this.#keyOperations.forEach((value, key) => {
1740
1740
  value?.forEach((operation) => {
1741
1741
  this.#opUuidTimestamp.set(operation?.uuid, Date.now());
@@ -2279,7 +2279,7 @@ class PlaySocket {
2279
2279
  }
2280
2280
  break;
2281
2281
 
2282
- case 'property_update':
2282
+ case 'property_updated':
2283
2283
  this.#roomVersion++; // Increment room version
2284
2284
  if (this.#debug) console.log(LOG_PREFIX + "Property update received:", message.update);
2285
2285
  this.#crdtManager.importPropertyUpdate(message.update);
@@ -2456,8 +2456,7 @@ class PlaySocket {
2456
2456
  if (this.#debug) console.log(LOG_PREFIX + "Property set update for key '" + key + "':", value);
2457
2457
  const propUpdate = this.#crdtManager.updateProperty(key, "set", value);
2458
2458
  this.#sendToServer({
2459
- type: 'property_update',
2460
- key,
2459
+ type: 'update_property',
2461
2460
  update: propUpdate
2462
2461
  });
2463
2462
  if (this.#crdtManager.didPropertiesChange) this.#triggerEvent("storageUpdated", this.getStorage); // Always trigger callback after send in case msgs are sent in the callback (which would break the order)
@@ -2474,8 +2473,7 @@ class PlaySocket {
2474
2473
  if (this.#debug) console.log(LOG_PREFIX + `Property array update for key '${key}', operation '${operation}', value '${value}' and updateValue '${updateValue}'.`);
2475
2474
  const propUpdate = this.#crdtManager.updateProperty(key, "array-" + operation, value, updateValue);
2476
2475
  this.#sendToServer({
2477
- type: 'property_update',
2478
- key,
2476
+ type: 'update_property',
2479
2477
  update: propUpdate
2480
2478
  });
2481
2479
  if (this.#crdtManager.didPropertiesChange) this.#triggerEvent("storageUpdated", this.getStorage);
@@ -1861,7 +1861,7 @@ function requireCrdtManager () {
1861
1861
  this.#vectorClock = new Map(vectorClock); // Rebuild the vector clock map
1862
1862
  if (!this.#vectorClock.has(this.#replicaId)) this.#vectorClock.set(this.#replicaId, 0); // Add own vector clock if it wasn't present in the imported state
1863
1863
 
1864
- // Map operation uuids to timestamp
1864
+ // Map all operation uuids to current timestamp
1865
1865
  this.#keyOperations.forEach((value, key) => {
1866
1866
  value?.forEach((operation) => {
1867
1867
  this.#opUuidTimestamp.set(operation?.uuid, Date.now());
@@ -2384,11 +2384,11 @@ function requireServer () {
2384
2384
  this.#triggerEvent("roomJoined", ws.clientId, roomId);
2385
2385
  break;
2386
2386
 
2387
- case 'property_update':
2387
+ case 'update_property':
2388
2388
  const updateRoomId = this.#clientRooms.get(ws.clientId);
2389
2389
  const updateRoom = updateRoomId ? this.#rooms[updateRoomId] : null;
2390
2390
 
2391
- if (updateRoom && data.key && data.update) {
2391
+ if (updateRoom && data.update) {
2392
2392
  updateRoom.crdtManager.importPropertyUpdate(data.update);
2393
2393
 
2394
2394
  // Increment version for this room
@@ -2400,7 +2400,7 @@ function requireServer () {
2400
2400
  const client = this.#clients.get(p);
2401
2401
  if (client) {
2402
2402
  client.send(encode({
2403
- type: 'property_update',
2403
+ type: 'property_updated',
2404
2404
  update: data.update,
2405
2405
  version: currentVersion
2406
2406
  }), { binary: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playsocketjs",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "WebSocket wrapper for creating simple multiplayer systems with ease.",
5
5
  "module": "dist/playsocket-client.js",
6
6
  "exports": {