@pluv/io 0.21.1 → 0.22.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.
@@ -1,9 +1,9 @@
1
1
 
2
- > @pluv/io@0.21.1 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.22.0 build /home/runner/work/pluv/pluv/packages/io
3
3
  > pnpm run version && tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
 
6
- > @pluv/io@0.21.1 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@0.22.0 version /home/runner/work/pluv/pluv/packages/io
7
7
  > genversion ./src/version.generated.ts --esm
8
8
 
9
9
  CLI Building entry: src/index.ts
@@ -12,11 +12,11 @@
12
12
  CLI Target: es6
13
13
  ESM Build start
14
14
  CJS Build start
15
- CJS dist/index.js 39.55 KB
16
- CJS ⚡️ Build success in 160ms
17
- ESM dist/index.mjs 37.39 KB
18
- ESM ⚡️ Build success in 162ms
15
+ ESM dist/index.mjs 37.62 KB
16
+ ESM ⚡️ Build success in 125ms
17
+ CJS dist/index.js 39.79 KB
18
+ CJS ⚡️ Build success in 126ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2389ms
21
- DTS dist/index.d.mts 23.50 KB
22
- DTS dist/index.d.ts 23.50 KB
20
+ DTS ⚡️ Build success in 2342ms
21
+ DTS dist/index.d.mts 23.57 KB
22
+ DTS dist/index.d.ts 23.57 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 650e577: \* Fix `@pluv/platform-cloudflare` causing frequent disconnects due to incorrect heartbeat handling.
8
+ - Updated default `mode` of `@pluv/platform-cloudflare` back to `"detached"` (i.e. use Cloudflare Worker Hibernation API by default).
9
+
10
+ ### Patch Changes
11
+
12
+ - @pluv/crdt@0.22.0
13
+ - @pluv/types@0.22.0
14
+
3
15
  ## 0.21.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -61,6 +61,7 @@ declare abstract class AbstractWebSocket<TWebSocket = any> {
61
61
  abstract get readyState(): 0 | 1 | 2 | 3;
62
62
  abstract get sessionId(): string;
63
63
  abstract get state(): WebSocketSerializedState;
64
+ abstract set state(state: WebSocketSerializedState);
64
65
  constructor(webSocket: TWebSocket, config: AbstractWebSocketConfig);
65
66
  /**
66
67
  * TODO
@@ -181,7 +182,7 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
181
182
  abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
182
183
  abstract convertWebSocket(webSocket: InferWebSocketSource<TWebSocket>, config: ConvertWebSocketConfig): AbstractWebSocket;
183
184
  abstract getLastPing(webSocket: AbstractWebSocket): number | null;
184
- abstract getSerializedState(webSocket: AbstractWebSocket): WebSocketSerializedState | null;
185
+ abstract getSerializedState(webSocket: InferWebSocketSource<TWebSocket>): WebSocketSerializedState | null;
185
186
  abstract getSessionId(webSocket: InferWebSocketSource<TWebSocket>): string | null;
186
187
  abstract getWebSockets(): readonly InferWebSocketSource<TWebSocket>[];
187
188
  abstract initialize(config: AbstractPlatformConfig<TPlatformContext, TRoomContext>): this;
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ declare abstract class AbstractWebSocket<TWebSocket = any> {
61
61
  abstract get readyState(): 0 | 1 | 2 | 3;
62
62
  abstract get sessionId(): string;
63
63
  abstract get state(): WebSocketSerializedState;
64
+ abstract set state(state: WebSocketSerializedState);
64
65
  constructor(webSocket: TWebSocket, config: AbstractWebSocketConfig);
65
66
  /**
66
67
  * TODO
@@ -181,7 +182,7 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
181
182
  abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
182
183
  abstract convertWebSocket(webSocket: InferWebSocketSource<TWebSocket>, config: ConvertWebSocketConfig): AbstractWebSocket;
183
184
  abstract getLastPing(webSocket: AbstractWebSocket): number | null;
184
- abstract getSerializedState(webSocket: AbstractWebSocket): WebSocketSerializedState | null;
185
+ abstract getSerializedState(webSocket: InferWebSocketSource<TWebSocket>): WebSocketSerializedState | null;
185
186
  abstract getSessionId(webSocket: InferWebSocketSource<TWebSocket>): string | null;
186
187
  abstract getWebSockets(): readonly InferWebSocketSource<TWebSocket>[];
187
188
  abstract initialize(config: AbstractPlatformConfig<TPlatformContext, TRoomContext>): this;
package/dist/index.js CHANGED
@@ -848,7 +848,7 @@ var IORoom = class {
848
848
  };
849
849
 
850
850
  // src/version.generated.ts
851
- var version = "0.21.1";
851
+ var version = "0.22.0";
852
852
 
853
853
  // src/PluvServer.ts
854
854
  var PluvServer = class {
@@ -945,7 +945,7 @@ var PluvServer = class {
945
945
  _purgeEmptyRooms() {
946
946
  const rooms = Array.from(this._rooms.entries());
947
947
  rooms.forEach(([id, room]) => {
948
- if (room.getSize()) return;
948
+ if (!!(room == null ? void 0 : room.getSize())) return;
949
949
  this._rooms.delete(id);
950
950
  });
951
951
  }
@@ -1007,7 +1007,12 @@ var PluvIO = class {
1007
1007
  $PING: this.procedure.self((data, { session }) => {
1008
1008
  if (!session) return {};
1009
1009
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
1010
- session.timers.ping = currentTime;
1010
+ const prevState = session.webSocket.state;
1011
+ session.webSocket.state = __spreadProps(__spreadValues({}, prevState), {
1012
+ timers: __spreadProps(__spreadValues({}, prevState.timers), {
1013
+ ping: currentTime
1014
+ })
1015
+ });
1011
1016
  return { $PONG: {} };
1012
1017
  }),
1013
1018
  $UPDATE_PRESENCE: this.procedure.broadcast((data, { session }) => {
package/dist/index.mjs CHANGED
@@ -807,7 +807,7 @@ var IORoom = class {
807
807
  };
808
808
 
809
809
  // src/version.generated.ts
810
- var version = "0.21.1";
810
+ var version = "0.22.0";
811
811
 
812
812
  // src/PluvServer.ts
813
813
  var PluvServer = class {
@@ -904,7 +904,7 @@ var PluvServer = class {
904
904
  _purgeEmptyRooms() {
905
905
  const rooms = Array.from(this._rooms.entries());
906
906
  rooms.forEach(([id, room]) => {
907
- if (room.getSize()) return;
907
+ if (!!(room == null ? void 0 : room.getSize())) return;
908
908
  this._rooms.delete(id);
909
909
  });
910
910
  }
@@ -966,7 +966,12 @@ var PluvIO = class {
966
966
  $PING: this.procedure.self((data, { session }) => {
967
967
  if (!session) return {};
968
968
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
969
- session.timers.ping = currentTime;
969
+ const prevState = session.webSocket.state;
970
+ session.webSocket.state = __spreadProps(__spreadValues({}, prevState), {
971
+ timers: __spreadProps(__spreadValues({}, prevState.timers), {
972
+ ping: currentTime
973
+ })
974
+ });
970
975
  return { $PONG: {} };
971
976
  }),
972
977
  $UPDATE_PRESENCE: this.procedure.broadcast((data, { session }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "description": "@pluv/io server-side websocket manager",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -21,16 +21,16 @@
21
21
  "jose": "^5.6.3",
22
22
  "kleur": "^4.1.5",
23
23
  "wonka": "^6.3.4",
24
- "@pluv/crdt": "^0.21.1",
25
- "@pluv/types": "^0.21.1"
24
+ "@pluv/crdt": "^0.22.0",
25
+ "@pluv/types": "^0.22.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^8.57.0",
29
29
  "genversion": "^3.2.0",
30
30
  "tsup": "^8.2.4",
31
31
  "typescript": "^5.5.4",
32
- "@pluv/tsconfig": "^0.21.1",
33
- "eslint-config-pluv": "^0.21.1"
32
+ "@pluv/tsconfig": "^0.22.0",
33
+ "eslint-config-pluv": "^0.22.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
@@ -68,7 +68,7 @@ export abstract class AbstractPlatform<
68
68
 
69
69
  public abstract getLastPing(webSocket: AbstractWebSocket): number | null;
70
70
 
71
- public abstract getSerializedState(webSocket: AbstractWebSocket): WebSocketSerializedState | null;
71
+ public abstract getSerializedState(webSocket: InferWebSocketSource<TWebSocket>): WebSocketSerializedState | null;
72
72
 
73
73
  public abstract getSessionId(webSocket: InferWebSocketSource<TWebSocket>): string | null;
74
74
 
@@ -72,6 +72,7 @@ export abstract class AbstractWebSocket<TWebSocket = any> {
72
72
  public abstract get readyState(): 0 | 1 | 2 | 3;
73
73
  public abstract get sessionId(): string;
74
74
  public abstract get state(): WebSocketSerializedState;
75
+ public abstract set state(state: WebSocketSerializedState);
75
76
 
76
77
  constructor(webSocket: TWebSocket, config: AbstractWebSocketConfig) {
77
78
  const { persistance, room } = config;
package/src/PluvIO.ts CHANGED
@@ -127,8 +127,15 @@ export class PluvIO<
127
127
  if (!session) return {};
128
128
 
129
129
  const currentTime = new Date().getTime();
130
-
131
- session.timers.ping = currentTime;
130
+ const prevState = session.webSocket.state;
131
+
132
+ session.webSocket.state = {
133
+ ...prevState,
134
+ timers: {
135
+ ...prevState.timers,
136
+ ping: currentTime,
137
+ },
138
+ };
132
139
 
133
140
  return { $PONG: {} };
134
141
  }),
package/src/PluvServer.ts CHANGED
@@ -189,7 +189,7 @@ export class PluvServer<
189
189
  const rooms = Array.from(this._rooms.entries());
190
190
 
191
191
  rooms.forEach(([id, room]) => {
192
- if (room.getSize()) return;
192
+ if (!!room?.getSize()) return;
193
193
 
194
194
  this._rooms.delete(id);
195
195
  });
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.21.1'
2
+ export const version = '0.22.0'