@overlaysymphony/twitch 0.1.1 → 0.2.1
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 +1 -1
- package/package.json +15 -17
- package/src/authentication/authentication.ts +110 -54
- package/src/chat/chat.ts +9 -8
- package/src/chat/helpers.ts +36 -0
- package/src/chat/index.ts +1 -0
- package/src/chat/interfaces/events.ts +29 -29
- package/src/chat/interfaces/index.ts +1 -1
- package/src/chat/parser.ts +9 -20
- package/src/eventsub/events/channel.ad_break.begin.ts +1 -1
- package/src/eventsub/events/channel.ban.ts +1 -1
- package/src/eventsub/events/channel.channel_points_custom_reward.add.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward.remove.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward.update.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.add.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.update.ts +2 -2
- package/src/eventsub/events/channel.charity_campaign.donate.ts +1 -1
- package/src/eventsub/events/channel.charity_campaign.progress.ts +1 -1
- package/src/eventsub/events/channel.charity_campaign.start.ts +1 -1
- package/src/eventsub/events/channel.charity_campaign.stop.ts +1 -1
- package/src/eventsub/events/channel.chat.clear.ts +1 -1
- package/src/eventsub/events/channel.chat.clear_user_messages.ts +1 -1
- package/src/eventsub/events/channel.chat.message_delete.ts +1 -1
- package/src/eventsub/events/channel.chat.notification.ts +1 -1
- package/src/eventsub/events/channel.cheer.ts +1 -1
- package/src/eventsub/events/channel.follow.ts +1 -1
- package/src/eventsub/events/channel.goal.begin.ts +1 -1
- package/src/eventsub/events/channel.goal.end.ts +1 -1
- package/src/eventsub/events/channel.goal.progress.ts +1 -1
- package/src/eventsub/events/channel.guest_star_guest.update.ts +1 -1
- package/src/eventsub/events/channel.guest_star_session.begin.ts +1 -1
- package/src/eventsub/events/channel.guest_star_session.end.ts +1 -1
- package/src/eventsub/events/channel.guest_star_settings.update.ts +1 -1
- package/src/eventsub/events/channel.hype_train.begin.ts +2 -2
- package/src/eventsub/events/channel.hype_train.end.ts +2 -2
- package/src/eventsub/events/channel.hype_train.progress.ts +2 -2
- package/src/eventsub/events/channel.moderator.add.ts +1 -1
- package/src/eventsub/events/channel.moderator.remove.ts +1 -1
- package/src/eventsub/events/channel.poll.begin.ts +2 -2
- package/src/eventsub/events/channel.poll.end.ts +2 -2
- package/src/eventsub/events/channel.poll.progress.ts +2 -2
- package/src/eventsub/events/channel.prediction.begin.ts +2 -2
- package/src/eventsub/events/channel.prediction.end.ts +2 -2
- package/src/eventsub/events/channel.prediction.lock.ts +2 -2
- package/src/eventsub/events/channel.prediction.progress.ts +2 -2
- package/src/eventsub/events/channel.raid.ts +1 -1
- package/src/eventsub/events/channel.shield_mode.begin.ts +1 -1
- package/src/eventsub/events/channel.shield_mode.end.ts +1 -1
- package/src/eventsub/events/channel.shoutout.create.ts +1 -1
- package/src/eventsub/events/channel.shoutout.receive.ts +1 -1
- package/src/eventsub/events/channel.subscribe.ts +1 -1
- package/src/eventsub/events/channel.subscription.end.ts +1 -1
- package/src/eventsub/events/channel.subscription.gift.ts +1 -1
- package/src/eventsub/events/channel.subscription.message.ts +1 -1
- package/src/eventsub/events/channel.unban.ts +1 -1
- package/src/eventsub/events/channel.update.ts +1 -1
- package/src/eventsub/events/index.ts +51 -51
- package/src/eventsub/events/stream.offline.ts +1 -1
- package/src/eventsub/events/stream.online.ts +1 -1
- package/src/eventsub/events/user.update.ts +1 -1
- package/src/eventsub/events-helpers.ts +2 -2
- package/src/eventsub/eventsub.ts +9 -10
- package/src/eventsub/messages.ts +1 -1
- package/src/helix/channel-points/custom-rewards.ts +2 -3
- package/src/helix/helix.ts +1 -1
- package/src/helix/subscriptions/subscriptions.ts +9 -19
- package/src/helix/users/users.ts +1 -1
- package/src/helpers/alerts/alerts.ts +3 -3
- package/src/helpers/charity/charity.ts +1 -1
- package/src/helpers/goal/goal.ts +1 -1
- package/src/helpers/hype-train/hype-train.ts +1 -1
- package/src/helpers/poll/poll.ts +17 -3
- package/src/helpers/prediction/prediction.ts +1 -1
- package/src/helpers/redemption/redemption.ts +21 -2
- package/src/helpers/status/status.ts +1 -1
- package/src/ui/authentication.ts +29 -86
- package/src/ui/popup.ts +46 -7
- package/src/ui/vite-env.d.ts +1 -0
package/src/chat/parser.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatEvent, ChatEventSource } from "./interfaces/index.js"
|
|
1
|
+
import { type ChatEvent, type ChatEventSource } from "./interfaces/index.js"
|
|
2
2
|
|
|
3
3
|
// Parses an IRC message and returns a JSON object with the message's
|
|
4
4
|
// component parts (tags, source (nick and host), command, parameters).
|
|
@@ -30,7 +30,7 @@ export default function parseEvent(input: string): ChatEvent | undefined {
|
|
|
30
30
|
|
|
31
31
|
// core
|
|
32
32
|
try {
|
|
33
|
-
const hasParameters = input.
|
|
33
|
+
const hasParameters = input.includes(":", idx)
|
|
34
34
|
if (hasParameters) {
|
|
35
35
|
const endIdx = input.indexOf(":", idx)
|
|
36
36
|
|
|
@@ -42,7 +42,7 @@ export default function parseEvent(input: string): ChatEvent | undefined {
|
|
|
42
42
|
return {
|
|
43
43
|
...message,
|
|
44
44
|
source,
|
|
45
|
-
// @ts-
|
|
45
|
+
// @ts-expect-error: generic objects are complicated
|
|
46
46
|
tags,
|
|
47
47
|
}
|
|
48
48
|
} else {
|
|
@@ -51,11 +51,11 @@ export default function parseEvent(input: string): ChatEvent | undefined {
|
|
|
51
51
|
return {
|
|
52
52
|
...message,
|
|
53
53
|
source,
|
|
54
|
-
// @ts-
|
|
54
|
+
// @ts-expect-error: generic objects are complicated
|
|
55
55
|
tags,
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
} catch (
|
|
58
|
+
} catch (error) {
|
|
59
59
|
return undefined
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -129,8 +129,7 @@ function parseTags(input: string): Record<string, unknown> {
|
|
|
129
129
|
key === "banDuration" ||
|
|
130
130
|
key === "pinnedChatPaidAmount" ||
|
|
131
131
|
key === "pinnedChatPaidExponent" ||
|
|
132
|
-
key === "slow"
|
|
133
|
-
false
|
|
132
|
+
key === "slow"
|
|
134
133
|
) {
|
|
135
134
|
tags[key] = parseInt(value)
|
|
136
135
|
continue
|
|
@@ -145,8 +144,7 @@ function parseTags(input: string): Record<string, unknown> {
|
|
|
145
144
|
key === "emoteOnly" ||
|
|
146
145
|
key === "followersOnly" ||
|
|
147
146
|
key === "subsOnly" ||
|
|
148
|
-
key === "pinnedChatPaidIsSystemMessage"
|
|
149
|
-
false
|
|
147
|
+
key === "pinnedChatPaidIsSystemMessage"
|
|
150
148
|
) {
|
|
151
149
|
tags[key] = !!parseInt(value)
|
|
152
150
|
continue
|
|
@@ -163,14 +161,12 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
163
161
|
|
|
164
162
|
switch (type) {
|
|
165
163
|
case "PING":
|
|
166
|
-
// @ts-ignore
|
|
167
164
|
return {
|
|
168
165
|
type,
|
|
169
166
|
message: parameters,
|
|
170
167
|
}
|
|
171
168
|
|
|
172
169
|
case "001":
|
|
173
|
-
// @ts-ignore
|
|
174
170
|
return {
|
|
175
171
|
type,
|
|
176
172
|
channel: parts[0],
|
|
@@ -178,7 +174,6 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
178
174
|
}
|
|
179
175
|
|
|
180
176
|
case "CAP":
|
|
181
|
-
// @ts-ignore
|
|
182
177
|
return {
|
|
183
178
|
type,
|
|
184
179
|
enabled: parts[1] === "ACK",
|
|
@@ -188,7 +183,6 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
188
183
|
|
|
189
184
|
case "JOIN":
|
|
190
185
|
case "PART":
|
|
191
|
-
// @ts-ignore
|
|
192
186
|
return {
|
|
193
187
|
type,
|
|
194
188
|
channel: parts[0],
|
|
@@ -196,7 +190,6 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
196
190
|
|
|
197
191
|
case "GLOBALUSERSTATE":
|
|
198
192
|
case "RECONNECT":
|
|
199
|
-
// @ts-ignore
|
|
200
193
|
return {
|
|
201
194
|
type,
|
|
202
195
|
}
|
|
@@ -206,7 +199,6 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
206
199
|
case "NOTICE":
|
|
207
200
|
case "ROOMSTATE":
|
|
208
201
|
case "USERSTATE":
|
|
209
|
-
// @ts-ignore
|
|
210
202
|
return {
|
|
211
203
|
type,
|
|
212
204
|
channel: parts[0],
|
|
@@ -214,7 +206,6 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
214
206
|
|
|
215
207
|
case "CLEARMSG":
|
|
216
208
|
case "USERNOTICE":
|
|
217
|
-
// @ts-ignore
|
|
218
209
|
return {
|
|
219
210
|
type,
|
|
220
211
|
channel: parts[0],
|
|
@@ -222,10 +213,9 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
222
213
|
|
|
223
214
|
case "PRIVMSG":
|
|
224
215
|
case "WHISPER":
|
|
225
|
-
if (parameters
|
|
216
|
+
if (parameters.startsWith("!")) {
|
|
226
217
|
const index = parameters.indexOf(" ")
|
|
227
218
|
|
|
228
|
-
// @ts-ignore
|
|
229
219
|
return {
|
|
230
220
|
type: `${type}-COMMAND`,
|
|
231
221
|
channel: parts[0],
|
|
@@ -233,7 +223,6 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
233
223
|
parameters: index > -1 ? parameters.slice(index + 1) : undefined,
|
|
234
224
|
}
|
|
235
225
|
} else {
|
|
236
|
-
// @ts-ignore
|
|
237
226
|
return {
|
|
238
227
|
type,
|
|
239
228
|
channel: parts[0],
|
|
@@ -261,5 +250,5 @@ function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
|
261
250
|
}
|
|
262
251
|
|
|
263
252
|
function toCamelCase(dashedCase: string): string {
|
|
264
|
-
return dashedCase.replace(/[-:]([a-z])/g, (_, b) =>
|
|
253
|
+
return dashedCase.replace(/[-:]([a-z])/g, (_, b: string) => b.toUpperCase())
|
|
265
254
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPointsCustomRewardGlobalCooldown, ChannelPointsCustomRewardImage, ChannelPointsCustomRewardMaxPerStream, ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
3
|
+
import { type ChannelPointsCustomRewardGlobalCooldown, type ChannelPointsCustomRewardImage, type ChannelPointsCustomRewardMaxPerStream, type ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPointsCustomRewardAddType = "channel.channel_points_custom_reward.add"
|
|
6
6
|
type ChannelPointsCustomRewardAddVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPointsCustomRewardGlobalCooldown, ChannelPointsCustomRewardImage, ChannelPointsCustomRewardMaxPerStream, ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
3
|
+
import { type ChannelPointsCustomRewardGlobalCooldown, type ChannelPointsCustomRewardImage, type ChannelPointsCustomRewardMaxPerStream, type ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPointsCustomRewardRemoveType = "channel.channel_points_custom_reward.remove"
|
|
6
6
|
type ChannelPointsCustomRewardRemoveVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPointsCustomRewardGlobalCooldown, ChannelPointsCustomRewardImage, ChannelPointsCustomRewardMaxPerStream, ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
3
|
+
import { type ChannelPointsCustomRewardGlobalCooldown, type ChannelPointsCustomRewardImage, type ChannelPointsCustomRewardMaxPerStream, type ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPointsCustomRewardUpdateType = "channel.channel_points_custom_reward.update"
|
|
6
6
|
type ChannelPointsCustomRewardUpdateVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPointsCustomRewardRedemptionReward } from "./channel.channel_points_custom_reward_redemption._.js"
|
|
3
|
+
import { type ChannelPointsCustomRewardRedemptionReward } from "./channel.channel_points_custom_reward_redemption._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPointsCustomRewardRedemptionAddType = "channel.channel_points_custom_reward_redemption.add"
|
|
6
6
|
type ChannelPointsCustomRewardRedemptionAddVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPointsCustomRewardRedemptionReward } from "./channel.channel_points_custom_reward_redemption._.js"
|
|
3
|
+
import { type ChannelPointsCustomRewardRedemptionReward } from "./channel.channel_points_custom_reward_redemption._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPointsCustomRewardRedemptionUpdateType = "channel.channel_points_custom_reward_redemption.update"
|
|
6
6
|
type ChannelPointsCustomRewardRedemptionUpdateVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { HypeTrainTopContribution } from "./channel.hype_train._.js"
|
|
3
|
+
import { type HypeTrainTopContribution } from "./channel.hype_train._.js"
|
|
4
4
|
|
|
5
5
|
type HypeTrainBeginType = "channel.hype_train.begin"
|
|
6
6
|
type HypeTrainBeginVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { HypeTrainTopContribution } from "./channel.hype_train._.js"
|
|
3
|
+
import { type HypeTrainTopContribution } from "./channel.hype_train._.js"
|
|
4
4
|
|
|
5
5
|
type HypeTrainEndType = "channel.hype_train.end"
|
|
6
6
|
type HypeTrainEndVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { HypeTrainTopContribution } from "./channel.hype_train._.js"
|
|
3
|
+
import { type HypeTrainTopContribution } from "./channel.hype_train._.js"
|
|
4
4
|
|
|
5
5
|
type HypeTrainProgressType = "channel.hype_train.progress"
|
|
6
6
|
type HypeTrainProgressVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPollBitsVoting, ChannelPollChoice, ChannelPollPointsVoting } from "./channel.poll._.js"
|
|
3
|
+
import { type ChannelPollBitsVoting, type ChannelPollChoice, type ChannelPollPointsVoting } from "./channel.poll._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPollBeginType = "channel.poll.begin"
|
|
6
6
|
type ChannelPollBeginVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPollBitsVoting, ChannelPollChoice, ChannelPollPointsVoting } from "./channel.poll._.js"
|
|
3
|
+
import { type ChannelPollBitsVoting, type ChannelPollChoice, type ChannelPollPointsVoting } from "./channel.poll._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPollEndType = "channel.poll.end"
|
|
6
6
|
type ChannelPollEndVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPollBitsVoting, ChannelPollChoice, ChannelPollPointsVoting } from "./channel.poll._.js"
|
|
3
|
+
import { type ChannelPollBitsVoting, type ChannelPollChoice, type ChannelPollPointsVoting } from "./channel.poll._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPollProgressType = "channel.poll.progress"
|
|
6
6
|
type ChannelPollProgressVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
3
|
+
import { type ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPredictionBeginType = "channel.prediction.begin"
|
|
6
6
|
type ChannelPredictionBeginVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
3
|
+
import { type ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPredictionEndType = "channel.prediction.end"
|
|
6
6
|
type ChannelPredictionEndVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
3
|
+
import { type ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPredictionLockType = "channel.prediction.lock"
|
|
6
6
|
type ChannelPredictionLockVersion = "1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseSubscription } from "../events-helpers.js"
|
|
1
|
+
import { type BaseSubscription } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
3
|
+
import { type ChannelPredictionOutcome } from "./channel.prediction._.js"
|
|
4
4
|
|
|
5
5
|
type ChannelPredictionProgressType = "channel.prediction.progress"
|
|
6
6
|
type ChannelPredictionProgressVersion = "1"
|