@eleven-am/pondsocket 0.1.52 → 0.1.53

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types.d.ts +25 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
package/types.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Express } from 'express';
2
2
  import { Server as HTTPServer, IncomingHttpHeaders } from 'http';
3
3
  import { WebSocketServer } from 'ws';
4
4
 
5
- export type Unsubscribe = () => void;
5
+ type Unsubscribe = () => void;
6
6
 
7
7
  type IsParam<Path> = Path extends `:${infer Param}` ? Param : never;
8
8
 
@@ -10,13 +10,13 @@ type FilteredParams<Path> = Path extends `${infer First}/${infer Second}`
10
10
  ? IsParam<First> | FilteredParams<Second>
11
11
  : IsParam<Path>
12
12
 
13
- export type Params<Path> = {
13
+ type Params<Path> = {
14
14
  [Key in FilteredParams<Path>]: string
15
15
  }
16
16
 
17
- export type PondPath<Path extends string> = Path | RegExp;
17
+ type PondPath<Path extends string> = Path | RegExp;
18
18
 
19
- export type EventParams<Path> = {
19
+ type EventParams<Path> = {
20
20
  query: Record<string, string>;
21
21
  params: Params<Path>;
22
22
  }
@@ -27,36 +27,36 @@ type PondObject = {
27
27
  [key: string]: Primitives | PondObject | PondObject[];
28
28
  }
29
29
 
30
- export type PondPresence = PondObject;
31
- export type PondMessage = PondObject;
32
- export type PondAssigns = PondObject;
33
- export type JoinParams = PondObject;
30
+ type PondPresence = PondObject;
31
+ type PondMessage = PondObject;
32
+ type PondAssigns = PondObject;
33
+ type JoinParams = PondObject;
34
34
 
35
- export interface PresencePayload {
35
+ interface PresencePayload {
36
36
  changed: PondPresence;
37
37
  presence: PondPresence[];
38
38
  }
39
39
 
40
- export interface UserPresences {
40
+ interface UserPresences {
41
41
  [userId: string]: PondPresence;
42
42
  }
43
43
 
44
- export interface UserAssigns {
44
+ interface UserAssigns {
45
45
  [userId: string]: PondAssigns;
46
46
  }
47
47
 
48
- export type PondEvent<Path> = EventParams<Path> & {
48
+ type PondEvent<Path> = EventParams<Path> & {
49
49
  payload: PondMessage;
50
50
  event: string;
51
51
  }
52
52
 
53
- export type IncomingConnection<Path> = EventParams<Path> & {
53
+ type IncomingConnection<Path> = EventParams<Path> & {
54
54
  id: string;
55
55
  headers: IncomingHttpHeaders;
56
56
  address: string;
57
57
  }
58
58
 
59
- export interface UserData {
59
+ interface UserData {
60
60
  assigns: PondAssigns;
61
61
  presence: PondPresence;
62
62
  id: string;
@@ -70,7 +70,7 @@ export enum ChannelState {
70
70
  CLOSED = 'CLOSED',
71
71
  }
72
72
 
73
- export declare class AbstractRequest<Path extends string> {
73
+ declare class AbstractRequest<Path extends string> {
74
74
  event: PondEvent<Path>;
75
75
 
76
76
  channelNme: string;
@@ -80,7 +80,7 @@ export declare class AbstractRequest<Path extends string> {
80
80
  presence: UserPresences;
81
81
  }
82
82
 
83
- export declare abstract class PondResponse {
83
+ declare abstract class PondResponse {
84
84
  /**
85
85
  * @desc Rejects the request with the given error message
86
86
  * @param message - the error message
@@ -104,11 +104,11 @@ export declare abstract class PondResponse {
104
104
  abstract accept (assigns?: PondAssigns): void;
105
105
  }
106
106
 
107
- export declare class EventRequest<Path extends string> extends AbstractRequest<Path> {
107
+ declare class EventRequest<Path extends string> extends AbstractRequest<Path> {
108
108
  user: UserData;
109
109
  }
110
110
 
111
- export declare class EventResponse extends PondResponse {
111
+ declare class EventResponse extends PondResponse {
112
112
  /**
113
113
  * @desc Accepts the request and optionally assigns data to the client
114
114
  * @param assigns - the data to assign to the client
@@ -191,7 +191,7 @@ export declare class Channel {
191
191
  /**
192
192
  * @desc Gets the current connection state of the channel.
193
193
  */
194
- get channelState (): ChannelState;
194
+ channelState: ChannelState;
195
195
 
196
196
  /**
197
197
  * @desc Connects to the channel.
@@ -285,7 +285,7 @@ export declare class Channel {
285
285
  onConnectionChange (callback: (connected: boolean) => void): Unsubscribe;
286
286
  }
287
287
 
288
- export declare class Endpoint {
288
+ declare class Endpoint {
289
289
  /**
290
290
  * @desc Adds a new PondChannel to this path on this endpoint
291
291
  * @param path - The path to add the channel to
@@ -316,13 +316,13 @@ export declare class Endpoint {
316
316
  closeConnection (clientIds: string | string[]): void;
317
317
  }
318
318
 
319
- export declare class JoinRequest<Path extends string> extends AbstractRequest<Path> {
319
+ declare class JoinRequest<Path extends string> extends AbstractRequest<Path> {
320
320
  joinParams: JoinParams;
321
321
 
322
322
  user: UserData;
323
323
  }
324
324
 
325
- export declare class JoinResponse extends PondResponse {
325
+ declare class JoinResponse extends PondResponse {
326
326
  #private;
327
327
 
328
328
  /**
@@ -375,7 +375,7 @@ export declare class JoinResponse extends PondResponse {
375
375
  trackPresence (presence: PondPresence): JoinResponse;
376
376
  }
377
377
 
378
- export declare class ConnectionResponse extends PondResponse {
378
+ declare class ConnectionResponse extends PondResponse {
379
379
  /**
380
380
  * @desc Accepts the request and optionally assigns data to the client
381
381
  * @param assigns - the data to assign to the client
@@ -427,7 +427,7 @@ export declare class PondChannel {
427
427
  broadcast (event: string, payload: PondMessage, channelName?: string): void;
428
428
  }
429
429
 
430
- export declare class PondSocket {
430
+ declare class PondSocket {
431
431
  constructor (server?: HTTPServer, socketServer?: WebSocketServer);
432
432
 
433
433
  /**
@@ -482,7 +482,7 @@ interface PondSocketExpressApp extends Express {
482
482
  upgrade<Path extends string> (path: PondPath<Path>, handler: (request: IncomingConnection<Path>, response: ConnectionResponse) => void | Promise<void>): Endpoint;
483
483
  }
484
484
 
485
- export declare class PondClient {
485
+ declare class PondClient {
486
486
  constructor (endpoint: string, params?: Record<string, any>);
487
487
 
488
488
  /**