@pluv/io 0.22.0 → 0.23.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 +68 -0
- package/dist/index.d.mts +91 -90
- package/dist/index.d.ts +91 -90
- package/dist/index.js +144 -150
- package/dist/index.mjs +144 -150
- package/package.json +5 -5
- package/src/AbstractPlatform.ts +5 -5
- package/src/IORoom.ts +60 -49
- package/src/PluvIO.ts +16 -185
- package/src/PluvRouter.ts +1 -3
- package/src/PluvServer.ts +160 -21
- package/src/createIO.ts +3 -7
- package/src/types.ts +33 -6
- package/src/version.generated.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/io@0.
|
|
2
|
+
> @pluv/io@0.23.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@0.
|
|
6
|
+
> @pluv/io@0.23.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
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m39.65 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 159ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m37.48 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 160ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2147ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m24.62 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m24.62 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @pluv/io
|
|
2
2
|
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c01b16f: **BREAKING**
|
|
8
|
+
|
|
9
|
+
Moved `getInitialStorage`, `onRoomDeleted` and `onStorageUpdated` from `createIO` to `PluvIO.server`.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createIO } from "@pluv/io";
|
|
13
|
+
|
|
14
|
+
// Before
|
|
15
|
+
const io = createIO({
|
|
16
|
+
// ...
|
|
17
|
+
getInitialStorage: (event) => {
|
|
18
|
+
// ...
|
|
19
|
+
},
|
|
20
|
+
onRoomDeleted: (event) => {
|
|
21
|
+
// ...
|
|
22
|
+
},
|
|
23
|
+
onStorageUpdated: (event) => {
|
|
24
|
+
// ...
|
|
25
|
+
},
|
|
26
|
+
// ...
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const ioServer = io.server({
|
|
30
|
+
// ...
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// After
|
|
34
|
+
const io = createIO({
|
|
35
|
+
// ...
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const ioServer = io.server({
|
|
39
|
+
// ...
|
|
40
|
+
getInitialStorage: (event) => {
|
|
41
|
+
// ...
|
|
42
|
+
},
|
|
43
|
+
onRoomDeleted: (event) => {
|
|
44
|
+
// ...
|
|
45
|
+
},
|
|
46
|
+
onStorageUpdated: (event) => {
|
|
47
|
+
// ...
|
|
48
|
+
},
|
|
49
|
+
// ...
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Added a new listener `onRoomMessage` to `PluvIO.server` to listen to events that are sent within a room.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const ioServer = io.server({
|
|
57
|
+
// ...
|
|
58
|
+
onRoomMessage: (event) => {
|
|
59
|
+
console.log(event.message);
|
|
60
|
+
console.log(event.user);
|
|
61
|
+
},
|
|
62
|
+
// ...
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- @pluv/crdt@0.23.0
|
|
69
|
+
- @pluv/types@0.23.0
|
|
70
|
+
|
|
3
71
|
## 0.22.0
|
|
4
72
|
|
|
5
73
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, BaseIOAuthorize,
|
|
1
|
+
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, BaseIOAuthorize, IORouterLike, InferIOAuthorizeUser, Id, Maybe, InferEventMessage, InferEventsOutput, IOLike, InferIOOutput, BaseUser, InferIOInput, InferIOAuthorize } from '@pluv/types';
|
|
2
2
|
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
3
3
|
import { AbstractCrdtDoc, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
4
4
|
|
|
@@ -82,6 +82,45 @@ declare abstract class AbstractWebSocket<TWebSocket = any> {
|
|
|
82
82
|
sendMessage<TMessage extends IOEventMessage<any> = IOEventMessage<any>>(data: TMessage): void;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
interface PluvProcedureConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> {
|
|
86
|
+
broadcast?: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
87
|
+
input?: InputZodLike<TInput>;
|
|
88
|
+
self?: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
89
|
+
sync?: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
90
|
+
}
|
|
91
|
+
declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}, TFilled extends "input" | "broadcast" | "self" | "sync" | "" = ""> {
|
|
92
|
+
private _broadcast;
|
|
93
|
+
private _input;
|
|
94
|
+
private _self;
|
|
95
|
+
private _sync;
|
|
96
|
+
get config(): {
|
|
97
|
+
broadcast: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
98
|
+
input: InputZodLike<TInput> | null;
|
|
99
|
+
resolver: () => EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TOutput>;
|
|
100
|
+
self: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
101
|
+
sync: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
102
|
+
};
|
|
103
|
+
constructor(config?: PluvProcedureConfig<TPlatform, TAuthorize, TContext, TInput, TOutput>);
|
|
104
|
+
broadcast<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "broadcast">, TFilled | "input" | "broadcast">;
|
|
105
|
+
input<TData extends JsonObject>(input: InputZodLike<TData>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TData, {}, TFilled | "input">, TFilled | "input">;
|
|
106
|
+
self<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "self">, TFilled | "input" | "self">;
|
|
107
|
+
sync<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "sync">, TFilled | "input" | "sync">;
|
|
108
|
+
private _resolver;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}> = {
|
|
112
|
+
[P: string]: Pick<PluvProcedure<TPlatform, TAuthorize, TContext, any, any>, "config">;
|
|
113
|
+
};
|
|
114
|
+
type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TRoot extends TRouters[0]["_events"] = {}> = TRouters extends [
|
|
115
|
+
infer IHead extends PluvRouter<TPlatform, TAuthorize, TContext, any>,
|
|
116
|
+
...infer ITail extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]
|
|
117
|
+
] ? MergedRouter<ITail, TPlatform, TAuthorize, TContext, TRoot & IHead["_events"]> : PluvRouter<TPlatform, TAuthorize, TContext, TRoot>;
|
|
118
|
+
declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
|
|
119
|
+
readonly _events: TEvents;
|
|
120
|
+
constructor(events: TEvents);
|
|
121
|
+
static merge<TRouters extends PluvRouter<any, any, any, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
|
|
122
|
+
}
|
|
123
|
+
|
|
85
124
|
declare global {
|
|
86
125
|
var console: {
|
|
87
126
|
log: (...data: any[]) => void;
|
|
@@ -139,14 +178,20 @@ type GetInitialStorageEvent<TPlatform extends AbstractPlatform> = {
|
|
|
139
178
|
room: string;
|
|
140
179
|
} & InferRoomContextType<TPlatform>;
|
|
141
180
|
type GetInitialStorageFn<TPlatform extends AbstractPlatform> = (event: GetInitialStorageEvent<TPlatform>) => MaybePromise<Maybe<string>>;
|
|
142
|
-
interface PluvIOListeners<TPlatform extends AbstractPlatform
|
|
143
|
-
onRoomDeleted: (event: IORoomListenerEvent<TPlatform>) => void;
|
|
144
|
-
|
|
181
|
+
interface PluvIOListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
182
|
+
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
183
|
+
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
184
|
+
onStorageUpdated: (event: IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
145
185
|
}
|
|
146
|
-
type IORoomListenerEvent<TPlatform extends AbstractPlatform
|
|
147
|
-
|
|
186
|
+
type IORoomListenerEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = {
|
|
187
|
+
context: TContext & InferRoomContextType<TPlatform>;
|
|
148
188
|
encodedState: string | null;
|
|
149
|
-
|
|
189
|
+
room: string;
|
|
190
|
+
};
|
|
191
|
+
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
192
|
+
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
193
|
+
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
194
|
+
};
|
|
150
195
|
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
151
196
|
|
|
152
197
|
type IOPubSubEventMessage<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>> = IOEventMessage<TIO, TEvent> & {
|
|
@@ -172,12 +217,12 @@ interface ConvertWebSocketConfig {
|
|
|
172
217
|
room: string;
|
|
173
218
|
}
|
|
174
219
|
declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket = AbstractWebSocket, TPlatformContext extends Record<string, any> = {}, TRoomContext extends Record<string, any> = {}> {
|
|
220
|
+
protected readonly _ioContext: TPlatformContext | undefined;
|
|
221
|
+
protected readonly _roomContext: TRoomContext | undefined;
|
|
175
222
|
private _initialized;
|
|
176
|
-
readonly _ioContext: TPlatformContext | undefined;
|
|
177
|
-
readonly _roomContext: TRoomContext | undefined;
|
|
178
|
-
abstract readonly _registrationMode: WebSocketRegistrationMode;
|
|
179
223
|
persistance: AbstractPersistance;
|
|
180
224
|
pubSub: AbstractPubSub;
|
|
225
|
+
abstract readonly _registrationMode: WebSocketRegistrationMode;
|
|
181
226
|
constructor(config?: AbstractPlatformConfig<TPlatformContext, TRoomContext>);
|
|
182
227
|
abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
183
228
|
abstract convertWebSocket(webSocket: InferWebSocketSource<TWebSocket>, config: ConvertWebSocketConfig): AbstractWebSocket;
|
|
@@ -211,52 +256,14 @@ interface AuthorizeModule {
|
|
|
211
256
|
encode: <TUser extends BaseUser, TPlatform extends AbstractPlatform>(params: JWTEncodeParams<TUser, TPlatform>) => Promise<string>;
|
|
212
257
|
}
|
|
213
258
|
|
|
214
|
-
interface
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
self?: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
218
|
-
sync?: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
219
|
-
}
|
|
220
|
-
declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}, TFilled extends "input" | "broadcast" | "self" | "sync" | "" = ""> {
|
|
221
|
-
private _broadcast;
|
|
222
|
-
private _input;
|
|
223
|
-
private _self;
|
|
224
|
-
private _sync;
|
|
225
|
-
get config(): {
|
|
226
|
-
broadcast: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
227
|
-
input: InputZodLike<TInput> | null;
|
|
228
|
-
resolver: () => EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TOutput>;
|
|
229
|
-
self: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
230
|
-
sync: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
231
|
-
};
|
|
232
|
-
constructor(config?: PluvProcedureConfig<TPlatform, TAuthorize, TContext, TInput, TOutput>);
|
|
233
|
-
broadcast<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "broadcast">, TFilled | "input" | "broadcast">;
|
|
234
|
-
input<TData extends JsonObject>(input: InputZodLike<TData>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TData, {}, TFilled | "input">, TFilled | "input">;
|
|
235
|
-
self<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "self">, TFilled | "input" | "self">;
|
|
236
|
-
sync<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "sync">, TFilled | "input" | "sync">;
|
|
237
|
-
private _resolver;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}> = {
|
|
241
|
-
[P: string]: Pick<PluvProcedure<TPlatform, TAuthorize, TContext, any, any>, "config">;
|
|
242
|
-
};
|
|
243
|
-
type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TRoot extends TRouters[0]["_events"] = {}> = TRouters extends [
|
|
244
|
-
infer IHead extends PluvRouter<TPlatform, TAuthorize, TContext, any>,
|
|
245
|
-
...infer ITail extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]
|
|
246
|
-
] ? MergedRouter<ITail, TPlatform, TAuthorize, TContext, TRoot & IHead["_events"]> : PluvRouter<TPlatform, TAuthorize, TContext, TRoot>;
|
|
247
|
-
declare class PluvRouter<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IORouterLike<TEvents> {
|
|
248
|
-
readonly _events: TEvents;
|
|
249
|
-
constructor(events: TEvents);
|
|
250
|
-
static merge<TRouters extends PluvRouter<any, any, any, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
interface IORoomListeners<TPlatform extends AbstractPlatform> {
|
|
254
|
-
onDestroy: (event: IORoomListenerEvent<TPlatform>) => void;
|
|
259
|
+
interface IORoomListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>>, TContext extends JsonObject, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
260
|
+
onDestroy: (event: IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
261
|
+
onMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
255
262
|
}
|
|
256
263
|
type BroadcastProxy<TIO extends IORoom<any, any, any, any>> = (<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>) => Promise<void>) & {
|
|
257
264
|
[event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>>[event]) => Promise<void>;
|
|
258
265
|
};
|
|
259
|
-
type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<IORoomListeners<TPlatform>> & {
|
|
266
|
+
type IORoomConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
260
267
|
authorize?: TAuthorize;
|
|
261
268
|
context: TContext & InferRoomContextType<TPlatform>;
|
|
262
269
|
crdt?: {
|
|
@@ -270,17 +277,17 @@ interface WebsocketRegisterOptions {
|
|
|
270
277
|
token?: string | null;
|
|
271
278
|
}
|
|
272
279
|
declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferRoomContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
280
|
+
readonly id: string;
|
|
281
|
+
readonly _authorize: TAuthorize | null;
|
|
282
|
+
private _doc;
|
|
283
|
+
private _uninitialize;
|
|
273
284
|
private readonly _context;
|
|
274
285
|
private readonly _debug;
|
|
275
286
|
private readonly _docFactory;
|
|
287
|
+
private readonly _listeners;
|
|
276
288
|
private readonly _platform;
|
|
277
|
-
private
|
|
278
|
-
private
|
|
279
|
-
private _sessions;
|
|
280
|
-
private _uninitialize;
|
|
281
|
-
readonly _authorize: TAuthorize | null;
|
|
282
|
-
readonly _router: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
283
|
-
readonly id: string;
|
|
289
|
+
private readonly _router;
|
|
290
|
+
private readonly _sessions;
|
|
284
291
|
get _events(): TEvents;
|
|
285
292
|
get broadcast(): BroadcastProxy<this>;
|
|
286
293
|
constructor(id: string, config: IORoomConfig<TPlatform, TAuthorize, TContext, TEvents>);
|
|
@@ -312,13 +319,14 @@ declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
|
|
|
312
319
|
}
|
|
313
320
|
|
|
314
321
|
type InferIORoom<TServer extends PluvServer<any, any, any, any>> = TServer extends PluvServer<infer IPlatform, infer IAuthorize, infer IContext, infer IEvents> ? IORoom<IPlatform, IAuthorize, IContext, IEvents> : never;
|
|
315
|
-
type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform>> & {
|
|
322
|
+
type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
316
323
|
authorize?: TAuthorize;
|
|
317
324
|
context?: TContext;
|
|
318
325
|
crdt?: {
|
|
319
326
|
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
320
327
|
};
|
|
321
328
|
debug?: boolean;
|
|
329
|
+
getInitialStorage?: GetInitialStorageFn<TPlatform>;
|
|
322
330
|
platform: TPlatform;
|
|
323
331
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
324
332
|
};
|
|
@@ -328,19 +336,20 @@ type GetRoomOptions<TPlatform extends AbstractPlatform> = keyof InferRoomContext
|
|
|
328
336
|
debug?: boolean;
|
|
329
337
|
} & InferRoomContextType<TPlatform>>];
|
|
330
338
|
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> {
|
|
331
|
-
|
|
339
|
+
_listeners: PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>;
|
|
340
|
+
readonly version: string;
|
|
332
341
|
readonly _authorize: TAuthorize | null;
|
|
333
|
-
readonly
|
|
334
|
-
readonly
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
readonly
|
|
338
|
-
readonly
|
|
339
|
-
readonly
|
|
340
|
-
readonly _router
|
|
341
|
-
readonly _version: string;
|
|
342
|
+
private readonly _baseRouter;
|
|
343
|
+
private readonly _context;
|
|
344
|
+
private readonly _crdt;
|
|
345
|
+
private readonly _debug;
|
|
346
|
+
private readonly _getInitialStorage;
|
|
347
|
+
private readonly _platform;
|
|
348
|
+
private readonly _rooms;
|
|
349
|
+
private readonly _router;
|
|
342
350
|
get _events(): TEvents;
|
|
343
351
|
get _registrationMode(): WebSocketRegistrationMode;
|
|
352
|
+
private get _procedure();
|
|
344
353
|
constructor(options: PluvServerConfig<TPlatform, TAuthorize, TContext, TEvents>);
|
|
345
354
|
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<InferIOAuthorize<this>>, TPlatform>): Promise<string>;
|
|
346
355
|
getRoom(room: string, ...options: GetRoomOptions<TPlatform>): IORoom<TPlatform, TAuthorize, TContext, TEvents>;
|
|
@@ -348,49 +357,41 @@ declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatf
|
|
|
348
357
|
private _purgeEmptyRooms;
|
|
349
358
|
}
|
|
350
359
|
|
|
351
|
-
type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>>, TContext extends JsonObject> =
|
|
360
|
+
type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>>, TContext extends JsonObject> = {
|
|
352
361
|
authorize?: TAuthorize;
|
|
353
362
|
context?: TContext;
|
|
354
363
|
crdt?: {
|
|
355
364
|
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
356
365
|
};
|
|
357
366
|
debug?: boolean;
|
|
358
|
-
getInitialStorage?: GetInitialStorageFn<TPlatform>;
|
|
359
367
|
platform: TPlatform;
|
|
360
368
|
};
|
|
361
|
-
|
|
369
|
+
type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
370
|
+
getInitialStorage?: GetInitialStorageFn<TPlatform>;
|
|
362
371
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
363
|
-
}
|
|
364
|
-
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}>
|
|
365
|
-
|
|
372
|
+
};
|
|
373
|
+
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferPlatformContextType<TPlatform>> = BaseIOAuthorize, TContext extends JsonObject = {}> {
|
|
374
|
+
readonly version: string;
|
|
366
375
|
readonly _authorize: TAuthorize | null;
|
|
367
|
-
readonly _context
|
|
368
|
-
readonly _crdt
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
readonly _debug: boolean;
|
|
372
|
-
readonly _getInitialStorage: GetInitialStorageFn<TPlatform> | null;
|
|
373
|
-
readonly _listeners: PluvIOListeners<TPlatform>;
|
|
374
|
-
readonly _platform: TPlatform;
|
|
375
|
-
readonly _version: string;
|
|
376
|
-
get _events(): {};
|
|
377
|
-
get _registrationMode(): WebSocketRegistrationMode;
|
|
376
|
+
private readonly _context;
|
|
377
|
+
private readonly _crdt;
|
|
378
|
+
private readonly _debug;
|
|
379
|
+
private readonly _platform;
|
|
378
380
|
get procedure(): PluvProcedure<TPlatform, TAuthorize, TContext, {}, {}>;
|
|
379
381
|
constructor(options: PluvIOConfig<TPlatform, TAuthorize, TContext>);
|
|
380
|
-
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<
|
|
382
|
+
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<TAuthorize>, TPlatform>): Promise<string>;
|
|
381
383
|
mergeRouters<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
|
|
382
384
|
router<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>>(events: TEvents): PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
383
385
|
server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>>(config?: ServerConfig<TPlatform, TAuthorize, TContext, TEvents>): PluvServer<TPlatform, TAuthorize, TContext, TEvents>;
|
|
384
386
|
}
|
|
385
387
|
|
|
386
|
-
type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends JsonObject = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false> =
|
|
388
|
+
type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends JsonObject = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false> = {
|
|
387
389
|
authorize?: IOAuthorize<TAuthorizeUser, TAuthorizeRequired, InferPlatformContextType<TPlatform>>;
|
|
388
390
|
context?: TContext;
|
|
389
391
|
crdt?: {
|
|
390
392
|
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
391
393
|
};
|
|
392
394
|
debug?: boolean;
|
|
393
|
-
getInitialStorage?: GetInitialStorageFn<TPlatform>;
|
|
394
395
|
platform: TPlatform;
|
|
395
396
|
};
|
|
396
397
|
declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}>, TContext extends JsonObject = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false>(params: CreateIOParams<TPlatform, TContext, TAuthorizeUser, TAuthorizeRequired>) => PluvIO<TPlatform, IOAuthorize<TAuthorizeUser, TAuthorizeRequired, InferPlatformContextType<TPlatform>>, TContext>;
|