playsocketjs 4.1.0 → 4.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playsocketjs",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "WebSocket wrapper for creating simple multiplayer systems with ease.",
5
5
  "type": "module",
6
6
  "module": "./src/client/client.js",
@@ -436,12 +436,14 @@ export default class CRDTManager {
436
436
  * @returns {*} - Sanitized value
437
437
  */
438
438
  #sanitizeValue(value) {
439
+ if (value === undefined) return null; // Normalize undefined to null to avoid divergence in transport
440
+
439
441
  // Check total serialized size
440
442
  const jsonString = JSON.stringify(value);
441
443
  if (jsonString?.length > 50000) throw new Error("Value too large!"); // 50KB limit
442
444
 
443
445
  if (typeof value === "string") return (value.includes("<") || value.includes(">")) ? value.replace(/[<>]/g, "") : value;
444
- if (Array.isArray(value)) return value.map(item => this.#sanitizeValue(item));
446
+ if (Array.isArray(value)) return Array.from(value, item => this.#sanitizeValue(item));
445
447
  if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, this.#sanitizeValue(v)]));
446
448
  return value;
447
449
  }