@pluv/io 3.2.2 → 4.0.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 +15 -17
- package/CHANGELOG.md +92 -0
- package/dist/index.d.mts +427 -423
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1390 -1476
- package/dist/index.mjs.map +1 -0
- package/package.json +18 -14
- package/src/IORoom.ts +65 -17
- package/src/PluvIO.ts +4 -16
- package/src/PluvRouter.ts +3 -10
- package/src/PluvServer.ts +31 -22
- package/src/index.ts +1 -0
- package/src/types.ts +13 -2
- package/src/version.generated.ts +1 -1
- package/tsdown.config.ts +14 -0
- package/dist/index.d.ts +0 -539
- package/dist/index.js +0 -1575
package/dist/index.d.ts
DELETED
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
import { AbstractCrdtDocFactory, CrdtLibraryType as CrdtLibraryType$1, NoopCrdtDocFactory } from '@pluv/crdt';
|
|
2
|
-
export { CrdtLibraryType } from '@pluv/crdt';
|
|
3
|
-
import { JsonObject, IOAuthorize, InferIOAuthorizeUser, MaybePromise, IOEventMessage, EventRecord, ProcedureLike, InputZodLike, IORouterLike, BaseUser, UndefinedProps, CrdtDocLike, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, CrdtLibraryType, InferIOInput, InferIOAuthorize, HasRequiredProperty } from '@pluv/types';
|
|
4
|
-
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
5
|
-
|
|
6
|
-
declare abstract class AbstractPersistence {
|
|
7
|
-
abstract addUser(room: string, connectionId: string, user: JsonObject | null): Promise<void>;
|
|
8
|
-
abstract deleteStorageState(room: string): Promise<void>;
|
|
9
|
-
abstract deleteUser(room: string, connectionId: string): Promise<void>;
|
|
10
|
-
abstract deleteUsers(room: string): Promise<void>;
|
|
11
|
-
abstract getStorageState(room: string): Promise<string | null>;
|
|
12
|
-
abstract getUser(room: string, connectionId: string): Promise<JsonObject | null>;
|
|
13
|
-
abstract getUsers(room: string): Promise<Map<[connectionId: string][0], JsonObject | null>>;
|
|
14
|
-
abstract getUsersSize(room: string): Promise<number>;
|
|
15
|
-
abstract initialize(roomContext: any): typeof this;
|
|
16
|
-
abstract setStorageState(room: string, state: string): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type AbstractEvent = {};
|
|
20
|
-
type AbstractCloseEvent = AbstractEvent & {
|
|
21
|
-
readonly code: number;
|
|
22
|
-
readonly reason: string;
|
|
23
|
-
};
|
|
24
|
-
type AbstractMessageEvent<T = any> = AbstractEvent & {
|
|
25
|
-
readonly data: T;
|
|
26
|
-
};
|
|
27
|
-
type AbstractErrorEvent = AbstractEvent & {
|
|
28
|
-
error: unknown;
|
|
29
|
-
message?: string;
|
|
30
|
-
};
|
|
31
|
-
interface AbstractEventMap {
|
|
32
|
-
close: AbstractCloseEvent;
|
|
33
|
-
message: AbstractMessageEvent;
|
|
34
|
-
error: AbstractErrorEvent;
|
|
35
|
-
}
|
|
36
|
-
type EventType = keyof AbstractEventMap;
|
|
37
|
-
interface AbstractWebSocketHandleErrorParams {
|
|
38
|
-
error: unknown;
|
|
39
|
-
message?: string;
|
|
40
|
-
room: string;
|
|
41
|
-
session?: WebSocketSession<any>;
|
|
42
|
-
}
|
|
43
|
-
type AbstractListener<TType extends keyof AbstractEventMap> = (event: AbstractEventMap[TType]) => MaybePromise<void>;
|
|
44
|
-
type InferWebSocketSource<TAbstractWebSocket extends AbstractWebSocket> = TAbstractWebSocket extends AbstractWebSocket<infer IWebSocket> ? IWebSocket : never;
|
|
45
|
-
interface AbstractWebSocketConfig {
|
|
46
|
-
persistence: AbstractPersistence;
|
|
47
|
-
platform: AbstractPlatform<any>;
|
|
48
|
-
room: string;
|
|
49
|
-
}
|
|
50
|
-
declare abstract class AbstractWebSocket<TWebSocket = any, TAuthorize extends IOAuthorize<any, any> | null = null> {
|
|
51
|
-
/** The connection is not yet open. */
|
|
52
|
-
readonly CONNECTING = 0;
|
|
53
|
-
/** The connection is open and ready to communicate. */
|
|
54
|
-
readonly OPEN = 1;
|
|
55
|
-
/** The connection is in the process of closing. */
|
|
56
|
-
readonly CLOSING = 2;
|
|
57
|
-
/** The connection is closed. */
|
|
58
|
-
readonly CLOSED = 3;
|
|
59
|
-
readonly persistence: AbstractPersistence;
|
|
60
|
-
readonly room: string;
|
|
61
|
-
readonly webSocket: TWebSocket;
|
|
62
|
-
protected readonly _platform: AbstractPlatform<this>;
|
|
63
|
-
abstract set presence(presence: JsonObject | null);
|
|
64
|
-
abstract get readyState(): 0 | 1 | 2 | 3;
|
|
65
|
-
abstract get session(): WebSocketSession<TAuthorize>;
|
|
66
|
-
abstract get sessionId(): string;
|
|
67
|
-
abstract get state(): WebSocketSerializedState;
|
|
68
|
-
abstract set state(state: WebSocketSerializedState);
|
|
69
|
-
abstract set user(user: InferIOAuthorizeUser<TAuthorize>);
|
|
70
|
-
constructor(webSocket: TWebSocket, config: AbstractWebSocketConfig);
|
|
71
|
-
/**
|
|
72
|
-
* TODO
|
|
73
|
-
* @description Return an unsubscribe method to remove the event-listener.
|
|
74
|
-
* This is preferred over adding an explicit abstract removeEventListener
|
|
75
|
-
* method, because the implementing class might have to transform the
|
|
76
|
-
* listener, and removing the same listener might be complicated as a
|
|
77
|
-
* result.
|
|
78
|
-
* @date August 28, 2022
|
|
79
|
-
*/
|
|
80
|
-
abstract addEventListener<TType extends EventType>(type: TType, handler: AbstractListener<TType>): void;
|
|
81
|
-
abstract close(code?: number | undefined, reason?: string | undefined): void;
|
|
82
|
-
abstract send(message: ArrayBuffer | ArrayBufferView | string): void;
|
|
83
|
-
abstract terminate(): void;
|
|
84
|
-
handleError(params: AbstractWebSocketHandleErrorParams): void;
|
|
85
|
-
sendMessage<TMessage extends IOEventMessage<any> = IOEventMessage<any>>(data: TMessage): void;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface PluvProcedureConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> {
|
|
89
|
-
broadcast?: EventResolver<"broadcast", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
90
|
-
input?: InputZodLike<TInput>;
|
|
91
|
-
self?: EventResolver<"self", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
92
|
-
sync?: EventResolver<"sync", TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
93
|
-
}
|
|
94
|
-
declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}, TFilled extends "input" | "broadcast" | "self" | "sync" | "" = ""> {
|
|
95
|
-
private _broadcast;
|
|
96
|
-
private _input;
|
|
97
|
-
private _self;
|
|
98
|
-
private _sync;
|
|
99
|
-
get config(): ProcedureLike<TInput, TOutput>["config"];
|
|
100
|
-
constructor(config?: PluvProcedureConfig<TPlatform, TAuthorize, TContext, TInput, TOutput>);
|
|
101
|
-
broadcast<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<"broadcast", TPlatform, TAuthorize, TContext, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "broadcast">, TFilled | "input" | "broadcast">;
|
|
102
|
-
input<TData extends JsonObject>(input: InputZodLike<TData>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TData, {}, TFilled | "input">, TFilled | "input">;
|
|
103
|
-
self<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<"self", TPlatform, TAuthorize, TContext, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "self">, TFilled | "input" | "self">;
|
|
104
|
-
sync<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<"sync", TPlatform, TAuthorize, TContext, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "sync">, TFilled | "input" | "sync">;
|
|
105
|
-
private _resolver;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
type PluvRouterEventConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}> = {
|
|
109
|
-
[P: string]: Pick<PluvProcedure<TPlatform, TAuthorize, TContext, any, any>, "config">;
|
|
110
|
-
};
|
|
111
|
-
type MergedRouter<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[] = [], TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> = any, TContext extends Record<string, any> = {}, TRoot extends TRouters[0]["_defs"]["events"] = {}> = TRouters extends [
|
|
112
|
-
infer IHead extends PluvRouter<TPlatform, TAuthorize, TContext, any>,
|
|
113
|
-
...infer ITail extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]
|
|
114
|
-
] ? MergedRouter<ITail, TPlatform, TAuthorize, TContext, TRoot & IHead["_defs"]["events"]> : PluvRouter<TPlatform, TAuthorize, TContext, TRoot>;
|
|
115
|
-
declare class PluvRouter<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> = {}> implements IORouterLike<TEvents> {
|
|
116
|
-
readonly _defs: {
|
|
117
|
-
events: TEvents;
|
|
118
|
-
};
|
|
119
|
-
constructor(events: TEvents);
|
|
120
|
-
static merge<TRouters extends PluvRouter<any, any, any, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
|
|
121
|
-
private _isValidEventName;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
type PluvContext<TPlatform extends AbstractPlatform, TContext extends Record<string, any>> = MaybePromise<TContext> | ((params: InferRoomContextType<TPlatform>) => MaybePromise<TContext>);
|
|
125
|
-
type EventResolverKind = "broadcast" | "self" | "sync";
|
|
126
|
-
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>;
|
|
127
|
-
interface EventResolverContext<TKind extends EventResolverKind = EventResolverKind, TPlatform extends AbstractPlatform = AbstractPlatform, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}> {
|
|
128
|
-
context: TContext;
|
|
129
|
-
doc: CrdtDocLike<any, any>;
|
|
130
|
-
garbageCollect: () => Promise<void>;
|
|
131
|
-
platform: TPlatform;
|
|
132
|
-
presence: JsonObject | null;
|
|
133
|
-
room: string;
|
|
134
|
-
session: TKind extends "sync" ? WebSocketSession<TAuthorize> | null : WebSocketSession<TAuthorize>;
|
|
135
|
-
sessions: readonly WebSocketSession<TAuthorize>[];
|
|
136
|
-
time: number;
|
|
137
|
-
}
|
|
138
|
-
type SendMessageOptions = {
|
|
139
|
-
type?: "broadcast";
|
|
140
|
-
sessionIds?: readonly string[];
|
|
141
|
-
} | {
|
|
142
|
-
type: "self";
|
|
143
|
-
} | {
|
|
144
|
-
type: "sync";
|
|
145
|
-
};
|
|
146
|
-
interface WebSocketSessionTimers {
|
|
147
|
-
ping: number;
|
|
148
|
-
presence: number | null;
|
|
149
|
-
}
|
|
150
|
-
interface WebSocketSerializedState {
|
|
151
|
-
presence: JsonObject | null;
|
|
152
|
-
quit: boolean;
|
|
153
|
-
room: string;
|
|
154
|
-
timers: WebSocketSessionTimers;
|
|
155
|
-
}
|
|
156
|
-
type WebSocketSession<TAuthorize extends IOAuthorize<any, any> | null = null> = WebSocketSerializedState & {
|
|
157
|
-
id: string;
|
|
158
|
-
user: InferIOAuthorizeUser<TAuthorize>;
|
|
159
|
-
webSocket: AbstractWebSocket;
|
|
160
|
-
};
|
|
161
|
-
type MergeEventRecords<TEventRecords extends EventRecord<string, any>[], TRoot extends EventRecord<string, any> = {}> = TEventRecords extends [
|
|
162
|
-
infer IHead extends EventRecord<string, any>,
|
|
163
|
-
...infer ITail extends EventRecord<string, any>[]
|
|
164
|
-
] ? MergeEventRecords<ITail, Omit<TRoot, keyof IHead> & {
|
|
165
|
-
[P in keyof IHead]: TRoot extends Record<P, any> ? TRoot[P] | IHead[P] : IHead[P];
|
|
166
|
-
}> : Id<TRoot>;
|
|
167
|
-
type GetInitialStorageEvent<TContext extends Record<string, any>> = {
|
|
168
|
-
context: TContext;
|
|
169
|
-
room: string;
|
|
170
|
-
};
|
|
171
|
-
type GetInitialStorageFn<TContext extends Record<string, any>> = (event: GetInitialStorageEvent<TContext>) => MaybePromise<Maybe<string>>;
|
|
172
|
-
type HandleMode = "io" | "fetch";
|
|
173
|
-
type WebSocketRegistrationMode = "attached" | "detached";
|
|
174
|
-
interface PlatformConfig {
|
|
175
|
-
authorize: {
|
|
176
|
-
secret?: boolean;
|
|
177
|
-
};
|
|
178
|
-
requireAuth?: boolean;
|
|
179
|
-
handleMode: HandleMode;
|
|
180
|
-
registrationMode: WebSocketRegistrationMode;
|
|
181
|
-
listeners: {
|
|
182
|
-
onRoomDeleted?: boolean;
|
|
183
|
-
onRoomMessage?: boolean;
|
|
184
|
-
onStorageUpdated?: boolean;
|
|
185
|
-
onUserConnected?: boolean;
|
|
186
|
-
onUserDisconnected?: boolean;
|
|
187
|
-
};
|
|
188
|
-
router?: boolean;
|
|
189
|
-
}
|
|
190
|
-
type ResolvedPluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser = any> = {
|
|
191
|
-
user: InputZodLike<TUser>;
|
|
192
|
-
} & UndefinedProps<{
|
|
193
|
-
secret?: string;
|
|
194
|
-
}, Exclude<"secret", InferPlatformAuthorizeProperties<TPlatform>>>;
|
|
195
|
-
type PluvIOAuthorize<TPlatform extends AbstractPlatform<any, any, any, any>, TUser extends BaseUser | null = any, TContext extends Record<string, unknown> = {}> = (TUser extends BaseUser ? ResolvedPluvIOAuthorize<TPlatform, TUser> : null) | ((context: TContext) => TUser extends BaseUser ? ResolvedPluvIOAuthorize<TPlatform, TUser> : null);
|
|
196
|
-
interface PluvIOLimits {
|
|
197
|
-
/**
|
|
198
|
-
* @description Maximum size of presence object in bytes
|
|
199
|
-
*/
|
|
200
|
-
presenceMaxSize?: number | null;
|
|
201
|
-
/**
|
|
202
|
-
* @description Maximum size of storage state in bytes
|
|
203
|
-
*/
|
|
204
|
-
storageMaxSize?: number | null;
|
|
205
|
-
/**
|
|
206
|
-
* @description Maximum length of user id in characters
|
|
207
|
-
*/
|
|
208
|
-
userIdMaxLength?: number | null;
|
|
209
|
-
/**
|
|
210
|
-
* @description Maximum size of user object in bytes
|
|
211
|
-
*/
|
|
212
|
-
userMaxSize?: number | null;
|
|
213
|
-
}
|
|
214
|
-
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>> = {
|
|
215
|
-
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
|
|
216
|
-
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
217
|
-
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
218
|
-
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
219
|
-
onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
220
|
-
};
|
|
221
|
-
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>>>;
|
|
222
|
-
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 ? {
|
|
223
|
-
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
224
|
-
} : {
|
|
225
|
-
router?: undefined;
|
|
226
|
-
};
|
|
227
|
-
type InferPlatformConfig<TPlatform extends AbstractPlatform<any, any, any, any>> = TPlatform extends AbstractPlatform<any, any, any, infer IConfig> ? IConfig : never;
|
|
228
|
-
type InferPlatformAuthorizeProperties<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
|
|
229
|
-
[P in keyof PlatformConfig["authorize"] as InferPlatformConfig<TPlatform>["authorize"][P] extends true | undefined ? P : never]: true;
|
|
230
|
-
};
|
|
231
|
-
type InferPlatformListeners<TPlatform extends AbstractPlatform<any, any, any, any>> = keyof {
|
|
232
|
-
[P in keyof PlatformConfig["listeners"] as InferPlatformConfig<TPlatform>["listeners"][P] extends true | undefined ? P : never]: true;
|
|
233
|
-
};
|
|
234
|
-
type InferPlatformRouter<TPlatform extends AbstractPlatform<any, any, any, any>> = InferPlatformConfig<TPlatform>["router"];
|
|
235
|
-
type IORoomListenerEvent<TPlatform extends AbstractPlatform<any, any, any, any>, TContext extends Record<string, any>> = {
|
|
236
|
-
context: TContext;
|
|
237
|
-
encodedState: string | null;
|
|
238
|
-
platform: TPlatform;
|
|
239
|
-
room: string;
|
|
240
|
-
};
|
|
241
|
-
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> & {
|
|
242
|
-
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
243
|
-
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
244
|
-
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
245
|
-
};
|
|
246
|
-
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
247
|
-
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
248
|
-
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
249
|
-
};
|
|
250
|
-
type IOUserConnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
251
|
-
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
252
|
-
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
253
|
-
};
|
|
254
|
-
type IOUserDisconnectedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>> = IORoomListenerEvent<TPlatform, TContext> & {
|
|
255
|
-
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
256
|
-
};
|
|
257
|
-
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
258
|
-
|
|
259
|
-
type IOPubSubEventMessage<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>> = IOEventMessage<TIO, TEvent> & {
|
|
260
|
-
options?: SendMessageOptions;
|
|
261
|
-
};
|
|
262
|
-
declare abstract class AbstractPubSub {
|
|
263
|
-
abstract publish(roomName: string, payload: IOPubSubEventMessage<any>): Promise<void>;
|
|
264
|
-
abstract subscribe(roomName: string, onMessage: (message: IOPubSubEventMessage<any>) => void): Promise<number>;
|
|
265
|
-
abstract unsubscribe(subscriptionId: number): void;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interface JWT<TUser extends BaseUser> {
|
|
269
|
-
room: string;
|
|
270
|
-
sub: string;
|
|
271
|
-
user: TUser;
|
|
272
|
-
}
|
|
273
|
-
type JWTEncodeParams<TUser extends BaseUser | null, TPlatform extends AbstractPlatform<any, any>> = {
|
|
274
|
-
maxAge?: number;
|
|
275
|
-
room: string;
|
|
276
|
-
user: TUser extends BaseUser ? TUser : "Error: Cannot create token without authorization!";
|
|
277
|
-
} & InferInitContextType<TPlatform>;
|
|
278
|
-
interface AuthorizeParams {
|
|
279
|
-
platform: AbstractPlatform<any, any>;
|
|
280
|
-
secret: string;
|
|
281
|
-
}
|
|
282
|
-
interface AuthorizeModule {
|
|
283
|
-
decode: <TUser extends BaseUser>(jwt: string) => Promise<TUser | null>;
|
|
284
|
-
encode: <TUser extends BaseUser, TPlatform extends AbstractPlatform<any, any>>(params: JWTEncodeParams<TUser, TPlatform>) => Promise<string>;
|
|
285
|
-
}
|
|
286
|
-
declare const authorize: (params: AuthorizeParams) => {
|
|
287
|
-
decode: <TUser extends BaseUser>(jwt: string) => Promise<JWT<TUser> | null>;
|
|
288
|
-
encode: <TUser extends BaseUser, TPlatform extends AbstractPlatform<any, any>>(encodeParams: JWTEncodeParams<TUser, TPlatform>) => Promise<string>;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
type InferPlatformWebSocketType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<infer IAbstractWebSocket> ? IAbstractWebSocket : never;
|
|
292
|
-
type InferPlatformWebSocketSource<TPlatform> = TPlatform extends AbstractPlatform<infer IAbstractWebSocket> ? InferWebSocketSource<IAbstractWebSocket> : never;
|
|
293
|
-
type InferInitContextType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<any, infer IInitContext> ? IInitContext : never;
|
|
294
|
-
type InferRoomContextType<TPlatform extends AbstractPlatform> = TPlatform extends AbstractPlatform<any, any, infer IRoomContext> ? IRoomContext : never;
|
|
295
|
-
type AbstractPlatformConfig<TRoomContext extends Record<string, any> = {}> = {
|
|
296
|
-
persistence?: AbstractPersistence;
|
|
297
|
-
pubSub?: AbstractPubSub;
|
|
298
|
-
roomContext?: TRoomContext;
|
|
299
|
-
};
|
|
300
|
-
interface ConvertWebSocketConfig {
|
|
301
|
-
room: string;
|
|
302
|
-
}
|
|
303
|
-
declare abstract class AbstractPlatform<TWebSocket extends AbstractWebSocket<any, any> = AbstractWebSocket<any, any>, TInitContext extends Record<string, any> = {}, TRoomContext extends Record<string, any> = {}, TConfig extends PlatformConfig = PlatformConfig> {
|
|
304
|
-
protected readonly _initContext: TInitContext | undefined;
|
|
305
|
-
protected readonly _roomContext: TRoomContext | undefined;
|
|
306
|
-
private _initialized;
|
|
307
|
-
persistence: AbstractPersistence;
|
|
308
|
-
pubSub: AbstractPubSub;
|
|
309
|
-
abstract readonly id: string;
|
|
310
|
-
readonly _createToken?: (params: JWTEncodeParams<any, any> & {
|
|
311
|
-
authorize: Maybe<ResolvedPluvIOAuthorize<any, any>>;
|
|
312
|
-
}) => Promise<string>;
|
|
313
|
-
_fetch?: (...args: any[]) => Promise<any>;
|
|
314
|
-
abstract readonly _config: TConfig;
|
|
315
|
-
abstract readonly _name: string;
|
|
316
|
-
constructor(config?: AbstractPlatformConfig<TRoomContext>);
|
|
317
|
-
abstract acceptWebSocket(webSocket: AbstractWebSocket): Promise<void>;
|
|
318
|
-
abstract convertWebSocket(webSocket: InferWebSocketSource<TWebSocket>, config: ConvertWebSocketConfig): AbstractWebSocket<any, any>;
|
|
319
|
-
abstract getLastPing(webSocket: AbstractWebSocket<any, any>): number | null;
|
|
320
|
-
abstract getSerializedState(webSocket: InferWebSocketSource<TWebSocket>): WebSocketSerializedState | null;
|
|
321
|
-
abstract getSessionId(webSocket: InferWebSocketSource<TWebSocket>): string | null;
|
|
322
|
-
abstract getWebSockets(): readonly InferWebSocketSource<TWebSocket>[];
|
|
323
|
-
abstract initialize(config: AbstractPlatformConfig<TRoomContext>): this;
|
|
324
|
-
abstract parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
325
|
-
abstract randomUUID(): string;
|
|
326
|
-
abstract setSerializedState(webSocket: AbstractWebSocket, state: WebSocketSerializedState): WebSocketSerializedState;
|
|
327
|
-
validateConfig(config: any): void;
|
|
328
|
-
protected _initialize(): typeof this;
|
|
329
|
-
}
|
|
330
|
-
|
|
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>> {
|
|
332
|
-
onDestroy: (event: IORoomListenerEvent<TPlatform, TContext>) => void;
|
|
333
|
-
onMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
334
|
-
onUserConnected: (event: IOUserConnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
335
|
-
onUserDisconnected: (event: IOUserDisconnectedEvent<TPlatform, TAuthorize, TContext>) => void;
|
|
336
|
-
}
|
|
337
|
-
type BroadcastProxy<TIO extends IORoom<any, any, any, any, any>> = (<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>) => Promise<void>) & {
|
|
338
|
-
[event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>>[event]) => Promise<void>;
|
|
339
|
-
};
|
|
340
|
-
type IORoomConfig<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<IORoomListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
341
|
-
authorize?: TAuthorize;
|
|
342
|
-
context: PluvContext<TPlatform, TContext>;
|
|
343
|
-
crdt?: {
|
|
344
|
-
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
345
|
-
};
|
|
346
|
-
debug: boolean;
|
|
347
|
-
getInitialStorage: GetInitialStorageFn<TContext>;
|
|
348
|
-
platform: TPlatform;
|
|
349
|
-
roomContext: InferRoomContextType<TPlatform>;
|
|
350
|
-
router: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
351
|
-
};
|
|
352
|
-
type WebSocketRegisterConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>> = {
|
|
353
|
-
token?: string | null;
|
|
354
|
-
} & InferInitContextType<TPlatform>;
|
|
355
|
-
declare class IORoom<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = null, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TCrdt, TEvents> {
|
|
356
|
-
readonly id: string;
|
|
357
|
-
private _doc;
|
|
358
|
-
private _lastGarbageCollectMs;
|
|
359
|
-
private _uninitialize;
|
|
360
|
-
private readonly _authorize;
|
|
361
|
-
private readonly _context;
|
|
362
|
-
private readonly _crdt;
|
|
363
|
-
private readonly _debug;
|
|
364
|
-
private readonly _docFactory;
|
|
365
|
-
private readonly _getInitialStorage;
|
|
366
|
-
private readonly _listeners;
|
|
367
|
-
private readonly _platform;
|
|
368
|
-
private readonly _roomContext;
|
|
369
|
-
private readonly _router;
|
|
370
|
-
private readonly _sessions;
|
|
371
|
-
private readonly _userSessionss;
|
|
372
|
-
/**
|
|
373
|
-
* @ignore
|
|
374
|
-
* @readonly
|
|
375
|
-
* @deprecated Internal use only. Changes to this will never be marked as breaking.
|
|
376
|
-
*/
|
|
377
|
-
get _defs(): {
|
|
378
|
-
authorize: TAuthorize;
|
|
379
|
-
context: TContext;
|
|
380
|
-
crdt: TCrdt;
|
|
381
|
-
events: TEvents;
|
|
382
|
-
platform: TPlatform;
|
|
383
|
-
};
|
|
384
|
-
get broadcast(): BroadcastProxy<this>;
|
|
385
|
-
private get _initialized();
|
|
386
|
-
constructor(id: string, config: IORoomConfig<TPlatform, TAuthorize, TContext, TEvents>);
|
|
387
|
-
/**
|
|
388
|
-
* @description Closes a connection with the specified sessionId
|
|
389
|
-
* @param sessionId The session id of the connection to close
|
|
390
|
-
*/
|
|
391
|
-
evict(sessionId: string): Promise<void>;
|
|
392
|
-
/**
|
|
393
|
-
* @description Closes all connections to this room, effectively destroying
|
|
394
|
-
* the room
|
|
395
|
-
*/
|
|
396
|
-
evictAll(): Promise<void>;
|
|
397
|
-
/**
|
|
398
|
-
* @description The IORoom will garbage collect occasionally as connections ping/pong the
|
|
399
|
-
* server
|
|
400
|
-
*/
|
|
401
|
-
garbageCollect(): Promise<void>;
|
|
402
|
-
getSize(): number;
|
|
403
|
-
onClose(webSocket: WebSocketType<TPlatform>): (event: AbstractCloseEvent) => Promise<void>;
|
|
404
|
-
onError(webSocket: WebSocketType<TPlatform>): (event: AbstractErrorEvent) => Promise<void>;
|
|
405
|
-
onMessage(webSocket: WebSocketType<TPlatform>): (event: AbstractMessageEvent) => Promise<void>;
|
|
406
|
-
register(webSocket: InferPlatformWebSocketSource<TPlatform>, ...options: keyof InferInitContextType<TPlatform> extends never ? [{
|
|
407
|
-
token?: string;
|
|
408
|
-
}?] : [WebSocketRegisterConfig<TPlatform>]): Promise<void>;
|
|
409
|
-
private _addUserSession;
|
|
410
|
-
private _broadcast;
|
|
411
|
-
private _closeWebSockets;
|
|
412
|
-
private _emitQuitters;
|
|
413
|
-
private _emitRegistered;
|
|
414
|
-
private _emitSyncState;
|
|
415
|
-
private _ensureDetached;
|
|
416
|
-
private _getAbstractWs;
|
|
417
|
-
/**
|
|
418
|
-
* TODO
|
|
419
|
-
* @description Revisit any cast types
|
|
420
|
-
* @date July 17, 2025
|
|
421
|
-
*/
|
|
422
|
-
private _getAuthorizedUser;
|
|
423
|
-
private _getContext;
|
|
424
|
-
private _getInitialDoc;
|
|
425
|
-
private _getIOAuthorize;
|
|
426
|
-
private _getLatestPresence;
|
|
427
|
-
private _getProcedure;
|
|
428
|
-
private _getProcedureInputs;
|
|
429
|
-
private _getSession;
|
|
430
|
-
private _getSessions;
|
|
431
|
-
private _initialize;
|
|
432
|
-
private _logDebug;
|
|
433
|
-
private _onClose;
|
|
434
|
-
private _onMessage;
|
|
435
|
-
private _parseMessage;
|
|
436
|
-
private _setPresence;
|
|
437
|
-
private _removeUserSession;
|
|
438
|
-
private _sendMessage;
|
|
439
|
-
private _sendBroadcastMessage;
|
|
440
|
-
private _sendSelfMessage;
|
|
441
|
-
private _sendSyncMessage;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
type InferIORoom<TServer extends PluvServer<any, any, any, any, any>> = TServer extends PluvServer<infer IPlatform, infer IAuthorize, infer IContext, infer ICrdt, infer IEvents> ? IORoom<IPlatform, IAuthorize, IContext, ICrdt, IEvents> : never;
|
|
445
|
-
type PluvServerConfig<TPlatform extends AbstractPlatform<any, any> = AbstractPlatform<any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
446
|
-
authorize?: TAuthorize;
|
|
447
|
-
context?: PluvContext<TPlatform, TContext>;
|
|
448
|
-
crdt?: {
|
|
449
|
-
doc: (value: any) => AbstractCrdtDocFactory<any, any>;
|
|
450
|
-
};
|
|
451
|
-
debug?: boolean;
|
|
452
|
-
limits: PluvIOLimits;
|
|
453
|
-
io: PluvIO<TPlatform, TAuthorize, TContext>;
|
|
454
|
-
platform: () => TPlatform;
|
|
455
|
-
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
456
|
-
} & (TCrdt extends CrdtLibraryType$1<NoopCrdtDocFactory> ? {
|
|
457
|
-
getInitialStorage?: "[ERROR]: Must specify crdt to use getInitialStorage";
|
|
458
|
-
} : {
|
|
459
|
-
getInitialStorage: GetInitialStorageFn<TContext>;
|
|
460
|
-
});
|
|
461
|
-
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>> & {
|
|
462
|
-
debug?: boolean;
|
|
463
|
-
};
|
|
464
|
-
type CreateRoomOptions<TPlatform extends AbstractPlatform<any, any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [
|
|
465
|
-
Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>
|
|
466
|
-
];
|
|
467
|
-
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> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TCrdt, TEvents> {
|
|
468
|
-
readonly version: string;
|
|
469
|
-
private readonly _config;
|
|
470
|
-
private readonly _docFactory;
|
|
471
|
-
get fetch(): (...args: any[]) => Promise<any>;
|
|
472
|
-
/**
|
|
473
|
-
* @ignore
|
|
474
|
-
* @readonly
|
|
475
|
-
* @deprecated Internal use only. Changes to this will never be marked as breaking.
|
|
476
|
-
*/
|
|
477
|
-
get _defs(): {
|
|
478
|
-
authorize: TAuthorize;
|
|
479
|
-
context: PluvContext<TPlatform, TContext>;
|
|
480
|
-
crdt: TCrdt;
|
|
481
|
-
events: TEvents;
|
|
482
|
-
platform: TPlatform;
|
|
483
|
-
};
|
|
484
|
-
private get _baseRouter();
|
|
485
|
-
private get _procedure();
|
|
486
|
-
private get _router();
|
|
487
|
-
constructor(options: PluvServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>);
|
|
488
|
-
createRoom(room: string, ...options: CreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>): IORoom<TPlatform, TAuthorize, TContext, TCrdt, TEvents>;
|
|
489
|
-
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<InferIOAuthorize<this>>, TPlatform>): Promise<string>;
|
|
490
|
-
private _getInitialStorage;
|
|
491
|
-
private _getListeners;
|
|
492
|
-
private _logDebug;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, InferInitContextType<TPlatform>> | null, TContext extends Record<string, any>, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<any>> = {
|
|
496
|
-
authorize?: TAuthorize;
|
|
497
|
-
context?: PluvContext<TPlatform, TContext>;
|
|
498
|
-
crdt?: TCrdt;
|
|
499
|
-
debug?: boolean;
|
|
500
|
-
limits?: PluvIOLimits;
|
|
501
|
-
platform: () => TPlatform;
|
|
502
|
-
};
|
|
503
|
-
type ResolvedServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & PluvIORouter<TPlatform, TAuthorize, TContext, TEvents> & (TCrdt extends CrdtLibraryType$1<NoopCrdtDocFactory> ? {
|
|
504
|
-
getInitialStorage?: "[ERROR]: Must specify crdt to use getInitialStorage";
|
|
505
|
-
} : {
|
|
506
|
-
getInitialStorage: GetInitialStorageFn<TContext>;
|
|
507
|
-
});
|
|
508
|
-
type BaseServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
|
|
509
|
-
[P in keyof ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents> as ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P] extends undefined ? never : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P];
|
|
510
|
-
};
|
|
511
|
-
type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = HasRequiredProperty<BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>> extends true ? [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>] : [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>?];
|
|
512
|
-
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<any>> {
|
|
513
|
-
readonly version: string;
|
|
514
|
-
private readonly _authorize;
|
|
515
|
-
private readonly _context;
|
|
516
|
-
private readonly _crdt;
|
|
517
|
-
private readonly _debug;
|
|
518
|
-
private readonly _limits;
|
|
519
|
-
private readonly _platform;
|
|
520
|
-
get procedure(): PluvProcedure<TPlatform, TAuthorize, TContext, {}, {}>;
|
|
521
|
-
constructor(options: PluvIOConfig<TPlatform, TAuthorize, TContext, TCrdt>);
|
|
522
|
-
createToken(params: JWTEncodeParams<InferIOAuthorizeUser<TAuthorize>, TPlatform>): Promise<string>;
|
|
523
|
-
mergeRouters<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
|
|
524
|
-
router<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>>(events: TEvents): PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
525
|
-
server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}>(...config: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>): PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents>;
|
|
526
|
-
private _getIOAuthorize;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>> = {
|
|
530
|
-
authorize?: PluvIOAuthorize<TPlatform, TUser, InferInitContextType<TPlatform>>;
|
|
531
|
-
context?: PluvContext<TPlatform, TContext>;
|
|
532
|
-
crdt?: TCrdt;
|
|
533
|
-
debug?: boolean;
|
|
534
|
-
limits?: PluvIOLimits;
|
|
535
|
-
platform: () => TPlatform;
|
|
536
|
-
};
|
|
537
|
-
declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TContext extends Record<string, any> = {}, TUser extends BaseUser | null = null, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>>(params: CreateIOParams<TPlatform, TContext, TUser, TCrdt>) => PluvIO<TPlatform, PluvIOAuthorize<TPlatform, TUser, InferInitContextType<TPlatform>>, TContext, TCrdt>;
|
|
538
|
-
|
|
539
|
-
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 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 PluvIOLimits, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
|