@pluv/io 2.1.0 → 2.2.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.
package/src/types.ts CHANGED
@@ -29,7 +29,7 @@ export type PluvContext<TPlatform extends AbstractPlatform, TContext extends Rec
29
29
  | ((params: InferRoomContextType<TPlatform>) => TContext);
30
30
 
31
31
  export interface CrdtLibraryType {
32
- doc: (value: any) => AbstractCrdtDocFactory<any>;
32
+ doc: (value: any) => AbstractCrdtDocFactory<any, any>;
33
33
  kind: "loro" | "yjs";
34
34
  }
35
35
 
@@ -54,8 +54,9 @@ export interface EventResolverContext<
54
54
  TContext extends Record<string, any> = {},
55
55
  > {
56
56
  context: TContext;
57
- doc: CrdtDocLike<any>;
57
+ doc: CrdtDocLike<any, any>;
58
58
  garbageCollect: () => Promise<void>;
59
+ platform: TPlatform;
59
60
  presence: JsonObject | null;
60
61
  room: string;
61
62
  session: TKind extends "sync"
@@ -176,7 +177,7 @@ export type BasePluvIOListeners<
176
177
  TContext extends Record<string, any>,
177
178
  TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>,
178
179
  > = {
179
- onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
180
+ onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
180
181
  onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
181
182
  onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext>) => void;
182
183
  onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
@@ -230,9 +231,13 @@ export type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any,
230
231
  export type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> =
231
232
  InferPlatformConfig<TPlatform>["router"];
232
233
 
233
- export type IORoomListenerEvent<TContext extends Record<string, any>> = {
234
+ export type IORoomListenerEvent<
235
+ TPlatform extends AbstractPlatform<any, any, any, any>,
236
+ TContext extends Record<string, any>,
237
+ > = {
234
238
  context: TContext;
235
239
  encodedState: string | null;
240
+ platform: TPlatform;
236
241
  room: string;
237
242
  };
238
243
 
@@ -241,7 +246,7 @@ export type IORoomMessageEvent<
241
246
  TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null,
242
247
  TContext extends Record<string, any>,
243
248
  TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>,
244
- > = IORoomListenerEvent<TContext> & {
249
+ > = IORoomListenerEvent<TPlatform, TContext> & {
245
250
  message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
246
251
  user?: InferIOAuthorizeUser<TAuthorize>;
247
252
  webSocket?: InferPlatformWebSocketSource<TPlatform>;
@@ -251,7 +256,7 @@ export type IOStorageUpdatedEvent<
251
256
  TPlatform extends AbstractPlatform<any>,
252
257
  TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null,
253
258
  TContext extends Record<string, any>,
254
- > = IORoomListenerEvent<TContext> & {
259
+ > = IORoomListenerEvent<TPlatform, TContext> & {
255
260
  user?: InferIOAuthorizeUser<TAuthorize>;
256
261
  webSocket?: InferPlatformWebSocketSource<TPlatform>;
257
262
  };
@@ -260,7 +265,7 @@ export type IOUserConnectedEvent<
260
265
  TPlatform extends AbstractPlatform<any>,
261
266
  TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null,
262
267
  TContext extends Record<string, any>,
263
- > = IORoomListenerEvent<TContext> & {
268
+ > = IORoomListenerEvent<TPlatform, TContext> & {
264
269
  user?: InferIOAuthorizeUser<TAuthorize>;
265
270
  webSocket?: InferPlatformWebSocketSource<TPlatform>;
266
271
  };
@@ -269,7 +274,7 @@ export type IOUserDisconnectedEvent<
269
274
  TPlatform extends AbstractPlatform<any>,
270
275
  TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null,
271
276
  TContext extends Record<string, any>,
272
- > = IORoomListenerEvent<TContext> & {
277
+ > = IORoomListenerEvent<TPlatform, TContext> & {
273
278
  user?: InferIOAuthorizeUser<TAuthorize>;
274
279
  };
275
280
 
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '2.1.0'
2
+ export const version = '2.2.1'