@pluv/io 0.32.2 → 0.32.4

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.32.2 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.32.4 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.32.2 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@0.32.4 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 40.14 KB
16
- ESM ⚡️ Build success in 156ms
17
- CJS dist/index.js 42.31 KB
18
- CJS ⚡️ Build success in 157ms
15
+ ESM dist/index.mjs 40.83 KB
16
+ ESM ⚡️ Build success in 101ms
17
+ CJS dist/index.js 43.00 KB
18
+ CJS ⚡️ Build success in 109ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2478ms
21
- DTS dist/index.d.mts 26.33 KB
22
- DTS dist/index.d.ts 26.33 KB
20
+ DTS ⚡️ Build success in 2393ms
21
+ DTS dist/index.d.mts 26.66 KB
22
+ DTS dist/index.d.ts 26.66 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.32.4
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@0.32.4
8
+ - @pluv/types@0.32.4
9
+
10
+ ## 0.32.3
11
+
12
+ ### Patch Changes
13
+
14
+ - bb21274: Added the ability to evict (i.e. close) a connection to a room via `IORoom.evict` and `IORoom.evictAll`.
15
+ - @pluv/crdt@0.32.3
16
+ - @pluv/types@0.32.3
17
+
3
18
  ## 0.32.2
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -313,6 +313,16 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
313
313
  get broadcast(): BroadcastProxy<this>;
314
314
  private get _initialized();
315
315
  constructor(id: string, config: IORoomConfig<TPlatform, TAuthorize, TContext, TEvents>);
316
+ /**
317
+ * @description Closes a connection with the specified sessionId
318
+ * @param sessionId The session id of the connection to close
319
+ */
320
+ evict(sessionId: string): Promise<void>;
321
+ /**
322
+ * @description Closes all connections to this room, effectively destroying
323
+ * the room
324
+ */
325
+ evictAll(): Promise<void>;
316
326
  getSize(): number;
317
327
  onClose(webSocket: WebSocketType<TPlatform>): (event: AbstractCloseEvent) => Promise<void>;
318
328
  onError(webSocket: WebSocketType<TPlatform>): (event: AbstractErrorEvent) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -313,6 +313,16 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
313
313
  get broadcast(): BroadcastProxy<this>;
314
314
  private get _initialized();
315
315
  constructor(id: string, config: IORoomConfig<TPlatform, TAuthorize, TContext, TEvents>);
316
+ /**
317
+ * @description Closes a connection with the specified sessionId
318
+ * @param sessionId The session id of the connection to close
319
+ */
320
+ evict(sessionId: string): Promise<void>;
321
+ /**
322
+ * @description Closes all connections to this room, effectively destroying
323
+ * the room
324
+ */
325
+ evictAll(): Promise<void>;
316
326
  getSize(): number;
317
327
  onClose(webSocket: WebSocketType<TPlatform>): (event: AbstractCloseEvent) => Promise<void>;
318
328
  onError(webSocket: WebSocketType<TPlatform>): (event: AbstractErrorEvent) => Promise<void>;
package/dist/index.js CHANGED
@@ -462,6 +462,30 @@ var IORoom = class {
462
462
  var _a;
463
463
  return Promise.resolve(!!((_a = this._uninitialize) == null ? void 0 : _a.then((result) => !!result)));
464
464
  }
465
+ /**
466
+ * @description Closes a connection with the specified sessionId
467
+ * @param sessionId The session id of the connection to close
468
+ */
469
+ evict(sessionId) {
470
+ return __async(this, null, function* () {
471
+ const session = this._sessions.get(sessionId);
472
+ if (session) session.state.quit = true;
473
+ yield this._emitQuitters();
474
+ });
475
+ }
476
+ /**
477
+ * @description Closes all connections to this room, effectively destroying
478
+ * the room
479
+ */
480
+ evictAll() {
481
+ return __async(this, null, function* () {
482
+ const sessions = Array.from(this._sessions.values());
483
+ sessions.forEach((session) => {
484
+ session.state.quit = true;
485
+ });
486
+ yield this._emitQuitters();
487
+ });
488
+ }
465
489
  getSize() {
466
490
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
467
491
  return Array.from(this._sessions.values()).reduce((count, pluvWs) => {
@@ -933,7 +957,7 @@ var IORoom = class {
933
957
  };
934
958
 
935
959
  // src/version.generated.ts
936
- var version = "0.32.2";
960
+ var version = "0.32.4";
937
961
 
938
962
  // src/PluvServer.ts
939
963
  var PluvServer = class {
package/dist/index.mjs CHANGED
@@ -420,6 +420,30 @@ var IORoom = class {
420
420
  var _a;
421
421
  return Promise.resolve(!!((_a = this._uninitialize) == null ? void 0 : _a.then((result) => !!result)));
422
422
  }
423
+ /**
424
+ * @description Closes a connection with the specified sessionId
425
+ * @param sessionId The session id of the connection to close
426
+ */
427
+ evict(sessionId) {
428
+ return __async(this, null, function* () {
429
+ const session = this._sessions.get(sessionId);
430
+ if (session) session.state.quit = true;
431
+ yield this._emitQuitters();
432
+ });
433
+ }
434
+ /**
435
+ * @description Closes all connections to this room, effectively destroying
436
+ * the room
437
+ */
438
+ evictAll() {
439
+ return __async(this, null, function* () {
440
+ const sessions = Array.from(this._sessions.values());
441
+ sessions.forEach((session) => {
442
+ session.state.quit = true;
443
+ });
444
+ yield this._emitQuitters();
445
+ });
446
+ }
423
447
  getSize() {
424
448
  const currentTime = (/* @__PURE__ */ new Date()).getTime();
425
449
  return Array.from(this._sessions.values()).reduce((count, pluvWs) => {
@@ -891,7 +915,7 @@ var IORoom = class {
891
915
  };
892
916
 
893
917
  // src/version.generated.ts
894
- var version = "0.32.2";
918
+ var version = "0.32.4";
895
919
 
896
920
  // src/PluvServer.ts
897
921
  var PluvServer = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.32.2",
3
+ "version": "0.32.4",
4
4
  "description": "@pluv/io server-side websocket manager",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,19 +18,19 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@panva/hkdf": "^1.2.1",
21
- "jose": "^5.9.3",
21
+ "jose": "^5.9.6",
22
22
  "kleur": "^4.1.5",
23
23
  "wonka": "^6.3.4",
24
- "@pluv/crdt": "^0.32.2",
25
- "@pluv/types": "^0.32.2"
24
+ "@pluv/crdt": "^0.32.4",
25
+ "@pluv/types": "^0.32.4"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^8.57.0",
29
29
  "genversion": "^3.2.0",
30
30
  "tsup": "^8.3.0",
31
- "typescript": "^5.6.2",
32
- "@pluv/tsconfig": "^0.32.2",
33
- "eslint-config-pluv": "^0.32.2"
31
+ "typescript": "^5.6.3",
32
+ "@pluv/tsconfig": "^0.32.4",
33
+ "eslint-config-pluv": "^0.32.4"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
package/src/IORoom.ts CHANGED
@@ -191,6 +191,32 @@ export class IORoom<
191
191
  this._uninitialize = uninitialize;
192
192
  }
193
193
 
194
+ /**
195
+ * @description Closes a connection with the specified sessionId
196
+ * @param sessionId The session id of the connection to close
197
+ */
198
+ public async evict(sessionId: string): Promise<void> {
199
+ const session = this._sessions.get(sessionId);
200
+
201
+ if (session) session.state.quit = true;
202
+
203
+ await this._emitQuitters();
204
+ }
205
+
206
+ /**
207
+ * @description Closes all connections to this room, effectively destroying
208
+ * the room
209
+ */
210
+ public async evictAll(): Promise<void> {
211
+ const sessions = Array.from(this._sessions.values());
212
+
213
+ sessions.forEach((session) => {
214
+ session.state.quit = true;
215
+ });
216
+
217
+ await this._emitQuitters();
218
+ }
219
+
194
220
  public getSize(): number {
195
221
  const currentTime = new Date().getTime();
196
222
 
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.32.2'
2
+ export const version = '0.32.4'