@pluv/io 2.1.0 → 2.2.0
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +19 -16
- package/dist/index.d.ts +19 -16
- package/dist/index.js +124 -91
- package/dist/index.mjs +124 -91
- package/package.json +5 -5
- package/src/IORoom.ts +11 -5
- package/src/PluvIO.ts +7 -5
- package/src/PluvServer.ts +238 -214
- package/src/createIO.ts +1 -1
- package/src/types.ts +13 -8
- package/src/version.generated.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/io@2.
|
|
2
|
+
> @pluv/io@2.2.0 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@2.
|
|
6
|
+
> @pluv/io@2.2.0 version /home/runner/work/pluv/pluv/packages/io
|
|
7
7
|
> genversion ./src/version.generated.ts --esm
|
|
8
8
|
|
|
9
9
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
[34mCLI[39m Target: es6
|
|
13
13
|
[34mESM[39m Build start
|
|
14
14
|
[34mCJS[39m Build start
|
|
15
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m51.
|
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m54.10 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 130ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m51.92 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 130ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m32.
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 4044ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m32.42 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.42 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -122,15 +122,16 @@ declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatf
|
|
|
122
122
|
|
|
123
123
|
type PluvContext<TPlatform extends AbstractPlatform, TContext extends Record<string, any>> = TContext | ((params: InferRoomContextType<TPlatform>) => TContext);
|
|
124
124
|
interface CrdtLibraryType {
|
|
125
|
-
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
125
|
+
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
126
126
|
kind: "loro" | "yjs";
|
|
127
127
|
}
|
|
128
128
|
type EventResolverKind = "broadcast" | "self" | "sync";
|
|
129
129
|
type EventResolver<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = (data: TInput, context: EventResolverContext<TKind, TPlatform, TAuthorize, TContext>) => MaybePromise<TOutput | void>;
|
|
130
130
|
interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}> {
|
|
131
131
|
context: TContext;
|
|
132
|
-
doc: CrdtDocLike<any>;
|
|
132
|
+
doc: CrdtDocLike<any, any>;
|
|
133
133
|
garbageCollect: () => Promise<void>;
|
|
134
|
+
platform: TPlatform;
|
|
134
135
|
presence: JsonObject | null;
|
|
135
136
|
room: string;
|
|
136
137
|
session: TKind extends "sync" ? WebSocketSession<TAuthorize> | null : WebSocketSession<TAuthorize>;
|
|
@@ -214,7 +215,7 @@ interface PluvIOLimits {
|
|
|
214
215
|
userMaxSize?: number | null;
|
|
215
216
|
}
|
|
216
217
|
type BasePluvIOListeners<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>> = {
|
|
217
|
-
onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
|
|
218
|
+
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
|
|
218
219
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
219
220
|
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
220
221
|
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
@@ -234,25 +235,26 @@ type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any, any, an
|
|
|
234
235
|
[P in keyof PlatformConfig["listeners"] as InferPlatformConfig<TPlatform>["listeners"][P] extends true | undefined ? P : never]: true;
|
|
235
236
|
};
|
|
236
237
|
type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> = InferPlatformConfig<TPlatform>["router"];
|
|
237
|
-
type IORoomListenerEvent<TContext extends Record<string, any>> = {
|
|
238
|
+
type IORoomListenerEvent<TPlatform extends AbstractPlatform<any, any, any, any>, TContext extends Record<string, any>> = {
|
|
238
239
|
context: TContext;
|
|
239
240
|
encodedState: string | null;
|
|
241
|
+
platform: TPlatform;
|
|
240
242
|
room: string;
|
|
241
243
|
};
|
|
242
|
-
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TContext> & {
|
|
244
|
+
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
243
245
|
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
244
246
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
245
247
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
246
248
|
};
|
|
247
|
-
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
249
|
+
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
248
250
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
249
251
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
250
252
|
};
|
|
251
|
-
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
253
|
+
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
252
254
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
253
255
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
254
256
|
};
|
|
255
|
-
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
257
|
+
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
256
258
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
257
259
|
};
|
|
258
260
|
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
@@ -327,7 +329,7 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket<any
|
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
330
|
-
onDestroy: (event: IORoomListenerEvent<TContext>) => void;
|
|
332
|
+
onDestroy: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
|
|
331
333
|
onMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
332
334
|
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
333
335
|
onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
@@ -339,7 +341,7 @@ type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any
|
|
|
339
341
|
authorize?: TAuthorize;
|
|
340
342
|
context: TContext;
|
|
341
343
|
crdt?: {
|
|
342
|
-
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
344
|
+
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
343
345
|
};
|
|
344
346
|
debug: boolean;
|
|
345
347
|
platform: TPlatform;
|
|
@@ -433,13 +435,13 @@ type PluvServerConfig<TPlatform extends AbstractPlatform<any, any> = AbstractPla
|
|
|
433
435
|
authorize?: TAuthorize;
|
|
434
436
|
context?: PluvContext<TPlatform, TContext>;
|
|
435
437
|
crdt?: {
|
|
436
|
-
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
438
|
+
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
437
439
|
};
|
|
438
440
|
debug?: boolean;
|
|
439
441
|
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
440
442
|
limits: PluvIOLimits;
|
|
441
443
|
io: PluvIO<TPlatform, TAuthorize, TContext>;
|
|
442
|
-
platform: TPlatform;
|
|
444
|
+
platform: () => TPlatform;
|
|
443
445
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
444
446
|
};
|
|
445
447
|
type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
@@ -451,7 +453,6 @@ type CreateRoomOptions<TPlatform extends AbstractPlatform<any, any>, TAuthorize
|
|
|
451
453
|
declare class PluvServer<TPlatform extends AbstractPlatform<any, any> = AbstractPlatform<any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
452
454
|
readonly version: string;
|
|
453
455
|
private readonly _authorize;
|
|
454
|
-
private readonly _baseRouter;
|
|
455
456
|
private readonly _context;
|
|
456
457
|
private readonly _crdt;
|
|
457
458
|
private readonly _debug;
|
|
@@ -459,7 +460,7 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any, any> = Abstract
|
|
|
459
460
|
private readonly _io;
|
|
460
461
|
private readonly _limits;
|
|
461
462
|
private readonly _platform;
|
|
462
|
-
private readonly
|
|
463
|
+
private readonly _inputRouter;
|
|
463
464
|
get fetch(): (...args: any[]) => Promise<any>;
|
|
464
465
|
/**
|
|
465
466
|
* @ignore
|
|
@@ -472,7 +473,9 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any, any> = Abstract
|
|
|
472
473
|
events: TEvents;
|
|
473
474
|
platform: TPlatform;
|
|
474
475
|
};
|
|
476
|
+
private get _baseRouter();
|
|
475
477
|
private get _procedure();
|
|
478
|
+
private get _router();
|
|
476
479
|
constructor(options: PluvServerConfig<TPlatform, TAuthorize, TContext, TEvents>);
|
|
477
480
|
createRoom(room: string, ...options: CreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>): IORoom<TPlatform, TAuthorize, TContext, TEvents>;
|
|
478
481
|
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<InferIOAuthorize<this>>, TPlatform>): Promise<string>;
|
|
@@ -486,7 +489,7 @@ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IO
|
|
|
486
489
|
crdt?: CrdtLibraryType;
|
|
487
490
|
debug?: boolean;
|
|
488
491
|
limits?: PluvIOLimits;
|
|
489
|
-
platform: TPlatform;
|
|
492
|
+
platform: () => TPlatform;
|
|
490
493
|
};
|
|
491
494
|
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> & {
|
|
492
495
|
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
@@ -517,7 +520,7 @@ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<a
|
|
|
517
520
|
crdt?: CrdtLibraryType;
|
|
518
521
|
debug?: boolean;
|
|
519
522
|
limits?: PluvIOLimits;
|
|
520
|
-
platform: TPlatform;
|
|
523
|
+
platform: () => TPlatform;
|
|
521
524
|
};
|
|
522
525
|
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>;
|
|
523
526
|
|
package/dist/index.d.ts
CHANGED
|
@@ -122,15 +122,16 @@ declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatf
|
|
|
122
122
|
|
|
123
123
|
type PluvContext<TPlatform extends AbstractPlatform, TContext extends Record<string, any>> = TContext | ((params: InferRoomContextType<TPlatform>) => TContext);
|
|
124
124
|
interface CrdtLibraryType {
|
|
125
|
-
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
125
|
+
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
126
126
|
kind: "loro" | "yjs";
|
|
127
127
|
}
|
|
128
128
|
type EventResolverKind = "broadcast" | "self" | "sync";
|
|
129
129
|
type EventResolver<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = (data: TInput, context: EventResolverContext<TKind, TPlatform, TAuthorize, TContext>) => MaybePromise<TOutput | void>;
|
|
130
130
|
interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}> {
|
|
131
131
|
context: TContext;
|
|
132
|
-
doc: CrdtDocLike<any>;
|
|
132
|
+
doc: CrdtDocLike<any, any>;
|
|
133
133
|
garbageCollect: () => Promise<void>;
|
|
134
|
+
platform: TPlatform;
|
|
134
135
|
presence: JsonObject | null;
|
|
135
136
|
room: string;
|
|
136
137
|
session: TKind extends "sync" ? WebSocketSession<TAuthorize> | null : WebSocketSession<TAuthorize>;
|
|
@@ -214,7 +215,7 @@ interface PluvIOLimits {
|
|
|
214
215
|
userMaxSize?: number | null;
|
|
215
216
|
}
|
|
216
217
|
type BasePluvIOListeners<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>> = {
|
|
217
|
-
onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
|
|
218
|
+
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
|
|
218
219
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
219
220
|
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
220
221
|
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
@@ -234,25 +235,26 @@ type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any, any, an
|
|
|
234
235
|
[P in keyof PlatformConfig["listeners"] as InferPlatformConfig<TPlatform>["listeners"][P] extends true | undefined ? P : never]: true;
|
|
235
236
|
};
|
|
236
237
|
type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> = InferPlatformConfig<TPlatform>["router"];
|
|
237
|
-
type IORoomListenerEvent<TContext extends Record<string, any>> = {
|
|
238
|
+
type IORoomListenerEvent<TPlatform extends AbstractPlatform<any, any, any, any>, TContext extends Record<string, any>> = {
|
|
238
239
|
context: TContext;
|
|
239
240
|
encodedState: string | null;
|
|
241
|
+
platform: TPlatform;
|
|
240
242
|
room: string;
|
|
241
243
|
};
|
|
242
|
-
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TContext> & {
|
|
244
|
+
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
243
245
|
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
244
246
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
245
247
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
246
248
|
};
|
|
247
|
-
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
249
|
+
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
248
250
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
249
251
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
250
252
|
};
|
|
251
|
-
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
253
|
+
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
252
254
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
253
255
|
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
254
256
|
};
|
|
255
|
-
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TContext> & {
|
|
257
|
+
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
256
258
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
257
259
|
};
|
|
258
260
|
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
@@ -327,7 +329,7 @@ declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket<any
|
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
330
|
-
onDestroy: (event: IORoomListenerEvent<TContext>) => void;
|
|
332
|
+
onDestroy: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
|
|
331
333
|
onMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
332
334
|
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
333
335
|
onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
@@ -339,7 +341,7 @@ type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any
|
|
|
339
341
|
authorize?: TAuthorize;
|
|
340
342
|
context: TContext;
|
|
341
343
|
crdt?: {
|
|
342
|
-
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
344
|
+
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
343
345
|
};
|
|
344
346
|
debug: boolean;
|
|
345
347
|
platform: TPlatform;
|
|
@@ -433,13 +435,13 @@ type PluvServerConfig<TPlatform extends AbstractPlatform<any, any> = AbstractPla
|
|
|
433
435
|
authorize?: TAuthorize;
|
|
434
436
|
context?: PluvContext<TPlatform, TContext>;
|
|
435
437
|
crdt?: {
|
|
436
|
-
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
438
|
+
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
437
439
|
};
|
|
438
440
|
debug?: boolean;
|
|
439
441
|
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
440
442
|
limits: PluvIOLimits;
|
|
441
443
|
io: PluvIO<TPlatform, TAuthorize, TContext>;
|
|
442
|
-
platform: TPlatform;
|
|
444
|
+
platform: () => TPlatform;
|
|
443
445
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
444
446
|
};
|
|
445
447
|
type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
@@ -451,7 +453,6 @@ type CreateRoomOptions<TPlatform extends AbstractPlatform<any, any>, TAuthorize
|
|
|
451
453
|
declare class PluvServer<TPlatform extends AbstractPlatform<any, any> = AbstractPlatform<any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
452
454
|
readonly version: string;
|
|
453
455
|
private readonly _authorize;
|
|
454
|
-
private readonly _baseRouter;
|
|
455
456
|
private readonly _context;
|
|
456
457
|
private readonly _crdt;
|
|
457
458
|
private readonly _debug;
|
|
@@ -459,7 +460,7 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any, any> = Abstract
|
|
|
459
460
|
private readonly _io;
|
|
460
461
|
private readonly _limits;
|
|
461
462
|
private readonly _platform;
|
|
462
|
-
private readonly
|
|
463
|
+
private readonly _inputRouter;
|
|
463
464
|
get fetch(): (...args: any[]) => Promise<any>;
|
|
464
465
|
/**
|
|
465
466
|
* @ignore
|
|
@@ -472,7 +473,9 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any, any> = Abstract
|
|
|
472
473
|
events: TEvents;
|
|
473
474
|
platform: TPlatform;
|
|
474
475
|
};
|
|
476
|
+
private get _baseRouter();
|
|
475
477
|
private get _procedure();
|
|
478
|
+
private get _router();
|
|
476
479
|
constructor(options: PluvServerConfig<TPlatform, TAuthorize, TContext, TEvents>);
|
|
477
480
|
createRoom(room: string, ...options: CreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>): IORoom<TPlatform, TAuthorize, TContext, TEvents>;
|
|
478
481
|
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<InferIOAuthorize<this>>, TPlatform>): Promise<string>;
|
|
@@ -486,7 +489,7 @@ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IO
|
|
|
486
489
|
crdt?: CrdtLibraryType;
|
|
487
490
|
debug?: boolean;
|
|
488
491
|
limits?: PluvIOLimits;
|
|
489
|
-
platform: TPlatform;
|
|
492
|
+
platform: () => TPlatform;
|
|
490
493
|
};
|
|
491
494
|
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> & {
|
|
492
495
|
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
@@ -517,7 +520,7 @@ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<a
|
|
|
517
520
|
crdt?: CrdtLibraryType;
|
|
518
521
|
debug?: boolean;
|
|
519
522
|
limits?: PluvIOLimits;
|
|
520
|
-
platform: TPlatform;
|
|
523
|
+
platform: () => TPlatform;
|
|
521
524
|
};
|
|
522
525
|
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>;
|
|
523
526
|
|