playsocketjs 1.1.1 → 1.1.3

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.
@@ -1774,9 +1774,9 @@ function requireCrdtManager () {
1774
1774
 
1775
1775
  // Add new operation if it's not already added
1776
1776
  const existingUuids = new Set(currentOps.map(op => op.uuid));
1777
- if (operation?.uuid && !existingUuids.has(operation.uuid)) {
1777
+ if (operation.uuid && !existingUuids.has(operation.uuid)) {
1778
1778
  currentOps.push({ ...operation }); // Add operation
1779
- this.#opUuidTimestamp.set(operation?.uuid, Date.now()); // Add timestamp for gc
1779
+ this.#opUuidTimestamp.set(operation.uuid, Date.now()); // Add timestamp for gc
1780
1780
  }
1781
1781
 
1782
1782
  // Sort, update operations & local value
@@ -1785,7 +1785,7 @@ function requireCrdtManager () {
1785
1785
  this.#checkGarbageCollection();
1786
1786
 
1787
1787
  } catch (error) {
1788
- console.error(CONSOLE_PREFIX + "Failed to import property:", error);
1788
+ console.error(CONSOLE_PREFIX + "Failed to import property update:", error);
1789
1789
  }
1790
1790
  }
1791
1791
 
@@ -2377,9 +2377,9 @@ class PlaySocket {
2377
2377
  async #requestStateSync() {
2378
2378
  if (this.#pendingStateRequest) return; // Return if already requested
2379
2379
  try {
2380
- Promise.race([
2381
- new Promise(async (resolve) => {
2382
- this.#pendingStateRequest = { resolve };
2380
+ await Promise.race([
2381
+ new Promise(async (resolve, reject) => {
2382
+ this.#pendingStateRequest = { resolve, reject };
2383
2383
  this.#sendToServer({ type: 'request_state' });
2384
2384
  }),
2385
2385
  this.#createTimeout("State request")
@@ -2411,7 +2411,7 @@ class PlaySocket {
2411
2411
  */
2412
2412
  #sendToServer(data) {
2413
2413
  if (!this.#socket || this.#socket.readyState !== WebSocket.OPEN) {
2414
- return console.error(ERROR_PREFIX + "Cannot send message - not connected.");
2414
+ return console.warn(WARNING_PREFIX + "Cannot send message - not connected.");
2415
2415
  }
2416
2416
  try {
2417
2417
  this.#socket.send(encode(data));
@@ -1900,9 +1900,9 @@ function requireCrdtManager () {
1900
1900
 
1901
1901
  // Add new operation if it's not already added
1902
1902
  const existingUuids = new Set(currentOps.map(op => op.uuid));
1903
- if (operation?.uuid && !existingUuids.has(operation.uuid)) {
1903
+ if (operation.uuid && !existingUuids.has(operation.uuid)) {
1904
1904
  currentOps.push({ ...operation }); // Add operation
1905
- this.#opUuidTimestamp.set(operation?.uuid, Date.now()); // Add timestamp for gc
1905
+ this.#opUuidTimestamp.set(operation.uuid, Date.now()); // Add timestamp for gc
1906
1906
  }
1907
1907
 
1908
1908
  // Sort, update operations & local value
@@ -1911,7 +1911,7 @@ function requireCrdtManager () {
1911
1911
  this.#checkGarbageCollection();
1912
1912
 
1913
1913
  } catch (error) {
1914
- console.error(CONSOLE_PREFIX + "Failed to import property:", error);
1914
+ console.error(CONSOLE_PREFIX + "Failed to import property update:", error);
1915
1915
  }
1916
1916
  }
1917
1917
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playsocketjs",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "WebSocket wrapper for creating simple multiplayer systems with ease.",
5
5
  "module": "dist/playsocket-client.js",
6
6
  "exports": {