@pluv/io 0.37.7 → 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,9 +1,9 @@
1
1
 
2
- > @pluv/io@0.37.7 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.38.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.37.7 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@0.38.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
- ESM dist/index.mjs 43.72 KB
16
- ESM ⚡️ Build success in 147ms
17
- CJS dist/index.js 45.90 KB
18
- CJS ⚡️ Build success in 155ms
15
+ ESM dist/index.mjs 43.71 KB
16
+ ESM ⚡️ Build success in 133ms
17
+ CJS dist/index.js 45.89 KB
18
+ CJS ⚡️ Build success in 133ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2408ms
20
+ DTS ⚡️ Build success in 2560ms
21
21
  DTS dist/index.d.mts 30.92 KB
22
22
  DTS dist/index.d.ts 30.92 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pluv/io
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
+
3
15
  ## 0.37.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -276,7 +276,7 @@ var AbstractWebSocket = class {
276
276
  connectionId,
277
277
  data: { message, stack },
278
278
  room,
279
- type: "$ERROR",
279
+ type: "$error",
280
280
  user: (_c = session == null ? void 0 : session.user) != null ? _c : null
281
281
  });
282
282
  }
@@ -605,7 +605,7 @@ var IORoom = class {
605
605
  const session = yield pluvWs.getSession();
606
606
  const sessionId = session.id;
607
607
  const user = session.user;
608
- yield this._sendSelfMessage({ type: "$REGISTERED", data: { sessionId } }, { sessionId, user });
608
+ yield this._sendSelfMessage({ type: "$registered", data: { sessionId } }, { sessionId, user });
609
609
  try {
610
610
  const doc = yield this._doc;
611
611
  const encodedState = doc.getEncodedState();
@@ -632,7 +632,7 @@ var IORoom = class {
632
632
  const session = yield webSocket.getSession();
633
633
  yield this._broadcast({
634
634
  message: {
635
- type: "$EXIT",
635
+ type: "$exit",
636
636
  data: { sessionId: session.id }
637
637
  },
638
638
  senderId: session.id
@@ -948,7 +948,7 @@ var IORoom = class {
948
948
  if (typeof senderId !== "string") return;
949
949
  const pluvWs = this._sessions.get(senderId);
950
950
  if (!pluvWs) return;
951
- if (message.type === "$PONG") yield this._emitQuitters();
951
+ if (message.type === "$pong") yield this._emitQuitters();
952
952
  const session = yield pluvWs.getSession();
953
953
  const user = (_b = session.user) != null ? _b : null;
954
954
  this._sendMessage(pluvWs, __spreadValues({
@@ -1000,7 +1000,7 @@ var IORoom = class {
1000
1000
  };
1001
1001
 
1002
1002
  // src/version.generated.ts
1003
- var version = "0.37.7";
1003
+ var version = "0.38.0";
1004
1004
 
1005
1005
  // src/PluvServer.ts
1006
1006
  var PluvServer = class {
@@ -1008,7 +1008,7 @@ var PluvServer = class {
1008
1008
  this.version = version;
1009
1009
  this._authorize = null;
1010
1010
  this._baseRouter = new PluvRouter({
1011
- $GET_OTHERS: this._procedure.sync((data, { room, session, sessions }) => {
1011
+ $getOthers: this._procedure.sync((data, { room, session, sessions }) => {
1012
1012
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
1013
1013
  const others = sessions.filter((wsSession) => {
1014
1014
  if (wsSession.id === (session == null ? void 0 : session.id)) return false;
@@ -1026,14 +1026,14 @@ var PluvServer = class {
1026
1026
  }),
1027
1027
  {}
1028
1028
  );
1029
- return { $OTHERS_RECEIVED: { others } };
1029
+ return { $othersReceived: { others } };
1030
1030
  }),
1031
- $INITIALIZE_SESSION: this._procedure.broadcast((data, { session }) => {
1031
+ $initializeSession: this._procedure.broadcast((data, { session }) => {
1032
1032
  const presence = data == null ? void 0 : data.presence;
1033
1033
  if (!session) return {};
1034
1034
  session.presence = presence;
1035
1035
  return {
1036
- $USER_JOINED: {
1036
+ $userJoined: {
1037
1037
  connectionId: session.id,
1038
1038
  user: session.user,
1039
1039
  presence
@@ -1059,9 +1059,9 @@ var PluvServer = class {
1059
1059
  });
1060
1060
  }
1061
1061
  const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
1062
- return { $STORAGE_RECEIVED: { state } };
1062
+ return { $storageReceived: { state } };
1063
1063
  })),
1064
- $PING: this._procedure.self((data, { session }) => {
1064
+ $ping: this._procedure.self((data, { session }) => {
1065
1065
  if (!session) return {};
1066
1066
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
1067
1067
  const prevState = session.webSocket.state;
@@ -1070,20 +1070,20 @@ var PluvServer = class {
1070
1070
  ping: currentTime
1071
1071
  })
1072
1072
  }));
1073
- return { $PONG: {} };
1073
+ return { $pong: {} };
1074
1074
  }),
1075
- $UPDATE_PRESENCE: this._procedure.broadcast((data, { session }) => {
1075
+ $updatePresence: this._procedure.broadcast((data, { session }) => {
1076
1076
  const presence = data == null ? void 0 : data.presence;
1077
1077
  if (!session) return {};
1078
1078
  const updated = Object.assign(/* @__PURE__ */ Object.create(null), session.presence, presence);
1079
1079
  session.webSocket.presence = updated;
1080
- return { $PRESENCE_UPDATED: { presence: updated } };
1080
+ return { $presenceUpdated: { presence: updated } };
1081
1081
  }),
1082
- $UPDATE_STORAGE: this._procedure.broadcast((data, { context, doc, room }) => {
1082
+ $updateStorage: this._procedure.broadcast((data, { context, doc, room }) => {
1083
1083
  var _a;
1084
1084
  const origin = data == null ? void 0 : data.origin;
1085
1085
  const update = (_a = data == null ? void 0 : data.update) != null ? _a : null;
1086
- if (origin === "$INITIALIZED" && Object.keys(doc.toJson()).length) return {};
1086
+ if (origin === "$initialized" && Object.keys(doc.toJson()).length) return {};
1087
1087
  const updated = update === null ? doc : doc.applyEncodedState({ update });
1088
1088
  const encodedState = updated.getEncodedState();
1089
1089
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
@@ -1093,7 +1093,7 @@ var PluvServer = class {
1093
1093
  room
1094
1094
  });
1095
1095
  });
1096
- return { $STORAGE_UPDATED: { state: encodedState } };
1096
+ return { $storageUpdated: { state: encodedState } };
1097
1097
  })
1098
1098
  });
1099
1099
  this._context = {};
package/dist/index.mjs CHANGED
@@ -234,7 +234,7 @@ var AbstractWebSocket = class {
234
234
  connectionId,
235
235
  data: { message, stack },
236
236
  room,
237
- type: "$ERROR",
237
+ type: "$error",
238
238
  user: (_c = session == null ? void 0 : session.user) != null ? _c : null
239
239
  });
240
240
  }
@@ -563,7 +563,7 @@ var IORoom = class {
563
563
  const session = yield pluvWs.getSession();
564
564
  const sessionId = session.id;
565
565
  const user = session.user;
566
- yield this._sendSelfMessage({ type: "$REGISTERED", data: { sessionId } }, { sessionId, user });
566
+ yield this._sendSelfMessage({ type: "$registered", data: { sessionId } }, { sessionId, user });
567
567
  try {
568
568
  const doc = yield this._doc;
569
569
  const encodedState = doc.getEncodedState();
@@ -590,7 +590,7 @@ var IORoom = class {
590
590
  const session = yield webSocket.getSession();
591
591
  yield this._broadcast({
592
592
  message: {
593
- type: "$EXIT",
593
+ type: "$exit",
594
594
  data: { sessionId: session.id }
595
595
  },
596
596
  senderId: session.id
@@ -906,7 +906,7 @@ var IORoom = class {
906
906
  if (typeof senderId !== "string") return;
907
907
  const pluvWs = this._sessions.get(senderId);
908
908
  if (!pluvWs) return;
909
- if (message.type === "$PONG") yield this._emitQuitters();
909
+ if (message.type === "$pong") yield this._emitQuitters();
910
910
  const session = yield pluvWs.getSession();
911
911
  const user = (_b = session.user) != null ? _b : null;
912
912
  this._sendMessage(pluvWs, __spreadValues({
@@ -958,7 +958,7 @@ var IORoom = class {
958
958
  };
959
959
 
960
960
  // src/version.generated.ts
961
- var version = "0.37.7";
961
+ var version = "0.38.0";
962
962
 
963
963
  // src/PluvServer.ts
964
964
  var PluvServer = class {
@@ -966,7 +966,7 @@ var PluvServer = class {
966
966
  this.version = version;
967
967
  this._authorize = null;
968
968
  this._baseRouter = new PluvRouter({
969
- $GET_OTHERS: this._procedure.sync((data, { room, session, sessions }) => {
969
+ $getOthers: this._procedure.sync((data, { room, session, sessions }) => {
970
970
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
971
971
  const others = sessions.filter((wsSession) => {
972
972
  if (wsSession.id === (session == null ? void 0 : session.id)) return false;
@@ -984,14 +984,14 @@ var PluvServer = class {
984
984
  }),
985
985
  {}
986
986
  );
987
- return { $OTHERS_RECEIVED: { others } };
987
+ return { $othersReceived: { others } };
988
988
  }),
989
- $INITIALIZE_SESSION: this._procedure.broadcast((data, { session }) => {
989
+ $initializeSession: this._procedure.broadcast((data, { session }) => {
990
990
  const presence = data == null ? void 0 : data.presence;
991
991
  if (!session) return {};
992
992
  session.presence = presence;
993
993
  return {
994
- $USER_JOINED: {
994
+ $userJoined: {
995
995
  connectionId: session.id,
996
996
  user: session.user,
997
997
  presence
@@ -1017,9 +1017,9 @@ var PluvServer = class {
1017
1017
  });
1018
1018
  }
1019
1019
  const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
1020
- return { $STORAGE_RECEIVED: { state } };
1020
+ return { $storageReceived: { state } };
1021
1021
  })),
1022
- $PING: this._procedure.self((data, { session }) => {
1022
+ $ping: this._procedure.self((data, { session }) => {
1023
1023
  if (!session) return {};
1024
1024
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
1025
1025
  const prevState = session.webSocket.state;
@@ -1028,20 +1028,20 @@ var PluvServer = class {
1028
1028
  ping: currentTime
1029
1029
  })
1030
1030
  }));
1031
- return { $PONG: {} };
1031
+ return { $pong: {} };
1032
1032
  }),
1033
- $UPDATE_PRESENCE: this._procedure.broadcast((data, { session }) => {
1033
+ $updatePresence: this._procedure.broadcast((data, { session }) => {
1034
1034
  const presence = data == null ? void 0 : data.presence;
1035
1035
  if (!session) return {};
1036
1036
  const updated = Object.assign(/* @__PURE__ */ Object.create(null), session.presence, presence);
1037
1037
  session.webSocket.presence = updated;
1038
- return { $PRESENCE_UPDATED: { presence: updated } };
1038
+ return { $presenceUpdated: { presence: updated } };
1039
1039
  }),
1040
- $UPDATE_STORAGE: this._procedure.broadcast((data, { context, doc, room }) => {
1040
+ $updateStorage: this._procedure.broadcast((data, { context, doc, room }) => {
1041
1041
  var _a;
1042
1042
  const origin = data == null ? void 0 : data.origin;
1043
1043
  const update = (_a = data == null ? void 0 : data.update) != null ? _a : null;
1044
- if (origin === "$INITIALIZED" && Object.keys(doc.toJson()).length) return {};
1044
+ if (origin === "$initialized" && Object.keys(doc.toJson()).length) return {};
1045
1045
  const updated = update === null ? doc : doc.applyEncodedState({ update });
1046
1046
  const encodedState = updated.getEncodedState();
1047
1047
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
@@ -1051,7 +1051,7 @@ var PluvServer = class {
1051
1051
  room
1052
1052
  });
1053
1053
  });
1054
- return { $STORAGE_UPDATED: { state: encodedState } };
1054
+ return { $storageUpdated: { state: encodedState } };
1055
1055
  })
1056
1056
  });
1057
1057
  this._context = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.37.7",
3
+ "version": "0.38.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.10.0",
22
22
  "kleur": "^4.1.5",
23
23
  "wonka": "^6.3.5",
24
- "@pluv/crdt": "^0.37.7",
25
- "@pluv/types": "^0.37.7"
24
+ "@pluv/crdt": "^0.38.0",
25
+ "@pluv/types": "^0.38.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^8.57.1",
29
29
  "genversion": "^3.2.0",
30
30
  "tsup": "^8.4.0",
31
31
  "typescript": "^5.8.2",
32
- "@pluv/tsconfig": "^0.37.7",
33
- "eslint-config-pluv": "^0.37.7"
32
+ "@pluv/tsconfig": "^0.38.0",
33
+ "eslint-config-pluv": "^0.38.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
@@ -133,7 +133,7 @@ export abstract class AbstractWebSocket<TWebSocket = any> {
133
133
  connectionId,
134
134
  data: { message, stack },
135
135
  room,
136
- type: "$ERROR" as const,
136
+ type: "$error" as const,
137
137
  user: session?.user ?? null,
138
138
  });
139
139
  }
package/src/IORoom.ts CHANGED
@@ -383,7 +383,7 @@ export class IORoom<
383
383
  const sessionId = session.id;
384
384
  const user = session.user;
385
385
 
386
- await this._sendSelfMessage({ type: "$REGISTERED", data: { sessionId } }, { sessionId, user });
386
+ await this._sendSelfMessage({ type: "$registered", data: { sessionId } }, { sessionId, user });
387
387
 
388
388
  try {
389
389
  const doc = await this._doc;
@@ -414,7 +414,7 @@ export class IORoom<
414
414
 
415
415
  await this._broadcast({
416
416
  message: {
417
- type: "$EXIT",
417
+ type: "$exit",
418
418
  data: { sessionId: session.id },
419
419
  },
420
420
  senderId: session.id,
@@ -821,7 +821,7 @@ export class IORoom<
821
821
  const pluvWs = this._sessions.get(senderId);
822
822
 
823
823
  if (!pluvWs) return;
824
- if (message.type === "$PONG") await this._emitQuitters();
824
+ if (message.type === "$pong") await this._emitQuitters();
825
825
 
826
826
  const session = await pluvWs.getSession();
827
827
  const user = session.user ?? null;
package/src/PluvServer.ts CHANGED
@@ -70,7 +70,7 @@ export class PluvServer<
70
70
 
71
71
  private readonly _authorize: TAuthorize = null as TAuthorize;
72
72
  private readonly _baseRouter: PluvRouter<TPlatform, TAuthorize, TContext, {}> = new PluvRouter({
73
- $GET_OTHERS: this._procedure.sync((data, { room, session, sessions }) => {
73
+ $getOthers: this._procedure.sync((data, { room, session, sessions }) => {
74
74
  const currentTime = new Date().getTime();
75
75
 
76
76
  const others = sessions
@@ -100,9 +100,9 @@ export class PluvServer<
100
100
  {},
101
101
  );
102
102
 
103
- return { $OTHERS_RECEIVED: { others } };
103
+ return { $othersReceived: { others } };
104
104
  }),
105
- $INITIALIZE_SESSION: this._procedure
105
+ $initializeSession: this._procedure
106
106
  .broadcast((data, { session }) => {
107
107
  const presence = (data as any)?.presence;
108
108
 
@@ -111,7 +111,7 @@ export class PluvServer<
111
111
  session.presence = presence;
112
112
 
113
113
  return {
114
- $USER_JOINED: {
114
+ $userJoined: {
115
115
  connectionId: session.id,
116
116
  user: session.user,
117
117
  presence,
@@ -143,9 +143,9 @@ export class PluvServer<
143
143
 
144
144
  const state = (await this._platform.persistence.getStorageState(room)) ?? doc.getEncodedState();
145
145
 
146
- return { $STORAGE_RECEIVED: { state } };
146
+ return { $storageReceived: { state } };
147
147
  }),
148
- $PING: this._procedure.self((data, { session }) => {
148
+ $ping: this._procedure.self((data, { session }) => {
149
149
  if (!session) return {};
150
150
 
151
151
  const currentTime = new Date().getTime();
@@ -159,9 +159,9 @@ export class PluvServer<
159
159
  },
160
160
  });
161
161
 
162
- return { $PONG: {} };
162
+ return { $pong: {} };
163
163
  }),
164
- $UPDATE_PRESENCE: this._procedure.broadcast((data, { session }) => {
164
+ $updatePresence: this._procedure.broadcast((data, { session }) => {
165
165
  const presence = (data as any)?.presence;
166
166
 
167
167
  if (!session) return {};
@@ -170,13 +170,13 @@ export class PluvServer<
170
170
 
171
171
  session.webSocket.presence = updated;
172
172
 
173
- return { $PRESENCE_UPDATED: { presence: updated } };
173
+ return { $presenceUpdated: { presence: updated } };
174
174
  }),
175
- $UPDATE_STORAGE: this._procedure.broadcast((data, { context, doc, room }) => {
175
+ $updateStorage: this._procedure.broadcast((data, { context, doc, room }) => {
176
176
  const origin = (data as any)?.origin as Maybe<string>;
177
177
  const update: string | null = (data as any)?.update ?? null;
178
178
 
179
- if (origin === "$INITIALIZED" && Object.keys(doc.toJson()).length) return {};
179
+ if (origin === "$initialized" && Object.keys(doc.toJson()).length) return {};
180
180
 
181
181
  const updated = update === null ? doc : doc.applyEncodedState({ update });
182
182
  const encodedState = updated.getEncodedState();
@@ -189,7 +189,7 @@ export class PluvServer<
189
189
  });
190
190
  });
191
191
 
192
- return { $STORAGE_UPDATED: { state: encodedState } };
192
+ return { $storageUpdated: { state: encodedState } };
193
193
  }),
194
194
  });
195
195
  private readonly _context: PluvContext<TPlatform, TContext> = {} as PluvContext<TPlatform, TContext>;
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.37.7'
2
+ export const version = '0.38.0'