@tixyel/streamelements 3.4.0 → 3.5.0

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/index.d.ts CHANGED
@@ -1,631 +1,568 @@
1
- type StreamElementsFieldTypes = 'button' | 'number' | 'slider' | 'text' | 'hidden' | 'checkbox' | 'dropdown' | 'colorpicker' | 'googleFont' | 'video-input' | 'image-input' | 'sound-input';
2
- type StreamElementsField = {
3
- type: StreamElementsFieldTypes;
4
- label: string;
5
- value?: string | number | boolean;
6
- group?: string;
7
- min?: number | string;
8
- max?: number | string;
9
- step?: number | string;
10
- options?: Record<string, string>;
11
- multiple?: boolean;
12
- };
13
- type StreamElementsFieldValue = string | number | boolean | undefined;
14
- type StreamElementsFieldTypeMap = Array<[string[], StreamElementsFieldTypes]>;
15
- type StreamElementsFieldAddonsMap = Array<[string[], Record<string, any>]>;
16
- type StreamElementsFieldTransformMap = Array<[string[], (value: string | number) => string | number]>;
17
- type StreamElementsFieldLabelMap = Array<[string[], string]>;
18
- type FieldSettings = {
19
- from?: string;
20
- endsWith?: string[];
21
- ignore?: string[];
22
- replace?: Record<string, string>;
23
- settings?: {
24
- types?: StreamElementsFieldTypeMap;
25
- addons?: StreamElementsFieldAddonsMap;
26
- transforms?: StreamElementsFieldTransformMap;
27
- labels?: StreamElementsFieldLabelMap;
28
- };
29
- subgroup?: boolean;
30
- template?: string;
31
- subgroupTemplate?: string;
32
- };
33
-
34
- type Session$1 = Session$Follower & Session$Subscriber & Session$Host & Session$Raid & Session$CharityCampaignDonation & Session$Cheer & Session$CheerPurchase & Session$Superchat & Session$Hypetrain & Session$ChannelPoints & Session$Tip & Session$Merch & Session$Purchase;
35
- type Session$Follower$Recent = {
1
+ type TwitchEmote = {
2
+ type: 'twitch';
36
3
  name: string;
37
- createdAt: string;
38
- };
39
- type Session$Follower = {
40
- 'follower-latest': {
41
- name: string;
42
- };
43
- 'follower-session': {
44
- count: number;
45
- };
46
- 'follower-week': {
47
- count: number;
48
- };
49
- 'follower-month': {
50
- count: number;
51
- };
52
- 'follower-goal': {
53
- amount: number;
54
- };
55
- 'follower-total': {
56
- count: number;
4
+ id: string;
5
+ gif: boolean;
6
+ urls: {
7
+ '1': string;
8
+ '2': string;
9
+ '4': string;
57
10
  };
58
- 'follower-recent': Session$Follower$Recent[];
11
+ start: number;
12
+ end: number;
59
13
  };
60
- type SubscriptionTier = 'prime' | '1000' | '2000' | '3000';
61
- interface Session$Subscriber$Recent {
62
- name: string;
63
- amount: number;
64
- tier: SubscriptionTier;
65
- createdAt: string;
66
- }
67
- interface Session$Subscriber {
68
- 'subscriber-latest': {
69
- name: string;
70
- amount: number;
71
- tier: SubscriptionTier;
72
- message: string;
73
- };
74
- 'subscriber-new-latest': {
75
- name: string;
76
- amount: number;
77
- message: string;
78
- };
79
- 'subscriber-resub-latest': {
80
- name: string;
81
- amount: number;
82
- message: string;
83
- };
84
- 'subscriber-gifted-latest': {
85
- name: string;
86
- amount: number;
87
- message: string;
88
- tier: SubscriptionTier;
89
- sender: string;
90
- };
91
- 'subscriber-session': {
92
- count: number;
93
- };
94
- 'subscriber-new-session': {
95
- count: number;
96
- };
97
- 'subscriber-resub-session': {
98
- count: number;
99
- };
100
- 'subscriber-gifted-session': {
101
- count: number;
102
- };
103
- 'subscriber-week': {
104
- count: number;
105
- };
106
- 'subscriber-month': {
107
- count: number;
108
- };
109
- 'subscriber-goal': {
110
- amount: number;
111
- };
112
- 'subscriber-total': {
113
- count: number;
114
- };
115
- 'subscriber-points': {
116
- amount: number;
117
- };
118
- 'subscriber-alltime-gifter': {
119
- name: string;
120
- amount: number;
121
- };
122
- 'subscriber-recent': Session$Subscriber$Recent[];
123
- }
124
- interface Session$Host$Recent {
125
- name: string;
126
- amount: number;
127
- createdAt: string;
128
- }
129
- interface Session$Host {
130
- 'host-latest': {
131
- name: string;
132
- amount: number;
133
- };
134
- 'host-recent': Session$Host$Recent[];
135
- }
136
- interface Session$Raid$Recent {
137
- name: string;
138
- amount: number;
139
- createdAt: string;
140
- }
141
- interface Session$Raid {
142
- 'raid-latest': {
143
- name: string;
144
- amount: number;
145
- };
146
- 'raid-recent': Session$Raid$Recent[];
147
- }
148
- interface Session$CharityCampaignDonation$Recent {
149
- name: string;
150
- amount: number;
151
- createdAt: string;
152
- }
153
- interface Session$CharityCampaignDonation {
154
- 'charityCampaignDonation-latest': {
155
- name: string;
156
- amount: number;
157
- };
158
- 'charityCampaignDonation-session-top-donation': {
159
- name: string;
160
- amount: number;
161
- };
162
- 'charityCampaignDonation-weekly-top-donation': {
163
- name: string;
164
- amount: number;
165
- };
166
- 'charityCampaignDonation-monthly-top-donation': {
167
- name: string;
168
- amount: number;
169
- };
170
- 'charityCampaignDonation-alltime-top-donation': {
171
- name: string;
172
- amount: number;
173
- };
174
- 'charityCampaignDonation-session-top-donator': {
175
- name: string;
176
- amount: number;
177
- };
178
- 'charityCampaignDonation-weekly-top-donator': {
179
- name: string;
180
- amount: number;
181
- };
182
- 'charityCampaignDonation-monthly-top-donator': {
183
- name: string;
184
- amount: number;
185
- };
186
- 'charityCampaignDonation-alltime-top-donator': {
187
- name: string;
188
- amount: number;
189
- };
190
- 'charityCampaignDonation-recent': Session$CharityCampaignDonation$Recent[];
191
- }
192
- interface Session$Cheer$Recent {
193
- name: string;
194
- amount: number;
195
- createdAt: string;
196
- }
197
- interface Session$Cheer {
198
- 'cheer-latest': {
199
- name: string;
200
- amount: number;
201
- message: string;
202
- };
203
- 'cheer-session-top-donation': {
204
- name: string;
205
- amount: number;
206
- };
207
- 'cheer-weekly-top-donation': {
208
- name: string;
209
- amount: number;
210
- };
211
- 'cheer-monthly-top-donation': {
212
- name: string;
213
- amount: number;
214
- };
215
- 'cheer-alltime-top-donation': {
216
- name: string;
217
- amount: number;
218
- };
219
- 'cheer-session-top-donator': {
220
- name: string;
221
- amount: number;
222
- };
223
- 'cheer-weekly-top-donator': {
224
- name: string;
225
- amount: number;
226
- };
227
- 'cheer-monthly-top-donator': {
228
- name: string;
229
- amount: number;
230
- };
231
- 'cheer-alltime-top-donator': {
232
- name: string;
233
- amount: number;
234
- };
235
- 'cheer-session': {
236
- amount: number;
237
- };
238
- 'cheer-week': {
239
- amount: number;
240
- };
241
- 'cheer-month': {
242
- amount: number;
243
- };
244
- 'cheer-total': {
245
- amount: number;
246
- };
247
- 'cheer-count': {
248
- count: number;
249
- };
250
- 'cheer-goal': {
251
- amount: number;
252
- };
253
- 'cheer-recent': Session$Cheer$Recent[];
254
- }
255
- interface Session$CheerPurchase$Recent {
256
- name: string;
257
- amount: number;
258
- createdAt: string;
259
- }
260
- interface Session$CheerPurchase {
261
- 'cheerPurchase-latest': {
262
- name: string;
263
- amount: number;
264
- };
265
- 'cheerPurchase-session-top-donation': {
266
- name: string;
267
- amount: number;
268
- };
269
- 'cheerPurchase-weekly-top-donation': {
270
- name: string;
271
- amount: number;
272
- };
273
- 'cheerPurchase-monthly-top-donation': {
274
- name: string;
275
- amount: number;
276
- };
277
- 'cheerPurchase-alltime-top-donation': {
278
- name: string;
279
- amount: number;
280
- };
281
- 'cheerPurchase-session-top-donator': {
282
- name: string;
283
- amount: number;
284
- };
285
- 'cheerPurchase-weekly-top-donator': {
286
- name: string;
287
- amount: number;
288
- };
289
- 'cheerPurchase-monthly-top-donator': {
290
- name: string;
291
- amount: number;
292
- };
293
- 'cheerPurchase-alltime-top-donator': {
294
- name: string;
295
- amount: number;
296
- };
297
- 'cheerPurchase-recent': Session$CheerPurchase$Recent[];
298
- }
299
- interface Session$Superchat$Recent {
300
- name: string;
301
- amount: number;
302
- createdAt: string;
303
- }
304
- interface Session$Superchat {
305
- 'superchat-latest': {
306
- name: string;
307
- amount: number;
308
- };
309
- 'superchat-session-top-donation': {
310
- name: string;
311
- amount: number;
312
- };
313
- 'superchat-weekly-top-donation': {
314
- name: string;
315
- amount: number;
316
- };
317
- 'superchat-monthly-top-donation': {
318
- name: string;
319
- amount: number;
320
- };
321
- 'superchat-alltime-top-donation': {
322
- name: string;
323
- amount: number;
324
- };
325
- 'superchat-session-top-donator': {
326
- name: string;
327
- amount: number;
328
- };
329
- 'superchat-weekly-top-donator': {
330
- name: string;
331
- amount: number;
332
- };
333
- 'superchat-monthly-top-donator': {
334
- name: string;
335
- amount: number;
336
- };
337
- 'superchat-alltime-top-donator': {
338
- name: string;
339
- amount: number;
340
- };
341
- 'superchat-session': {
342
- amount: number;
343
- };
344
- 'superchat-week': {
345
- amount: number;
346
- };
347
- 'superchat-month': {
348
- amount: number;
349
- };
350
- 'superchat-total': {
351
- amount: number;
352
- };
353
- 'superchat-count': {
354
- count: number;
355
- };
356
- 'superchat-goal': {
357
- amount: number;
358
- };
359
- 'superchat-recent': Session$Superchat$Recent[];
360
- }
361
- interface Session$Hypetrain$TopContributor {
362
- name: string;
363
- }
364
- interface Session$Hypetrain {
365
- 'hypetrain-latest': {
366
- name: string;
367
- amount: number;
368
- active: number;
369
- level: any;
370
- levelChanged: any;
371
- type: any;
372
- };
373
- 'hypetrain-level-goal': {
374
- amount: number;
375
- };
376
- 'hypetrain-level-progress': {
377
- amount: number;
378
- percent: number;
379
- };
380
- 'hypetrain-total': {
381
- amount: number;
382
- };
383
- 'hypetrain-latest-top-contributors': Session$Hypetrain$TopContributor[];
384
- }
385
- interface Session$ChannelPoints {
386
- 'channel-points-latest': {
387
- name: string;
388
- amount: number;
389
- message: string;
390
- redemption: string;
391
- };
392
- }
393
- interface Session$Tip$Recent {
14
+ type SeventvEmote = {
15
+ type: '7tv';
394
16
  name: string;
395
- amount: number;
396
- createdAt: string;
397
- }
398
- interface Session$Tip {
399
- 'tip-latest': {
400
- name: string;
401
- amount: number;
402
- };
403
- 'tip-session-top-donation': {
404
- name: string;
405
- amount: number;
406
- };
407
- 'tip-weekly-top-donation': {
408
- name: string;
409
- amount: number;
410
- };
411
- 'tip-monthly-top-donation': {
412
- name: string;
413
- amount: number;
414
- };
415
- 'tip-alltime-top-donation': {
416
- name: string;
417
- amount: number;
418
- };
419
- 'tip-session-top-donator': {
420
- name: string;
421
- amount: number;
422
- };
423
- 'tip-weekly-top-donator': {
424
- name: string;
425
- amount: number;
426
- };
427
- 'tip-monthly-top-donator': {
428
- name: string;
429
- amount: number;
430
- };
431
- 'tip-alltime-top-donator': {
432
- name: string;
433
- amount: number;
434
- };
435
- 'tip-session': {
436
- amount: number;
437
- };
438
- 'tip-week': {
439
- amount: number;
440
- };
441
- 'tip-month': {
442
- amount: number;
443
- };
444
- 'tip-total': {
445
- amount: number;
446
- };
447
- 'tip-count': {
448
- count: number;
17
+ id: string;
18
+ gif: boolean;
19
+ animated: boolean;
20
+ urls: {
21
+ '1': string;
22
+ '2': string;
23
+ '3': string;
24
+ '4': string;
449
25
  };
450
- 'tip-goal': {
451
- amount: number;
26
+ start: number;
27
+ end: number;
28
+ cords: {
29
+ x: number;
30
+ y: number;
452
31
  };
453
- 'tip-recent': Session$Tip$Recent[];
454
- }
455
- interface Session$Merch$Recent {
32
+ };
33
+ type BttvEmote = {
34
+ type: 'bttv';
456
35
  name: string;
457
- }
458
- interface Session$Merch {
459
- 'merch-latest': {
460
- name: string;
461
- amount: number;
462
- items: any[];
463
- };
464
- 'merch-goal-orders': {
465
- amount: number;
466
- };
467
- 'merch-goal-items': {
468
- amount: number;
469
- };
470
- 'merch-goal-total': {
471
- amount: number;
36
+ id: string;
37
+ gif: boolean;
38
+ animated: boolean;
39
+ urls: {
40
+ '1': string;
41
+ '2': string;
42
+ '4': string;
472
43
  };
473
- 'merch-recent': Session$Merch$Recent[];
474
- }
475
- interface Session$Purchase {
476
- 'purchase-latest': {
477
- name: string;
478
- amount: number;
479
- items: any[];
480
- avatar: string;
481
- message: string;
44
+ start: number;
45
+ end: number;
46
+ coords: {
47
+ x: number;
48
+ y: number;
49
+ width: number;
50
+ height: number;
482
51
  };
483
- }
52
+ };
484
53
 
485
- type onWidgetLoadEvent = CustomEvent<onWidgetLoad>;
486
- type onWidgetLoad = {
487
- channel: {
488
- username: string;
54
+ declare namespace Twitch {
55
+ type IRC = {
56
+ /**
57
+ * Contains metadata related to the chat badges in the badges tag.
58
+ * Currently, this tag contains metadata only for subscriber badges, to indicate the number of months the user has been a subscriber.
59
+ * @example
60
+ * ```javascript
61
+ * 'subscriber/25'
62
+ * ```
63
+ */
64
+ 'badge-info': String;
489
65
  /**
490
- * The channel's streamelements api token (used to authenticate requests to the SE API)
66
+ * Comma-separated list of chat badges in the form, <badge>/<version>. For example admin/1. There are many possible badge values, but here are few: admin, bits, broadcaster, moderator, subscriber, staff, turbo
67
+ * Most badges have only 1 version, but some badges like subscriber badges offer different versions of the badge depending on how long the user has subscribed.
68
+ * @example
69
+ * ```javascript
70
+ * 'staff/1,bits/1000,partner/1'
71
+ * ```
491
72
  */
492
- apiToken: string;
73
+ 'badges': String;
493
74
  /**
494
- * The channel's unique identifier in the SE system
75
+ * The color of the user's name in the chat.
76
+ * @example
77
+ * ```javascript
78
+ * '#FF0000'
79
+ * ```
495
80
  */
496
- id: string;
81
+ 'color': string | undefined;
82
+ /**
83
+ * The user’s display name, escaped as described in the [IRCv3 spec](https://ircv3.net/specs/extensions/message-tags.html). This tag may be empty if it is never set.
84
+ * @example
85
+ * ```javascript
86
+ * 'TwitchUser'
87
+ * ```
88
+ */
89
+ 'display-name': String;
497
90
  /**
498
- * The channel's unique identifier from the provider (e.g. Twitch user ID)
91
+ * A comma-delimited list of IDs that identify the emote sets that the user has access to. Is always set to at least zero (0).
499
92
  */
500
- providerId: string;
501
- avatar: string;
502
- };
503
- currency: {
504
- code: string;
505
- name: string;
506
- symbol: string;
507
- };
508
- fieldData: Record<string, StreamElementsFieldValue>;
509
- recents: Array<Object>;
510
- session: {
511
- data: Session$1;
512
- settings: {
513
- autoReset: boolean;
514
- calendar: boolean;
515
- resetOnStart: boolean;
516
- };
517
- };
518
- overlay: {
93
+ 'emote-sets': String;
519
94
  /**
520
- * Whether the overlay is being viewed in the editor mode (in the SE dashboard) or live (on stream)
95
+ * A slash-delimited list of emotes and their positions in the message. Each emote is in the form, `<emote ID>:<ranges>`, where ranges are comma-delimited pairs of indices in the form `<start position>-<end position>`. The position indices are zero-based.
96
+ * NOTE: It’s possible for a message to begin with with `\001ACTION` when /me is used by a user in chat. In these cases emote positions should be considered to begin after `001ACTION `, which includes its succeeding whitespace.
97
+ * @example
98
+ * ```javascript
99
+ * '25:0-4,12-16/1902:6-10'
100
+ * ```
101
+ */
102
+ 'emotes': String;
103
+ 'flags': String;
104
+ /**
105
+ * A Boolean value that indicates whether the user has site-wide commercial free mode enabled. Is true (1) if enabled; otherwise, false (0).
106
+ */
107
+ 'turbo': 0 | 1;
108
+ /**
109
+ * The User ID of the relevant user.
110
+ * @example
111
+ * ```javascript
112
+ * '1337'
113
+ * ```
114
+ */
115
+ 'user-id': String;
116
+ /**
117
+ * The type of user. Possible values are:
118
+ * ```
119
+ * • "" - A normal user
120
+ * • admin - A Twitch administrator
121
+ * • global_mod - A global moderator
122
+ * • staff - A Twitch employee
123
+ * ```
124
+ */
125
+ 'user-type': '' | 'admin' | 'global_mod' | 'staff';
126
+ /**
127
+ * The amount of Bits the user cheered. Only a Bits cheer message includes this tag.
128
+ */
129
+ 'bits': number;
130
+ /**
131
+ * A Boolean value that determines whether the user is a moderator. Is true (1) if the user is a moderator; otherwise, false (0).
132
+ */
133
+ 'mod': 0 | 1;
134
+ /**
135
+ * The ID of the message. In UUID format.
136
+ */
137
+ 'msg-id': string | undefined;
138
+ /**
139
+ * An ID that uniquely identifies the direct parent message that this message is replying to. The message does not include this tag if this message is not a reply.
140
+ */
141
+ 'reply-parent-msg-id': string | undefined;
142
+ /**
143
+ * An ID that identifies the sender of the direct parent message. The message does not include this tag if this message is not a reply.
144
+ */
145
+ 'reply-parent-user-id': string | undefined;
146
+ /**
147
+ * The login name of the sender of the direct parent message. The message does not include this tag if this message is not a reply.
148
+ */
149
+ 'reply-parent-user-login': string | undefined;
150
+ /**
151
+ * The display name of the sender of the direct parent message. The message does not include this tag if this message is not a reply.
152
+ */
153
+ 'reply-parent-display-name': string | undefined;
154
+ /**
155
+ * The text of the direct parent message. The message does not include this tag if this message is not a reply.
156
+ */
157
+ 'reply-parent-msg-body': string | undefined;
158
+ /**
159
+ * An ID that uniquely identifies the top-level parent message of the reply thread that this message is replying to. The message does not include this tag if this message is not a reply.
521
160
  */
522
- isEditorMode: boolean;
161
+ 'reply-thread-parent-msg-id': string | undefined;
523
162
  /**
524
- * Whether the overlay is muted or not
163
+ * The login name of the sender of the top-level parent message. The message does not include this tag if this message is not a reply.
525
164
  */
526
- muted: boolean;
165
+ 'reply-thread-parent-user-login': string | undefined;
166
+ /**
167
+ * An ID that identifies the chat room (channel).
168
+ */
169
+ 'room-id': String;
170
+ /**
171
+ * Comma-separated list of chat badges for the chatter in the room the message was sent from. This uses the same format as the `badges` tag.
172
+ */
173
+ 'source-badges': String;
174
+ /**
175
+ * Contains metadata related to the chat badges in the source-badges tag.
176
+ */
177
+ 'source-badge-info': String;
178
+ /**
179
+ * A UUID that identifies the source message from the channel the message was sent from.
180
+ */
181
+ 'source-id': String;
182
+ /**
183
+ * A Boolean that indicates if a message sent during a shared chat session is only sent to the source channel. Has no effect if the message is not sent during a shared chat session.
184
+ */
185
+ 'source-only': Boolean;
186
+ /**
187
+ * An ID that identifies the chat room (channel) the message was sent from.
188
+ */
189
+ 'source-room-id': String;
190
+ /**
191
+ * A Boolean value that determines whether the user is a subscriber. Is true (1) if the user is a subscriber; otherwise, false (0).
192
+ */
193
+ 'subscriber': 0 | 1;
194
+ /**
195
+ * The UNIX timestamp.
196
+ */
197
+ 'tmi-sent-ts': number;
198
+ /**
199
+ * A Boolean value that determines whether the user that sent the chat is a VIP. The message includes this tag if the user is a VIP; otherwise, the message doesn’t include this tag (check for the presence of the tag instead of whether the tag is set to true or false).
200
+ */
201
+ 'vip': undefined | '';
527
202
  };
528
- emulated?: boolean;
529
- };
530
-
531
- declare enum Alejo$Pronouns {
532
- hehim = "He/Him",
533
- sheher = "She/Her",
534
- theythem = "They/Them",
535
- shethem = "She/They",
536
- hethem = "He/They",
537
- heshe = "He/She",
538
- xexem = "Xe/Xem",
539
- faefaer = "Fae/Faer",
540
- vever = "Ve/Ver",
541
- aeaer = "Ae/Aer",
542
- ziehir = "Zie/Hir",
543
- perper = "Per/Per",
544
- eem = "E/Em",
545
- itits = "It/Its"
203
+ type badge = {
204
+ type: string;
205
+ version: string;
206
+ url: string;
207
+ description: string;
208
+ };
209
+ type roles = '100 bits' | 'no audio' | 'no video' | 'bot' | 'twitch staff' | 'admins' | 'artist' | 'game developer' | 'prime' | 'turbo' | 'subscriber' | 'broadcaster' | 'verified' | 'moderator' | 'vip';
546
210
  }
547
- type Alejo$Pronouns$name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
548
- type Alejo$Pronouns$display = 'He/Him' | 'She/Her' | 'They/Them' | 'She/They' | 'He/They' | 'He/She' | 'Xe/Xem' | 'Fae/Faer' | 'Ve/Ver' | 'Ae/Aer' | 'Zie/Hir' | 'Per/Per' | 'E/Em' | 'It/Its';
549
- type Alejo$Pronouns$User = {
550
- id: string;
551
- login: string;
552
- pronouns: Alejo$Pronouns$name;
553
- };
554
211
 
212
+ type Emote = TwitchEmote | BttvEmote | SeventvEmote;
555
213
  /**
556
- * EventProvider class for managing event listeners and emitters.
557
- * This class allows you to register event listeners, emit events, and manage event subscriptions.
558
- * @example
559
- * ```typescript
560
- * interface TestEvents {
561
- * load: [{ type: 'load' }];
562
- * event: [{ type: 'event' }];
563
- * }
564
- *
565
- * class Test extends EventProvider<TestEvents> {}
566
- *
567
- * const test = new Test();
568
- * test.on('load', (data) => {})
569
- * test.once('event', (data) => {})
570
- * test.emit('load', { type: 'load' });
214
+ * Finds emotes in a given text.
215
+ * @param text - The text to search for emotes.
216
+ * @param emotes - An array of emotes to search for. Defaults to Simulation data emotes.
217
+ * @returns An array of emotes found in the text with their positions.
218
+ */
219
+ declare function findEmotesInText(text: string, emotes?: Emote[]): Emote[];
220
+ /**
221
+ * Replaces emotes in the text with corresponding HTML image tags.
222
+ * @param text - The text containing emotes.
223
+ * @param emotes - An array of emotes with their positions in the text.
224
+ * @returns The text with emotes replaced by HTML image tags.
225
+ */
226
+ declare function replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
227
+ type TwitchResult = {
228
+ keys: Twitch.roles[];
229
+ badges: Twitch.badge[];
230
+ };
231
+ type YouTubeResult = {
232
+ isVerified: boolean;
233
+ isChatOwner: boolean;
234
+ isChatSponsor: boolean;
235
+ isChatModerator: boolean;
236
+ };
237
+ type BadgeOptions = Twitch.roles[] | Twitch.roles | `${Twitch.roles}, ${Twitch.roles}` | `${Twitch.roles}, ${Twitch.roles}, ${Twitch.roles}`;
238
+ /**
239
+ * Generates badge data based on the provided badges and platform.
240
+ * @param badges - The badges to generate. Can be an array or a comma-separated string.
241
+ * @param provider - The platform provider ('twitch' or 'youtube'). Defaults to 'twitch'.
242
+ * @returns A promise that resolves to the generated badge data.
243
+ * @example
244
+ * ```javascript
245
+ * // Generate Twitch badges
246
+ * const twitchBadges = await generateBadges(['broadcaster', 'moderator'], 'twitch');
247
+ * // Generate YouTube badges
248
+ * const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube');
571
249
  * ```
572
250
  */
573
- declare class EventProvider<EventMap extends Record<string, any[]> = Record<string, any[]>> {
574
- /**
575
- * Stores registered event listeners.
576
- */
577
- private registeredEvents;
578
- /**
579
- * Emits an event to all registered listeners.
580
- * Returns an array of return values from the listeners.
581
- * @param eventName The name of the event.
582
- * @param args Arguments to pass to the listeners.
583
- */
584
- emit<K extends keyof EventMap>(eventName: K, ...args: EventMap[K]): any[];
585
- /**
586
- * Registers an event listener.
587
- * @param eventName The name of the event.
588
- * @param callback The callback function.
589
- */
590
- on<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
591
- /**
592
- * Removes a specific event listener.
593
- * @param eventName The name of the event.
594
- * @param callback The callback function to remove.
595
- */
596
- off<K extends keyof EventMap>(eventName: K, callback?: (this: this, ...args: EventMap[K]) => any): this;
597
- /**
598
- * Registers a listener that is executed only once.
599
- * @param eventName The name of the event.
600
- * @param callback The callback function.
601
- */
602
- once<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
603
- /**
604
- * Removes all listeners for a specific event.
605
- * @param eventName The name of the event.
606
- */
607
- removeAllListeners<K extends keyof EventMap>(eventName: K): this;
251
+ declare function generateBadges(badges: BadgeOptions, provider: 'youtube'): Promise<YouTubeResult>;
252
+ declare function generateBadges(badges: BadgeOptions, provider: 'twitch'): Promise<TwitchResult>;
253
+
254
+ declare namespace StreamElementsEvents {
255
+ namespace Tip {
256
+ type Data = {
257
+ listener: 'tip-latest';
258
+ event: Event;
259
+ };
260
+ type Event = {
261
+ amount: number;
262
+ avatar: string;
263
+ name: string;
264
+ displayName: string;
265
+ providerId: string;
266
+ _id: string;
267
+ sessionTop: boolean;
268
+ type: 'tip';
269
+ originalEventName: 'tip-latest';
270
+ };
271
+ }
272
+ namespace KVStore {
273
+ type Data = {
274
+ listener: 'kvstore:update';
275
+ event: Event;
276
+ };
277
+ type Event = {
278
+ data: {
279
+ key: `customWidget.${string}`;
280
+ value: string | number | boolean | Record<string, any>;
281
+ };
282
+ };
283
+ }
284
+ namespace BotCounter {
285
+ type Data = {
286
+ listener: 'bot:counter';
287
+ event: Event;
288
+ };
289
+ type Event = {
290
+ counter: string;
291
+ value: number;
292
+ };
293
+ }
294
+ namespace AlertService {
295
+ type Data = {
296
+ listener: 'alertService:toggleSound';
297
+ event: Event;
298
+ };
299
+ type Event = {
300
+ muted: boolean;
301
+ };
302
+ }
303
+ namespace EventSkip {
304
+ type Data = {
305
+ listener: 'event:skip';
306
+ event: Event;
307
+ };
308
+ type Event = {};
309
+ }
310
+ namespace EventTest {
311
+ export type Data = {
312
+ listener: 'event:test';
313
+ event: Event;
314
+ };
315
+ export type Event = widgetButton | emulatedEvents<EventType> | Session;
316
+ type items = {
317
+ name: string;
318
+ price: number;
319
+ quantity: number;
320
+ };
321
+ type widgetButton = {
322
+ listener: 'widget-button';
323
+ field: string;
324
+ value: string | number | boolean;
325
+ };
326
+ type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid';
327
+ type EventTier = 'prime' | '1000' | '2000' | '3000';
328
+ type emulatedEvents<T extends EventType> = {
329
+ listener: `${T}-latest`;
330
+ event: {
331
+ type: T;
332
+ name: string;
333
+ amount: number;
334
+ count: number;
335
+ message?: string;
336
+ gifted?: boolean;
337
+ bulkGifted?: boolean;
338
+ sender?: string;
339
+ subExtension?: boolean;
340
+ items: items[];
341
+ tier: EventTier;
342
+ month: string;
343
+ isTest: true;
344
+ };
345
+ };
346
+ type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints;
347
+ type SessionCount = {
348
+ listener: `${EventType}-count`;
349
+ event: {
350
+ type: EventType;
351
+ name: string;
352
+ count: number;
353
+ items: items[];
354
+ tier: EventTier;
355
+ month: string;
356
+ isTest: true;
357
+ };
358
+ };
359
+ type SessionTotal = {
360
+ listener: `${EventType}-total`;
361
+ event: {
362
+ type: EventType;
363
+ name: string;
364
+ amount: number;
365
+ count: number;
366
+ items: items[];
367
+ tier: EventTier;
368
+ month: string;
369
+ isTest: true;
370
+ };
371
+ };
372
+ type SessionTop = {
373
+ listener: `${EventType}-top`;
374
+ event: {
375
+ type: EventType;
376
+ name: string;
377
+ amount: number;
378
+ count: number;
379
+ items: items[];
380
+ tier: EventTier;
381
+ month: string;
382
+ isTest: true;
383
+ };
384
+ };
385
+ type SessionGoal = {
386
+ listener: `${EventType}-goal`;
387
+ event: {
388
+ type: EventType;
389
+ name: string;
390
+ amount: number;
391
+ count: number;
392
+ items: items[];
393
+ tier: EventTier;
394
+ month: string;
395
+ isTest: true;
396
+ };
397
+ };
398
+ type SessionRecent = {
399
+ listener: `${EventType}-recent`;
400
+ event: {
401
+ event: SessionRecentEvent[];
402
+ };
403
+ };
404
+ type SessionRecentEvent = {
405
+ type: EventType;
406
+ name: string;
407
+ amount: number;
408
+ count: number;
409
+ tier: EventTier;
410
+ isTest: true;
411
+ };
412
+ type SessionPoints = {
413
+ listener: `${EventType}-points`;
414
+ event: {
415
+ type: EventType;
416
+ name: string;
417
+ amount: number;
418
+ count: number;
419
+ items: items[];
420
+ tier: EventTier;
421
+ month: string;
422
+ isTest: true;
423
+ };
424
+ };
425
+ export {};
426
+ }
608
427
  }
609
428
 
610
- type SE_API = {
611
- responses: Record<string, any>;
612
- sendMessage: (message: string, data: object) => void;
613
- counters: {
614
- get: (key: string) => number | null;
615
- };
616
- store: {
617
- get: <T>(key: string) => Promise<T | null>;
618
- set: <T>(key: string, value: T) => void;
619
- };
620
- resumeQueue: () => void;
621
- sanitize: (message: string) => string;
622
- cheerFilter: (message: string) => string;
623
- setField: (key: string, value: string | number | boolean | undefined, reload: boolean) => void;
624
- getOverlayStatus: () => {
625
- isEditorMode: boolean;
626
- muted: boolean;
627
- };
628
- };
429
+ declare namespace YoutubeEvents {
430
+ namespace Message {
431
+ export type Data = {
432
+ listener: 'message';
433
+ event: Event;
434
+ };
435
+ export type Event = {
436
+ service: 'youtube';
437
+ data: {
438
+ kind: string;
439
+ etag: string;
440
+ id: string;
441
+ snippet: {
442
+ type: string;
443
+ liveChatId: string;
444
+ authorChannelId: string;
445
+ publishedAt: string;
446
+ hasDisplayContent: boolean;
447
+ displayMessage: string;
448
+ textMessageDetails: {
449
+ messageText: string;
450
+ };
451
+ };
452
+ authorDetails: {
453
+ channelId: string;
454
+ channelUrl: string;
455
+ displayName: string;
456
+ profileImageUrl: string;
457
+ isVerified: boolean;
458
+ isChatOwner: boolean;
459
+ isChatSponsor: boolean;
460
+ isChatModerator: boolean;
461
+ };
462
+ msgId: string;
463
+ userId: string;
464
+ nick: string;
465
+ badges: Array<Badges>;
466
+ displayName: string;
467
+ isAction: boolean;
468
+ time: number;
469
+ tags: Array<Tags>;
470
+ displayColor: string | null;
471
+ channel: string;
472
+ text: string;
473
+ avatar: string;
474
+ emotes: Array<Emotes>;
475
+ };
476
+ renderedText: string;
477
+ };
478
+ type Badges = {};
479
+ type Tags = {};
480
+ type Emotes = {};
481
+ export {};
482
+ }
483
+ namespace Superchat {
484
+ type Data = {
485
+ listener: 'superchat-latest';
486
+ event: Event;
487
+ };
488
+ type Event = {
489
+ amount: number;
490
+ avatar: string;
491
+ displayName: string;
492
+ providerId: string;
493
+ name: string;
494
+ _id: string;
495
+ sessionTop: boolean;
496
+ type: 'superchat';
497
+ originalEventName: 'superchat-latest';
498
+ };
499
+ }
500
+ namespace Subscriber {
501
+ type Data = {
502
+ listener: 'subscriber-latest';
503
+ event: Event;
504
+ };
505
+ type Event = {
506
+ avatar: string;
507
+ displayName: string;
508
+ providerId: string;
509
+ name: string;
510
+ _id: string;
511
+ sessionTop: boolean;
512
+ type: 'subscriber';
513
+ originalEventName: 'subscriber-latest';
514
+ };
515
+ }
516
+ namespace Sponsor {
517
+ type Data = {
518
+ listener: 'sponsor-latest';
519
+ event: Event;
520
+ };
521
+ type Event = common & (normal | gift | community | spam);
522
+ type common = {
523
+ amount: number;
524
+ name: string;
525
+ displayName: string;
526
+ message?: string;
527
+ providerId?: string;
528
+ avatar?: string;
529
+ sender?: string;
530
+ gifted?: boolean;
531
+ bulkGifted?: boolean;
532
+ isCommunityGift?: boolean;
533
+ _id?: string;
534
+ sessionTop?: boolean;
535
+ playedAsCommunityGift?: boolean;
536
+ type: 'sponsor';
537
+ originalEventName: 'sponsor-latest';
538
+ };
539
+ type normal = {
540
+ sender?: undefined;
541
+ gifted?: false;
542
+ bulkGifted?: false;
543
+ isCommunityGift?: false;
544
+ };
545
+ type gift = {
546
+ sender: string;
547
+ gifted: true;
548
+ bulkGifted?: false;
549
+ isCommunityGift?: false;
550
+ };
551
+ type community = {
552
+ message: string;
553
+ sender: string;
554
+ gifted?: false;
555
+ bulkGifted: true;
556
+ isCommunityGift?: false;
557
+ };
558
+ type spam = {
559
+ sender: string;
560
+ gifted: true;
561
+ bulkGifted?: false;
562
+ isCommunityGift: true;
563
+ };
564
+ }
565
+ }
629
566
 
630
567
  type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue<T[K], Rest> : never : P extends keyof T ? T[P] : never;
631
568
  type NumberAsString<T extends number | bigint | string> = ReturnType<T['toString']>;
@@ -633,920 +570,1021 @@ type MapNumberValuesToString<T> = {
633
570
  [K in keyof T]: T[K] extends number ? NumberAsString<T[K]> : T[K];
634
571
  };
635
572
 
636
- type UseStorageEvents<T> = {
637
- load: [T | null];
638
- update: [T];
639
- };
640
- type UseStorageOptions<T> = {
641
- id?: string;
642
- data: T;
643
- };
644
- declare class useStorage<T extends object = Record<string, any>> extends EventProvider<UseStorageEvents<T>> {
645
- /**
646
- * The unique identifier for the storage instance.
647
- */
648
- id: string;
649
- loaded: boolean;
650
- data: T;
651
- constructor(options: UseStorageOptions<T>);
652
- SE_API: SE_API | null;
653
- private start;
654
- /**
655
- * Saves the current data to storage.
656
- * @param data Data to save (defaults to current)
657
- */
658
- private save;
659
- /**
660
- * Updates the storage data and emits an update event
661
- * @param data Data to update (defaults to current)
662
- */
663
- update(data?: T): void;
664
- /**
665
- * Adds a value to the storage at the specified path.
666
- * @param path Path to add the value to
667
- * @param value Value to add
668
- */
669
- add<P extends string>(path: P, value: PathValue<T, P>): void;
670
- /**
671
- * Clears all data from the storage.
672
- */
673
- clear(): void;
674
- /**
675
- * Sets a value in the storage at the specified path.
676
- * @param obj The object to set the value in
677
- * @param path The path to set the value at
678
- * @param value The value to set
679
- * @returns The updated object
680
- */
681
- static setByPath<P extends string, T extends object>(obj: T, path: P, value: PathValue<T, P>): void;
682
- on<K extends keyof UseStorageEvents<T>>(eventName: K, callback: (this: useStorage<T>, ...args: UseStorageEvents<T>[K]) => void): this;
573
+ declare namespace TwitchEvents {
574
+ namespace Message {
575
+ export type Data = {
576
+ listener: 'message';
577
+ event: Event;
578
+ };
579
+ export type Event = {
580
+ service: 'twitch';
581
+ data: {
582
+ time: number;
583
+ tags: Partial<MapNumberValuesToString<Twitch.IRC>> & {
584
+ 'client-nonce': string;
585
+ 'flags': string;
586
+ 'id': string;
587
+ 'first-msg': '1' | '0';
588
+ 'returning-chatter': '1' | '0';
589
+ };
590
+ nick: string;
591
+ displayName: string;
592
+ displayColor: string;
593
+ channel: string;
594
+ text: string;
595
+ isAction: boolean;
596
+ userId: string;
597
+ msgId: string;
598
+ badges: Array<Badge>;
599
+ emotes: Array<Emote>;
600
+ };
601
+ renderedText: string;
602
+ };
603
+ type Badge = {
604
+ type: string;
605
+ version: string;
606
+ description: string;
607
+ url: string;
608
+ };
609
+ type Emote = {
610
+ type: string;
611
+ name: string;
612
+ id: string;
613
+ gif: boolean;
614
+ urls: {
615
+ '1': string;
616
+ '2': string;
617
+ '4': string;
618
+ };
619
+ start: number;
620
+ end: number;
621
+ };
622
+ export {};
623
+ }
624
+ namespace DeleteMessage {
625
+ type Data = {
626
+ listener: 'delete-message';
627
+ event: Event;
628
+ };
629
+ type Event = {
630
+ msgId: string;
631
+ };
632
+ }
633
+ namespace DeleteMessages {
634
+ type Data = {
635
+ listener: 'delete-messages';
636
+ event: Event;
637
+ };
638
+ type Event = {
639
+ userId: string;
640
+ };
641
+ }
642
+ namespace Follower {
643
+ type Data = {
644
+ listener: 'follower-latest';
645
+ event: Event;
646
+ };
647
+ type Event = {
648
+ avatar: string;
649
+ name: string;
650
+ displayName: string;
651
+ providerId: string;
652
+ _id: string;
653
+ sessionTop: boolean;
654
+ type: 'follower';
655
+ originalEventName: 'follower-latest';
656
+ };
657
+ }
658
+ namespace Cheer {
659
+ type Data = {
660
+ listener: 'cheer-latest';
661
+ event: Event;
662
+ };
663
+ type Event = {
664
+ amount: number;
665
+ avatar: string;
666
+ name: string;
667
+ displayName: string;
668
+ providerId: string;
669
+ message: string;
670
+ _id: string;
671
+ sessionTop: boolean;
672
+ type: 'cheer';
673
+ originalEventName: 'cheer-latest';
674
+ };
675
+ }
676
+ namespace Raid {
677
+ type Data = {
678
+ listener: 'raid-latest';
679
+ event: Event;
680
+ };
681
+ type Event = {
682
+ amount: number;
683
+ avatar: string;
684
+ displayName: string;
685
+ providerId: string;
686
+ name: string;
687
+ _id: string;
688
+ sessionTop: boolean;
689
+ type: 'raid';
690
+ originalEventName: 'raid-latest';
691
+ };
692
+ }
693
+ namespace Subscriber {
694
+ export type Data = {
695
+ listener: 'subscriber-latest';
696
+ event: Event;
697
+ };
698
+ export type Event = common & (normal | gift | community | spam);
699
+ type common = {
700
+ amount: number;
701
+ name: string;
702
+ displayName: string;
703
+ message?: string;
704
+ providerId?: string;
705
+ avatar?: string;
706
+ sender?: string;
707
+ gifted?: boolean;
708
+ bulkGifted?: boolean;
709
+ isCommunityGift?: boolean;
710
+ _id?: string;
711
+ sessionTop?: boolean;
712
+ playedAsCommunityGift?: boolean;
713
+ type: 'subscriber';
714
+ originalEventName: 'subscriber-latest';
715
+ };
716
+ export type normal = {
717
+ sender?: undefined;
718
+ gifted?: false;
719
+ bulkGifted?: false;
720
+ isCommunityGift?: false;
721
+ };
722
+ export type gift = {
723
+ sender: string;
724
+ gifted: true;
725
+ bulkGifted?: false;
726
+ isCommunityGift?: false;
727
+ };
728
+ export type community = {
729
+ message: string;
730
+ sender: string;
731
+ gifted?: false;
732
+ bulkGifted: true;
733
+ isCommunityGift?: false;
734
+ };
735
+ export type spam = {
736
+ sender: string;
737
+ gifted: true;
738
+ bulkGifted?: false;
739
+ isCommunityGift: true;
740
+ };
741
+ export {};
742
+ }
683
743
  }
684
744
 
685
- type StreamElements$AlertService = {
686
- listener: 'alertService:toggleSound';
687
- event: toggleSound;
688
- };
689
- type toggleSound = {
690
- muted: boolean;
691
- };
692
-
693
- type StreamElements$BotCounter = {
694
- listener: 'bot:counter';
695
- event: BotCounter;
696
- };
697
- type BotCounter = {
698
- counter: string;
699
- value: number;
700
- };
701
-
702
- type StreamElements$EventSkip = {
703
- listener: 'event:skip';
704
- event: EventSkip;
705
- };
706
- type EventSkip = {};
707
-
708
- type StreamElements$EventTest = {
709
- listener: 'event:test';
710
- event: EventTest;
711
- };
712
- type EventTest = widgetButton | emulatedEvents<EventType> | Session;
713
- type items = {
714
- name: string;
715
- price: number;
716
- quantity: number;
717
- };
718
- type widgetButton = {
719
- listener: 'widget-button';
720
- field: string;
721
- value: string | number | boolean;
722
- };
723
- type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid';
724
- type EventTier = 'prime' | '1000' | '2000' | '3000';
725
- type emulatedEvents<T extends EventType> = {
726
- listener: `${T}-latest`;
727
- event: {
728
- type: T;
729
- name: string;
730
- amount: number;
731
- count: number;
732
- message?: string;
733
- gifted?: boolean;
734
- bulkGifted?: boolean;
735
- sender?: string;
736
- subExtension?: boolean;
737
- items: items[];
738
- tier: EventTier;
739
- month: string;
740
- isTest: true;
741
- };
742
- };
743
- type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints;
744
- type SessionCount = {
745
- listener: `${EventType}-count`;
746
- event: {
747
- type: EventType;
748
- name: string;
749
- count: number;
750
- items: items[];
751
- tier: EventTier;
752
- month: string;
753
- isTest: true;
754
- };
755
- };
756
- type SessionTotal = {
757
- listener: `${EventType}-total`;
758
- event: {
759
- type: EventType;
760
- name: string;
761
- amount: number;
762
- count: number;
763
- items: items[];
764
- tier: EventTier;
765
- month: string;
766
- isTest: true;
767
- };
768
- };
769
- type SessionTop = {
770
- listener: `${EventType}-top`;
771
- event: {
772
- type: EventType;
773
- name: string;
774
- amount: number;
775
- count: number;
776
- items: items[];
777
- tier: EventTier;
778
- month: string;
779
- isTest: true;
780
- };
781
- };
782
- type SessionGoal = {
783
- listener: `${EventType}-goal`;
784
- event: {
785
- type: EventType;
786
- name: string;
787
- amount: number;
788
- count: number;
789
- items: items[];
790
- tier: EventTier;
791
- month: string;
792
- isTest: true;
793
- };
794
- };
795
- type SessionRecent = {
796
- listener: `${EventType}-recent`;
797
- event: {
798
- event: SessionRecentEvent[];
799
- };
800
- };
801
- type SessionRecentEvent = {
802
- type: EventType;
803
- name: string;
804
- amount: number;
805
- count: number;
806
- tier: EventTier;
807
- isTest: true;
808
- };
809
- type SessionPoints = {
810
- listener: `${EventType}-points`;
811
- event: {
812
- type: EventType;
813
- name: string;
814
- amount: number;
815
- count: number;
816
- items: items[];
817
- tier: EventTier;
818
- month: string;
819
- isTest: true;
820
- };
821
- };
822
-
823
- type StreamElements$KVStore = {
824
- listener: 'kvstore:update';
825
- event: KVStore;
826
- };
827
- type KVStore = {
828
- data: {
829
- key: `customWidget.${string}`;
830
- value: string | number | boolean | Record<string, any>;
745
+ declare namespace StreamElements {
746
+ namespace CustomField {
747
+ type Types = 'button' | 'number' | 'slider' | 'text' | 'hidden' | 'checkbox' | 'dropdown' | 'colorpicker' | 'googleFont' | 'video-input' | 'image-input' | 'sound-input';
748
+ type Schema = {
749
+ type: Types;
750
+ label: string;
751
+ value?: string | number | boolean;
752
+ group?: string;
753
+ min?: number | string;
754
+ max?: number | string;
755
+ step?: number | string;
756
+ options?: Record<string, string>;
757
+ multiple?: boolean;
758
+ };
759
+ type Value = string | number | boolean | undefined;
760
+ }
761
+ type SE_API = {
762
+ responses: Record<string, any>;
763
+ sendMessage: (message: string, data: object) => void;
764
+ counters: {
765
+ get: (key: string) => number | null;
766
+ };
767
+ store: {
768
+ get: <T>(key: string) => Promise<T | null>;
769
+ set: <T>(key: string, value: T) => void;
770
+ };
771
+ resumeQueue: () => void;
772
+ sanitize: (message: string) => string;
773
+ cheerFilter: (message: string) => string;
774
+ setField: (key: string, value: string | number | boolean | undefined, reload: boolean) => void;
775
+ getOverlayStatus: () => {
776
+ isEditorMode: boolean;
777
+ muted: boolean;
778
+ };
831
779
  };
832
- };
833
-
834
- type StreamElements$Tip = {
835
- listener: 'tip-latest';
836
- event: Tip;
837
- };
838
- type Tip = {
839
- amount: number;
840
- avatar: string;
841
- name: string;
842
- displayName: string;
843
- providerId: string;
844
- _id: string;
845
- sessionTop: boolean;
846
- type: 'tip';
847
- originalEventName: 'tip-latest';
848
- };
849
-
850
- type StreamElements = StreamElements$Tip | StreamElements$KVStore | StreamElements$BotCounter | StreamElements$AlertService | StreamElements$EventSkip | StreamElements$EventTest;
851
-
852
- type Twitch$Cheer = {
853
- listener: 'cheer-latest';
854
- event: Cheer;
855
- };
856
- type Cheer = {
857
- amount: number;
858
- avatar: string;
859
- name: string;
860
- displayName: string;
861
- providerId: string;
862
- message: string;
863
- _id: string;
864
- sessionTop: boolean;
865
- type: 'cheer';
866
- originalEventName: 'cheer-latest';
867
- };
868
-
869
- type Twitch$Follower = {
870
- listener: 'follower-latest';
871
- event: Follower;
872
- };
873
- type Follower = {
874
- avatar: string;
875
- name: string;
876
- displayName: string;
877
- providerId: string;
878
- _id: string;
879
- sessionTop: boolean;
880
- type: 'follower';
881
- originalEventName: 'follower-latest';
882
- };
883
-
884
- type Twitch$IRC = {
885
- /**
886
- * Contains metadata related to the chat badges in the badges tag.
887
- * Currently, this tag contains metadata only for subscriber badges, to indicate the number of months the user has been a subscriber.
888
- * @example
889
- * ```javascript
890
- * 'subscriber/25'
891
- * ```
892
- */
893
- 'badge-info': String;
894
- /**
895
- * Comma-separated list of chat badges in the form, <badge>/<version>. For example admin/1. There are many possible badge values, but here are few: admin, bits, broadcaster, moderator, subscriber, staff, turbo
896
- * Most badges have only 1 version, but some badges like subscriber badges offer different versions of the badge depending on how long the user has subscribed.
897
- * @example
898
- * ```javascript
899
- * 'staff/1,bits/1000,partner/1'
900
- * ```
901
- */
902
- 'badges': String;
903
- /**
904
- * The color of the user's name in the chat.
905
- * @example
906
- * ```javascript
907
- * '#FF0000'
908
- * ```
909
- */
910
- 'color': string | undefined;
911
- /**
912
- * The user’s display name, escaped as described in the [IRCv3 spec](https://ircv3.net/specs/extensions/message-tags.html). This tag may be empty if it is never set.
913
- * @example
914
- * ```javascript
915
- * 'TwitchUser'
916
- * ```
917
- */
918
- 'display-name': String;
919
- /**
920
- * A comma-delimited list of IDs that identify the emote sets that the user has access to. Is always set to at least zero (0).
921
- */
922
- 'emote-sets': String;
923
- /**
924
- * A slash-delimited list of emotes and their positions in the message. Each emote is in the form, `<emote ID>:<ranges>`, where ranges are comma-delimited pairs of indices in the form `<start position>-<end position>`. The position indices are zero-based.
925
- * NOTE: It’s possible for a message to begin with with `\001ACTION` when /me is used by a user in chat. In these cases emote positions should be considered to begin after `001ACTION `, which includes its succeeding whitespace.
926
- * @example
927
- * ```javascript
928
- * '25:0-4,12-16/1902:6-10'
929
- * ```
930
- */
931
- 'emotes': String;
932
- 'flags': String;
933
- /**
934
- * A Boolean value that indicates whether the user has site-wide commercial free mode enabled. Is true (1) if enabled; otherwise, false (0).
935
- */
936
- 'turbo': 0 | 1;
937
- /**
938
- * The User ID of the relevant user.
939
- * @example
940
- * ```javascript
941
- * '1337'
942
- * ```
943
- */
944
- 'user-id': String;
945
- /**
946
- * The type of user. Possible values are:
947
- * ```
948
- * • "" - A normal user
949
- * • admin - A Twitch administrator
950
- * • global_mod - A global moderator
951
- * • staff - A Twitch employee
952
- * ```
953
- */
954
- 'user-type': '' | 'admin' | 'global_mod' | 'staff';
955
- /**
956
- * The amount of Bits the user cheered. Only a Bits cheer message includes this tag.
957
- */
958
- 'bits': number;
959
- /**
960
- * A Boolean value that determines whether the user is a moderator. Is true (1) if the user is a moderator; otherwise, false (0).
961
- */
962
- 'mod': 0 | 1;
963
- /**
964
- * The ID of the message. In UUID format.
965
- */
966
- 'msg-id': string | undefined;
967
- /**
968
- * An ID that uniquely identifies the direct parent message that this message is replying to. The message does not include this tag if this message is not a reply.
969
- */
970
- 'reply-parent-msg-id': string | undefined;
971
- /**
972
- * An ID that identifies the sender of the direct parent message. The message does not include this tag if this message is not a reply.
973
- */
974
- 'reply-parent-user-id': string | undefined;
975
- /**
976
- * The login name of the sender of the direct parent message. The message does not include this tag if this message is not a reply.
977
- */
978
- 'reply-parent-user-login': string | undefined;
979
- /**
980
- * The display name of the sender of the direct parent message. The message does not include this tag if this message is not a reply.
981
- */
982
- 'reply-parent-display-name': string | undefined;
983
- /**
984
- * The text of the direct parent message. The message does not include this tag if this message is not a reply.
985
- */
986
- 'reply-parent-msg-body': string | undefined;
987
- /**
988
- * An ID that uniquely identifies the top-level parent message of the reply thread that this message is replying to. The message does not include this tag if this message is not a reply.
989
- */
990
- 'reply-thread-parent-msg-id': string | undefined;
991
- /**
992
- * The login name of the sender of the top-level parent message. The message does not include this tag if this message is not a reply.
993
- */
994
- 'reply-thread-parent-user-login': string | undefined;
995
- /**
996
- * An ID that identifies the chat room (channel).
997
- */
998
- 'room-id': String;
999
- /**
1000
- * Comma-separated list of chat badges for the chatter in the room the message was sent from. This uses the same format as the `badges` tag.
1001
- */
1002
- 'source-badges': String;
1003
- /**
1004
- * Contains metadata related to the chat badges in the source-badges tag.
1005
- */
1006
- 'source-badge-info': String;
1007
- /**
1008
- * A UUID that identifies the source message from the channel the message was sent from.
1009
- */
1010
- 'source-id': String;
1011
- /**
1012
- * A Boolean that indicates if a message sent during a shared chat session is only sent to the source channel. Has no effect if the message is not sent during a shared chat session.
1013
- */
1014
- 'source-only': Boolean;
1015
- /**
1016
- * An ID that identifies the chat room (channel) the message was sent from.
1017
- */
1018
- 'source-room-id': String;
1019
- /**
1020
- * A Boolean value that determines whether the user is a subscriber. Is true (1) if the user is a subscriber; otherwise, false (0).
1021
- */
1022
- 'subscriber': 0 | 1;
1023
- /**
1024
- * The UNIX timestamp.
1025
- */
1026
- 'tmi-sent-ts': number;
1027
- /**
1028
- * A Boolean value that determines whether the user that sent the chat is a VIP. The message includes this tag if the user is a VIP; otherwise, the message doesn’t include this tag (check for the presence of the tag instead of whether the tag is set to true or false).
1029
- */
1030
- 'vip': undefined | '';
1031
- };
1032
-
1033
- type Twitch$DeleteMessage = {
1034
- listener: 'delete-message';
1035
- event: {
1036
- msgId: string;
1037
- };
1038
- };
1039
- type Twitch$DeleteMessages = {
1040
- listener: 'delete-messages';
1041
- event: {
1042
- userId: string;
1043
- };
1044
- };
1045
-
1046
- type Twitch$Message = {
1047
- listener: 'message';
1048
- event: Message;
1049
- };
1050
- type Message = {
1051
- service: 'twitch';
1052
- data: {
1053
- time: number;
1054
- tags: Partial<MapNumberValuesToString<Twitch$IRC>> & {
1055
- 'client-nonce': string;
1056
- 'flags': string;
1057
- 'id': string;
1058
- 'first-msg': '1' | '0';
1059
- 'returning-chatter': '1' | '0';
1060
- };
1061
- nick: string;
1062
- displayName: string;
1063
- displayColor: string;
1064
- channel: string;
1065
- text: string;
1066
- isAction: boolean;
1067
- userId: string;
1068
- msgId: string;
1069
- badges: Array<Message$Badge>;
1070
- emotes: Array<Message$Emote>;
1071
- };
1072
- renderedText: string;
1073
- };
1074
- type Message$Badge = {
1075
- type: string;
1076
- version: string;
1077
- description: string;
1078
- url: string;
1079
- };
1080
- type Message$Emote = {
1081
- type: string;
1082
- name: string;
1083
- id: string;
1084
- gif: boolean;
1085
- urls: {
1086
- '1': string;
1087
- '2': string;
1088
- '4': string;
1089
- };
1090
- start: number;
1091
- end: number;
1092
- };
1093
-
1094
- type Twitch$Raid = {
1095
- listener: 'raid-latest';
1096
- event: Raid;
1097
- };
1098
- type Raid = {
1099
- amount: number;
1100
- avatar: string;
1101
- displayName: string;
1102
- providerId: string;
1103
- name: string;
1104
- _id: string;
1105
- sessionTop: boolean;
1106
- type: 'raid';
1107
- originalEventName: 'raid-latest';
1108
- };
1109
-
1110
- type Twitch$Subscriber = {
1111
- listener: 'subscriber-latest';
1112
- event: Subscriber$1;
1113
- };
1114
- type Subscriber$1 = Subscriber$default & (Subscriber$normal | Subscriber$gift | Subscriber$community | Subscriber$spam);
1115
- type Subscriber$default = {
1116
- amount: number;
1117
- name: string;
1118
- displayName: string;
1119
- message?: string;
1120
- providerId?: string;
1121
- avatar?: string;
1122
- sender?: string;
1123
- gifted?: boolean;
1124
- bulkGifted?: boolean;
1125
- isCommunityGift?: boolean;
1126
- _id?: string;
1127
- sessionTop?: boolean;
1128
- playedAsCommunityGift?: boolean;
1129
- type: 'subscriber';
1130
- originalEventName: 'subscriber-latest';
1131
- };
1132
- type Subscriber$normal = {
1133
- sender?: undefined;
1134
- gifted?: false;
1135
- bulkGifted?: false;
1136
- isCommunityGift?: false;
1137
- };
1138
- type Subscriber$gift = {
1139
- sender: string;
1140
- gifted: true;
1141
- bulkGifted?: false;
1142
- isCommunityGift?: false;
1143
- };
1144
- type Subscriber$community = {
1145
- message: string;
1146
- sender: string;
1147
- gifted?: false;
1148
- bulkGifted: true;
1149
- isCommunityGift?: false;
1150
- };
1151
- type Subscriber$spam = {
1152
- sender: string;
1153
- gifted: true;
1154
- bulkGifted?: false;
1155
- isCommunityGift: true;
1156
- };
1157
-
1158
- type Twitch = Twitch$Message | Twitch$DeleteMessage | Twitch$DeleteMessages | Twitch$Follower | Twitch$Cheer | Twitch$Raid | Twitch$Subscriber;
1159
-
1160
- type Youtube$Message = {
1161
- listener: 'message';
1162
- event: YTMessage;
1163
- };
1164
- type YTMessage = {
1165
- service: 'youtube';
1166
- data: {
1167
- kind: string;
1168
- etag: string;
1169
- id: string;
1170
- snippet: {
1171
- type: string;
1172
- liveChatId: string;
1173
- authorChannelId: string;
1174
- publishedAt: string;
1175
- hasDisplayContent: boolean;
1176
- displayMessage: string;
1177
- textMessageDetails: {
1178
- messageText: string;
1179
- };
1180
- };
1181
- authorDetails: {
1182
- channelId: string;
1183
- channelUrl: string;
1184
- displayName: string;
1185
- profileImageUrl: string;
1186
- isVerified: boolean;
1187
- isChatOwner: boolean;
1188
- isChatSponsor: boolean;
1189
- isChatModerator: boolean;
1190
- };
1191
- msgId: string;
1192
- userId: string;
1193
- nick: string;
1194
- badges: Array<Badges>;
1195
- displayName: string;
1196
- isAction: boolean;
1197
- time: number;
1198
- tags: Array<Tags>;
1199
- displayColor: string | null;
1200
- channel: string;
1201
- text: string;
1202
- avatar: string;
1203
- emotes: Array<Emotes>;
1204
- };
1205
- renderedText: string;
1206
- };
1207
- type Badges = {};
1208
- type Tags = {};
1209
- type Emotes = {};
1210
-
1211
- type Youtube$Sponsor = {
1212
- listener: 'sponsor-latest';
1213
- event: Sponsor;
1214
- };
1215
- type Sponsor = Sponsor$default & (Sponsor$normal | Sponsor$gift | Sponsor$community | Sponsor$spam);
1216
- type Sponsor$default = {
1217
- amount: number;
1218
- name: string;
1219
- displayName: string;
1220
- message?: string;
1221
- providerId?: string;
1222
- avatar?: string;
1223
- sender?: string;
1224
- gifted?: boolean;
1225
- bulkGifted?: boolean;
1226
- isCommunityGift?: boolean;
1227
- _id?: string;
1228
- sessionTop?: boolean;
1229
- playedAsCommunityGift?: boolean;
1230
- type: 'sponsor';
1231
- originalEventName: 'sponsor-latest';
1232
- };
1233
- type Sponsor$normal = {
1234
- sender?: undefined;
1235
- gifted?: false;
1236
- bulkGifted?: false;
1237
- isCommunityGift?: false;
1238
- };
1239
- type Sponsor$gift = {
1240
- sender: string;
1241
- gifted: true;
1242
- bulkGifted?: false;
1243
- isCommunityGift?: false;
1244
- };
1245
- type Sponsor$community = {
1246
- message: string;
1247
- sender: string;
1248
- gifted?: false;
1249
- bulkGifted: true;
1250
- isCommunityGift?: false;
1251
- };
1252
- type Sponsor$spam = {
1253
- sender: string;
1254
- gifted: true;
1255
- bulkGifted?: false;
1256
- isCommunityGift: true;
1257
- };
1258
-
1259
- type YouTube$Subscriber = {
1260
- listener: 'subscriber-latest';
1261
- event: Subscriber;
1262
- };
1263
- type Subscriber = {
1264
- avatar: string;
1265
- displayName: string;
1266
- providerId: string;
1267
- name: string;
1268
- _id: string;
1269
- sessionTop: boolean;
1270
- type: 'subscriber';
1271
- originalEventName: 'subscriber-latest';
1272
- };
1273
-
1274
- type YouTube$Superchat = {
1275
- listener: 'superchat-latest';
1276
- event: Superchat;
1277
- };
1278
- type Superchat = {
1279
- amount: number;
1280
- avatar: string;
1281
- displayName: string;
1282
- providerId: string;
1283
- name: string;
1284
- _id: string;
1285
- sessionTop: boolean;
1286
- type: 'superchat';
1287
- originalEventName: 'superchat-latest';
1288
- };
1289
-
1290
- type Youtube = Youtube$Message | YouTube$Superchat | YouTube$Subscriber | Youtube$Sponsor;
1291
-
1292
- type Provider = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
1293
- type ClientEvents$1 = {
1294
- provider: 'streamelements';
1295
- data: StreamElements;
1296
- } | {
1297
- provider: 'twitch';
1298
- data: Twitch;
1299
- } | {
1300
- provider: 'youtube';
1301
- data: Youtube;
1302
- } | {
1303
- provider: 'kick';
1304
- data: Kick;
1305
- } | {
1306
- provider: 'facebook';
1307
- data: Facebook;
1308
- };
1309
- type Kick = Kick$Message;
1310
- type Kick$Message = {
1311
- listener: 'message';
1312
- event: {};
1313
- };
1314
- type Facebook = Facebook$Message;
1315
- type Facebook$Message = {
1316
- listener: 'message';
1317
- event: {};
1318
- };
1319
-
1320
- interface CommandOptions {
1321
- prefix?: string;
1322
- name: string;
1323
- description?: string;
1324
- arguments?: boolean;
1325
- run: (this: Client, args: string[], event: CommandEvent) => void;
1326
- test?: string;
1327
- aliases?: string[];
1328
- permissions?: string[];
1329
- admins?: string[];
1330
- }
1331
- type CommandEvent = {
1332
- provider: 'twitch';
1333
- data: Twitch$Message;
1334
- } | {
1335
- provider: 'youtube';
1336
- data: Youtube$Message;
1337
- } | {
1338
- provider: 'kick';
1339
- data: any;
1340
- };
1341
- declare class Command {
1342
- prefix: string;
1343
- name: string;
1344
- description: string;
1345
- arguments: boolean;
1346
- test: string;
1347
- aliases: string[];
1348
- permissions?: string[] | boolean;
1349
- admins: string[];
1350
- constructor(options: CommandOptions);
1351
- run(this: Client, args: string[], event: CommandEvent): void;
1352
- verify(nickname: string, roles: string[], args: string[]): boolean;
1353
- parse(text: string, event: CommandEvent): boolean;
1354
- static execute(received: CommandEvent): boolean;
1355
- }
1356
-
1357
- interface ButtonOptions {
1358
- field: string | ((field: string, value: string | boolean | number) => boolean);
1359
- template?: string;
1360
- run: (field: string, value: string | boolean | number) => void;
1361
- }
1362
- declare class Button {
1363
- field: ButtonOptions['field'];
1364
- template: string;
1365
- run: ButtonOptions['run'];
1366
- constructor(options: ButtonOptions);
1367
- parse(field: string, value: string | boolean | number): Button;
1368
- static execute(field: string, value: string | boolean | number): boolean;
1369
- }
1370
-
1371
- type ClientEvents = {
1372
- load: [event: onWidgetLoad];
1373
- action: [action: Button | Command, type: 'created' | 'executed'];
1374
- session: [session: Session$1];
1375
- event: [event: ClientEvents$1];
1376
- };
1377
- type ClientOptions = {
1378
- id?: string;
1379
- };
1380
- type ClientStorageOptions<T> = {
1381
- value: T;
1382
- timestamp: number;
1383
- expire: number;
1384
- };
1385
- type ClientStorage = {
1386
- user: Record<string, ClientStorageOptions<string>>;
1387
- avatar: Record<string, ClientStorageOptions<string>>;
1388
- pronoun: Record<string, ClientStorageOptions<Alejo$Pronouns$name>>;
1389
- emote: Record<string, ClientStorageOptions<string>>;
1390
- };
1391
- declare class Client extends EventProvider<ClientEvents> {
1392
- id: string;
1393
- storage: useStorage<ClientStorage>;
1394
- fields: onWidgetLoad['fieldData'];
1395
- session: Session$1;
1396
- loaded: boolean;
1397
- constructor(options: ClientOptions);
1398
- actions: {
1399
- commands: Command[];
1400
- buttons: Button[];
1401
- };
1402
- details: {
1403
- provider: Provider | 'local';
1404
- user: onWidgetLoad['channel'];
1405
- currency: onWidgetLoad['currency'];
1406
- overlay: onWidgetLoad['overlay'];
1407
- };
1408
- cache: {
1409
- avatar: number;
1410
- pronoun: number;
1411
- emote: number;
1412
- };
1413
- on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
780
+ namespace Event {
781
+ type onWidgetLoad = {
782
+ channel: {
783
+ username: string;
784
+ /**
785
+ * The channel's streamelements api token (used to authenticate requests to the SE API)
786
+ */
787
+ apiToken: string;
788
+ /**
789
+ * The channel's unique identifier in the SE system
790
+ */
791
+ id: string;
792
+ /**
793
+ * The channel's unique identifier from the provider (e.g. Twitch user ID)
794
+ */
795
+ providerId: string;
796
+ avatar: string;
797
+ };
798
+ currency: {
799
+ code: string;
800
+ name: string;
801
+ symbol: string;
802
+ };
803
+ fieldData: Record<string, StreamElements.CustomField.Value>;
804
+ recents: Array<Object>;
805
+ session: {
806
+ data: StreamElements.Session.Data;
807
+ settings: {
808
+ autoReset: boolean;
809
+ calendar: boolean;
810
+ resetOnStart: boolean;
811
+ };
812
+ };
813
+ overlay: {
814
+ /**
815
+ * Whether the overlay is being viewed in the editor mode (in the SE dashboard) or live (on stream)
816
+ */
817
+ isEditorMode: boolean;
818
+ /**
819
+ * Whether the overlay is muted or not
820
+ */
821
+ muted: boolean;
822
+ };
823
+ emulated?: boolean;
824
+ };
825
+ type onSessionUpdate = {
826
+ session: StreamElements.Session.Data;
827
+ };
828
+ namespace Provider {
829
+ namespace YouTube {
830
+ type Events = YoutubeEvents.Message.Data | YoutubeEvents.Sponsor.Data | YoutubeEvents.Subscriber.Data | YoutubeEvents.Superchat.Data;
831
+ type Message = YoutubeEvents.Message.Data;
832
+ type Superchat = YoutubeEvents.Superchat.Data;
833
+ type Subscriber = YoutubeEvents.Subscriber.Data;
834
+ type Sponsor = YoutubeEvents.Sponsor.Data;
835
+ type gift = YoutubeEvents.Sponsor.gift;
836
+ type community = YoutubeEvents.Sponsor.community;
837
+ type spam = YoutubeEvents.Sponsor.spam;
838
+ }
839
+ namespace StreamElements {
840
+ type Events = StreamElementsEvents.Tip.Data | StreamElementsEvents.KVStore.Data | StreamElementsEvents.BotCounter.Data | StreamElementsEvents.AlertService.Data | StreamElementsEvents.EventSkip.Data | StreamElementsEvents.EventTest.Data;
841
+ type Tip = StreamElementsEvents.Tip.Data;
842
+ type KVStore = StreamElementsEvents.KVStore.Data;
843
+ type BotCounter = StreamElementsEvents.BotCounter.Data;
844
+ type AlertService = StreamElementsEvents.AlertService.Data;
845
+ type EventSkip = StreamElementsEvents.EventSkip.Data;
846
+ type EventTest = StreamElementsEvents.EventTest.Data;
847
+ }
848
+ namespace Twitch {
849
+ type Events = TwitchEvents.Cheer.Data | TwitchEvents.Follower.Data | TwitchEvents.Raid.Data | TwitchEvents.Subscriber.Data | TwitchEvents.Message.Data | TwitchEvents.DeleteMessage.Data | TwitchEvents.DeleteMessages.Data;
850
+ type Message = TwitchEvents.Message.Data;
851
+ type DeleteMessage = TwitchEvents.DeleteMessage.Data;
852
+ type DeleteMessages = TwitchEvents.DeleteMessages.Data;
853
+ type Cheer = TwitchEvents.Cheer.Data;
854
+ type Follower = TwitchEvents.Follower.Data;
855
+ type Raid = TwitchEvents.Raid.Data;
856
+ type Subscriber = TwitchEvents.Subscriber.Data;
857
+ type gift = TwitchEvents.Subscriber.gift;
858
+ type community = TwitchEvents.Subscriber.community;
859
+ type spam = TwitchEvents.Subscriber.spam;
860
+ }
861
+ namespace Kick {
862
+ type Events = {
863
+ listener: 'message';
864
+ event: {};
865
+ };
866
+ }
867
+ namespace Facebook {
868
+ type Events = {
869
+ listener: 'message';
870
+ event: {};
871
+ };
872
+ }
873
+ }
874
+ type onEventReceived = Provider.Twitch.Events | Provider.YouTube.Events | Provider.StreamElements.Events;
875
+ }
876
+ namespace Session {
877
+ type Data = Follower & Subscriber & Host & Raid & CharityCampaignDonation & Cheer & CheerPurchase & Superchat & Hypetrain & ChannelPoints & Tip & Merch & Purchase;
878
+ namespace Config {
879
+ type Int = {
880
+ type: 'int';
881
+ min: number;
882
+ max: number;
883
+ };
884
+ type String = {
885
+ type: 'string';
886
+ options: string[];
887
+ };
888
+ type Array = {
889
+ type: 'array';
890
+ options: any[];
891
+ };
892
+ type Date = {
893
+ type: 'date';
894
+ range: number;
895
+ };
896
+ type Recent = {
897
+ type: 'recent';
898
+ amount: number;
899
+ value: Record<string, Any>;
900
+ };
901
+ type Any = Int | String | Date | Array | Recent | undefined;
902
+ namespace Available {
903
+ type Category = Record<string, Config.Any | Record<string, Config.Any | undefined> | undefined>;
904
+ type Data = Record<string, Category | undefined>;
905
+ }
906
+ }
907
+ type Follower = {
908
+ 'follower-latest': {
909
+ name: string;
910
+ };
911
+ 'follower-session': {
912
+ count: number;
913
+ };
914
+ 'follower-week': {
915
+ count: number;
916
+ };
917
+ 'follower-month': {
918
+ count: number;
919
+ };
920
+ 'follower-goal': {
921
+ amount: number;
922
+ };
923
+ 'follower-total': {
924
+ count: number;
925
+ };
926
+ 'follower-recent': {
927
+ name: string;
928
+ createdAt: string;
929
+ }[];
930
+ };
931
+ type SubscriptionTier = 'prime' | '1000' | '2000' | '3000';
932
+ interface Subscriber {
933
+ 'subscriber-latest': {
934
+ name: string;
935
+ amount: number;
936
+ tier: SubscriptionTier;
937
+ message: string;
938
+ };
939
+ 'subscriber-new-latest': {
940
+ name: string;
941
+ amount: number;
942
+ message: string;
943
+ };
944
+ 'subscriber-resub-latest': {
945
+ name: string;
946
+ amount: number;
947
+ message: string;
948
+ };
949
+ 'subscriber-gifted-latest': {
950
+ name: string;
951
+ amount: number;
952
+ message: string;
953
+ tier: SubscriptionTier;
954
+ sender: string;
955
+ };
956
+ 'subscriber-session': {
957
+ count: number;
958
+ };
959
+ 'subscriber-new-session': {
960
+ count: number;
961
+ };
962
+ 'subscriber-resub-session': {
963
+ count: number;
964
+ };
965
+ 'subscriber-gifted-session': {
966
+ count: number;
967
+ };
968
+ 'subscriber-week': {
969
+ count: number;
970
+ };
971
+ 'subscriber-month': {
972
+ count: number;
973
+ };
974
+ 'subscriber-goal': {
975
+ amount: number;
976
+ };
977
+ 'subscriber-total': {
978
+ count: number;
979
+ };
980
+ 'subscriber-points': {
981
+ amount: number;
982
+ };
983
+ 'subscriber-alltime-gifter': {
984
+ name: string;
985
+ amount: number;
986
+ };
987
+ 'subscriber-recent': {
988
+ name: string;
989
+ amount: number;
990
+ tier: SubscriptionTier;
991
+ createdAt: string;
992
+ }[];
993
+ }
994
+ interface Host {
995
+ 'host-latest': {
996
+ name: string;
997
+ amount: number;
998
+ };
999
+ 'host-recent': {
1000
+ name: string;
1001
+ amount: number;
1002
+ createdAt: string;
1003
+ }[];
1004
+ }
1005
+ interface Raid {
1006
+ 'raid-latest': {
1007
+ name: string;
1008
+ amount: number;
1009
+ };
1010
+ 'raid-recent': {
1011
+ name: string;
1012
+ amount: number;
1013
+ createdAt: string;
1014
+ }[];
1015
+ }
1016
+ interface CharityCampaignDonation {
1017
+ 'charityCampaignDonation-latest': {
1018
+ name: string;
1019
+ amount: number;
1020
+ };
1021
+ 'charityCampaignDonation-session-top-donation': {
1022
+ name: string;
1023
+ amount: number;
1024
+ };
1025
+ 'charityCampaignDonation-weekly-top-donation': {
1026
+ name: string;
1027
+ amount: number;
1028
+ };
1029
+ 'charityCampaignDonation-monthly-top-donation': {
1030
+ name: string;
1031
+ amount: number;
1032
+ };
1033
+ 'charityCampaignDonation-alltime-top-donation': {
1034
+ name: string;
1035
+ amount: number;
1036
+ };
1037
+ 'charityCampaignDonation-session-top-donator': {
1038
+ name: string;
1039
+ amount: number;
1040
+ };
1041
+ 'charityCampaignDonation-weekly-top-donator': {
1042
+ name: string;
1043
+ amount: number;
1044
+ };
1045
+ 'charityCampaignDonation-monthly-top-donator': {
1046
+ name: string;
1047
+ amount: number;
1048
+ };
1049
+ 'charityCampaignDonation-alltime-top-donator': {
1050
+ name: string;
1051
+ amount: number;
1052
+ };
1053
+ 'charityCampaignDonation-recent': {
1054
+ name: string;
1055
+ amount: number;
1056
+ createdAt: string;
1057
+ }[];
1058
+ }
1059
+ interface Cheer {
1060
+ 'cheer-latest': {
1061
+ name: string;
1062
+ amount: number;
1063
+ message: string;
1064
+ };
1065
+ 'cheer-session-top-donation': {
1066
+ name: string;
1067
+ amount: number;
1068
+ };
1069
+ 'cheer-weekly-top-donation': {
1070
+ name: string;
1071
+ amount: number;
1072
+ };
1073
+ 'cheer-monthly-top-donation': {
1074
+ name: string;
1075
+ amount: number;
1076
+ };
1077
+ 'cheer-alltime-top-donation': {
1078
+ name: string;
1079
+ amount: number;
1080
+ };
1081
+ 'cheer-session-top-donator': {
1082
+ name: string;
1083
+ amount: number;
1084
+ };
1085
+ 'cheer-weekly-top-donator': {
1086
+ name: string;
1087
+ amount: number;
1088
+ };
1089
+ 'cheer-monthly-top-donator': {
1090
+ name: string;
1091
+ amount: number;
1092
+ };
1093
+ 'cheer-alltime-top-donator': {
1094
+ name: string;
1095
+ amount: number;
1096
+ };
1097
+ 'cheer-session': {
1098
+ amount: number;
1099
+ };
1100
+ 'cheer-week': {
1101
+ amount: number;
1102
+ };
1103
+ 'cheer-month': {
1104
+ amount: number;
1105
+ };
1106
+ 'cheer-total': {
1107
+ amount: number;
1108
+ };
1109
+ 'cheer-count': {
1110
+ count: number;
1111
+ };
1112
+ 'cheer-goal': {
1113
+ amount: number;
1114
+ };
1115
+ 'cheer-recent': {
1116
+ name: string;
1117
+ amount: number;
1118
+ createdAt: string;
1119
+ }[];
1120
+ }
1121
+ interface CheerPurchase {
1122
+ 'cheerPurchase-latest': {
1123
+ name: string;
1124
+ amount: number;
1125
+ };
1126
+ 'cheerPurchase-session-top-donation': {
1127
+ name: string;
1128
+ amount: number;
1129
+ };
1130
+ 'cheerPurchase-weekly-top-donation': {
1131
+ name: string;
1132
+ amount: number;
1133
+ };
1134
+ 'cheerPurchase-monthly-top-donation': {
1135
+ name: string;
1136
+ amount: number;
1137
+ };
1138
+ 'cheerPurchase-alltime-top-donation': {
1139
+ name: string;
1140
+ amount: number;
1141
+ };
1142
+ 'cheerPurchase-session-top-donator': {
1143
+ name: string;
1144
+ amount: number;
1145
+ };
1146
+ 'cheerPurchase-weekly-top-donator': {
1147
+ name: string;
1148
+ amount: number;
1149
+ };
1150
+ 'cheerPurchase-monthly-top-donator': {
1151
+ name: string;
1152
+ amount: number;
1153
+ };
1154
+ 'cheerPurchase-alltime-top-donator': {
1155
+ name: string;
1156
+ amount: number;
1157
+ };
1158
+ 'cheerPurchase-recent': {
1159
+ name: string;
1160
+ amount: number;
1161
+ createdAt: string;
1162
+ }[];
1163
+ }
1164
+ interface Superchat {
1165
+ 'superchat-latest': {
1166
+ name: string;
1167
+ amount: number;
1168
+ };
1169
+ 'superchat-session-top-donation': {
1170
+ name: string;
1171
+ amount: number;
1172
+ };
1173
+ 'superchat-weekly-top-donation': {
1174
+ name: string;
1175
+ amount: number;
1176
+ };
1177
+ 'superchat-monthly-top-donation': {
1178
+ name: string;
1179
+ amount: number;
1180
+ };
1181
+ 'superchat-alltime-top-donation': {
1182
+ name: string;
1183
+ amount: number;
1184
+ };
1185
+ 'superchat-session-top-donator': {
1186
+ name: string;
1187
+ amount: number;
1188
+ };
1189
+ 'superchat-weekly-top-donator': {
1190
+ name: string;
1191
+ amount: number;
1192
+ };
1193
+ 'superchat-monthly-top-donator': {
1194
+ name: string;
1195
+ amount: number;
1196
+ };
1197
+ 'superchat-alltime-top-donator': {
1198
+ name: string;
1199
+ amount: number;
1200
+ };
1201
+ 'superchat-session': {
1202
+ amount: number;
1203
+ };
1204
+ 'superchat-week': {
1205
+ amount: number;
1206
+ };
1207
+ 'superchat-month': {
1208
+ amount: number;
1209
+ };
1210
+ 'superchat-total': {
1211
+ amount: number;
1212
+ };
1213
+ 'superchat-count': {
1214
+ count: number;
1215
+ };
1216
+ 'superchat-goal': {
1217
+ amount: number;
1218
+ };
1219
+ 'superchat-recent': {
1220
+ name: string;
1221
+ amount: number;
1222
+ createdAt: string;
1223
+ }[];
1224
+ }
1225
+ interface Hypetrain {
1226
+ 'hypetrain-latest': {
1227
+ name: string;
1228
+ amount: number;
1229
+ active: number;
1230
+ level: any;
1231
+ levelChanged: any;
1232
+ type: any;
1233
+ };
1234
+ 'hypetrain-level-goal': {
1235
+ amount: number;
1236
+ };
1237
+ 'hypetrain-level-progress': {
1238
+ amount: number;
1239
+ percent: number;
1240
+ };
1241
+ 'hypetrain-total': {
1242
+ amount: number;
1243
+ };
1244
+ 'hypetrain-latest-top-contributors': {
1245
+ name: string;
1246
+ }[];
1247
+ }
1248
+ interface ChannelPoints {
1249
+ 'channel-points-latest': {
1250
+ name: string;
1251
+ amount: number;
1252
+ message: string;
1253
+ redemption: string;
1254
+ };
1255
+ }
1256
+ interface Tip {
1257
+ 'tip-latest': {
1258
+ name: string;
1259
+ amount: number;
1260
+ };
1261
+ 'tip-session-top-donation': {
1262
+ name: string;
1263
+ amount: number;
1264
+ };
1265
+ 'tip-weekly-top-donation': {
1266
+ name: string;
1267
+ amount: number;
1268
+ };
1269
+ 'tip-monthly-top-donation': {
1270
+ name: string;
1271
+ amount: number;
1272
+ };
1273
+ 'tip-alltime-top-donation': {
1274
+ name: string;
1275
+ amount: number;
1276
+ };
1277
+ 'tip-session-top-donator': {
1278
+ name: string;
1279
+ amount: number;
1280
+ };
1281
+ 'tip-weekly-top-donator': {
1282
+ name: string;
1283
+ amount: number;
1284
+ };
1285
+ 'tip-monthly-top-donator': {
1286
+ name: string;
1287
+ amount: number;
1288
+ };
1289
+ 'tip-alltime-top-donator': {
1290
+ name: string;
1291
+ amount: number;
1292
+ };
1293
+ 'tip-session': {
1294
+ amount: number;
1295
+ };
1296
+ 'tip-week': {
1297
+ amount: number;
1298
+ };
1299
+ 'tip-month': {
1300
+ amount: number;
1301
+ };
1302
+ 'tip-total': {
1303
+ amount: number;
1304
+ };
1305
+ 'tip-count': {
1306
+ count: number;
1307
+ };
1308
+ 'tip-goal': {
1309
+ amount: number;
1310
+ };
1311
+ 'tip-recent': {
1312
+ name: string;
1313
+ amount: number;
1314
+ createdAt: string;
1315
+ }[];
1316
+ }
1317
+ interface Merch {
1318
+ 'merch-latest': {
1319
+ name: string;
1320
+ amount: number;
1321
+ items: any[];
1322
+ };
1323
+ 'merch-goal-orders': {
1324
+ amount: number;
1325
+ };
1326
+ 'merch-goal-items': {
1327
+ amount: number;
1328
+ };
1329
+ 'merch-goal-total': {
1330
+ amount: number;
1331
+ };
1332
+ 'merch-recent': {
1333
+ name: string;
1334
+ }[];
1335
+ }
1336
+ interface Purchase {
1337
+ 'purchase-latest': {
1338
+ name: string;
1339
+ amount: number;
1340
+ items: any[];
1341
+ avatar: string;
1342
+ message: string;
1343
+ };
1344
+ }
1345
+ }
1414
1346
  }
1415
1347
 
1416
- type TwitchBadge = {
1417
- type: string;
1418
- version: string;
1419
- url: string;
1420
- description: string;
1421
- };
1422
- type TwitchBadgesKeys = '100 bits' | 'no audio' | 'no video' | 'bot' | 'twitch staff' | 'admins' | 'artist' | 'game developer' | 'prime' | 'turbo' | 'subscriber' | 'broadcaster' | 'verified' | 'moderator' | 'vip';
1423
-
1424
- type TwitchEmote = {
1425
- type: 'twitch';
1426
- name: string;
1427
- id: string;
1428
- gif: boolean;
1429
- urls: {
1430
- '1': string;
1431
- '2': string;
1432
- '4': string;
1433
- };
1434
- start: number;
1435
- end: number;
1436
- };
1437
- type SeventvEmote = {
1438
- type: '7tv';
1439
- name: string;
1440
- id: string;
1441
- gif: boolean;
1442
- animated: boolean;
1443
- urls: {
1444
- '1': string;
1445
- '2': string;
1446
- '3': string;
1447
- '4': string;
1448
- };
1449
- start: number;
1450
- end: number;
1451
- cords: {
1452
- x: number;
1453
- y: number;
1454
- };
1455
- };
1456
- type BttvEmote = {
1457
- type: 'bttv';
1458
- name: string;
1459
- id: string;
1460
- gif: boolean;
1461
- animated: boolean;
1462
- urls: {
1463
- '1': string;
1464
- '2': string;
1465
- '4': string;
1466
- };
1467
- start: number;
1468
- end: number;
1469
- coords: {
1470
- x: number;
1471
- y: number;
1472
- width: number;
1473
- height: number;
1474
- };
1475
- };
1476
-
1477
- type onEventReceivedEvent = CustomEvent<onEventReceived>;
1478
- type onEventReceived = Twitch | Youtube | StreamElements;
1348
+ /**
1349
+ * EventProvider class for managing event listeners and emitters.
1350
+ * This class allows you to register event listeners, emit events, and manage event subscriptions.
1351
+ * @example
1352
+ * ```typescript
1353
+ * interface TestEvents {
1354
+ * load: [{ type: 'load' }];
1355
+ * event: [{ type: 'event' }];
1356
+ * }
1357
+ *
1358
+ * class Test extends EventProvider<TestEvents> {}
1359
+ *
1360
+ * const test = new Test();
1361
+ * test.on('load', (data) => {})
1362
+ * test.once('event', (data) => {})
1363
+ * test.emit('load', { type: 'load' });
1364
+ * ```
1365
+ */
1366
+ declare class EventProvider<EventMap extends Record<string, any[]> = Record<string, any[]>> {
1367
+ /**
1368
+ * Stores registered event listeners.
1369
+ */
1370
+ private registeredEvents;
1371
+ /**
1372
+ * Emits an event to all registered listeners.
1373
+ * Returns an array of return values from the listeners.
1374
+ * @param eventName The name of the event.
1375
+ * @param args Arguments to pass to the listeners.
1376
+ */
1377
+ emit<K extends keyof EventMap>(eventName: K, ...args: EventMap[K]): any[];
1378
+ /**
1379
+ * Registers an event listener.
1380
+ * @param eventName The name of the event.
1381
+ * @param callback The callback function.
1382
+ */
1383
+ on<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
1384
+ /**
1385
+ * Removes a specific event listener.
1386
+ * @param eventName The name of the event.
1387
+ * @param callback The callback function to remove.
1388
+ */
1389
+ off<K extends keyof EventMap>(eventName: K, callback?: (this: this, ...args: EventMap[K]) => any): this;
1390
+ /**
1391
+ * Registers a listener that is executed only once.
1392
+ * @param eventName The name of the event.
1393
+ * @param callback The callback function.
1394
+ */
1395
+ once<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
1396
+ /**
1397
+ * Removes all listeners for a specific event.
1398
+ * @param eventName The name of the event.
1399
+ */
1400
+ removeAllListeners<K extends keyof EventMap>(eventName: K): this;
1401
+ }
1479
1402
 
1480
- type onSessionUpdateEvent = CustomEvent<onSessionUpdate>;
1481
- type onSessionUpdate = {
1482
- session: Session$1;
1403
+ type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
1404
+ type ClientEvents$1 = {
1405
+ provider: 'streamelements';
1406
+ data: StreamElements.Event.Provider.StreamElements.Events;
1407
+ } | {
1408
+ provider: 'twitch';
1409
+ data: StreamElements.Event.Provider.Twitch.Events;
1410
+ } | {
1411
+ provider: 'youtube';
1412
+ data: StreamElements.Event.Provider.YouTube.Events;
1413
+ } | {
1414
+ provider: 'kick';
1415
+ data: StreamElements.Event.Provider.Kick.Events;
1416
+ } | {
1417
+ provider: 'facebook';
1418
+ data: StreamElements.Event.Provider.Facebook.Events;
1483
1419
  };
1484
1420
 
1485
- type Session$AnyConfig = Session$IntConfig | Session$StringConfig | Session$DateConfig | Session$ArrayConfig | Session$RecentConfig | undefined;
1486
- type Session$AvailableCategory = Record<string, Session$AnyConfig | Record<string, Session$AnyConfig | undefined> | undefined>;
1487
- type Session$AvailableData = Record<string, Session$AvailableCategory | undefined>;
1488
- type Session$IntConfig = {
1489
- type: 'int';
1490
- min: number;
1491
- max: number;
1492
- };
1493
- type Session$StringConfig = {
1494
- type: 'string';
1495
- options: string[];
1496
- };
1497
- type Session$ArrayConfig = {
1498
- type: 'array';
1499
- options: any[];
1500
- };
1501
- type Session$DateConfig = {
1502
- type: 'date';
1503
- range: number;
1504
- };
1505
- type Session$RecentConfig = {
1506
- type: 'recent';
1507
- amount: number;
1508
- value: Record<string, Session$AnyConfig>;
1509
- };
1421
+ declare namespace Alejo {
1422
+ namespace Pronouns {
1423
+ type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
1424
+ type display = 'He/Him' | 'She/Her' | 'They/Them' | 'She/They' | 'He/They' | 'He/She' | 'Xe/Xem' | 'Fae/Faer' | 'Ve/Ver' | 'Ae/Aer' | 'Zie/Hir' | 'Per/Per' | 'E/Em' | 'It/Its';
1425
+ enum map {
1426
+ hehim = "He/Him",
1427
+ sheher = "She/Her",
1428
+ theythem = "They/Them",
1429
+ shethem = "She/They",
1430
+ hethem = "He/They",
1431
+ heshe = "He/She",
1432
+ xexem = "Xe/Xem",
1433
+ faefaer = "Fae/Faer",
1434
+ vever = "Ve/Ver",
1435
+ aeaer = "Ae/Aer",
1436
+ ziehir = "Zie/Hir",
1437
+ perper = "Per/Per",
1438
+ eem = "E/Em",
1439
+ itits = "It/Its"
1440
+ }
1441
+ }
1442
+ type user = {
1443
+ id: string;
1444
+ login: string;
1445
+ pronouns: Pronouns.name;
1446
+ };
1447
+ }
1510
1448
 
1511
- type Modifier = (value: string, param: string | null | undefined, values: {
1512
- amount?: number;
1513
- count?: number;
1514
- }) => string;
1515
- declare class Simulation {
1516
- static data: {
1449
+ declare namespace Simulation {
1450
+ export const data: {
1517
1451
  names: string[];
1518
1452
  messages: string[];
1519
1453
  tiers: string[];
1520
1454
  avatars: string[];
1521
- items: any[];
1522
1455
  emotes: (TwitchEmote | BttvEmote | SeventvEmote)[];
1523
- badges: Record<TwitchBadgesKeys, TwitchBadge>;
1524
- pronouns: typeof Alejo$Pronouns;
1456
+ badges: Record<Twitch.roles, Twitch.badge>;
1457
+ items: any[];
1525
1458
  tts: string[];
1459
+ pronouns: typeof Alejo.Pronouns.map;
1460
+ css_color_names: string[];
1526
1461
  };
1527
- static color: {
1528
- opacity(opacity: number | undefined, color: string): string;
1529
- getOpacity(hex: string): {
1530
- opacity: number;
1531
- hex: string;
1532
- color?: undefined;
1533
- } | {
1534
- opacity: number;
1462
+ export const color: {
1463
+ /**
1464
+ * Generate opacity hex value
1465
+ * @param opacity - Opacity value from 0 to 100
1466
+ * @param color - Hex color code
1467
+ * @returns - Hex color code with opacity
1468
+ */
1469
+ opacity(opacity?: number, color?: string): string;
1470
+ /**
1471
+ * Extract color and opacity from hex code
1472
+ * @param hex - Hex color code
1473
+ * @returns - Object with color and opacity
1474
+ */
1475
+ extract(hex: string): {
1535
1476
  color: string;
1536
- hex?: undefined;
1477
+ opacity: number;
1537
1478
  };
1538
- validate(str: string): "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name" | false;
1479
+ validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
1539
1480
  };
1540
- static rand: {
1481
+ export const rand: {
1482
+ /**
1483
+ * Generate random color
1484
+ * @param type - Color format
1485
+ * @returns - Random color in specified format
1486
+ * @example
1487
+ * ```javascript
1488
+ * const hexColor = Simulation.rand.color('hex');
1489
+ * console.log(hexColor); // e.g. #3e92cc
1490
+ *
1491
+ * const rgbColor = Simulation.rand.color('rgb');
1492
+ * console.log(rgbColor); // e.g. rgb(62, 146, 204)
1493
+ * ```
1494
+ */
1541
1495
  color(type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string;
1496
+ /**
1497
+ * Generate random number
1498
+ * @param min - Minimum value
1499
+ * @param max - Maximum value
1500
+ * @param float - Number of decimal places (0 for integer)
1501
+ * @returns - Random number
1502
+ * @example
1503
+ * ```javascript
1504
+ * const intNumber = Simulation.rand.number(1, 10);
1505
+ * console.log(intNumber); // e.g. 7
1506
+ *
1507
+ * const floatNumber = Simulation.rand.number(1, 10, 2);
1508
+ * console.log(floatNumber); // e.g. 3.14
1509
+ * ```
1510
+ */
1542
1511
  number(min: number, max: number, float?: number): number;
1512
+ /**
1513
+ * Generate random boolean
1514
+ * @param threshold - Threshold between 0 and 1
1515
+ * @returns - Random boolean
1516
+ * @example
1517
+ * ```javascript
1518
+ * const boolValue = Simulation.rand.boolean(0.7);
1519
+ * console.log(boolValue); // e.g. true (70% chance)
1520
+ * ```
1521
+ */
1543
1522
  boolean(threshold?: number): boolean;
1523
+ /**
1524
+ * Generate random string
1525
+ * @param length - Length of the string
1526
+ * @param chars - Characters to use
1527
+ * @returns - Random string
1528
+ * @example
1529
+ * ```javascript
1530
+ * const randString = Simulation.rand.string(10);
1531
+ * console.log(randString); // e.g. "aZ3bT9xYqP"
1532
+ * ```
1533
+ */
1544
1534
  string(length: number, chars?: string): string;
1535
+ /**
1536
+ * Pick random element from array
1537
+ * @param arr - Array to pick from
1538
+ * @returns - Random element and its index
1539
+ * @example
1540
+ * ```javascript
1541
+ * const [element, index] = Simulation.rand.array(['apple', 'banana', 'cherry']);
1542
+ * console.log(element, index); // e.g. "banana", 1
1543
+ * ```
1544
+ */
1545
1545
  array<T>(arr: T[]): [value: T, index: number];
1546
- date(rangeDays?: number): string;
1546
+ /**
1547
+ * Generate random date
1548
+ * @param start - Start date
1549
+ * @param end - End date
1550
+ * @returns - Random date between start and end
1551
+ * @example
1552
+ * ```javascript
1553
+ * const randDate = Simulation.rand.date(new Date(2020, 0, 1), new Date());
1554
+ * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
1555
+ * ```
1556
+ */
1557
+ date(start?: Date, end?: Date): Date;
1558
+ /**
1559
+ * Generate ISO date string offset by days
1560
+ * @param daysAgo - Number of days to go back
1561
+ * @returns - ISO date string
1562
+ * @example
1563
+ * ```javascript
1564
+ * const isoDate = Simulation.rand.daysOffset(7);
1565
+ * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
1566
+ *
1567
+ * const isoDate30 = Simulation.rand.daysOffset(30);
1568
+ * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
1569
+ * ```
1570
+ */
1571
+ daysOffset(daysAgo: number): string;
1572
+ /**
1573
+ * Generate UUID v4
1574
+ * @returns - UUID string
1575
+ * @example
1576
+ * ```javascript
1577
+ * const uuid = Simulation.rand.uuid();
1578
+ * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
1579
+ * ```
1580
+ */
1547
1581
  uuid(): string;
1548
1582
  };
1549
- static string: {
1583
+ type Modifier = (value: string, param: string | null | undefined, values: {
1584
+ amount?: number;
1585
+ count?: number;
1586
+ }) => string;
1587
+ export const string: {
1550
1588
  /**
1551
1589
  * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
1552
1590
  * @param string - The input string to perform replacements on.
@@ -1594,7 +1632,7 @@ declare class Simulation {
1594
1632
  aliases?: Record<string, string[]>;
1595
1633
  }): string;
1596
1634
  };
1597
- static element: {
1635
+ export const element: {
1598
1636
  /**
1599
1637
  * Merges outer span styles with inner span styles in the provided HTML string.
1600
1638
  * @param outerStyle - The style string to be applied to the outer span.
@@ -1643,7 +1681,7 @@ declare class Simulation {
1643
1681
  */
1644
1682
  splitTextToChars(htmlString: string, startIndex?: number): string;
1645
1683
  };
1646
- static object: {
1684
+ export const object: {
1647
1685
  /**
1648
1686
  * Flattens a nested object into a single-level object with dot-separated keys.
1649
1687
  * @param obj - The nested object to be flattened.
@@ -1659,11 +1697,11 @@ declare class Simulation {
1659
1697
  */
1660
1698
  flatten(obj: Record<string, any>, prefix?: string): Record<string, string>;
1661
1699
  };
1662
- static generate: {
1700
+ export const generate: {
1663
1701
  session: {
1664
- types: Record<string, Session$AnyConfig>;
1665
- available(): Session$AvailableData;
1666
- get(): Promise<Session$1>;
1702
+ types: Record<string, StreamElements.Session.Config.Any>;
1703
+ available(): StreamElements.Session.Config.Available.Data;
1704
+ get(): Promise<StreamElements.Session.Data>;
1667
1705
  };
1668
1706
  event: {
1669
1707
  /**
@@ -1673,13 +1711,13 @@ declare class Simulation {
1673
1711
  * @param currency - The currency to be used (default is 'USD').
1674
1712
  * @returns A Promise that resolves to the simulated onWidgetLoad event data.
1675
1713
  */
1676
- onWidgetLoad(fields: Record<string, StreamElementsFieldValue>, session: Session$1, currency?: "BRL" | "USD" | "EUR"): Promise<onWidgetLoad>;
1714
+ onWidgetLoad(fields: Record<string, StreamElements.CustomField.Value>, session: StreamElements.Session.Data, currency?: "BRL" | "USD" | "EUR"): Promise<StreamElements.Event.onWidgetLoad>;
1677
1715
  /**
1678
1716
  * Simulates the onSessionUpdate event for a widget.
1679
1717
  * @param session - The session data to be included in the event.
1680
1718
  * @returns A Promise that resolves to the simulated onSessionUpdate event data.
1681
1719
  */
1682
- onSessionUpdate(session?: Session$1): Promise<onSessionUpdate>;
1720
+ onSessionUpdate(session?: StreamElements.Session.Data): Promise<StreamElements.Event.onSessionUpdate>;
1683
1721
  /**
1684
1722
  * Simulates the onEventReceived event for a widget.
1685
1723
  * @param provider - The provider of the event (default is 'random').
@@ -1695,12 +1733,10 @@ declare class Simulation {
1695
1733
  * const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
1696
1734
  * ```
1697
1735
  */
1698
- onEventReceived(provider?: Provider | "random", type?: onEventReceived["listener"] | "random" | "tip" | "cheer" | "follower" | "raid" | "subscriber", options?: Record<string, string | number | boolean>): Promise<onEventReceived | null>;
1736
+ onEventReceived(provider?: Provider$1 | "random", type?: StreamElements.Event.onEventReceived["listener"] | "random" | "tip" | "cheer" | "follower" | "raid" | "subscriber", options?: Record<string, string | number | boolean>): Promise<StreamElements.Event.onEventReceived | null>;
1699
1737
  };
1700
1738
  };
1701
- static fields(settings: FieldSettings): Record<string, StreamElementsField>;
1702
- static start(): Promise<void>;
1703
- static emulate: {
1739
+ export const emulate: {
1704
1740
  twitch: {
1705
1741
  message(data?: Record<string, string | number | boolean>): void;
1706
1742
  follower(data?: Record<string, string | number | boolean>): void;
@@ -1723,29 +1759,158 @@ declare class Simulation {
1723
1759
  };
1724
1760
  kick: {};
1725
1761
  facebook: {};
1726
- send<T extends "onEventReceived" | "onSessionUpdate" | "onWidgetLoad">(listener: T, event: T extends "onEventReceived" ? onEventReceived : T extends "onSessionUpdate" ? onSessionUpdate : onWidgetLoad): void;
1762
+ send<T extends "onEventReceived" | "onSessionUpdate" | "onWidgetLoad">(listener: T, event: T extends "onEventReceived" ? StreamElements.Event.onEventReceived : T extends "onSessionUpdate" ? StreamElements.Event.onSessionUpdate : StreamElements.Event.onWidgetLoad): void;
1727
1763
  };
1764
+ export function start(fieldsFile?: string[], dataFiles?: string[]): Promise<void>;
1765
+ export {};
1766
+ }
1767
+
1768
+ type UseStorageEvents<T> = {
1769
+ load: [T | null];
1770
+ update: [T];
1771
+ };
1772
+ type UseStorageOptions<T> = {
1773
+ id?: string;
1774
+ data: T;
1775
+ };
1776
+ declare class useStorage<T extends object = Record<string, any>> extends EventProvider<UseStorageEvents<T>> {
1777
+ /**
1778
+ * The unique identifier for the storage instance.
1779
+ */
1780
+ id: string;
1781
+ loaded: boolean;
1782
+ data: T;
1783
+ constructor(options: UseStorageOptions<T>);
1784
+ SE_API: StreamElements.SE_API | null;
1785
+ private start;
1786
+ /**
1787
+ * Saves the current data to storage.
1788
+ * @param data Data to save (defaults to current)
1789
+ */
1790
+ private save;
1791
+ /**
1792
+ * Updates the storage data and emits an update event
1793
+ * @param data Data to update (defaults to current)
1794
+ */
1795
+ update(data?: T): void;
1796
+ /**
1797
+ * Adds a value to the storage at the specified path.
1798
+ * @param path Path to add the value to
1799
+ * @param value Value to add
1800
+ */
1801
+ add<P extends string>(path: P, value: PathValue<T, P>): void;
1802
+ /**
1803
+ * Clears all data from the storage.
1804
+ */
1805
+ clear(): void;
1806
+ /**
1807
+ * Sets a value in the storage at the specified path.
1808
+ * @param obj The object to set the value in
1809
+ * @param path The path to set the value at
1810
+ * @param value The value to set
1811
+ * @returns The updated object
1812
+ */
1813
+ static setByPath<P extends string, T extends object>(obj: T, path: P, value: PathValue<T, P>): void;
1814
+ on<K extends keyof UseStorageEvents<T>>(eventName: K, callback: (this: useStorage<T>, ...args: UseStorageEvents<T>[K]) => void): this;
1728
1815
  }
1729
1816
 
1730
- type LoggerThemeName = 'error' | 'success' | 'alert' | 'warn' | 'status' | 'received' | 'simple' | 'info';
1731
- type LoggerLogFunction = (...args: any[]) => void;
1732
- type LoggerMethods = Record<LoggerThemeName, LoggerLogFunction>;
1733
- declare class Logger implements LoggerMethods {
1734
- private readonly themes;
1735
- error: LoggerLogFunction;
1736
- success: LoggerLogFunction;
1737
- alert: LoggerLogFunction;
1738
- warn: LoggerLogFunction;
1739
- status: LoggerLogFunction;
1740
- received: LoggerLogFunction;
1741
- simple: LoggerLogFunction;
1742
- info: LoggerLogFunction;
1743
- constructor();
1817
+ interface ButtonOptions {
1818
+ field: string | ((field: string, value: string | boolean | number) => boolean);
1819
+ template?: string;
1820
+ run: (field: string, value: string | boolean | number) => void;
1821
+ }
1822
+ declare class Button {
1823
+ field: ButtonOptions['field'];
1824
+ template: string;
1825
+ run: ButtonOptions['run'];
1826
+ constructor(options: ButtonOptions);
1827
+ parse(field: string, value: string | boolean | number): Button;
1828
+ remove(): void;
1829
+ static execute(field: string, value: string | boolean | number): boolean;
1744
1830
  }
1745
1831
 
1746
- type Emote = TwitchEmote | BttvEmote | SeventvEmote;
1747
- declare function findEmotesInText(text: string, emotes?: Emote[]): Emote[];
1748
- declare function replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
1832
+ type ClientEvents = {
1833
+ load: [event: StreamElements.Event.onWidgetLoad];
1834
+ action: [action: Button | Command, type: 'created' | 'executed' | 'removed'];
1835
+ session: [session: StreamElements.Session.Data];
1836
+ event: [event: ClientEvents$1];
1837
+ };
1838
+ type ClientOptions = {
1839
+ id?: string;
1840
+ };
1841
+ type ClientStorageOptions<T> = {
1842
+ value: T;
1843
+ timestamp: number;
1844
+ expire: number;
1845
+ };
1846
+ type ClientStorage = {
1847
+ user: Record<string, ClientStorageOptions<string>>;
1848
+ avatar: Record<string, ClientStorageOptions<string>>;
1849
+ pronoun: Record<string, ClientStorageOptions<Alejo.Pronouns.name>>;
1850
+ emote: Record<string, ClientStorageOptions<string>>;
1851
+ };
1852
+ declare class Client extends EventProvider<ClientEvents> {
1853
+ id: string;
1854
+ storage: useStorage<ClientStorage>;
1855
+ fields: StreamElements.Event.onWidgetLoad['fieldData'];
1856
+ session: StreamElements.Session.Data;
1857
+ loaded: boolean;
1858
+ constructor(options: ClientOptions);
1859
+ actions: {
1860
+ commands: Command[];
1861
+ buttons: Button[];
1862
+ };
1863
+ details: {
1864
+ provider: Provider$1 | 'local';
1865
+ user: StreamElements.Event.onWidgetLoad['channel'];
1866
+ currency: StreamElements.Event.onWidgetLoad['currency'];
1867
+ overlay: StreamElements.Event.onWidgetLoad['overlay'];
1868
+ };
1869
+ cache: {
1870
+ avatar: number;
1871
+ pronoun: number;
1872
+ emote: number;
1873
+ };
1874
+ on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
1875
+ }
1876
+
1877
+ interface CommandOptions {
1878
+ prefix?: string;
1879
+ name: string;
1880
+ description?: string;
1881
+ arguments?: boolean;
1882
+ run: (this: Client, args: string[], event: CommandEvent) => void;
1883
+ test?: string;
1884
+ aliases?: string[];
1885
+ permissions?: string[];
1886
+ admins?: string[];
1887
+ }
1888
+ type CommandEvent = {
1889
+ provider: 'twitch';
1890
+ data: StreamElements.Event.Provider.Twitch.Message;
1891
+ } | {
1892
+ provider: 'youtube';
1893
+ data: StreamElements.Event.Provider.YouTube.Message;
1894
+ } | {
1895
+ provider: 'kick';
1896
+ data: any;
1897
+ };
1898
+ declare class Command {
1899
+ prefix: string;
1900
+ name: string;
1901
+ description: string;
1902
+ arguments: boolean;
1903
+ test: string;
1904
+ aliases: string[];
1905
+ permissions?: string[] | boolean;
1906
+ admins: string[];
1907
+ constructor(options: CommandOptions);
1908
+ run(this: Client, args: string[], event: CommandEvent): void;
1909
+ verify(nickname: string, roles: string[], args: string[]): boolean;
1910
+ parse(text: string, event: CommandEvent): boolean;
1911
+ remove(): void;
1912
+ static execute(received: CommandEvent): boolean;
1913
+ }
1749
1914
 
1750
1915
  type QueueEvents<T> = {
1751
1916
  load: [];
@@ -1794,14 +1959,53 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
1794
1959
  on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
1795
1960
  }
1796
1961
 
1797
- declare const USE_SE_API: Promise<SE_API>;
1962
+ interface Theme {
1963
+ color?: string;
1964
+ background?: string;
1965
+ bold?: boolean;
1966
+ italic?: boolean;
1967
+ fontSize?: number;
1968
+ icon?: string;
1969
+ }
1970
+ interface Options {
1971
+ enabled?: boolean;
1972
+ prefix?: string;
1973
+ }
1974
+ type LogMethod = (...args: unknown[]) => void;
1975
+ declare class Logger {
1976
+ private readonly enabled;
1977
+ private readonly prefix;
1978
+ readonly error: LogMethod;
1979
+ readonly warn: LogMethod;
1980
+ readonly success: LogMethod;
1981
+ readonly info: LogMethod;
1982
+ readonly debug: LogMethod;
1983
+ readonly alert: LogMethod;
1984
+ readonly status: LogMethod;
1985
+ readonly received: LogMethod;
1986
+ readonly simple: LogMethod;
1987
+ constructor(options?: Options);
1988
+ apply(theme: Theme): LogMethod;
1989
+ private style;
1990
+ group(label: string): void;
1991
+ groupCollapsed(label: string): void;
1992
+ groupEnd(): void;
1993
+ table(data: unknown): void;
1994
+ time(label: string): void;
1995
+ timeEnd(label: string): void;
1996
+ }
1997
+
1998
+ declare const USE_SE_API: Promise<StreamElements.SE_API>;
1999
+ declare const logger: Logger;
1798
2000
  declare const Tixyel: {
1799
- readonly Client: typeof Client;
2001
+ readonly USE_SE_API: Promise<StreamElements.SE_API>;
1800
2002
  readonly Simulation: typeof Simulation;
2003
+ readonly Client: typeof Client;
1801
2004
  readonly logger: Logger;
1802
2005
  readonly utils: {
1803
2006
  readonly findEmotesInText: typeof findEmotesInText;
1804
2007
  readonly replaceEmotesWithHTML: typeof replaceEmotesWithHTML;
2008
+ readonly generateBadges: typeof generateBadges;
1805
2009
  };
1806
2010
  readonly modules: {
1807
2011
  readonly Button: typeof Button;
@@ -1809,24 +2013,24 @@ declare const Tixyel: {
1809
2013
  readonly EventProvider: typeof EventProvider;
1810
2014
  readonly useStorage: typeof useStorage;
1811
2015
  readonly useQueue: typeof useQueue;
2016
+ readonly Logger: typeof Logger;
1812
2017
  };
1813
- readonly USE_SE_API: Promise<SE_API>;
1814
2018
  };
1815
- type _Tixyel_ = typeof Tixyel;
2019
+ type Main = typeof Tixyel;
1816
2020
  declare global {
1817
2021
  interface Window {
1818
- Tixyel: _Tixyel_;
2022
+ Tixyel: Main;
1819
2023
  client: Client;
1820
2024
  }
1821
2025
  interface WindowEventMap {
1822
- onWidgetLoad: onWidgetLoadEvent;
1823
- onSessionUpdate: onSessionUpdateEvent;
1824
- onEventReceived: onEventReceivedEvent;
2026
+ onWidgetLoad: CustomEvent<StreamElements.Event.onWidgetLoad>;
2027
+ onSessionUpdate: CustomEvent<StreamElements.Event.onSessionUpdate>;
2028
+ onEventReceived: CustomEvent<StreamElements.Event.onEventReceived>;
1825
2029
  }
1826
- const Tixyel: _Tixyel_;
2030
+ const Tixyel: Main;
1827
2031
  var client: Client;
1828
- const SE_API: SE_API;
2032
+ const SE_API: StreamElements.SE_API;
1829
2033
  }
1830
2034
 
1831
- export { Alejo$Pronouns, Tixyel, USE_SE_API };
1832
- export type { Alejo$Pronouns$User, Alejo$Pronouns$display, Alejo$Pronouns$name, BttvEmote, ClientEvents$1 as ClientEvents, Facebook, Kick, Provider, SeventvEmote, StreamElements, Twitch, Twitch$Cheer, Twitch$DeleteMessage, Twitch$DeleteMessages, Twitch$Follower, Twitch$IRC, Twitch$Message, Twitch$Raid, Twitch$Subscriber, TwitchBadge, TwitchBadgesKeys, TwitchEmote, Youtube };
2035
+ export { Alejo, StreamElements, StreamElementsEvents, Tixyel, TwitchEvents, USE_SE_API, YoutubeEvents, logger };
2036
+ export type { BttvEmote, ClientEvents$1 as ClientEvents, Provider$1 as Provider, SeventvEmote, TwitchEmote };