@allior/wmake-streamelements-events 0.0.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 +46 -0
- package/README_RU.md +46 -0
- package/dist/react/hooks/index.d.ts +4 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/use-event-listener.d.ts +4 -0
- package/dist/react/hooks/use-event-listener.d.ts.map +1 -0
- package/dist/react/hooks/use-on-event-received.d.ts +44 -0
- package/dist/react/hooks/use-on-event-received.d.ts.map +1 -0
- package/dist/react/hooks/use-on-widget-load.d.ts +4 -0
- package/dist/react/hooks/use-on-widget-load.d.ts.map +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.iife.js +2 -0
- package/dist/react/index.iife.js.map +1 -0
- package/dist/react/index.js +179 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/types/index.d.ts +2 -0
- package/dist/react/types/index.d.ts.map +1 -0
- package/dist/react/types/window-events.d.ts +3 -0
- package/dist/react/types/window-events.d.ts.map +1 -0
- package/dist/root/aggregate.d.ts +12 -0
- package/dist/root/aggregate.d.ts.map +1 -0
- package/dist/root/classifier.d.ts +9 -0
- package/dist/root/classifier.d.ts.map +1 -0
- package/dist/root/commands.d.ts +9 -0
- package/dist/root/commands.d.ts.map +1 -0
- package/dist/root/data/event-detail.d.ts +10 -0
- package/dist/root/data/event-detail.d.ts.map +1 -0
- package/dist/root/data/field-value.d.ts +3 -0
- package/dist/root/data/field-value.d.ts.map +1 -0
- package/dist/root/data/index.d.ts +3 -0
- package/dist/root/data/index.d.ts.map +1 -0
- package/dist/root/data/widget-load.d.ts +5 -0
- package/dist/root/data/widget-load.d.ts.map +1 -0
- package/dist/root/index.d.ts +10 -0
- package/dist/root/index.d.ts.map +1 -0
- package/dist/root/index.iife.js +2 -0
- package/dist/root/index.iife.js.map +1 -0
- package/dist/root/index.js +2692 -0
- package/dist/root/index.js.map +1 -0
- package/dist/root/keys.d.ts +6 -0
- package/dist/root/keys.d.ts.map +1 -0
- package/dist/root/message/event.d.ts +7 -0
- package/dist/root/message/event.d.ts.map +1 -0
- package/dist/root/message/index.d.ts +5 -0
- package/dist/root/message/index.d.ts.map +1 -0
- package/dist/root/message/message.d.ts +37 -0
- package/dist/root/message/message.d.ts.map +1 -0
- package/dist/root/message/roles.d.ts +4 -0
- package/dist/root/message/roles.d.ts.map +1 -0
- package/dist/root/message/tags.d.ts +69 -0
- package/dist/root/message/tags.d.ts.map +1 -0
- package/dist/root/sources/alerts.d.ts +162 -0
- package/dist/root/sources/alerts.d.ts.map +1 -0
- package/dist/root/sources/index.d.ts +5 -0
- package/dist/root/sources/index.d.ts.map +1 -0
- package/dist/root/sources/messages.d.ts +963 -0
- package/dist/root/sources/messages.d.ts.map +1 -0
- package/dist/root/sources/on-widget-load-detail.d.ts +542 -0
- package/dist/root/sources/on-widget-load-detail.d.ts.map +1 -0
- package/dist/root/types/index.d.ts +3 -0
- package/dist/root/types/index.d.ts.map +1 -0
- package/dist/root/types/on-event-received.d.ts +170 -0
- package/dist/root/types/on-event-received.d.ts.map +1 -0
- package/dist/root/types/on-widget-load.d.ts +135 -0
- package/dist/root/types/on-widget-load.d.ts.map +1 -0
- package/dist/root/window-event-map.d.ts +10 -0
- package/dist/root/window-event-map.d.ts.map +1 -0
- package/package.json +48 -0
- package/src/react/hooks/index.ts +3 -0
- package/src/react/hooks/use-event-listener.ts +17 -0
- package/src/react/hooks/use-on-event-received.ts +206 -0
- package/src/react/hooks/use-on-widget-load.ts +15 -0
- package/src/react/index.ts +3 -0
- package/src/react/types/index.ts +1 -0
- package/src/react/types/window-events.ts +6 -0
- package/src/root/aggregate.ts +258 -0
- package/src/root/classifier.ts +208 -0
- package/src/root/commands.ts +33 -0
- package/src/root/data/event-detail.ts +14 -0
- package/src/root/data/field-value.ts +2 -0
- package/src/root/data/index.ts +2 -0
- package/src/root/data/widget-load.ts +5 -0
- package/src/root/index.ts +9 -0
- package/src/root/keys.ts +14 -0
- package/src/root/message/event.ts +7 -0
- package/src/root/message/index.ts +4 -0
- package/src/root/message/message.ts +40 -0
- package/src/root/message/roles.ts +43 -0
- package/src/root/message/tags.ts +119 -0
- package/src/root/sources/alerts.ts +163 -0
- package/src/root/sources/index.ts +5 -0
- package/src/root/sources/messages.ts +1245 -0
- package/src/root/sources/on-widget-load-detail.ts +969 -0
- package/src/root/types/index.ts +2 -0
- package/src/root/types/on-event-received.ts +198 -0
- package/src/root/types/on-widget-load.ts +171 -0
- package/src/root/window-event-map.ts +11 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Типы для входящих событий StreamElements/Twitch и результата классификации.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Алерт: новый подписчик (follower-latest). */
|
|
6
|
+
export interface FollowerDetail {
|
|
7
|
+
listener: "follower-latest";
|
|
8
|
+
event: { name: string };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Алерт: массовая раздача подписок (communityGiftPurchase). */
|
|
12
|
+
export interface CommunityGiftPurchaseDetail {
|
|
13
|
+
listener: "event";
|
|
14
|
+
event: {
|
|
15
|
+
type: "communityGiftPurchase";
|
|
16
|
+
provider: string;
|
|
17
|
+
channel: string;
|
|
18
|
+
activityGroup: string;
|
|
19
|
+
data: {
|
|
20
|
+
amount: number;
|
|
21
|
+
username: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
tier: string;
|
|
24
|
+
sender?: string;
|
|
25
|
+
};
|
|
26
|
+
_id: string;
|
|
27
|
+
activityId: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Алерт: подписка latest (subscriber-latest). */
|
|
32
|
+
export interface SubscriberLatestDetail {
|
|
33
|
+
listener: "subscriber-latest";
|
|
34
|
+
event: { name: string; amount: number };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Алерт: подписка (self, подарок одному, продление). */
|
|
38
|
+
export interface SubscriberDetail {
|
|
39
|
+
listener: "event";
|
|
40
|
+
event: {
|
|
41
|
+
type: "subscriber";
|
|
42
|
+
provider: string;
|
|
43
|
+
channel: string;
|
|
44
|
+
data: {
|
|
45
|
+
amount: number;
|
|
46
|
+
username: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
tier: string;
|
|
49
|
+
sender?: string;
|
|
50
|
+
gifted?: boolean;
|
|
51
|
+
message?: string;
|
|
52
|
+
};
|
|
53
|
+
_id: string;
|
|
54
|
+
activityId: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Алерт: чиры (bits). */
|
|
59
|
+
export interface CheerDetail {
|
|
60
|
+
listener: "cheer-latest";
|
|
61
|
+
event: { name: string; amount: number };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Алерт: рейд. */
|
|
65
|
+
export interface RaidDetail {
|
|
66
|
+
listener: "raid-latest";
|
|
67
|
+
event: { name: string; amount: number };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Алерт: донат. */
|
|
71
|
+
export interface DonationDetail {
|
|
72
|
+
listener: "donation";
|
|
73
|
+
event: {
|
|
74
|
+
data: {
|
|
75
|
+
alert_type?: string;
|
|
76
|
+
currency?: string;
|
|
77
|
+
billing_system?: string;
|
|
78
|
+
id?: number;
|
|
79
|
+
amount_main?: number;
|
|
80
|
+
amount?: number;
|
|
81
|
+
username?: string;
|
|
82
|
+
message?: string;
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Все типы алертов (onEventReceived). */
|
|
89
|
+
export type AlertDetail =
|
|
90
|
+
| FollowerDetail
|
|
91
|
+
| SubscriberLatestDetail
|
|
92
|
+
| CommunityGiftPurchaseDetail
|
|
93
|
+
| SubscriberDetail
|
|
94
|
+
| CheerDetail
|
|
95
|
+
| RaidDetail
|
|
96
|
+
| DonationDetail;
|
|
97
|
+
|
|
98
|
+
/** Входящее событие (обобщённый вид для classifyEvent и т.д.). */
|
|
99
|
+
export interface IncomingDetail {
|
|
100
|
+
listener: string;
|
|
101
|
+
event?: {
|
|
102
|
+
type?: string;
|
|
103
|
+
provider?: string;
|
|
104
|
+
channel?: string;
|
|
105
|
+
activityGroup?: string;
|
|
106
|
+
activityId?: string;
|
|
107
|
+
_id?: string;
|
|
108
|
+
bulkGifted?: boolean;
|
|
109
|
+
sender?: string;
|
|
110
|
+
name?: string;
|
|
111
|
+
amount?: number;
|
|
112
|
+
tier?: string | number;
|
|
113
|
+
gifted?: boolean;
|
|
114
|
+
isCommunityGift?: boolean;
|
|
115
|
+
communityGifted?: boolean;
|
|
116
|
+
message?: string;
|
|
117
|
+
data?: Record<string, unknown>;
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface TierInfo {
|
|
123
|
+
tier: number;
|
|
124
|
+
tierText: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type NormalizedType =
|
|
128
|
+
| "community-gift-anonymous"
|
|
129
|
+
| "community-gift"
|
|
130
|
+
| "self-sub"
|
|
131
|
+
| "solo-sub-to-someone"
|
|
132
|
+
| "sub-renewal";
|
|
133
|
+
|
|
134
|
+
export interface ClassifiedBase {
|
|
135
|
+
type: NormalizedType;
|
|
136
|
+
tier: number;
|
|
137
|
+
tierText: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface ClassifiedCommunityGiftPurchase extends ClassifiedBase {
|
|
141
|
+
type: "community-gift" | "community-gift-anonymous";
|
|
142
|
+
totalAmount: number;
|
|
143
|
+
recipients: string[];
|
|
144
|
+
sender?: string;
|
|
145
|
+
anonymousDisplayName?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ClassifiedRecipient extends ClassifiedBase {
|
|
149
|
+
_role: "recipient";
|
|
150
|
+
activityGroup: string;
|
|
151
|
+
recipient: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface ClassifiedSoloSub extends ClassifiedBase {
|
|
155
|
+
type: "solo-sub-to-someone";
|
|
156
|
+
sender: string;
|
|
157
|
+
recipient: string;
|
|
158
|
+
firstGiftInChannel?: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface ClassifiedSubRenewal extends ClassifiedBase {
|
|
162
|
+
type: "sub-renewal";
|
|
163
|
+
name: string;
|
|
164
|
+
months: number;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface ClassifiedSelfSub extends ClassifiedBase {
|
|
168
|
+
type: "self-sub";
|
|
169
|
+
name: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type ClassifiedEvent =
|
|
173
|
+
| ClassifiedCommunityGiftPurchase
|
|
174
|
+
| ClassifiedRecipient
|
|
175
|
+
| ClassifiedSoloSub
|
|
176
|
+
| ClassifiedSubRenewal
|
|
177
|
+
| ClassifiedSelfSub
|
|
178
|
+
| (ClassifiedBase & { type: NormalizedType; [key: string]: unknown });
|
|
179
|
+
|
|
180
|
+
export interface CacheLike {
|
|
181
|
+
_has(key: string): boolean;
|
|
182
|
+
_set(key: string, value: boolean): void;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface CacheSubsByType {
|
|
186
|
+
_has?(key: string): boolean;
|
|
187
|
+
_set?(key: string, value: boolean): void;
|
|
188
|
+
[type: string]:
|
|
189
|
+
| CacheLike
|
|
190
|
+
| ((k: string) => boolean)
|
|
191
|
+
| ((k: string, v: boolean) => void)
|
|
192
|
+
| undefined;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface NormalizerOptions {
|
|
196
|
+
cacheSubs?: CacheSubsByType;
|
|
197
|
+
broadcasterLogin?: string;
|
|
198
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export interface OnWidgetLoadEventDetails {
|
|
2
|
+
channel: Channel;
|
|
3
|
+
currency: Currency;
|
|
4
|
+
fieldData: FieldData;
|
|
5
|
+
overlay: Overlay;
|
|
6
|
+
recents: Recents;
|
|
7
|
+
session: Session;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Channel {
|
|
11
|
+
/**
|
|
12
|
+
* StreamElements API Token (not JWT Token)
|
|
13
|
+
*/
|
|
14
|
+
apiToken: string;
|
|
15
|
+
avatar: string;
|
|
16
|
+
id: string;
|
|
17
|
+
providerId: string;
|
|
18
|
+
username: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Currency {
|
|
22
|
+
code: string;
|
|
23
|
+
name: string;
|
|
24
|
+
symbol: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type FieldData = Record<string, unknown>;
|
|
28
|
+
|
|
29
|
+
export interface Overlay {
|
|
30
|
+
isEditorMode: boolean;
|
|
31
|
+
muted: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Base for recent (onWidgetLoad): follower / subscriber / cheer / raid */
|
|
35
|
+
export interface RecentItemBase {
|
|
36
|
+
name: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RecentItemFollower extends RecentItemBase {
|
|
41
|
+
type: "follower";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RecentItemSubscriber extends RecentItemBase {
|
|
45
|
+
type: "subscriber";
|
|
46
|
+
tier: string;
|
|
47
|
+
amount: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface RecentItemCheer extends RecentItemBase {
|
|
51
|
+
type: "cheer";
|
|
52
|
+
amount: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RecentItemRaid extends RecentItemBase {
|
|
56
|
+
type: "raid";
|
|
57
|
+
amount: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type RecentsItem =
|
|
61
|
+
| RecentItemFollower
|
|
62
|
+
| RecentItemSubscriber
|
|
63
|
+
| RecentItemCheer
|
|
64
|
+
| RecentItemRaid;
|
|
65
|
+
|
|
66
|
+
export type Recents = RecentsItem[];
|
|
67
|
+
|
|
68
|
+
// --- Session (StreamElements overlay session data) ---
|
|
69
|
+
|
|
70
|
+
export interface SessionSettings {
|
|
71
|
+
autoReset: boolean;
|
|
72
|
+
calendar: boolean;
|
|
73
|
+
resetOnStart: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Запись в списке follower-recent / subscriber-recent / raid-recent / cheer-recent */
|
|
77
|
+
export interface SessionRecentItem {
|
|
78
|
+
name: string;
|
|
79
|
+
createdAt: string;
|
|
80
|
+
type: string;
|
|
81
|
+
amount?: number;
|
|
82
|
+
tier?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Объект *-latest с полями name и amount (subscriber, cheer, tip, host, raid и т.д.) */
|
|
86
|
+
export interface SessionLatestNamedAmount {
|
|
87
|
+
name: string;
|
|
88
|
+
amount: number;
|
|
89
|
+
message?: string;
|
|
90
|
+
tier?: string;
|
|
91
|
+
sender?: string;
|
|
92
|
+
redemption?: string;
|
|
93
|
+
items?: unknown[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Объект *-session / *-total и т.п. с полем count */
|
|
97
|
+
export interface SessionCountEntry {
|
|
98
|
+
count: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Объект *-goal / *-session (amount) и т.п. с полем amount */
|
|
102
|
+
export interface SessionAmountEntry {
|
|
103
|
+
amount: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Объект top-donation / top-donator */
|
|
107
|
+
export interface SessionTopEntry {
|
|
108
|
+
name: string;
|
|
109
|
+
amount: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** channel-points-latest */
|
|
113
|
+
export interface SessionChannelPointsLatest {
|
|
114
|
+
name: string;
|
|
115
|
+
amount: number;
|
|
116
|
+
message: string;
|
|
117
|
+
redemption: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** community-gift-latest */
|
|
121
|
+
export interface SessionCommunityGiftLatest {
|
|
122
|
+
name: string;
|
|
123
|
+
amount: number;
|
|
124
|
+
tier: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** hypetrain-latest */
|
|
128
|
+
export interface SessionHypetrainLatest {
|
|
129
|
+
active: number;
|
|
130
|
+
amount: number;
|
|
131
|
+
level: number;
|
|
132
|
+
levelChanged: number;
|
|
133
|
+
name: string;
|
|
134
|
+
type: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** merch-latest */
|
|
138
|
+
export interface SessionMerchLatest {
|
|
139
|
+
name: string;
|
|
140
|
+
amount: number;
|
|
141
|
+
items: unknown[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Элемент массива purchase-latest */
|
|
145
|
+
export interface SessionPurchaseLatest {
|
|
146
|
+
name: string;
|
|
147
|
+
amount: number;
|
|
148
|
+
avatar: string;
|
|
149
|
+
message: string;
|
|
150
|
+
items: unknown[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type SessionDataEntry =
|
|
154
|
+
| SessionLatestNamedAmount
|
|
155
|
+
| SessionCountEntry
|
|
156
|
+
| SessionAmountEntry
|
|
157
|
+
| SessionTopEntry
|
|
158
|
+
| SessionChannelPointsLatest
|
|
159
|
+
| SessionCommunityGiftLatest
|
|
160
|
+
| SessionHypetrainLatest
|
|
161
|
+
| SessionMerchLatest
|
|
162
|
+
| SessionPurchaseLatest
|
|
163
|
+
| SessionRecentItem[]
|
|
164
|
+
| { name: string }
|
|
165
|
+
| { level?: number; percent?: number; amount?: number }
|
|
166
|
+
| Record<string, unknown>;
|
|
167
|
+
|
|
168
|
+
export interface Session {
|
|
169
|
+
data: Record<string, SessionDataEntry>;
|
|
170
|
+
settings: SessionSettings;
|
|
171
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EventDetail } from "./data/event-detail.js";
|
|
2
|
+
import type { WidgetLoadDetail } from "./data/widget-load.js";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
interface WindowEventMap {
|
|
6
|
+
onEventReceived: CustomEvent<EventDetail>;
|
|
7
|
+
onWidgetLoad: CustomEvent<WidgetLoadDetail>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {};
|