multichat-ts 0.0.85 → 0.0.87
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/dist/default/kick.d.ts +6 -0
- package/dist/default/kick.js +32 -3
- package/dist/worker/kick.d.ts +6 -0
- package/dist/worker/kick.js +32 -3
- package/package.json +1 -1
- package/src/default/kick.ts +38 -10
- package/src/worker/kick.ts +38 -10
package/dist/default/kick.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import Pusher from 'pusher-js';
|
|
2
2
|
import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index.js';
|
|
3
|
+
type ConnectionState = 'initialized' | 'connecting' | 'connected' | 'unavailable' | 'failed';
|
|
4
|
+
type ConnectionStateEvent = {
|
|
5
|
+
previous: ConnectionState;
|
|
6
|
+
current: ConnectionState;
|
|
7
|
+
};
|
|
3
8
|
type EventCallbackFunctions = {
|
|
4
9
|
message: (message: Message) => unknown;
|
|
5
10
|
subscription: (data: ChatSubscriptionEvent) => unknown;
|
|
6
11
|
gifted: (data: ChatGiftedEvent) => unknown;
|
|
7
12
|
raw_message: (message: ChatMessageEvent) => unknown;
|
|
13
|
+
connection_state_changed: (state: ConnectionStateEvent) => unknown;
|
|
8
14
|
};
|
|
9
15
|
type EventNames = keyof EventCallbackFunctions;
|
|
10
16
|
export declare class KickPusher {
|
package/dist/default/kick.js
CHANGED
|
@@ -67,10 +67,39 @@ export class KickPusher {
|
|
|
67
67
|
});
|
|
68
68
|
this.socket
|
|
69
69
|
.subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
|
|
70
|
-
.bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess())
|
|
70
|
+
.bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess('pusher:subscription_succeeded'))
|
|
71
71
|
.bind('App\\Events\\ChatMessageEvent', (data) => this.onChatMessage(data))
|
|
72
72
|
.bind('App\\Events\\SubscriptionEvent', (data) => this.onChatSubscription(data))
|
|
73
73
|
.bind('App\\Events\\GiftedSubscriptionsEvent', (data) => this.onChatGifted(data));
|
|
74
|
+
this.socket.connection.bind('state_change', (state) => {
|
|
75
|
+
switch (state.current) {
|
|
76
|
+
case 'connected': {
|
|
77
|
+
this.isConnected = true;
|
|
78
|
+
console.log(`Connected to Kick Pusher (${this.channel_name})!`);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'connecting': {
|
|
82
|
+
this.isConnected = false;
|
|
83
|
+
console.log(`Connecting to Kick Pusher (${this.channel_name})...`);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'failed': {
|
|
87
|
+
this.isConnected = false;
|
|
88
|
+
console.log(`Failed to connect to Kick Pusher (${this.channel_name})`);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'unavailable': {
|
|
92
|
+
this.isConnected = false;
|
|
93
|
+
console.log(`Disconnected from Kick Pusher (${this.channel_name})`);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default: {
|
|
97
|
+
this.isConnected = false;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.public_listeners.connection_state_changed?.(state);
|
|
102
|
+
});
|
|
74
103
|
}
|
|
75
104
|
disconnect() {
|
|
76
105
|
this.socket?.disconnect();
|
|
@@ -79,8 +108,8 @@ export class KickPusher {
|
|
|
79
108
|
on(event_name, callback_fn) {
|
|
80
109
|
this.public_listeners[event_name] = callback_fn;
|
|
81
110
|
}
|
|
82
|
-
onSubscriptionSuccess() {
|
|
83
|
-
console.log(`
|
|
111
|
+
onSubscriptionSuccess(channel) {
|
|
112
|
+
console.log(`Subscribed to Channel on Kick Pusher (${channel})`);
|
|
84
113
|
}
|
|
85
114
|
onChatSubscription(data) {
|
|
86
115
|
this.public_listeners.subscription?.(data);
|
package/dist/worker/kick.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import Pusher from 'pusher-js/worker';
|
|
2
2
|
import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index.js';
|
|
3
|
+
type ConnectionState = 'initialized' | 'connecting' | 'connected' | 'unavailable' | 'failed';
|
|
4
|
+
type ConnectionStateEvent = {
|
|
5
|
+
previous: ConnectionState;
|
|
6
|
+
current: ConnectionState;
|
|
7
|
+
};
|
|
3
8
|
type EventCallbackFunctions = {
|
|
4
9
|
message: (message: Message) => unknown;
|
|
5
10
|
subscription: (data: ChatSubscriptionEvent) => unknown;
|
|
6
11
|
gifted: (data: ChatGiftedEvent) => unknown;
|
|
7
12
|
raw_message: (message: ChatMessageEvent) => unknown;
|
|
13
|
+
connection_state_changed: (state: ConnectionStateEvent) => unknown;
|
|
8
14
|
};
|
|
9
15
|
type EventNames = keyof EventCallbackFunctions;
|
|
10
16
|
export declare class KickPusher {
|
package/dist/worker/kick.js
CHANGED
|
@@ -67,10 +67,39 @@ export class KickPusher {
|
|
|
67
67
|
});
|
|
68
68
|
this.socket
|
|
69
69
|
.subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
|
|
70
|
-
.bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess())
|
|
70
|
+
.bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess('pusher:subscription_succeeded'))
|
|
71
71
|
.bind('App\\Events\\ChatMessageEvent', (data) => this.onChatMessage(data))
|
|
72
72
|
.bind('App\\Events\\SubscriptionEvent', (data) => this.onChatSubscription(data))
|
|
73
73
|
.bind('App\\Events\\GiftedSubscriptionsEvent', (data) => this.onChatGifted(data));
|
|
74
|
+
this.socket.connection.bind('state_change', (state) => {
|
|
75
|
+
switch (state.current) {
|
|
76
|
+
case 'connected': {
|
|
77
|
+
this.isConnected = true;
|
|
78
|
+
console.log(`Connected to Kick Pusher (${this.channel_name})!`);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'connecting': {
|
|
82
|
+
this.isConnected = false;
|
|
83
|
+
console.log(`Connecting to Kick Pusher (${this.channel_name})...`);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'failed': {
|
|
87
|
+
this.isConnected = false;
|
|
88
|
+
console.log(`Failed to connect to Kick Pusher (${this.channel_name})`);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'unavailable': {
|
|
92
|
+
this.isConnected = false;
|
|
93
|
+
console.log(`Disconnected from Kick Pusher (${this.channel_name})`);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default: {
|
|
97
|
+
this.isConnected = false;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.public_listeners.connection_state_changed?.(state);
|
|
102
|
+
});
|
|
74
103
|
}
|
|
75
104
|
disconnect() {
|
|
76
105
|
this.socket?.disconnect();
|
|
@@ -79,8 +108,8 @@ export class KickPusher {
|
|
|
79
108
|
on(event_name, callback_fn) {
|
|
80
109
|
this.public_listeners[event_name] = callback_fn;
|
|
81
110
|
}
|
|
82
|
-
onSubscriptionSuccess() {
|
|
83
|
-
console.log(`
|
|
111
|
+
onSubscriptionSuccess(channel) {
|
|
112
|
+
console.log(`Subscribed to Channel on Kick Pusher (${channel})`);
|
|
84
113
|
}
|
|
85
114
|
onChatSubscription(data) {
|
|
86
115
|
this.public_listeners.subscription?.(data);
|
package/package.json
CHANGED
package/src/default/kick.ts
CHANGED
|
@@ -7,11 +7,15 @@ import {
|
|
|
7
7
|
type Message,
|
|
8
8
|
} from './index.js';
|
|
9
9
|
|
|
10
|
+
type ConnectionState = 'initialized' | 'connecting' | 'connected' | 'unavailable' | 'failed';
|
|
11
|
+
type ConnectionStateEvent = { previous: ConnectionState; current: ConnectionState };
|
|
12
|
+
|
|
10
13
|
type EventCallbackFunctions = {
|
|
11
14
|
message: (message: Message) => unknown;
|
|
12
15
|
subscription: (data: ChatSubscriptionEvent) => unknown;
|
|
13
16
|
gifted: (data: ChatGiftedEvent) => unknown;
|
|
14
17
|
raw_message: (message: ChatMessageEvent) => unknown;
|
|
18
|
+
connection_state_changed: (state: ConnectionStateEvent) => unknown;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
type EventNames = keyof EventCallbackFunctions;
|
|
@@ -119,7 +123,9 @@ export class KickPusher {
|
|
|
119
123
|
*/
|
|
120
124
|
this.socket
|
|
121
125
|
.subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
|
|
122
|
-
.bind('pusher:subscription_succeeded', () =>
|
|
126
|
+
.bind('pusher:subscription_succeeded', () =>
|
|
127
|
+
this.onSubscriptionSuccess('pusher:subscription_succeeded'),
|
|
128
|
+
)
|
|
123
129
|
.bind('App\\Events\\ChatMessageEvent', (data: ChatMessageEvent) => this.onChatMessage(data))
|
|
124
130
|
.bind('App\\Events\\SubscriptionEvent', (data: ChatSubscriptionEvent) =>
|
|
125
131
|
this.onChatSubscription(data),
|
|
@@ -128,13 +134,35 @@ export class KickPusher {
|
|
|
128
134
|
this.onChatGifted(data),
|
|
129
135
|
);
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
this.socket.connection.bind('state_change', (state: ConnectionStateEvent) => {
|
|
138
|
+
switch (state.current) {
|
|
139
|
+
case 'connected': {
|
|
140
|
+
this.isConnected = true;
|
|
141
|
+
console.log(`Connected to Kick Pusher (${this.channel_name})!`);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'connecting': {
|
|
145
|
+
this.isConnected = false;
|
|
146
|
+
console.log(`Connecting to Kick Pusher (${this.channel_name})...`);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case 'failed': {
|
|
150
|
+
this.isConnected = false;
|
|
151
|
+
console.log(`Failed to connect to Kick Pusher (${this.channel_name})`);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case 'unavailable': {
|
|
155
|
+
this.isConnected = false;
|
|
156
|
+
console.log(`Disconnected from Kick Pusher (${this.channel_name})`);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
default: {
|
|
160
|
+
this.isConnected = false;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
this.public_listeners.connection_state_changed?.(state);
|
|
165
|
+
});
|
|
138
166
|
}
|
|
139
167
|
|
|
140
168
|
public disconnect() {
|
|
@@ -149,8 +177,8 @@ export class KickPusher {
|
|
|
149
177
|
this.public_listeners[event_name] = callback_fn;
|
|
150
178
|
}
|
|
151
179
|
|
|
152
|
-
private onSubscriptionSuccess() {
|
|
153
|
-
console.log(`
|
|
180
|
+
private onSubscriptionSuccess(channel: string) {
|
|
181
|
+
console.log(`Subscribed to Channel on Kick Pusher (${channel})`);
|
|
154
182
|
}
|
|
155
183
|
|
|
156
184
|
private onChatSubscription(data: ChatSubscriptionEvent) {
|
package/src/worker/kick.ts
CHANGED
|
@@ -7,11 +7,15 @@ import {
|
|
|
7
7
|
type Message,
|
|
8
8
|
} from './index.js';
|
|
9
9
|
|
|
10
|
+
type ConnectionState = 'initialized' | 'connecting' | 'connected' | 'unavailable' | 'failed';
|
|
11
|
+
type ConnectionStateEvent = { previous: ConnectionState; current: ConnectionState };
|
|
12
|
+
|
|
10
13
|
type EventCallbackFunctions = {
|
|
11
14
|
message: (message: Message) => unknown;
|
|
12
15
|
subscription: (data: ChatSubscriptionEvent) => unknown;
|
|
13
16
|
gifted: (data: ChatGiftedEvent) => unknown;
|
|
14
17
|
raw_message: (message: ChatMessageEvent) => unknown;
|
|
18
|
+
connection_state_changed: (state: ConnectionStateEvent) => unknown;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
type EventNames = keyof EventCallbackFunctions;
|
|
@@ -119,7 +123,9 @@ export class KickPusher {
|
|
|
119
123
|
*/
|
|
120
124
|
this.socket
|
|
121
125
|
.subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
|
|
122
|
-
.bind('pusher:subscription_succeeded', () =>
|
|
126
|
+
.bind('pusher:subscription_succeeded', () =>
|
|
127
|
+
this.onSubscriptionSuccess('pusher:subscription_succeeded'),
|
|
128
|
+
)
|
|
123
129
|
.bind('App\\Events\\ChatMessageEvent', (data: ChatMessageEvent) => this.onChatMessage(data))
|
|
124
130
|
.bind('App\\Events\\SubscriptionEvent', (data: ChatSubscriptionEvent) =>
|
|
125
131
|
this.onChatSubscription(data),
|
|
@@ -128,13 +134,35 @@ export class KickPusher {
|
|
|
128
134
|
this.onChatGifted(data),
|
|
129
135
|
);
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
this.socket.connection.bind('state_change', (state: ConnectionStateEvent) => {
|
|
138
|
+
switch (state.current) {
|
|
139
|
+
case 'connected': {
|
|
140
|
+
this.isConnected = true;
|
|
141
|
+
console.log(`Connected to Kick Pusher (${this.channel_name})!`);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'connecting': {
|
|
145
|
+
this.isConnected = false;
|
|
146
|
+
console.log(`Connecting to Kick Pusher (${this.channel_name})...`);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case 'failed': {
|
|
150
|
+
this.isConnected = false;
|
|
151
|
+
console.log(`Failed to connect to Kick Pusher (${this.channel_name})`);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case 'unavailable': {
|
|
155
|
+
this.isConnected = false;
|
|
156
|
+
console.log(`Disconnected from Kick Pusher (${this.channel_name})`);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
default: {
|
|
160
|
+
this.isConnected = false;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
this.public_listeners.connection_state_changed?.(state);
|
|
165
|
+
});
|
|
138
166
|
}
|
|
139
167
|
|
|
140
168
|
public disconnect() {
|
|
@@ -149,8 +177,8 @@ export class KickPusher {
|
|
|
149
177
|
this.public_listeners[event_name] = callback_fn;
|
|
150
178
|
}
|
|
151
179
|
|
|
152
|
-
private onSubscriptionSuccess() {
|
|
153
|
-
console.log(`
|
|
180
|
+
private onSubscriptionSuccess(channel: string) {
|
|
181
|
+
console.log(`Subscribed to Channel on Kick Pusher (${channel})`);
|
|
154
182
|
}
|
|
155
183
|
|
|
156
184
|
private onChatSubscription(data: ChatSubscriptionEvent) {
|