@xpadev-net/niconicomments 0.2.37 → 0.2.38
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_JP +11 -0
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/dist/bundle.d.ts +450 -357
- package/dist/bundle.js +127 -88
- package/package.json +2 -1
package/LICENSE_JP
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021 xpadev https://xpadev.net
|
|
5
|
+
|
|
6
|
+
以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
|
|
7
|
+
|
|
8
|
+
上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
|
|
9
|
+
|
|
10
|
+
ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
|
|
11
|
+
作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
|
package/README.en.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# [niconicomments](https://xpadev.net/niconicomments/)
|
|
2
2
|
[](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
|
|
3
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
|
|
4
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
|
|
3
5
|
|
|
4
6
|
[[日本語](https://github.com/xpadev-net/niconicomments/blob/develop/README.md)]
|
|
5
7
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# [niconicomments](https://xpadev.net/niconicomments/)
|
|
2
2
|
[](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
|
|
3
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
|
|
4
|
+
[](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
|
|
3
5
|
|
|
4
6
|
[[English](https://github.com/xpadev-net/niconicomments/blob/develop/README.en.md)]
|
|
5
7
|
|
package/dist/bundle.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { IComment } from "@/@types/IComment";
|
|
2
|
+
import type { formattedCommentWithFont, formattedCommentWithSize, measureTextInput, measureTextResult, parsedCommand } from "@/@types/types";
|
|
3
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
1
4
|
declare class FlashComment implements IComment {
|
|
2
5
|
private readonly context;
|
|
3
6
|
readonly comment: formattedCommentWithSize;
|
|
@@ -8,7 +11,7 @@ declare class FlashComment implements IComment {
|
|
|
8
11
|
image?: HTMLCanvasElement | null;
|
|
9
12
|
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
10
13
|
get invisible(): boolean;
|
|
11
|
-
get loc(): commentLoc;
|
|
14
|
+
get loc(): import("@/@types/types").commentLoc;
|
|
12
15
|
get long(): number;
|
|
13
16
|
get vpos(): number;
|
|
14
17
|
get width(): number;
|
|
@@ -27,6 +30,9 @@ declare class FlashComment implements IComment {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
|
|
33
|
+
import type { IComment } from "@/@types/IComment";
|
|
34
|
+
import type { formattedCommentWithFont, formattedCommentWithSize, measureTextInput, measureTextResult } from "@/@types/types";
|
|
35
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
30
36
|
declare class HTML5Comment implements IComment {
|
|
31
37
|
private readonly context;
|
|
32
38
|
readonly comment: formattedCommentWithSize;
|
|
@@ -34,7 +40,7 @@ declare class HTML5Comment implements IComment {
|
|
|
34
40
|
image?: HTMLCanvasElement | null;
|
|
35
41
|
constructor(comment: formattedComment, context: CanvasRenderingContext2D);
|
|
36
42
|
get invisible(): boolean;
|
|
37
|
-
get loc(): commentLoc;
|
|
43
|
+
get loc(): import("@/@types/types").commentLoc;
|
|
38
44
|
get long(): number;
|
|
39
45
|
get vpos(): number;
|
|
40
46
|
get width(): number;
|
|
@@ -61,6 +67,7 @@ declare let imageCache: {
|
|
|
61
67
|
declare const resetImageCache: () => void;
|
|
62
68
|
|
|
63
69
|
|
|
70
|
+
import type { nicoScript } from "@/@types/types";
|
|
64
71
|
declare let nicoScripts: nicoScript;
|
|
65
72
|
declare const resetNicoScripts: () => void;
|
|
66
73
|
|
|
@@ -96,13 +103,15 @@ declare const colors: {
|
|
|
96
103
|
};
|
|
97
104
|
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
import type { BaseConfig } from "@/@types/config";
|
|
107
|
+
import type { BaseOptions } from "@/@types/options";
|
|
108
|
+
declare let defaultConfig: BaseConfig;
|
|
100
109
|
declare const initConfig: () => void;
|
|
101
|
-
declare const defaultOptions:
|
|
102
|
-
declare let config:
|
|
103
|
-
declare let options:
|
|
104
|
-
declare const setConfig: (value:
|
|
105
|
-
declare const setOptions: (value:
|
|
110
|
+
declare const defaultOptions: BaseOptions;
|
|
111
|
+
declare let config: BaseConfig;
|
|
112
|
+
declare let options: BaseOptions;
|
|
113
|
+
declare const setConfig: (value: BaseConfig) => BaseConfig;
|
|
114
|
+
declare const setOptions: (value: BaseOptions) => BaseOptions;
|
|
106
115
|
|
|
107
116
|
|
|
108
117
|
declare const fontTemplates: {
|
|
@@ -211,68 +220,68 @@ declare const fonts: {
|
|
|
211
220
|
};
|
|
212
221
|
|
|
213
222
|
|
|
214
|
-
type configItem<T> = T | { html5: T; flash: T };
|
|
215
|
-
type configSizeItem<T> = { big: T; medium: T; small: T };
|
|
216
|
-
type configResizedItem<T> = { default: T; resized: T };
|
|
217
|
-
|
|
218
|
-
type commentStageSize = { width: number; fullWidth: number; height: number };
|
|
219
|
-
|
|
220
|
-
type flashCharList = {
|
|
221
|
-
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
222
|
-
};
|
|
223
|
-
type flashMode = "xp" | "vista";
|
|
224
|
-
type flashScriptChar = {
|
|
225
|
-
[key in "super" | "sub"]: string;
|
|
226
|
-
};
|
|
227
|
-
type fontList = {
|
|
228
|
-
[key in "gulim" | "simsun"]: string;
|
|
229
|
-
};
|
|
230
|
-
type lineCounts = {
|
|
231
|
-
[key in "default" | "resized" | "doubleResized"]: configSizeItem<number>;
|
|
232
|
-
};
|
|
233
|
-
type typeDoubleResizeMaxWidth = {
|
|
234
|
-
[key in "full" | "normal"]: number;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
type
|
|
238
|
-
cacheAge: number;
|
|
239
|
-
canvasHeight: number;
|
|
240
|
-
canvasWidth: number;
|
|
241
|
-
collisionRange: { [key in "left" | "right"]: number };
|
|
242
|
-
colors: { [key: string]: string };
|
|
243
|
-
commentDrawPadding: number;
|
|
244
|
-
commentDrawRange: number;
|
|
245
|
-
commentScale: configItem<number>;
|
|
246
|
-
commentStageSize: configItem<commentStageSize>;
|
|
247
|
-
commentYMarginBottom: configSizeItem<number>;
|
|
248
|
-
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
249
|
-
commentYPaddingTop: configResizedItem<number>;
|
|
250
|
-
contextFillLiveOpacity: number;
|
|
251
|
-
contextLineWidth: number;
|
|
252
|
-
contextStrokeColor: string;
|
|
253
|
-
contextStrokeInversionColor: string;
|
|
254
|
-
contextStrokeOpacity: number;
|
|
255
|
-
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
256
|
-
flashChar: flashCharList;
|
|
257
|
-
flashMode: flashMode;
|
|
258
|
-
flashScriptChar: flashScriptChar;
|
|
259
|
-
flashThreshold: number;
|
|
260
|
-
font: fontList;
|
|
261
|
-
fonts: platformFont;
|
|
262
|
-
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
263
|
-
fpsInterval: number;
|
|
264
|
-
hiResCommentCorrection: number;
|
|
265
|
-
lineCounts: configItem<lineCounts>;
|
|
266
|
-
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
267
|
-
minFontSize: number;
|
|
268
|
-
sameCAGap: number;
|
|
269
|
-
sameCAMinScore: number;
|
|
270
|
-
sameCARange: number;
|
|
271
|
-
letterSpacing: number;
|
|
272
|
-
scriptCharOffset: number;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
type
|
|
223
|
+
type configItem<T> = T | { html5: T; flash: T };
|
|
224
|
+
type configSizeItem<T> = { big: T; medium: T; small: T };
|
|
225
|
+
type configResizedItem<T> = { default: T; resized: T };
|
|
226
|
+
|
|
227
|
+
type commentStageSize = { width: number; fullWidth: number; height: number };
|
|
228
|
+
|
|
229
|
+
type flashCharList = {
|
|
230
|
+
[key in "simsunStrong" | "simsunWeak" | "gulim" | "gothic"]: string;
|
|
231
|
+
};
|
|
232
|
+
type flashMode = "xp" | "vista";
|
|
233
|
+
type flashScriptChar = {
|
|
234
|
+
[key in "super" | "sub"]: string;
|
|
235
|
+
};
|
|
236
|
+
type fontList = {
|
|
237
|
+
[key in "gulim" | "simsun"]: string;
|
|
238
|
+
};
|
|
239
|
+
type lineCounts = {
|
|
240
|
+
[key in "default" | "resized" | "doubleResized"]: configSizeItem<number>;
|
|
241
|
+
};
|
|
242
|
+
type typeDoubleResizeMaxWidth = {
|
|
243
|
+
[key in "full" | "normal"]: number;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
type BaseConfig = {
|
|
247
|
+
cacheAge: number;
|
|
248
|
+
canvasHeight: number;
|
|
249
|
+
canvasWidth: number;
|
|
250
|
+
collisionRange: { [key in "left" | "right"]: number };
|
|
251
|
+
colors: { [key: string]: string };
|
|
252
|
+
commentDrawPadding: number;
|
|
253
|
+
commentDrawRange: number;
|
|
254
|
+
commentScale: configItem<number>;
|
|
255
|
+
commentStageSize: configItem<commentStageSize>;
|
|
256
|
+
commentYMarginBottom: configSizeItem<number>;
|
|
257
|
+
commentYOffset: configSizeItem<configResizedItem<number>>;
|
|
258
|
+
commentYPaddingTop: configResizedItem<number>;
|
|
259
|
+
contextFillLiveOpacity: number;
|
|
260
|
+
contextLineWidth: number;
|
|
261
|
+
contextStrokeColor: string;
|
|
262
|
+
contextStrokeInversionColor: string;
|
|
263
|
+
contextStrokeOpacity: number;
|
|
264
|
+
doubleResizeMaxWidth: configItem<typeDoubleResizeMaxWidth>;
|
|
265
|
+
flashChar: flashCharList;
|
|
266
|
+
flashMode: flashMode;
|
|
267
|
+
flashScriptChar: flashScriptChar;
|
|
268
|
+
flashThreshold: number;
|
|
269
|
+
font: fontList;
|
|
270
|
+
fonts: platformFont;
|
|
271
|
+
fontSize: configItem<configSizeItem<configResizedItem<number>>>;
|
|
272
|
+
fpsInterval: number;
|
|
273
|
+
hiResCommentCorrection: number;
|
|
274
|
+
lineCounts: configItem<lineCounts>;
|
|
275
|
+
lineHeight: configItem<configSizeItem<configResizedItem<number>>>;
|
|
276
|
+
minFontSize: number;
|
|
277
|
+
sameCAGap: number;
|
|
278
|
+
sameCAMinScore: number;
|
|
279
|
+
sameCARange: number;
|
|
280
|
+
letterSpacing: number;
|
|
281
|
+
scriptCharOffset: number;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export type Config = Partial<BaseConfig>;
|
|
276
285
|
|
|
277
286
|
type platform =
|
|
278
287
|
| "win7"
|
|
@@ -292,298 +301,318 @@ type platformFont = {
|
|
|
292
301
|
[key in HTML5Fonts]: FontItem;
|
|
293
302
|
};
|
|
294
303
|
|
|
295
|
-
type formattedComment = {
|
|
296
|
-
id: number;
|
|
297
|
-
vpos: number;
|
|
298
|
-
content: string;
|
|
299
|
-
date: number;
|
|
300
|
-
date_usec: number;
|
|
301
|
-
owner: boolean;
|
|
302
|
-
premium: boolean;
|
|
303
|
-
mail: string[];
|
|
304
|
-
user_id: number;
|
|
305
|
-
layer: number;
|
|
306
|
-
};
|
|
307
|
-
type formattedLegacyComment = {
|
|
308
|
-
id: number;
|
|
309
|
-
vpos: number;
|
|
310
|
-
content: string;
|
|
311
|
-
date: number;
|
|
312
|
-
date_usec: number;
|
|
313
|
-
owner: boolean;
|
|
314
|
-
premium: boolean;
|
|
315
|
-
mail: string[];
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
type rawApiResponse = {
|
|
319
|
-
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
320
|
-
};
|
|
321
|
-
type apiPing = {
|
|
322
|
-
content: string;
|
|
323
|
-
};
|
|
324
|
-
type apiThread = {
|
|
325
|
-
resultcode: number;
|
|
326
|
-
thread: string;
|
|
327
|
-
server_time: number;
|
|
328
|
-
ticket: string;
|
|
329
|
-
revision: number;
|
|
330
|
-
};
|
|
331
|
-
type apiLeaf = {
|
|
332
|
-
thread: string;
|
|
333
|
-
count: number;
|
|
334
|
-
};
|
|
335
|
-
type apiGlobalNumRes = {
|
|
336
|
-
thread: string;
|
|
337
|
-
num_res: number;
|
|
338
|
-
};
|
|
339
|
-
type apiChat = {
|
|
340
|
-
thread: string;
|
|
341
|
-
no: number;
|
|
342
|
-
vpos: number;
|
|
343
|
-
date: number;
|
|
344
|
-
date_usec: number;
|
|
345
|
-
nicoru: number;
|
|
346
|
-
premium: number;
|
|
347
|
-
anonymity: number;
|
|
348
|
-
user_id: string;
|
|
349
|
-
mail: string;
|
|
350
|
-
content: string;
|
|
351
|
-
deleted: number;
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
type ownerComment = {
|
|
355
|
-
time: string;
|
|
356
|
-
command: string;
|
|
357
|
-
comment: string;
|
|
358
|
-
};
|
|
304
|
+
export type formattedComment = {
|
|
305
|
+
id: number;
|
|
306
|
+
vpos: number;
|
|
307
|
+
content: string;
|
|
308
|
+
date: number;
|
|
309
|
+
date_usec: number;
|
|
310
|
+
owner: boolean;
|
|
311
|
+
premium: boolean;
|
|
312
|
+
mail: string[];
|
|
313
|
+
user_id: number;
|
|
314
|
+
layer: number;
|
|
315
|
+
};
|
|
316
|
+
export type formattedLegacyComment = {
|
|
317
|
+
id: number;
|
|
318
|
+
vpos: number;
|
|
319
|
+
content: string;
|
|
320
|
+
date: number;
|
|
321
|
+
date_usec: number;
|
|
322
|
+
owner: boolean;
|
|
323
|
+
premium: boolean;
|
|
324
|
+
mail: string[];
|
|
325
|
+
};
|
|
359
326
|
|
|
360
|
-
type
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
};
|
|
366
|
-
type
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
};
|
|
327
|
+
export type rawApiResponse = {
|
|
328
|
+
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
329
|
+
};
|
|
330
|
+
type apiPing = {
|
|
331
|
+
content: string;
|
|
332
|
+
};
|
|
333
|
+
type apiThread = {
|
|
334
|
+
resultcode: number;
|
|
335
|
+
thread: string;
|
|
336
|
+
server_time: number;
|
|
337
|
+
ticket: string;
|
|
338
|
+
revision: number;
|
|
339
|
+
};
|
|
340
|
+
type apiLeaf = {
|
|
341
|
+
thread: string;
|
|
342
|
+
count: number;
|
|
343
|
+
};
|
|
344
|
+
type apiGlobalNumRes = {
|
|
345
|
+
thread: string;
|
|
346
|
+
num_res: number;
|
|
347
|
+
};
|
|
348
|
+
type apiChat = {
|
|
349
|
+
thread: string;
|
|
350
|
+
no: number;
|
|
351
|
+
vpos: number;
|
|
352
|
+
date: number;
|
|
353
|
+
date_usec: number;
|
|
354
|
+
nicoru: number;
|
|
355
|
+
premium: number;
|
|
356
|
+
anonymity: number;
|
|
357
|
+
user_id: string;
|
|
358
|
+
mail: string;
|
|
359
|
+
content: string;
|
|
360
|
+
deleted: number;
|
|
361
|
+
};
|
|
381
362
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
long: number;
|
|
388
|
-
height: number;
|
|
389
|
-
vpos: number;
|
|
390
|
-
flash: boolean;
|
|
391
|
-
posY: number;
|
|
392
|
-
owner: boolean;
|
|
393
|
-
layer: number;
|
|
394
|
-
mail: string[];
|
|
395
|
-
image?: HTMLCanvasElement | null;
|
|
396
|
-
getTextImage: (vpos: number) => void;
|
|
397
|
-
draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
|
|
398
|
-
}
|
|
363
|
+
export type ownerComment = {
|
|
364
|
+
time: string;
|
|
365
|
+
command: string;
|
|
366
|
+
comment: string;
|
|
367
|
+
};
|
|
399
368
|
|
|
400
|
-
type
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
debug: boolean;
|
|
422
|
-
enableLegacyPiP: boolean;
|
|
423
|
-
format: inputFormatType;
|
|
424
|
-
formatted: boolean;
|
|
425
|
-
keepCA: boolean;
|
|
426
|
-
mode: modeType;
|
|
427
|
-
scale: number;
|
|
428
|
-
showCollision: boolean;
|
|
429
|
-
showCommentCount: boolean;
|
|
430
|
-
showFPS: boolean;
|
|
431
|
-
useLegacy: boolean;
|
|
432
|
-
video: HTMLVideoElement | undefined;
|
|
433
|
-
};
|
|
434
|
-
type InitOptions = Partial<Options>;
|
|
369
|
+
export type v1Thread = {
|
|
370
|
+
id: string;
|
|
371
|
+
fork: string;
|
|
372
|
+
commentCount: number;
|
|
373
|
+
comments: { [key: string]: v1Comment };
|
|
374
|
+
};
|
|
375
|
+
type v1Comment = {
|
|
376
|
+
id: string;
|
|
377
|
+
no: number;
|
|
378
|
+
vposMs: number;
|
|
379
|
+
body: string;
|
|
380
|
+
commands: string[];
|
|
381
|
+
userId: string;
|
|
382
|
+
isPremium: boolean;
|
|
383
|
+
score: number;
|
|
384
|
+
postedAt: string;
|
|
385
|
+
nicoruCount: number;
|
|
386
|
+
nicoruId: undefined;
|
|
387
|
+
source: string;
|
|
388
|
+
isMyPost: boolean;
|
|
389
|
+
};
|
|
435
390
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
invisible: boolean;
|
|
456
|
-
content: commentContentItem[];
|
|
457
|
-
flash: boolean;
|
|
458
|
-
lineCount: number;
|
|
459
|
-
lineOffset: number;
|
|
460
|
-
};
|
|
461
|
-
type formattedCommentWithSize = formattedCommentWithFont & {
|
|
462
|
-
height: number;
|
|
463
|
-
width: number;
|
|
464
|
-
lineHeight: number;
|
|
465
|
-
resized: boolean;
|
|
466
|
-
resizedX: boolean;
|
|
467
|
-
resizedY: boolean;
|
|
468
|
-
content: commentMeasuredContentItem[];
|
|
469
|
-
charSize: number;
|
|
470
|
-
};
|
|
471
|
-
type parsedComment = formattedCommentWithSize & {
|
|
472
|
-
posY: number;
|
|
473
|
-
image?: HTMLCanvasElement | boolean;
|
|
474
|
-
};
|
|
475
|
-
type commentContentItem = {
|
|
476
|
-
content: string;
|
|
477
|
-
font?: commentFlashFont;
|
|
478
|
-
width?: number[];
|
|
479
|
-
};
|
|
480
|
-
type commentMeasuredContentItem = commentContentItem & {
|
|
481
|
-
width: number[];
|
|
482
|
-
};
|
|
483
|
-
type commentContentIndex = {
|
|
484
|
-
index: number;
|
|
485
|
-
font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
|
|
486
|
-
};
|
|
487
|
-
type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
|
|
488
|
-
type commentFlashFont = "defont" | "gulim" | "simsun";
|
|
489
|
-
type commentSize = "big" | "medium" | "small";
|
|
490
|
-
type commentLoc = "ue" | "naka" | "shita";
|
|
491
|
-
type collision = { [key in collisionPos]: collisionItem };
|
|
492
|
-
type collisionPos = "ue" | "shita" | "right" | "left";
|
|
493
|
-
type collisionItem = { [p: number]: IComment[] };
|
|
494
|
-
type nicoScript = {
|
|
495
|
-
reverse: nicoScriptReverse[];
|
|
496
|
-
ban: nicoScriptBan[];
|
|
497
|
-
default: nicoScriptDefault[];
|
|
498
|
-
replace: nicoScriptReplace[];
|
|
499
|
-
};
|
|
500
|
-
type nicoScriptReverse = {
|
|
501
|
-
target: nicoScriptReverseTarget;
|
|
502
|
-
start: number;
|
|
503
|
-
end: number;
|
|
504
|
-
};
|
|
505
|
-
type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
|
|
506
|
-
type nicoScriptReplace = {
|
|
507
|
-
start: number;
|
|
508
|
-
long: number | undefined;
|
|
509
|
-
keyword: string;
|
|
510
|
-
replace: string;
|
|
511
|
-
range: nicoScriptReplaceRange;
|
|
512
|
-
target: nicoScriptReplaceTarget;
|
|
513
|
-
condition: nicoScriptReplaceCondition;
|
|
514
|
-
color: string | undefined;
|
|
515
|
-
size: commentSize | undefined;
|
|
516
|
-
font: commentFont | undefined;
|
|
517
|
-
loc: commentLoc | undefined;
|
|
518
|
-
no: number;
|
|
519
|
-
};
|
|
520
|
-
type nicoScriptReplaceRange = "単" | "全";
|
|
521
|
-
type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
|
|
522
|
-
type nicoScriptReplaceCondition = "完全一致" | "部分一致";
|
|
523
|
-
type nicoScriptBan = {
|
|
524
|
-
start: number;
|
|
525
|
-
end: number;
|
|
526
|
-
};
|
|
527
|
-
type nicoScriptDefault = {
|
|
528
|
-
start: number;
|
|
529
|
-
long: number | undefined;
|
|
530
|
-
color: string | undefined;
|
|
531
|
-
size: commentSize | undefined;
|
|
532
|
-
font: commentFont | undefined;
|
|
533
|
-
loc: commentLoc | undefined;
|
|
534
|
-
};
|
|
535
|
-
type measureTextResult = {
|
|
536
|
-
width: number;
|
|
537
|
-
height: number;
|
|
538
|
-
resized: boolean;
|
|
539
|
-
resizedX: boolean;
|
|
540
|
-
resizedY: boolean;
|
|
541
|
-
fontSize: number;
|
|
542
|
-
lineHeight: number;
|
|
543
|
-
content: commentMeasuredContentItem[];
|
|
544
|
-
charSize: number;
|
|
545
|
-
};
|
|
546
|
-
type parsedCommand = {
|
|
547
|
-
loc: commentLoc | undefined;
|
|
548
|
-
size: commentSize | undefined;
|
|
549
|
-
fontSize: number | undefined;
|
|
550
|
-
color: string | undefined;
|
|
551
|
-
font: commentFont | undefined;
|
|
552
|
-
full: boolean;
|
|
553
|
-
ender: boolean;
|
|
554
|
-
_live: boolean;
|
|
555
|
-
invisible: boolean;
|
|
556
|
-
long: number | undefined;
|
|
557
|
-
};
|
|
391
|
+
import { commentLoc, formattedCommentWithSize } from "@/@types/types";
|
|
392
|
+
|
|
393
|
+
export interface IComment {
|
|
394
|
+
comment: formattedCommentWithSize;
|
|
395
|
+
invisible: boolean;
|
|
396
|
+
loc: commentLoc;
|
|
397
|
+
width: number;
|
|
398
|
+
long: number;
|
|
399
|
+
height: number;
|
|
400
|
+
vpos: number;
|
|
401
|
+
flash: boolean;
|
|
402
|
+
posY: number;
|
|
403
|
+
owner: boolean;
|
|
404
|
+
layer: number;
|
|
405
|
+
mail: string[];
|
|
406
|
+
image?: HTMLCanvasElement | null;
|
|
407
|
+
getTextImage: (vpos: number) => void;
|
|
408
|
+
draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
|
|
409
|
+
}
|
|
558
410
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
411
|
+
import {
|
|
412
|
+
formattedComment,
|
|
413
|
+
formattedLegacyComment,
|
|
414
|
+
} from "@/@types/format.formatted";
|
|
415
|
+
import { rawApiResponse } from "@/@types/format.legacy";
|
|
416
|
+
import { ownerComment } from "@/@types/format.owner";
|
|
417
|
+
import { v1Thread } from "@/@types/format.v1";
|
|
418
|
+
import { Config } from "@/@types/config";
|
|
419
|
+
|
|
420
|
+
export type inputFormatType =
|
|
421
|
+
| "XMLDocument"
|
|
422
|
+
| "niconicome"
|
|
423
|
+
| "formatted"
|
|
424
|
+
| "legacy"
|
|
425
|
+
| "legacyOwner"
|
|
426
|
+
| "owner"
|
|
427
|
+
| "v1"
|
|
428
|
+
| "empty"
|
|
429
|
+
| "default";
|
|
430
|
+
export type inputFormat =
|
|
431
|
+
| XMLDocument
|
|
432
|
+
| formattedComment[]
|
|
433
|
+
| formattedLegacyComment[]
|
|
434
|
+
| rawApiResponse[]
|
|
435
|
+
| ownerComment[]
|
|
436
|
+
| v1Thread[]
|
|
437
|
+
| string
|
|
438
|
+
| undefined;
|
|
439
|
+
type modeType = "default" | "html5" | "flash";
|
|
440
|
+
type BaseOptions = {
|
|
441
|
+
config: Config;
|
|
442
|
+
debug: boolean;
|
|
443
|
+
enableLegacyPiP: boolean;
|
|
444
|
+
format: inputFormatType;
|
|
445
|
+
formatted: boolean;
|
|
446
|
+
keepCA: boolean;
|
|
447
|
+
mode: modeType;
|
|
448
|
+
scale: number;
|
|
449
|
+
showCollision: boolean;
|
|
450
|
+
showCommentCount: boolean;
|
|
451
|
+
showFPS: boolean;
|
|
452
|
+
useLegacy: boolean;
|
|
453
|
+
video: HTMLVideoElement | undefined;
|
|
454
|
+
};
|
|
455
|
+
export type Options = Partial<BaseOptions>;
|
|
575
456
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
457
|
+
import { IComment } from "@/@types/IComment";
|
|
458
|
+
|
|
459
|
+
type formattedCommentWithFont = {
|
|
460
|
+
id: number;
|
|
461
|
+
vpos: number;
|
|
462
|
+
date: number;
|
|
463
|
+
date_usec: number;
|
|
464
|
+
owner: boolean;
|
|
465
|
+
premium: boolean;
|
|
466
|
+
mail: string[];
|
|
467
|
+
user_id: number;
|
|
468
|
+
layer: number;
|
|
469
|
+
loc: commentLoc;
|
|
470
|
+
size: commentSize;
|
|
471
|
+
fontSize: number;
|
|
472
|
+
font: commentFont;
|
|
473
|
+
color: string;
|
|
474
|
+
strokeColor?: string;
|
|
475
|
+
full: boolean;
|
|
476
|
+
ender: boolean;
|
|
477
|
+
_live: boolean;
|
|
478
|
+
long: number;
|
|
479
|
+
invisible: boolean;
|
|
480
|
+
content: commentContentItem[];
|
|
481
|
+
flash: boolean;
|
|
482
|
+
lineCount: number;
|
|
483
|
+
lineOffset: number;
|
|
484
|
+
};
|
|
485
|
+
type formattedCommentWithSize = formattedCommentWithFont & {
|
|
486
|
+
height: number;
|
|
487
|
+
width: number;
|
|
488
|
+
lineHeight: number;
|
|
489
|
+
resized: boolean;
|
|
490
|
+
resizedX: boolean;
|
|
491
|
+
resizedY: boolean;
|
|
492
|
+
content: commentMeasuredContentItem[];
|
|
493
|
+
charSize: number;
|
|
494
|
+
};
|
|
495
|
+
type parsedComment = formattedCommentWithSize & {
|
|
496
|
+
posY: number;
|
|
497
|
+
image?: HTMLCanvasElement | boolean;
|
|
498
|
+
};
|
|
499
|
+
type commentContentItem = {
|
|
500
|
+
content: string;
|
|
501
|
+
font?: commentFlashFont;
|
|
502
|
+
width?: number[];
|
|
503
|
+
};
|
|
504
|
+
type commentMeasuredContentItem = commentContentItem & {
|
|
505
|
+
width: number[];
|
|
506
|
+
};
|
|
507
|
+
type commentContentIndex = {
|
|
508
|
+
index: number;
|
|
509
|
+
font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
|
|
510
|
+
};
|
|
511
|
+
type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
|
|
512
|
+
type commentFlashFont = "defont" | "gulim" | "simsun";
|
|
513
|
+
type commentSize = "big" | "medium" | "small";
|
|
514
|
+
type commentLoc = "ue" | "naka" | "shita";
|
|
515
|
+
type collision = { [key in collisionPos]: collisionItem };
|
|
516
|
+
type collisionPos = "ue" | "shita" | "right" | "left";
|
|
517
|
+
type collisionItem = { [p: number]: IComment[] };
|
|
518
|
+
type nicoScript = {
|
|
519
|
+
reverse: nicoScriptReverse[];
|
|
520
|
+
ban: nicoScriptBan[];
|
|
521
|
+
default: nicoScriptDefault[];
|
|
522
|
+
replace: nicoScriptReplace[];
|
|
523
|
+
};
|
|
524
|
+
type nicoScriptReverse = {
|
|
525
|
+
target: nicoScriptReverseTarget;
|
|
526
|
+
start: number;
|
|
527
|
+
end: number;
|
|
528
|
+
};
|
|
529
|
+
type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
|
|
530
|
+
type nicoScriptReplace = {
|
|
531
|
+
start: number;
|
|
532
|
+
long: number | undefined;
|
|
533
|
+
keyword: string;
|
|
534
|
+
replace: string;
|
|
535
|
+
range: nicoScriptReplaceRange;
|
|
536
|
+
target: nicoScriptReplaceTarget;
|
|
537
|
+
condition: nicoScriptReplaceCondition;
|
|
538
|
+
color: string | undefined;
|
|
539
|
+
size: commentSize | undefined;
|
|
540
|
+
font: commentFont | undefined;
|
|
541
|
+
loc: commentLoc | undefined;
|
|
542
|
+
no: number;
|
|
543
|
+
};
|
|
544
|
+
type nicoScriptReplaceRange = "単" | "全";
|
|
545
|
+
type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
|
|
546
|
+
type nicoScriptReplaceCondition = "完全一致" | "部分一致";
|
|
547
|
+
type nicoScriptBan = {
|
|
548
|
+
start: number;
|
|
549
|
+
end: number;
|
|
550
|
+
};
|
|
551
|
+
type nicoScriptDefault = {
|
|
552
|
+
start: number;
|
|
553
|
+
long: number | undefined;
|
|
554
|
+
color: string | undefined;
|
|
555
|
+
size: commentSize | undefined;
|
|
556
|
+
font: commentFont | undefined;
|
|
557
|
+
loc: commentLoc | undefined;
|
|
558
|
+
};
|
|
559
|
+
type measureTextResult = {
|
|
560
|
+
width: number;
|
|
561
|
+
height: number;
|
|
562
|
+
resized: boolean;
|
|
563
|
+
resizedX: boolean;
|
|
564
|
+
resizedY: boolean;
|
|
565
|
+
fontSize: number;
|
|
566
|
+
lineHeight: number;
|
|
567
|
+
content: commentMeasuredContentItem[];
|
|
568
|
+
charSize: number;
|
|
569
|
+
};
|
|
570
|
+
type parsedCommand = {
|
|
571
|
+
loc: commentLoc | undefined;
|
|
572
|
+
size: commentSize | undefined;
|
|
573
|
+
fontSize: number | undefined;
|
|
574
|
+
color: string | undefined;
|
|
575
|
+
strokeColor?: string;
|
|
576
|
+
font: commentFont | undefined;
|
|
577
|
+
full: boolean;
|
|
578
|
+
ender: boolean;
|
|
579
|
+
_live: boolean;
|
|
580
|
+
invisible: boolean;
|
|
581
|
+
long: number | undefined;
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
type measureTextInput = {
|
|
585
|
+
content: commentContentItem[];
|
|
586
|
+
resized?: boolean;
|
|
587
|
+
ender: boolean;
|
|
588
|
+
size: commentSize;
|
|
589
|
+
fontSize: number;
|
|
590
|
+
resizedY?: boolean;
|
|
591
|
+
resizedX?: boolean;
|
|
592
|
+
font: commentFont;
|
|
593
|
+
loc: commentLoc;
|
|
594
|
+
full: boolean;
|
|
595
|
+
flash: boolean;
|
|
596
|
+
lineCount: number;
|
|
597
|
+
lineHeight?: number;
|
|
598
|
+
charSize?: number;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
type measureInput = {
|
|
602
|
+
font: commentFont;
|
|
603
|
+
content: commentContentItem[];
|
|
604
|
+
lineHeight: number;
|
|
605
|
+
charSize: number;
|
|
606
|
+
lineCount: number;
|
|
607
|
+
};
|
|
583
608
|
|
|
609
|
+
import type { inputFormatType } from "@/@types/options";
|
|
610
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
584
611
|
declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
|
|
585
612
|
|
|
586
613
|
|
|
614
|
+
import type { inputFormat, Options } from "@/@types/options";
|
|
615
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
587
616
|
declare class NiconiComments {
|
|
588
617
|
enableLegacyPiP: boolean;
|
|
589
618
|
showCollision: boolean;
|
|
@@ -595,7 +624,59 @@ declare class NiconiComments {
|
|
|
595
624
|
private readonly collision;
|
|
596
625
|
private readonly context;
|
|
597
626
|
private readonly timeline;
|
|
598
|
-
|
|
627
|
+
static typeGuard: {
|
|
628
|
+
formatted: {
|
|
629
|
+
comment: (i: unknown) => i is formattedComment;
|
|
630
|
+
comments: (i: unknown) => i is formattedComment[];
|
|
631
|
+
legacyComment: (i: unknown) => i is import("@/@types/format.formatted").formattedLegacyComment;
|
|
632
|
+
legacyComments: (i: unknown) => i is import("@/@types/format.formatted").formattedLegacyComment[];
|
|
633
|
+
};
|
|
634
|
+
legacy: {
|
|
635
|
+
rawApiResponses: (i: unknown) => i is import("./@types/format.legacy").rawApiResponse[];
|
|
636
|
+
apiChat: (i: unknown) => i is import("./@types/format.legacy").apiChat;
|
|
637
|
+
apiGlobalNumRes: (i: unknown) => i is import("./@types/format.legacy").apiGlobalNumRes;
|
|
638
|
+
apiLeaf: (i: unknown) => i is import("./@types/format.legacy").apiLeaf;
|
|
639
|
+
apiPing: (i: unknown) => i is import("./@types/format.legacy").apiPing;
|
|
640
|
+
apiThread: (i: unknown) => i is import("./@types/format.legacy").apiThread;
|
|
641
|
+
};
|
|
642
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
643
|
+
legacyOwner: {
|
|
644
|
+
comments: (i: unknown) => i is string;
|
|
645
|
+
};
|
|
646
|
+
owner: {
|
|
647
|
+
comment: (i: unknown) => i is import("./@types/format.owner").ownerComment;
|
|
648
|
+
comments: (i: unknown) => i is import("./@types/format.owner").ownerComment[];
|
|
649
|
+
};
|
|
650
|
+
v1: {
|
|
651
|
+
comment: (i: unknown) => i is import("./@types/format.v1").v1Comment;
|
|
652
|
+
thread: (i: unknown) => i is import("./@types/format.v1").v1Thread;
|
|
653
|
+
threads: (i: unknown) => i is import("./@types/format.v1").v1Thread[];
|
|
654
|
+
};
|
|
655
|
+
nicoScript: {
|
|
656
|
+
range: {
|
|
657
|
+
target: (i: unknown) => i is import("@/@types/types").nicoScriptReverseTarget;
|
|
658
|
+
};
|
|
659
|
+
replace: {
|
|
660
|
+
range: (i: unknown) => i is import("@/@types/types").nicoScriptReplaceRange;
|
|
661
|
+
target: (i: unknown) => i is import("@/@types/types").nicoScriptReplaceTarget;
|
|
662
|
+
condition: (i: unknown) => i is import("@/@types/types").nicoScriptReplaceCondition;
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
comment: {
|
|
666
|
+
font: (i: unknown) => i is import("@/@types/types").commentFont;
|
|
667
|
+
loc: (i: unknown) => i is import("@/@types/types").commentLoc;
|
|
668
|
+
size: (i: unknown) => i is import("@/@types/types").commentSize;
|
|
669
|
+
command: {
|
|
670
|
+
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
671
|
+
};
|
|
672
|
+
color: (i: unknown) => i is "white" | "red" | "pink" | "orange" | "yellow" | "green" | "cyan" | "blue" | "purple" | "black" | "white2" | "niconicowhite" | "red2" | "truered" | "pink2" | "orange2" | "passionorange" | "yellow2" | "madyellow" | "green2" | "elementalgreen" | "cyan2" | "blue2" | "marinblue" | "purple2" | "nobleviolet" | "black2";
|
|
673
|
+
colorCode: (i: unknown) => i is string;
|
|
674
|
+
};
|
|
675
|
+
config: {
|
|
676
|
+
initOptions: (item: unknown) => item is Partial<import("@/@types/options").BaseOptions>;
|
|
677
|
+
};
|
|
678
|
+
};
|
|
679
|
+
constructor(canvas: HTMLCanvasElement, data: inputFormat, initOptions?: Options);
|
|
599
680
|
private preRendering;
|
|
600
681
|
private getCommentPos;
|
|
601
682
|
private sortComment;
|
|
@@ -605,6 +686,7 @@ declare class NiconiComments {
|
|
|
605
686
|
}
|
|
606
687
|
|
|
607
688
|
|
|
689
|
+
import type { commentSize, measureInput } from "@/@types/types";
|
|
608
690
|
declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
|
|
609
691
|
declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
|
|
610
692
|
declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
|
|
@@ -619,6 +701,11 @@ declare const getFontSizeAndScale: (charSize: number) => {
|
|
|
619
701
|
};
|
|
620
702
|
|
|
621
703
|
|
|
704
|
+
import type { formattedComment, formattedLegacyComment } from "@/@types/format.formatted";
|
|
705
|
+
import type { apiChat, apiGlobalNumRes, apiLeaf, apiPing, apiThread, rawApiResponse } from "@/@types/format.legacy";
|
|
706
|
+
import type { ownerComment } from "@/@types/format.owner";
|
|
707
|
+
import type { v1Comment, v1Thread } from "@/@types/format.v1";
|
|
708
|
+
import type { commentFont, commentLoc, commentSize, nicoScriptReplaceCondition, nicoScriptReplaceRange, nicoScriptReplaceTarget, nicoScriptReverseTarget } from "@/@types/types";
|
|
622
709
|
declare const typeGuard: {
|
|
623
710
|
formatted: {
|
|
624
711
|
comment: (i: unknown) => i is formattedComment;
|
|
@@ -634,9 +721,7 @@ declare const typeGuard: {
|
|
|
634
721
|
apiPing: (i: unknown) => i is apiPing;
|
|
635
722
|
apiThread: (i: unknown) => i is apiThread;
|
|
636
723
|
};
|
|
637
|
-
|
|
638
|
-
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
639
|
-
};
|
|
724
|
+
xmlDocument: (i: unknown) => i is XMLDocument;
|
|
640
725
|
legacyOwner: {
|
|
641
726
|
comments: (i: unknown) => i is string;
|
|
642
727
|
};
|
|
@@ -666,13 +751,19 @@ declare const typeGuard: {
|
|
|
666
751
|
command: {
|
|
667
752
|
key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
|
|
668
753
|
};
|
|
754
|
+
color: (i: unknown) => i is "white" | "red" | "pink" | "orange" | "yellow" | "green" | "cyan" | "blue" | "purple" | "black" | "white2" | "niconicowhite" | "red2" | "truered" | "pink2" | "orange2" | "passionorange" | "yellow2" | "madyellow" | "green2" | "elementalgreen" | "cyan2" | "blue2" | "marinblue" | "purple2" | "nobleviolet" | "black2";
|
|
755
|
+
colorCode: (i: unknown) => i is string;
|
|
669
756
|
};
|
|
670
757
|
config: {
|
|
671
|
-
initOptions: (item: unknown) => item is Partial<
|
|
758
|
+
initOptions: (item: unknown) => item is Partial<import("@/@types/options").BaseOptions>;
|
|
672
759
|
};
|
|
673
760
|
};
|
|
674
761
|
|
|
675
762
|
|
|
763
|
+
import type { configItem } from "@/@types/config";
|
|
764
|
+
import type { IComment } from "@/@types/IComment";
|
|
765
|
+
import type { commentFont, formattedCommentWithFont, formattedCommentWithSize } from "@/@types/types";
|
|
766
|
+
import type { formattedComment } from "@/@types/format.formatted";
|
|
676
767
|
declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
|
|
677
768
|
currentPos: number;
|
|
678
769
|
isChanged: boolean;
|
|
@@ -684,11 +775,13 @@ declare const arrayPush: (array: {
|
|
|
684
775
|
[key: number]: IComment[];
|
|
685
776
|
}, key: string | number, push: IComment) => void;
|
|
686
777
|
declare const hex2rgb: (hex: string) => number[];
|
|
778
|
+
declare const hex2rgba: (hex: string) => number[];
|
|
687
779
|
declare const replaceAll: (string: string, target: string, replace: string) => string;
|
|
688
780
|
declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
|
|
689
781
|
declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
|
|
690
782
|
declare const isFlashComment: (comment: formattedComment) => boolean;
|
|
691
783
|
declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
|
|
784
|
+
declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
|
|
692
785
|
|
|
693
786
|
|
|
694
787
|
export default NiconiComments;
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.38
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -9,6 +9,36 @@
|
|
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.NiconiComments = factory());
|
|
10
10
|
})(this, (function () { 'use strict';
|
|
11
11
|
|
|
12
|
+
var colors = {
|
|
13
|
+
white: "#FFFFFF",
|
|
14
|
+
red: "#FF0000",
|
|
15
|
+
pink: "#FF8080",
|
|
16
|
+
orange: "#FFC000",
|
|
17
|
+
yellow: "#FFFF00",
|
|
18
|
+
green: "#00FF00",
|
|
19
|
+
cyan: "#00FFFF",
|
|
20
|
+
blue: "#0000FF",
|
|
21
|
+
purple: "#C000FF",
|
|
22
|
+
black: "#000000",
|
|
23
|
+
white2: "#CCCC99",
|
|
24
|
+
niconicowhite: "#CCCC99",
|
|
25
|
+
red2: "#CC0033",
|
|
26
|
+
truered: "#CC0033",
|
|
27
|
+
pink2: "#FF33CC",
|
|
28
|
+
orange2: "#FF6600",
|
|
29
|
+
passionorange: "#FF6600",
|
|
30
|
+
yellow2: "#999900",
|
|
31
|
+
madyellow: "#999900",
|
|
32
|
+
green2: "#00CC66",
|
|
33
|
+
elementalgreen: "#00CC66",
|
|
34
|
+
cyan2: "#00CCCC",
|
|
35
|
+
blue2: "#3399FF",
|
|
36
|
+
marinblue: "#3399FF",
|
|
37
|
+
purple2: "#6633CC",
|
|
38
|
+
nobleviolet: "#6633CC",
|
|
39
|
+
black2: "#666666",
|
|
40
|
+
};
|
|
41
|
+
|
|
12
42
|
var isBoolean = function (i) { return typeof i === "boolean"; };
|
|
13
43
|
var isNumber = function (i) { return typeof i === "number"; };
|
|
14
44
|
var isObject = function (i) { return typeof i === "object"; };
|
|
@@ -101,47 +131,28 @@
|
|
|
101
131
|
]);
|
|
102
132
|
},
|
|
103
133
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
134
|
+
xmlDocument: function (i) {
|
|
135
|
+
if (!i.documentElement ||
|
|
136
|
+
i.documentElement.nodeName !== "packet")
|
|
137
|
+
return false;
|
|
138
|
+
if (!i.documentElement.children)
|
|
139
|
+
return false;
|
|
140
|
+
for (var index = 0; index < i.documentElement.children.length; index++) {
|
|
141
|
+
var value = i.documentElement.children[index];
|
|
142
|
+
if (!value)
|
|
143
|
+
continue;
|
|
144
|
+
if (value.nodeName === "chat" &&
|
|
145
|
+
!typeAttributeVerify(value, [
|
|
146
|
+
"no",
|
|
147
|
+
"vpos",
|
|
148
|
+
"date",
|
|
149
|
+
"date_usec",
|
|
150
|
+
"mail",
|
|
151
|
+
"premium",
|
|
152
|
+
]))
|
|
110
153
|
return false;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (!value)
|
|
114
|
-
continue;
|
|
115
|
-
if (index === 0) {
|
|
116
|
-
if (value.nodeName !== "thread" ||
|
|
117
|
-
!typeAttributeVerify(value, [
|
|
118
|
-
"resultcode",
|
|
119
|
-
"thread",
|
|
120
|
-
"server_time",
|
|
121
|
-
"last_res",
|
|
122
|
-
"revision",
|
|
123
|
-
]))
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
if (value.nodeName !== "chat" ||
|
|
128
|
-
!typeAttributeVerify(value, [
|
|
129
|
-
"thread",
|
|
130
|
-
"no",
|
|
131
|
-
"vpos",
|
|
132
|
-
"date",
|
|
133
|
-
"date_usec",
|
|
134
|
-
"anonymity",
|
|
135
|
-
"mail",
|
|
136
|
-
"leaf",
|
|
137
|
-
"premium",
|
|
138
|
-
"score",
|
|
139
|
-
]))
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return true;
|
|
144
|
-
},
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
145
156
|
},
|
|
146
157
|
legacyOwner: {
|
|
147
158
|
comments: function (i) {
|
|
@@ -214,19 +225,20 @@
|
|
|
214
225
|
nicoScript: {
|
|
215
226
|
range: {
|
|
216
227
|
target: function (i) {
|
|
217
|
-
return typeof i === "string" && !!i.match(/^(
|
|
228
|
+
return typeof i === "string" && !!i.match(/^(?:\u6295?\u30b3\u30e1|\u5168)$/);
|
|
218
229
|
},
|
|
219
230
|
},
|
|
220
231
|
replace: {
|
|
221
232
|
range: function (i) {
|
|
222
|
-
return typeof i === "string" && !!i.match(/^(
|
|
233
|
+
return typeof i === "string" && !!i.match(/^(?:\u5358|\u5168)$/);
|
|
223
234
|
},
|
|
224
235
|
target: function (i) {
|
|
225
236
|
return typeof i === "string" &&
|
|
226
|
-
!!i.match(/^(
|
|
237
|
+
!!i.match(/^(?:\u30b3\u30e1|\u6295\u30b3\u30e1|\u5168|\u542b\u3080|\u542b\u307e\u306a\u3044)$/);
|
|
227
238
|
},
|
|
228
239
|
condition: function (i) {
|
|
229
|
-
return typeof i === "string" &&
|
|
240
|
+
return typeof i === "string" &&
|
|
241
|
+
!!i.match(/^(?:\u90e8\u5206\u4e00\u81f4|\u5b8c\u5168\u4e00\u81f4)$/);
|
|
230
242
|
},
|
|
231
243
|
},
|
|
232
244
|
},
|
|
@@ -245,6 +257,13 @@
|
|
|
245
257
|
return typeof i === "string" && !!i.match(/^(?:full|ender|_live|invisible)$/);
|
|
246
258
|
},
|
|
247
259
|
},
|
|
260
|
+
color: function (i) {
|
|
261
|
+
return typeof i === "string" && Object.keys(colors).includes(i);
|
|
262
|
+
},
|
|
263
|
+
colorCode: function (i) {
|
|
264
|
+
return typeof i === "string" &&
|
|
265
|
+
!!i.match(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/);
|
|
266
|
+
},
|
|
248
267
|
},
|
|
249
268
|
config: {
|
|
250
269
|
initOptions: function (item) {
|
|
@@ -307,8 +326,9 @@
|
|
|
307
326
|
if (type === "empty" && data === undefined) {
|
|
308
327
|
return [];
|
|
309
328
|
}
|
|
310
|
-
else if (type === "
|
|
311
|
-
|
|
329
|
+
else if ((type === "XMLDocument" || type === "niconicome") &&
|
|
330
|
+
typeGuard.xmlDocument(data)) {
|
|
331
|
+
result = fromXMLDocument(data);
|
|
312
332
|
}
|
|
313
333
|
else if (type === "formatted" && typeGuard.formatted.legacyComments(data)) {
|
|
314
334
|
result = fromFormatted(data);
|
|
@@ -330,7 +350,7 @@
|
|
|
330
350
|
}
|
|
331
351
|
return sort(result);
|
|
332
352
|
};
|
|
333
|
-
var
|
|
353
|
+
var fromXMLDocument = function (data) {
|
|
334
354
|
var _a;
|
|
335
355
|
var data_ = [], userList = [];
|
|
336
356
|
for (var _i = 0, _b = Array.from(data.documentElement.children); _i < _b.length; _i++) {
|
|
@@ -724,36 +744,6 @@
|
|
|
724
744
|
},
|
|
725
745
|
};
|
|
726
746
|
|
|
727
|
-
var colors = {
|
|
728
|
-
white: "#FFFFFF",
|
|
729
|
-
red: "#FF0000",
|
|
730
|
-
pink: "#FF8080",
|
|
731
|
-
orange: "#FFC000",
|
|
732
|
-
yellow: "#FFFF00",
|
|
733
|
-
green: "#00FF00",
|
|
734
|
-
cyan: "#00FFFF",
|
|
735
|
-
blue: "#0000FF",
|
|
736
|
-
purple: "#C000FF",
|
|
737
|
-
black: "#000000",
|
|
738
|
-
white2: "#CCCC99",
|
|
739
|
-
niconicowhite: "#CCCC99",
|
|
740
|
-
red2: "#CC0033",
|
|
741
|
-
truered: "#CC0033",
|
|
742
|
-
pink2: "#FF33CC",
|
|
743
|
-
orange2: "#FF6600",
|
|
744
|
-
passionorange: "#FF6600",
|
|
745
|
-
yellow2: "#999900",
|
|
746
|
-
madyellow: "#999900",
|
|
747
|
-
green2: "#00CC66",
|
|
748
|
-
elementalgreen: "#00CC66",
|
|
749
|
-
cyan2: "#00CCCC",
|
|
750
|
-
blue2: "#3399FF",
|
|
751
|
-
marinblue: "#3399FF",
|
|
752
|
-
purple2: "#6633CC",
|
|
753
|
-
nobleviolet: "#6633CC",
|
|
754
|
-
black2: "#666666",
|
|
755
|
-
};
|
|
756
|
-
|
|
757
747
|
var defaultConfig;
|
|
758
748
|
var initConfig = function () {
|
|
759
749
|
var platform = (function (ua) {
|
|
@@ -1021,6 +1011,30 @@
|
|
|
1021
1011
|
return parseInt(str, 16);
|
|
1022
1012
|
});
|
|
1023
1013
|
};
|
|
1014
|
+
var hex2rgba = function (hex) {
|
|
1015
|
+
if (hex.slice(0, 1) === "#")
|
|
1016
|
+
hex = hex.slice(1);
|
|
1017
|
+
if (hex.length === 4)
|
|
1018
|
+
hex =
|
|
1019
|
+
hex.slice(0, 1) +
|
|
1020
|
+
hex.slice(0, 1) +
|
|
1021
|
+
hex.slice(1, 2) +
|
|
1022
|
+
hex.slice(1, 2) +
|
|
1023
|
+
hex.slice(2, 3) +
|
|
1024
|
+
hex.slice(2, 3) +
|
|
1025
|
+
hex.slice(3, 4) +
|
|
1026
|
+
hex.slice(3, 4);
|
|
1027
|
+
return [
|
|
1028
|
+
hex.slice(0, 2),
|
|
1029
|
+
hex.slice(2, 4),
|
|
1030
|
+
hex.slice(4, 6),
|
|
1031
|
+
hex.slice(4, 6),
|
|
1032
|
+
].map(function (str, index) {
|
|
1033
|
+
if (index === 3)
|
|
1034
|
+
return parseInt(str, 16) / 256;
|
|
1035
|
+
return parseInt(str, 16);
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1024
1038
|
var replaceAll = function (string, target, replace) {
|
|
1025
1039
|
while (string.indexOf(target) !== -1) {
|
|
1026
1040
|
string = string.replace(target, replace);
|
|
@@ -1282,6 +1296,7 @@
|
|
|
1282
1296
|
size: undefined,
|
|
1283
1297
|
fontSize: undefined,
|
|
1284
1298
|
color: undefined,
|
|
1299
|
+
strokeColor: undefined,
|
|
1285
1300
|
font: undefined,
|
|
1286
1301
|
full: false,
|
|
1287
1302
|
ender: false,
|
|
@@ -1292,10 +1307,19 @@
|
|
|
1292
1307
|
for (var _i = 0, metadata_1 = metadata; _i < metadata_1.length; _i++) {
|
|
1293
1308
|
var command = metadata_1[_i];
|
|
1294
1309
|
command = command.toLowerCase();
|
|
1295
|
-
var match =
|
|
1296
|
-
if (match && match[1]) {
|
|
1310
|
+
var match = void 0;
|
|
1311
|
+
if ((match = command.match(/^(?:@|\uff20)([0-9.]+)/)) && match[1]) {
|
|
1297
1312
|
result.long = Number(match[1]);
|
|
1298
1313
|
}
|
|
1314
|
+
else if (result.strokeColor === undefined &&
|
|
1315
|
+
(match = command.match(/^nico:stroke:(.+)$/))) {
|
|
1316
|
+
if (typeGuard.comment.color(match[1])) {
|
|
1317
|
+
result.strokeColor = colors[match[1]];
|
|
1318
|
+
}
|
|
1319
|
+
else if (typeGuard.comment.colorCode(match[1])) {
|
|
1320
|
+
result.strokeColor = match[1].slice(1);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1299
1323
|
else if (result.loc === undefined && typeGuard.comment.loc(command)) {
|
|
1300
1324
|
result.loc = command;
|
|
1301
1325
|
}
|
|
@@ -1327,6 +1351,20 @@
|
|
|
1327
1351
|
}
|
|
1328
1352
|
}
|
|
1329
1353
|
return result;
|
|
1354
|
+
};
|
|
1355
|
+
var getStrokeColor = function (comment) {
|
|
1356
|
+
if (comment.strokeColor) {
|
|
1357
|
+
var length_1 = comment.strokeColor.length;
|
|
1358
|
+
if (length_1 === 3 || length_1 === 6) {
|
|
1359
|
+
return "rgba(".concat(hex2rgb(comment.strokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
1360
|
+
}
|
|
1361
|
+
else if (length_1 === 4 || length_1 === 8) {
|
|
1362
|
+
return "rgba(".concat(hex2rgba(comment.strokeColor).join(","), ")");
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
return "rgba(".concat(hex2rgb(comment.color === "#000000"
|
|
1366
|
+
? config.contextStrokeInversionColor
|
|
1367
|
+
: config.contextStrokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
1330
1368
|
};
|
|
1331
1369
|
|
|
1332
1370
|
var getLineHeight = function (fontSize, isFlash, resized) {
|
|
@@ -1700,7 +1738,9 @@
|
|
|
1700
1738
|
var _this = this;
|
|
1701
1739
|
var _a;
|
|
1702
1740
|
if (this.comment.invisible ||
|
|
1703
|
-
(this.comment.lineCount === 1 && this.comment.width === 0)
|
|
1741
|
+
(this.comment.lineCount === 1 && this.comment.width === 0) ||
|
|
1742
|
+
this.comment.height - (this.comment.charSize - this.comment.lineHeight) <=
|
|
1743
|
+
0)
|
|
1704
1744
|
return null;
|
|
1705
1745
|
var cacheKey = JSON.stringify(this.comment.content) +
|
|
1706
1746
|
"@@HTML5@@" +
|
|
@@ -1725,9 +1765,7 @@
|
|
|
1725
1765
|
var context = image.getContext("2d");
|
|
1726
1766
|
if (!context)
|
|
1727
1767
|
throw new Error("Fail to get CanvasRenderingContext2D");
|
|
1728
|
-
context.strokeStyle =
|
|
1729
|
-
? config.contextStrokeInversionColor
|
|
1730
|
-
: config.contextStrokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
1768
|
+
context.strokeStyle = getStrokeColor(this.comment);
|
|
1731
1769
|
context.textAlign = "start";
|
|
1732
1770
|
context.textBaseline = "alphabetic";
|
|
1733
1771
|
context.lineWidth = config.contextLineWidth;
|
|
@@ -2249,7 +2287,9 @@
|
|
|
2249
2287
|
FlashComment.prototype.getTextImage = function () {
|
|
2250
2288
|
var _this = this;
|
|
2251
2289
|
if (this.comment.invisible ||
|
|
2252
|
-
(this.comment.lineCount === 1 && this.comment.width === 0)
|
|
2290
|
+
(this.comment.lineCount === 1 && this.comment.width === 0) ||
|
|
2291
|
+
this.comment.height - (this.comment.charSize - this.comment.lineHeight) <=
|
|
2292
|
+
0)
|
|
2253
2293
|
return null;
|
|
2254
2294
|
var cacheKey = JSON.stringify(this.comment.content) +
|
|
2255
2295
|
"@@FLASH@@" +
|
|
@@ -2271,9 +2311,7 @@
|
|
|
2271
2311
|
var context = image.getContext("2d");
|
|
2272
2312
|
if (!context)
|
|
2273
2313
|
throw new Error("Fail to get CanvasRenderingContext2D");
|
|
2274
|
-
context.strokeStyle =
|
|
2275
|
-
? config.contextStrokeInversionColor
|
|
2276
|
-
: config.contextStrokeColor).join(","), ",").concat(config.contextStrokeOpacity, ")");
|
|
2314
|
+
context.strokeStyle = getStrokeColor(this.comment);
|
|
2277
2315
|
context.textAlign = "start";
|
|
2278
2316
|
context.textBaseline = "alphabetic";
|
|
2279
2317
|
context.lineWidth = 4;
|
|
@@ -2705,6 +2743,7 @@
|
|
|
2705
2743
|
NiconiComments.prototype.clear = function () {
|
|
2706
2744
|
this.context.clearRect(0, 0, config.canvasWidth, config.canvasHeight);
|
|
2707
2745
|
};
|
|
2746
|
+
NiconiComments.typeGuard = typeGuard;
|
|
2708
2747
|
return NiconiComments;
|
|
2709
2748
|
}());
|
|
2710
2749
|
var logger = function (msg) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
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/bundle.d.ts",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"prettier": "2.7.1",
|
|
60
60
|
"rimraf": "^3.0.2",
|
|
61
61
|
"rollup": "^3.3.0",
|
|
62
|
+
"tslib": "^2.4.1",
|
|
62
63
|
"typedoc": "^0.23.21",
|
|
63
64
|
"typedoc-plugin-missing-exports": "^1.0.0",
|
|
64
65
|
"typescript": "^4.9.3"
|