@xpadev-net/niconicomments 0.2.26 → 0.2.28
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/LICENSE +21 -21
- package/README.md +42 -42
- package/dist/bundle.d.ts +683 -367
- package/dist/bundle.js +2767 -1507
- package/package.json +61 -61
package/dist/bundle.d.ts
CHANGED
|
@@ -1,368 +1,684 @@
|
|
|
1
|
-
declare
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
1
|
+
declare class FlashComment implements IComment {
|
|
2
|
+
private readonly context;
|
|
3
|
+
readonly comment: formattedCommentWithSize;
|
|
4
|
+
private readonly _globalScale;
|
|
5
|
+
private scale;
|
|
6
|
+
posY: number;
|
|
7
|
+
image?: HTMLCanvasElement | null;
|
|
8
|
+
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
9
|
+
get invisible(): boolean;
|
|
10
|
+
get loc(): commentLoc;
|
|
11
|
+
get long(): number;
|
|
12
|
+
get vpos(): number;
|
|
13
|
+
get width(): number;
|
|
14
|
+
get height(): number;
|
|
15
|
+
get flash(): boolean;
|
|
16
|
+
get layer(): number;
|
|
17
|
+
get owner(): boolean;
|
|
18
|
+
get mail(): string[];
|
|
19
|
+
get lineCount(): number;
|
|
20
|
+
parseCommand(comment: formattedComment): parsedCommand;
|
|
21
|
+
parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
|
|
22
|
+
measureText(comment: measureTextInput): measureTextResult;
|
|
23
|
+
getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
|
|
24
|
+
draw(vpos: number, showCollision: boolean, debug: boolean): void;
|
|
25
|
+
getTextImage(): HTMLCanvasElement | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
declare class HTML5Comment implements IComment {
|
|
30
|
+
private readonly context;
|
|
31
|
+
readonly comment: formattedCommentWithSize;
|
|
32
|
+
posY: number;
|
|
33
|
+
image?: HTMLCanvasElement | null;
|
|
34
|
+
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
35
|
+
get invisible(): boolean;
|
|
36
|
+
get loc(): commentLoc;
|
|
37
|
+
get long(): number;
|
|
38
|
+
get vpos(): number;
|
|
39
|
+
get width(): number;
|
|
40
|
+
get height(): number;
|
|
41
|
+
get flash(): boolean;
|
|
42
|
+
get layer(): number;
|
|
43
|
+
get owner(): boolean;
|
|
44
|
+
get mail(): string[];
|
|
45
|
+
get lineCount(): number;
|
|
46
|
+
parseCommand(comment: formattedComment): parsedCommand;
|
|
47
|
+
parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
|
|
48
|
+
measureText(comment: measureTextInput): measureTextResult;
|
|
49
|
+
getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
|
|
50
|
+
draw(vpos: number, showCollision: boolean, debug: boolean): void;
|
|
51
|
+
getTextImage(): HTMLCanvasElement | null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
declare let imageCache: {
|
|
56
|
+
[key: string]: {
|
|
57
|
+
image: HTMLCanvasElement;
|
|
58
|
+
timeout: number;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
declare const resetImageCache: () => void;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
declare const canvas: HTMLCanvasElement;
|
|
65
|
+
declare const context: CanvasRenderingContext2D;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
declare let nicoScripts: nicoScript;
|
|
69
|
+
declare const resetNicoScripts: () => void;
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
declare const colors: {
|
|
73
|
+
white: string;
|
|
74
|
+
red: string;
|
|
75
|
+
pink: string;
|
|
76
|
+
orange: string;
|
|
77
|
+
yellow: string;
|
|
78
|
+
green: string;
|
|
79
|
+
cyan: string;
|
|
80
|
+
blue: string;
|
|
81
|
+
purple: string;
|
|
82
|
+
black: string;
|
|
83
|
+
white2: string;
|
|
84
|
+
niconicowhite: string;
|
|
85
|
+
red2: string;
|
|
86
|
+
truered: string;
|
|
87
|
+
pink2: string;
|
|
88
|
+
orange2: string;
|
|
89
|
+
passionorange: string;
|
|
90
|
+
yellow2: string;
|
|
91
|
+
madyellow: string;
|
|
92
|
+
green2: string;
|
|
93
|
+
elementalgreen: string;
|
|
94
|
+
cyan2: string;
|
|
95
|
+
blue2: string;
|
|
96
|
+
marinblue: string;
|
|
97
|
+
purple2: string;
|
|
98
|
+
nobleviolet: string;
|
|
99
|
+
black2: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
declare const defaultConfig: Config;
|
|
104
|
+
declare const defaultOptions: Options;
|
|
105
|
+
declare let config: Config;
|
|
106
|
+
declare let options: Options;
|
|
107
|
+
declare const setConfig: (value: Config) => Config;
|
|
108
|
+
declare const setOptions: (value: Options) => Options;
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
declare const fontTemplates: {
|
|
112
|
+
arial: {
|
|
113
|
+
font: string;
|
|
114
|
+
offset: number;
|
|
115
|
+
weight: number;
|
|
116
|
+
};
|
|
117
|
+
gothic: {
|
|
118
|
+
font: string;
|
|
119
|
+
offset: number;
|
|
120
|
+
weight: number;
|
|
121
|
+
};
|
|
122
|
+
gulim: {
|
|
123
|
+
font: string;
|
|
124
|
+
offset: number;
|
|
125
|
+
weight: number;
|
|
126
|
+
};
|
|
127
|
+
mincho: {
|
|
128
|
+
font: string;
|
|
129
|
+
offset: number;
|
|
130
|
+
weight: number;
|
|
131
|
+
};
|
|
132
|
+
simsun: {
|
|
133
|
+
font: string;
|
|
134
|
+
offset: number;
|
|
135
|
+
weight: number;
|
|
136
|
+
};
|
|
137
|
+
macGothicPro6: {
|
|
138
|
+
font: string;
|
|
139
|
+
offset: number;
|
|
140
|
+
weight: number;
|
|
141
|
+
};
|
|
142
|
+
macGothicPro3: {
|
|
143
|
+
font: string;
|
|
144
|
+
offset: number;
|
|
145
|
+
weight: number;
|
|
146
|
+
};
|
|
147
|
+
macMincho: {
|
|
148
|
+
font: string;
|
|
149
|
+
offset: number;
|
|
150
|
+
weight: number;
|
|
151
|
+
};
|
|
152
|
+
macGothic1: {
|
|
153
|
+
font: string;
|
|
154
|
+
offset: number;
|
|
155
|
+
weight: number;
|
|
156
|
+
};
|
|
157
|
+
macGothic2: {
|
|
158
|
+
font: string;
|
|
159
|
+
offset: number;
|
|
160
|
+
weight: number;
|
|
161
|
+
};
|
|
162
|
+
sansSerif600: {
|
|
163
|
+
font: string;
|
|
164
|
+
offset: number;
|
|
165
|
+
weight: number;
|
|
166
|
+
};
|
|
167
|
+
sansSerif400: {
|
|
168
|
+
font: string;
|
|
169
|
+
offset: number;
|
|
170
|
+
weight: number;
|
|
171
|
+
};
|
|
172
|
+
serif: {
|
|
173
|
+
font: string;
|
|
174
|
+
offset: number;
|
|
175
|
+
weight: number;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
declare const fonts: {
|
|
179
|
+
win7: {
|
|
180
|
+
defont: FontItem;
|
|
181
|
+
gothic: FontItem;
|
|
182
|
+
mincho: FontItem;
|
|
183
|
+
};
|
|
184
|
+
win8_1: {
|
|
185
|
+
defont: FontItem;
|
|
186
|
+
gothic: FontItem;
|
|
187
|
+
mincho: FontItem;
|
|
188
|
+
};
|
|
189
|
+
win: {
|
|
190
|
+
defont: FontItem;
|
|
191
|
+
gothic: FontItem;
|
|
192
|
+
mincho: FontItem;
|
|
193
|
+
};
|
|
194
|
+
mac10_9: {
|
|
195
|
+
defont: FontItem;
|
|
196
|
+
gothic: FontItem;
|
|
197
|
+
mincho: FontItem;
|
|
198
|
+
};
|
|
199
|
+
mac10_11: {
|
|
200
|
+
defont: FontItem;
|
|
201
|
+
gothic: FontItem;
|
|
202
|
+
mincho: FontItem;
|
|
203
|
+
};
|
|
204
|
+
mac: {
|
|
205
|
+
defont: FontItem;
|
|
206
|
+
gothic: FontItem;
|
|
207
|
+
mincho: FontItem;
|
|
208
|
+
};
|
|
209
|
+
other: {
|
|
210
|
+
defont: FontItem;
|
|
211
|
+
gothic: FontItem;
|
|
212
|
+
mincho: FontItem;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
interface IComment {
|
|
218
|
+
comment: formattedCommentWithSize;
|
|
219
|
+
invisible: boolean;
|
|
220
|
+
loc: commentLoc;
|
|
221
|
+
width: number;
|
|
222
|
+
long: number;
|
|
223
|
+
height: number;
|
|
224
|
+
vpos: number;
|
|
225
|
+
flash: boolean;
|
|
226
|
+
posY: number;
|
|
227
|
+
owner: boolean;
|
|
228
|
+
layer: number;
|
|
229
|
+
mail: string[];
|
|
230
|
+
image?: HTMLCanvasElement | null;
|
|
231
|
+
getTextImage: (vpos: number) => void;
|
|
232
|
+
draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
type configItem<T> = T | { html5: T; flash: T };
|
|
236
|
+
type configSizeItem<T> = { big: T; medium: T; small: T };
|
|
237
|
+
type configResizedItem<T> = { default: T; resized: T };
|
|
238
|
+
|
|
239
|
+
type commentStageSize = { width: number; fullWidth: number; height: number };
|
|
240
|
+
|
|
241
|
+
type flashCharList = {
|
|
242
|
+
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
243
|
+
};
|
|
244
|
+
type flashMode = "xp" | "vista";
|
|
245
|
+
type flashScriptChar = {
|
|
246
|
+
[key in "super" | "sub"]: string;
|
|
247
|
+
};
|
|
248
|
+
type fontList = {
|
|
249
|
+
[key in "gulim" | "simsun"]: string;
|
|
250
|
+
};
|
|
251
|
+
type lineCounts = {
|
|
252
|
+
[key in "default" | "resized" | "doubleResized"]: configSizeItem<number>;
|
|
253
|
+
};
|
|
254
|
+
type typeDoubleResizeMaxWidth = {
|
|
255
|
+
[key in "full" | "normal"]: number;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
type Config = {
|
|
259
|
+
cacheAge: number;
|
|
260
|
+
canvasHeight: number;
|
|
261
|
+
canvasWidth: number;
|
|
262
|
+
collisionRange: { [key in "left" | "right"]: number };
|
|
263
|
+
colors: { [key: string]: string };
|
|
264
|
+
commentDrawPadding: configItem<number>;
|
|
265
|
+
commentDrawRange: configItem<number>;
|
|
266
|
+
commentScale: configItem<number>;
|
|
267
|
+
commentStageSize: configItem<commentStageSize>;
|
|
268
|
+
commentYMarginBottom: configSizeItem<number>;
|
|
269
|
+
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
270
|
+
commentYPaddingTop: configSizeItem<number>;
|
|
271
|
+
contextFillLiveOpacity: number;
|
|
272
|
+
contextLineWidth: number;
|
|
273
|
+
contextStrokeColor: string;
|
|
274
|
+
contextStrokeInversionColor: string;
|
|
275
|
+
contextStrokeOpacity: number;
|
|
276
|
+
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
277
|
+
flashChar: flashCharList;
|
|
278
|
+
flashMode: flashMode;
|
|
279
|
+
flashScriptChar: flashScriptChar;
|
|
280
|
+
flashThreshold: number;
|
|
281
|
+
font: fontList;
|
|
282
|
+
fonts: platformFont;
|
|
283
|
+
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
284
|
+
fpsInterval: number;
|
|
285
|
+
hiResCommentCorrection: number;
|
|
286
|
+
lineCounts: configItem<lineCounts>;
|
|
287
|
+
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
288
|
+
minFontSize: number;
|
|
289
|
+
sameCAGap: number;
|
|
290
|
+
sameCAMinScore: number;
|
|
291
|
+
sameCARange: number;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
type ConfigNullable = Partial<Config>;
|
|
295
|
+
|
|
296
|
+
type platform =
|
|
297
|
+
| "win7"
|
|
298
|
+
| "win8_1"
|
|
299
|
+
| "win"
|
|
300
|
+
| "mac10_9"
|
|
301
|
+
| "mac10_11"
|
|
302
|
+
| "mac"
|
|
303
|
+
| "other";
|
|
304
|
+
type HTML5Fonts = "gothic" | "mincho" | "defont";
|
|
305
|
+
type FontItem = {
|
|
306
|
+
font: string;
|
|
307
|
+
offset: number;
|
|
308
|
+
weight: number;
|
|
309
|
+
};
|
|
310
|
+
type platformFont = {
|
|
311
|
+
[key in HTML5Fonts]: FontItem;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
type formattedComment = {
|
|
315
|
+
id: number;
|
|
316
|
+
vpos: number;
|
|
317
|
+
content: string;
|
|
318
|
+
date: number;
|
|
319
|
+
date_usec: number;
|
|
320
|
+
owner: boolean;
|
|
321
|
+
premium: boolean;
|
|
322
|
+
mail: string[];
|
|
323
|
+
user_id: number;
|
|
324
|
+
layer: number;
|
|
325
|
+
};
|
|
326
|
+
type formattedLegacyComment = {
|
|
327
|
+
id: number;
|
|
328
|
+
vpos: number;
|
|
329
|
+
content: string;
|
|
330
|
+
date: number;
|
|
331
|
+
date_usec: number;
|
|
332
|
+
owner: boolean;
|
|
333
|
+
premium: boolean;
|
|
334
|
+
mail: string[];
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
type rawApiResponse = {
|
|
338
|
+
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
339
|
+
};
|
|
340
|
+
type apiPing = {
|
|
341
|
+
content: string;
|
|
342
|
+
};
|
|
343
|
+
type apiThread = {
|
|
344
|
+
resultcode: number;
|
|
345
|
+
thread: string;
|
|
346
|
+
server_time: number;
|
|
347
|
+
ticket: string;
|
|
348
|
+
revision: number;
|
|
349
|
+
};
|
|
350
|
+
type apiLeaf = {
|
|
351
|
+
thread: string;
|
|
352
|
+
count: number;
|
|
353
|
+
};
|
|
354
|
+
type apiGlobalNumRes = {
|
|
355
|
+
thread: string;
|
|
356
|
+
num_res: number;
|
|
357
|
+
};
|
|
358
|
+
type apiChat = {
|
|
359
|
+
thread: string;
|
|
360
|
+
no: number;
|
|
361
|
+
vpos: number;
|
|
362
|
+
date: number;
|
|
363
|
+
date_usec: number;
|
|
364
|
+
nicoru: number;
|
|
365
|
+
premium: number;
|
|
366
|
+
anonymity: number;
|
|
367
|
+
user_id: string;
|
|
368
|
+
mail: string;
|
|
369
|
+
content: string;
|
|
370
|
+
deleted: number;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
type ownerComment = {
|
|
374
|
+
time: string;
|
|
375
|
+
command: string;
|
|
376
|
+
comment: string;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
type v1Thread = {
|
|
380
|
+
id: string;
|
|
381
|
+
fork: string;
|
|
382
|
+
commentCount: number;
|
|
383
|
+
comments: { [key: string]: v1Comment };
|
|
384
|
+
};
|
|
385
|
+
type v1Comment = {
|
|
386
|
+
id: string;
|
|
387
|
+
no: number;
|
|
388
|
+
vposMs: number;
|
|
389
|
+
body: string;
|
|
390
|
+
commands: string[];
|
|
391
|
+
userId: string;
|
|
392
|
+
isPremium: boolean;
|
|
393
|
+
score: number;
|
|
394
|
+
postedAt: string;
|
|
395
|
+
nicoruCount: number;
|
|
396
|
+
nicoruId: undefined;
|
|
397
|
+
source: string;
|
|
398
|
+
isMyPost: boolean;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
type inputFormatType =
|
|
402
|
+
| "niconicome"
|
|
403
|
+
| "formatted"
|
|
404
|
+
| "legacy"
|
|
405
|
+
| "legacyOwner"
|
|
406
|
+
| "owner"
|
|
407
|
+
| "v1"
|
|
408
|
+
| "default";
|
|
409
|
+
type modeType = "default" | "html5" | "flash";
|
|
410
|
+
type Options = {
|
|
411
|
+
config: ConfigNullable;
|
|
412
|
+
debug: boolean;
|
|
413
|
+
enableLegacyPiP: boolean;
|
|
414
|
+
format: inputFormatType;
|
|
415
|
+
formatted: boolean;
|
|
416
|
+
keepCA: boolean;
|
|
417
|
+
mode: modeType;
|
|
418
|
+
scale: number;
|
|
419
|
+
showCollision: boolean;
|
|
420
|
+
showCommentCount: boolean;
|
|
421
|
+
showFPS: boolean;
|
|
422
|
+
useLegacy: boolean;
|
|
423
|
+
video: HTMLVideoElement | undefined;
|
|
424
|
+
};
|
|
425
|
+
type InitOptions = Partial<Options>;
|
|
426
|
+
|
|
427
|
+
type formattedCommentWithFont = {
|
|
428
|
+
id: number;
|
|
429
|
+
vpos: number;
|
|
430
|
+
date: number;
|
|
431
|
+
date_usec: number;
|
|
432
|
+
owner: boolean;
|
|
433
|
+
premium: boolean;
|
|
434
|
+
mail: string[];
|
|
435
|
+
user_id: number;
|
|
436
|
+
layer: number;
|
|
437
|
+
loc: commentLoc;
|
|
438
|
+
size: commentSize;
|
|
439
|
+
fontSize: number;
|
|
440
|
+
font: commentFont;
|
|
441
|
+
color: string;
|
|
442
|
+
full: boolean;
|
|
443
|
+
ender: boolean;
|
|
444
|
+
_live: boolean;
|
|
445
|
+
long: number;
|
|
446
|
+
invisible: boolean;
|
|
447
|
+
content: commentContentItem[];
|
|
448
|
+
flash: boolean;
|
|
449
|
+
lineCount: number;
|
|
450
|
+
lineOffset: number;
|
|
451
|
+
};
|
|
452
|
+
type formattedCommentWithSize = formattedCommentWithFont & {
|
|
453
|
+
height: number;
|
|
454
|
+
width: number;
|
|
455
|
+
lineHeight: number;
|
|
456
|
+
resized: boolean;
|
|
457
|
+
resizedX: boolean;
|
|
458
|
+
resizedY: boolean;
|
|
459
|
+
content: commentMeasuredContentItem[];
|
|
460
|
+
charSize: number;
|
|
461
|
+
};
|
|
462
|
+
type parsedComment = formattedCommentWithSize & {
|
|
463
|
+
posY: number;
|
|
464
|
+
image?: HTMLCanvasElement | boolean;
|
|
465
|
+
};
|
|
466
|
+
type commentContentItem = {
|
|
467
|
+
content: string;
|
|
468
|
+
font?: commentFlashFont;
|
|
469
|
+
width?: number[];
|
|
470
|
+
};
|
|
471
|
+
type commentMeasuredContentItem = commentContentItem & {
|
|
472
|
+
width: number[];
|
|
473
|
+
};
|
|
474
|
+
type commentContentIndex = {
|
|
475
|
+
index: number;
|
|
476
|
+
font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
|
|
477
|
+
};
|
|
478
|
+
type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
|
|
479
|
+
type commentFlashFont = "defont" | "gulim" | "simsun";
|
|
480
|
+
type commentSize = "big" | "medium" | "small";
|
|
481
|
+
type commentLoc = "ue" | "naka" | "shita";
|
|
482
|
+
type collision = { [key in collisionPos]: collisionItem };
|
|
483
|
+
type collisionPos = "ue" | "shita" | "right" | "left";
|
|
484
|
+
type collisionItem = { [p: number]: number[] };
|
|
485
|
+
type nicoScript = {
|
|
486
|
+
reverse: nicoScriptReverse[];
|
|
487
|
+
ban: nicoScriptBan[];
|
|
488
|
+
default: nicoScriptDefault[];
|
|
489
|
+
replace: nicoScriptReplace[];
|
|
490
|
+
};
|
|
491
|
+
type nicoScriptReverse = {
|
|
492
|
+
target: nicoScriptReverseTarget;
|
|
493
|
+
start: number;
|
|
494
|
+
end: number;
|
|
495
|
+
};
|
|
496
|
+
type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
|
|
497
|
+
type nicoScriptReplace = {
|
|
498
|
+
start: number;
|
|
499
|
+
long: number | undefined;
|
|
500
|
+
keyword: string;
|
|
501
|
+
replace: string;
|
|
502
|
+
range: nicoScriptReplaceRange;
|
|
503
|
+
target: nicoScriptReplaceTarget;
|
|
504
|
+
condition: nicoScriptReplaceCondition;
|
|
505
|
+
color: string | undefined;
|
|
506
|
+
size: commentSize | undefined;
|
|
507
|
+
font: commentFont | undefined;
|
|
508
|
+
loc: commentLoc | undefined;
|
|
509
|
+
no: number;
|
|
510
|
+
};
|
|
511
|
+
type nicoScriptReplaceRange = "単" | "全";
|
|
512
|
+
type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
|
|
513
|
+
type nicoScriptReplaceCondition = "完全一致" | "部分一致";
|
|
514
|
+
type nicoScriptBan = {
|
|
515
|
+
start: number;
|
|
516
|
+
end: number;
|
|
517
|
+
};
|
|
518
|
+
type nicoScriptDefault = {
|
|
519
|
+
start: number;
|
|
520
|
+
long: number | undefined;
|
|
521
|
+
color: string | undefined;
|
|
522
|
+
size: commentSize | undefined;
|
|
523
|
+
font: commentFont | undefined;
|
|
524
|
+
loc: commentLoc | undefined;
|
|
525
|
+
};
|
|
526
|
+
type measureTextResult = {
|
|
527
|
+
width: number;
|
|
528
|
+
height: number;
|
|
529
|
+
resized: boolean;
|
|
530
|
+
resizedX: boolean;
|
|
531
|
+
resizedY: boolean;
|
|
532
|
+
fontSize: number;
|
|
533
|
+
lineHeight: number;
|
|
534
|
+
content: commentMeasuredContentItem[];
|
|
535
|
+
charSize: number;
|
|
536
|
+
};
|
|
537
|
+
type parsedCommand = {
|
|
538
|
+
loc: commentLoc | undefined;
|
|
539
|
+
size: commentSize | undefined;
|
|
540
|
+
fontSize: number | undefined;
|
|
541
|
+
color: string | undefined;
|
|
542
|
+
font: commentFont | undefined;
|
|
543
|
+
full: boolean;
|
|
544
|
+
ender: boolean;
|
|
545
|
+
_live: boolean;
|
|
546
|
+
invisible: boolean;
|
|
547
|
+
long: number | undefined;
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
type measureTextInput = {
|
|
551
|
+
content: commentContentItem[];
|
|
552
|
+
resized?: boolean;
|
|
553
|
+
ender: boolean;
|
|
554
|
+
size: commentSize;
|
|
555
|
+
fontSize: number;
|
|
556
|
+
resizedY?: boolean;
|
|
557
|
+
resizedX?: boolean;
|
|
558
|
+
font: commentFont;
|
|
559
|
+
loc: commentLoc;
|
|
560
|
+
full: boolean;
|
|
561
|
+
flash: boolean;
|
|
562
|
+
lineCount: number;
|
|
563
|
+
lineHeight?: number;
|
|
564
|
+
charSize?: number;
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
type measureInput = {
|
|
568
|
+
font: commentFont;
|
|
569
|
+
content: commentContentItem[];
|
|
570
|
+
lineHeight: number;
|
|
571
|
+
charSize: number;
|
|
572
|
+
lineCount: number;
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
declare class NiconiComments {
|
|
579
|
+
enableLegacyPiP: boolean;
|
|
580
|
+
showCollision: boolean;
|
|
581
|
+
showFPS: boolean;
|
|
582
|
+
showCommentCount: boolean;
|
|
583
|
+
video: HTMLVideoElement | undefined;
|
|
584
|
+
private data;
|
|
585
|
+
private lastVpos;
|
|
586
|
+
private readonly canvas;
|
|
587
|
+
private readonly collision;
|
|
588
|
+
private readonly context;
|
|
589
|
+
private readonly timeline;
|
|
590
|
+
constructor(canvas: HTMLCanvasElement, data: (rawApiResponse | formattedComment)[], initOptions?: InitOptions);
|
|
591
|
+
preRendering(rawData: formattedComment[]): void;
|
|
592
|
+
getCommentPos(data: IComment[]): IComment[];
|
|
593
|
+
sortComment(parsedData: IComment[]): IComment[];
|
|
594
|
+
drawCanvas(vpos: number, forceRendering?: boolean): void;
|
|
595
|
+
clear(): void;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
|
|
600
|
+
declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
|
|
601
|
+
declare const measure: (comment: measureInput) => {
|
|
602
|
+
height: number;
|
|
603
|
+
width: number;
|
|
604
|
+
lineWidth: number[];
|
|
605
|
+
itemWidth: number[][];
|
|
606
|
+
};
|
|
607
|
+
declare const getFontSizeAndScale: (charSize: number) => {
|
|
608
|
+
scale: number;
|
|
609
|
+
fontSize: number;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
declare const typeGuard: {
|
|
614
|
+
formatted: {
|
|
615
|
+
comment: (i: unknown) => i is formattedComment;
|
|
616
|
+
comments: (i: unknown) => i is formattedComment[];
|
|
617
|
+
legacyComment: (i: unknown) => i is formattedLegacyComment;
|
|
618
|
+
legacyComments: (i: unknown) => i is formattedLegacyComment[];
|
|
619
|
+
};
|
|
620
|
+
legacy: {
|
|
621
|
+
rawApiResponses: (i: unknown) => i is rawApiResponse[];
|
|
622
|
+
apiChat: (i: unknown) => i is apiChat;
|
|
623
|
+
apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
|
|
624
|
+
apiLeaf: (i: unknown) => i is apiLeaf;
|
|
625
|
+
apiPing: (i: unknown) => i is apiPing;
|
|
626
|
+
apiThread: (i: unknown) => i is apiThread;
|
|
627
|
+
};
|
|
628
|
+
niconicome: {
|
|
629
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
630
|
+
};
|
|
631
|
+
legacyOwner: {
|
|
632
|
+
comments: (i: unknown) => i is string;
|
|
633
|
+
};
|
|
634
|
+
owner: {
|
|
635
|
+
comment: (i: unknown) => i is ownerComment;
|
|
636
|
+
comments: (i: unknown) => i is ownerComment[];
|
|
637
|
+
};
|
|
638
|
+
v1: {
|
|
639
|
+
comment: (i: unknown) => i is apiThread;
|
|
640
|
+
thread: (i: unknown) => i is v1Thread;
|
|
641
|
+
threads: (i: unknown) => i is v1Thread[];
|
|
642
|
+
};
|
|
643
|
+
nicoScript: {
|
|
644
|
+
range: {
|
|
645
|
+
target: (i: unknown) => i is nicoScriptReverseTarget;
|
|
646
|
+
};
|
|
647
|
+
replace: {
|
|
648
|
+
range: (i: unknown) => i is nicoScriptReplaceRange;
|
|
649
|
+
target: (i: unknown) => i is nicoScriptReplaceTarget;
|
|
650
|
+
condition: (i: unknown) => i is nicoScriptReplaceCondition;
|
|
651
|
+
};
|
|
652
|
+
};
|
|
653
|
+
comment: {
|
|
654
|
+
font: (i: unknown) => i is commentFont;
|
|
655
|
+
loc: (i: unknown) => i is commentLoc;
|
|
656
|
+
size: (i: unknown) => i is commentSize;
|
|
657
|
+
command: {
|
|
658
|
+
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
659
|
+
};
|
|
660
|
+
};
|
|
661
|
+
config: {
|
|
662
|
+
initOptions: (item: unknown) => item is Partial<Options>;
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
declare const getPosY: (currentPos: number, targetComment: IComment, collision: number[] | undefined, data: IComment[]) => {
|
|
668
|
+
currentPos: number;
|
|
669
|
+
isChanged: boolean;
|
|
670
|
+
isBreak: boolean;
|
|
671
|
+
};
|
|
672
|
+
declare const getPosX: (width: number, vpos: number, long: number, isFlash: boolean) => number;
|
|
673
|
+
declare const parseFont: (font: commentFont, size: string | number) => string;
|
|
674
|
+
declare const arrayPush: (array: {
|
|
675
|
+
[key: number]: number[];
|
|
676
|
+
}, key: string | number, push: number) => void;
|
|
677
|
+
declare const hex2rgb: (hex: string) => number[];
|
|
678
|
+
declare const replaceAll: (string: string, target: string, replace: string) => string;
|
|
679
|
+
declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
|
|
680
|
+
declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
|
|
681
|
+
declare const isFlashComment: (comment: formattedComment) => boolean;
|
|
682
|
+
|
|
683
|
+
|
|
368
684
|
export default NiconiComments;
|