@pluv/client 0.23.0 → 0.24.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +15 -0
- package/dist/index.js +14 -2
- package/dist/index.mjs +14 -2
- package/package.json +5 -5
- package/src/OtherNotifier.ts +9 -0
- package/src/PluvRoom.ts +5 -4
- package/src/UsersManager.ts +4 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/client@0.
|
|
2
|
+
> @pluv/client@0.24.1 build /home/runner/work/pluv/pluv/packages/client
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m43.49 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 150ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m42.22 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 151ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3226ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m14.60 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m14.60 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pluv/client
|
|
2
2
|
|
|
3
|
+
## 0.24.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ba299e2: Fixed "others" state in the PluvClient not getting cleared when the user's websocket connection is closed, creating "ghost users" during some reconnects.
|
|
8
|
+
- @pluv/crdt@0.24.1
|
|
9
|
+
- @pluv/types@0.24.1
|
|
10
|
+
|
|
11
|
+
## 0.24.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @pluv/crdt@0.24.0
|
|
16
|
+
- @pluv/types@0.24.0
|
|
17
|
+
|
|
3
18
|
## 0.23.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;
|
|
@@ -1097,8 +1111,6 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
1097
1111
|
this._logDebug("WebSocket event received: ", message.type, message);
|
|
1098
1112
|
}
|
|
1099
1113
|
this._eventNotifier.subject(message.type).next(message);
|
|
1100
|
-
const { connectionId } = message;
|
|
1101
|
-
if (!connectionId) return;
|
|
1102
1114
|
switch (message.type) {
|
|
1103
1115
|
case "$EXIT": {
|
|
1104
1116
|
this._handleExit(message);
|
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;
|
|
@@ -1068,8 +1082,6 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
1068
1082
|
this._logDebug("WebSocket event received: ", message.type, message);
|
|
1069
1083
|
}
|
|
1070
1084
|
this._eventNotifier.subject(message.type).next(message);
|
|
1071
|
-
const { connectionId } = message;
|
|
1072
|
-
if (!connectionId) return;
|
|
1073
1085
|
switch (message.type) {
|
|
1074
1086
|
case "$EXIT": {
|
|
1075
1087
|
this._handleExit(message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
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.
|
|
22
|
-
"@pluv/types": "^0.
|
|
21
|
+
"@pluv/crdt": "^0.24.1",
|
|
22
|
+
"@pluv/types": "^0.24.1"
|
|
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.
|
|
29
|
-
"eslint-config-pluv": "^0.
|
|
28
|
+
"@pluv/tsconfig": "^0.24.1",
|
|
29
|
+
"eslint-config-pluv": "^0.24.1"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/OtherNotifier.ts
CHANGED
|
@@ -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,
|
|
@@ -968,10 +973,6 @@ export class PluvRoom<
|
|
|
968
973
|
|
|
969
974
|
this._eventNotifier.subject(message.type as keyof InferIOOutput<TIO>).next(message as any);
|
|
970
975
|
|
|
971
|
-
const { connectionId } = message;
|
|
972
|
-
|
|
973
|
-
if (!connectionId) return;
|
|
974
|
-
|
|
975
976
|
switch (message.type) {
|
|
976
977
|
case "$EXIT": {
|
|
977
978
|
this._handleExit(message);
|
package/src/UsersManager.ts
CHANGED
|
@@ -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,
|