@pluv/io 0.25.0 → 0.25.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.
@@ -1,9 +1,9 @@
1
1
 
2
- > @pluv/io@0.25.0 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.25.2 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.25.0 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@0.25.2 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
- CJS dist/index.js 41.55 KB
16
- CJS ⚡️ Build success in 147ms
17
- ESM dist/index.mjs 39.41 KB
18
- ESM ⚡️ Build success in 148ms
15
+ ESM dist/index.mjs 39.55 KB
16
+ ESM ⚡️ Build success in 127ms
17
+ CJS dist/index.js 41.69 KB
18
+ CJS ⚡️ Build success in 127ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2276ms
21
- DTS dist/index.d.mts 25.78 KB
22
- DTS dist/index.d.ts 25.78 KB
20
+ DTS ⚡️ Build success in 2481ms
21
+ DTS dist/index.d.mts 25.71 KB
22
+ DTS dist/index.d.ts 25.71 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.25.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 60a0bf1: Update internal accessor.
8
+ - @pluv/crdt@0.25.2
9
+ - @pluv/types@0.25.2
10
+
11
+ ## 0.25.1
12
+
13
+ ### Patch Changes
14
+
15
+ - 3925f7c: Update internal accessor.
16
+ - @pluv/crdt@0.25.1
17
+ - @pluv/types@0.25.1
18
+
3
19
  ## 0.25.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -224,7 +224,6 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
224
224
  private _initialized;
225
225
  persistence: AbstractPersistence;
226
226
  pubSub: AbstractPubSub;
227
- readonly _meta: any;
228
227
  abstract readonly _registrationMode: WebSocketRegistrationMode;
229
228
  constructor(config?: AbstractPlatformConfig<TPlatformContext, TRoomContext>);
230
229
  abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
@@ -350,7 +349,6 @@ type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize e
350
349
  };
351
350
  type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>>, TContext extends JsonObject, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
352
351
  declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
353
- _listeners: PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>;
354
352
  readonly version: string;
355
353
  private readonly _authorize;
356
354
  private readonly _baseRouter;
@@ -375,6 +373,7 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
375
373
  constructor(options: PluvServerConfig<TPlatform, TAuthorize, TContext, TEvents>);
376
374
  createRoom(room: string, ...options: CreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>): IORoom<TPlatform, TAuthorize, TContext, TEvents>;
377
375
  createToken(params: JWTEncodeParams<InferIOAuthorizeUser<InferIOAuthorize<this>>, TPlatform>): Promise<string>;
376
+ private _getListeners;
378
377
  private _logDebug;
379
378
  }
380
379
 
package/dist/index.d.ts CHANGED
@@ -224,7 +224,6 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
224
224
  private _initialized;
225
225
  persistence: AbstractPersistence;
226
226
  pubSub: AbstractPubSub;
227
- readonly _meta: any;
228
227
  abstract readonly _registrationMode: WebSocketRegistrationMode;
229
228
  constructor(config?: AbstractPlatformConfig<TPlatformContext, TRoomContext>);
230
229
  abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
@@ -350,7 +349,6 @@ type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize e
350
349
  };
351
350
  type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>>, TContext extends JsonObject, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
352
351
  declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
353
- _listeners: PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>;
354
352
  readonly version: string;
355
353
  private readonly _authorize;
356
354
  private readonly _baseRouter;
@@ -375,6 +373,7 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
375
373
  constructor(options: PluvServerConfig<TPlatform, TAuthorize, TContext, TEvents>);
376
374
  createRoom(room: string, ...options: CreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>): IORoom<TPlatform, TAuthorize, TContext, TEvents>;
377
375
  createToken(params: JWTEncodeParams<InferIOAuthorizeUser<InferIOAuthorize<this>>, TPlatform>): Promise<string>;
376
+ private _getListeners;
378
377
  private _logDebug;
379
378
  }
380
379
 
package/dist/index.js CHANGED
@@ -217,8 +217,8 @@ var PubSub = class extends AbstractPubSub {
217
217
  var AbstractPlatform = class {
218
218
  constructor(config = {}) {
219
219
  this._initialized = false;
220
- this._meta = void 0;
221
220
  const { context, persistence, pubSub } = config;
221
+ this._meta = config._meta;
222
222
  context && (this._ioContext = context);
223
223
  context && (this._roomContext = context);
224
224
  this.persistence = persistence != null ? persistence : new Persistence();
@@ -690,7 +690,7 @@ var IORoom = class {
690
690
  const encodedState = doc2.getEncodedState();
691
691
  doc2.destroy();
692
692
  this._doc = Promise.resolve(this._docFactory.getEmpty());
693
- this._listeners.onDestroy(__spreadProps(__spreadValues({}, this._platform._meta ? { _meta: this._platform._meta } : {}), {
693
+ this._listeners.onDestroy(__spreadProps(__spreadValues({}, "_meta" in this._platform && !!this._platform._meta ? { _meta: this._platform._meta } : {}), {
694
694
  context: this._context,
695
695
  encodedState,
696
696
  room: this.id
@@ -756,7 +756,7 @@ var IORoom = class {
756
756
  const message = this._parseMessage(event);
757
757
  if (!message) return;
758
758
  const procedure = this._getProcedure(message);
759
- this._listeners.onMessage(__spreadProps(__spreadValues({}, this._platform._meta ? { _meta: this._platform._meta } : {}), {
759
+ this._listeners.onMessage(__spreadProps(__spreadValues({}, "_meta" in this._platform && !!this._platform._meta ? { _meta: this._platform._meta } : {}), {
760
760
  context: this._context,
761
761
  encodedState: doc.getEncodedState(),
762
762
  message,
@@ -914,7 +914,7 @@ var IORoom = class {
914
914
  };
915
915
 
916
916
  // src/version.generated.ts
917
- var version = "0.25.0";
917
+ var version = "0.25.2";
918
918
 
919
919
  // src/PluvServer.ts
920
920
  var PluvServer = class {
@@ -964,7 +964,7 @@ var PluvServer = class {
964
964
  if (updates.some((_update) => !!_update)) {
965
965
  const encodedState = doc.batchApplyEncodedState(updates).getEncodedState();
966
966
  yield this._platform.persistence.setStorageState(room, encodedState);
967
- this._listeners.onStorageUpdated({ context, encodedState, room });
967
+ this._getListeners().onStorageUpdated({ context, encodedState, room });
968
968
  }
969
969
  const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
970
970
  return { $STORAGE_RECEIVED: { state } };
@@ -995,7 +995,7 @@ var PluvServer = class {
995
995
  const updated = update === null ? doc : doc.applyEncodedState({ update });
996
996
  const encodedState = updated.getEncodedState();
997
997
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
998
- this._listeners.onStorageUpdated({
998
+ this._getListeners().onStorageUpdated({
999
999
  context,
1000
1000
  encodedState,
1001
1001
  room
@@ -1062,13 +1062,13 @@ var PluvServer = class {
1062
1062
  onDestroy: (event) => __async(this, null, function* () {
1063
1063
  this._logDebug(`${import_kleur2.default.blue("Deleting empty room:")} ${room}`);
1064
1064
  yield Promise.resolve(onDestroy == null ? void 0 : onDestroy(event));
1065
- yield Promise.resolve(this._listeners.onRoomDeleted(event));
1065
+ yield Promise.resolve(this._getListeners().onRoomDeleted(event));
1066
1066
  yield this._platform.persistence.deleteStorageState(room);
1067
1067
  this._logDebug(`${import_kleur2.default.blue("Deleted room:")} ${room}`);
1068
1068
  }),
1069
1069
  onMessage: (event) => __async(this, null, function* () {
1070
1070
  yield Promise.resolve(onMessage == null ? void 0 : onMessage(event));
1071
- yield Promise.resolve(this._listeners.onRoomMessage(event));
1071
+ yield Promise.resolve(this._getListeners().onRoomMessage(event));
1072
1072
  }),
1073
1073
  platform: this._platform,
1074
1074
  router: this._router
@@ -1089,6 +1089,9 @@ var PluvServer = class {
1089
1089
  }).encode(params);
1090
1090
  });
1091
1091
  }
1092
+ _getListeners() {
1093
+ return this._listeners;
1094
+ }
1092
1095
  _logDebug(...data) {
1093
1096
  this._debug && console.log(...data);
1094
1097
  }
package/dist/index.mjs CHANGED
@@ -176,8 +176,8 @@ var PubSub = class extends AbstractPubSub {
176
176
  var AbstractPlatform = class {
177
177
  constructor(config = {}) {
178
178
  this._initialized = false;
179
- this._meta = void 0;
180
179
  const { context, persistence, pubSub } = config;
180
+ this._meta = config._meta;
181
181
  context && (this._ioContext = context);
182
182
  context && (this._roomContext = context);
183
183
  this.persistence = persistence != null ? persistence : new Persistence();
@@ -649,7 +649,7 @@ var IORoom = class {
649
649
  const encodedState = doc2.getEncodedState();
650
650
  doc2.destroy();
651
651
  this._doc = Promise.resolve(this._docFactory.getEmpty());
652
- this._listeners.onDestroy(__spreadProps(__spreadValues({}, this._platform._meta ? { _meta: this._platform._meta } : {}), {
652
+ this._listeners.onDestroy(__spreadProps(__spreadValues({}, "_meta" in this._platform && !!this._platform._meta ? { _meta: this._platform._meta } : {}), {
653
653
  context: this._context,
654
654
  encodedState,
655
655
  room: this.id
@@ -715,7 +715,7 @@ var IORoom = class {
715
715
  const message = this._parseMessage(event);
716
716
  if (!message) return;
717
717
  const procedure = this._getProcedure(message);
718
- this._listeners.onMessage(__spreadProps(__spreadValues({}, this._platform._meta ? { _meta: this._platform._meta } : {}), {
718
+ this._listeners.onMessage(__spreadProps(__spreadValues({}, "_meta" in this._platform && !!this._platform._meta ? { _meta: this._platform._meta } : {}), {
719
719
  context: this._context,
720
720
  encodedState: doc.getEncodedState(),
721
721
  message,
@@ -873,7 +873,7 @@ var IORoom = class {
873
873
  };
874
874
 
875
875
  // src/version.generated.ts
876
- var version = "0.25.0";
876
+ var version = "0.25.2";
877
877
 
878
878
  // src/PluvServer.ts
879
879
  var PluvServer = class {
@@ -923,7 +923,7 @@ var PluvServer = class {
923
923
  if (updates.some((_update) => !!_update)) {
924
924
  const encodedState = doc.batchApplyEncodedState(updates).getEncodedState();
925
925
  yield this._platform.persistence.setStorageState(room, encodedState);
926
- this._listeners.onStorageUpdated({ context, encodedState, room });
926
+ this._getListeners().onStorageUpdated({ context, encodedState, room });
927
927
  }
928
928
  const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
929
929
  return { $STORAGE_RECEIVED: { state } };
@@ -954,7 +954,7 @@ var PluvServer = class {
954
954
  const updated = update === null ? doc : doc.applyEncodedState({ update });
955
955
  const encodedState = updated.getEncodedState();
956
956
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
957
- this._listeners.onStorageUpdated({
957
+ this._getListeners().onStorageUpdated({
958
958
  context,
959
959
  encodedState,
960
960
  room
@@ -1021,13 +1021,13 @@ var PluvServer = class {
1021
1021
  onDestroy: (event) => __async(this, null, function* () {
1022
1022
  this._logDebug(`${colors2.blue("Deleting empty room:")} ${room}`);
1023
1023
  yield Promise.resolve(onDestroy == null ? void 0 : onDestroy(event));
1024
- yield Promise.resolve(this._listeners.onRoomDeleted(event));
1024
+ yield Promise.resolve(this._getListeners().onRoomDeleted(event));
1025
1025
  yield this._platform.persistence.deleteStorageState(room);
1026
1026
  this._logDebug(`${colors2.blue("Deleted room:")} ${room}`);
1027
1027
  }),
1028
1028
  onMessage: (event) => __async(this, null, function* () {
1029
1029
  yield Promise.resolve(onMessage == null ? void 0 : onMessage(event));
1030
- yield Promise.resolve(this._listeners.onRoomMessage(event));
1030
+ yield Promise.resolve(this._getListeners().onRoomMessage(event));
1031
1031
  }),
1032
1032
  platform: this._platform,
1033
1033
  router: this._router
@@ -1048,6 +1048,9 @@ var PluvServer = class {
1048
1048
  }).encode(params);
1049
1049
  });
1050
1050
  }
1051
+ _getListeners() {
1052
+ return this._listeners;
1053
+ }
1051
1054
  _logDebug(...data) {
1052
1055
  this._debug && console.log(...data);
1053
1056
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
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.7.0",
22
22
  "kleur": "^4.1.5",
23
23
  "wonka": "^6.3.4",
24
- "@pluv/crdt": "^0.25.0",
25
- "@pluv/types": "^0.25.0"
24
+ "@pluv/crdt": "^0.25.2",
25
+ "@pluv/types": "^0.25.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^8.57.0",
29
29
  "genversion": "^3.2.0",
30
30
  "tsup": "^8.2.4",
31
31
  "typescript": "^5.5.4",
32
- "@pluv/tsconfig": "^0.25.0",
33
- "eslint-config-pluv": "^0.25.0"
32
+ "@pluv/tsconfig": "^0.25.2",
33
+ "eslint-config-pluv": "^0.25.2"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
@@ -47,13 +47,12 @@ export abstract class AbstractPlatform<
47
47
  public persistence: AbstractPersistence;
48
48
  public pubSub: AbstractPubSub;
49
49
 
50
- public readonly _meta: any = undefined;
51
-
52
50
  public abstract readonly _registrationMode: WebSocketRegistrationMode;
53
51
 
54
52
  constructor(config: AbstractPlatformConfig<TPlatformContext, TRoomContext> = {}) {
55
53
  const { context, persistence, pubSub } = config;
56
54
 
55
+ (this as any)._meta = (config as any)._meta;
57
56
  context && (this._ioContext = context);
58
57
  context && (this._roomContext = context);
59
58
 
package/src/IORoom.ts CHANGED
@@ -487,7 +487,7 @@ export class IORoom<
487
487
  this._doc = Promise.resolve(this._docFactory.getEmpty());
488
488
 
489
489
  this._listeners.onDestroy({
490
- ...(this._platform._meta ? { _meta: this._platform._meta } : {}),
490
+ ...("_meta" in this._platform && !!this._platform._meta ? { _meta: this._platform._meta } : {}),
491
491
  context: this._context,
492
492
  encodedState,
493
493
  room: this.id,
@@ -577,7 +577,7 @@ export class IORoom<
577
577
  const procedure = this._getProcedure(message);
578
578
 
579
579
  this._listeners.onMessage({
580
- ...(this._platform._meta ? { _meta: this._platform._meta } : {}),
580
+ ...("_meta" in this._platform && !!this._platform._meta ? { _meta: this._platform._meta } : {}),
581
581
  context: this._context,
582
582
  encodedState: doc.getEncodedState(),
583
583
  message: message as InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>,
package/src/PluvServer.ts CHANGED
@@ -73,8 +73,6 @@ export class PluvServer<
73
73
  TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {},
74
74
  > implements IORouterLike<TEvents>
75
75
  {
76
- public _listeners: PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>;
77
-
78
76
  public readonly version: string = __PLUV_VERSION as any;
79
77
 
80
78
  private readonly _authorize: TAuthorize | null = null;
@@ -141,7 +139,7 @@ export class PluvServer<
141
139
 
142
140
  await this._platform.persistence.setStorageState(room, encodedState);
143
141
 
144
- this._listeners.onStorageUpdated({ context, encodedState, room });
142
+ this._getListeners().onStorageUpdated({ context, encodedState, room });
145
143
  }
146
144
 
147
145
  const state = (await this._platform.persistence.getStorageState(room)) ?? doc.getEncodedState();
@@ -185,7 +183,7 @@ export class PluvServer<
185
183
  const encodedState = updated.getEncodedState();
186
184
 
187
185
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
188
- this._listeners.onStorageUpdated({
186
+ this._getListeners().onStorageUpdated({
189
187
  context,
190
188
  encodedState,
191
189
  room,
@@ -248,11 +246,11 @@ export class PluvServer<
248
246
  if (context) this._context = context;
249
247
  if (getInitialStorage) this._getInitialStorage = getInitialStorage;
250
248
 
251
- this._listeners = {
249
+ (this as any)._listeners = {
252
250
  onRoomDeleted: (event) => onRoomDeleted?.(event),
253
251
  onRoomMessage: (event) => onRoomMessage?.(event),
254
252
  onStorageUpdated: (event) => onStorageUpdated?.(event),
255
- };
253
+ } as PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>;
256
254
  }
257
255
 
258
256
  public createRoom(
@@ -279,14 +277,14 @@ export class PluvServer<
279
277
  this._logDebug(`${colors.blue("Deleting empty room:")} ${room}`);
280
278
 
281
279
  await Promise.resolve(onDestroy?.(event));
282
- await Promise.resolve(this._listeners.onRoomDeleted(event));
280
+ await Promise.resolve(this._getListeners().onRoomDeleted(event));
283
281
  await this._platform.persistence.deleteStorageState(room);
284
282
 
285
283
  this._logDebug(`${colors.blue("Deleted room:")} ${room}`);
286
284
  },
287
285
  onMessage: async (event) => {
288
286
  await Promise.resolve(onMessage?.(event));
289
- await Promise.resolve(this._listeners.onRoomMessage(event));
287
+ await Promise.resolve(this._getListeners().onRoomMessage(event));
290
288
  },
291
289
  platform: this._platform,
292
290
  router: this._router,
@@ -315,6 +313,10 @@ export class PluvServer<
315
313
  }).encode(params);
316
314
  }
317
315
 
316
+ private _getListeners(): PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents> {
317
+ return (this as any)._listeners;
318
+ }
319
+
318
320
  private _logDebug(...data: any[]): void {
319
321
  this._debug && console.log(...data);
320
322
  }
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.25.0'
2
+ export const version = '0.25.2'