@allior/wmake-streamelements-events 2.0.2 → 2.0.4

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 (66) hide show
  1. package/dist/react/hooks/use-on-event-received.d.ts +1 -1
  2. package/dist/react/hooks/use-on-widget-load.d.ts +1 -1
  3. package/dist/react/index.iife.js +2 -2
  4. package/dist/react/index.iife.js.map +1 -1
  5. package/dist/react/index.js +32 -92
  6. package/dist/react/index.js.map +1 -1
  7. package/dist/root/guards/on-event-received.d.ts +1 -1
  8. package/dist/root/index.iife.js +2 -2
  9. package/dist/root/index.iife.js.map +1 -1
  10. package/dist/root/index.js +2 -3116
  11. package/dist/root/queue/alert-queue.d.ts +1 -1
  12. package/dist/root/queue/next-alert-callback.d.ts +1 -1
  13. package/dist/root/types/on-event-received/message.d.ts +1 -1
  14. package/dist/root-BzhLLMHq.js +2934 -0
  15. package/dist/root-BzhLLMHq.js.map +1 -0
  16. package/package.json +11 -13
  17. package/dist/root/index.js.map +0 -1
  18. package/src/react/hooks/index.ts +0 -3
  19. package/src/react/hooks/use-event-listener.ts +0 -20
  20. package/src/react/hooks/use-on-event-received.ts +0 -108
  21. package/src/react/hooks/use-on-widget-load.ts +0 -15
  22. package/src/react/index.ts +0 -3
  23. package/src/react/types/index.ts +0 -1
  24. package/src/react/types/window-events.ts +0 -6
  25. package/src/root/aggregate.ts +0 -257
  26. package/src/root/classifier.ts +0 -271
  27. package/src/root/commands.ts +0 -39
  28. package/src/root/data/field-value.ts +0 -2
  29. package/src/root/data/index.ts +0 -2
  30. package/src/root/data/widget-load.ts +0 -5
  31. package/src/root/guards/index.ts +0 -1
  32. package/src/root/guards/on-event-received.ts +0 -58
  33. package/src/root/index.ts +0 -11
  34. package/src/root/keys.ts +0 -14
  35. package/src/root/message/index.ts +0 -1
  36. package/src/root/message/twitch/index.ts +0 -2
  37. package/src/root/message/twitch/message.ts +0 -48
  38. package/src/root/message/twitch/user-message-data.ts +0 -112
  39. package/src/root/queue/alert-queue.ts +0 -31
  40. package/src/root/queue/index.ts +0 -2
  41. package/src/root/queue/next-alert-callback.ts +0 -7
  42. package/src/root/sources/alerts.ts +0 -163
  43. package/src/root/sources/index.ts +0 -5
  44. package/src/root/sources/messages.ts +0 -1611
  45. package/src/root/sources/on-widget-load-detail.ts +0 -968
  46. package/src/root/types/index.ts +0 -2
  47. package/src/root/types/on-event-received/base.ts +0 -94
  48. package/src/root/types/on-event-received/cheer.ts +0 -10
  49. package/src/root/types/on-event-received/donation.ts +0 -29
  50. package/src/root/types/on-event-received/follower.ts +0 -9
  51. package/src/root/types/on-event-received/index.ts +0 -58
  52. package/src/root/types/on-event-received/message.ts +0 -13
  53. package/src/root/types/on-event-received/moderation.ts +0 -7
  54. package/src/root/types/on-event-received/other.ts +0 -14
  55. package/src/root/types/on-event-received/raid.ts +0 -10
  56. package/src/root/types/on-event-received/subscriber.ts +0 -77
  57. package/src/root/types/on-widget-load/base.ts +0 -35
  58. package/src/root/types/on-widget-load/index.ts +0 -3
  59. package/src/root/types/on-widget-load/recents.ts +0 -33
  60. package/src/root/types/on-widget-load/session.ts +0 -102
  61. package/src/root/window-event-map.ts +0 -9
  62. package/tsconfig.app.json +0 -31
  63. package/tsconfig.json +0 -8
  64. package/tsconfig.node.json +0 -25
  65. package/vite.config.ts +0 -36
  66. package/vite.iife.config.ts +0 -52
@@ -1,48 +0,0 @@
1
- export namespace TwitchMessage {
2
- export interface Data {
3
- tags: Tags;
4
- nick: string;
5
- userId: string;
6
- displayName: string;
7
- displayColor?: string;
8
- badges: Array<Badge>;
9
- channel: string;
10
- text: string;
11
- isAction: boolean;
12
- emotes: Array<Emote>;
13
- msgId: string;
14
- time?: number;
15
- }
16
-
17
- export type Tags = Record<string, unknown> & {
18
- "badge-info"?: string;
19
- badges?: string;
20
- "first-msg"?: string;
21
- turbo?: string;
22
- subscriber?: string;
23
- mod?: string;
24
- vip?: string;
25
- "user-type"?: string;
26
- "reply-parent-msg-id"?: string;
27
- "reply-parent-msg-body"?: string;
28
- "reply-parent-display-name"?: string;
29
- "reply-parent-user-login"?: string;
30
- "reply-parent-user-id"?: string;
31
- };
32
-
33
- export interface Badge {
34
- type: string;
35
- version?: string;
36
- url?: string;
37
- description?: string;
38
- }
39
-
40
- export interface Emote {
41
- type: string;
42
- name: string;
43
- id: string;
44
- urls: Record<string, string>;
45
- start?: number;
46
- end?: number;
47
- }
48
- }
@@ -1,112 +0,0 @@
1
- import type { TwitchMessage } from "./message";
2
-
3
- export enum UserRole {
4
- BROADCASTER = "broadcaster",
5
- LEAD_MODERATOR = "lead_moderator",
6
- MODERATOR = "moderator",
7
- VIP = "vip",
8
- ARTIST = "artist",
9
- FOUNDER = "founder",
10
- SUBSCRIBER = "subscriber",
11
- TURBO = "turbo",
12
- DEFAULT = "default",
13
- }
14
-
15
- type UserMessageDataOptions = {
16
- badges?: TwitchMessage.Badge[];
17
- tags?: TwitchMessage.Tags;
18
- };
19
-
20
- export const TwitchUserMessageData = ({
21
- badges = [],
22
- tags = {},
23
- }: UserMessageDataOptions) => {
24
- const includesBadgeType = (type: string) => {
25
- return !!badges.find((b) => b.type === type);
26
- };
27
-
28
- const tagBadgesString = tags.badges ?? "";
29
- const userType = tags["user-type"] ?? "";
30
-
31
- const isSubscriber =
32
- tagBadgesString.includes("subscriber/1") ||
33
- tags.subscriber === "1" ||
34
- includesBadgeType("subscriber");
35
-
36
- const isFounder =
37
- tagBadgesString.includes("founder/1") || includesBadgeType("founder");
38
-
39
- const isBroadcaster =
40
- tagBadgesString.includes("broadcaster/1") ||
41
- includesBadgeType("broadcaster");
42
-
43
- const isFirstMessageChatter = tags["first-msg"] === "1";
44
-
45
- const isTurbo = tags.turbo === "1";
46
-
47
- const isVip =
48
- tags.vip === "1" ||
49
- tagBadgesString.includes("vip/1") ||
50
- includesBadgeType("vip");
51
-
52
- const isLeadModerator =
53
- tagBadgesString.includes("lead_moderator/1") ||
54
- includesBadgeType("lead_moderator");
55
-
56
- const isModerator =
57
- ((tags.mod === "1" ||
58
- tagBadgesString.includes("moderator/1") ||
59
- userType === "mod") &&
60
- !isLeadModerator) ||
61
- includesBadgeType("moderator");
62
-
63
- const isAnyModerator = isModerator || isLeadModerator;
64
-
65
- const isArtist =
66
- tagBadgesString.includes("artist-badge/1") ||
67
- includesBadgeType("artist-badge");
68
-
69
- const roles: UserRole[] = [];
70
- if (isBroadcaster) roles.push(UserRole.BROADCASTER);
71
- if (isLeadModerator) roles.push(UserRole.LEAD_MODERATOR);
72
- if (isModerator) roles.push(UserRole.MODERATOR);
73
- if (isVip) roles.push(UserRole.VIP);
74
- if (isArtist) roles.push(UserRole.ARTIST);
75
- if (isFounder) roles.push(UserRole.FOUNDER);
76
- if (isSubscriber) roles.push(UserRole.SUBSCRIBER);
77
- if (isTurbo) roles.push(UserRole.TURBO);
78
- roles.push(UserRole.DEFAULT);
79
-
80
- const getSubscriberMonths = (): number => {
81
- for (const key of ["badge-info", "badges"]) {
82
- const tag = tags[key] as string;
83
- if (tag) {
84
- const match = tag.match(/^subscriber\/(\d+)$/);
85
- if (match) {
86
- return parseInt(match[1], 10);
87
- }
88
- }
89
- }
90
- return 0;
91
- };
92
-
93
- const getBadgeUrlByType = (type: string) =>
94
- badges.find((b) => b.type === type)?.url;
95
-
96
- return {
97
- isSubscriber,
98
- isBroadcaster,
99
- isFirstMessageChatter,
100
- isFounder,
101
- isTurbo,
102
- isVip,
103
- isAnyModerator,
104
- isModerator,
105
- isLeadModerator,
106
- isArtist,
107
- roles,
108
- includesBadgeType,
109
- getSubscriberMonths,
110
- getBadgeUrlByType,
111
- };
112
- };
@@ -1,31 +0,0 @@
1
- import type { ClassifiedEvent } from "@/root";
2
- import type { NextAlertCallback } from ".";
3
-
4
- export class AlertQueue {
5
- private readonly queue: ClassifiedEvent[] = [];
6
- public isShowingAlert: boolean = false;
7
- public onNextAlert: NextAlertCallback;
8
-
9
- constructor(onNextAlert: NextAlertCallback) {
10
- this.onNextAlert = onNextAlert;
11
- }
12
-
13
- public push(event: ClassifiedEvent) {
14
- this.queue.push(event);
15
- }
16
-
17
- // DON'T FORGET SET "this.isShowingAlert = false" AFTER EXECUTION
18
- public processNextAlert() {
19
- if (this.queue.length === 0 || this.isShowingAlert) {
20
- return;
21
- }
22
-
23
- const alertData = this.queue.shift();
24
- if (!alertData) {
25
- return;
26
- }
27
- this.isShowingAlert = true;
28
-
29
- this.onNextAlert(this, alertData);
30
- }
31
- }
@@ -1,2 +0,0 @@
1
- export * from "./alert-queue";
2
- export * from "./next-alert-callback";
@@ -1,7 +0,0 @@
1
- import type { ClassifiedEvent } from "@/root";
2
- import type { AlertQueue } from ".";
3
-
4
- export type NextAlertCallback = (
5
- self: AlertQueue,
6
- event: ClassifiedEvent | null,
7
- ) => void;
@@ -1,163 +0,0 @@
1
- export const testAlerts = {
2
- follower: {
3
- listener: "follower-latest",
4
- event: {
5
- name: "An1by",
6
- },
7
- },
8
- communityGiftAnonymous: {
9
- listener: "event",
10
- event: {
11
- type: "communityGiftPurchase",
12
- provider: "twitch",
13
- channel: "663b10ba6cd449c4162a2230",
14
- activityGroup: "41a50a915794e4ae7cf5e600fd3445d4",
15
- data: {
16
- amount: 2,
17
- username: "anonymous",
18
- displayName: "AnAnonymousGifter",
19
- tier: "2000",
20
- sender: "Anonymous",
21
- },
22
- _id: "699868d7df734989ec85d393",
23
- activityId: "699868d7df734989ec85d393",
24
- },
25
- },
26
- communityGift: {
27
- listener: "event",
28
- event: {
29
- type: "communityGiftPurchase",
30
- provider: "twitch",
31
- channel: "663b10ba6cd449c4162a2230",
32
- activityGroup: "841592c0bccbf3e1e7de71e1c8f4d9f0",
33
- data: {
34
- amount: 1,
35
- username: "rishamon",
36
- displayName: "rishamon",
37
- tier: "1000",
38
- sender: "rishamon",
39
- },
40
- _id: "699867c7fef23197a6a089f5",
41
- activityId: "699867c7fef23197a6a089f5",
42
- },
43
- },
44
- sub: {
45
- listener: "subscriber-latest",
46
- event: {
47
- name: "An1by",
48
- amount: 1,
49
- },
50
- },
51
- selfSub: {
52
- listener: "event",
53
- event: {
54
- type: "subscriber",
55
- provider: "twitch",
56
- channel: "663b10ba6cd449c4162a2230",
57
- data: {
58
- amount: 1,
59
- username: "rishamon",
60
- displayName: "rishamon",
61
- tier: "1000",
62
- },
63
- _id: "6998676317aed69e62b8f283",
64
- activityId: "6998676317aed69e62b8f283",
65
- },
66
- },
67
- soloSubToSomeone: {
68
- listener: "event",
69
- event: {
70
- type: "subscriber",
71
- provider: "twitch",
72
- channel: "663b10ba6cd449c4162a2230",
73
- data: {
74
- amount: 1,
75
- username: "encry_s",
76
- displayName: "encry_s",
77
- message:
78
- "rishamon gifted a Tier 1 sub to encry_s! This is their first Gift Sub in the channel!",
79
- tier: "1000",
80
- sender: "rishamon",
81
- gifted: true,
82
- },
83
- _id: "699866e82d9cd9a70854baf2",
84
- activityId: "699866e82d9cd9a70854baf2",
85
- },
86
- },
87
- subRenewal: {
88
- listener: "event",
89
- event: {
90
- type: "subscriber",
91
- provider: "twitch",
92
- channel: "663b10ba6cd449c4162a2230",
93
- data: {
94
- amount: 8,
95
- username: "silgestian",
96
- displayName: "SilgeStian",
97
- tier: "1000",
98
- },
99
- _id: "69986dfaf25724ff4162bd1a",
100
- activityId: "69986dfaf25724ff4162bd1a",
101
- },
102
- },
103
- bits: {
104
- listener: "cheer-latest",
105
- event: {
106
- name: "An1by",
107
- amount: 30,
108
- },
109
- },
110
- raid: {
111
- listener: "raid-latest",
112
- event: {
113
- name: "An1by",
114
- amount: 50,
115
- },
116
- },
117
- donationShortText: {
118
- listener: "donation",
119
- event: {
120
- data: {
121
- alert_type: "1",
122
- currency: "RUB",
123
- billing_system: "CARD",
124
- id: 5,
125
- amount_main: 500,
126
- amount: 500,
127
- username: "An1by",
128
- message: "Simple message text",
129
- },
130
- },
131
- },
132
- donationLongText: {
133
- listener: "donation",
134
- event: {
135
- data: {
136
- alert_type: "1",
137
- currency: "RUB",
138
- billing_system: "CARD",
139
- id: 5,
140
- amount_main: 500,
141
- amount: 500,
142
- username: "An1by",
143
- message:
144
- "A plain gray stone lay on the shore, basking in the sun's warmth. A shove broke its peace—a thoughtless toss sent it flying. The stone splashed into water. Ripples spread, yet none noticed. It sank to the bottom, heavy with loneliness. \"Didn't I deserve to stay where I was happy still?\" it wondered.",
145
- },
146
- },
147
- },
148
- donation: {
149
- listener: "donation",
150
- event: {
151
- data: {
152
- alert_type: "1",
153
- currency: "RUB",
154
- billing_system: "CARD",
155
- id: 5,
156
- amount_main: 500,
157
- amount: 500,
158
- username: "An1by",
159
- message: "",
160
- },
161
- },
162
- },
163
- };
@@ -1,5 +0,0 @@
1
- import testOnWidgetLoadDetail from "./on-widget-load-detail.js";
2
-
3
- export * from "./alerts.js";
4
- export * from "./messages.js";
5
- export { testOnWidgetLoadDetail };