@mkody/twitch-emoticons 2.9.6 → 3.0.0-beta.2
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 +530 -169
- package/dist/TwitchEmoticons.cjs +950 -0
- package/dist/TwitchEmoticons.esm.min.js +7 -0
- package/dist/TwitchEmoticons.esm.min.js.map +7 -0
- package/dist/TwitchEmoticons.min.js +2 -20
- package/dist/TwitchEmoticons.min.js.map +4 -4
- package/package.json +99 -72
- package/src/index.js +38 -12
- package/src/struct/BTTVEmote.js +72 -74
- package/src/struct/Channel.js +48 -48
- package/src/struct/Emote.js +71 -71
- package/src/struct/EmoteFetcher.js +358 -322
- package/src/struct/EmoteParser.js +95 -84
- package/src/struct/EmoteTypeMapper.js +9 -9
- package/src/struct/FFZEmote.js +91 -93
- package/src/struct/SevenTVEmote.js +88 -90
- package/src/struct/TwitchEmote.js +72 -71
- package/src/util/Collection.js +69 -55
- package/src/util/Constants.js +30 -30
- package/typings/index.d.cts +254 -0
- package/typings/index.d.ts +216 -99
- package/.jsdoc.json +0 -46
- package/.nvmrc +0 -1
- package/docs/BTTVEmote.html +0 -1532
- package/docs/Channel.html +0 -824
- package/docs/Collection.html +0 -798
- package/docs/Emote.html +0 -832
- package/docs/EmoteFetcher.html +0 -3741
- package/docs/EmoteParser.html +0 -1187
- package/docs/FFZEmote.html +0 -1686
- package/docs/SevenTVEmote.html +0 -1596
- package/docs/TwitchEmote.html +0 -1528
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +0 -233
- package/docs/scripts/collapse.js +0 -39
- package/docs/scripts/commonNav.js +0 -28
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/nav.js +0 -12
- package/docs/scripts/polyfill.js +0 -4
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/scripts/search.js +0 -99
- package/docs/struct_BTTVEmote.js.html +0 -162
- package/docs/struct_Channel.js.html +0 -132
- package/docs/struct_Emote.js.html +0 -159
- package/docs/struct_EmoteFetcher.js.html +0 -429
- package/docs/struct_EmoteParser.js.html +0 -172
- package/docs/struct_FFZEmote.js.html +0 -185
- package/docs/struct_SevenTVEmote.js.html +0 -180
- package/docs/struct_TwitchEmote.js.html +0 -159
- package/docs/styles/jsdoc.css +0 -776
- package/docs/styles/prettify.css +0 -80
- package/docs/util_Collection.js.html +0 -151
- package/eslint.config.mjs +0 -215
- package/jest.config.js +0 -198
- package/test/BTTV.test.js +0 -48
- package/test/FFZ.test.js +0 -71
- package/test/SevenTV.test.js +0 -71
- package/test/ToFromObject.test.js +0 -156
- package/test/Twitch.test.js +0 -64
- package/test/__snapshots__/ToFromObject.test.js.snap +0 -121
- package/test/other.test.js +0 -72
package/package.json
CHANGED
|
@@ -1,75 +1,102 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"all": "pnpm run lint && pnpm run test && pnpm run build && pnpm run docs",
|
|
47
|
-
"build": "esbuild ./src/index.js --bundle --minify --keep-names --sourcemap --format=esm --outfile=./dist/TwitchEmoticons.min.js",
|
|
48
|
-
"docs": "jsdoc --configure .jsdoc.json",
|
|
49
|
-
"lint": "eslint ./src ./test",
|
|
50
|
-
"test": "jest"
|
|
51
|
-
},
|
|
52
|
-
"repository": {
|
|
53
|
-
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/mkody/twitch-emoticons.git"
|
|
55
|
-
},
|
|
56
|
-
"bugs": {
|
|
57
|
-
"url": "https://github.com/mkody/twitch-emoticons/issues"
|
|
58
|
-
},
|
|
59
|
-
"homepage": "https://github.com/mkody/twitch-emoticons",
|
|
60
|
-
"directories": {
|
|
61
|
-
"doc": "docs",
|
|
62
|
-
"test": "test"
|
|
63
|
-
},
|
|
64
|
-
"engines": {
|
|
65
|
-
"node": ">=18.0.0",
|
|
66
|
-
"pnpm": ">=9"
|
|
67
|
-
},
|
|
68
|
-
"packageManager": "pnpm@10.24.0",
|
|
69
|
-
"pnpm": {
|
|
70
|
-
"onlyBuiltDependencies": [
|
|
71
|
-
"esbuild",
|
|
72
|
-
"unrs-resolver"
|
|
73
|
-
]
|
|
2
|
+
"name": "@mkody/twitch-emoticons",
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
|
+
"description": "Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "MKody <gh@kdy.ch> (André Fernandes)",
|
|
8
|
+
"contributors": [
|
|
9
|
+
"1Computer",
|
|
10
|
+
"Killusions",
|
|
11
|
+
"MKody",
|
|
12
|
+
"Tzahi12345"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/mkody/twitch-emoticons.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/mkody/twitch-emoticons/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/mkody/twitch-emoticons",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"7tv",
|
|
24
|
+
"bettertwitchtv",
|
|
25
|
+
"bttv",
|
|
26
|
+
"emotes",
|
|
27
|
+
"emoticons",
|
|
28
|
+
"ffz",
|
|
29
|
+
"frankerfacez",
|
|
30
|
+
"parse",
|
|
31
|
+
"seventv",
|
|
32
|
+
"twitch-api",
|
|
33
|
+
"twitch"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./typings/index.d.ts",
|
|
40
|
+
"default": "./src/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./typings/index.d.cts",
|
|
44
|
+
"default": "./dist/TwitchEmoticons.cjs"
|
|
45
|
+
}
|
|
74
46
|
}
|
|
47
|
+
},
|
|
48
|
+
"types": "./typings/index.d.ts",
|
|
49
|
+
"main": "./dist/TwitchEmoticons.cjs",
|
|
50
|
+
"jsdelivr": "./dist/TwitchEmoticons.min.js",
|
|
51
|
+
"unpkg": "./dist/TwitchEmoticons.min.js",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@twurple/api": "^8.0.3",
|
|
54
|
+
"@twurple/auth": "^8.0.3"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
59
|
+
"cross-env": "^10.1.0",
|
|
60
|
+
"docdash": "^2.0.2",
|
|
61
|
+
"esbuild": "^0.27.3",
|
|
62
|
+
"eslint": "^9.39.3",
|
|
63
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
64
|
+
"jest": "^30.2.0",
|
|
65
|
+
"jsdoc": "^4.0.5",
|
|
66
|
+
"neostandard": "^0.13.0"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"all": "pnpm run lint && pnpm run test && pnpm run esbuild && pnpm run build:docs",
|
|
70
|
+
"build:cjs": "esbuild src/index.js --bundle --platform=node --outfile=dist/TwitchEmoticons.cjs --format=cjs --packages=external",
|
|
71
|
+
"build:docs": "jsdoc --configure .jsdoc.json",
|
|
72
|
+
"build:esm": "esbuild src/index.js --bundle --minify --keep-names --sourcemap --format=esm --outfile=dist/TwitchEmoticons.esm.min.js",
|
|
73
|
+
"build:global": "esbuild src/index.js --bundle --minify --keep-names --sourcemap --format=iife --global-name=TwitchEmoticons --outfile=dist/TwitchEmoticons.min.js",
|
|
74
|
+
"esbuild": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:global",
|
|
75
|
+
"lint": "eslint .",
|
|
76
|
+
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public"
|
|
80
|
+
},
|
|
81
|
+
"files": [
|
|
82
|
+
"dist/",
|
|
83
|
+
"src/",
|
|
84
|
+
"typings/",
|
|
85
|
+
"SECURITY.md"
|
|
86
|
+
],
|
|
87
|
+
"directories": {
|
|
88
|
+
"doc": "docs",
|
|
89
|
+
"test": "test"
|
|
90
|
+
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=20.18.1",
|
|
93
|
+
"pnpm": ">=10"
|
|
94
|
+
},
|
|
95
|
+
"packageManager": "pnpm@10.30.3",
|
|
96
|
+
"pnpm": {
|
|
97
|
+
"onlyBuiltDependencies": [
|
|
98
|
+
"esbuild",
|
|
99
|
+
"unrs-resolver"
|
|
100
|
+
]
|
|
101
|
+
}
|
|
75
102
|
}
|
package/src/index.js
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/// <reference types="../typings/index.d.ts" />
|
|
2
|
+
import BTTVEmote from './struct/BTTVEmote.js'
|
|
3
|
+
import Channel from './struct/Channel.js'
|
|
4
|
+
import Collection from './util/Collection.js'
|
|
5
|
+
import Constants from './util/Constants.js'
|
|
6
|
+
import Emote from './struct/Emote.js'
|
|
7
|
+
import EmoteFetcher from './struct/EmoteFetcher.js'
|
|
8
|
+
import EmoteParser from './struct/EmoteParser.js'
|
|
9
|
+
import FFZEmote from './struct/FFZEmote.js'
|
|
10
|
+
import SevenTVEmote from './struct/SevenTVEmote.js'
|
|
11
|
+
import TwitchEmote from './struct/TwitchEmote.js'
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
BTTVEmote,
|
|
15
|
+
Channel,
|
|
16
|
+
Collection,
|
|
17
|
+
Constants,
|
|
18
|
+
Emote,
|
|
19
|
+
EmoteFetcher,
|
|
20
|
+
EmoteParser,
|
|
21
|
+
FFZEmote,
|
|
22
|
+
SevenTVEmote,
|
|
23
|
+
TwitchEmote,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Default export for compatibility
|
|
27
|
+
export default {
|
|
28
|
+
BTTVEmote,
|
|
29
|
+
Channel,
|
|
30
|
+
Collection,
|
|
31
|
+
Constants,
|
|
32
|
+
Emote,
|
|
33
|
+
EmoteFetcher,
|
|
34
|
+
EmoteParser,
|
|
35
|
+
FFZEmote,
|
|
36
|
+
SevenTVEmote,
|
|
37
|
+
TwitchEmote,
|
|
38
|
+
}
|
package/src/struct/BTTVEmote.js
CHANGED
|
@@ -1,90 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import Emote from './Emote.js'
|
|
2
|
+
import Constants from '../util/Constants.js'
|
|
3
3
|
|
|
4
4
|
/** @augments Emote */
|
|
5
5
|
class BTTVEmote extends Emote {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The channel of this emote's creator.
|
|
19
|
-
* Not guaranteed to contain the emote, or be cached.
|
|
20
|
-
* @readonly
|
|
21
|
-
* @type {?Channel}
|
|
22
|
-
*/
|
|
23
|
-
get owner() {
|
|
24
|
-
return this.fetcher.channels.get(this.ownerName);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
_setup(data) {
|
|
28
|
-
super._setup(data);
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The name of the emote creator's channel.
|
|
32
|
-
* Will be null for global or channel emotes.
|
|
33
|
-
* @type {?string}
|
|
34
|
-
*/
|
|
35
|
-
this.ownerName = 'user' in data ? data.user.name : null;
|
|
6
|
+
/**
|
|
7
|
+
* A BTTV emote.
|
|
8
|
+
* @param {Channel} channel - Channel this emote belongs to.
|
|
9
|
+
* @param {string} id - ID of the emote.
|
|
10
|
+
* @param {data} data - The raw emote data.
|
|
11
|
+
*/
|
|
12
|
+
constructor (channel, id, data) {
|
|
13
|
+
super(channel, id, data)
|
|
14
|
+
this.type = 'bttv'
|
|
15
|
+
}
|
|
36
16
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* @type {boolean}
|
|
40
|
-
*/
|
|
41
|
-
this.animated = data.animated;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The image type of the emote.
|
|
45
|
-
* @type {string}
|
|
46
|
-
*/
|
|
47
|
-
this.imageType = 'webp';
|
|
48
|
-
}
|
|
17
|
+
_setup (data) {
|
|
18
|
+
super._setup(data)
|
|
49
19
|
|
|
50
20
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
21
|
+
* The name of the emote creator's channel.
|
|
22
|
+
* Will be null for global or channel emotes.
|
|
23
|
+
* @type {?string}
|
|
54
24
|
*/
|
|
55
|
-
|
|
56
|
-
return Constants.BTTV.CDN(this.id, size); // eslint-disable-line new-cap
|
|
57
|
-
}
|
|
25
|
+
this.ownerName = 'user' in data ? data.user.name : null
|
|
58
26
|
|
|
59
27
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @returns {object}
|
|
28
|
+
* If emote is animated.
|
|
29
|
+
* @type {boolean}
|
|
63
30
|
*/
|
|
64
|
-
|
|
65
|
-
return Object.assign({}, super.toObject(), {
|
|
66
|
-
animated: this.animated,
|
|
67
|
-
ownerName: this.ownerName,
|
|
68
|
-
type: this.type
|
|
69
|
-
});
|
|
70
|
-
}
|
|
31
|
+
this.animated = data.animated
|
|
71
32
|
|
|
72
33
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
* @param {Channel} [channel=null] - Channel this emote belongs to.
|
|
76
|
-
* @returns {BTTVEmote}
|
|
34
|
+
* The image type of the emote.
|
|
35
|
+
* @type {string}
|
|
77
36
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
37
|
+
this.imageType = 'webp'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets the image link of the emote.
|
|
42
|
+
* @param {object} [options] - Options for the link.
|
|
43
|
+
* @param {number} [options.size=0] - Size (scale) for the emote.
|
|
44
|
+
* @param {boolean} [options.forceStatic] - Whether to force the emote to be static (non-animated). Defaults to the fetcher's forceStatic or `false`.
|
|
45
|
+
* @returns {string} - The URL to the emote.
|
|
46
|
+
*/
|
|
47
|
+
toLink (options) {
|
|
48
|
+
const {
|
|
49
|
+
size = 0,
|
|
50
|
+
forceStatic = this.fetcher.forceStatic || false,
|
|
51
|
+
} = options || {}
|
|
52
|
+
|
|
53
|
+
return Constants.BTTV.CDN(this.id, size, forceStatic)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Override for `toObject`.
|
|
58
|
+
* Will result in an Object representation of a BTTVEmote
|
|
59
|
+
* @returns {object} - Object representation of the BTTVEmote.
|
|
60
|
+
*/
|
|
61
|
+
toObject () {
|
|
62
|
+
return {
|
|
63
|
+
...super.toObject(),
|
|
64
|
+
animated: this.animated,
|
|
65
|
+
ownerName: this.ownerName,
|
|
66
|
+
type: this.type,
|
|
87
67
|
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Converts an emote Object into a BTTVEmote
|
|
72
|
+
* @param {object} [emoteObject] - Object representation of this emote
|
|
73
|
+
* @param {Channel} [channel] - Channel this emote belongs to.
|
|
74
|
+
* @returns {BTTVEmote} - A BTTVEmote instance.
|
|
75
|
+
*/
|
|
76
|
+
static fromObject (emoteObject, channel) {
|
|
77
|
+
return new BTTVEmote(channel, emoteObject.id,
|
|
78
|
+
{
|
|
79
|
+
code: emoteObject.code,
|
|
80
|
+
animated: emoteObject.animated,
|
|
81
|
+
user: {
|
|
82
|
+
name: emoteObject.ownerName,
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
}
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
|
|
88
|
+
export default BTTVEmote
|
package/src/struct/Channel.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import Collection from '../util/Collection.js'
|
|
2
2
|
|
|
3
3
|
class Channel {
|
|
4
|
+
/**
|
|
5
|
+
* A Twitch channel.
|
|
6
|
+
* @param {EmoteFetcher} fetcher - The emote fetcher.
|
|
7
|
+
* @param {number} id - ID of the channel.
|
|
8
|
+
*/
|
|
9
|
+
constructor (fetcher, id) {
|
|
4
10
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param {int} id - ID of the channel.
|
|
11
|
+
* The emote fetcher.
|
|
12
|
+
* @type {EmoteFetcher}
|
|
8
13
|
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The emote fetcher.
|
|
12
|
-
* @type {EmoteFetcher}
|
|
13
|
-
*/
|
|
14
|
-
this.fetcher = fetcher;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The ID of this channel.
|
|
18
|
-
* For the global channel, the ID will be null.
|
|
19
|
-
* @type {?int}
|
|
20
|
-
*/
|
|
21
|
-
this.channel_id = id;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Cached emotes belonging to this channel.
|
|
25
|
-
* @type {Collection<string, Emote>}
|
|
26
|
-
*/
|
|
27
|
-
this.emotes = new Collection();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* There are tests that those are returning Collections, but c8 doesn't get it. */
|
|
31
|
-
/* c8 ignore start */
|
|
14
|
+
this.fetcher = fetcher
|
|
32
15
|
|
|
33
16
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
17
|
+
* The ID of this channel.
|
|
18
|
+
* For the global channel, the ID will be null.
|
|
19
|
+
* @type {?number}
|
|
36
20
|
*/
|
|
37
|
-
|
|
38
|
-
return this.fetcher.fetchBTTVEmotes(this.id);
|
|
39
|
-
}
|
|
21
|
+
this.channel_id = id || null
|
|
40
22
|
|
|
41
23
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
24
|
+
* Cached emotes belonging to this channel.
|
|
25
|
+
* @type {Collection<string, Emote>}
|
|
44
26
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
27
|
+
this.emotes = new Collection()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* There are tests that those are returning Collections, but c8 doesn't get it. */
|
|
31
|
+
/* c8 ignore start */
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Fetches the BTTV emotes for this channel.
|
|
35
|
+
* @returns {Promise<Collection<string, BTTVEmote>>} - A promise that resolves to a collection of BTTVEmotes.
|
|
36
|
+
*/
|
|
37
|
+
fetchBTTVEmotes () {
|
|
38
|
+
return this.fetcher.fetchBTTVEmotes(this.id)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Fetches the FFZ emotes for this channel.
|
|
43
|
+
* @returns {Promise<Collection<string, FFZEmote>>} - A promise that resolves to a collection of FFZEmotes.
|
|
44
|
+
*/
|
|
45
|
+
fetchFFZEmotes () {
|
|
46
|
+
return this.fetcher.fetchFFZEmotes(this.id)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Fetches the 7TV emotes for this channel.
|
|
51
|
+
* @returns {Promise<Collection<string, SevenTVEmote>>} - A promise that resolves to a collection of SevenTVEmotes.
|
|
52
|
+
*/
|
|
53
|
+
fetchSevenTVEmotes () {
|
|
54
|
+
return this.fetcher.fetchSevenTVEmotes(this.id)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* c8 ignore end */
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
export default Channel
|
package/src/struct/Emote.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
class Emote {
|
|
2
|
+
/**
|
|
3
|
+
* Base class for emotes.
|
|
4
|
+
* This constructor is not to be used.
|
|
5
|
+
* @param {Channel} channel - Channel this emote belongs to.
|
|
6
|
+
* @param {string} id - ID of the emote.
|
|
7
|
+
* @param {data} data - The raw emote data.
|
|
8
|
+
* @throws {Error} When trying to use the base Emote class directly.
|
|
9
|
+
*/
|
|
10
|
+
constructor (channel, id, data) {
|
|
11
|
+
if (new.target.name === Emote.name) {
|
|
12
|
+
throw new Error('Base Emote class cannot be used')
|
|
13
|
+
}
|
|
14
|
+
|
|
2
15
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param {Channel} channel - Channel this emote belongs to.
|
|
6
|
-
* @param {string} id - ID of the emote.
|
|
7
|
-
* @param {data} data - The raw emote data.
|
|
8
|
-
* @throws {Error} When trying to use the base Emote class directly.
|
|
16
|
+
* The emote fetcher.
|
|
17
|
+
* @type {EmoteFetcher}
|
|
9
18
|
*/
|
|
10
|
-
|
|
11
|
-
if (new.target.name === Emote.name) {
|
|
12
|
-
throw new Error('Base Emote class cannot be used');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The emote fetcher.
|
|
17
|
-
* @type {EmoteFetcher}
|
|
18
|
-
*/
|
|
19
|
-
this.fetcher = channel.fetcher;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The channel this emote belongs to.
|
|
23
|
-
* Only accurate and constant on Twitch emotes.
|
|
24
|
-
* For other types of emotes, use the `owner` or `ownerName` property.
|
|
25
|
-
* @type {Channel}
|
|
26
|
-
*/
|
|
27
|
-
this.channel = channel;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The ID of this emote.
|
|
31
|
-
* @type {string}
|
|
32
|
-
*/
|
|
33
|
-
this.id = id;
|
|
19
|
+
this.fetcher = channel.fetcher
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this._setup(data);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_setup(data) {
|
|
46
|
-
/**
|
|
47
|
-
* The code or name of the emote.
|
|
48
|
-
* @type {string}
|
|
49
|
-
*/
|
|
50
|
-
this.code = data.code;
|
|
51
|
-
}
|
|
21
|
+
/**
|
|
22
|
+
* The channel this emote belongs to.
|
|
23
|
+
* Only accurate and constant on Twitch emotes.
|
|
24
|
+
* For other types of emotes, use the `owner` or `ownerName` property.
|
|
25
|
+
* @type {Channel}
|
|
26
|
+
*/
|
|
27
|
+
this.channel = channel
|
|
52
28
|
|
|
53
29
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
56
|
-
* @returns {string}
|
|
30
|
+
* The ID of this emote.
|
|
31
|
+
* @type {string}
|
|
57
32
|
*/
|
|
58
|
-
|
|
59
|
-
toLink() {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
33
|
+
this.id = id
|
|
62
34
|
|
|
63
35
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
36
|
+
* The type of this emote.
|
|
37
|
+
* Either `twitch`, `bttv`, `ffz`, or '7tv'.
|
|
38
|
+
* @type {string | null}
|
|
67
39
|
*/
|
|
68
|
-
|
|
69
|
-
toString() {
|
|
70
|
-
return this.code;
|
|
71
|
-
}
|
|
40
|
+
this.type = null
|
|
72
41
|
|
|
42
|
+
this._setup(data)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_setup (data) {
|
|
73
46
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @returns {object}
|
|
47
|
+
* The code or name of the emote.
|
|
48
|
+
* @type {string}
|
|
77
49
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
50
|
+
this.code = data.code
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets the image link of the emote.
|
|
55
|
+
* @param {number} size - The size of the image.
|
|
56
|
+
* @returns {string} - The URL to the emote.
|
|
57
|
+
*/
|
|
58
|
+
/* c8 ignore next 3 */
|
|
59
|
+
toLink () {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Override for `toString`.
|
|
65
|
+
* Will give the emote's name.
|
|
66
|
+
* @returns {string} - The emote code.
|
|
67
|
+
*/
|
|
68
|
+
/* c8 ignore next 3 */
|
|
69
|
+
toString () {
|
|
70
|
+
return this.code
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Override for `toObject`.
|
|
75
|
+
* Will result in an Object representation of an Emote
|
|
76
|
+
* @returns {object} - Object representation of the Emote.
|
|
77
|
+
*/
|
|
78
|
+
toObject () {
|
|
79
|
+
return {
|
|
80
|
+
code: this.code,
|
|
81
|
+
id: this.id,
|
|
82
|
+
channel_id: this.channel.channel_id,
|
|
84
83
|
}
|
|
84
|
+
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
export default Emote
|