@mkody/twitch-emoticons 3.0.0-beta.6 → 3.0.0-beta.7
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 +10 -3
- package/dist/TwitchEmoticons.cjs +6 -1
- package/dist/TwitchEmoticons.esm.min.js +5 -3
- package/dist/TwitchEmoticons.esm.min.js.map +3 -3
- package/dist/TwitchEmoticons.min.js +5 -3
- package/dist/TwitchEmoticons.min.js.map +3 -3
- package/package.json +9 -16
- package/src/struct/EmoteParser.js +3 -0
- package/src/struct/SevenTVEmote.js +2 -2
- package/src/util/Constants.js +2 -0
- package/typings/index.d.cts +2 -0
- package/typings/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mkody/twitch-emoticons",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.7",
|
|
4
4
|
"description": "Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"jsdelivr": "./dist/TwitchEmoticons.min.js",
|
|
51
51
|
"unpkg": "./dist/TwitchEmoticons.min.js",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@twurple/api": "^8.1.
|
|
54
|
-
"@twurple/auth": "^8.1.
|
|
53
|
+
"@twurple/api": "^8.1.4",
|
|
54
|
+
"@twurple/auth": "^8.1.4"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
|
58
|
-
"@typescript-eslint/parser": "^8.
|
|
58
|
+
"@typescript-eslint/parser": "^8.61.0",
|
|
59
59
|
"cross-env": "^10.1.0",
|
|
60
60
|
"docdash": "^2.0.2",
|
|
61
|
-
"esbuild": "^0.28.
|
|
61
|
+
"esbuild": "^0.28.1",
|
|
62
62
|
"eslint": "^9.39.4",
|
|
63
|
-
"eslint-plugin-jsdoc": "^
|
|
64
|
-
"jest": "^30.
|
|
63
|
+
"eslint-plugin-jsdoc": "^63.0.2",
|
|
64
|
+
"jest": "^30.4.2",
|
|
65
65
|
"jsdoc": "^4.0.5",
|
|
66
66
|
"neostandard": "^0.13.0"
|
|
67
67
|
},
|
|
@@ -89,14 +89,7 @@
|
|
|
89
89
|
"test": "test"
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
|
-
"node": ">=20.18.1"
|
|
93
|
-
"pnpm": ">=10"
|
|
92
|
+
"node": ">=20.18.1"
|
|
94
93
|
},
|
|
95
|
-
"packageManager": "pnpm@
|
|
96
|
-
"pnpm": {
|
|
97
|
-
"onlyBuiltDependencies": [
|
|
98
|
-
"esbuild",
|
|
99
|
-
"unrs-resolver"
|
|
100
|
-
]
|
|
101
|
-
}
|
|
94
|
+
"packageManager": "pnpm@11.7.0"
|
|
102
95
|
}
|
|
@@ -5,6 +5,7 @@ class EmoteParser {
|
|
|
5
5
|
* A parser to replace text with emotes.
|
|
6
6
|
* @param {EmoteFetcher} fetcher - The {@linkcode EmoteFetcher} to use the cache of.
|
|
7
7
|
* @param {object} [options={}] - Options for the parser.
|
|
8
|
+
* @param {boolean} [options.allowNSFW=false] - Only for 7TV: allow usage of NSFW/unlisted emotes.
|
|
8
9
|
* @param {string} [options.template=''] - The template to be used.
|
|
9
10
|
* The strings that can be interpolated are:
|
|
10
11
|
* - `{link}` The link of the emote.
|
|
@@ -29,6 +30,7 @@ class EmoteParser {
|
|
|
29
30
|
* @type {object}
|
|
30
31
|
*/
|
|
31
32
|
this.options = {
|
|
33
|
+
allowNSFW: false,
|
|
32
34
|
template: '',
|
|
33
35
|
type: 'html',
|
|
34
36
|
match: /([^\s]+)/g,
|
|
@@ -92,6 +94,7 @@ class EmoteParser {
|
|
|
92
94
|
const emote = this.fetcher.emotes.get(id)
|
|
93
95
|
if (!emote) return matched
|
|
94
96
|
if (emote.modifier) return ''
|
|
97
|
+
if (emote.nsfw && !this.options.allowNSFW) return matched
|
|
95
98
|
|
|
96
99
|
const template = this.options.template || Constants.Templates[this.options.type]
|
|
97
100
|
const link = emote.toLink({ size, forceStatic, themeMode })
|
|
@@ -81,11 +81,11 @@ class SevenTVEmote extends Emote {
|
|
|
81
81
|
this.zeroWidth = (data.flags & ActiveEmoteFlags.ZeroWidth) !== 0 || (data.data.flags & EmoteFlags.ZeroWidth) !== 0
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* If emote is NSFW (or Twitch disallowed, just in case).
|
|
84
|
+
* If emote is NSFW/unlisted (or Twitch disallowed, just in case).
|
|
85
85
|
* Do note that this flag isn't always applied to what *looks* NSFW.
|
|
86
86
|
* @type {boolean}
|
|
87
87
|
*/
|
|
88
|
-
this.nsfw = (data.data.flags & EmoteFlags.Sexual) !== 0 || (data.data.flags & EmoteFlags.TwitchDisallowed) !== 0
|
|
88
|
+
this.nsfw = (data.data.flags & EmoteFlags.Sexual) !== 0 || (data.data.flags & EmoteFlags.TwitchDisallowed) !== 0 || data.data.listed === false
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
package/src/util/Constants.js
CHANGED
package/typings/index.d.cts
CHANGED
|
@@ -145,6 +145,7 @@ declare class EmoteParser {
|
|
|
145
145
|
* A parser to replace text with emotes.
|
|
146
146
|
* @param {EmoteFetcher} fetcher - The {@linkcode EmoteFetcher} to use the cache of.
|
|
147
147
|
* @param {object} [options={}] - Options for the parser.
|
|
148
|
+
* @param {boolean} [options.allowNSFW=false] - Only for 7TV: allow usage of NSFW/unlisted emotes.
|
|
148
149
|
* @param {string} [options.template=''] - The template to be used.
|
|
149
150
|
* The strings that can be interpolated are:
|
|
150
151
|
* - `{link}` The link of the emote.
|
|
@@ -160,6 +161,7 @@ declare class EmoteParser {
|
|
|
160
161
|
public constructor (
|
|
161
162
|
fetcher: EmoteFetcher,
|
|
162
163
|
options?: {
|
|
164
|
+
allowNSFW?: boolean,
|
|
163
165
|
template?: string,
|
|
164
166
|
type?: 'html' | 'markdown' | 'bbcode' | 'plain',
|
|
165
167
|
match?: RegExp
|
package/typings/index.d.ts
CHANGED
|
@@ -145,6 +145,7 @@ export class EmoteParser {
|
|
|
145
145
|
* A parser to replace text with emotes.
|
|
146
146
|
* @param {EmoteFetcher} fetcher - The {@linkcode EmoteFetcher} to use the cache of.
|
|
147
147
|
* @param {object} [options={}] - Options for the parser.
|
|
148
|
+
* @param {boolean} [options.allowNSFW=false] - Only for 7TV: allow usage of NSFW/unlisted emotes.
|
|
148
149
|
* @param {string} [options.template=''] - The template to be used.
|
|
149
150
|
* The strings that can be interpolated are:
|
|
150
151
|
* - `{link}` The link of the emote.
|
|
@@ -160,6 +161,7 @@ export class EmoteParser {
|
|
|
160
161
|
public constructor (
|
|
161
162
|
fetcher: EmoteFetcher,
|
|
162
163
|
options?: {
|
|
164
|
+
allowNSFW?: boolean,
|
|
163
165
|
template?: string,
|
|
164
166
|
type?: 'html' | 'markdown' | 'bbcode' | 'plain',
|
|
165
167
|
match?: RegExp
|