@xpadev-net/niconicomments 0.2.21 → 0.2.22
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/bundle.js +699 -568
- package/dist/dts/types.d.ts +208 -137
- package/package.json +25 -9
package/dist/dts/types.d.ts
CHANGED
|
@@ -1,154 +1,225 @@
|
|
|
1
|
-
type inputFormatType =
|
|
1
|
+
type inputFormatType =
|
|
2
|
+
| "niconicome"
|
|
3
|
+
| "formatted"
|
|
4
|
+
| "legacy"
|
|
5
|
+
| "owner"
|
|
6
|
+
| "v1"
|
|
7
|
+
| "default";
|
|
2
8
|
type InitOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
9
|
+
useLegacy?: boolean;
|
|
10
|
+
formatted?: boolean;
|
|
11
|
+
format?: inputFormatType;
|
|
12
|
+
video?: HTMLVideoElement | undefined;
|
|
13
|
+
showCollision?: boolean;
|
|
14
|
+
showFPS?: boolean;
|
|
15
|
+
showCommentCount?: boolean;
|
|
16
|
+
drawAllImageOnLoad?: boolean;
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
enableLegacyPiP?: boolean;
|
|
19
|
+
keepCA?: boolean;
|
|
20
|
+
};
|
|
15
21
|
type Options = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
22
|
+
useLegacy: boolean;
|
|
23
|
+
formatted: boolean;
|
|
24
|
+
format: inputFormatType;
|
|
25
|
+
video: HTMLVideoElement | undefined;
|
|
26
|
+
showCollision: boolean;
|
|
27
|
+
showFPS: boolean;
|
|
28
|
+
showCommentCount: boolean;
|
|
29
|
+
drawAllImageOnLoad: boolean;
|
|
30
|
+
debug: boolean;
|
|
31
|
+
enableLegacyPiP: boolean;
|
|
32
|
+
keepCA: boolean;
|
|
33
|
+
};
|
|
28
34
|
type rawApiResponse = {
|
|
29
|
-
|
|
30
|
-
}
|
|
35
|
+
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
36
|
+
};
|
|
31
37
|
type apiPing = {
|
|
32
|
-
|
|
33
|
-
}
|
|
38
|
+
content: string;
|
|
39
|
+
};
|
|
34
40
|
type apiThread = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
+
resultcode: number;
|
|
42
|
+
thread: string;
|
|
43
|
+
server_time: number;
|
|
44
|
+
ticket: string;
|
|
45
|
+
revision: number;
|
|
46
|
+
};
|
|
41
47
|
type apiLeaf = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
48
|
+
thread: string;
|
|
49
|
+
count: number;
|
|
50
|
+
};
|
|
45
51
|
type apiGlobalNumRes = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
52
|
+
thread: string;
|
|
53
|
+
num_res: number;
|
|
54
|
+
};
|
|
49
55
|
type apiChat = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
56
|
+
thread: string;
|
|
57
|
+
no: number;
|
|
58
|
+
vpos: number;
|
|
59
|
+
date: number;
|
|
60
|
+
date_usec: number;
|
|
61
|
+
nicoru: number;
|
|
62
|
+
premium: number;
|
|
63
|
+
anonymity: number;
|
|
64
|
+
user_id: string;
|
|
65
|
+
mail: string;
|
|
66
|
+
content: string;
|
|
67
|
+
deleted: number;
|
|
68
|
+
};
|
|
63
69
|
type formattedComment = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
70
|
+
id: number;
|
|
71
|
+
vpos: number;
|
|
72
|
+
content: string;
|
|
73
|
+
date: number;
|
|
74
|
+
date_usec: number;
|
|
75
|
+
owner: boolean;
|
|
76
|
+
premium: boolean;
|
|
77
|
+
mail: string[];
|
|
78
|
+
user_id: number;
|
|
79
|
+
layer: number;
|
|
80
|
+
};
|
|
75
81
|
type formattedLegacyComment = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
82
|
+
id: number;
|
|
83
|
+
vpos: number;
|
|
84
|
+
content: string;
|
|
85
|
+
date: number;
|
|
86
|
+
date_usec: number;
|
|
87
|
+
owner: boolean;
|
|
88
|
+
premium: boolean;
|
|
89
|
+
mail: string[];
|
|
90
|
+
};
|
|
85
91
|
type formattedCommentWithFont = formattedComment & {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
92
|
+
loc: commentLoc;
|
|
93
|
+
size: commentSize;
|
|
94
|
+
fontSize: number;
|
|
95
|
+
font: commentFont;
|
|
96
|
+
color: string;
|
|
97
|
+
full: boolean;
|
|
98
|
+
ender: boolean;
|
|
99
|
+
_live: boolean;
|
|
100
|
+
long: number;
|
|
101
|
+
invisible: boolean;
|
|
102
|
+
};
|
|
97
103
|
type formattedCommentWithSize = formattedCommentWithFont & {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
+
height: number;
|
|
105
|
+
width: number;
|
|
106
|
+
width_max: number;
|
|
107
|
+
width_min: number;
|
|
108
|
+
lineHeight: number;
|
|
109
|
+
};
|
|
104
110
|
type parsedComment = formattedCommentWithSize & {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
111
|
+
posY: number;
|
|
112
|
+
image?: HTMLCanvasElement | boolean;
|
|
113
|
+
};
|
|
114
|
+
type groupedResult = formattedCommentWithFont & {
|
|
115
|
+
index: number;
|
|
116
|
+
};
|
|
117
|
+
type groupedComments = {
|
|
118
|
+
[key in commentFont]: { [key: string]: groupedResult[] };
|
|
119
|
+
};
|
|
120
|
+
type commentFont = "defont" | "mincho" | "gothic";
|
|
121
|
+
type commentSize = "big" | "medium" | "small";
|
|
122
|
+
type commentLoc = "ue" | "naka" | "shita";
|
|
123
|
+
type collision = { [key in collisionPos]: collisionItem };
|
|
124
|
+
type collisionPos = "ue" | "shita" | "right" | "left";
|
|
125
|
+
type collisionItem = { [p: number]: number[] };
|
|
126
|
+
type nicoScript = {
|
|
127
|
+
reverse: nicoScriptReverse[];
|
|
128
|
+
ban: nicoScriptBan[];
|
|
129
|
+
default: nicoScriptDefault[];
|
|
130
|
+
replace: nicoScriptReplace[];
|
|
131
|
+
};
|
|
132
|
+
type nicoScriptReverse = {
|
|
133
|
+
target: nicoScriptReverseTarget;
|
|
134
|
+
start: number;
|
|
135
|
+
end: number;
|
|
136
|
+
};
|
|
137
|
+
type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
|
|
138
|
+
type nicoScriptReplace = {
|
|
139
|
+
start: number;
|
|
140
|
+
long: number | undefined;
|
|
141
|
+
keyword: string;
|
|
142
|
+
replace: string;
|
|
143
|
+
range: nicoScriptReplaceRange;
|
|
144
|
+
target: nicoScriptReplaceTarget;
|
|
145
|
+
condition: nicoScriptReplaceCondition;
|
|
146
|
+
color: string | undefined;
|
|
147
|
+
size: commentSize | undefined;
|
|
148
|
+
font: commentFont | undefined;
|
|
149
|
+
loc: commentLoc | undefined;
|
|
150
|
+
no: number;
|
|
151
|
+
};
|
|
152
|
+
type nicoScriptReplaceRange = "単" | "全";
|
|
153
|
+
type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
|
|
154
|
+
type nicoScriptReplaceCondition = "完全一致" | "部分一致";
|
|
155
|
+
type nicoScriptBan = {
|
|
156
|
+
start: number;
|
|
157
|
+
end: number;
|
|
158
|
+
};
|
|
159
|
+
type nicoScriptDefault = {
|
|
160
|
+
start: number;
|
|
161
|
+
long: number | undefined;
|
|
162
|
+
color: string | undefined;
|
|
163
|
+
size: commentSize | undefined;
|
|
164
|
+
font: commentFont | undefined;
|
|
165
|
+
loc: commentLoc | undefined;
|
|
166
|
+
};
|
|
108
167
|
type measureTextResult = {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
type
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
168
|
+
width: number;
|
|
169
|
+
width_max: number;
|
|
170
|
+
width_min: number;
|
|
171
|
+
height: number;
|
|
172
|
+
resized: boolean;
|
|
173
|
+
fontSize: number;
|
|
174
|
+
lineHeight: number;
|
|
175
|
+
};
|
|
176
|
+
type parsedCommand = {
|
|
177
|
+
loc: commentLoc | undefined;
|
|
178
|
+
size: commentSize | undefined;
|
|
179
|
+
fontSize: number | undefined;
|
|
180
|
+
color: string | undefined;
|
|
181
|
+
font: commentFont | undefined;
|
|
182
|
+
full: boolean;
|
|
183
|
+
ender: boolean;
|
|
184
|
+
_live: boolean;
|
|
185
|
+
invisible: boolean;
|
|
186
|
+
long: number | undefined;
|
|
187
|
+
};
|
|
188
|
+
type typeFontSize = {
|
|
189
|
+
[key in commentSize]: {
|
|
190
|
+
default: number;
|
|
191
|
+
resized: number;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
type typeDoubleResizeMaxWidth = {
|
|
195
|
+
[key in "full" | "normal"]: {
|
|
196
|
+
legacy: number;
|
|
197
|
+
default: number;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
129
200
|
type v1Thread = {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
201
|
+
id: string;
|
|
202
|
+
fork: string;
|
|
203
|
+
commentCount: number;
|
|
204
|
+
comments: { [key: string]: v1Comment };
|
|
205
|
+
};
|
|
135
206
|
type v1Comment = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
207
|
+
id: string;
|
|
208
|
+
no: number;
|
|
209
|
+
vposMs: number;
|
|
210
|
+
body: string;
|
|
211
|
+
commands: string[];
|
|
212
|
+
userId: string;
|
|
213
|
+
isPremium: boolean;
|
|
214
|
+
score: number;
|
|
215
|
+
postedAt: string;
|
|
216
|
+
nicoruCount: number;
|
|
217
|
+
nicoruId: undefined;
|
|
218
|
+
source: string;
|
|
219
|
+
isMyPost: boolean;
|
|
220
|
+
};
|
|
150
221
|
type ownerComment = {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
222
|
+
time: string;
|
|
223
|
+
command: string;
|
|
224
|
+
comment: string;
|
|
225
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
6
|
"types": "dist/dts/types.d.ts",
|
|
@@ -8,9 +8,16 @@
|
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"build": "rollup -c rollup.config.js",
|
|
10
10
|
"watch": "rollup -c rollup.config.js -w",
|
|
11
|
-
"typedoc": "typedoc --entryPointStrategy Expand --
|
|
11
|
+
"typedoc": "typedoc --entryPointStrategy Expand --out ./docs/type/ ./src/",
|
|
12
12
|
"copy-dts": "npx copyfiles -u 2 src/@types/*.d.ts dist/dts",
|
|
13
|
-
"prepublishOnly": "npm run copy-dts&&npm run build"
|
|
13
|
+
"prepublishOnly": "npm run copy-dts&&npm run build",
|
|
14
|
+
"check-types": "npx tsc --noEmit --jsx react",
|
|
15
|
+
"eslint": "eslint src/**/*.ts*",
|
|
16
|
+
"eslint:fix": "eslint src/**/*.ts* --fix",
|
|
17
|
+
"format": "prettier --write \"src/**/*.{tsx,ts,js,json,css,scss}\"",
|
|
18
|
+
"lint": "npm run eslint&&npm run check-types",
|
|
19
|
+
"lint:fix": "npm run format&&npm run eslint:fix&&npm run check-types",
|
|
20
|
+
"prepare": "husky install"
|
|
14
21
|
},
|
|
15
22
|
"repository": {
|
|
16
23
|
"type": "git",
|
|
@@ -30,15 +37,24 @@
|
|
|
30
37
|
"homepage": "https://xpadev.net/niconicomments/docs/",
|
|
31
38
|
"license": "MIT",
|
|
32
39
|
"devDependencies": {
|
|
33
|
-
"@babel/
|
|
40
|
+
"@babel/core": "^7.18.10",
|
|
41
|
+
"@babel/preset-env": "^7.18.10",
|
|
34
42
|
"@rollup/plugin-babel": "^5.3.0",
|
|
43
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
44
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
35
45
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
36
|
-
"@rollup/plugin-typescript": "^8.3.
|
|
46
|
+
"@rollup/plugin-typescript": "^8.3.4",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
48
|
+
"@typescript-eslint/parser": "^5.33.0",
|
|
37
49
|
"copyfiles": "^2.4.1",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
50
|
+
"eslint": "^8.21.0",
|
|
51
|
+
"eslint-config-prettier": "8.5.0",
|
|
52
|
+
"husky": "^8.0.0",
|
|
53
|
+
"lint-staged": "^13.0.3",
|
|
54
|
+
"prettier": "2.7.1",
|
|
55
|
+
"rollup": "^2.77.2",
|
|
56
|
+
"typedoc": "^0.23.10",
|
|
57
|
+
"typedoc-plugin-missing-exports": "^0.23.0",
|
|
42
58
|
"typescript": "^4.7.4"
|
|
43
59
|
}
|
|
44
60
|
}
|