@mkody/twitch-emoticons 2.7.0 → 2.8.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.
Files changed (45) hide show
  1. package/.eslintrc.json +143 -143
  2. package/.github/codeql/codeql-config.yml +4 -4
  3. package/.github/workflows/codeql.yml +50 -50
  4. package/.github/workflows/eslint.yml +50 -50
  5. package/.github/workflows/release.yml +22 -0
  6. package/.github/workflows/yarn-test.yml +17 -17
  7. package/.jsdoc.json +39 -39
  8. package/.nvmrc +1 -0
  9. package/LICENSE +22 -22
  10. package/README.md +36 -4
  11. package/docs/BTTVEmote.html +1641 -1319
  12. package/docs/Channel.html +823 -823
  13. package/docs/Collection.html +797 -797
  14. package/docs/Emote.html +906 -801
  15. package/docs/EmoteFetcher.html +3680 -2946
  16. package/docs/EmoteParser.html +811 -811
  17. package/docs/FFZEmote.html +1795 -1473
  18. package/docs/SevenTV.html +1190 -1190
  19. package/docs/SevenTVEmote.html +1705 -1395
  20. package/docs/TwitchEmote.html +1637 -1315
  21. package/docs/index.html +230 -206
  22. package/docs/struct_BTTVEmote.js.html +162 -132
  23. package/docs/struct_Channel.js.html +127 -127
  24. package/docs/struct_Emote.js.html +151 -138
  25. package/docs/struct_EmoteFetcher.js.html +427 -399
  26. package/docs/struct_EmoteParser.js.html +153 -153
  27. package/docs/struct_FFZEmote.js.html +185 -146
  28. package/docs/struct_SevenTVEmote.js.html +178 -141
  29. package/docs/struct_TwitchEmote.js.html +159 -130
  30. package/docs/util_Collection.js.html +150 -150
  31. package/package.json +57 -57
  32. package/src/index.js +12 -12
  33. package/src/struct/BTTVEmote.js +90 -60
  34. package/src/struct/Channel.js +55 -55
  35. package/src/struct/Emote.js +79 -66
  36. package/src/struct/EmoteFetcher.js +355 -327
  37. package/src/struct/EmoteParser.js +81 -81
  38. package/src/struct/EmoteTypeMapper.js +13 -0
  39. package/src/struct/FFZEmote.js +113 -74
  40. package/src/struct/SevenTVEmote.js +106 -69
  41. package/src/struct/TwitchEmote.js +87 -58
  42. package/src/util/Collection.js +78 -78
  43. package/src/util/Constants.js +31 -31
  44. package/test/index.js +482 -174
  45. package/typings/index.d.ts +115 -98
package/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 1Computer1
4
- Copyright (c) 2019 André "Kody" Fernandes
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 1Computer1
4
+ Copyright (c) 2019 André "Kody" Fernandes
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -49,6 +49,18 @@ fetcher.fetchTwitchEmotes(null).then(() => {
49
49
  });
50
50
  ```
51
51
 
52
+ #### Bring your own `@twurple/api`
53
+
54
+ If you already use [Twurple](https://twurple.js.org/) in your project and manage authentification
55
+ (i.e. with user tokens), you can reuse it in this project by skipping the first two paramters and
56
+ setting `apiClient` with your [ApiClient](https://twurple.js.org/reference/api/classes/ApiClient.html) object.
57
+
58
+ ```js
59
+ const fetcher = new EmoteFetcher(null, null, {
60
+ apiClient: yourOwnTwurpleApiClientHere
61
+ });
62
+ ```
63
+
52
64
  #### All providers, global + channel, custom template and match pattern
53
65
 
54
66
  ```js
@@ -110,16 +122,36 @@ const { EmoteFetcher } = require('@mkody/twitch-emoticons');
110
122
  const fetcher = new EmoteFetcher();
111
123
 
112
124
  // Fetch global emotes in AVIF (channel id has to be `null` for global)
113
- fetcher.fetchSevenTVEmotes(null, 'avif');
125
+ await fetcher.fetchSevenTVEmotes(null, 'avif');
114
126
 
115
127
  // Fetch 0kody's emotes with the package's default format (WEBP)
116
- fetcher.fetchSevenTVEmotes(44317909);
128
+ await fetcher.fetchSevenTVEmotes(44317909);
117
129
 
118
130
  // ... which is currently the same as
119
- fetcher.fetchSevenTVEmotes(44317909, 'webp');
131
+ await fetcher.fetchSevenTVEmotes(44317909, 'webp');
120
132
 
121
133
  // Fetch Anatole's emotes in AVIF
122
- fetcher.fetchSevenTVEmotes(24377667, 'avif');
134
+ await fetcher.fetchSevenTVEmotes(24377667, 'avif');
135
+ ```
136
+
137
+ #### Export and import emote data
138
+
139
+ This can be useful to save the emotes in a cache or for offline content.
140
+ (For offline content, you'll still need to download emotes and proxy their URLs.)
141
+
142
+ ```js
143
+ const { EmoteFetcher } = require('@mkody/twitch-emoticons');
144
+ const fetcher = new EmoteFetcher();
145
+
146
+ // First fetch some emotes
147
+ await fetcher.fetchSevenTVEmotes(null, 'avif');
148
+
149
+ // Then you can use .toObject() on an `Emote` to export its data.
150
+ // Here's a map to get them all in a single array.
151
+ const emotes = fetcher.emotes.map(emote => emote.toObject());
152
+
153
+ // Later, with or without a fresh `EmoteFetcher`, you can use .fromObject() on the fetcher.
154
+ fetcher.fromObject(emotes);
123
155
  ```
124
156
 
125
157
  ### Links