@pluv/client 0.37.6 → 0.38.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.37.6 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@0.38.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 48.92 KB
12
- CJS ⚡️ Build success in 132ms
13
- ESM dist/index.mjs 47.60 KB
14
- ESM ⚡️ Build success in 136ms
11
+ ESM dist/index.mjs 47.59 KB
12
+ ESM ⚡️ Build success in 101ms
13
+ CJS dist/index.js 48.91 KB
14
+ CJS ⚡️ Build success in 101ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3572ms
16
+ DTS ⚡️ Build success in 3519ms
17
17
  DTS dist/index.d.mts 23.13 KB
18
18
  DTS dist/index.d.ts 23.13 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 0.38.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f4ceca3: Updated internal event names to follow a new naming convention.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [f4ceca3]
12
+ - @pluv/types@0.38.0
13
+ - @pluv/crdt@0.38.0
14
+
15
+ ## 0.37.7
16
+
17
+ ### Patch Changes
18
+
19
+ - @pluv/crdt@0.37.7
20
+ - @pluv/types@0.37.7
21
+
3
22
  ## 0.37.6
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -432,8 +432,8 @@ var ADD_TO_STORAGE_STATE_DEBOUNCE_MS = 1e3;
432
432
  var HEARTBEAT_INTERVAL_MS = 1e4;
433
433
  var PONG_TIMEOUT_MS = 2e3;
434
434
  var RECONNECT_TIMEOUT_MS = 3e4;
435
- var ORIGIN_INITIALIZED = "$INITIALIZED";
436
- var ORIGIN_STORAGE_UPDATED = "$STORAGE_UPDATED";
435
+ var ORIGIN_INITIALIZED = "$initialized";
436
+ var ORIGIN_STORAGE_UPDATED = "$storageUpdated";
437
437
  var DEFAULT_PLUV_CLIENT_ADDON = (input) => ({
438
438
  storage: new StorageStore(input.room.id)
439
439
  });
@@ -590,7 +590,7 @@ var PluvRoom = class extends AbstractRoom {
590
590
  this._stateNotifier.subjects["my-presence"].next(myPresence);
591
591
  !!myself && this._stateNotifier.subjects["myself"].next(myself);
592
592
  this.broadcast(
593
- "$UPDATE_PRESENCE",
593
+ "$updatePresence",
594
594
  { presence: newPresence }
595
595
  );
596
596
  };
@@ -907,7 +907,7 @@ var PluvRoom = class extends AbstractRoom {
907
907
  this._stateNotifier.subjects["myself"].next(myself);
908
908
  const update = this._state.connection.count > 1 ? (_b = this._crdtManager.doc.getEncodedState()) != null ? _b : null : null;
909
909
  this._sendMessage({
910
- type: "$INITIALIZE_SESSION",
910
+ type: "$initializeSession",
911
911
  data: { presence, update }
912
912
  });
913
913
  }
@@ -932,7 +932,7 @@ var PluvRoom = class extends AbstractRoom {
932
932
  this._emitSharedTypes();
933
933
  const update = this._crdtManager.doc.getEncodedState();
934
934
  this._sendMessage({
935
- type: "$UPDATE_STORAGE",
935
+ type: "$updateStorage",
936
936
  data: { origin: ORIGIN_INITIALIZED, update }
937
937
  });
938
938
  });
@@ -967,7 +967,7 @@ var PluvRoom = class extends AbstractRoom {
967
967
  const data = message.data;
968
968
  const myself = this._usersManager.myself;
969
969
  if (myself.connectionId === connectionId) {
970
- this._sendMessage({ type: "$GET_OTHERS", data: {} });
970
+ this._sendMessage({ type: "$getOthers", data: {} });
971
971
  }
972
972
  this._usersManager.setUser(connectionId, data.user, data.presence);
973
973
  const other = this._usersManager.getOther(connectionId);
@@ -978,7 +978,7 @@ var PluvRoom = class extends AbstractRoom {
978
978
  _heartbeat() {
979
979
  this._clearTimeout(this._timeouts.pong);
980
980
  this._timeouts.pong = setTimeout(this._reconnect.bind(this), PONG_TIMEOUT_MS);
981
- this._sendMessage('{"type":"$PING","data":{}}');
981
+ this._sendMessage('{"type":"$ping","data":{}}');
982
982
  }
983
983
  _logDebug(...data) {
984
984
  var _a;
@@ -1001,7 +1001,7 @@ var PluvRoom = class extends AbstractRoom {
1001
1001
  if (!this._state.connection.id) return;
1002
1002
  if (this._state.webSocket.readyState !== WebSocket.OPEN) return;
1003
1003
  this._sendMessage({
1004
- type: "$UPDATE_STORAGE",
1004
+ type: "$updateStorage",
1005
1005
  data: { origin, update: event.update }
1006
1006
  });
1007
1007
  });
@@ -1054,35 +1054,35 @@ var PluvRoom = class extends AbstractRoom {
1054
1054
  }
1055
1055
  this._eventNotifier.subject(message.type).next(message);
1056
1056
  switch (message.type) {
1057
- case "$EXIT": {
1057
+ case "$exit": {
1058
1058
  this._handleExit(message);
1059
1059
  return;
1060
1060
  }
1061
- case "$OTHERS_RECEIVED": {
1061
+ case "$othersReceived": {
1062
1062
  this._handleReceiveOthers(message);
1063
1063
  return;
1064
1064
  }
1065
- case "$PONG": {
1065
+ case "$pong": {
1066
1066
  this._clearTimeout(this._timeouts.pong);
1067
1067
  return;
1068
1068
  }
1069
- case "$PRESENCE_UPDATED": {
1069
+ case "$presenceUpdated": {
1070
1070
  this._handlePresenceUpdatedMessage(message);
1071
1071
  return;
1072
1072
  }
1073
- case "$REGISTERED": {
1073
+ case "$registered": {
1074
1074
  this._handleRegisteredMessage(message);
1075
1075
  return;
1076
1076
  }
1077
- case "$STORAGE_RECEIVED": {
1077
+ case "$storageReceived": {
1078
1078
  this._handleStorageReceivedMessage(message);
1079
1079
  return;
1080
1080
  }
1081
- case "$STORAGE_UPDATED": {
1081
+ case "$storageUpdated": {
1082
1082
  this._handleStorageUpdatedMessage(message);
1083
1083
  return;
1084
1084
  }
1085
- case "$USER_JOINED": {
1085
+ case "$userJoined": {
1086
1086
  this._handleUserJoinedMessage(message);
1087
1087
  return;
1088
1088
  }
@@ -1433,7 +1433,7 @@ var MockedRoom = class extends AbstractRoom {
1433
1433
  var _a2;
1434
1434
  const origin = (_a2 = event.origin) != null ? _a2 : null;
1435
1435
  if (!this._crdtManager) return;
1436
- if (origin === "$STORAGE_UPDATED") return;
1436
+ if (origin === "$storageUpdated") return;
1437
1437
  const sharedTypes = this._crdtManager.doc.get();
1438
1438
  const storageRoot = Object.keys(sharedTypes).reduce(
1439
1439
  (acc, prop) => {
package/dist/index.mjs CHANGED
@@ -401,8 +401,8 @@ var ADD_TO_STORAGE_STATE_DEBOUNCE_MS = 1e3;
401
401
  var HEARTBEAT_INTERVAL_MS = 1e4;
402
402
  var PONG_TIMEOUT_MS = 2e3;
403
403
  var RECONNECT_TIMEOUT_MS = 3e4;
404
- var ORIGIN_INITIALIZED = "$INITIALIZED";
405
- var ORIGIN_STORAGE_UPDATED = "$STORAGE_UPDATED";
404
+ var ORIGIN_INITIALIZED = "$initialized";
405
+ var ORIGIN_STORAGE_UPDATED = "$storageUpdated";
406
406
  var DEFAULT_PLUV_CLIENT_ADDON = (input) => ({
407
407
  storage: new StorageStore(input.room.id)
408
408
  });
@@ -559,7 +559,7 @@ var PluvRoom = class extends AbstractRoom {
559
559
  this._stateNotifier.subjects["my-presence"].next(myPresence);
560
560
  !!myself && this._stateNotifier.subjects["myself"].next(myself);
561
561
  this.broadcast(
562
- "$UPDATE_PRESENCE",
562
+ "$updatePresence",
563
563
  { presence: newPresence }
564
564
  );
565
565
  };
@@ -876,7 +876,7 @@ var PluvRoom = class extends AbstractRoom {
876
876
  this._stateNotifier.subjects["myself"].next(myself);
877
877
  const update = this._state.connection.count > 1 ? (_b = this._crdtManager.doc.getEncodedState()) != null ? _b : null : null;
878
878
  this._sendMessage({
879
- type: "$INITIALIZE_SESSION",
879
+ type: "$initializeSession",
880
880
  data: { presence, update }
881
881
  });
882
882
  }
@@ -901,7 +901,7 @@ var PluvRoom = class extends AbstractRoom {
901
901
  this._emitSharedTypes();
902
902
  const update = this._crdtManager.doc.getEncodedState();
903
903
  this._sendMessage({
904
- type: "$UPDATE_STORAGE",
904
+ type: "$updateStorage",
905
905
  data: { origin: ORIGIN_INITIALIZED, update }
906
906
  });
907
907
  });
@@ -936,7 +936,7 @@ var PluvRoom = class extends AbstractRoom {
936
936
  const data = message.data;
937
937
  const myself = this._usersManager.myself;
938
938
  if (myself.connectionId === connectionId) {
939
- this._sendMessage({ type: "$GET_OTHERS", data: {} });
939
+ this._sendMessage({ type: "$getOthers", data: {} });
940
940
  }
941
941
  this._usersManager.setUser(connectionId, data.user, data.presence);
942
942
  const other = this._usersManager.getOther(connectionId);
@@ -947,7 +947,7 @@ var PluvRoom = class extends AbstractRoom {
947
947
  _heartbeat() {
948
948
  this._clearTimeout(this._timeouts.pong);
949
949
  this._timeouts.pong = setTimeout(this._reconnect.bind(this), PONG_TIMEOUT_MS);
950
- this._sendMessage('{"type":"$PING","data":{}}');
950
+ this._sendMessage('{"type":"$ping","data":{}}');
951
951
  }
952
952
  _logDebug(...data) {
953
953
  var _a;
@@ -970,7 +970,7 @@ var PluvRoom = class extends AbstractRoom {
970
970
  if (!this._state.connection.id) return;
971
971
  if (this._state.webSocket.readyState !== WebSocket.OPEN) return;
972
972
  this._sendMessage({
973
- type: "$UPDATE_STORAGE",
973
+ type: "$updateStorage",
974
974
  data: { origin, update: event.update }
975
975
  });
976
976
  });
@@ -1023,35 +1023,35 @@ var PluvRoom = class extends AbstractRoom {
1023
1023
  }
1024
1024
  this._eventNotifier.subject(message.type).next(message);
1025
1025
  switch (message.type) {
1026
- case "$EXIT": {
1026
+ case "$exit": {
1027
1027
  this._handleExit(message);
1028
1028
  return;
1029
1029
  }
1030
- case "$OTHERS_RECEIVED": {
1030
+ case "$othersReceived": {
1031
1031
  this._handleReceiveOthers(message);
1032
1032
  return;
1033
1033
  }
1034
- case "$PONG": {
1034
+ case "$pong": {
1035
1035
  this._clearTimeout(this._timeouts.pong);
1036
1036
  return;
1037
1037
  }
1038
- case "$PRESENCE_UPDATED": {
1038
+ case "$presenceUpdated": {
1039
1039
  this._handlePresenceUpdatedMessage(message);
1040
1040
  return;
1041
1041
  }
1042
- case "$REGISTERED": {
1042
+ case "$registered": {
1043
1043
  this._handleRegisteredMessage(message);
1044
1044
  return;
1045
1045
  }
1046
- case "$STORAGE_RECEIVED": {
1046
+ case "$storageReceived": {
1047
1047
  this._handleStorageReceivedMessage(message);
1048
1048
  return;
1049
1049
  }
1050
- case "$STORAGE_UPDATED": {
1050
+ case "$storageUpdated": {
1051
1051
  this._handleStorageUpdatedMessage(message);
1052
1052
  return;
1053
1053
  }
1054
- case "$USER_JOINED": {
1054
+ case "$userJoined": {
1055
1055
  this._handleUserJoinedMessage(message);
1056
1056
  return;
1057
1057
  }
@@ -1402,7 +1402,7 @@ var MockedRoom = class extends AbstractRoom {
1402
1402
  var _a2;
1403
1403
  const origin = (_a2 = event.origin) != null ? _a2 : null;
1404
1404
  if (!this._crdtManager) return;
1405
- if (origin === "$STORAGE_UPDATED") return;
1405
+ if (origin === "$storageUpdated") return;
1406
1406
  const sharedTypes = this._crdtManager.doc.get();
1407
1407
  const storageRoot = Object.keys(sharedTypes).reduce(
1408
1408
  (acc, prop) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "0.37.6",
3
+ "version": "0.38.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.5",
21
- "@pluv/crdt": "^0.37.6",
22
- "@pluv/types": "^0.37.6"
21
+ "@pluv/crdt": "^0.38.0",
22
+ "@pluv/types": "^0.38.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^8.57.1",
26
26
  "tsup": "^8.4.0",
27
27
  "typescript": "^5.8.2",
28
- "@pluv/tsconfig": "^0.37.6",
29
- "eslint-config-pluv": "^0.37.6"
28
+ "@pluv/tsconfig": "^0.38.0",
29
+ "eslint-config-pluv": "^0.38.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/MockedRoom.ts CHANGED
@@ -301,7 +301,7 @@ export class MockedRoom<
301
301
  const origin = event.origin ?? null;
302
302
 
303
303
  if (!this._crdtManager) return;
304
- if (origin === "$STORAGE_UPDATED") return;
304
+ if (origin === "$storageUpdated") return;
305
305
 
306
306
  const sharedTypes = this._crdtManager.doc.get();
307
307
 
package/src/PluvRoom.ts CHANGED
@@ -47,8 +47,8 @@ const ADD_TO_STORAGE_STATE_DEBOUNCE_MS = 1_000;
47
47
  const HEARTBEAT_INTERVAL_MS = 10_000;
48
48
  const PONG_TIMEOUT_MS = 2_000;
49
49
  const RECONNECT_TIMEOUT_MS = 30_000;
50
- const ORIGIN_INITIALIZED = "$INITIALIZED";
51
- const ORIGIN_STORAGE_UPDATED = "$STORAGE_UPDATED";
50
+ const ORIGIN_INITIALIZED = "$initialized";
51
+ const ORIGIN_STORAGE_UPDATED = "$storageUpdated";
52
52
 
53
53
  export const DEFAULT_PLUV_CLIENT_ADDON = <
54
54
  TIO extends IOLike = IOLike,
@@ -534,7 +534,7 @@ export class PluvRoom<
534
534
  !!myself && this._stateNotifier.subjects["myself"].next(myself);
535
535
 
536
536
  this.broadcast(
537
- "$UPDATE_PRESENCE" as keyof InferIOInput<MergeEvents<TEvents, TIO>>,
537
+ "$updatePresence" as keyof InferIOInput<MergeEvents<TEvents, TIO>>,
538
538
  { presence: newPresence } as any,
539
539
  );
540
540
  };
@@ -778,7 +778,7 @@ export class PluvRoom<
778
778
  // Should not reach here
779
779
  if (!this._state.webSocket) throw new Error("Could not find WebSocket");
780
780
 
781
- const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$PRESENCE_UPDATED"];
781
+ const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$presenceUpdated"];
782
782
 
783
783
  this._usersManager.patchPresence(connectionId, data.presence as TPresence);
784
784
 
@@ -804,7 +804,7 @@ export class PluvRoom<
804
804
  // Should not reach here
805
805
  if (!this._state.webSocket) throw new Error("Could not find WebSocket");
806
806
 
807
- const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$OTHERS_RECEIVED"];
807
+ const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$othersReceived"];
808
808
 
809
809
  Object.keys(data.others).forEach((connectionId) => {
810
810
  const { presence, user } = data.others[connectionId];
@@ -849,7 +849,7 @@ export class PluvRoom<
849
849
  const update = this._state.connection.count > 1 ? (this._crdtManager.doc.getEncodedState() ?? null) : null;
850
850
 
851
851
  this._sendMessage({
852
- type: "$INITIALIZE_SESSION",
852
+ type: "$initializeSession",
853
853
  data: { presence, update },
854
854
  });
855
855
  }
@@ -861,7 +861,7 @@ export class PluvRoom<
861
861
  // Should not reach here
862
862
  if (!this._state.webSocket) throw new Error("Could not find WebSocket");
863
863
 
864
- const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$STORAGE_RECEIVED"];
864
+ const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$storageReceived"];
865
865
 
866
866
  this._crdtManager.initialize({
867
867
  onInitialized: async (update) => {
@@ -884,7 +884,7 @@ export class PluvRoom<
884
884
  const update = this._crdtManager.doc.getEncodedState();
885
885
 
886
886
  this._sendMessage({
887
- type: "$UPDATE_STORAGE",
887
+ type: "$updateStorage",
888
888
  data: { origin: ORIGIN_INITIALIZED, update },
889
889
  });
890
890
  }
@@ -933,12 +933,12 @@ export class PluvRoom<
933
933
  if (!this._state.webSocket) throw new Error("Could not find WebSocket");
934
934
  if (!this._usersManager.myself) return;
935
935
 
936
- const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$USER_JOINED"];
936
+ const data = message.data as BaseIOEventRecord<InferIOAuthorize<TIO>>["$userJoined"];
937
937
 
938
938
  const myself = this._usersManager.myself;
939
939
 
940
940
  if (myself.connectionId === connectionId) {
941
- this._sendMessage({ type: "$GET_OTHERS", data: {} });
941
+ this._sendMessage({ type: "$getOthers", data: {} });
942
942
  }
943
943
 
944
944
  this._usersManager.setUser(connectionId, data.user, data.presence as TPresence);
@@ -960,7 +960,7 @@ export class PluvRoom<
960
960
  * consistent way.
961
961
  * @date July 8, 2024
962
962
  */
963
- this._sendMessage('{"type":"$PING","data":{}}');
963
+ this._sendMessage('{"type":"$ping","data":{}}');
964
964
  }
965
965
 
966
966
  private _logDebug(...data: any[]): void {
@@ -990,7 +990,7 @@ export class PluvRoom<
990
990
  if (this._state.webSocket.readyState !== WebSocket.OPEN) return;
991
991
 
992
992
  this._sendMessage({
993
- type: "$UPDATE_STORAGE",
993
+ type: "$updateStorage",
994
994
  data: { origin, update: event.update },
995
995
  });
996
996
  });
@@ -1058,35 +1058,35 @@ export class PluvRoom<
1058
1058
  this._eventNotifier.subject(message.type as keyof InferIOOutput<TIO>).next(message as any);
1059
1059
 
1060
1060
  switch (message.type) {
1061
- case "$EXIT": {
1061
+ case "$exit": {
1062
1062
  this._handleExit(message);
1063
1063
  return;
1064
1064
  }
1065
- case "$OTHERS_RECEIVED": {
1065
+ case "$othersReceived": {
1066
1066
  this._handleReceiveOthers(message);
1067
1067
  return;
1068
1068
  }
1069
- case "$PONG": {
1069
+ case "$pong": {
1070
1070
  this._clearTimeout(this._timeouts.pong);
1071
1071
  return;
1072
1072
  }
1073
- case "$PRESENCE_UPDATED": {
1073
+ case "$presenceUpdated": {
1074
1074
  this._handlePresenceUpdatedMessage(message);
1075
1075
  return;
1076
1076
  }
1077
- case "$REGISTERED": {
1077
+ case "$registered": {
1078
1078
  this._handleRegisteredMessage(message);
1079
1079
  return;
1080
1080
  }
1081
- case "$STORAGE_RECEIVED": {
1081
+ case "$storageReceived": {
1082
1082
  this._handleStorageReceivedMessage(message);
1083
1083
  return;
1084
1084
  }
1085
- case "$STORAGE_UPDATED": {
1085
+ case "$storageUpdated": {
1086
1086
  this._handleStorageUpdatedMessage(message);
1087
1087
  return;
1088
1088
  }
1089
- case "$USER_JOINED": {
1089
+ case "$userJoined": {
1090
1090
  this._handleUserJoinedMessage(message);
1091
1091
  return;
1092
1092
  }