@pluv/io 0.3.2 → 0.3.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,5 +1,5 @@
1
1
 
2
- > @pluv/io@0.3.2 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.3.4 build /home/runner/work/pluv/pluv/packages/io
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,10 +8,10 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 29.21 KB
12
- CJS ⚡️ Build success in 69ms
13
- ESM dist/index.mjs 27.13 KB
14
- ESM ⚡️ Build success in 71ms
11
+ CJS dist/index.js 29.25 KB
12
+ CJS ⚡️ Build success in 80ms
13
+ ESM dist/index.mjs 27.19 KB
14
+ ESM ⚡️ Build success in 87ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 2367ms
16
+ DTS ⚡️ Build success in 2666ms
17
17
  DTS dist/index.d.ts 12.73 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 850626e: bumped dependencies
8
+ - Updated dependencies [850626e]
9
+ - @pluv/crdt-yjs@0.3.5
10
+ - @pluv/types@0.1.6
11
+
12
+ ## 0.3.3
13
+
14
+ ### Patch Changes
15
+
16
+ - 77069a1: replaced chalk for kleur
17
+ - @pluv/crdt-yjs@0.3.4
18
+ - @pluv/types@0.1.5
19
+
3
20
  ## 0.3.2
4
21
 
5
22
  ### Patch Changes
package/dist/index.js CHANGED
@@ -259,7 +259,7 @@ var AbstractWebSocket = class {
259
259
  };
260
260
 
261
261
  // src/PluvIO.ts
262
- var import_chalk2 = __toESM(require("chalk"));
262
+ var import_kleur2 = __toESM(require("kleur"));
263
263
 
264
264
  // src/authorize.ts
265
265
  var import_hkdf = __toESM(require("@panva/hkdf"));
@@ -299,7 +299,7 @@ var authorize = (params) => {
299
299
 
300
300
  // src/IORoom.ts
301
301
  var import_crdt_yjs = require("@pluv/crdt-yjs");
302
- var import_chalk = __toESM(require("chalk"));
302
+ var import_kleur = __toESM(require("kleur"));
303
303
  var PING_TIMEOUT_MS = 3e4;
304
304
  var IORoom = class {
305
305
  constructor(id, config) {
@@ -345,7 +345,7 @@ var IORoom = class {
345
345
  room: this.id
346
346
  });
347
347
  this._logDebug(
348
- `${import_chalk.default.blue(
348
+ `${import_kleur.default.blue(
349
349
  `Registering connection for room ${this.id}:`
350
350
  )} ${sessionId}`
351
351
  );
@@ -360,7 +360,7 @@ var IORoom = class {
360
360
  );
361
361
  if (isUnauthorized || isTokenInUse) {
362
362
  this._logDebug(
363
- `${import_chalk.default.blue(
363
+ `${import_kleur.default.blue(
364
364
  "Authorization failed for connection:"
365
365
  )} ${sessionId}`
366
366
  );
@@ -450,7 +450,7 @@ var IORoom = class {
450
450
  return;
451
451
  session.quit = true;
452
452
  this._logDebug(
453
- `${import_chalk.default.blue(
453
+ `${import_kleur.default.blue(
454
454
  `(Unregistering connection for room ${this.id}:`
455
455
  )} ${sessionId}`
456
456
  );
@@ -467,12 +467,12 @@ var IORoom = class {
467
467
  uninitializeWs();
468
468
  const size2 = this._getSessionsSize();
469
469
  this._logDebug(
470
- `${import_chalk.default.blue(
470
+ `${import_kleur.default.blue(
471
471
  `Unregistered connection for room ${this.id}:`
472
472
  )} ${sessionId}`
473
473
  );
474
474
  this._logDebug(
475
- `${import_chalk.default.blue(`Room ${this.id} size:`)} ${size2}`
475
+ `${import_kleur.default.blue(`Room ${this.id} size:`)} ${size2}`
476
476
  );
477
477
  if (size2)
478
478
  return;
@@ -482,12 +482,12 @@ var IORoom = class {
482
482
  pluvWs.addEventListener("close", closeHandler);
483
483
  pluvWs.addEventListener("error", closeHandler);
484
484
  this._logDebug(
485
- `${import_chalk.default.blue(
485
+ `${import_kleur.default.blue(
486
486
  `Registered connection for room ${this.id}:`
487
487
  )} ${sessionId}`
488
488
  );
489
489
  const size = this._getSessionsSize();
490
- this._logDebug(`${import_chalk.default.blue(`Room ${this.id} size:`)} ${size}`);
490
+ this._logDebug(`${import_kleur.default.blue(`Room ${this.id} size:`)} ${size}`);
491
491
  });
492
492
  }
493
493
  _broadcast(params) {
@@ -568,22 +568,24 @@ var IORoom = class {
568
568
  secret: this._authorize.secret
569
569
  }).decode(token);
570
570
  if (!payload) {
571
- this._logDebug(import_chalk.default.blue("Could not decode token:"));
571
+ this._logDebug(import_kleur.default.blue("Could not decode token:"));
572
572
  this._logDebug(token);
573
573
  return null;
574
574
  }
575
575
  if (payload.room !== this.id) {
576
576
  this._logDebug(
577
- import_chalk.default.blue(`Token is not authorized for room ${this.id}:`)
577
+ import_kleur.default.blue(`Token is not authorized for room ${this.id}:`)
578
578
  );
579
- this._logDebug(import_chalk.default.blue("Received:"), payload.room);
579
+ this._logDebug(import_kleur.default.blue("Received:"), payload.room);
580
580
  this._logDebug(token);
581
581
  return null;
582
582
  }
583
583
  try {
584
584
  return (_a = this._authorize.user.parse(payload.user)) != null ? _a : null;
585
585
  } catch (e) {
586
- this._logDebug(`${import_chalk.default.blue("Token fails validation:")} ${token}`);
586
+ this._logDebug(
587
+ `${import_kleur.default.blue("Token fails validation:")} ${token}`
588
+ );
587
589
  return null;
588
590
  }
589
591
  });
@@ -602,7 +604,7 @@ var IORoom = class {
602
604
  }
603
605
  _initialize() {
604
606
  return __async(this, null, function* () {
605
- this._logDebug(`${import_chalk.default.blue(`Initializing room ${this.id}:`)}`);
607
+ this._logDebug(`${import_kleur.default.blue(`Initializing room ${this.id}:`)}`);
606
608
  if (!!this._uninitialize) {
607
609
  yield this._uninitialize();
608
610
  this._uninitialize = null;
@@ -878,13 +880,15 @@ var PluvIO = class {
878
880
  return (_a2 = this._initialStorage) == null ? void 0 : _a2.call(this, room);
879
881
  },
880
882
  onDestroy: (encodedState) => {
881
- this._logDebug(`${import_chalk2.default.blue("Deleting empty room:")} ${room}`);
883
+ this._logDebug(
884
+ `${import_kleur2.default.blue("Deleting empty room:")} ${room}`
885
+ );
882
886
  this._rooms.delete(room);
883
887
  if (this._debug) {
884
888
  const rooms = Array.from(this._rooms.keys());
885
- this._logDebug(`${import_chalk2.default.blue("Deleted room:")} ${room}`);
889
+ this._logDebug(`${import_kleur2.default.blue("Deleted room:")} ${room}`);
886
890
  this._logDebug(
887
- `${import_chalk2.default.blue("Rooms available:")} ${rooms.join(", ")}`
891
+ `${import_kleur2.default.blue("Rooms available:")} ${rooms.join(", ")}`
888
892
  );
889
893
  }
890
894
  this._platform.persistance.getSize(room).then((size) => {
@@ -898,9 +902,9 @@ var PluvIO = class {
898
902
  this._rooms.set(room, newRoom);
899
903
  if (this._debug) {
900
904
  const rooms = Array.from(this._rooms.keys());
901
- this._logDebug(`${import_chalk2.default.blue("Created room:")} ${room}`);
905
+ this._logDebug(`${import_kleur2.default.blue("Created room:")} ${room}`);
902
906
  this._logDebug(
903
- `${import_chalk2.default.blue("Rooms available:")} ${rooms.join(", ")}`
907
+ `${import_kleur2.default.blue("Rooms available:")} ${rooms.join(", ")}`
904
908
  );
905
909
  }
906
910
  return newRoom;
package/dist/index.mjs CHANGED
@@ -222,7 +222,7 @@ var AbstractWebSocket = class {
222
222
  };
223
223
 
224
224
  // src/PluvIO.ts
225
- import chalk2 from "chalk";
225
+ import colors2 from "kleur";
226
226
 
227
227
  // src/authorize.ts
228
228
  import hkdf from "@panva/hkdf";
@@ -262,7 +262,7 @@ var authorize = (params) => {
262
262
 
263
263
  // src/IORoom.ts
264
264
  import { doc } from "@pluv/crdt-yjs";
265
- import chalk from "chalk";
265
+ import colors from "kleur";
266
266
  var PING_TIMEOUT_MS = 3e4;
267
267
  var IORoom = class {
268
268
  constructor(id, config) {
@@ -308,7 +308,7 @@ var IORoom = class {
308
308
  room: this.id
309
309
  });
310
310
  this._logDebug(
311
- `${chalk.blue(
311
+ `${colors.blue(
312
312
  `Registering connection for room ${this.id}:`
313
313
  )} ${sessionId}`
314
314
  );
@@ -323,7 +323,7 @@ var IORoom = class {
323
323
  );
324
324
  if (isUnauthorized || isTokenInUse) {
325
325
  this._logDebug(
326
- `${chalk.blue(
326
+ `${colors.blue(
327
327
  "Authorization failed for connection:"
328
328
  )} ${sessionId}`
329
329
  );
@@ -413,7 +413,7 @@ var IORoom = class {
413
413
  return;
414
414
  session.quit = true;
415
415
  this._logDebug(
416
- `${chalk.blue(
416
+ `${colors.blue(
417
417
  `(Unregistering connection for room ${this.id}:`
418
418
  )} ${sessionId}`
419
419
  );
@@ -430,12 +430,12 @@ var IORoom = class {
430
430
  uninitializeWs();
431
431
  const size2 = this._getSessionsSize();
432
432
  this._logDebug(
433
- `${chalk.blue(
433
+ `${colors.blue(
434
434
  `Unregistered connection for room ${this.id}:`
435
435
  )} ${sessionId}`
436
436
  );
437
437
  this._logDebug(
438
- `${chalk.blue(`Room ${this.id} size:`)} ${size2}`
438
+ `${colors.blue(`Room ${this.id} size:`)} ${size2}`
439
439
  );
440
440
  if (size2)
441
441
  return;
@@ -445,12 +445,12 @@ var IORoom = class {
445
445
  pluvWs.addEventListener("close", closeHandler);
446
446
  pluvWs.addEventListener("error", closeHandler);
447
447
  this._logDebug(
448
- `${chalk.blue(
448
+ `${colors.blue(
449
449
  `Registered connection for room ${this.id}:`
450
450
  )} ${sessionId}`
451
451
  );
452
452
  const size = this._getSessionsSize();
453
- this._logDebug(`${chalk.blue(`Room ${this.id} size:`)} ${size}`);
453
+ this._logDebug(`${colors.blue(`Room ${this.id} size:`)} ${size}`);
454
454
  });
455
455
  }
456
456
  _broadcast(params) {
@@ -531,22 +531,24 @@ var IORoom = class {
531
531
  secret: this._authorize.secret
532
532
  }).decode(token);
533
533
  if (!payload) {
534
- this._logDebug(chalk.blue("Could not decode token:"));
534
+ this._logDebug(colors.blue("Could not decode token:"));
535
535
  this._logDebug(token);
536
536
  return null;
537
537
  }
538
538
  if (payload.room !== this.id) {
539
539
  this._logDebug(
540
- chalk.blue(`Token is not authorized for room ${this.id}:`)
540
+ colors.blue(`Token is not authorized for room ${this.id}:`)
541
541
  );
542
- this._logDebug(chalk.blue("Received:"), payload.room);
542
+ this._logDebug(colors.blue("Received:"), payload.room);
543
543
  this._logDebug(token);
544
544
  return null;
545
545
  }
546
546
  try {
547
547
  return (_a = this._authorize.user.parse(payload.user)) != null ? _a : null;
548
548
  } catch (e) {
549
- this._logDebug(`${chalk.blue("Token fails validation:")} ${token}`);
549
+ this._logDebug(
550
+ `${colors.blue("Token fails validation:")} ${token}`
551
+ );
550
552
  return null;
551
553
  }
552
554
  });
@@ -565,7 +567,7 @@ var IORoom = class {
565
567
  }
566
568
  _initialize() {
567
569
  return __async(this, null, function* () {
568
- this._logDebug(`${chalk.blue(`Initializing room ${this.id}:`)}`);
570
+ this._logDebug(`${colors.blue(`Initializing room ${this.id}:`)}`);
569
571
  if (!!this._uninitialize) {
570
572
  yield this._uninitialize();
571
573
  this._uninitialize = null;
@@ -841,13 +843,15 @@ var PluvIO = class {
841
843
  return (_a2 = this._initialStorage) == null ? void 0 : _a2.call(this, room);
842
844
  },
843
845
  onDestroy: (encodedState) => {
844
- this._logDebug(`${chalk2.blue("Deleting empty room:")} ${room}`);
846
+ this._logDebug(
847
+ `${colors2.blue("Deleting empty room:")} ${room}`
848
+ );
845
849
  this._rooms.delete(room);
846
850
  if (this._debug) {
847
851
  const rooms = Array.from(this._rooms.keys());
848
- this._logDebug(`${chalk2.blue("Deleted room:")} ${room}`);
852
+ this._logDebug(`${colors2.blue("Deleted room:")} ${room}`);
849
853
  this._logDebug(
850
- `${chalk2.blue("Rooms available:")} ${rooms.join(", ")}`
854
+ `${colors2.blue("Rooms available:")} ${rooms.join(", ")}`
851
855
  );
852
856
  }
853
857
  this._platform.persistance.getSize(room).then((size) => {
@@ -861,9 +865,9 @@ var PluvIO = class {
861
865
  this._rooms.set(room, newRoom);
862
866
  if (this._debug) {
863
867
  const rooms = Array.from(this._rooms.keys());
864
- this._logDebug(`${chalk2.blue("Created room:")} ${room}`);
868
+ this._logDebug(`${colors2.blue("Created room:")} ${room}`);
865
869
  this._logDebug(
866
- `${chalk2.blue("Rooms available:")} ${rooms.join(", ")}`
870
+ `${colors2.blue("Rooms available:")} ${rooms.join(", ")}`
867
871
  );
868
872
  }
869
873
  return newRoom;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "@pluv/io server-side websocket manager",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,21 +18,21 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@panva/hkdf": "^1.0.4",
21
- "chalk": "^4.1.2",
22
21
  "jose": "^4.13.1",
22
+ "kleur": "^4.1.5",
23
23
  "wonka": "^6.3.1",
24
- "@pluv/crdt-yjs": "^0.3.4",
25
- "@pluv/types": "^0.1.5"
24
+ "@pluv/crdt-yjs": "^0.3.5",
25
+ "@pluv/types": "^0.1.6"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "yjs": "^13.0.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "tsup": "^6.7.0",
32
- "typescript": "^5.0.3",
32
+ "typescript": "^5.0.4",
33
33
  "yjs": "^13.5.52",
34
- "@pluv/tsconfig": "^0.1.4",
35
- "eslint-config-pluv": "^0.1.8"
34
+ "@pluv/tsconfig": "^0.1.5",
35
+ "eslint-config-pluv": "^0.1.10"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/IORoom.ts CHANGED
@@ -16,7 +16,7 @@ import type {
16
16
  Maybe,
17
17
  MaybePromise,
18
18
  } from "@pluv/types";
19
- import chalk from "chalk";
19
+ import colors from "kleur";
20
20
  import type { AbstractPlatform, InferWebSocketType } from "./AbstractPlatform";
21
21
  import { authorize } from "./authorize";
22
22
  import type {
@@ -139,7 +139,7 @@ export class IORoom<
139
139
  });
140
140
 
141
141
  this._logDebug(
142
- `${chalk.blue(
142
+ `${colors.blue(
143
143
  `Registering connection for room ${this.id}:`
144
144
  )} ${sessionId}`
145
145
  );
@@ -158,7 +158,7 @@ export class IORoom<
158
158
 
159
159
  if (isUnauthorized || isTokenInUse) {
160
160
  this._logDebug(
161
- `${chalk.blue(
161
+ `${colors.blue(
162
162
  "Authorization failed for connection:"
163
163
  )} ${sessionId}`
164
164
  );
@@ -266,7 +266,7 @@ export class IORoom<
266
266
  session.quit = true;
267
267
 
268
268
  this._logDebug(
269
- `${chalk.blue(
269
+ `${colors.blue(
270
270
  `(Unregistering connection for room ${this.id}:`
271
271
  )} ${sessionId}`
272
272
  );
@@ -288,12 +288,12 @@ export class IORoom<
288
288
  const size = this._getSessionsSize();
289
289
 
290
290
  this._logDebug(
291
- `${chalk.blue(
291
+ `${colors.blue(
292
292
  `Unregistered connection for room ${this.id}:`
293
293
  )} ${sessionId}`
294
294
  );
295
295
  this._logDebug(
296
- `${chalk.blue(`Room ${this.id} size:`)} ${size}`
296
+ `${colors.blue(`Room ${this.id} size:`)} ${size}`
297
297
  );
298
298
 
299
299
  if (size) return;
@@ -306,14 +306,14 @@ export class IORoom<
306
306
  pluvWs.addEventListener("error", closeHandler);
307
307
 
308
308
  this._logDebug(
309
- `${chalk.blue(
309
+ `${colors.blue(
310
310
  `Registered connection for room ${this.id}:`
311
311
  )} ${sessionId}`
312
312
  );
313
313
 
314
314
  const size = this._getSessionsSize();
315
315
 
316
- this._logDebug(`${chalk.blue(`Room ${this.id} size:`)} ${size}`);
316
+ this._logDebug(`${colors.blue(`Room ${this.id} size:`)} ${size}`);
317
317
  }
318
318
 
319
319
  private _broadcast(params: BroadcastParams<this>): void {
@@ -412,7 +412,7 @@ export class IORoom<
412
412
  }).decode(token);
413
413
 
414
414
  if (!payload) {
415
- this._logDebug(chalk.blue("Could not decode token:"));
415
+ this._logDebug(colors.blue("Could not decode token:"));
416
416
  this._logDebug(token);
417
417
 
418
418
  return null;
@@ -420,9 +420,9 @@ export class IORoom<
420
420
 
421
421
  if (payload.room !== this.id) {
422
422
  this._logDebug(
423
- chalk.blue(`Token is not authorized for room ${this.id}:`)
423
+ colors.blue(`Token is not authorized for room ${this.id}:`)
424
424
  );
425
- this._logDebug(chalk.blue("Received:"), payload.room);
425
+ this._logDebug(colors.blue("Received:"), payload.room);
426
426
  this._logDebug(token);
427
427
 
428
428
  return null;
@@ -431,7 +431,9 @@ export class IORoom<
431
431
  try {
432
432
  return this._authorize.user.parse(payload.user) ?? null;
433
433
  } catch {
434
- this._logDebug(`${chalk.blue("Token fails validation:")} ${token}`);
434
+ this._logDebug(
435
+ `${colors.blue("Token fails validation:")} ${token}`
436
+ );
435
437
 
436
438
  return null;
437
439
  }
@@ -462,7 +464,7 @@ export class IORoom<
462
464
  }
463
465
 
464
466
  private async _initialize(): Promise<void> {
465
- this._logDebug(`${chalk.blue(`Initializing room ${this.id}:`)}`);
467
+ this._logDebug(`${colors.blue(`Initializing room ${this.id}:`)}`);
466
468
 
467
469
  if (!!this._uninitialize) {
468
470
  await this._uninitialize();
package/src/PluvIO.ts CHANGED
@@ -12,7 +12,7 @@ import type {
12
12
  MaybePromise,
13
13
  Maybe,
14
14
  } from "@pluv/types";
15
- import chalk from "chalk";
15
+ import colors from "kleur";
16
16
  import type { AbstractPlatform } from "./AbstractPlatform";
17
17
  import type { JWTEncodeParams } from "./authorize";
18
18
  import { authorize } from "./authorize";
@@ -277,16 +277,18 @@ export class PluvIO<
277
277
  events: this._events,
278
278
  initialStorage: () => this._initialStorage?.(room),
279
279
  onDestroy: (encodedState) => {
280
- this._logDebug(`${chalk.blue("Deleting empty room:")} ${room}`);
280
+ this._logDebug(
281
+ `${colors.blue("Deleting empty room:")} ${room}`
282
+ );
281
283
 
282
284
  this._rooms.delete(room);
283
285
 
284
286
  if (this._debug) {
285
287
  const rooms = Array.from(this._rooms.keys());
286
288
 
287
- this._logDebug(`${chalk.blue("Deleted room:")} ${room}`);
289
+ this._logDebug(`${colors.blue("Deleted room:")} ${room}`);
288
290
  this._logDebug(
289
- `${chalk.blue("Rooms available:")} ${rooms.join(", ")}`
291
+ `${colors.blue("Rooms available:")} ${rooms.join(", ")}`
290
292
  );
291
293
  }
292
294
 
@@ -304,9 +306,9 @@ export class PluvIO<
304
306
  if (this._debug) {
305
307
  const rooms = Array.from(this._rooms.keys());
306
308
 
307
- this._logDebug(`${chalk.blue("Created room:")} ${room}`);
309
+ this._logDebug(`${colors.blue("Created room:")} ${room}`);
308
310
  this._logDebug(
309
- `${chalk.blue("Rooms available:")} ${rooms.join(", ")}`
311
+ `${colors.blue("Rooms available:")} ${rooms.join(", ")}`
310
312
  );
311
313
  }
312
314