@eleven-am/pondsocket-client 0.0.2 → 0.0.3

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.
@@ -1,5 +1,5 @@
1
+ import { JoinParams } from '@eleven-am/pondsocket-common';
1
2
  import { Channel } from '../core/channel';
2
- import { JoinParams } from '../types';
3
3
 
4
4
  export default class PondClient {
5
5
  constructor (endpoint: string, params?: Record<string, any>);
@@ -24,7 +24,7 @@ export default class PondClient {
24
24
  * @param name - The name of the channel.
25
25
  * @param params - The params to send to the server.
26
26
  */
27
- createChannel (name: string, params?: JoinParams): Channel<import('../types').PondEventMap>;
27
+ createChannel (name: string, params?: JoinParams): Channel<import('@eleven-am/pondsocket-common').PondEventMap>;
28
28
 
29
29
  /**
30
30
  * @desc Subscribes to the connection state.
package/core/channel.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ChannelState } from '@eleven-am/pondsocket-common';
2
1
  import {
2
+ ChannelState,
3
3
  PondPresence,
4
4
  PondMessage,
5
5
  PresencePayload,
@@ -7,7 +7,7 @@ import {
7
7
  EventWithResponse,
8
8
  PayloadForResponse,
9
9
  ResponseForEvent,
10
- } from '../types';
10
+ } from '@eleven-am/pondsocket-common';
11
11
 
12
12
  export declare class Channel<EventMap extends PondEventMap = PondEventMap> {
13
13
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket-client",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -28,7 +28,7 @@
28
28
  "pipeline": "npm run lint && npm run test && npm run build && npm run push"
29
29
  },
30
30
  "dependencies": {
31
- "@eleven-am/pondsocket-common": "^0.0.5",
31
+ "@eleven-am/pondsocket-common": "^0.0.6",
32
32
  "websocket": "^1.0.34",
33
33
  "zod": "^3.22.4"
34
34
  },
package/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { ChannelReceiver, PresenceEventTypes, ClientActions } from '@eleven-am/pondsocket-common';
2
- export type Unsubscribe = () => void;
1
+ import { ChannelReceivers, ClientActions, PondMessage } from '@eleven-am/pondsocket-common';
3
2
  export interface ClientMessage {
4
3
  addresses: ChannelReceivers | string[];
5
4
  action: ClientActions;
@@ -8,47 +7,4 @@ export interface ClientMessage {
8
7
  channelName: string;
9
8
  requestId: string;
10
9
  }
11
- type Primitives = number | string | boolean | null | undefined;
12
- type PondObject = {
13
- [key: string]: Primitives | PondObject | PondObject[];
14
- };
15
- export type PondPresence = PondObject;
16
- export type PondMessage = PondObject;
17
- export type PondAssigns = PondObject;
18
- export type JoinParams = PondObject;
19
- export interface PresencePayload extends PondObject {
20
- changed: PondPresence;
21
- presence: PondPresence[];
22
- }
23
- export interface UserPresences {
24
- [userId: string]: PondPresence;
25
- }
26
- export interface UserAssigns {
27
- [userId: string]: PondAssigns;
28
- }
29
- export type ChannelReceivers = ChannelReceiver | string[];
30
- export interface Event {
31
- action: 'SYSTEM' | 'BROADCAST' | 'ERROR';
32
- event: string;
33
- payload: PondMessage;
34
- channelName: string;
35
- requestId: string;
36
- }
37
- interface PresenceEventMessage {
38
- action: 'PRESENCE';
39
- event: PresenceEventTypes;
40
- channelName: string;
41
- payload: PresencePayload;
42
- requestId: string;
43
- }
44
- export type ChannelEvent = Event | PresenceEventMessage;
45
10
  export type Publisher = (data: ClientMessage) => void;
46
- export type PondEventMap = {
47
- [key: string]: PondMessage | [PondMessage, PondMessage];
48
- };
49
- export type EventWithResponse<EventMap extends PondEventMap> = {
50
- [Event in keyof EventMap]: EventMap[Event] extends [PondMessage, PondMessage] ? Event : never;
51
- }[keyof EventMap];
52
- export type PayloadForResponse<EventMap extends PondEventMap, Event extends EventWithResponse<EventMap>> = EventMap[Event] extends [PondMessage, PondMessage] ? EventMap[Event][0] : never;
53
- export type ResponseForEvent<EventMap extends PondEventMap, Event extends EventWithResponse<EventMap>> = EventMap[Event] extends [PondMessage, PondMessage] ? EventMap[Event][1] : never;
54
- export {};