@pluv/client 0.24.0 → 0.25.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,5 +1,5 @@
1
1
 
2
- > @pluv/client@0.24.0 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@0.25.0 build /home/runner/work/pluv/pluv/packages/client
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 43.06 KB
12
- CJS ⚡️ Build success in 95ms
13
- ESM dist/index.mjs 41.79 KB
14
- ESM ⚡️ Build success in 100ms
11
+ ESM dist/index.mjs 42.22 KB
12
+ ESM ⚡️ Build success in 98ms
13
+ CJS dist/index.js 43.49 KB
14
+ CJS ⚡️ Build success in 121ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3053ms
16
+ DTS ⚡️ Build success in 3131ms
17
17
  DTS dist/index.d.mts 14.60 KB
18
18
  DTS dist/index.d.ts 14.60 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 0.25.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@0.25.0
8
+ - @pluv/types@0.25.0
9
+
10
+ ## 0.24.1
11
+
12
+ ### Patch Changes
13
+
14
+ - ba299e2: Fixed "others" state in the PluvClient not getting cleared when the user's websocket connection is closed, creating "ghost users" during some reconnects.
15
+ - @pluv/crdt@0.24.1
16
+ - @pluv/types@0.24.1
17
+
3
18
  ## 0.24.0
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -188,6 +188,13 @@ var OtherNotifier = class {
188
188
  constructor() {
189
189
  this.subjects = /* @__PURE__ */ new Map();
190
190
  }
191
+ clear() {
192
+ const connectionIds = Array.from(this.subjects.keys());
193
+ connectionIds.forEach((connectionId) => {
194
+ this.subject(connectionId).next(null);
195
+ this.subjects.delete(connectionId);
196
+ });
197
+ }
191
198
  subject(name) {
192
199
  const subject = this.subjects.get(name);
193
200
  if (subject) return subject;
@@ -271,6 +278,9 @@ var UsersManager = class {
271
278
  removeUser(connectionId) {
272
279
  this._others.delete(connectionId);
273
280
  }
281
+ removeUsers() {
282
+ this._others.clear();
283
+ }
274
284
  setMyself(connectionId, user) {
275
285
  this._myself = {
276
286
  connectionId,
@@ -810,6 +820,10 @@ var PluvRoom = class extends AbstractRoom {
810
820
  this._clearTimeout(this._timeouts.reconnect);
811
821
  this._detachWindowListeners();
812
822
  this._usersManager.removeMyself();
823
+ this._usersManager.removeUsers();
824
+ this._otherNotifier.clear();
825
+ this._stateNotifier.subjects.myself.next(null);
826
+ this._stateNotifier.subjects.others.next([]);
813
827
  const canClose = [WebSocket.CONNECTING, WebSocket.OPEN].some(
814
828
  (readyState) => {
815
829
  var _a2;
package/dist/index.mjs CHANGED
@@ -159,6 +159,13 @@ var OtherNotifier = class {
159
159
  constructor() {
160
160
  this.subjects = /* @__PURE__ */ new Map();
161
161
  }
162
+ clear() {
163
+ const connectionIds = Array.from(this.subjects.keys());
164
+ connectionIds.forEach((connectionId) => {
165
+ this.subject(connectionId).next(null);
166
+ this.subjects.delete(connectionId);
167
+ });
168
+ }
162
169
  subject(name) {
163
170
  const subject = this.subjects.get(name);
164
171
  if (subject) return subject;
@@ -242,6 +249,9 @@ var UsersManager = class {
242
249
  removeUser(connectionId) {
243
250
  this._others.delete(connectionId);
244
251
  }
252
+ removeUsers() {
253
+ this._others.clear();
254
+ }
245
255
  setMyself(connectionId, user) {
246
256
  this._myself = {
247
257
  connectionId,
@@ -781,6 +791,10 @@ var PluvRoom = class extends AbstractRoom {
781
791
  this._clearTimeout(this._timeouts.reconnect);
782
792
  this._detachWindowListeners();
783
793
  this._usersManager.removeMyself();
794
+ this._usersManager.removeUsers();
795
+ this._otherNotifier.clear();
796
+ this._stateNotifier.subjects.myself.next(null);
797
+ this._stateNotifier.subjects.others.next([]);
784
798
  const canClose = [WebSocket.CONNECTING, WebSocket.OPEN].some(
785
799
  (readyState) => {
786
800
  var _a2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "@pluv/io frontend client",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "wonka": "^6.3.4",
21
- "@pluv/crdt": "^0.24.0",
22
- "@pluv/types": "^0.24.0"
21
+ "@pluv/crdt": "^0.25.0",
22
+ "@pluv/types": "^0.25.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^8.57.0",
26
26
  "tsup": "^8.2.4",
27
27
  "typescript": "^5.5.4",
28
- "@pluv/tsconfig": "^0.24.0",
29
- "eslint-config-pluv": "^0.24.0"
28
+ "@pluv/tsconfig": "^0.25.0",
29
+ "eslint-config-pluv": "^0.25.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -8,6 +8,15 @@ export type OtherNotifierSubscriptionCallback<TIO extends IOLike> = (value: Id<U
8
8
  export class OtherNotifier<TIO extends IOLike> {
9
9
  public subjects = new Map<string, Subject<Id<UserInfo<TIO>> | null>>();
10
10
 
11
+ public clear(): void {
12
+ const connectionIds = Array.from(this.subjects.keys());
13
+
14
+ connectionIds.forEach((connectionId) => {
15
+ this.subject(connectionId).next(null);
16
+ this.subjects.delete(connectionId);
17
+ });
18
+ }
19
+
11
20
  public subject<TEvent extends string>(name: TEvent): Subject<Id<UserInfo<TIO>> | null> {
12
21
  const subject = this.subjects.get(name);
13
22
 
package/src/PluvRoom.ts CHANGED
@@ -534,7 +534,12 @@ export class PluvRoom<
534
534
  this._clearTimeout(this._timeouts.reconnect);
535
535
 
536
536
  this._detachWindowListeners();
537
+
537
538
  this._usersManager.removeMyself();
539
+ this._usersManager.removeUsers();
540
+ this._otherNotifier.clear();
541
+ this._stateNotifier.subjects.myself.next(null);
542
+ this._stateNotifier.subjects.others.next([]);
538
543
 
539
544
  const canClose = [WebSocket.CONNECTING, WebSocket.OPEN].some(
540
545
  (readyState) => readyState === this._state.webSocket?.readyState,
@@ -85,6 +85,10 @@ export class UsersManager<TIO extends IOLike, TPresence extends JsonObject = {}>
85
85
  this._others.delete(connectionId);
86
86
  }
87
87
 
88
+ public removeUsers(): void {
89
+ this._others.clear();
90
+ }
91
+
88
92
  public setMyself(connectionId: string, user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>): void {
89
93
  this._myself = {
90
94
  connectionId,