@pluv/io 0.36.0 → 0.37.1

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.36.0 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.37.1 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.36.0 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@0.37.1 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
@@ -13,10 +13,10 @@
13
13
  ESM Build start
14
14
  CJS Build start
15
15
  ESM dist/index.mjs 43.58 KB
16
- ESM ⚡️ Build success in 124ms
17
- CJS dist/index.js 45.75 KB
18
- CJS ⚡️ Build success in 124ms
16
+ ESM ⚡️ Build success in 173ms
17
+ CJS dist/index.js 45.76 KB
18
+ CJS ⚡️ Build success in 169ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 2384ms
21
- DTS dist/index.d.mts 29.65 KB
22
- DTS dist/index.d.ts 29.65 KB
20
+ DTS ⚡️ Build success in 2471ms
21
+ DTS dist/index.d.mts 30.77 KB
22
+ DTS dist/index.d.ts 30.77 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.37.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/crdt@0.37.1
8
+ - @pluv/types@0.37.1
9
+
10
+ ## 0.37.0
11
+
12
+ ### Patch Changes
13
+
14
+ - 9b74abb: Improved type inference when calling `PluvIO.server` to not include options that are always undefined (i.e. are not allowed by the specified platform).
15
+ - @pluv/crdt@0.37.0
16
+ - @pluv/types@0.37.0
17
+
3
18
  ## 0.36.0
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -185,6 +185,7 @@ interface PlatformConfig {
185
185
  onUserConnected?: boolean;
186
186
  onUserDisconnected?: boolean;
187
187
  };
188
+ router?: boolean;
188
189
  }
189
190
  type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any> = {
190
191
  user: InputZodLike<TUser>;
@@ -200,6 +201,11 @@ type BasePluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>,
200
201
  onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
201
202
  };
202
203
  type PluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = UndefinedProps<BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, Exclude<keyof BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, InferPlatformListeners<TPlatform>>>;
204
+ type PluvIORouter<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = InferPlatformRouter<TPlatform> extends true ? {
205
+ router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
206
+ } : {
207
+ router?: undefined;
208
+ };
203
209
  type InferPlatformConfig<TPlatform extends AbstractPlatform<any, any, any, any>> = TPlatform extends AbstractPlatform<any, any, any, infer IConfig> ? IConfig : never;
204
210
  type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
205
211
  [P in keyof PlatformConfig["authorize"] as InferPlatformConfig<TPlatform>["authorize"][P] extends true | undefined ? P : never]: true;
@@ -207,6 +213,7 @@ type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, an
207
213
  type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
208
214
  [P in keyof PlatformConfig["listeners"] as InferPlatformConfig<TPlatform>["listeners"][P] extends true | undefined ? P : never]: true;
209
215
  };
216
+ type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> = InferPlatformConfig<TPlatform>["router"];
210
217
  type IORoomListenerEvent<TContext extends Record<string, any>> = {
211
218
  context: TContext;
212
219
  encodedState: string | null;
@@ -267,9 +274,9 @@ type InferPlatformWebSocketSource<TPlatform> = TPlatform extends AbstractPlatfor
267
274
  type InferInitContextType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<any, infer IInitContext> ? IInitContext : never;
268
275
  type InferRoomContextType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<any, any, infer IRoomContext> ? IRoomContext : never;
269
276
  type AbstractPlatformConfig<TRoomContext extends Record<string, any> = {}> = {
270
- context?: TRoomContext;
271
277
  persistence?: AbstractPersistence;
272
278
  pubSub?: AbstractPubSub;
279
+ roomContext?: TRoomContext;
273
280
  };
274
281
  interface ConvertWebSocketConfig {
275
282
  room: string;
@@ -443,9 +450,11 @@ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IO
443
450
  debug?: boolean;
444
451
  platform: TPlatform;
445
452
  };
446
- type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
453
+ type ResolvedServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & PluvIORouter<TPlatform, TAuthorize, TContext, TEvents> & {
447
454
  getInitialStorage?: GetInitialStorageFn<TContext>;
448
- router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
455
+ };
456
+ type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
457
+ [P in keyof ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents> as ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents>[P] extends undefined ? never : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents>[P];
449
458
  };
450
459
  declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> {
451
460
  readonly version: string;
@@ -470,6 +479,6 @@ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<a
470
479
  debug?: boolean;
471
480
  platform: TPlatform;
472
481
  };
473
- declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}, PlatformConfig>, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null>(params: CreateIOParams<TPlatform, TContext, TUser>) => PluvIO<TPlatform, PluvIOAuthorize<TPlatform, TUser, InferInitContextType<TPlatform>>, TContext>;
482
+ declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null>(params: CreateIOParams<TPlatform, TContext, TUser>) => PluvIO<TPlatform, PluvIOAuthorize<TPlatform, TUser, InferInitContextType<TPlatform>>, TContext>;
474
483
 
475
- export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type HandleMode, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type IOUserConnectedEvent, type IOUserDisconnectedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, type PlatformConfig, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
484
+ export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type HandleMode, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type IOUserConnectedEvent, type IOUserDisconnectedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, type PlatformConfig, type PluvContext, PluvIO, type PluvIOAuthorize, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
package/dist/index.d.ts CHANGED
@@ -185,6 +185,7 @@ interface PlatformConfig {
185
185
  onUserConnected?: boolean;
186
186
  onUserDisconnected?: boolean;
187
187
  };
188
+ router?: boolean;
188
189
  }
189
190
  type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any> = {
190
191
  user: InputZodLike<TUser>;
@@ -200,6 +201,11 @@ type BasePluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>,
200
201
  onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
201
202
  };
202
203
  type PluvIOListeners<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = UndefinedProps<BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, Exclude<keyof BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, InferPlatformListeners<TPlatform>>>;
204
+ type PluvIORouter<TPlatform extends AbstractPlatform<any, any, any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = InferPlatformRouter<TPlatform> extends true ? {
205
+ router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
206
+ } : {
207
+ router?: undefined;
208
+ };
203
209
  type InferPlatformConfig<TPlatform extends AbstractPlatform<any, any, any, any>> = TPlatform extends AbstractPlatform<any, any, any, infer IConfig> ? IConfig : never;
204
210
  type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
205
211
  [P in keyof PlatformConfig["authorize"] as InferPlatformConfig<TPlatform>["authorize"][P] extends true | undefined ? P : never]: true;
@@ -207,6 +213,7 @@ type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, an
207
213
  type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
208
214
  [P in keyof PlatformConfig["listeners"] as InferPlatformConfig<TPlatform>["listeners"][P] extends true | undefined ? P : never]: true;
209
215
  };
216
+ type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> = InferPlatformConfig<TPlatform>["router"];
210
217
  type IORoomListenerEvent<TContext extends Record<string, any>> = {
211
218
  context: TContext;
212
219
  encodedState: string | null;
@@ -267,9 +274,9 @@ type InferPlatformWebSocketSource<TPlatform> = TPlatform extends AbstractPlatfor
267
274
  type InferInitContextType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<any, infer IInitContext> ? IInitContext : never;
268
275
  type InferRoomContextType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<any, any, infer IRoomContext> ? IRoomContext : never;
269
276
  type AbstractPlatformConfig<TRoomContext extends Record<string, any> = {}> = {
270
- context?: TRoomContext;
271
277
  persistence?: AbstractPersistence;
272
278
  pubSub?: AbstractPubSub;
279
+ roomContext?: TRoomContext;
273
280
  };
274
281
  interface ConvertWebSocketConfig {
275
282
  room: string;
@@ -443,9 +450,11 @@ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IO
443
450
  debug?: boolean;
444
451
  platform: TPlatform;
445
452
  };
446
- type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
453
+ type ResolvedServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & PluvIORouter<TPlatform, TAuthorize, TContext, TEvents> & {
447
454
  getInitialStorage?: GetInitialStorageFn<TContext>;
448
- router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
455
+ };
456
+ type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
457
+ [P in keyof ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents> as ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents>[P] extends undefined ? never : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents>[P];
449
458
  };
450
459
  declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> {
451
460
  readonly version: string;
@@ -470,6 +479,6 @@ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<a
470
479
  debug?: boolean;
471
480
  platform: TPlatform;
472
481
  };
473
- declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}, PlatformConfig>, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null>(params: CreateIOParams<TPlatform, TContext, TUser>) => PluvIO<TPlatform, PluvIOAuthorize<TPlatform, TUser, InferInitContextType<TPlatform>>, TContext>;
482
+ declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null>(params: CreateIOParams<TPlatform, TContext, TUser>) => PluvIO<TPlatform, PluvIOAuthorize<TPlatform, TUser, InferInitContextType<TPlatform>>, TContext>;
474
483
 
475
- export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type HandleMode, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type IOUserConnectedEvent, type IOUserDisconnectedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, type PlatformConfig, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
484
+ export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type HandleMode, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type IOUserConnectedEvent, type IOUserDisconnectedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, type PlatformConfig, type PluvContext, PluvIO, type PluvIOAuthorize, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
package/dist/index.js CHANGED
@@ -218,9 +218,9 @@ var PubSub = class extends AbstractPubSub {
218
218
  var AbstractPlatform = class {
219
219
  constructor(config = {}) {
220
220
  this._initialized = false;
221
- const { context, persistence, pubSub } = config;
221
+ const { roomContext, persistence, pubSub } = config;
222
222
  this._meta = config._meta;
223
- context && (this._roomContext = context);
223
+ roomContext && (this._roomContext = roomContext);
224
224
  this.persistence = persistence != null ? persistence : new Persistence();
225
225
  this.pubSub = pubSub != null ? pubSub : new PubSub();
226
226
  }
@@ -420,7 +420,7 @@ var IORoom = class {
420
420
  this._debug = debug;
421
421
  this._docFactory = crdt.doc(() => ({}));
422
422
  this._router = router;
423
- this._platform = platform.initialize(__spreadProps(__spreadValues({}, !!_meta ? { _meta } : {}), { context: roomContext }));
423
+ this._platform = platform.initialize(__spreadProps(__spreadValues({}, !!_meta ? { _meta } : {}), { roomContext }));
424
424
  this._listeners = {
425
425
  onDestroy: (event) => onDestroy == null ? void 0 : onDestroy(event),
426
426
  onMessage: (event) => onMessage == null ? void 0 : onMessage(event),
@@ -998,7 +998,7 @@ var IORoom = class {
998
998
  };
999
999
 
1000
1000
  // src/version.generated.ts
1001
- var version = "0.36.0";
1001
+ var version = "0.37.1";
1002
1002
 
1003
1003
  // src/PluvServer.ts
1004
1004
  var PluvServer = class {
package/dist/index.mjs CHANGED
@@ -176,9 +176,9 @@ var PubSub = class extends AbstractPubSub {
176
176
  var AbstractPlatform = class {
177
177
  constructor(config = {}) {
178
178
  this._initialized = false;
179
- const { context, persistence, pubSub } = config;
179
+ const { roomContext, persistence, pubSub } = config;
180
180
  this._meta = config._meta;
181
- context && (this._roomContext = context);
181
+ roomContext && (this._roomContext = roomContext);
182
182
  this.persistence = persistence != null ? persistence : new Persistence();
183
183
  this.pubSub = pubSub != null ? pubSub : new PubSub();
184
184
  }
@@ -378,7 +378,7 @@ var IORoom = class {
378
378
  this._debug = debug;
379
379
  this._docFactory = crdt.doc(() => ({}));
380
380
  this._router = router;
381
- this._platform = platform.initialize(__spreadProps(__spreadValues({}, !!_meta ? { _meta } : {}), { context: roomContext }));
381
+ this._platform = platform.initialize(__spreadProps(__spreadValues({}, !!_meta ? { _meta } : {}), { roomContext }));
382
382
  this._listeners = {
383
383
  onDestroy: (event) => onDestroy == null ? void 0 : onDestroy(event),
384
384
  onMessage: (event) => onMessage == null ? void 0 : onMessage(event),
@@ -956,7 +956,7 @@ var IORoom = class {
956
956
  };
957
957
 
958
958
  // src/version.generated.ts
959
- var version = "0.36.0";
959
+ var version = "0.37.1";
960
960
 
961
961
  // src/PluvServer.ts
962
962
  var PluvServer = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
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.4",
24
- "@pluv/crdt": "^0.36.0",
25
- "@pluv/types": "^0.36.0"
24
+ "@pluv/crdt": "^0.37.1",
25
+ "@pluv/types": "^0.37.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^8.57.1",
29
29
  "genversion": "^3.2.0",
30
30
  "tsup": "^8.4.0",
31
- "typescript": "^5.7.3",
32
- "@pluv/tsconfig": "^0.36.0",
33
- "eslint-config-pluv": "^0.36.0"
31
+ "typescript": "^5.8.2",
32
+ "@pluv/tsconfig": "^0.37.1",
33
+ "eslint-config-pluv": "^0.37.1"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
@@ -19,9 +19,9 @@ export type InferRoomContextType<TPlatform extends AbstractPlatform> =
19
19
  TPlatform extends AbstractPlatform<any, any, infer IRoomContext> ? IRoomContext : never;
20
20
 
21
21
  export type AbstractPlatformConfig<TRoomContext extends Record<string, any> = {}> = {
22
- context?: TRoomContext;
23
22
  persistence?: AbstractPersistence;
24
23
  pubSub?: AbstractPubSub;
24
+ roomContext?: TRoomContext;
25
25
  };
26
26
 
27
27
  export interface ConvertWebSocketConfig {
@@ -48,10 +48,10 @@ export abstract class AbstractPlatform<
48
48
  public abstract readonly _name: string;
49
49
 
50
50
  constructor(config: AbstractPlatformConfig<TRoomContext> = {}) {
51
- const { context, persistence, pubSub } = config;
51
+ const { roomContext, persistence, pubSub } = config;
52
52
 
53
53
  (this as any)._meta = (config as any)._meta;
54
- context && (this._roomContext = context);
54
+ roomContext && (this._roomContext = roomContext);
55
55
 
56
56
  this.persistence = persistence ?? new Persistence();
57
57
  this.pubSub = pubSub ?? new PubSub();
package/src/IORoom.ts CHANGED
@@ -174,7 +174,7 @@ export class IORoom<
174
174
  this._debug = debug;
175
175
  this._docFactory = crdt.doc(() => ({}));
176
176
  this._router = router;
177
- this._platform = platform.initialize({ ...(!!_meta ? { _meta } : {}), context: roomContext });
177
+ this._platform = platform.initialize({ ...(!!_meta ? { _meta } : {}), roomContext });
178
178
 
179
179
  this._listeners = {
180
180
  onDestroy: (event) => onDestroy?.(event),
package/src/PluvIO.ts CHANGED
@@ -6,7 +6,7 @@ import { WebsocketRegisterConfig } from "./IORoom";
6
6
  import { PluvProcedure } from "./PluvProcedure";
7
7
  import type { MergedRouter, PluvRouterEventConfig } from "./PluvRouter";
8
8
  import { PluvRouter } from "./PluvRouter";
9
- import { PluvServer } from "./PluvServer";
9
+ import { PluvServer, PluvServerConfig } from "./PluvServer";
10
10
  import type { JWTEncodeParams } from "./authorize";
11
11
  import { authorize } from "./authorize";
12
12
  import type {
@@ -15,6 +15,7 @@ import type {
15
15
  PluvContext,
16
16
  PluvIOAuthorize,
17
17
  PluvIOListeners,
18
+ PluvIORouter,
18
19
  ResolvedPluvIOAuthorize,
19
20
  } from "./types";
20
21
  import { __PLUV_VERSION } from "./version";
@@ -31,14 +32,30 @@ export type PluvIOConfig<
31
32
  platform: TPlatform;
32
33
  };
33
34
 
35
+ type ResolvedServerConfig<
36
+ TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>,
37
+ TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any,
38
+ TContext extends Record<string, any> = {},
39
+ TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {},
40
+ > = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> &
41
+ PluvIORouter<TPlatform, TAuthorize, TContext, TEvents> & {
42
+ getInitialStorage?: GetInitialStorageFn<TContext>;
43
+ };
44
+
34
45
  export type ServerConfig<
35
46
  TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>,
36
47
  TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any,
37
48
  TContext extends Record<string, any> = {},
38
49
  TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {},
39
- > = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
40
- getInitialStorage?: GetInitialStorageFn<TContext>;
41
- router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
50
+ > = {
51
+ [P in keyof ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents> as ResolvedServerConfig<
52
+ TPlatform,
53
+ TAuthorize,
54
+ TContext,
55
+ TEvents
56
+ >[P] extends undefined
57
+ ? never
58
+ : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TEvents>[P];
42
59
  };
43
60
 
44
61
  export class PluvIO<
@@ -93,7 +110,12 @@ export class PluvIO<
93
110
  }
94
111
 
95
112
  public server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>>(
96
- config: ServerConfig<TPlatform, TAuthorize, TContext, TEvents> = {},
113
+ config: ServerConfig<TPlatform, TAuthorize, TContext, TEvents> = {} as ServerConfig<
114
+ TPlatform,
115
+ TAuthorize,
116
+ TContext,
117
+ TEvents
118
+ >,
97
119
  ): PluvServer<TPlatform, TAuthorize, TContext, TEvents> {
98
120
  return new PluvServer<TPlatform, TAuthorize, TContext, TEvents>({
99
121
  ...config,
@@ -102,7 +124,7 @@ export class PluvIO<
102
124
  crdt: this._crdt,
103
125
  debug: this._debug,
104
126
  platform: this._platform,
105
- });
127
+ } as PluvServerConfig<TPlatform, TAuthorize, TContext, TEvents>);
106
128
  }
107
129
 
108
130
  private _getIOAuthorize(options: WebsocketRegisterConfig<TPlatform>): ResolvedPluvIOAuthorize<any, any> | null {
package/src/index.ts CHANGED
@@ -44,6 +44,8 @@ export type {
44
44
  IOUserConnectedEvent,
45
45
  IOUserDisconnectedEvent,
46
46
  PlatformConfig,
47
+ PluvContext,
48
+ PluvIOAuthorize,
47
49
  PluvIOListeners,
48
50
  WebSocketRegistrationMode,
49
51
  WebSocketSerializedState,
package/src/types.ts CHANGED
@@ -21,7 +21,7 @@ import type {
21
21
  InferRoomContextType,
22
22
  } from "./AbstractPlatform";
23
23
  import type { AbstractWebSocket } from "./AbstractWebSocket";
24
- import type { PluvRouterEventConfig } from "./PluvRouter";
24
+ import type { PluvRouter, PluvRouterEventConfig } from "./PluvRouter";
25
25
 
26
26
  declare global {
27
27
  var console: {
@@ -128,6 +128,7 @@ export interface PlatformConfig {
128
128
  onUserConnected?: boolean;
129
129
  onUserDisconnected?: boolean;
130
130
  };
131
+ router?: boolean;
131
132
  }
132
133
 
133
134
  export type ResolvedPluvIOAuthorize<
@@ -169,6 +170,16 @@ export type PluvIOListeners<
169
170
  Exclude<keyof BasePluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>, InferPlatformListeners<TPlatform>>
170
171
  >;
171
172
 
173
+ export type PluvIORouter<
174
+ TPlatform extends AbstractPlatform<any, any, any, any>,
175
+ TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null,
176
+ TContext extends Record<string, any>,
177
+ TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>,
178
+ > =
179
+ InferPlatformRouter<TPlatform> extends true
180
+ ? { router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents> }
181
+ : { router?: undefined };
182
+
172
183
  export type InferPlatformConfig<TPlatform extends AbstractPlatform<any, any, any, any>> =
173
184
  TPlatform extends AbstractPlatform<any, any, any, infer IConfig> ? IConfig : never;
174
185
 
@@ -184,6 +195,9 @@ export type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any,
184
195
  : never]: true;
185
196
  };
186
197
 
198
+ export type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> =
199
+ InferPlatformConfig<TPlatform>["router"];
200
+
187
201
  export type IORoomListenerEvent<TContext extends Record<string, any>> = {
188
202
  context: TContext;
189
203
  encodedState: string | null;
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.36.0'
2
+ export const version = '0.37.1'