@eleven-am/pondsocket-client 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -30,18 +30,6 @@ const endpoint = pond.createEndpoint('/api/socket', (req, res) => {
30
30
 
31
31
  // Start the server
32
32
  pond.listen(3000);
33
-
34
- // Or alternatively, working with express
35
- import pondSocket from "@eleven-am/pondsocket/express";
36
- import express from "express";
37
-
38
- const app = pondSocket(express());
39
-
40
- const endpoint = app.upgrade('/api/socket', (req, res) => {
41
- // Handle socket connection and authentication
42
- });
43
-
44
- app.listen(3000);
45
33
  ```
46
34
 
47
35
  Within each endpoint, sockets interact through channels. Channels provide an organized way to group users and manage efficient communication among them. When users join a channel, they can participate in real-time events and exchange information with other users in the same channel.
@@ -1,15 +1,23 @@
1
1
  import {
2
- ChannelState,
2
+ PondEventMap,
3
+ JoinParams,
3
4
  PondPresence,
4
- PondMessage,
5
5
  PresencePayload,
6
- PondEventMap,
6
+ PondMessage,
7
7
  EventWithResponse,
8
8
  PayloadForResponse,
9
- ResponseForEvent,
9
+ ResponseForEvent, Unsubscribe,
10
10
  } from '@eleven-am/pondsocket-common';
11
11
 
12
- export declare class Channel<EventMap extends PondEventMap = PondEventMap> {
12
+ export enum ChannelState {
13
+ IDLE = 'IDLE',
14
+ JOINING = 'JOINING',
15
+ JOINED = 'JOINED',
16
+ STALLED = 'STALLED',
17
+ CLOSED = 'CLOSED',
18
+ }
19
+
20
+ declare class Channel<EventMap extends PondEventMap = PondEventMap> {
13
21
  /**
14
22
  * @desc Gets the current connection state of the channel.
15
23
  */
@@ -100,7 +108,7 @@ export declare class Channel<EventMap extends PondEventMap = PondEventMap> {
100
108
  * @desc Monitors the presence of the channel.
101
109
  * @param callback - The callback to call when the presence changes.
102
110
  */
103
- onUsersChange (callback: (users: PondPresence[]) => void): import('@eleven-am/pondsocket-common/subjects/types').Unsubscribe;
111
+ onUsersChange (callback: (users: PondPresence[]) => void): Unsubscribe;
104
112
 
105
113
  /**
106
114
  * @desc Checks if the channel is connected.
@@ -121,5 +129,37 @@ export declare class Channel<EventMap extends PondEventMap = PondEventMap> {
121
129
  * @desc Monitors the connection state of the channel.
122
130
  * @param callback - The callback to call when the connection state changes.
123
131
  */
124
- onConnectionChange (callback: (connected: boolean) => void): import('@eleven-am/pondsocket-common/subjects/types').Unsubscribe;
132
+ onConnectionChange (callback: (connected: boolean) => void): Unsubscribe;
133
+ }
134
+
135
+ declare class PondClient {
136
+ constructor (endpoint: string, params?: Record<string, any>);
137
+
138
+ /**
139
+ * @desc Connects to the server and returns the socket.
140
+ */
141
+ connect (backoff?: number): void;
142
+
143
+ /**
144
+ * @desc Returns the current state of the socket.
145
+ */
146
+ getState (): boolean;
147
+
148
+ /**
149
+ * @desc Disconnects the socket.
150
+ */
151
+ disconnect (): void;
152
+
153
+ /**
154
+ * @desc Creates a channel with the given name and params.
155
+ * @param name - The name of the channel.
156
+ * @param params - The params to send to the server.
157
+ */
158
+ createChannel<EventType extends PondEventMap = PondEventMap> (name: string, params?: JoinParams): Channel<EventType>;
159
+
160
+ /**
161
+ * @desc Subscribes to the connection state.
162
+ * @param callback - The callback to call when the state changes.
163
+ */
164
+ onConnectionChange (callback: (state: boolean) => void): Unsubscribe;
125
165
  }
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { default as BrowserClient } from './browser/client';
2
- declare const _default: typeof BrowserClient;
3
- export default _default;
1
+ import { PondClient } from './dist';
2
+
3
+ export default PondClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket-client",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -24,9 +24,9 @@
24
24
  "build": "rimraf dist && tsc",
25
25
  "lint": "eslint --ext .ts src",
26
26
  "lint:fix": "eslint --fix --ext .ts src",
27
- "copy": "cp package.json dist && cp README.md dist && cp LICENSE dist",
27
+ "copy": "cp package.json dist && cp README.md dist && cp LICENSE dist && cp src/index.d.ts dist && cp src/dist.d.ts dist",
28
28
  "push": "npm version patch && npm run copy && cd dist && npm publish && cd ..",
29
- "pipeline": "npm run lint && npm run test && npm run build && npm run push"
29
+ "pipeline": "npm run test && npm run build && npm run push"
30
30
  },
31
31
  "dependencies": {
32
32
  "@eleven-am/pondsocket-common": "^0.0.6",
@@ -1,34 +0,0 @@
1
- import { JoinParams } from '@eleven-am/pondsocket-common';
2
- import { Channel } from '../core/channel';
3
-
4
- export default class PondClient {
5
- constructor (endpoint: string, params?: Record<string, any>);
6
-
7
- /**
8
- * @desc Connects to the server and returns the socket.
9
- */
10
- connect (backoff?: number): void;
11
-
12
- /**
13
- * @desc Returns the current state of the socket.
14
- */
15
- getState (): boolean;
16
-
17
- /**
18
- * @desc Disconnects the socket.
19
- */
20
- disconnect (): void;
21
-
22
- /**
23
- * @desc Creates a channel with the given name and params.
24
- * @param name - The name of the channel.
25
- * @param params - The params to send to the server.
26
- */
27
- createChannel (name: string, params?: JoinParams): Channel<import('@eleven-am/pondsocket-common').PondEventMap>;
28
-
29
- /**
30
- * @desc Subscribes to the connection state.
31
- * @param callback - The callback to call when the state changes.
32
- */
33
- onConnectionChange (callback: (state: boolean) => void): import('@eleven-am/pondsocket-common/subjects/types').Unsubscribe;
34
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/node/node.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import PondSocketClient from '../browser/client';
2
- export default class PondClient extends PondSocketClient {
3
- /**
4
- * @desc Connects to the server and returns the socket.
5
- */
6
- connect(backoff?: number): void;
7
- }
package/types.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { ChannelReceivers, ClientActions, PondMessage } from '@eleven-am/pondsocket-common';
2
- export interface ClientMessage {
3
- addresses: ChannelReceivers | string[];
4
- action: ClientActions;
5
- event: string;
6
- payload: PondMessage;
7
- channelName: string;
8
- requestId: string;
9
- }
10
- export type Publisher = (data: ClientMessage) => void;