@pluv/io 0.25.1 → 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.1 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.1 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
- ESM dist/index.mjs 39.43 KB
16
- ESM ⚡️ Build success in 121ms
17
- CJS dist/index.js 41.57 KB
18
- CJS ⚡️ Build success in 121ms
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 2430ms
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,13 @@
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
+
3
11
  ## 0.25.1
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -226,7 +226,6 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
226
226
  pubSub: AbstractPubSub;
227
227
  abstract readonly _registrationMode: WebSocketRegistrationMode;
228
228
  constructor(config?: AbstractPlatformConfig<TPlatformContext, TRoomContext>);
229
- get _meta(): any;
230
229
  abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
231
230
  abstract convertWebSocket(webSocket: InferWebSocketSource<TWebSocket>, config: ConvertWebSocketConfig): AbstractWebSocket;
232
231
  abstract getLastPing(webSocket: AbstractWebSocket): number | null;
@@ -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
@@ -226,7 +226,6 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = A
226
226
  pubSub: AbstractPubSub;
227
227
  abstract readonly _registrationMode: WebSocketRegistrationMode;
228
228
  constructor(config?: AbstractPlatformConfig<TPlatformContext, TRoomContext>);
229
- get _meta(): any;
230
229
  abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
231
230
  abstract convertWebSocket(webSocket: InferWebSocketSource<TWebSocket>, config: ConvertWebSocketConfig): AbstractWebSocket;
232
231
  abstract getLastPing(webSocket: AbstractWebSocket): number | null;
@@ -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
@@ -218,14 +218,12 @@ var AbstractPlatform = class {
218
218
  constructor(config = {}) {
219
219
  this._initialized = false;
220
220
  const { context, persistence, pubSub } = config;
221
+ this._meta = config._meta;
221
222
  context && (this._ioContext = context);
222
223
  context && (this._roomContext = context);
223
224
  this.persistence = persistence != null ? persistence : new Persistence();
224
225
  this.pubSub = pubSub != null ? pubSub : new PubSub();
225
226
  }
226
- get _meta() {
227
- return void 0;
228
- }
229
227
  _initialize() {
230
228
  if (this._initialized) throw new Error("Platform is already initialized");
231
229
  this._initialized = true;
@@ -692,7 +690,7 @@ var IORoom = class {
692
690
  const encodedState = doc2.getEncodedState();
693
691
  doc2.destroy();
694
692
  this._doc = Promise.resolve(this._docFactory.getEmpty());
695
- 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 } : {}), {
696
694
  context: this._context,
697
695
  encodedState,
698
696
  room: this.id
@@ -758,7 +756,7 @@ var IORoom = class {
758
756
  const message = this._parseMessage(event);
759
757
  if (!message) return;
760
758
  const procedure = this._getProcedure(message);
761
- 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 } : {}), {
762
760
  context: this._context,
763
761
  encodedState: doc.getEncodedState(),
764
762
  message,
@@ -916,7 +914,7 @@ var IORoom = class {
916
914
  };
917
915
 
918
916
  // src/version.generated.ts
919
- var version = "0.25.1";
917
+ var version = "0.25.2";
920
918
 
921
919
  // src/PluvServer.ts
922
920
  var PluvServer = class {
@@ -966,7 +964,7 @@ var PluvServer = class {
966
964
  if (updates.some((_update) => !!_update)) {
967
965
  const encodedState = doc.batchApplyEncodedState(updates).getEncodedState();
968
966
  yield this._platform.persistence.setStorageState(room, encodedState);
969
- this._listeners.onStorageUpdated({ context, encodedState, room });
967
+ this._getListeners().onStorageUpdated({ context, encodedState, room });
970
968
  }
971
969
  const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
972
970
  return { $STORAGE_RECEIVED: { state } };
@@ -997,7 +995,7 @@ var PluvServer = class {
997
995
  const updated = update === null ? doc : doc.applyEncodedState({ update });
998
996
  const encodedState = updated.getEncodedState();
999
997
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
1000
- this._listeners.onStorageUpdated({
998
+ this._getListeners().onStorageUpdated({
1001
999
  context,
1002
1000
  encodedState,
1003
1001
  room
@@ -1064,13 +1062,13 @@ var PluvServer = class {
1064
1062
  onDestroy: (event) => __async(this, null, function* () {
1065
1063
  this._logDebug(`${import_kleur2.default.blue("Deleting empty room:")} ${room}`);
1066
1064
  yield Promise.resolve(onDestroy == null ? void 0 : onDestroy(event));
1067
- yield Promise.resolve(this._listeners.onRoomDeleted(event));
1065
+ yield Promise.resolve(this._getListeners().onRoomDeleted(event));
1068
1066
  yield this._platform.persistence.deleteStorageState(room);
1069
1067
  this._logDebug(`${import_kleur2.default.blue("Deleted room:")} ${room}`);
1070
1068
  }),
1071
1069
  onMessage: (event) => __async(this, null, function* () {
1072
1070
  yield Promise.resolve(onMessage == null ? void 0 : onMessage(event));
1073
- yield Promise.resolve(this._listeners.onRoomMessage(event));
1071
+ yield Promise.resolve(this._getListeners().onRoomMessage(event));
1074
1072
  }),
1075
1073
  platform: this._platform,
1076
1074
  router: this._router
@@ -1091,6 +1089,9 @@ var PluvServer = class {
1091
1089
  }).encode(params);
1092
1090
  });
1093
1091
  }
1092
+ _getListeners() {
1093
+ return this._listeners;
1094
+ }
1094
1095
  _logDebug(...data) {
1095
1096
  this._debug && console.log(...data);
1096
1097
  }
package/dist/index.mjs CHANGED
@@ -177,14 +177,12 @@ var AbstractPlatform = class {
177
177
  constructor(config = {}) {
178
178
  this._initialized = false;
179
179
  const { context, persistence, pubSub } = config;
180
+ this._meta = config._meta;
180
181
  context && (this._ioContext = context);
181
182
  context && (this._roomContext = context);
182
183
  this.persistence = persistence != null ? persistence : new Persistence();
183
184
  this.pubSub = pubSub != null ? pubSub : new PubSub();
184
185
  }
185
- get _meta() {
186
- return void 0;
187
- }
188
186
  _initialize() {
189
187
  if (this._initialized) throw new Error("Platform is already initialized");
190
188
  this._initialized = true;
@@ -651,7 +649,7 @@ var IORoom = class {
651
649
  const encodedState = doc2.getEncodedState();
652
650
  doc2.destroy();
653
651
  this._doc = Promise.resolve(this._docFactory.getEmpty());
654
- 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 } : {}), {
655
653
  context: this._context,
656
654
  encodedState,
657
655
  room: this.id
@@ -717,7 +715,7 @@ var IORoom = class {
717
715
  const message = this._parseMessage(event);
718
716
  if (!message) return;
719
717
  const procedure = this._getProcedure(message);
720
- 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 } : {}), {
721
719
  context: this._context,
722
720
  encodedState: doc.getEncodedState(),
723
721
  message,
@@ -875,7 +873,7 @@ var IORoom = class {
875
873
  };
876
874
 
877
875
  // src/version.generated.ts
878
- var version = "0.25.1";
876
+ var version = "0.25.2";
879
877
 
880
878
  // src/PluvServer.ts
881
879
  var PluvServer = class {
@@ -925,7 +923,7 @@ var PluvServer = class {
925
923
  if (updates.some((_update) => !!_update)) {
926
924
  const encodedState = doc.batchApplyEncodedState(updates).getEncodedState();
927
925
  yield this._platform.persistence.setStorageState(room, encodedState);
928
- this._listeners.onStorageUpdated({ context, encodedState, room });
926
+ this._getListeners().onStorageUpdated({ context, encodedState, room });
929
927
  }
930
928
  const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
931
929
  return { $STORAGE_RECEIVED: { state } };
@@ -956,7 +954,7 @@ var PluvServer = class {
956
954
  const updated = update === null ? doc : doc.applyEncodedState({ update });
957
955
  const encodedState = updated.getEncodedState();
958
956
  this._platform.persistence.setStorageState(room, encodedState).then(() => {
959
- this._listeners.onStorageUpdated({
957
+ this._getListeners().onStorageUpdated({
960
958
  context,
961
959
  encodedState,
962
960
  room
@@ -1023,13 +1021,13 @@ var PluvServer = class {
1023
1021
  onDestroy: (event) => __async(this, null, function* () {
1024
1022
  this._logDebug(`${colors2.blue("Deleting empty room:")} ${room}`);
1025
1023
  yield Promise.resolve(onDestroy == null ? void 0 : onDestroy(event));
1026
- yield Promise.resolve(this._listeners.onRoomDeleted(event));
1024
+ yield Promise.resolve(this._getListeners().onRoomDeleted(event));
1027
1025
  yield this._platform.persistence.deleteStorageState(room);
1028
1026
  this._logDebug(`${colors2.blue("Deleted room:")} ${room}`);
1029
1027
  }),
1030
1028
  onMessage: (event) => __async(this, null, function* () {
1031
1029
  yield Promise.resolve(onMessage == null ? void 0 : onMessage(event));
1032
- yield Promise.resolve(this._listeners.onRoomMessage(event));
1030
+ yield Promise.resolve(this._getListeners().onRoomMessage(event));
1033
1031
  }),
1034
1032
  platform: this._platform,
1035
1033
  router: this._router
@@ -1050,6 +1048,9 @@ var PluvServer = class {
1050
1048
  }).encode(params);
1051
1049
  });
1052
1050
  }
1051
+ _getListeners() {
1052
+ return this._listeners;
1053
+ }
1053
1054
  _logDebug(...data) {
1054
1055
  this._debug && console.log(...data);
1055
1056
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.25.1",
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.1",
25
- "@pluv/types": "^0.25.1"
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.1",
33
- "eslint-config-pluv": "^0.25.1"
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",
@@ -52,6 +52,7 @@ export abstract class AbstractPlatform<
52
52
  constructor(config: AbstractPlatformConfig<TPlatformContext, TRoomContext> = {}) {
53
53
  const { context, persistence, pubSub } = config;
54
54
 
55
+ (this as any)._meta = (config as any)._meta;
55
56
  context && (this._ioContext = context);
56
57
  context && (this._roomContext = context);
57
58
 
@@ -59,10 +60,6 @@ export abstract class AbstractPlatform<
59
60
  this.pubSub = pubSub ?? new PubSub();
60
61
  }
61
62
 
62
- public get _meta(): any {
63
- return undefined;
64
- }
65
-
66
63
  public abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
67
64
 
68
65
  public abstract convertWebSocket(
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.1'
2
+ export const version = '0.25.2'