playsocketjs 4.2.0 → 4.2.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.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "WebSocket wrapper for creating simple multiplayer systems with ease.",
5
5
  "type": "module",
6
6
  "module": "./src/client/client.js",
@@ -1,6 +1,6 @@
1
1
  import { encode, decode } from "@msgpack/msgpack";
2
2
  import CRDTManager from "../universal/crdtManager.js";
3
- import packageData from "../../package.json" with { type: "json" };
3
+ import { VERSION } from "../universal/constants.js";
4
4
 
5
5
  const ERROR_PREFIX = "PlaySocket error: ";
6
6
  const WARNING_PREFIX = "PlaySocket warning: ";
@@ -161,7 +161,7 @@ export default class PlaySocket {
161
161
  this.#sendToServer({
162
162
  type: "register",
163
163
  id: this.#id,
164
- version: packageData.version,
164
+ version: VERSION,
165
165
  customData: this.#customData || undefined
166
166
  });
167
167
  }),
@@ -2,8 +2,7 @@ import { WebSocketServer } from "ws";
2
2
  import { createServer } from "node:http";
3
3
  import { encode, decode } from "@msgpack/msgpack";
4
4
  import CRDTManager, { getUpdateDetails } from "../universal/crdtManager.js";
5
- import packageData from "../../package.json" with { type: "json" };
6
- import { HEARTBEAT_INTERVAL } from "../universal/constants.js";
5
+ import { HEARTBEAT_INTERVAL, VERSION } from "../universal/constants.js";
7
6
 
8
7
  const MAX_ROOM_SIZE = 500;
9
8
  export const RECONNECT_GRACE_PERIOD = 5000; // Exported for use in tests
@@ -147,8 +146,8 @@ export default class PlaySocketServer {
147
146
  switch (data.type) {
148
147
  case "register": {
149
148
  // Ensure client uses the same version as server
150
- if (data.version !== packageData.version) {
151
- ws.send(encode({ type: "registration_failed", reason: `Version mismatch (client ${data.version ? "v" + data.version : "legacy"}, server v${packageData.version}). Please reload the page, an update may have been released.` }), { binary: true });
149
+ if (data.version !== VERSION) {
150
+ ws.send(encode({ type: "registration_failed", reason: `Version mismatch (client ${data.version ? "v" + data.version : "legacy"}, server v${VERSION}). Please reload the page, an update may have been released.` }), { binary: true });
152
151
  return;
153
152
  }
154
153
 
@@ -5,3 +5,8 @@
5
5
  * be desynced as a result of gc
6
6
  */
7
7
  export const HEARTBEAT_INTERVAL = 5000;
8
+
9
+ /**
10
+ * Library version, must match package.json
11
+ */
12
+ export const VERSION = "4.2.1";
@@ -5,3 +5,7 @@
5
5
  * be desynced as a result of gc
6
6
  */
7
7
  export declare const HEARTBEAT_INTERVAL = 5000;
8
+ /**
9
+ * Library version, must match package.json
10
+ */
11
+ export declare const VERSION = "4.2.1";