@eleven-am/pondsocket 0.1.63 → 0.1.64
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/package.json +1 -1
- package/types.d.ts +15 -6
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { WebSocketServer } from 'ws';
|
|
|
4
4
|
|
|
5
5
|
type Unsubscribe = () => void;
|
|
6
6
|
|
|
7
|
+
export type default_t<T = any> = Record<string, T>;
|
|
7
8
|
type IsParam<Path> = Path extends `:${infer Param}` ? Param : never;
|
|
8
9
|
|
|
9
10
|
type FilteredParams<Path> = Path extends `${infer First}/${infer Second}`
|
|
@@ -21,12 +22,7 @@ type EventParams<Path> = {
|
|
|
21
22
|
params: Params<Path>;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
type PondObject = {
|
|
27
|
-
[key: string]: Primitives | PondObject | PondObject[];
|
|
28
|
-
}
|
|
29
|
-
|
|
25
|
+
type PondObject = default_t;
|
|
30
26
|
type PondPresence = PondObject;
|
|
31
27
|
type PondMessage = PondObject;
|
|
32
28
|
type PondAssigns = PondObject;
|
|
@@ -56,6 +52,13 @@ type IncomingConnection<Path> = EventParams<Path> & {
|
|
|
56
52
|
address: string;
|
|
57
53
|
}
|
|
58
54
|
|
|
55
|
+
interface LeaveEvent {
|
|
56
|
+
userId: string;
|
|
57
|
+
assigns: PondAssigns;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type LeaveCallback = (event: LeaveEvent) => void;
|
|
61
|
+
|
|
59
62
|
interface UserData {
|
|
60
63
|
assigns: PondAssigns;
|
|
61
64
|
presence: PondPresence;
|
|
@@ -479,6 +482,12 @@ export declare class PondChannel {
|
|
|
479
482
|
*});
|
|
480
483
|
*/
|
|
481
484
|
broadcast (event: string, payload: PondMessage, channelName?: string): void;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @desc Handles the leave event for a user, can occur when a user disconnects or leaves a channel, use this to clean up any resources
|
|
488
|
+
* @param callback - The callback to execute when a user leaves
|
|
489
|
+
*/
|
|
490
|
+
public onLeave (callback: LeaveCallback): void;
|
|
482
491
|
}
|
|
483
492
|
|
|
484
493
|
declare class PondSocket {
|