@mkody/twitch-emoticons 3.0.0-beta.4 → 3.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -23
- package/SECURITY.md +10 -9
- package/dist/TwitchEmoticons.cjs +49 -49
- package/dist/TwitchEmoticons.esm.min.js +1 -1
- package/dist/TwitchEmoticons.esm.min.js.map +2 -2
- package/dist/TwitchEmoticons.min.js +1 -1
- package/dist/TwitchEmoticons.min.js.map +2 -2
- package/package.json +4 -4
- package/src/struct/BTTVEmote.js +10 -10
- package/src/struct/Channel.js +5 -5
- package/src/struct/Emote.js +11 -10
- package/src/struct/EmoteFetcher.js +15 -15
- package/src/struct/EmoteParser.js +3 -3
- package/src/struct/FFZEmote.js +10 -9
- package/src/struct/SevenTVEmote.js +12 -10
- package/src/struct/TwitchEmote.js +8 -8
- package/src/util/Collection.js +2 -2
- package/typings/index.d.cts +349 -6
- package/typings/index.d.ts +348 -6
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!
|
|
|
25
25
|
- The defaults for `EmoteParser` changed to use the `html` template, and it does not require `:colons:` by default (using `/(\w+)/` to match any words).
|
|
26
26
|
- The default `html` template does not have `twitch-emote-{size}` anymore in its `class` attribute.
|
|
27
27
|
*The `size` is inconsistent between the different sources, so it cannot be reliably used.*
|
|
28
|
-
- If you somehow used `EmoteFetcher.globalChannel`, it has now been removed.
|
|
28
|
+
- If you somehow used `EmoteFetcher.globalChannel`, it has now been removed.
|
|
29
|
+
*Directly use `EmoteFetcher.channels.get(null)` instead.*
|
|
29
30
|
- The `EmoteFetcher.fetchSevenTVEmotes()`, `Emote.toLink()`, and `EmoteParse.parse()` methods now have their options as an object.
|
|
30
31
|
- `fetcher.fetchSevenTVEmotes(null, { format: 'avif' })` - The first parameter is still the Twitch user ID (or `null` for global).
|
|
31
32
|
- `emote.toLink({ size: 1, forceStatic: true, themeMode: 'light' })`
|
|
@@ -97,7 +98,7 @@ To fetch "native" emotes from Twitch.tv, you need to [create an app here](https:
|
|
|
97
98
|
If you are only using BetterTTV, FrankerFaceZ and 7TV you do not need to provide Twitch app keys.
|
|
98
99
|
|
|
99
100
|
You must use a Twitch user ID instead of the username to fetch users' emotes.
|
|
100
|
-
|
|
101
|
+
If you just need to get one or a very few, you can [use this page to manually convert them](https://s.kdy.ch/twitchid/) (please do not automate/abuse it).
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
## Install
|
|
@@ -189,10 +190,24 @@ await fetcher.fetchFFZEmotes()
|
|
|
189
190
|
await fetcher.fetchSevenTVEmotes(null, { format: 'avif' }) // Example of loading images in AVIF here
|
|
190
191
|
```
|
|
191
192
|
|
|
193
|
+
With the emotes now fetched, you can look them up!
|
|
194
|
+
To grab a specific emote, you can do `fetcher.emotes.get('...')`, with the case-sensitive name of the emote in place of the ellipsis.
|
|
195
|
+
From there, you can read properties like `.id`, `.code`, `.ownerName`,
|
|
196
|
+
`.animated`, `.imageType`, or `.type`, but you can also use the `.toLink()`
|
|
197
|
+
method to… get a link!
|
|
198
|
+
|
|
199
|
+
> Note: Some extended `Emote`s have additional properties:
|
|
200
|
+
> - FFZ:
|
|
201
|
+
> - `.zeroWidth` (boolean, can overlay an another emote)
|
|
202
|
+
> - `.modifier` (boolean, emote effects, should be hidden)
|
|
203
|
+
> - 7TV:
|
|
204
|
+
> - `.zeroWidth` (boolean, can overlay an another emote)
|
|
205
|
+
> - `.nsfw` (boolean, flagged "Sexual" or "Twitch disallowed")
|
|
206
|
+
|
|
192
207
|
|
|
193
208
|
### Parse strings to include emotes with `EmoteParser`
|
|
194
209
|
|
|
195
|
-
And now that we have our list of emotes that we can expect to find, we should use it
|
|
210
|
+
And now that we have our list of emotes that we can expect to find, we should use it.
|
|
196
211
|
Create an `EmoteParser` object:
|
|
197
212
|
|
|
198
213
|
```js
|
|
@@ -220,24 +235,8 @@ const parser = new EmoteParser(
|
|
|
220
235
|
)
|
|
221
236
|
```
|
|
222
237
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
To grab a specific emote, you can do `fetcher.emotes.get('...')`, with the case-sensitive name of the emote in place of the ellipsis.
|
|
227
|
-
From there, you can read properties like `.id`, `.code`, `.ownerName`,
|
|
228
|
-
`.animated`, `.imageType`, or `.type`, but you can also use the `.toLink()`
|
|
229
|
-
method to… get a link!
|
|
230
|
-
|
|
231
|
-
> Note: Some extended `Emote`s have additional properties:
|
|
232
|
-
> - FFZ:
|
|
233
|
-
> - `.zeroWidth` (boolean, can overlay an another emote)
|
|
234
|
-
> - `.modifier` (boolean, emote effects, should be hidden)
|
|
235
|
-
> - 7TV:
|
|
236
|
-
> - `.zeroWidth` (boolean, can overlay an another emote)
|
|
237
|
-
> - `.nsfw` (boolean, flagged "Sexual" or "Twitch disallowed")
|
|
238
|
-
|
|
239
|
-
To parse text, you use the `parser.parse()` method.
|
|
240
|
-
The first parameter is the input text. There is also an optional second parameter
|
|
238
|
+
And now, we can parse text and get the output as set by `type` or `template`, using the `parser.parse()` method.
|
|
239
|
+
Just pass the input text as the first parameter. There is also an optional second parameter
|
|
241
240
|
where you can provide a few settings (which can overwrite the same ones set in the `EmoteFetcher`).
|
|
242
241
|
|
|
243
242
|
```js
|
|
@@ -339,7 +338,7 @@ const fetcher = new EmoteFetcher({
|
|
|
339
338
|
})
|
|
340
339
|
const parser = new EmoteParser(fetcher, {
|
|
341
340
|
// Custom HTML format
|
|
342
|
-
template:
|
|
341
|
+
template: `
|
|
343
342
|
<img
|
|
344
343
|
class="emote"
|
|
345
344
|
alt="{name}"
|
|
@@ -532,7 +531,7 @@ fetcher.fromObject(emotes)
|
|
|
532
531
|
```
|
|
533
532
|
|
|
534
533
|
> **NOTE:**
|
|
535
|
-
> For offline access, you
|
|
534
|
+
> For offline access, you will still need to download emotes and proxy their URLs.
|
|
536
535
|
|
|
537
536
|
</details>
|
|
538
537
|
|
package/SECURITY.md
CHANGED
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Supported Versions
|
|
4
4
|
|
|
5
|
-
| Version | Supported
|
|
6
|
-
| ------- |
|
|
7
|
-
| >= 3.0 | :white_check_mark: |
|
|
8
|
-
| >= 2.9 | :white_check_mark: |
|
|
9
|
-
| < 2.9 | :x:
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ---------------------------------.--- |
|
|
7
|
+
| >= 3.0 | :white_check_mark: (current) |
|
|
8
|
+
| >= 2.9 | :white_check_mark: (until March 2027) |
|
|
9
|
+
| < 2.9 | :x: |
|
|
10
|
+
|
|
10
11
|
|
|
11
12
|
## Reporting a Vulnerability
|
|
12
13
|
|
|
13
14
|
**Please do not report security vulnerabilities through public GitHub issues.**
|
|
14
15
|
|
|
15
|
-
Try to get in touch with the main maintainer by email at `im`[at]`kdy.ch` ([PGP](https://kdy.ch/pubkey.txt))
|
|
16
|
+
Try to get in touch with the main maintainer by email at `im`[at]`kdy.ch` ([PGP](https://kdy.ch/pubkey.txt)) with `[SECURITY]` prefixed in the subject line.
|
|
16
17
|
|
|
17
|
-
You should expect a reply within
|
|
18
|
+
You should expect a reply within 48 hours. If for some reason it does not happen, please follow up again via email or [try to notify me on an another platform](https://kdy.ch) that I should have recieved an email from you.
|
|
18
19
|
|
|
19
|
-
Please prefer to use English and
|
|
20
|
+
Please prefer to use English and provide as much information as possible, including:
|
|
20
21
|
|
|
21
22
|
- Version(s) tested
|
|
22
23
|
- Full path to the file(s) being the cause of the report
|
|
23
|
-
- The tested environnement (i.e. the OS and its version, NodeJS version)
|
|
24
|
+
- The tested environnement (i.e. the OS and its version, NodeJS/runtime version)
|
|
24
25
|
- Special configuration used, if any
|
|
25
26
|
- A proof-of-concept or the code used for exploitation, if possible
|
|
26
27
|
- Explanation of the impact and how an attacker can run an exploit
|
package/dist/TwitchEmoticons.cjs
CHANGED
|
@@ -37,14 +37,14 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
var Emote = class _Emote {
|
|
38
38
|
/**
|
|
39
39
|
* Base class for emotes.
|
|
40
|
-
* This constructor is not to be used.
|
|
41
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
40
|
+
* This constructor is not to be used directly.
|
|
41
|
+
* @param {Channel} channel - {@linkcode Channel} this emote belongs to.
|
|
42
42
|
* @param {string} id - ID of the emote.
|
|
43
43
|
* @param {data} data - The raw emote data.
|
|
44
44
|
* @throws {Error} When trying to use the base Emote class directly.
|
|
45
45
|
*/
|
|
46
46
|
constructor(channel, id, data) {
|
|
47
|
-
if (new.target
|
|
47
|
+
if (new.target === _Emote) {
|
|
48
48
|
throw new Error("Base Emote class cannot be used");
|
|
49
49
|
}
|
|
50
50
|
this.fetcher = channel.fetcher;
|
|
@@ -76,8 +76,8 @@ var Emote = class _Emote {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Override for `toObject`.
|
|
79
|
-
* Will result in an Object representation of an Emote
|
|
80
|
-
* @returns {object} - Object representation of the Emote.
|
|
79
|
+
* Will result in an Object representation of an {@linkcode Emote}.
|
|
80
|
+
* @returns {object} - Object representation of the {@linkcode Emote}.
|
|
81
81
|
*/
|
|
82
82
|
toObject() {
|
|
83
83
|
return {
|
|
@@ -175,7 +175,7 @@ var Constants_default = {
|
|
|
175
175
|
var BTTVEmote = class _BTTVEmote extends Emote_default {
|
|
176
176
|
/**
|
|
177
177
|
* A BTTV emote.
|
|
178
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
178
|
+
* @param {Channel} channel - {@linkcode Channel} this emote belongs to.
|
|
179
179
|
* @param {string} id - ID of the emote.
|
|
180
180
|
* @param {data} data - The raw emote data.
|
|
181
181
|
*/
|
|
@@ -204,9 +204,9 @@ var BTTVEmote = class _BTTVEmote extends Emote_default {
|
|
|
204
204
|
return Constants_default.BTTV.CDN(this.id, size, forceStatic);
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
|
-
* Override for `toObject`.
|
|
208
|
-
* Will result in an Object representation of a BTTVEmote
|
|
209
|
-
* @returns {object} - Object representation of the BTTVEmote.
|
|
207
|
+
* Override of the override for `toObject`.
|
|
208
|
+
* Will result in an Object representation of a {@linkcode BTTVEmote}.
|
|
209
|
+
* @returns {object} - Object representation of the {@linkcode BTTVEmote}.
|
|
210
210
|
*/
|
|
211
211
|
toObject() {
|
|
212
212
|
return {
|
|
@@ -217,10 +217,10 @@ var BTTVEmote = class _BTTVEmote extends Emote_default {
|
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
|
-
* Converts an emote Object into a BTTVEmote
|
|
220
|
+
* Converts an emote Object into a {@linkcode BTTVEmote}
|
|
221
221
|
* @param {object} [emoteObject] - Object representation of this emote
|
|
222
|
-
* @param {Channel} [channel] - Channel this emote belongs to.
|
|
223
|
-
* @returns {BTTVEmote} - A BTTVEmote instance.
|
|
222
|
+
* @param {Channel} [channel] - {@linkcode Channel} this emote belongs to.
|
|
223
|
+
* @returns {BTTVEmote} - A {@linkcode BTTVEmote} instance.
|
|
224
224
|
*/
|
|
225
225
|
static fromObject(emoteObject, channel) {
|
|
226
226
|
return new _BTTVEmote(
|
|
@@ -243,9 +243,9 @@ var Collection = class extends Map {
|
|
|
243
243
|
/**
|
|
244
244
|
* Finds first matching value by property or function.
|
|
245
245
|
* Same as `Array#find`.
|
|
246
|
-
* @param {string|Function} propOrFunc - Property or function to test.
|
|
246
|
+
* @param {string | Function} propOrFunc - Property or function to test.
|
|
247
247
|
* @param {any} [value] - Value to find.
|
|
248
|
-
* @returns {any|null} - The found item or null if none found.
|
|
248
|
+
* @returns {any | null} - The found item or null if none found.
|
|
249
249
|
*/
|
|
250
250
|
find(propOrFunc, value) {
|
|
251
251
|
if (typeof propOrFunc === "string") {
|
|
@@ -330,21 +330,21 @@ var Channel = class {
|
|
|
330
330
|
/* c8 ignore start */
|
|
331
331
|
/**
|
|
332
332
|
* Fetches the BTTV emotes for this channel.
|
|
333
|
-
* @returns {Promise<Collection<string, BTTVEmote>>} - A promise that resolves to a collection of
|
|
333
|
+
* @returns {Promise<Collection<string, BTTVEmote>>} - A promise that resolves to a collection of {@linkcode BTTVEmote}s.
|
|
334
334
|
*/
|
|
335
335
|
fetchBTTVEmotes() {
|
|
336
336
|
return this.fetcher.fetchBTTVEmotes(this.id);
|
|
337
337
|
}
|
|
338
338
|
/**
|
|
339
339
|
* Fetches the FFZ emotes for this channel.
|
|
340
|
-
* @returns {Promise<Collection<string, FFZEmote>>} - A promise that resolves to a collection of
|
|
340
|
+
* @returns {Promise<Collection<string, FFZEmote>>} - A promise that resolves to a collection of {@linkcode FFZEmote}s.
|
|
341
341
|
*/
|
|
342
342
|
fetchFFZEmotes() {
|
|
343
343
|
return this.fetcher.fetchFFZEmotes(this.id);
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
346
|
* Fetches the 7TV emotes for this channel.
|
|
347
|
-
* @returns {Promise<Collection<string, SevenTVEmote>>} - A promise that resolves to a collection of
|
|
347
|
+
* @returns {Promise<Collection<string, SevenTVEmote>>} - A promise that resolves to a collection of {@linkcode SevenTVEmote}s.
|
|
348
348
|
*/
|
|
349
349
|
fetchSevenTVEmotes() {
|
|
350
350
|
return this.fetcher.fetchSevenTVEmotes(this.id);
|
|
@@ -357,7 +357,7 @@ var Channel_default = Channel;
|
|
|
357
357
|
var FFZEmote = class _FFZEmote extends Emote_default {
|
|
358
358
|
/**
|
|
359
359
|
* An FFZ emote.
|
|
360
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
360
|
+
* @param {Channel} channel - {@linkcode Channel} this emote belongs to.
|
|
361
361
|
* @param {string} id - ID of the emote.
|
|
362
362
|
* @param {data} data - The raw emote data.
|
|
363
363
|
*/
|
|
@@ -391,9 +391,9 @@ var FFZEmote = class _FFZEmote extends Emote_default {
|
|
|
391
391
|
return Constants_default.FFZ.CDN(this.id, sizeKey);
|
|
392
392
|
}
|
|
393
393
|
/**
|
|
394
|
-
* Override for `toObject`.
|
|
395
|
-
* Will result in an Object representation of a FFZEmote
|
|
396
|
-
* @returns {object} - Object representation of the FFZEmote.
|
|
394
|
+
* Override of the override for `toObject`.
|
|
395
|
+
* Will result in an Object representation of a {@linkcode FFZEmote}.
|
|
396
|
+
* @returns {object} - Object representation of the {@linkcode FFZEmote}.
|
|
397
397
|
*/
|
|
398
398
|
toObject() {
|
|
399
399
|
return {
|
|
@@ -407,10 +407,10 @@ var FFZEmote = class _FFZEmote extends Emote_default {
|
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
409
|
/**
|
|
410
|
-
* Converts an emote Object into a FFZEmote
|
|
410
|
+
* Converts an emote Object into a {@linkcode FFZEmote}
|
|
411
411
|
* @param {object} [emoteObject] - Object representation of this emote
|
|
412
|
-
* @param {Channel} [channel] - Channel this emote belongs to.
|
|
413
|
-
* @returns {FFZEmote} - A FFZEmote instance.
|
|
412
|
+
* @param {Channel} [channel] - {@linkcode Channel} this emote belongs to.
|
|
413
|
+
* @returns {FFZEmote} - A {@linkcode FFZEmote} instance.
|
|
414
414
|
*/
|
|
415
415
|
static fromObject(emoteObject, channel) {
|
|
416
416
|
const sizesObj = emoteObject.sizes.reduce(
|
|
@@ -441,7 +441,7 @@ var FFZEmote_default = FFZEmote;
|
|
|
441
441
|
var SevenTVEmote = class _SevenTVEmote extends Emote_default {
|
|
442
442
|
/**
|
|
443
443
|
* A 7TV emote.
|
|
444
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
444
|
+
* @param {Channel} channel - {@linkcode Channel} this emote belongs to.
|
|
445
445
|
* @param {string} id - ID of the emote.
|
|
446
446
|
* @param {data} data - The raw emote data.
|
|
447
447
|
*/
|
|
@@ -503,9 +503,9 @@ var SevenTVEmote = class _SevenTVEmote extends Emote_default {
|
|
|
503
503
|
return Constants_default.SevenTV.CDN(this.id, this.imageType, sizeKey, forceStatic);
|
|
504
504
|
}
|
|
505
505
|
/**
|
|
506
|
-
* Override for `toObject`.
|
|
507
|
-
* Will result in an Object representation of a SevenTVEmote
|
|
508
|
-
* @returns {object} - Object representation of the SevenTVEmote.
|
|
506
|
+
* Override of the override for `toObject`.
|
|
507
|
+
* Will result in an Object representation of a {@linkcode SevenTVEmote}.
|
|
508
|
+
* @returns {object} - Object representation of the {@linkcode SevenTVEmote}.
|
|
509
509
|
*/
|
|
510
510
|
toObject() {
|
|
511
511
|
return {
|
|
@@ -520,10 +520,10 @@ var SevenTVEmote = class _SevenTVEmote extends Emote_default {
|
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
522
|
/**
|
|
523
|
-
* Converts an emote Object into a SevenTVEmote
|
|
523
|
+
* Converts an emote Object into a {@linkcode SevenTVEmote}
|
|
524
524
|
* @param {object} [emoteObject] - Object representation of this emote
|
|
525
|
-
* @param {Channel} [channel] - Channel this emote belongs to.
|
|
526
|
-
* @returns {SevenTVEmote} - A SevenTVEmote instance.
|
|
525
|
+
* @param {Channel} [channel] - {@linkcode Channel} this emote belongs to.
|
|
526
|
+
* @returns {SevenTVEmote} - A {@linkcode SevenTVEmote} instance.
|
|
527
527
|
*/
|
|
528
528
|
static fromObject(emoteObject, channel) {
|
|
529
529
|
const sizes = emoteObject.sizes.map((size) => {
|
|
@@ -555,7 +555,7 @@ var SevenTVEmote_default = SevenTVEmote;
|
|
|
555
555
|
var TwitchEmote = class _TwitchEmote extends Emote_default {
|
|
556
556
|
/**
|
|
557
557
|
* A Twitch emote.
|
|
558
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
558
|
+
* @param {Channel} channel - {@linkcode Channel} this emote belongs to.
|
|
559
559
|
* @param {string} id - ID of the emote.
|
|
560
560
|
* @param {data} data - The raw emote data.
|
|
561
561
|
*/
|
|
@@ -586,9 +586,9 @@ var TwitchEmote = class _TwitchEmote extends Emote_default {
|
|
|
586
586
|
return Constants_default.Twitch.CDN(this.id, size, forceStatic, themeMode);
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
|
-
* Override for `toObject`.
|
|
590
|
-
* Will result in an Object representation of a TwitchEmote
|
|
591
|
-
* @returns {object} - Object representation of the TwitchEmote.
|
|
589
|
+
* Override of the override for `toObject`.
|
|
590
|
+
* Will result in an Object representation of a {@linkcode TwitchEmote}.
|
|
591
|
+
* @returns {object} - Object representation of the {@linkcode TwitchEmote}.
|
|
592
592
|
*/
|
|
593
593
|
toObject() {
|
|
594
594
|
return {
|
|
@@ -599,10 +599,10 @@ var TwitchEmote = class _TwitchEmote extends Emote_default {
|
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
601
|
/**
|
|
602
|
-
* Converts an emote Object into a TwitchEmote
|
|
602
|
+
* Converts an emote Object into a {@linkcode TwitchEmote}
|
|
603
603
|
* @param {object} [emoteObject] - Object representation of this emote
|
|
604
|
-
* @param {Channel} [channel] - Channel this emote belongs to.
|
|
605
|
-
* @returns {TwitchEmote} - A TwitchEmote instance.
|
|
604
|
+
* @param {Channel} [channel] -{@linkcode Channel} this emote belongs to.
|
|
605
|
+
* @returns {TwitchEmote} - A {@linkcode TwitchEmote} instance.
|
|
606
606
|
*/
|
|
607
607
|
static fromObject(emoteObject, channel) {
|
|
608
608
|
return new _TwitchEmote(
|
|
@@ -628,7 +628,7 @@ var EmoteFetcher = class {
|
|
|
628
628
|
* @param {object} [options={}] Fetcher's options.
|
|
629
629
|
* @param {string} [options.twitchAppID] Your app ID for the Twitch API.
|
|
630
630
|
* @param {string} [options.twitchAppSecret] Your app secret for the Twitch API.
|
|
631
|
-
* @param {ApiClient} [options.apiClient] - Bring your own Twurple ApiClient.
|
|
631
|
+
* @param {ApiClient} [options.apiClient] - Bring your own Twurple {@linkcode ApiClient}.
|
|
632
632
|
* @param {boolean} [options.forceStatic=false] - Force emotes to be static (non-animated).
|
|
633
633
|
* @param {'dark' | 'light'} [options.twitchThemeMode='dark'] - Theme mode (background color) preference for Twitch emotes.
|
|
634
634
|
*/
|
|
@@ -776,7 +776,7 @@ var EmoteFetcher = class {
|
|
|
776
776
|
* Gets the raw 7TV emotes data for a channel.
|
|
777
777
|
* @private
|
|
778
778
|
* @param {number} [id] - ID of the channel.
|
|
779
|
-
* @param {
|
|
779
|
+
* @param {'webp' | 'avif'} [format] - The type file format to use (webp/avif).
|
|
780
780
|
* @returns {Promise<object[]>} - A promise that resolves to an array of raw 7TV emote data.
|
|
781
781
|
*/
|
|
782
782
|
_getRawSevenTVEmotes(id, format) {
|
|
@@ -799,7 +799,7 @@ var EmoteFetcher = class {
|
|
|
799
799
|
* @private
|
|
800
800
|
* @param {number} channelId - ID of the channel.
|
|
801
801
|
* @param {object} data - Raw data.
|
|
802
|
-
* @param {
|
|
802
|
+
* @param {'webp' | 'avif'} format - The type file format to use (webp/avif).
|
|
803
803
|
* @param {SevenTVEmote} [existingEmote] - Existing emote to cache.
|
|
804
804
|
* @returns {SevenTVEmote} - A SevenTVEmote instance.
|
|
805
805
|
*/
|
|
@@ -814,7 +814,7 @@ var EmoteFetcher = class {
|
|
|
814
814
|
* Fetches the Twitch emotes for a channel.
|
|
815
815
|
* Use `null` for the global emotes channel.
|
|
816
816
|
* @param {number} [channel] - ID of the channel.
|
|
817
|
-
* @returns {Promise<Collection<string, TwitchEmote>>} - A promise that resolves to a collection of
|
|
817
|
+
* @returns {Promise<Collection<string, TwitchEmote>>} - A promise that resolves to a collection of {@linkcode TwitchEmote}s.
|
|
818
818
|
*/
|
|
819
819
|
fetchTwitchEmotes(channel) {
|
|
820
820
|
if (!channel) channel = null;
|
|
@@ -836,7 +836,7 @@ var EmoteFetcher = class {
|
|
|
836
836
|
* Fetches the BTTV emotes for a channel.
|
|
837
837
|
* Use `null` for the global emotes channel.
|
|
838
838
|
* @param {number} [channel] - ID of the channel.
|
|
839
|
-
* @returns {Promise<Collection<string, BTTVEmote>>} - A promise that resolves to a collection of
|
|
839
|
+
* @returns {Promise<Collection<string, BTTVEmote>>} - A promise that resolves to a collection of {@linkcode BTTVEmote}s.
|
|
840
840
|
*/
|
|
841
841
|
fetchBTTVEmotes(channel) {
|
|
842
842
|
if (!channel) channel = null;
|
|
@@ -850,7 +850,7 @@ var EmoteFetcher = class {
|
|
|
850
850
|
/**
|
|
851
851
|
* Fetches the FFZ emotes for a channel.
|
|
852
852
|
* @param {number} [channel] - ID of the channel.
|
|
853
|
-
* @returns {Promise<Collection<string, FFZEmote>>} - A promise that resolves to a collection of
|
|
853
|
+
* @returns {Promise<Collection<string, FFZEmote>>} - A promise that resolves to a collection of {@linkcode FFZEmote}s.
|
|
854
854
|
*/
|
|
855
855
|
async fetchFFZEmotes(channel) {
|
|
856
856
|
if (!channel) channel = null;
|
|
@@ -881,8 +881,8 @@ var EmoteFetcher = class {
|
|
|
881
881
|
* Fetches the 7TV emotes for a channel.
|
|
882
882
|
* @param {number} [channel] - ID of the channel.
|
|
883
883
|
* @param {object} [options] - Options for fetching.
|
|
884
|
-
* @param {
|
|
885
|
-
* @returns {Promise<Collection<string, SevenTVEmote>>} - A promise that resolves to a collection of
|
|
884
|
+
* @param {'webp' | 'avif'} [options.format] - The type file format to use (webp/avif).
|
|
885
|
+
* @returns {Promise<Collection<string, SevenTVEmote>>} - A promise that resolves to a collection of {@linkcode SevenTVEmote}s.
|
|
886
886
|
*/
|
|
887
887
|
fetchSevenTVEmotes(channel, options) {
|
|
888
888
|
if (!channel) channel = null;
|
|
@@ -898,10 +898,10 @@ var EmoteFetcher = class {
|
|
|
898
898
|
});
|
|
899
899
|
}
|
|
900
900
|
/**
|
|
901
|
-
* Converts emote
|
|
901
|
+
* Converts emote objects to emotes
|
|
902
902
|
* @param {object[]} [emotesArray] - An array of emote objects
|
|
903
903
|
* @throws {TypeError} When an emote has an unknown type.
|
|
904
|
-
* @returns {Emote[]} - An array of Emote instances.
|
|
904
|
+
* @returns {Emote[]} - An array of {@linkcode Emote} instances.
|
|
905
905
|
*/
|
|
906
906
|
fromObject(emotesArray) {
|
|
907
907
|
const emotes = [];
|
|
@@ -943,7 +943,7 @@ var EmoteFetcher_default = EmoteFetcher;
|
|
|
943
943
|
var EmoteParser = class {
|
|
944
944
|
/**
|
|
945
945
|
* A parser to replace text with emotes.
|
|
946
|
-
* @param {EmoteFetcher} fetcher - The
|
|
946
|
+
* @param {EmoteFetcher} fetcher - The {@linkcode EmoteFetcher} to use the cache of.
|
|
947
947
|
* @param {object} [options={}] - Options for the parser.
|
|
948
948
|
* @param {string} [options.template=''] - The template to be used.
|
|
949
949
|
* The strings that can be interpolated are:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Gn=Object.create;var ni=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Vn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty;var s=(n,e)=>ni(n,"name",{value:e,configurable:!0});var tr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Zn=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of $n(e))!zn.call(n,a)&&a!==t&&ni(n,a,{get:()=>e[a],enumerable:!(r=Wn(e,a))||r.enumerable});return n};var nt=(n,e,t)=>(t=n!=null?Gn(Vn(n)):{},Zn(e||!n||!n.__esModule?ni(t,"default",{value:n,enumerable:!0}):t,n));var ct=tr((ks,Oi)=>{Oi.exports.isNode=!1});var Ji=tr((Dc,Ki)=>{function F(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}s(F,"RetryOperation");Ki.exports=F;F.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};F.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};F.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};F.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};F.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};F.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};F.prototype.start=F.prototype.try;F.prototype.errors=function(){return this._errors};F.prototype.attempts=function(){return this._attempts};F.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var a=this._errors[r],c=a.message,m=(n[c]||0)+1;n[c]=m,m>=t&&(e=a,t=m)}return e}});var Yi=tr(we=>{var as=Ji();we.operation=function(n){var e=we.timeouts(n);return new as(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};we.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],a=0;a<e.retries;a++)r.push(this.createTimeout(a,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(a,e)),r.sort(function(c,m){return c-m}),r};we.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};we.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var a=0;a<t.length;a++){var c=t[a],m=n[c];n[c]=s(function(f){var C=we.operation(e),T=Array.prototype.slice.call(arguments,1),k=T.pop();T.push(function(q){C.retry(q)||(q&&(arguments[0]=C.mainError()),k.apply(this,arguments))}),C.attempt(function(){f.apply(n,T)})},"retryWrapper").bind(n,m),n[c].options=e}}});var en=tr((Oc,Xi)=>{Xi.exports=Yi()});var si=class n{static{s(this,"Emote")}constructor(e,t,r){if(new.target
|
|
1
|
+
var Gn=Object.create;var ni=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Vn=Object.getPrototypeOf,zn=Object.prototype.hasOwnProperty;var s=(n,e)=>ni(n,"name",{value:e,configurable:!0});var tr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Zn=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of $n(e))!zn.call(n,a)&&a!==t&&ni(n,a,{get:()=>e[a],enumerable:!(r=Wn(e,a))||r.enumerable});return n};var nt=(n,e,t)=>(t=n!=null?Gn(Vn(n)):{},Zn(e||!n||!n.__esModule?ni(t,"default",{value:n,enumerable:!0}):t,n));var ct=tr((ks,Oi)=>{Oi.exports.isNode=!1});var Ji=tr((Dc,Ki)=>{function F(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}s(F,"RetryOperation");Ki.exports=F;F.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};F.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};F.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};F.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};F.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};F.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};F.prototype.start=F.prototype.try;F.prototype.errors=function(){return this._errors};F.prototype.attempts=function(){return this._attempts};F.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,r=0;r<this._errors.length;r++){var a=this._errors[r],c=a.message,m=(n[c]||0)+1;n[c]=m,m>=t&&(e=a,t=m)}return e}});var Yi=tr(we=>{var as=Ji();we.operation=function(n){var e=we.timeouts(n);return new as(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};we.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],a=0;a<e.retries;a++)r.push(this.createTimeout(a,e));return n&&n.forever&&!r.length&&r.push(this.createTimeout(a,e)),r.sort(function(c,m){return c-m}),r};we.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,r=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return r=Math.min(r,e.maxTimeout),r};we.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var r in n)typeof n[r]=="function"&&t.push(r)}for(var a=0;a<t.length;a++){var c=t[a],m=n[c];n[c]=s(function(f){var C=we.operation(e),T=Array.prototype.slice.call(arguments,1),k=T.pop();T.push(function(q){C.retry(q)||(q&&(arguments[0]=C.mainError()),k.apply(this,arguments))}),C.attempt(function(){f.apply(n,T)})},"retryWrapper").bind(n,m),n[c].options=e}}});var en=tr((Oc,Xi)=>{Xi.exports=Yi()});var si=class n{static{s(this,"Emote")}constructor(e,t,r){if(new.target===n)throw new Error("Base Emote class cannot be used");this.fetcher=e.fetcher,this.channel=e,this.id=t,this.type=null,this._setup(r)}_setup(e){this.code=e.code}toLink(){return""}toString(){return this.code}toObject(){return{code:this.code,id:this.id,channel_id:this.channel?.channel_id||null,type:this.type}}},$=si;var B={Twitch:{CDN:s((n,e=0,t=!1,r="dark")=>`https://static-cdn.jtvnw.net/emoticons/v2/${n}/${t?"static":"default"}/${r}/${e+1}.0`,"CDN")},BTTV:{Global:"https://api.betterttv.net/3/cached/emotes/global",Channel:s(n=>`https://api.betterttv.net/3/cached/users/twitch/${n}`,"Channel"),CDN:s((n,e=0,t=!1)=>`https://cdn.betterttv.net/emote/${n}/${e+1}x.${t?"png":"webp"}`,"CDN")},SevenTV:{GQL:"https://7tv.io/v3/gql",GlobalQuery:`
|
|
2
2
|
query GetGlobalEmotes($format: [ImageFormat!]) {
|
|
3
3
|
namedEmoteSet(name: GLOBAL) {
|
|
4
4
|
emotes {
|