@pluv/client 0.41.0 → 0.41.2
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 +17 -9
- package/dist/index.mjs +17 -9
- package/package.json +5 -5
- package/src/PluvRoom.ts +22 -8
- package/src/UsersManager.ts +5 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/client@0.41.
|
|
2
|
+
> @pluv/client@0.41.2 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
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m54.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m55.
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m54.44 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 116ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m55.76 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 116ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3794ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m24.58 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m24.58 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @pluv/client
|
|
2
2
|
|
|
3
|
+
## 0.41.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 37956d3: When presence is received for a user that is not currently being tracked, `PluvRoom` now automatically updates `others` to include the connection of the received presence.
|
|
8
|
+
- @pluv/crdt@0.41.2
|
|
9
|
+
- @pluv/types@0.41.2
|
|
10
|
+
|
|
11
|
+
## 0.41.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @pluv/crdt@0.41.1
|
|
16
|
+
- @pluv/types@0.41.1
|
|
17
|
+
|
|
3
18
|
## 0.41.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -334,7 +334,7 @@ var UsersManager = class {
|
|
|
334
334
|
this._others = /* @__PURE__ */ new Map();
|
|
335
335
|
this._presence = null;
|
|
336
336
|
const { initialPresence, presence = null } = config;
|
|
337
|
-
this.
|
|
337
|
+
this.initialPresence = initialPresence;
|
|
338
338
|
this._myPresence = initialPresence;
|
|
339
339
|
this._presence = presence;
|
|
340
340
|
}
|
|
@@ -347,7 +347,7 @@ var UsersManager = class {
|
|
|
347
347
|
addConnection(userInfo) {
|
|
348
348
|
var _a;
|
|
349
349
|
const data = __spreadProps(__spreadValues({}, userInfo), {
|
|
350
|
-
presence: (_a = userInfo.presence) != null ? _a : this.
|
|
350
|
+
presence: (_a = userInfo.presence) != null ? _a : this.initialPresence
|
|
351
351
|
});
|
|
352
352
|
const myClientId = !!this._myself ? this.getClientId(this._myself) : null;
|
|
353
353
|
const clientId = this.getClientId(data);
|
|
@@ -434,7 +434,7 @@ var UsersManager = class {
|
|
|
434
434
|
setMyself(userInfo) {
|
|
435
435
|
var _a;
|
|
436
436
|
const connectionId = userInfo.connectionId;
|
|
437
|
-
const presence = (_a = userInfo.presence) != null ? _a : this.
|
|
437
|
+
const presence = (_a = userInfo.presence) != null ? _a : this.initialPresence;
|
|
438
438
|
this._myself = __spreadProps(__spreadValues({}, userInfo), { presence });
|
|
439
439
|
this._myPresence = presence;
|
|
440
440
|
const clientId = this.getClientId(this._myself);
|
|
@@ -983,9 +983,19 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
983
983
|
this._stateNotifier.subjects.myself.next(this._usersManager.myself);
|
|
984
984
|
return;
|
|
985
985
|
}
|
|
986
|
-
|
|
986
|
+
if (!!clientId) {
|
|
987
|
+
const other = this._usersManager.getOther(connectionId);
|
|
988
|
+
this._otherNotifier.subject(clientId).next(other);
|
|
989
|
+
} else {
|
|
990
|
+
const added = this._usersManager.addConnection({
|
|
991
|
+
connectionId,
|
|
992
|
+
presence: __spreadValues(__spreadValues({}, this._usersManager.initialPresence), data.presence),
|
|
993
|
+
user: message.user
|
|
994
|
+
});
|
|
995
|
+
const other = this._usersManager.getOther(connectionId);
|
|
996
|
+
this._otherNotifier.subject(added.clientId).next(other);
|
|
997
|
+
}
|
|
987
998
|
const others = this._usersManager.getOthers();
|
|
988
|
-
if (!!clientId) this._otherNotifier.subject(clientId).next(other);
|
|
989
999
|
this._stateNotifier.subjects.others.next(others);
|
|
990
1000
|
}
|
|
991
1001
|
_handleReceiveOthers(message) {
|
|
@@ -1086,7 +1096,6 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
1086
1096
|
this._crdtNotifier.rootSubject.next(storageRoot);
|
|
1087
1097
|
}
|
|
1088
1098
|
_handleUserJoinedMessage(message) {
|
|
1089
|
-
var _a;
|
|
1090
1099
|
const { connectionId } = message;
|
|
1091
1100
|
if (!connectionId) return;
|
|
1092
1101
|
if (!this._state.webSocket) throw new Error("Could not find WebSocket");
|
|
@@ -1097,15 +1106,14 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
1097
1106
|
this._sendMessage({ type: "$getOthers", data: {} });
|
|
1098
1107
|
return;
|
|
1099
1108
|
}
|
|
1100
|
-
const
|
|
1109
|
+
const added = this._usersManager.addConnection({
|
|
1101
1110
|
connectionId,
|
|
1102
1111
|
presence: data.presence,
|
|
1103
1112
|
user: data.user
|
|
1104
1113
|
});
|
|
1105
|
-
const clientId = (_a = result == null ? void 0 : result.clientId) != null ? _a : null;
|
|
1106
1114
|
const other = this._usersManager.getOther(connectionId);
|
|
1107
1115
|
const others = this._usersManager.getOthers();
|
|
1108
|
-
|
|
1116
|
+
this._otherNotifier.subject(added.clientId).next(other);
|
|
1109
1117
|
this._stateNotifier.subjects.others.next(others);
|
|
1110
1118
|
}
|
|
1111
1119
|
_heartbeat() {
|
package/dist/index.mjs
CHANGED
|
@@ -303,7 +303,7 @@ var UsersManager = class {
|
|
|
303
303
|
this._others = /* @__PURE__ */ new Map();
|
|
304
304
|
this._presence = null;
|
|
305
305
|
const { initialPresence, presence = null } = config;
|
|
306
|
-
this.
|
|
306
|
+
this.initialPresence = initialPresence;
|
|
307
307
|
this._myPresence = initialPresence;
|
|
308
308
|
this._presence = presence;
|
|
309
309
|
}
|
|
@@ -316,7 +316,7 @@ var UsersManager = class {
|
|
|
316
316
|
addConnection(userInfo) {
|
|
317
317
|
var _a;
|
|
318
318
|
const data = __spreadProps(__spreadValues({}, userInfo), {
|
|
319
|
-
presence: (_a = userInfo.presence) != null ? _a : this.
|
|
319
|
+
presence: (_a = userInfo.presence) != null ? _a : this.initialPresence
|
|
320
320
|
});
|
|
321
321
|
const myClientId = !!this._myself ? this.getClientId(this._myself) : null;
|
|
322
322
|
const clientId = this.getClientId(data);
|
|
@@ -403,7 +403,7 @@ var UsersManager = class {
|
|
|
403
403
|
setMyself(userInfo) {
|
|
404
404
|
var _a;
|
|
405
405
|
const connectionId = userInfo.connectionId;
|
|
406
|
-
const presence = (_a = userInfo.presence) != null ? _a : this.
|
|
406
|
+
const presence = (_a = userInfo.presence) != null ? _a : this.initialPresence;
|
|
407
407
|
this._myself = __spreadProps(__spreadValues({}, userInfo), { presence });
|
|
408
408
|
this._myPresence = presence;
|
|
409
409
|
const clientId = this.getClientId(this._myself);
|
|
@@ -952,9 +952,19 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
952
952
|
this._stateNotifier.subjects.myself.next(this._usersManager.myself);
|
|
953
953
|
return;
|
|
954
954
|
}
|
|
955
|
-
|
|
955
|
+
if (!!clientId) {
|
|
956
|
+
const other = this._usersManager.getOther(connectionId);
|
|
957
|
+
this._otherNotifier.subject(clientId).next(other);
|
|
958
|
+
} else {
|
|
959
|
+
const added = this._usersManager.addConnection({
|
|
960
|
+
connectionId,
|
|
961
|
+
presence: __spreadValues(__spreadValues({}, this._usersManager.initialPresence), data.presence),
|
|
962
|
+
user: message.user
|
|
963
|
+
});
|
|
964
|
+
const other = this._usersManager.getOther(connectionId);
|
|
965
|
+
this._otherNotifier.subject(added.clientId).next(other);
|
|
966
|
+
}
|
|
956
967
|
const others = this._usersManager.getOthers();
|
|
957
|
-
if (!!clientId) this._otherNotifier.subject(clientId).next(other);
|
|
958
968
|
this._stateNotifier.subjects.others.next(others);
|
|
959
969
|
}
|
|
960
970
|
_handleReceiveOthers(message) {
|
|
@@ -1055,7 +1065,6 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
1055
1065
|
this._crdtNotifier.rootSubject.next(storageRoot);
|
|
1056
1066
|
}
|
|
1057
1067
|
_handleUserJoinedMessage(message) {
|
|
1058
|
-
var _a;
|
|
1059
1068
|
const { connectionId } = message;
|
|
1060
1069
|
if (!connectionId) return;
|
|
1061
1070
|
if (!this._state.webSocket) throw new Error("Could not find WebSocket");
|
|
@@ -1066,15 +1075,14 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
1066
1075
|
this._sendMessage({ type: "$getOthers", data: {} });
|
|
1067
1076
|
return;
|
|
1068
1077
|
}
|
|
1069
|
-
const
|
|
1078
|
+
const added = this._usersManager.addConnection({
|
|
1070
1079
|
connectionId,
|
|
1071
1080
|
presence: data.presence,
|
|
1072
1081
|
user: data.user
|
|
1073
1082
|
});
|
|
1074
|
-
const clientId = (_a = result == null ? void 0 : result.clientId) != null ? _a : null;
|
|
1075
1083
|
const other = this._usersManager.getOther(connectionId);
|
|
1076
1084
|
const others = this._usersManager.getOthers();
|
|
1077
|
-
|
|
1085
|
+
this._otherNotifier.subject(added.clientId).next(other);
|
|
1078
1086
|
this._stateNotifier.subjects.others.next(others);
|
|
1079
1087
|
}
|
|
1080
1088
|
_heartbeat() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/client",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.2",
|
|
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.5",
|
|
21
|
-
"@pluv/
|
|
22
|
-
"@pluv/
|
|
21
|
+
"@pluv/types": "^0.41.2",
|
|
22
|
+
"@pluv/crdt": "^0.41.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"eslint": "^9.25.0",
|
|
26
26
|
"tsup": "^8.4.0",
|
|
27
27
|
"typescript": "^5.8.3",
|
|
28
|
-
"@pluv/tsconfig": "^0.41.
|
|
29
|
-
"eslint-config-pluv": "^0.41.
|
|
28
|
+
"@pluv/tsconfig": "^0.41.2",
|
|
29
|
+
"eslint-config-pluv": "^0.41.2"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/PluvRoom.ts
CHANGED
|
@@ -77,9 +77,6 @@ export const DEFAULT_PLUV_CLIENT_ADDON = <
|
|
|
77
77
|
storage: new StorageStore(input.room.id),
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
interface CloseWsOptions {
|
|
81
|
-
connectionState?: ConnectionState;
|
|
82
|
-
}
|
|
83
80
|
interface WindowListeners {
|
|
84
81
|
onNavigatorOffline: () => void;
|
|
85
82
|
onNavigatorOnline: () => void;
|
|
@@ -857,10 +854,28 @@ export class PluvRoom<
|
|
|
857
854
|
return;
|
|
858
855
|
}
|
|
859
856
|
|
|
860
|
-
|
|
857
|
+
if (!!clientId) {
|
|
858
|
+
const other = this._usersManager.getOther(connectionId);
|
|
859
|
+
|
|
860
|
+
this._otherNotifier.subject(clientId).next(other);
|
|
861
|
+
} else {
|
|
862
|
+
/**
|
|
863
|
+
* !HACK
|
|
864
|
+
* @description User could not be found. Add the connection to keep others up-to-date
|
|
865
|
+
* @date April 19, 2025
|
|
866
|
+
*/
|
|
867
|
+
const added = this._usersManager.addConnection({
|
|
868
|
+
connectionId,
|
|
869
|
+
presence: { ...this._usersManager.initialPresence, ...data.presence } as TPresence,
|
|
870
|
+
user: message.user as Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>,
|
|
871
|
+
});
|
|
872
|
+
const other = this._usersManager.getOther(connectionId);
|
|
873
|
+
|
|
874
|
+
this._otherNotifier.subject(added.clientId).next(other);
|
|
875
|
+
}
|
|
876
|
+
|
|
861
877
|
const others = this._usersManager.getOthers();
|
|
862
878
|
|
|
863
|
-
if (!!clientId) this._otherNotifier.subject(clientId).next(other);
|
|
864
879
|
this._stateNotifier.subjects.others.next(others);
|
|
865
880
|
}
|
|
866
881
|
|
|
@@ -1020,17 +1035,16 @@ export class PluvRoom<
|
|
|
1020
1035
|
return;
|
|
1021
1036
|
}
|
|
1022
1037
|
|
|
1023
|
-
const
|
|
1038
|
+
const added = this._usersManager.addConnection({
|
|
1024
1039
|
connectionId,
|
|
1025
1040
|
presence: data.presence as TPresence,
|
|
1026
1041
|
user: data.user,
|
|
1027
1042
|
});
|
|
1028
1043
|
|
|
1029
|
-
const clientId = result?.clientId ?? null;
|
|
1030
1044
|
const other = this._usersManager.getOther(connectionId);
|
|
1031
1045
|
const others = this._usersManager.getOthers();
|
|
1032
1046
|
|
|
1033
|
-
|
|
1047
|
+
this._otherNotifier.subject(added.clientId).next(other);
|
|
1034
1048
|
this._stateNotifier.subjects.others.next(others);
|
|
1035
1049
|
}
|
|
1036
1050
|
|
package/src/UsersManager.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class UsersManager<TIO extends IOLike, TPresence extends JsonObject = {}>
|
|
|
28
28
|
fromClientId: new Map<[clientId: string][0], Set<[connectionId: string][0]>>(),
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
public readonly initialPresence: TPresence;
|
|
32
32
|
/**
|
|
33
33
|
* @description This presence can be updated while the user is not
|
|
34
34
|
* connected.
|
|
@@ -44,7 +44,8 @@ export class UsersManager<TIO extends IOLike, TPresence extends JsonObject = {}>
|
|
|
44
44
|
constructor(config: UsersManagerConfig<TPresence>) {
|
|
45
45
|
const { initialPresence, presence = null } = config;
|
|
46
46
|
|
|
47
|
-
this.
|
|
47
|
+
this.initialPresence = initialPresence as TPresence;
|
|
48
|
+
|
|
48
49
|
this._myPresence = initialPresence as TPresence;
|
|
49
50
|
this._presence = presence;
|
|
50
51
|
}
|
|
@@ -62,7 +63,7 @@ export class UsersManager<TIO extends IOLike, TPresence extends JsonObject = {}>
|
|
|
62
63
|
): AddConnectionResult<TIO, TPresence> {
|
|
63
64
|
const data: UserInfo<TIO, TPresence> = {
|
|
64
65
|
...userInfo,
|
|
65
|
-
presence: userInfo.presence ?? this.
|
|
66
|
+
presence: userInfo.presence ?? this.initialPresence,
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
const myClientId = !!this._myself ? this.getClientId(this._myself) : null;
|
|
@@ -205,7 +206,7 @@ export class UsersManager<TIO extends IOLike, TPresence extends JsonObject = {}>
|
|
|
205
206
|
|
|
206
207
|
public setMyself(userInfo: OptionalProps<UserInfo<TIO, TPresence>, "presence">): void {
|
|
207
208
|
const connectionId = userInfo.connectionId;
|
|
208
|
-
const presence = userInfo.presence ?? this.
|
|
209
|
+
const presence = userInfo.presence ?? this.initialPresence;
|
|
209
210
|
|
|
210
211
|
this._myself = { ...userInfo, presence };
|
|
211
212
|
this._myPresence = presence;
|