@tixyel/streamelements 3.4.0 → 3.6.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,1056 @@ 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: [event: { type: 'load' }];
1355
+ * event: [event: { type: 'event' }];
1356
+ * };
1357
+ *
1358
+ * class Test extends EventProvider<TestEvents> {}
1359
+ *
1360
+ * const test = new Test();
1361
+ * test.once('load', (data) => {});
1362
+ * test.emit('load', { type: 'load' });
1363
+ *
1364
+ * test.on('event', (data) => {});
1365
+ * test.emit('event', { type: 'event' });
1366
+ * ```
1367
+ */
1368
+ declare class EventProvider<EventMap extends Record<string, any[]> = Record<string, any[]>> {
1369
+ /**
1370
+ * Stores registered event listeners.
1371
+ */
1372
+ private registeredEvents;
1373
+ /**
1374
+ * Emits an event to all registered listeners.
1375
+ * Returns an array of return values from the listeners.
1376
+ * @param eventName The name of the event.
1377
+ * @param args Arguments to pass to the listeners.
1378
+ */
1379
+ emit<K extends keyof EventMap>(eventName: K, ...args: EventMap[K]): any[];
1380
+ /**
1381
+ * Registers an event listener.
1382
+ * @param eventName The name of the event.
1383
+ * @param callback The callback function.
1384
+ */
1385
+ on<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
1386
+ /**
1387
+ * Removes a specific event listener.
1388
+ * @param eventName The name of the event.
1389
+ * @param callback The callback function to remove.
1390
+ */
1391
+ off<K extends keyof EventMap>(eventName: K, callback?: (this: this, ...args: EventMap[K]) => any): this;
1392
+ /**
1393
+ * Registers a listener that is executed only once.
1394
+ * @param eventName The name of the event.
1395
+ * @param callback The callback function.
1396
+ */
1397
+ once<K extends keyof EventMap>(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this;
1398
+ /**
1399
+ * Removes all listeners for a specific event.
1400
+ * @param eventName The name of the event.
1401
+ */
1402
+ removeAllListeners<K extends keyof EventMap>(eventName: K): this;
1403
+ }
1479
1404
 
1480
- type onSessionUpdateEvent = CustomEvent<onSessionUpdate>;
1481
- type onSessionUpdate = {
1482
- session: Session$1;
1405
+ type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
1406
+ type ClientEvents$1 = {
1407
+ provider: 'streamelements';
1408
+ data: StreamElements.Event.Provider.StreamElements.Events;
1409
+ } | {
1410
+ provider: 'twitch';
1411
+ data: StreamElements.Event.Provider.Twitch.Events;
1412
+ } | {
1413
+ provider: 'youtube';
1414
+ data: StreamElements.Event.Provider.YouTube.Events;
1415
+ } | {
1416
+ provider: 'kick';
1417
+ data: StreamElements.Event.Provider.Kick.Events;
1418
+ } | {
1419
+ provider: 'facebook';
1420
+ data: StreamElements.Event.Provider.Facebook.Events;
1483
1421
  };
1484
1422
 
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
- };
1423
+ declare namespace Alejo {
1424
+ namespace Pronouns {
1425
+ type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
1426
+ 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';
1427
+ enum map {
1428
+ hehim = "He/Him",
1429
+ sheher = "She/Her",
1430
+ theythem = "They/Them",
1431
+ shethem = "She/They",
1432
+ hethem = "He/They",
1433
+ heshe = "He/She",
1434
+ xexem = "Xe/Xem",
1435
+ faefaer = "Fae/Faer",
1436
+ vever = "Ve/Ver",
1437
+ aeaer = "Ae/Aer",
1438
+ ziehir = "Zie/Hir",
1439
+ perper = "Per/Per",
1440
+ eem = "E/Em",
1441
+ itits = "It/Its"
1442
+ }
1443
+ }
1444
+ type user = {
1445
+ id: string;
1446
+ login: string;
1447
+ pronouns: Pronouns.name;
1448
+ };
1449
+ }
1510
1450
 
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: {
1451
+ declare namespace Simulation {
1452
+ export const data: {
1517
1453
  names: string[];
1518
1454
  messages: string[];
1519
1455
  tiers: string[];
1520
1456
  avatars: string[];
1521
- items: any[];
1522
1457
  emotes: (TwitchEmote | BttvEmote | SeventvEmote)[];
1523
- badges: Record<TwitchBadgesKeys, TwitchBadge>;
1524
- pronouns: typeof Alejo$Pronouns;
1458
+ youtube_emotes: {
1459
+ emojiId: string;
1460
+ shortcuts: string[];
1461
+ searchTerms: string[];
1462
+ image: {
1463
+ thumbnails: {
1464
+ url: string;
1465
+ width: number;
1466
+ height: number;
1467
+ }[];
1468
+ accessibility: {
1469
+ accessibilityData: {
1470
+ label: string;
1471
+ };
1472
+ };
1473
+ };
1474
+ isCustomEmoji: boolean;
1475
+ index: number;
1476
+ }[];
1477
+ badges: Record<Twitch.roles, Twitch.badge>;
1478
+ items: any[];
1525
1479
  tts: string[];
1480
+ pronouns: typeof Alejo.Pronouns.map;
1481
+ css_color_names: string[];
1526
1482
  };
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;
1483
+ export const color: {
1484
+ /**
1485
+ * Generate opacity hex value
1486
+ * @param opacity - Opacity value from 0 to 100
1487
+ * @param color - Hex color code
1488
+ * @returns - Hex color code with opacity
1489
+ */
1490
+ opacity(opacity?: number, color?: string): string;
1491
+ /**
1492
+ * Extract color and opacity from hex code
1493
+ * @param hex - Hex color code
1494
+ * @returns - Object with color and opacity
1495
+ */
1496
+ extract(hex: string): {
1535
1497
  color: string;
1536
- hex?: undefined;
1498
+ opacity: number;
1537
1499
  };
1538
- validate(str: string): "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name" | false;
1500
+ validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
1501
+ /**
1502
+ * Convert color to different format
1503
+ * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)")
1504
+ * @param format - Target format
1505
+ * @returns - Converted color string
1506
+ * @example
1507
+ * ```javascript
1508
+ * const hexColor = Simulation.color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733"
1509
+ * const rgbColor = Simulation.color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)"
1510
+ * const hslColor = Simulation.color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)"
1511
+ * const colorName = Simulation.color.convert("#FF5733", "css-color-name"); // "orangered"
1512
+ * ```
1513
+ */
1514
+ convert(str: string, format: "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string | null;
1539
1515
  };
1540
- static rand: {
1516
+ export const rand: {
1517
+ /**
1518
+ * Generate random color
1519
+ * @param type - Color format
1520
+ * @returns - Random color in specified format
1521
+ * @example
1522
+ * ```javascript
1523
+ * const hexColor = Simulation.rand.color('hex');
1524
+ * console.log(hexColor); // e.g. #3e92cc
1525
+ *
1526
+ * const rgbColor = Simulation.rand.color('rgb');
1527
+ * console.log(rgbColor); // e.g. rgb(62, 146, 204)
1528
+ * ```
1529
+ */
1541
1530
  color(type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string;
1531
+ /**
1532
+ * Generate random number
1533
+ * @param min - Minimum value
1534
+ * @param max - Maximum value
1535
+ * @param float - Number of decimal places (0 for integer)
1536
+ * @returns - Random number
1537
+ * @example
1538
+ * ```javascript
1539
+ * const intNumber = Simulation.rand.number(1, 10);
1540
+ * console.log(intNumber); // e.g. 7
1541
+ *
1542
+ * const floatNumber = Simulation.rand.number(1, 10, 2);
1543
+ * console.log(floatNumber); // e.g. 3.14
1544
+ * ```
1545
+ */
1542
1546
  number(min: number, max: number, float?: number): number;
1547
+ /**
1548
+ * Generate random boolean
1549
+ * @param threshold - Threshold between 0 and 1
1550
+ * @returns - Random boolean
1551
+ * @example
1552
+ * ```javascript
1553
+ * const boolValue = Simulation.rand.boolean(0.7);
1554
+ * console.log(boolValue); // e.g. true (70% chance)
1555
+ * ```
1556
+ */
1543
1557
  boolean(threshold?: number): boolean;
1558
+ /**
1559
+ * Generate random string
1560
+ * @param length - Length of the string
1561
+ * @param chars - Characters to use
1562
+ * @returns - Random string
1563
+ * @example
1564
+ * ```javascript
1565
+ * const randString = Simulation.rand.string(10);
1566
+ * console.log(randString); // e.g. "aZ3bT9xYqP"
1567
+ * ```
1568
+ */
1544
1569
  string(length: number, chars?: string): string;
1570
+ /**
1571
+ * Pick random element from array
1572
+ * @param arr - Array to pick from
1573
+ * @returns - Random element and its index
1574
+ * @example
1575
+ * ```javascript
1576
+ * const [element, index] = Simulation.rand.array(['apple', 'banana', 'cherry']);
1577
+ * console.log(element, index); // e.g. "banana", 1
1578
+ * ```
1579
+ */
1545
1580
  array<T>(arr: T[]): [value: T, index: number];
1546
- date(rangeDays?: number): string;
1581
+ /**
1582
+ * Generate random date
1583
+ * @param start - Start date
1584
+ * @param end - End date
1585
+ * @returns - Random date between start and end
1586
+ * @example
1587
+ * ```javascript
1588
+ * const randDate = Simulation.rand.date(new Date(2020, 0, 1), new Date());
1589
+ * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
1590
+ * ```
1591
+ */
1592
+ date(start?: Date, end?: Date): Date;
1593
+ /**
1594
+ * Generate ISO date string offset by days
1595
+ * @param daysAgo - Number of days to go back
1596
+ * @returns - ISO date string
1597
+ * @example
1598
+ * ```javascript
1599
+ * const isoDate = Simulation.rand.daysOffset(7);
1600
+ * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
1601
+ *
1602
+ * const isoDate30 = Simulation.rand.daysOffset(30);
1603
+ * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
1604
+ * ```
1605
+ */
1606
+ daysOffset(daysAgo: number): string;
1607
+ /**
1608
+ * Generate UUID v4
1609
+ * @returns - UUID string
1610
+ * @example
1611
+ * ```javascript
1612
+ * const uuid = Simulation.rand.uuid();
1613
+ * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
1614
+ * ```
1615
+ */
1547
1616
  uuid(): string;
1548
1617
  };
1549
- static string: {
1618
+ type Modifier = (value: string, param: string | null | undefined, values: {
1619
+ amount?: number;
1620
+ count?: number;
1621
+ }) => string;
1622
+ export const string: {
1550
1623
  /**
1551
1624
  * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
1552
1625
  * @param string - The input string to perform replacements on.
@@ -1594,7 +1667,34 @@ declare class Simulation {
1594
1667
  aliases?: Record<string, string[]>;
1595
1668
  }): string;
1596
1669
  };
1597
- static element: {
1670
+ export const number: {
1671
+ /**
1672
+ * Translate number to words
1673
+ * @param num - Number to translate
1674
+ * @param type - Translation type
1675
+ * @returns - Number in words
1676
+ * @example
1677
+ * ```javascript
1678
+ * const cardinal = Simulation.number.translate(42, 'cardinal');
1679
+ * console.log(cardinal); // "forty-two"
1680
+ * ```
1681
+ */
1682
+ translate(num: number, type?: "cardinal" | "ordinal" | "suffix"): string;
1683
+ /**
1684
+ * Balances a number within a specified range
1685
+ * @param amount - Number to balance
1686
+ * @param min - Minimum value
1687
+ * @param max - Maximum value
1688
+ * @returns - Balanced number
1689
+ * @example
1690
+ * ```javascript
1691
+ * const balancedValue = Simulation.number.balance(150, 0, 100);
1692
+ * console.log(balancedValue); // 100
1693
+ * ```
1694
+ */
1695
+ balance(amount: number, min?: number, max?: number): number;
1696
+ };
1697
+ export const element: {
1598
1698
  /**
1599
1699
  * Merges outer span styles with inner span styles in the provided HTML string.
1600
1700
  * @param outerStyle - The style string to be applied to the outer span.
@@ -1643,7 +1743,7 @@ declare class Simulation {
1643
1743
  */
1644
1744
  splitTextToChars(htmlString: string, startIndex?: number): string;
1645
1745
  };
1646
- static object: {
1746
+ export const object: {
1647
1747
  /**
1648
1748
  * Flattens a nested object into a single-level object with dot-separated keys.
1649
1749
  * @param obj - The nested object to be flattened.
@@ -1659,11 +1759,11 @@ declare class Simulation {
1659
1759
  */
1660
1760
  flatten(obj: Record<string, any>, prefix?: string): Record<string, string>;
1661
1761
  };
1662
- static generate: {
1762
+ export const generate: {
1663
1763
  session: {
1664
- types: Record<string, Session$AnyConfig>;
1665
- available(): Session$AvailableData;
1666
- get(): Promise<Session$1>;
1764
+ types: Record<string, StreamElements.Session.Config.Any>;
1765
+ available(): StreamElements.Session.Config.Available.Data;
1766
+ get(): Promise<StreamElements.Session.Data>;
1667
1767
  };
1668
1768
  event: {
1669
1769
  /**
@@ -1673,13 +1773,13 @@ declare class Simulation {
1673
1773
  * @param currency - The currency to be used (default is 'USD').
1674
1774
  * @returns A Promise that resolves to the simulated onWidgetLoad event data.
1675
1775
  */
1676
- onWidgetLoad(fields: Record<string, StreamElementsFieldValue>, session: Session$1, currency?: "BRL" | "USD" | "EUR"): Promise<onWidgetLoad>;
1776
+ onWidgetLoad(fields: Record<string, StreamElements.CustomField.Value>, session: StreamElements.Session.Data, currency?: "BRL" | "USD" | "EUR"): Promise<StreamElements.Event.onWidgetLoad>;
1677
1777
  /**
1678
1778
  * Simulates the onSessionUpdate event for a widget.
1679
1779
  * @param session - The session data to be included in the event.
1680
1780
  * @returns A Promise that resolves to the simulated onSessionUpdate event data.
1681
1781
  */
1682
- onSessionUpdate(session?: Session$1): Promise<onSessionUpdate>;
1782
+ onSessionUpdate(session?: StreamElements.Session.Data): Promise<StreamElements.Event.onSessionUpdate>;
1683
1783
  /**
1684
1784
  * Simulates the onEventReceived event for a widget.
1685
1785
  * @param provider - The provider of the event (default is 'random').
@@ -1695,12 +1795,10 @@ declare class Simulation {
1695
1795
  * const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
1696
1796
  * ```
1697
1797
  */
1698
- onEventReceived(provider?: Provider | "random", type?: onEventReceived["listener"] | "random" | "tip" | "cheer" | "follower" | "raid" | "subscriber", options?: Record<string, string | number | boolean>): Promise<onEventReceived | null>;
1798
+ 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
1799
  };
1700
1800
  };
1701
- static fields(settings: FieldSettings): Record<string, StreamElementsField>;
1702
- static start(): Promise<void>;
1703
- static emulate: {
1801
+ export const emulate: {
1704
1802
  twitch: {
1705
1803
  message(data?: Record<string, string | number | boolean>): void;
1706
1804
  follower(data?: Record<string, string | number | boolean>): void;
@@ -1723,29 +1821,165 @@ declare class Simulation {
1723
1821
  };
1724
1822
  kick: {};
1725
1823
  facebook: {};
1726
- send<T extends "onEventReceived" | "onSessionUpdate" | "onWidgetLoad">(listener: T, event: T extends "onEventReceived" ? onEventReceived : T extends "onSessionUpdate" ? onSessionUpdate : onWidgetLoad): void;
1824
+ 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
1825
  };
1826
+ /**
1827
+ * Delays execution for a specified number of milliseconds.
1828
+ * @param ms - The number of milliseconds to delay.
1829
+ * @returns A Promise that resolves after the specified delay.
1830
+ */
1831
+ export function delay(ms: number): Promise<void>;
1832
+ export function probability(items: Record<string, number>): string | undefined;
1833
+ export function start(fieldsFile?: string[], dataFiles?: string[]): Promise<void>;
1834
+ export {};
1835
+ }
1836
+
1837
+ type UseStorageEvents<T> = {
1838
+ load: [T | null];
1839
+ update: [T];
1840
+ };
1841
+ type UseStorageOptions<T> = {
1842
+ id?: string;
1843
+ data: T;
1844
+ };
1845
+ declare class useStorage<T extends Record<string, any>> extends EventProvider<UseStorageEvents<T>> {
1846
+ /**
1847
+ * The unique identifier for the storage instance.
1848
+ */
1849
+ id: string;
1850
+ loaded: boolean;
1851
+ data: T;
1852
+ constructor(options: UseStorageOptions<T>);
1853
+ SE_API: StreamElements.SE_API | null;
1854
+ private start;
1855
+ /**
1856
+ * Saves the current data to storage.
1857
+ * @param data Data to save (defaults to current)
1858
+ */
1859
+ private save;
1860
+ /**
1861
+ * Updates the storage data and emits an update event
1862
+ * @param data Data to update (defaults to current)
1863
+ */
1864
+ update(data?: T): void;
1865
+ /**
1866
+ * Adds a value to the storage at the specified path.
1867
+ * @param path Path to add the value to
1868
+ * @param value Value to add
1869
+ */
1870
+ add<P extends string>(path: P, value: PathValue<T, P>): void;
1871
+ /**
1872
+ * Clears all data from the storage.
1873
+ */
1874
+ clear(): void;
1875
+ /**
1876
+ * Sets a value in the storage at the specified path.
1877
+ * @param obj The object to set the value in
1878
+ * @param path The path to set the value at
1879
+ * @param value The value to set
1880
+ * @returns The updated object
1881
+ */
1882
+ static setByPath<P extends string, T extends object>(obj: T, path: P, value: PathValue<T, P>): void;
1883
+ on<K extends keyof UseStorageEvents<T>>(eventName: K, callback: (this: useStorage<T>, ...args: UseStorageEvents<T>[K]) => void): this;
1728
1884
  }
1729
1885
 
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();
1886
+ interface ButtonOptions {
1887
+ field: string | ((field: string, value: string | boolean | number) => boolean);
1888
+ template?: string;
1889
+ run: (field: string, value: string | boolean | number) => void;
1890
+ }
1891
+ declare class Button {
1892
+ field: ButtonOptions['field'];
1893
+ template: string;
1894
+ run: ButtonOptions['run'];
1895
+ constructor(options: ButtonOptions);
1896
+ parse(field: string, value: string | boolean | number): Button;
1897
+ remove(): void;
1898
+ static execute(field: string, value: string | boolean | number): boolean;
1744
1899
  }
1745
1900
 
1746
- type Emote = TwitchEmote | BttvEmote | SeventvEmote;
1747
- declare function findEmotesInText(text: string, emotes?: Emote[]): Emote[];
1748
- declare function replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
1901
+ type ClientEvents = {
1902
+ load: [event: StreamElements.Event.onWidgetLoad];
1903
+ action: [action: Button | Command, type: 'created' | 'executed' | 'removed'];
1904
+ session: [session: StreamElements.Session.Data];
1905
+ event: [provider: 'streamelements', event: StreamElements.Event.Provider.StreamElements.Events] | [provider: 'twitch', event: StreamElements.Event.Provider.Twitch.Events] | [provider: 'youtube', event: StreamElements.Event.Provider.YouTube.Events] | [provider: 'kick', event: StreamElements.Event.Provider.Kick.Events] | [provider: 'facebook', event: StreamElements.Event.Provider.Facebook.Events];
1906
+ };
1907
+ type ClientStorageOptions<T> = {
1908
+ value: T;
1909
+ timestamp: number;
1910
+ expire: number;
1911
+ };
1912
+ type ClientStorage = {
1913
+ user: Record<string, ClientStorageOptions<string>>;
1914
+ avatar: Record<string, ClientStorageOptions<string>>;
1915
+ pronoun: Record<string, ClientStorageOptions<Alejo.Pronouns.name>>;
1916
+ emote: Record<string, ClientStorageOptions<string>>;
1917
+ };
1918
+ type ClientOptions = {
1919
+ id?: string;
1920
+ };
1921
+ declare class Client extends EventProvider<ClientEvents> {
1922
+ id: string;
1923
+ storage: useStorage<ClientStorage>;
1924
+ fields: StreamElements.Event.onWidgetLoad['fieldData'];
1925
+ session: StreamElements.Session.Data;
1926
+ loaded: boolean;
1927
+ constructor(options: ClientOptions);
1928
+ actions: {
1929
+ commands: Command[];
1930
+ buttons: Button[];
1931
+ };
1932
+ details: {
1933
+ provider: Provider$1 | 'local';
1934
+ user: StreamElements.Event.onWidgetLoad['channel'];
1935
+ currency: StreamElements.Event.onWidgetLoad['currency'];
1936
+ overlay: StreamElements.Event.onWidgetLoad['overlay'];
1937
+ };
1938
+ cache: {
1939
+ avatar: number;
1940
+ pronoun: number;
1941
+ emote: number;
1942
+ };
1943
+ on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
1944
+ }
1945
+
1946
+ interface CommandOptions {
1947
+ prefix?: string;
1948
+ name: string;
1949
+ description?: string;
1950
+ arguments?: boolean;
1951
+ run: (this: Client, args: string[], event: CommandEvent) => void;
1952
+ test?: string;
1953
+ aliases?: string[];
1954
+ permissions?: string[];
1955
+ admins?: string[];
1956
+ }
1957
+ type CommandEvent = {
1958
+ provider: 'twitch';
1959
+ data: StreamElements.Event.Provider.Twitch.Message;
1960
+ } | {
1961
+ provider: 'youtube';
1962
+ data: StreamElements.Event.Provider.YouTube.Message;
1963
+ } | {
1964
+ provider: 'kick';
1965
+ data: any;
1966
+ };
1967
+ declare class Command {
1968
+ prefix: string;
1969
+ name: string;
1970
+ description: string;
1971
+ arguments: boolean;
1972
+ test: string;
1973
+ aliases: string[];
1974
+ permissions?: string[] | boolean;
1975
+ admins: string[];
1976
+ constructor(options: CommandOptions);
1977
+ run(this: Client, args: string[], event: CommandEvent): void;
1978
+ verify(nickname: string, roles: string[], args: string[]): boolean;
1979
+ parse(text: string, event: CommandEvent): boolean;
1980
+ remove(): void;
1981
+ static execute(received: CommandEvent): boolean;
1982
+ }
1749
1983
 
1750
1984
  type QueueEvents<T> = {
1751
1985
  load: [];
@@ -1794,14 +2028,53 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
1794
2028
  on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
1795
2029
  }
1796
2030
 
1797
- declare const USE_SE_API: Promise<SE_API>;
2031
+ interface Theme {
2032
+ color?: string;
2033
+ background?: string;
2034
+ bold?: boolean;
2035
+ italic?: boolean;
2036
+ fontSize?: number;
2037
+ icon?: string;
2038
+ }
2039
+ interface Options {
2040
+ enabled?: boolean;
2041
+ prefix?: string;
2042
+ }
2043
+ type LogMethod = (...args: unknown[]) => void;
2044
+ declare class Logger {
2045
+ private readonly enabled;
2046
+ private readonly prefix;
2047
+ readonly error: LogMethod;
2048
+ readonly warn: LogMethod;
2049
+ readonly success: LogMethod;
2050
+ readonly info: LogMethod;
2051
+ readonly debug: LogMethod;
2052
+ readonly alert: LogMethod;
2053
+ readonly status: LogMethod;
2054
+ readonly received: LogMethod;
2055
+ readonly simple: LogMethod;
2056
+ constructor(options?: Options);
2057
+ apply(theme: Theme): LogMethod;
2058
+ private style;
2059
+ group(label: string): void;
2060
+ groupCollapsed(label: string): void;
2061
+ groupEnd(): void;
2062
+ table(data: unknown): void;
2063
+ time(label: string): void;
2064
+ timeEnd(label: string): void;
2065
+ }
2066
+
2067
+ declare const USE_SE_API: Promise<StreamElements.SE_API>;
2068
+ declare const logger: Logger;
1798
2069
  declare const Tixyel: {
1799
- readonly Client: typeof Client;
2070
+ readonly USE_SE_API: Promise<StreamElements.SE_API>;
1800
2071
  readonly Simulation: typeof Simulation;
2072
+ readonly Client: typeof Client;
1801
2073
  readonly logger: Logger;
1802
2074
  readonly utils: {
1803
2075
  readonly findEmotesInText: typeof findEmotesInText;
1804
2076
  readonly replaceEmotesWithHTML: typeof replaceEmotesWithHTML;
2077
+ readonly generateBadges: typeof generateBadges;
1805
2078
  };
1806
2079
  readonly modules: {
1807
2080
  readonly Button: typeof Button;
@@ -1809,24 +2082,27 @@ declare const Tixyel: {
1809
2082
  readonly EventProvider: typeof EventProvider;
1810
2083
  readonly useStorage: typeof useStorage;
1811
2084
  readonly useQueue: typeof useQueue;
2085
+ readonly Logger: typeof Logger;
2086
+ };
2087
+ readonly data: {
2088
+ readonly usedStorages: useStorage<any>[];
1812
2089
  };
1813
- readonly USE_SE_API: Promise<SE_API>;
1814
2090
  };
1815
- type _Tixyel_ = typeof Tixyel;
2091
+ type Main = typeof Tixyel;
1816
2092
  declare global {
1817
2093
  interface Window {
1818
- Tixyel: _Tixyel_;
2094
+ Tixyel: Main;
1819
2095
  client: Client;
1820
2096
  }
1821
2097
  interface WindowEventMap {
1822
- onWidgetLoad: onWidgetLoadEvent;
1823
- onSessionUpdate: onSessionUpdateEvent;
1824
- onEventReceived: onEventReceivedEvent;
2098
+ onWidgetLoad: CustomEvent<StreamElements.Event.onWidgetLoad>;
2099
+ onSessionUpdate: CustomEvent<StreamElements.Event.onSessionUpdate>;
2100
+ onEventReceived: CustomEvent<StreamElements.Event.onEventReceived>;
1825
2101
  }
1826
- const Tixyel: _Tixyel_;
2102
+ const Tixyel: Main;
1827
2103
  var client: Client;
1828
- const SE_API: SE_API;
2104
+ const SE_API: StreamElements.SE_API;
1829
2105
  }
1830
2106
 
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 };
2107
+ export { Alejo, StreamElements, StreamElementsEvents, Tixyel, TwitchEvents, USE_SE_API, YoutubeEvents, logger };
2108
+ export type { BttvEmote, ClientEvents$1 as ClientEvents, Provider$1 as Provider, SeventvEmote, TwitchEmote };