@tixyel/streamelements 5.2.0 → 5.4.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
@@ -6,243 +6,6 @@
6
6
 
7
7
  import { ComfyJSInstance, OnErrorHandler, OnCommandHandler, OnChatHandler, OnWhisperHandler, OnMessageDeletedHandler, OnJoinHandler, OnPartHandler, OnHostedHandler, OnRaidHandler, OnSubHandler, OnResubHandler, OnSubGiftHandler, OnSubMysteryGiftHandler, OnGiftSubContinueHandler, OnCheerHandler, OnChatModeHandler, OnRewardHandler, OnConnectedHandler, OnReconnectHandler } from 'comfy.js';
8
8
 
9
- interface ButtonOptions {
10
- field: string | ((field: string, value: string | boolean | number) => boolean);
11
- template?: string;
12
- run: (field: string, value: string | boolean | number) => void;
13
- }
14
- declare class Button {
15
- field: ButtonOptions['field'];
16
- template: string;
17
- run: ButtonOptions['run'];
18
- constructor(options: ButtonOptions);
19
- parse(field: string, value: string | boolean | number): Button;
20
- remove(): void;
21
- static execute(field: string, value: string | boolean | number): boolean;
22
- }
23
-
24
- type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
25
- type ClientEvents$1 = {
26
- provider: 'streamelements';
27
- data: StreamElements.Event.Provider.StreamElements.Events;
28
- } | {
29
- provider: 'twitch';
30
- data: StreamElements.Event.Provider.Twitch.Events;
31
- } | {
32
- provider: 'youtube';
33
- data: StreamElements.Event.Provider.YouTube.Events;
34
- } | {
35
- provider: 'kick';
36
- data: StreamElements.Event.Provider.Kick.Events;
37
- } | {
38
- provider: 'facebook';
39
- data: StreamElements.Event.Provider.Facebook.Events;
40
- };
41
-
42
- declare namespace StreamElementsEvents {
43
- namespace Tip {
44
- type Data = {
45
- listener: 'tip-latest';
46
- event: Event;
47
- };
48
- type Event = {
49
- amount: number;
50
- avatar: string;
51
- name: string;
52
- displayName: string;
53
- providerId: string;
54
- _id: string;
55
- sessionTop: boolean;
56
- type: 'tip';
57
- originalEventName: 'tip-latest';
58
- };
59
- }
60
- namespace KVStore {
61
- type Data = {
62
- listener: 'kvstore:update';
63
- event: Event;
64
- };
65
- type Event = {
66
- data: {
67
- key: `customWidget.${string}`;
68
- value: string | number | boolean | Record<string, any>;
69
- };
70
- };
71
- }
72
- namespace BotCounter {
73
- type Data = {
74
- listener: 'bot:counter';
75
- event: Event;
76
- };
77
- type Event = {
78
- counter: string;
79
- value: number;
80
- };
81
- }
82
- namespace AlertService {
83
- type Data = {
84
- listener: 'alertService:toggleSound';
85
- event: Event;
86
- };
87
- type Event = {
88
- muted: boolean;
89
- };
90
- }
91
- namespace EventSkip {
92
- type Data = {
93
- listener: 'event:skip';
94
- event: Event;
95
- };
96
- type Event = {};
97
- }
98
- namespace EventTest {
99
- export type Data = {
100
- listener: 'event:test';
101
- event: Event;
102
- };
103
- export type Event = widgetButton | emulatedEvents<EventType> | Session;
104
- type items = {
105
- name: string;
106
- price: number;
107
- quantity: number;
108
- };
109
- type widgetButton = {
110
- listener: 'widget-button';
111
- field: string;
112
- value: string | number | boolean;
113
- };
114
- type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid';
115
- type EventTier = 'prime' | '1000' | '2000' | '3000';
116
- type emulatedEvents<T extends EventType> = {
117
- listener: `${T}-latest`;
118
- event: {
119
- type: T;
120
- name: string;
121
- amount: number;
122
- count: number;
123
- message?: string;
124
- gifted?: boolean;
125
- bulkGifted?: boolean;
126
- sender?: string;
127
- subExtension?: boolean;
128
- items: items[];
129
- tier: EventTier;
130
- month: string;
131
- isTest: true;
132
- };
133
- };
134
- type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints;
135
- type SessionCount = {
136
- listener: `${EventType}-count`;
137
- event: {
138
- type: EventType;
139
- name: string;
140
- count: number;
141
- items: items[];
142
- tier: EventTier;
143
- month: string;
144
- isTest: true;
145
- };
146
- };
147
- type SessionTotal = {
148
- listener: `${EventType}-total`;
149
- event: {
150
- type: EventType;
151
- name: string;
152
- amount: number;
153
- count: number;
154
- items: items[];
155
- tier: EventTier;
156
- month: string;
157
- isTest: true;
158
- };
159
- };
160
- type SessionTop = {
161
- listener: `${EventType}-top`;
162
- event: {
163
- type: EventType;
164
- name: string;
165
- amount: number;
166
- count: number;
167
- items: items[];
168
- tier: EventTier;
169
- month: string;
170
- isTest: true;
171
- };
172
- };
173
- type SessionGoal = {
174
- listener: `${EventType}-goal`;
175
- event: {
176
- type: EventType;
177
- name: string;
178
- amount: number;
179
- count: number;
180
- items: items[];
181
- tier: EventTier;
182
- month: string;
183
- isTest: true;
184
- };
185
- };
186
- type SessionRecent = {
187
- listener: `${EventType}-recent`;
188
- event: {
189
- event: SessionRecentEvent[];
190
- };
191
- };
192
- type SessionRecentEvent = {
193
- type: EventType;
194
- name: string;
195
- amount: number;
196
- count: number;
197
- tier: EventTier;
198
- isTest: true;
199
- };
200
- type SessionPoints = {
201
- listener: `${EventType}-points`;
202
- event: {
203
- type: EventType;
204
- name: string;
205
- amount: number;
206
- count: number;
207
- items: items[];
208
- tier: EventTier;
209
- month: string;
210
- isTest: true;
211
- };
212
- };
213
- export {};
214
- }
215
- interface BaseEvent {
216
- provider: Provider$1;
217
- flagged: boolean;
218
- channel: string;
219
- createdAt: string;
220
- _id: string;
221
- expiresAt: string;
222
- updatedAt: string;
223
- activityId: string;
224
- sessionEventsCount: number;
225
- isMock?: boolean;
226
- }
227
- namespace Event {
228
- type Data = {
229
- listener: 'event';
230
- event: Event;
231
- };
232
- type Event = Tip;
233
- interface Tip extends BaseEvent {
234
- type: 'tip';
235
- data: {
236
- amount: string;
237
- currency: string;
238
- username: string;
239
- message: string;
240
- avatar: string;
241
- };
242
- }
243
- }
244
- }
245
-
246
9
  declare namespace YoutubeEvents {
247
10
  namespace Message {
248
11
  export type Data = {
@@ -1584,25 +1347,344 @@ declare namespace StreamElements {
1584
1347
  }
1585
1348
  }
1586
1349
 
1587
- /**
1588
- * EventProvider class for managing event listeners and emitters.
1589
- * This class allows you to register event listeners, emit events, and manage event subscriptions.
1590
- * @example
1591
- * ```typescript
1592
- * type TestEvents = {
1593
- * load: [event: { type: 'load' }];
1594
- * event: [event: { type: 'event' }];
1595
- * };
1596
- *
1597
- * class Test extends EventProvider<TestEvents> {}
1598
- *
1599
- * const test = new Test();
1600
- * test.once('load', (data) => {});
1601
- * test.emit('load', { type: 'load' });
1602
- *
1603
- * test.on('event', (data) => {});
1604
- * test.emit('event', { type: 'event' });
1605
- * ```
1350
+ type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements';
1351
+ type ClientEvents$1 = {
1352
+ provider: 'streamelements';
1353
+ data: StreamElements.Event.Provider.StreamElements.Events;
1354
+ } | {
1355
+ provider: 'twitch';
1356
+ data: StreamElements.Event.Provider.Twitch.Events;
1357
+ } | {
1358
+ provider: 'youtube';
1359
+ data: StreamElements.Event.Provider.YouTube.Events;
1360
+ } | {
1361
+ provider: 'kick';
1362
+ data: StreamElements.Event.Provider.Kick.Events;
1363
+ } | {
1364
+ provider: 'facebook';
1365
+ data: StreamElements.Event.Provider.Facebook.Events;
1366
+ };
1367
+
1368
+ declare namespace StreamElementsEvents {
1369
+ namespace Tip {
1370
+ type Data = {
1371
+ listener: 'tip-latest';
1372
+ event: Event;
1373
+ };
1374
+ type Event = {
1375
+ amount: number;
1376
+ avatar: string;
1377
+ name: string;
1378
+ displayName: string;
1379
+ providerId: string;
1380
+ _id: string;
1381
+ sessionTop: boolean;
1382
+ type: 'tip';
1383
+ originalEventName: 'tip-latest';
1384
+ };
1385
+ }
1386
+ namespace KVStore {
1387
+ type Data = {
1388
+ listener: 'kvstore:update';
1389
+ event: Event;
1390
+ };
1391
+ type Event = {
1392
+ data: {
1393
+ key: `customWidget.${string}`;
1394
+ value: string | number | boolean | Record<string, any>;
1395
+ };
1396
+ };
1397
+ }
1398
+ namespace BotCounter {
1399
+ type Data = {
1400
+ listener: 'bot:counter';
1401
+ event: Event;
1402
+ };
1403
+ type Event = {
1404
+ counter: string;
1405
+ value: number;
1406
+ };
1407
+ }
1408
+ namespace AlertService {
1409
+ type Data = {
1410
+ listener: 'alertService:toggleSound';
1411
+ event: Event;
1412
+ };
1413
+ type Event = {
1414
+ muted: boolean;
1415
+ };
1416
+ }
1417
+ namespace EventSkip {
1418
+ type Data = {
1419
+ listener: 'event:skip';
1420
+ event: Event;
1421
+ };
1422
+ type Event = {};
1423
+ }
1424
+ namespace EventTest {
1425
+ export type Data = {
1426
+ listener: 'event:test';
1427
+ event: Event;
1428
+ };
1429
+ export type Event = widgetButton | emulatedEvents<EventType> | Session;
1430
+ type items = {
1431
+ name: string;
1432
+ price: number;
1433
+ quantity: number;
1434
+ };
1435
+ type widgetButton = {
1436
+ listener: 'widget-button';
1437
+ field: string;
1438
+ value: string | number | boolean;
1439
+ };
1440
+ type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid';
1441
+ type EventTier = 'prime' | '1000' | '2000' | '3000';
1442
+ type emulatedEvents<T extends EventType> = {
1443
+ listener: `${T}-latest`;
1444
+ event: {
1445
+ type: T;
1446
+ name: string;
1447
+ amount: number;
1448
+ count: number;
1449
+ message?: string;
1450
+ gifted?: boolean;
1451
+ bulkGifted?: boolean;
1452
+ sender?: string;
1453
+ subExtension?: boolean;
1454
+ items: items[];
1455
+ tier: EventTier;
1456
+ month: string;
1457
+ isTest: true;
1458
+ };
1459
+ };
1460
+ type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints;
1461
+ type SessionCount = {
1462
+ listener: `${EventType}-count`;
1463
+ event: {
1464
+ type: EventType;
1465
+ name: string;
1466
+ count: number;
1467
+ items: items[];
1468
+ tier: EventTier;
1469
+ month: string;
1470
+ isTest: true;
1471
+ };
1472
+ };
1473
+ type SessionTotal = {
1474
+ listener: `${EventType}-total`;
1475
+ event: {
1476
+ type: EventType;
1477
+ name: string;
1478
+ amount: number;
1479
+ count: number;
1480
+ items: items[];
1481
+ tier: EventTier;
1482
+ month: string;
1483
+ isTest: true;
1484
+ };
1485
+ };
1486
+ type SessionTop = {
1487
+ listener: `${EventType}-top`;
1488
+ event: {
1489
+ type: EventType;
1490
+ name: string;
1491
+ amount: number;
1492
+ count: number;
1493
+ items: items[];
1494
+ tier: EventTier;
1495
+ month: string;
1496
+ isTest: true;
1497
+ };
1498
+ };
1499
+ type SessionGoal = {
1500
+ listener: `${EventType}-goal`;
1501
+ event: {
1502
+ type: EventType;
1503
+ name: string;
1504
+ amount: number;
1505
+ count: number;
1506
+ items: items[];
1507
+ tier: EventTier;
1508
+ month: string;
1509
+ isTest: true;
1510
+ };
1511
+ };
1512
+ type SessionRecent = {
1513
+ listener: `${EventType}-recent`;
1514
+ event: {
1515
+ event: SessionRecentEvent[];
1516
+ };
1517
+ };
1518
+ type SessionRecentEvent = {
1519
+ type: EventType;
1520
+ name: string;
1521
+ amount: number;
1522
+ count: number;
1523
+ tier: EventTier;
1524
+ isTest: true;
1525
+ };
1526
+ type SessionPoints = {
1527
+ listener: `${EventType}-points`;
1528
+ event: {
1529
+ type: EventType;
1530
+ name: string;
1531
+ amount: number;
1532
+ count: number;
1533
+ items: items[];
1534
+ tier: EventTier;
1535
+ month: string;
1536
+ isTest: true;
1537
+ };
1538
+ };
1539
+ export {};
1540
+ }
1541
+ interface BaseEvent {
1542
+ provider: Provider$1;
1543
+ flagged: boolean;
1544
+ channel: string;
1545
+ createdAt: string;
1546
+ _id: string;
1547
+ expiresAt: string;
1548
+ updatedAt: string;
1549
+ activityId: string;
1550
+ sessionEventsCount: number;
1551
+ isMock?: boolean;
1552
+ }
1553
+ namespace Event {
1554
+ type Data = {
1555
+ listener: 'event';
1556
+ event: Event;
1557
+ };
1558
+ type Event = Tip;
1559
+ interface Tip extends BaseEvent {
1560
+ type: 'tip';
1561
+ data: {
1562
+ amount: string;
1563
+ currency: string;
1564
+ username: string;
1565
+ message: string;
1566
+ avatar: string;
1567
+ };
1568
+ }
1569
+ }
1570
+ }
1571
+
1572
+ type TwitchEmote = {
1573
+ type: 'twitch';
1574
+ name: string;
1575
+ id: string;
1576
+ gif: boolean;
1577
+ urls: {
1578
+ '1': string;
1579
+ '2': string;
1580
+ '4': string;
1581
+ };
1582
+ start: number;
1583
+ end: number;
1584
+ };
1585
+ type SeventvEmote = {
1586
+ type: '7tv';
1587
+ name: string;
1588
+ id: string;
1589
+ gif: boolean;
1590
+ animated: boolean;
1591
+ urls: {
1592
+ '1': string;
1593
+ '2': string;
1594
+ '3': string;
1595
+ '4': string;
1596
+ };
1597
+ start: number;
1598
+ end: number;
1599
+ cords: {
1600
+ x: number;
1601
+ y: number;
1602
+ };
1603
+ };
1604
+ type BttvEmote = {
1605
+ type: 'bttv';
1606
+ name: string;
1607
+ id: string;
1608
+ gif: boolean;
1609
+ animated: boolean;
1610
+ urls: {
1611
+ '1': string;
1612
+ '2': string;
1613
+ '4': string;
1614
+ };
1615
+ start: number;
1616
+ end: number;
1617
+ coords: {
1618
+ x: number;
1619
+ y: number;
1620
+ width: number;
1621
+ height: number;
1622
+ };
1623
+ };
1624
+ type Emote = TwitchEmote | BttvEmote | SeventvEmote;
1625
+
1626
+ interface ButtonOptions {
1627
+ field: string | ((field: string, value: string | boolean | number) => boolean);
1628
+ template?: string;
1629
+ name?: string;
1630
+ value?: string;
1631
+ run: (field: string, value: string | boolean | number) => void;
1632
+ }
1633
+ /**
1634
+ * Represents a button action that can be triggered by custom fields in StreamElements.
1635
+ * The button can be configured with a template and a name, and it will execute a specified function when triggered.
1636
+ * @example
1637
+ * ```javascript
1638
+ * const button = new Button({
1639
+ * field: (field, value) => field.startsWith('message-') && field.split('-')[1],
1640
+ * template: 'message-{role}',
1641
+ * // name: '[CAP={role}] role message',
1642
+ * name: 'Generate {role} message',
1643
+ * run(field, value) {
1644
+ * console.log(`Button ${field} was clicked with value: ${value}`);
1645
+ * }
1646
+ * })
1647
+ *
1648
+ * const field = button.generate([{ role: 'broadcaster' }, { role: 'moderator' }]);
1649
+ * // This will create buttons with fields "message-broadcaster" and "message-moderator" and names "Generate broadcaster message" and "Generate moderator message".
1650
+ * // field['message-broadcaster'] => { type: 'button', label: 'Generate broadcaster message' }
1651
+ * // field['message-moderator'] => { type: 'button', label: 'Generate moderator message' }
1652
+ *
1653
+ * // When a custom field with the name "message-broadcaster" or "message-moderator" is triggered, the run function will be called with the field and value.
1654
+ * ```
1655
+ */
1656
+ declare class Button {
1657
+ field: ButtonOptions['field'];
1658
+ template: string;
1659
+ name: string;
1660
+ value: string;
1661
+ run: ButtonOptions['run'];
1662
+ constructor(options: ButtonOptions);
1663
+ generate(values: Array<Record<string, string | number>>): Record<string, StreamElements.CustomField.Schema>;
1664
+ parse(field: string, value: string | boolean | number): Button;
1665
+ remove(): void;
1666
+ static execute(field: string, value: string | boolean | number): boolean;
1667
+ }
1668
+
1669
+ /**
1670
+ * EventProvider class for managing event listeners and emitters.
1671
+ * This class allows you to register event listeners, emit events, and manage event subscriptions.
1672
+ * @example
1673
+ * ```typescript
1674
+ * type TestEvents = {
1675
+ * load: [event: { type: 'load' }];
1676
+ * event: [event: { type: 'event' }];
1677
+ * };
1678
+ *
1679
+ * class Test extends EventProvider<TestEvents> {}
1680
+ *
1681
+ * const test = new Test();
1682
+ * test.once('load', (data) => {});
1683
+ * test.emit('load', { type: 'load' });
1684
+ *
1685
+ * test.on('event', (data) => {});
1686
+ * test.emit('event', { type: 'event' });
1687
+ * ```
1606
1688
  */
1607
1689
  declare class EventProvider<EventMap extends Record<string, any[]> = Record<string, any[]>> {
1608
1690
  /**
@@ -1698,250 +1780,682 @@ declare class useStorage<T extends JSONObject> extends EventProvider<UseStorageE
1698
1780
  on<K extends keyof UseStorageEvents<T>>(eventName: K, callback: (this: useStorage<T>, ...args: UseStorageEvents<T>[K]) => void): this;
1699
1781
  }
1700
1782
 
1701
- declare namespace Alejo {
1702
- namespace Pronouns {
1703
- type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
1704
- 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';
1705
- enum map {
1706
- hehim = "He/Him",
1707
- sheher = "She/Her",
1708
- theythem = "They/Them",
1709
- shethem = "She/They",
1710
- hethem = "He/They",
1711
- heshe = "He/She",
1712
- xexem = "Xe/Xem",
1713
- faefaer = "Fae/Faer",
1714
- vever = "Ve/Ver",
1715
- aeaer = "Ae/Aer",
1716
- ziehir = "Zie/Hir",
1717
- perper = "Per/Per",
1718
- eem = "E/Em",
1719
- itits = "It/Its"
1783
+ declare namespace Alejo {
1784
+ namespace Pronouns {
1785
+ type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits';
1786
+ 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';
1787
+ enum map {
1788
+ hehim = "He/Him",
1789
+ sheher = "She/Her",
1790
+ theythem = "They/Them",
1791
+ shethem = "She/They",
1792
+ hethem = "He/They",
1793
+ heshe = "He/She",
1794
+ xexem = "Xe/Xem",
1795
+ faefaer = "Fae/Faer",
1796
+ vever = "Ve/Ver",
1797
+ aeaer = "Ae/Aer",
1798
+ ziehir = "Zie/Hir",
1799
+ perper = "Per/Per",
1800
+ eem = "E/Em",
1801
+ itits = "It/Its"
1802
+ }
1803
+ }
1804
+ function list(): Promise<typeof Pronouns.map>;
1805
+ type user = {
1806
+ id: string;
1807
+ login: string;
1808
+ pronoun_id: Pronouns.name;
1809
+ };
1810
+ function get(username: string): Promise<Pronouns.name | undefined>;
1811
+ }
1812
+
1813
+ type ClientEvents = {
1814
+ load: [event: StreamElements.Event.onWidgetLoad];
1815
+ action: [action: Button | Command, type: 'created' | 'executed' | 'removed'];
1816
+ session: [session: StreamElements.Session.Data];
1817
+ 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];
1818
+ };
1819
+ type ClientStorageOptions<T> = {
1820
+ value: T;
1821
+ timestamp: number;
1822
+ expire: number;
1823
+ };
1824
+ type ClientStorage = {
1825
+ user: Record<string, ClientStorageOptions<string>>;
1826
+ avatar: Record<string, ClientStorageOptions<string>>;
1827
+ pronoun: Record<string, ClientStorageOptions<Alejo.Pronouns.name>>;
1828
+ emote: Record<string, ClientStorageOptions<string>>;
1829
+ };
1830
+ type ClientOptions = {
1831
+ id?: string;
1832
+ debug?: boolean | (() => boolean);
1833
+ };
1834
+ declare class Client extends EventProvider<ClientEvents> {
1835
+ id: string;
1836
+ debug: boolean;
1837
+ storage: useStorage<ClientStorage>;
1838
+ fields: StreamElements.Event.onWidgetLoad['fieldData'];
1839
+ session: StreamElements.Session.Data;
1840
+ loaded: boolean;
1841
+ constructor(options: ClientOptions);
1842
+ actions: {
1843
+ commands: Command[];
1844
+ buttons: Button[];
1845
+ };
1846
+ details: {
1847
+ provider: Provider$1 | 'local';
1848
+ user: StreamElements.Event.onWidgetLoad['channel'];
1849
+ currency: StreamElements.Event.onWidgetLoad['currency'];
1850
+ overlay: StreamElements.Event.onWidgetLoad['overlay'];
1851
+ };
1852
+ cache: {
1853
+ /**
1854
+ * Avatar cache duration in minutes.
1855
+ */
1856
+ avatar: number;
1857
+ /**
1858
+ * Pronoun cache duration in minutes.
1859
+ */
1860
+ pronoun: number;
1861
+ /**
1862
+ * Emote cache duration in minutes.
1863
+ */
1864
+ emote: number;
1865
+ };
1866
+ on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
1867
+ }
1868
+
1869
+ interface CommandOptions {
1870
+ prefix?: string;
1871
+ name: string;
1872
+ description?: string;
1873
+ arguments?: boolean;
1874
+ run: (this: Client, args: string[], event: CommandEvent) => void;
1875
+ test?: string;
1876
+ aliases?: string[];
1877
+ permissions?: string[];
1878
+ admins?: string[];
1879
+ }
1880
+ type CommandEvent = {
1881
+ provider: 'twitch';
1882
+ data: StreamElements.Event.Provider.Twitch.Message;
1883
+ } | {
1884
+ provider: 'youtube';
1885
+ data: StreamElements.Event.Provider.YouTube.Message;
1886
+ } | {
1887
+ provider: 'kick';
1888
+ data: any;
1889
+ };
1890
+ declare class Command {
1891
+ prefix: string;
1892
+ name: string;
1893
+ description: string;
1894
+ arguments: boolean;
1895
+ test: string | (() => string);
1896
+ aliases: string[];
1897
+ permissions?: string[] | boolean;
1898
+ admins: string[];
1899
+ constructor(options: CommandOptions);
1900
+ run(this: Client, args: string[], event: CommandEvent): void;
1901
+ verify(nickname: string, roles: string[], args: string[]): boolean;
1902
+ parse(text: string, event: CommandEvent): boolean;
1903
+ remove(): void;
1904
+ static execute(received: CommandEvent): boolean;
1905
+ }
1906
+
1907
+ type QueueEvents<T> = {
1908
+ load: [];
1909
+ cancel: [];
1910
+ update: [queue: QueueItem<T>[], priorityQueue: QueueItem<T>[], history: QueueItem<T>[], timeouts: Array<ReturnType<typeof setTimeout>>];
1911
+ process: [item: QueueItem<T>, queue: useQueue<T>];
1912
+ };
1913
+ type QueueProps = {
1914
+ isoDate: string;
1915
+ isLoop: boolean;
1916
+ isPriority: boolean;
1917
+ isImmediate: boolean;
1918
+ };
1919
+ type QueueItem<T> = {
1920
+ value: T;
1921
+ } & QueueProps;
1922
+ type QueueProcessor<T> = (item: T, queue: useQueue<T>) => Promise<any>;
1923
+ type QueueDuration = number | boolean | undefined;
1924
+ interface QueueOptions<T> {
1925
+ /**
1926
+ * Duration between processing each item in milliseconds. Set to `0` or `false` for immediate processing.
1927
+ */
1928
+ duration?: QueueDuration | 'client';
1929
+ /**
1930
+ * Function to process each item in the queue.
1931
+ */
1932
+ processor: QueueProcessor<T>;
1933
+ }
1934
+ /**
1935
+ * A utility class to manage a queue of items with support for priority, looping, and immediate processing.
1936
+ * @template T - The type of items in the queue.
1937
+ * @extends EventProvider<QueueEvents<T>>
1938
+ * @example
1939
+ * ```javascript
1940
+ * const myQueue = new useQueue({
1941
+ * duration: 1000,
1942
+ * processor: async (item) => {
1943
+ * console.log('Processing item:', item);
1944
+ * },
1945
+ * });
1946
+ *
1947
+ * myQueue.enqueue('Item 1');
1948
+ * myQueue.enqueue('Item 2', { isPriority: true });
1949
+ * ```
1950
+ */
1951
+ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
1952
+ queue: QueueItem<T>[];
1953
+ priorityQueue: QueueItem<T>[];
1954
+ history: QueueItem<T>[];
1955
+ private timeouts;
1956
+ running: boolean;
1957
+ duration: QueueDuration;
1958
+ private loaded;
1959
+ processor: QueueProcessor<T>;
1960
+ constructor(options: QueueOptions<T>);
1961
+ enqueue(value: T, options?: Partial<QueueProps>): this;
1962
+ private run;
1963
+ private next;
1964
+ resume(): this;
1965
+ update(save: Partial<useQueue<T>>): this;
1966
+ cancel(): void;
1967
+ hasItems(): boolean;
1968
+ on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
1969
+ }
1970
+
1971
+ declare namespace Helper {
1972
+ namespace number {
1973
+ /**
1974
+ * Translate number to words
1975
+ * @param num - Number to translate
1976
+ * @param type - Translation type
1977
+ * @returns - Number in words
1978
+ * @example
1979
+ * ```javascript
1980
+ * const cardinal = Simulation.number.translate(42, 'cardinal');
1981
+ * console.log(cardinal); // "forty-two"
1982
+ * ```
1983
+ */
1984
+ function translate(num: number, type?: 'cardinal' | 'ordinal' | 'suffix'): string;
1985
+ /**
1986
+ * Balances a number within a specified range
1987
+ * @param amount - Number to balance
1988
+ * @param min - Minimum value
1989
+ * @param max - Maximum value
1990
+ * @returns - Balanced number
1991
+ * @example
1992
+ * ```javascript
1993
+ * const balancedValue = Simulation.number.balance(150, 0, 100);
1994
+ * console.log(balancedValue); // 100
1995
+ * ```
1996
+ */
1997
+ function balance(amount: number, min?: number, max?: number): number;
1998
+ /**
1999
+ * Rounds a number to a specified number of decimal places
2000
+ * @param value - Number to round
2001
+ * @param decimals - Number of decimal places (default is 2)
2002
+ * @returns Rounded number
2003
+ * @example
2004
+ * ```javascript
2005
+ * const roundedValue = Simulation.number.float(3.14159, 3);
2006
+ * console.log(roundedValue); // 3.142
2007
+ * ```
2008
+ */
2009
+ function round(value: number, decimals?: number): number;
2010
+ }
2011
+ namespace utils {
2012
+ /**
2013
+ * Delays execution for a specified number of milliseconds.
2014
+ * @param ms - The number of milliseconds to delay.
2015
+ * @returns A Promise that resolves after the specified delay.
2016
+ */
2017
+ function delay<R extends any, M extends number>(ms: M, callback?: () => R): Promise<R | null>;
2018
+ /**
2019
+ * Returns typed entries of an object.
2020
+ * @param obj - The object to get entries from.
2021
+ * @returns An array of key-value pairs from the object.
2022
+ */
2023
+ function typedEntries<K extends string, V>(obj: Record<K, V> | Array<V>): [K, V][];
2024
+ /**
2025
+ * Returns typed values of an object.
2026
+ * @param obj - The object to get values from.
2027
+ * @returns An array of values from the object.
2028
+ */
2029
+ function typedValues<K extends string, V>(obj: Record<K, V> | Array<V>): V[];
2030
+ /**
2031
+ * Returns typed keys of an object.
2032
+ * @param obj - The object to get keys from.
2033
+ * @returns An array of keys from the object.
2034
+ */
2035
+ function typedKeys<K extends string, V>(obj: Record<K, V> | Array<V>): K[];
2036
+ /**
2037
+ * Selects an item based on weighted probabilities.
2038
+ * @param items - An object where keys are items and values are their weights.
2039
+ * @returns A randomly selected item based on the given probabilities.
2040
+ */
2041
+ function probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2042
+ }
2043
+ namespace element {
2044
+ interface ScaleOptions<T extends HTMLElement> {
2045
+ /**
2046
+ * The parent element to use for scaling calculations. If not provided, the element's parent will be used.
2047
+ */
2048
+ parent?: HTMLElement;
2049
+ /**
2050
+ * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default).
2051
+ */
2052
+ prefer?: 'width' | 'height' | 'auto';
2053
+ /**
2054
+ * The minimum percentage of the parent size to scale to. Default is 0.
2055
+ */
2056
+ min?: number;
2057
+ /**
2058
+ * The maximum percentage of the parent size to scale to. Default is 1 (100%).
2059
+ */
2060
+ max?: number;
2061
+ /**
2062
+ * A callback function that is called after scaling is applied.
2063
+ * @param this - The HTML element being scaled.
2064
+ * @param number - The scale factor applied to the element.
2065
+ * @param element - The HTML element being scaled.
2066
+ * @returns void
2067
+ */
2068
+ apply?: (this: T, number: number, element: T) => void;
1720
2069
  }
2070
+ type FitTextOptions = {
2071
+ minFontSize?: number;
2072
+ maxFontSize?: number;
2073
+ parent?: HTMLElement;
2074
+ };
2075
+ /**
2076
+ * Merges outer span styles with inner span styles in the provided HTML string.
2077
+ * @param outerStyle - The style string to be applied to the outer span.
2078
+ * @param innerHTML - The inner HTML string which may contain a span with its own styles.
2079
+ * @returns A new HTML string with merged styles applied to a single span.
2080
+ * @example
2081
+ * ```javascript
2082
+ * const result = mergeSpanStyles("color: red; font-weight: bold;", '<span style="font-size: 14px;">Hello World</span>');
2083
+ * console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
2084
+ * ```
2085
+ */
2086
+ function mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2087
+ /**
2088
+ * Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors.
2089
+ * @param element - The HTML element to be scaled.
2090
+ * @param min - Minimum scale factor (default is 0).
2091
+ * @param max - Maximum scale factor (default is 1).
2092
+ * @param options - Optional settings for scaling.
2093
+ * @returns - An object containing the new width, height, and scale factor, or void if not applied.
2094
+ * @example
2095
+ * ```javascript
2096
+ * const element = document.getElementById('myElement');
2097
+ * scale(element, 0.5, 1, { return: false });
2098
+ * ```
2099
+ */
2100
+ function scale(element: HTMLElement, min?: number, max?: number, options?: {
2101
+ return: boolean;
2102
+ parent: HTMLElement;
2103
+ base: 'width' | 'height';
2104
+ }): {
2105
+ width: number;
2106
+ height: number;
2107
+ scale: number;
2108
+ } | void;
2109
+ /**
2110
+ * Scales an HTML element to fit within its parent element based on specified options.
2111
+ * @param element - The HTML element to be scaled.
2112
+ * @param options - Optional settings for scaling.
2113
+ * @returns The scale factor applied to the element.
2114
+ * @example
2115
+ * ```javascript
2116
+ * const element = document.getElementById('myElement');
2117
+ * const scaleFactor scalev2(element, {
2118
+ * min: 0.5,
2119
+ * max: 1,
2120
+ * prefer: 'width',
2121
+ * apply: (scale, el) => el.style.transform = `scale(${scale})`
2122
+ * });
2123
+ * console.log(`Element scaled by a factor of ${scaleFactor}`);
2124
+ * ```
2125
+ */
2126
+ function scalev2<T extends HTMLElement>(element: T, options?: ScaleOptions<T>): number;
2127
+ /**
2128
+ * Fits the text within the parent element by adjusting the font size.
2129
+ * @param element - The HTML element containing the text to be fitted.
2130
+ * @param compressor - A multiplier to adjust the fitting sensitivity (default is 1).
2131
+ * @param options - Optional settings for fitting text.
2132
+ * @returns The HTML element with adjusted font size.
2133
+ * @example
2134
+ * ```javascript
2135
+ * const element = document.getElementById('myTextElement');
2136
+ * fitText(element, 1, { minFontSize: 12, maxFontSize: 36 });
2137
+ * console.log(`Adjusted font size: ${element.style.fontSize}`);
2138
+ * ```
2139
+ */
2140
+ function fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement;
2141
+ /**
2142
+ * Wraps formatted HTML text with containers and splits characters into indexed spans.
2143
+ * Adds 'container' class and data-index to all parent elements, and wraps each character in a span with class 'char' and data-index.
2144
+ * @param htmlString - The input HTML string containing formatted text elements (span, strong, em, etc).
2145
+ * @param startIndex - The starting index for the data-index attribute (default is 0).
2146
+ * @returns - A new HTML string with containers and character-level indexing.
2147
+ * @example
2148
+ * ```javascript
2149
+ * const result = splitTextToChars('<span>TesTe</span> <strong>bold</strong>', 0);
2150
+ * console.log(result);
2151
+ * // Output: '<span class="container" data-index="0"><span class="char" data-index="0">T</span><span class="char" data-index="1">e</span>...'
2152
+ * ```
2153
+ */
2154
+ function splitTextToChars(htmlString: string, startIndex?: number): string;
1721
2155
  }
1722
- function list(): Promise<typeof Pronouns.map>;
1723
- type user = {
1724
- id: string;
1725
- login: string;
1726
- pronoun_id: Pronouns.name;
1727
- };
1728
- function get(username: string): Promise<Pronouns.name | undefined>;
1729
- }
1730
-
1731
- type ClientEvents = {
1732
- load: [event: StreamElements.Event.onWidgetLoad];
1733
- action: [action: Button | Command, type: 'created' | 'executed' | 'removed'];
1734
- session: [session: StreamElements.Session.Data];
1735
- 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];
1736
- };
1737
- type ClientStorageOptions<T> = {
1738
- value: T;
1739
- timestamp: number;
1740
- expire: number;
1741
- };
1742
- type ClientStorage = {
1743
- user: Record<string, ClientStorageOptions<string>>;
1744
- avatar: Record<string, ClientStorageOptions<string>>;
1745
- pronoun: Record<string, ClientStorageOptions<Alejo.Pronouns.name>>;
1746
- emote: Record<string, ClientStorageOptions<string>>;
1747
- };
1748
- type ClientOptions = {
1749
- id?: string;
1750
- debug?: boolean | (() => boolean);
1751
- };
1752
- declare class Client extends EventProvider<ClientEvents> {
1753
- id: string;
1754
- debug: boolean;
1755
- storage: useStorage<ClientStorage>;
1756
- fields: StreamElements.Event.onWidgetLoad['fieldData'];
1757
- session: StreamElements.Session.Data;
1758
- loaded: boolean;
1759
- constructor(options: ClientOptions);
1760
- actions: {
1761
- commands: Command[];
1762
- buttons: Button[];
1763
- };
1764
- details: {
1765
- provider: Provider$1 | 'local';
1766
- user: StreamElements.Event.onWidgetLoad['channel'];
1767
- currency: StreamElements.Event.onWidgetLoad['currency'];
1768
- overlay: StreamElements.Event.onWidgetLoad['overlay'];
1769
- };
1770
- cache: {
2156
+ namespace object {
2157
+ /**
2158
+ * Flattens a nested object into a single-level object with dot-separated keys.
2159
+ * @param obj - The nested object to be flattened.
2160
+ * @param prefix - The prefix to be added to each key (used for recursion).
2161
+ * @returns A flattened object with dot-separated keys.
2162
+ * @example
2163
+ * ```javascript
2164
+ * const nestedObj = { a: { b: 1, c: { d: 2 } }, e: [3, 4] };
2165
+ * const flatObj = flatten(nestedObj);
2166
+ * console.log(flatObj);
2167
+ * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
2168
+ * ```
2169
+ */
2170
+ function flatten(obj: Record<string, any>, stringify?: boolean, prefix?: string): Record<string, typeof stringify extends true ? string : string | number | boolean>;
2171
+ }
2172
+ namespace message {
2173
+ type BadgeOptions = Twitch.roles[] | Twitch.roles | `${Twitch.roles}, ${Twitch.roles}` | `${Twitch.roles}, ${Twitch.roles}, ${Twitch.roles}`;
2174
+ type TwitchResult = {
2175
+ keys: Twitch.roles[];
2176
+ badges: Twitch.badge[];
2177
+ };
2178
+ type YouTubeResult = {
2179
+ isVerified: boolean;
2180
+ isChatOwner: boolean;
2181
+ isChatSponsor: boolean;
2182
+ isChatModerator: boolean;
2183
+ };
2184
+ /**
2185
+ * Finds emotes in a given text.
2186
+ * @param text - The text to search for emotes.
2187
+ * @param emotes - An array of emotes to search for. Defaults to Local data emotes.
2188
+ * @returns An array of emotes found in the text with their positions.
2189
+ */
2190
+ function findEmotesInText(text: string, emotes?: Emote[]): Emote[];
2191
+ /**
2192
+ * Replaces emotes in the text with corresponding HTML image tags.
2193
+ * @param text - The text containing emotes.
2194
+ * @param emotes - An array of emotes with their positions in the text.
2195
+ * @returns The text with emotes replaced by HTML image tags.
2196
+ */
2197
+ function replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
2198
+ /**
2199
+ * Replaces YouTube emotes in the text with corresponding HTML image tags.
2200
+ * @param text - The text containing YouTube emotes.
2201
+ * @param emotes - An array of YouTube emotes. Defaults to Local data YouTube emotes.
2202
+ * @returns The text with YouTube emotes replaced by HTML image tags.
2203
+ */
2204
+ function replaceYoutubeEmotesWithHTML(text: string, emotes?: {
2205
+ emojiId: string;
2206
+ shortcuts: string[];
2207
+ searchTerms: string[];
2208
+ image: {
2209
+ thumbnails: {
2210
+ url: string;
2211
+ width: number;
2212
+ height: number;
2213
+ }[];
2214
+ accessibility: {
2215
+ accessibilityData: {
2216
+ label: string;
2217
+ };
2218
+ };
2219
+ };
2220
+ isCustomEmoji: boolean;
2221
+ index: number;
2222
+ }[]): string;
2223
+ /**
2224
+ * Generates badge data based on the provided badges and platform.
2225
+ * @param badges - The badges to generate. Can be an array or a comma-separated string.
2226
+ * @param provider - The platform provider ('twitch' or 'youtube'). Defaults to 'twitch'.
2227
+ * @returns A promise that resolves to the generated badge data.
2228
+ * @example
2229
+ * ```javascript
2230
+ * // Generate Twitch badges
2231
+ * const twitchBadges = await generateBadges(['broadcaster', 'moderator'], 'twitch');
2232
+ * // Generate YouTube badges
2233
+ * const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube');
2234
+ * ```
2235
+ */
2236
+ function generateBadges<T extends Provider$1>(badges: BadgeOptions | undefined, provider: T): Promise<T extends 'twitch' ? TwitchResult : YouTubeResult>;
2237
+ }
2238
+ namespace event {
2239
+ /**
2240
+ * Parses the provider information from the event detail object.
2241
+ * @param detail - The event detail object received from the StreamElements event.
2242
+ * @returns An object containing the provider and the original event data.
2243
+ */
2244
+ function parseProvider(detail: StreamElements.Event.onEventReceived): ClientEvents$1;
2245
+ }
2246
+ namespace string {
2247
+ type Modifier = (value: string, param: string | null | undefined, values: {
2248
+ amount?: number;
2249
+ count?: number;
2250
+ }) => string;
2251
+ /**
2252
+ * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
2253
+ * @param string - The input string to perform replacements on.
2254
+ * @param pattern - The pattern to match in the string (can be a string or a regular expression).
2255
+ * @param callback - An asynchronous callback function that takes the matched substring and any captured groups as arguments and returns the replacement string.
2256
+ * @returns A promise that resolves to the modified string with replacements applied.
2257
+ * @example
2258
+ * ```javascript
2259
+ * const result = await string.replace("Hello World", /World/, async (match) => {
2260
+ * return await fetchSomeData(match); // Assume this function fetches data asynchronously
2261
+ * });
2262
+ * console.log(result); // Output will depend on the fetched data
2263
+ * ```
2264
+ */
2265
+ function replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2266
+ /**
2267
+ * Capitalizes the first letter of a given string.
2268
+ * @param string - The input string to be capitalized.
2269
+ * @returns The capitalized string.
2270
+ * @example
2271
+ * ```javascript
2272
+ * const result = string.capitalize("hello world");
2273
+ * console.log(result); // Output: "Hello world"
2274
+ * ```
2275
+ */
2276
+ function capitalize(string: string): Capitalize<string>;
2277
+ /**
2278
+ * Composes a template string by replacing placeholders with corresponding values and applying optional modifiers.
2279
+ * @param template - The template string containing placeholders in the format {key} and optional modifiers in the format [MODIFIER:param=value].
2280
+ * @param values - An object containing key-value pairs to replace the placeholders in the template.
2281
+ * @param options - Optional settings for the composition process.
2282
+ * @returns The composed string with placeholders replaced and modifiers applied.
2283
+ * @example
2284
+ * ```javascript
2285
+ * const template = "Hello, {username}! You have {amount} [UPPERCASE=messages] and your name is [CAPITALIZE=name].";
2286
+ * const values = { username: "john_doe", amount: 5, name: "john" };
2287
+ * const result = string.compose(template, values);
2288
+ * console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
2289
+ * ```
2290
+ */
2291
+ function compose(template: string, values?: Record<string, any>, options?: {
2292
+ method?: 'loop' | 'index';
2293
+ html?: boolean;
2294
+ modifiers?: Record<string, Modifier>;
2295
+ aliases?: Record<string, string[]>;
2296
+ }): string;
2297
+ }
2298
+ namespace sound {
2299
+ let playing: boolean;
2300
+ let audio: AudioContext;
2301
+ /**
2302
+ * Play sound from URL with optional volume and replace parameters
2303
+ * @param url - Sound URL to play
2304
+ * @param volume - Volume level from 0 to 100 (default: 100)
2305
+ * @param replace - If true, replaces currently playing sound (default: false)
2306
+ */
2307
+ function play(url: string, volume?: number, replace?: boolean): void;
2308
+ }
2309
+ namespace color {
2310
+ /**
2311
+ * Generate opacity hex value
2312
+ * @param opacity - Opacity value from 0 to 100
2313
+ * @param color - Hex color code
2314
+ * @returns - Hex color code with opacity
2315
+ */
2316
+ function opacity(opacity?: number, color?: string): string;
2317
+ /**
2318
+ * Extract color and opacity from hex code
2319
+ * @param hex - Hex color code
2320
+ * @returns - Object with color and opacity
2321
+ */
2322
+ function extract(hex: string): {
2323
+ color: string;
2324
+ opacity: number;
2325
+ };
2326
+ /**
2327
+ * Validate color string format
2328
+ * @param str - Color string to validate
2329
+ * @returns Detected color format or false if invalid
2330
+ * @example
2331
+ * ```javascript
2332
+ * const format1 = color.validate("#FF5733"); // "hex"
2333
+ * const format2 = color.validate("rgb(255, 87, 51)"); // "rgb"
2334
+ * const format3 = color.validate("hsl(14, 100%, 60%)"); // "hsl"
2335
+ * const format4 = color.validate("orangered"); // "css-color-name"
2336
+ * const format5 = color.validate("invalid-color"); // false
2337
+ * ```
2338
+ */
2339
+ function validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
2340
+ /**
2341
+ * Convert color to different format
2342
+ * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)")
2343
+ * @param format - Target format
2344
+ * @returns - Converted color string
2345
+ * @example
2346
+ * ```javascript
2347
+ * const hexColor = color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733"
2348
+ * const rgbColor = color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)"
2349
+ * const hslColor = color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)"
2350
+ * const colorName = color.convert("#FF5733", "css-color-name"); // "orangered"
2351
+ * ```
2352
+ */
2353
+ function convert(str: string, format: 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): Promise<string | null>;
2354
+ }
2355
+ namespace random {
2356
+ /**
2357
+ * Generate random color
2358
+ * @param type - Color format
2359
+ * @returns - Random color in specified format
2360
+ * @example
2361
+ * ```javascript
2362
+ * const hexColor = random.color('hex');
2363
+ * console.log(hexColor); // e.g. #3e92cc
2364
+ *
2365
+ * const rgbColor = random.color('rgb');
2366
+ * console.log(rgbColor); // e.g. rgb(62, 146, 204)
2367
+ * ```
2368
+ */
2369
+ function color(type?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): string;
2370
+ /**
2371
+ * Generate random number
2372
+ * @param min - Minimum value
2373
+ * @param max - Maximum value
2374
+ * @param float - Number of decimal places (0 for integer)
2375
+ * @returns - Random number
2376
+ * @example
2377
+ * ```javascript
2378
+ * const intNumber = random.number(1, 10);
2379
+ * console.log(intNumber); // e.g. 7
2380
+ *
2381
+ * const floatNumber = random.number(1, 10, 2);
2382
+ * console.log(floatNumber); // e.g. 3.14
2383
+ * ```
2384
+ */
2385
+ function number(min: number, max: number, float?: number): number;
1771
2386
  /**
1772
- * Avatar cache duration in minutes.
2387
+ * Generate random boolean
2388
+ * @param threshold - Threshold between 0 and 1
2389
+ * @returns - Random boolean
2390
+ * @example
2391
+ * ```javascript
2392
+ * const boolValue = random.boolean(0.7);
2393
+ * console.log(boolValue); // e.g. true (70% chance)
2394
+ * ```
1773
2395
  */
1774
- avatar: number;
2396
+ function boolean(threshold?: number): boolean;
1775
2397
  /**
1776
- * Pronoun cache duration in minutes.
2398
+ * Generate random string
2399
+ * @param length - Length of the string
2400
+ * @param chars - Characters to use
2401
+ * @returns - Random string
2402
+ * @example
2403
+ * ```javascript
2404
+ * const randString = random.string(10);
2405
+ * console.log(randString); // e.g. "aZ3bT9xYqP"
2406
+ * ```
1777
2407
  */
1778
- pronoun: number;
2408
+ function string(length: number, chars?: string): string;
1779
2409
  /**
1780
- * Emote cache duration in minutes.
2410
+ * Pick random element from array
2411
+ * @param arr - Array to pick from
2412
+ * @returns - Random element and its index
2413
+ * @example
2414
+ * ```javascript
2415
+ * const [element, index] = random.array(['apple', 'banana', 'cherry']);
2416
+ * console.log(element, index); // e.g. "banana", 1
2417
+ * ```
1781
2418
  */
1782
- emote: number;
1783
- };
1784
- on<K extends keyof ClientEvents>(eventName: K, callback: (this: Client, ...args: ClientEvents[K]) => void): this;
1785
- }
1786
-
1787
- interface CommandOptions {
1788
- prefix?: string;
1789
- name: string;
1790
- description?: string;
1791
- arguments?: boolean;
1792
- run: (this: Client, args: string[], event: CommandEvent) => void;
1793
- test?: string;
1794
- aliases?: string[];
1795
- permissions?: string[];
1796
- admins?: string[];
1797
- }
1798
- type CommandEvent = {
1799
- provider: 'twitch';
1800
- data: StreamElements.Event.Provider.Twitch.Message;
1801
- } | {
1802
- provider: 'youtube';
1803
- data: StreamElements.Event.Provider.YouTube.Message;
1804
- } | {
1805
- provider: 'kick';
1806
- data: any;
1807
- };
1808
- declare class Command {
1809
- prefix: string;
1810
- name: string;
1811
- description: string;
1812
- arguments: boolean;
1813
- test: string;
1814
- aliases: string[];
1815
- permissions?: string[] | boolean;
1816
- admins: string[];
1817
- constructor(options: CommandOptions);
1818
- run(this: Client, args: string[], event: CommandEvent): void;
1819
- verify(nickname: string, roles: string[], args: string[]): boolean;
1820
- parse(text: string, event: CommandEvent): boolean;
1821
- remove(): void;
1822
- static execute(received: CommandEvent): boolean;
1823
- }
1824
-
1825
- type QueueEvents<T> = {
1826
- load: [];
1827
- cancel: [];
1828
- update: [queue: QueueItem<T>[], priorityQueue: QueueItem<T>[], history: QueueItem<T>[], timeouts: Array<ReturnType<typeof setTimeout>>];
1829
- process: [item: QueueItem<T>, queue: useQueue<T>];
1830
- };
1831
- type QueueProps = {
1832
- isoDate: string;
1833
- isLoop: boolean;
1834
- isPriority: boolean;
1835
- isImmediate: boolean;
1836
- };
1837
- type QueueItem<T> = {
1838
- value: T;
1839
- } & QueueProps;
1840
- type QueueProcessor<T> = (item: T, queue: useQueue<T>) => Promise<any>;
1841
- type QueueDuration = number | boolean | undefined;
1842
- interface QueueOptions<T> {
1843
- /**
1844
- * Duration between processing each item in milliseconds. Set to `0` or `false` for immediate processing.
1845
- */
1846
- duration?: QueueDuration | 'client';
1847
- /**
1848
- * Function to process each item in the queue.
1849
- */
1850
- processor: QueueProcessor<T>;
1851
- }
1852
- /**
1853
- * A utility class to manage a queue of items with support for priority, looping, and immediate processing.
1854
- * @template T - The type of items in the queue.
1855
- * @extends EventProvider<QueueEvents<T>>
1856
- * @example
1857
- * ```javascript
1858
- * const myQueue = new useQueue({
1859
- * duration: 1000,
1860
- * processor: async (item) => {
1861
- * console.log('Processing item:', item);
1862
- * },
1863
- * });
1864
- *
1865
- * myQueue.enqueue('Item 1');
1866
- * myQueue.enqueue('Item 2', { isPriority: true });
1867
- * ```
1868
- */
1869
- declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
1870
- queue: QueueItem<T>[];
1871
- priorityQueue: QueueItem<T>[];
1872
- history: QueueItem<T>[];
1873
- private timeouts;
1874
- running: boolean;
1875
- duration: QueueDuration;
1876
- private loaded;
1877
- processor: QueueProcessor<T>;
1878
- constructor(options: QueueOptions<T>);
1879
- enqueue(value: T, options?: Partial<QueueProps>): this;
1880
- private run;
1881
- private next;
1882
- resume(): this;
1883
- update(save: Partial<useQueue<T>>): this;
1884
- cancel(): void;
1885
- hasItems(): boolean;
1886
- on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
2419
+ function array<T>(arr: T[]): [value: T, index: number];
2420
+ /**
2421
+ * Generate random date
2422
+ * @param start - Start date
2423
+ * @param end - End date
2424
+ * @returns - Random date between start and end
2425
+ * @example
2426
+ * ```javascript
2427
+ * const randDate = random.date(new Date(2020, 0, 1), new Date());
2428
+ * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
2429
+ * ```
2430
+ */
2431
+ function date(start?: Date, end?: Date): Date;
2432
+ /**
2433
+ * Generate ISO date string offset by days
2434
+ * @param daysAgo - Number of days to go back
2435
+ * @returns - ISO date string
2436
+ * @example
2437
+ * ```javascript
2438
+ * const isoDate = random.daysOffset(7);
2439
+ * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
2440
+ *
2441
+ * const isoDate30 = random.daysOffset(30);
2442
+ * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
2443
+ * ```
2444
+ */
2445
+ function daysOffset(daysAgo: number): string;
2446
+ /**
2447
+ * Generate UUID v4
2448
+ * @returns - UUID string
2449
+ * @example
2450
+ * ```javascript
2451
+ * const uuid = random.uuid();
2452
+ * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
2453
+ * ```
2454
+ */
2455
+ function uuid(): string;
2456
+ }
1887
2457
  }
1888
2458
 
1889
- type TwitchEmote = {
1890
- type: 'twitch';
1891
- name: string;
1892
- id: string;
1893
- gif: boolean;
1894
- urls: {
1895
- '1': string;
1896
- '2': string;
1897
- '4': string;
1898
- };
1899
- start: number;
1900
- end: number;
1901
- };
1902
- type SeventvEmote = {
1903
- type: '7tv';
1904
- name: string;
1905
- id: string;
1906
- gif: boolean;
1907
- animated: boolean;
1908
- urls: {
1909
- '1': string;
1910
- '2': string;
1911
- '3': string;
1912
- '4': string;
1913
- };
1914
- start: number;
1915
- end: number;
1916
- cords: {
1917
- x: number;
1918
- y: number;
1919
- };
1920
- };
1921
- type BttvEmote = {
1922
- type: 'bttv';
1923
- name: string;
1924
- id: string;
1925
- gif: boolean;
1926
- animated: boolean;
1927
- urls: {
1928
- '1': string;
1929
- '2': string;
1930
- '4': string;
1931
- };
1932
- start: number;
1933
- end: number;
1934
- coords: {
1935
- x: number;
1936
- y: number;
1937
- width: number;
1938
- height: number;
1939
- };
1940
- };
1941
-
1942
- type Emote = TwitchEmote | BttvEmote | SeventvEmote;
1943
- type BadgeOptions = Twitch.roles[] | Twitch.roles | `${Twitch.roles}, ${Twitch.roles}` | `${Twitch.roles}, ${Twitch.roles}, ${Twitch.roles}`;
1944
-
1945
2459
  declare namespace Local {
1946
2460
  type Queue = useQueue<{
1947
2461
  listener: 'onEventReceived';
@@ -1999,7 +2513,7 @@ declare namespace Local {
1999
2513
  message(data?: Partial<{
2000
2514
  name: string;
2001
2515
  message: string;
2002
- badges: BadgeOptions;
2516
+ badges: Helper.message.BadgeOptions;
2003
2517
  color: string;
2004
2518
  userId: string;
2005
2519
  msgId: string;
@@ -2046,7 +2560,7 @@ declare namespace Local {
2046
2560
  message(data?: Partial<{
2047
2561
  name: string;
2048
2562
  message: string;
2049
- badges: BadgeOptions;
2563
+ badges: Helper.message.BadgeOptions;
2050
2564
  color: string;
2051
2565
  userId: string;
2052
2566
  msgId: string;
@@ -2175,142 +2689,6 @@ declare class useLogger {
2175
2689
  readonly simple: LogMethod;
2176
2690
  }
2177
2691
 
2178
- interface ScaleOptions<T extends HTMLElement> {
2179
- /**
2180
- * The parent element to use for scaling calculations. If not provided, the element's parent will be used.
2181
- */
2182
- parent?: HTMLElement;
2183
- /**
2184
- * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default).
2185
- */
2186
- prefer?: 'width' | 'height' | 'auto';
2187
- /**
2188
- * The minimum percentage of the parent size to scale to. Default is 0.
2189
- */
2190
- min?: number;
2191
- /**
2192
- * The maximum percentage of the parent size to scale to. Default is 1 (100%).
2193
- */
2194
- max?: number;
2195
- /**
2196
- * A callback function that is called after scaling is applied.
2197
- * @param this - The HTML element being scaled.
2198
- * @param number - The scale factor applied to the element.
2199
- * @param element - The HTML element being scaled.
2200
- * @returns void
2201
- */
2202
- apply?: (this: T, number: number, element: T) => void;
2203
- }
2204
- type FitTextOptions = {
2205
- minFontSize?: number;
2206
- maxFontSize?: number;
2207
- parent?: HTMLElement;
2208
- };
2209
-
2210
- declare namespace Helper {
2211
- const sound: {
2212
- playing: boolean;
2213
- audio: AudioContext | null;
2214
- play(url: string, volume?: number, replace?: boolean): void;
2215
- };
2216
- const element: {
2217
- mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2218
- scale(element: HTMLElement, min?: number, max?: number, options?: {
2219
- return: boolean;
2220
- parent: HTMLElement;
2221
- base: "width" | "height";
2222
- }): {
2223
- width: number;
2224
- height: number;
2225
- scale: number;
2226
- } | void;
2227
- scalev2<T extends HTMLElement>(element: T, options?: ScaleOptions<T>): number;
2228
- fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement;
2229
- splitTextToChars(htmlString: string, startIndex?: number): string;
2230
- };
2231
- const color: {
2232
- opacity(opacity?: number, color?: string): string;
2233
- extract(hex: string): {
2234
- color: string;
2235
- opacity: number;
2236
- };
2237
- validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
2238
- convert(str: string, format: "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): Promise<string | null>;
2239
- random: (type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name") => string;
2240
- };
2241
- const object: {
2242
- flatten(obj: Record<string, any>, stringify?: boolean, prefix?: string): Record<string, typeof stringify extends true ? string : string | number | boolean>;
2243
- };
2244
- const utils: {
2245
- delay<R extends unknown, M extends number>(ms: M, callback?: () => R): Promise<R | null>;
2246
- typedEntries<K extends string, V>(obj: Record<K, V>): [K, V][];
2247
- probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2248
- };
2249
- const random: {
2250
- color(type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string;
2251
- number(min: number, max: number, float?: number): number;
2252
- boolean(threshold?: number): boolean;
2253
- string(length: number, chars?: string): string;
2254
- array<T>(arr: T[]): [value: T, index: number];
2255
- date(start?: Date, end?: Date): Date;
2256
- daysOffset(daysAgo: number): string;
2257
- uuid(): string;
2258
- };
2259
- const number: {
2260
- translate(num: number, type?: "cardinal" | "ordinal" | "suffix"): string;
2261
- balance(amount: number, min?: number, max?: number): number;
2262
- round(value: number, decimals?: number): number;
2263
- };
2264
- const string: {
2265
- replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2266
- capitalize(string: string): Capitalize<string>;
2267
- compose(template: string, values?: Record<string, any>, options?: {
2268
- method?: "loop" | "index";
2269
- html?: boolean;
2270
- modifiers?: Record<string, (value: string, param: string | null | undefined, values: {
2271
- amount?: number;
2272
- count?: number;
2273
- }) => string>;
2274
- aliases?: Record<string, string[]>;
2275
- }): string;
2276
- };
2277
- const message: {
2278
- findEmotesInText(text: string, emotes?: Emote[]): Emote[];
2279
- replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
2280
- replaceYoutubeEmotesWithHTML(text: string, emotes?: {
2281
- emojiId: string;
2282
- shortcuts: string[];
2283
- searchTerms: string[];
2284
- image: {
2285
- thumbnails: {
2286
- url: string;
2287
- width: number;
2288
- height: number;
2289
- }[];
2290
- accessibility: {
2291
- accessibilityData: {
2292
- label: string;
2293
- };
2294
- };
2295
- };
2296
- isCustomEmoji: boolean;
2297
- index: number;
2298
- }[]): string;
2299
- generateBadges<T extends Provider$1>(badges: BadgeOptions | undefined, provider: T): Promise<T extends "twitch" ? {
2300
- keys: Twitch.roles[];
2301
- badges: Twitch.badge[];
2302
- } : {
2303
- isVerified: boolean;
2304
- isChatOwner: boolean;
2305
- isChatSponsor: boolean;
2306
- isChatModerator: boolean;
2307
- }>;
2308
- };
2309
- const event: {
2310
- parseProvider(detail: StreamElements.Event.onEventReceived): ClientEvents$1;
2311
- };
2312
- }
2313
-
2314
2692
  declare namespace Data {
2315
2693
  const avatars: string[];
2316
2694
  const badges: Record<Twitch.roles, Twitch.badge>;
@@ -2387,4 +2765,4 @@ declare global {
2387
2765
  }
2388
2766
 
2389
2767
  export { Alejo, Button, Command, EventProvider, StreamElements, StreamElementsEvents, Twitch, TwitchEvents, YoutubeEvents, main as default, useComfyJs, useLogger, useQueue, useStorage };
2390
- export type { BttvEmote, ClientEvents$1 as ClientEvents, Provider$1 as Provider, SeventvEmote, TwitchEmote };
2768
+ export type { BttvEmote, ClientEvents$1 as ClientEvents, Emote, Provider$1 as Provider, SeventvEmote, TwitchEmote };