@xpadev-net/niconicomments 0.2.39 → 0.2.41

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.d.ts CHANGED
@@ -1,224 +1,244 @@
1
-
2
-
3
-
4
- declare class FlashComment implements IComment {
5
- private readonly context;
6
- readonly comment: formattedCommentWithSize;
7
- private readonly _globalScale;
8
- private scale;
9
- private scaleX;
10
- posY: number;
11
- image?: HTMLCanvasElement | null;
12
- constructor(comment: formattedComment, context: CanvasRenderingContext2D);
13
- get invisible(): boolean;
14
- get loc(): commentLoc;
15
- get long(): number;
16
- get vpos(): number;
17
- get width(): number;
18
- get height(): number;
19
- get flash(): boolean;
20
- get layer(): number;
21
- get owner(): boolean;
22
- get mail(): string[];
23
- get lineCount(): number;
24
- parseCommand(comment: formattedComment): parsedCommand;
25
- parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
26
- measureText(comment: measureTextInput): measureTextResult;
27
- getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
28
- draw(vpos: number, showCollision: boolean, debug: boolean): void;
29
- getTextImage(): HTMLCanvasElement | null;
30
- }
31
-
32
-
33
-
34
-
35
-
36
- declare class HTML5Comment implements IComment {
37
- private readonly context;
38
- readonly comment: formattedCommentWithSize;
39
- posY: number;
40
- image?: HTMLCanvasElement | null;
41
- constructor(comment: formattedComment, context: CanvasRenderingContext2D);
42
- get invisible(): boolean;
43
- get loc(): import("@/@types/types").commentLoc;
44
- get long(): number;
45
- get vpos(): number;
46
- get width(): number;
47
- get height(): number;
48
- get flash(): boolean;
49
- get layer(): number;
50
- get owner(): boolean;
51
- get mail(): string[];
52
- get lineCount(): number;
53
- parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
54
- measureText(comment: measureTextInput): measureTextResult;
55
- getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
56
- draw(vpos: number, showCollision: boolean, debug: boolean): void;
57
- getTextImage(): HTMLCanvasElement | null;
58
- }
59
-
60
-
61
- declare let imageCache: {
62
- [key: string]: {
63
- image: HTMLCanvasElement;
64
- timeout: number;
65
- };
66
- };
67
- declare const resetImageCache: () => void;
68
-
69
-
70
-
71
- declare let nicoScripts: nicoScript;
72
- declare const resetNicoScripts: () => void;
73
-
74
-
75
- declare const colors: {
76
- white: string;
77
- red: string;
78
- pink: string;
79
- orange: string;
80
- yellow: string;
81
- green: string;
82
- cyan: string;
83
- blue: string;
84
- purple: string;
85
- black: string;
86
- white2: string;
87
- niconicowhite: string;
88
- red2: string;
89
- truered: string;
90
- pink2: string;
91
- orange2: string;
92
- passionorange: string;
93
- yellow2: string;
94
- madyellow: string;
95
- green2: string;
96
- elementalgreen: string;
97
- cyan2: string;
98
- blue2: string;
99
- marinblue: string;
100
- purple2: string;
101
- nobleviolet: string;
102
- black2: string;
103
- };
104
-
105
-
106
-
107
-
108
- declare let defaultConfig: BaseConfig;
109
- declare const initConfig: () => void;
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;
115
-
116
-
117
- declare const fontTemplates: {
118
- arial: {
119
- font: string;
120
- offset: number;
121
- weight: number;
122
- };
123
- gothic: {
124
- font: string;
125
- offset: number;
126
- weight: number;
127
- };
128
- gulim: {
129
- font: string;
130
- offset: number;
131
- weight: number;
132
- };
133
- mincho: {
134
- font: string;
135
- offset: number;
136
- weight: number;
137
- };
138
- simsun: {
139
- font: string;
140
- offset: number;
141
- weight: number;
142
- };
143
- macGothicPro6: {
144
- font: string;
145
- offset: number;
146
- weight: number;
147
- };
148
- macGothicPro3: {
149
- font: string;
150
- offset: number;
151
- weight: number;
152
- };
153
- macMincho: {
154
- font: string;
155
- offset: number;
156
- weight: number;
157
- };
158
- macGothic1: {
159
- font: string;
160
- offset: number;
161
- weight: number;
162
- };
163
- macGothic2: {
164
- font: string;
165
- offset: number;
166
- weight: number;
167
- };
168
- sansSerif600: {
169
- font: string;
170
- offset: number;
171
- weight: number;
172
- };
173
- sansSerif400: {
174
- font: string;
175
- offset: number;
176
- weight: number;
177
- };
178
- serif: {
179
- font: string;
180
- offset: number;
181
- weight: number;
182
- };
183
- };
184
- declare const fonts: {
185
- win7: {
186
- defont: FontItem;
187
- gothic: FontItem;
188
- mincho: FontItem;
189
- };
190
- win8_1: {
191
- defont: FontItem;
192
- gothic: FontItem;
193
- mincho: FontItem;
194
- };
195
- win: {
196
- defont: FontItem;
197
- gothic: FontItem;
198
- mincho: FontItem;
199
- };
200
- mac10_9: {
201
- defont: FontItem;
202
- gothic: FontItem;
203
- mincho: FontItem;
204
- };
205
- mac10_11: {
206
- defont: FontItem;
207
- gothic: FontItem;
208
- mincho: FontItem;
209
- };
210
- mac: {
211
- defont: FontItem;
212
- gothic: FontItem;
213
- mincho: FontItem;
214
- };
215
- other: {
216
- defont: FontItem;
217
- gothic: FontItem;
218
- mincho: FontItem;
219
- };
220
- };
221
-
1
+
2
+
3
+
4
+ declare class FlashComment implements IComment {
5
+ private readonly context;
6
+ readonly comment: formattedCommentWithSize;
7
+ private readonly _globalScale;
8
+ private scale;
9
+ private scaleX;
10
+ posY: number;
11
+ image?: HTMLCanvasElement | null;
12
+ constructor(comment: formattedComment, context: CanvasRenderingContext2D);
13
+ get invisible(): boolean;
14
+ get loc(): commentLoc;
15
+ get long(): number;
16
+ get vpos(): number;
17
+ get width(): number;
18
+ get height(): number;
19
+ get flash(): boolean;
20
+ get layer(): number;
21
+ get owner(): boolean;
22
+ get mail(): string[];
23
+ get lineCount(): number;
24
+ parseCommand(comment: formattedComment): parsedCommand;
25
+ parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
26
+ measureText(comment: measureTextInput): measureTextResult;
27
+ getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
28
+ draw(vpos: number, showCollision: boolean, debug: boolean): void;
29
+ getTextImage(): HTMLCanvasElement | null;
30
+ }
31
+
32
+
33
+
34
+
35
+
36
+ declare class HTML5Comment implements IComment {
37
+ private readonly context;
38
+ readonly comment: formattedCommentWithSize;
39
+ posY: number;
40
+ image?: HTMLCanvasElement | null;
41
+ constructor(comment: formattedComment, context: CanvasRenderingContext2D);
42
+ get invisible(): boolean;
43
+ get loc(): commentLoc;
44
+ get long(): number;
45
+ get vpos(): number;
46
+ get width(): number;
47
+ get height(): number;
48
+ get flash(): boolean;
49
+ get layer(): number;
50
+ get owner(): boolean;
51
+ get mail(): string[];
52
+ get lineCount(): number;
53
+ parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
54
+ measureText(comment: measureTextInput): measureTextResult;
55
+ getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
56
+ draw(vpos: number, showCollision: boolean, debug: boolean): void;
57
+ getTextImage(): HTMLCanvasElement | null;
58
+ }
59
+
60
+
61
+ declare let imageCache: {
62
+ [key: string]: {
63
+ image: HTMLCanvasElement;
64
+ timeout: number;
65
+ };
66
+ };
67
+ declare const resetImageCache: () => void;
68
+
69
+
70
+
71
+ declare let nicoScripts: nicoScript;
72
+ declare const resetNicoScripts: () => void;
73
+
74
+
75
+ declare const colors: {
76
+ white: string;
77
+ red: string;
78
+ pink: string;
79
+ orange: string;
80
+ yellow: string;
81
+ green: string;
82
+ cyan: string;
83
+ blue: string;
84
+ purple: string;
85
+ black: string;
86
+ white2: string;
87
+ niconicowhite: string;
88
+ red2: string;
89
+ truered: string;
90
+ pink2: string;
91
+ orange2: string;
92
+ passionorange: string;
93
+ yellow2: string;
94
+ madyellow: string;
95
+ green2: string;
96
+ elementalgreen: string;
97
+ cyan2: string;
98
+ blue2: string;
99
+ marinblue: string;
100
+ purple2: string;
101
+ nobleviolet: string;
102
+ black2: string;
103
+ };
104
+
105
+
106
+
107
+
108
+ declare let defaultConfig: BaseConfig;
109
+ declare const initConfig: () => void;
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;
115
+
116
+
117
+ declare const fontTemplates: {
118
+ arial: {
119
+ font: string;
120
+ offset: number;
121
+ weight: number;
122
+ };
123
+ gothic: {
124
+ font: string;
125
+ offset: number;
126
+ weight: number;
127
+ };
128
+ gulim: {
129
+ font: string;
130
+ offset: number;
131
+ weight: number;
132
+ };
133
+ mincho: {
134
+ font: string;
135
+ offset: number;
136
+ weight: number;
137
+ };
138
+ simsun: {
139
+ font: string;
140
+ offset: number;
141
+ weight: number;
142
+ };
143
+ macGothicPro6: {
144
+ font: string;
145
+ offset: number;
146
+ weight: number;
147
+ };
148
+ macGothicPro3: {
149
+ font: string;
150
+ offset: number;
151
+ weight: number;
152
+ };
153
+ macMincho: {
154
+ font: string;
155
+ offset: number;
156
+ weight: number;
157
+ };
158
+ macGothic1: {
159
+ font: string;
160
+ offset: number;
161
+ weight: number;
162
+ };
163
+ macGothic2: {
164
+ font: string;
165
+ offset: number;
166
+ weight: number;
167
+ };
168
+ sansSerif600: {
169
+ font: string;
170
+ offset: number;
171
+ weight: number;
172
+ };
173
+ sansSerif400: {
174
+ font: string;
175
+ offset: number;
176
+ weight: number;
177
+ };
178
+ serif: {
179
+ font: string;
180
+ offset: number;
181
+ weight: number;
182
+ };
183
+ };
184
+ declare const fonts: {
185
+ win7: {
186
+ defont: FontItem;
187
+ gothic: FontItem;
188
+ mincho: FontItem;
189
+ };
190
+ win8_1: {
191
+ defont: FontItem;
192
+ gothic: FontItem;
193
+ mincho: FontItem;
194
+ };
195
+ win: {
196
+ defont: FontItem;
197
+ gothic: FontItem;
198
+ mincho: FontItem;
199
+ };
200
+ mac10_9: {
201
+ defont: FontItem;
202
+ gothic: FontItem;
203
+ mincho: FontItem;
204
+ };
205
+ mac10_11: {
206
+ defont: FontItem;
207
+ gothic: FontItem;
208
+ mincho: FontItem;
209
+ };
210
+ mac: {
211
+ defont: FontItem;
212
+ gothic: FontItem;
213
+ mincho: FontItem;
214
+ };
215
+ other: {
216
+ defont: FontItem;
217
+ gothic: FontItem;
218
+ mincho: FontItem;
219
+ };
220
+ };
221
+
222
+
223
+
224
+
225
+ export interface IComment {
226
+ comment: formattedCommentWithSize;
227
+ invisible: boolean;
228
+ loc: commentLoc;
229
+ width: number;
230
+ long: number;
231
+ height: number;
232
+ vpos: number;
233
+ flash: boolean;
234
+ posY: number;
235
+ owner: boolean;
236
+ layer: number;
237
+ mail: string[];
238
+ image?: HTMLCanvasElement | null;
239
+ getTextImage: (vpos: number) => void;
240
+ draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
241
+ }
222
242
 
223
243
  type configItem<T> = T | { html5: T; flash: T };
224
244
  type configSizeItem<T> = { big: T; medium: T; small: T };
@@ -388,400 +408,380 @@ type v1Comment = {
388
408
  isMyPost: boolean;
389
409
  };
390
410
 
391
-
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
- }
410
-
411
- import type {
412
- formattedComment,
413
- formattedLegacyComment,
414
- } from "@/@types/format.formatted";
415
-
416
-
417
-
418
-
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>;
456
-
457
-
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
- };
608
-
609
-
610
-
611
- declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
612
-
613
-
614
-
615
-
616
- declare class NiconiComments {
617
- enableLegacyPiP: boolean;
618
- showCollision: boolean;
619
- showFPS: boolean;
620
- showCommentCount: boolean;
621
- video: HTMLVideoElement | undefined;
622
- private lastVpos;
623
- private readonly canvas;
624
- private readonly collision;
625
- private readonly context;
626
- private readonly timeline;
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);
680
- private preRendering;
681
- private getCommentPos;
682
- private sortComment;
683
- addComments(...rawComments: formattedComment[]): void;
684
- drawCanvas(vpos: number, forceRendering?: boolean): void;
685
- clear(): void;
686
- }
687
-
688
-
689
-
690
- declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
691
- declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
692
- declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
693
- height: number;
694
- width: number;
695
- lineWidth: number[];
696
- itemWidth: number[][];
697
- };
698
- declare const getFontSizeAndScale: (charSize: number) => {
699
- scale: number;
700
- fontSize: number;
701
- };
702
-
703
-
704
-
705
-
706
-
707
-
708
-
709
- declare const typeGuard: {
710
- formatted: {
711
- comment: (i: unknown) => i is formattedComment;
712
- comments: (i: unknown) => i is formattedComment[];
713
- legacyComment: (i: unknown) => i is formattedLegacyComment;
714
- legacyComments: (i: unknown) => i is formattedLegacyComment[];
715
- };
716
- legacy: {
717
- rawApiResponses: (i: unknown) => i is rawApiResponse[];
718
- apiChat: (i: unknown) => i is apiChat;
719
- apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
720
- apiLeaf: (i: unknown) => i is apiLeaf;
721
- apiPing: (i: unknown) => i is apiPing;
722
- apiThread: (i: unknown) => i is apiThread;
723
- };
724
- xmlDocument: (i: unknown) => i is XMLDocument;
725
- legacyOwner: {
726
- comments: (i: unknown) => i is string;
727
- };
728
- owner: {
729
- comment: (i: unknown) => i is ownerComment;
730
- comments: (i: unknown) => i is ownerComment[];
731
- };
732
- v1: {
733
- comment: (i: unknown) => i is v1Comment;
734
- thread: (i: unknown) => i is v1Thread;
735
- threads: (i: unknown) => i is v1Thread[];
736
- };
737
- nicoScript: {
738
- range: {
739
- target: (i: unknown) => i is nicoScriptReverseTarget;
740
- };
741
- replace: {
742
- range: (i: unknown) => i is nicoScriptReplaceRange;
743
- target: (i: unknown) => i is nicoScriptReplaceTarget;
744
- condition: (i: unknown) => i is nicoScriptReplaceCondition;
745
- };
746
- };
747
- comment: {
748
- font: (i: unknown) => i is commentFont;
749
- loc: (i: unknown) => i is commentLoc;
750
- size: (i: unknown) => i is commentSize;
751
- command: {
752
- key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
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;
756
- };
757
- config: {
758
- initOptions: (item: unknown) => item is Partial<import("@/@types/options").BaseOptions>;
759
- };
760
- };
761
-
762
-
763
-
764
-
765
-
766
-
767
- declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
768
- currentPos: number;
769
- isChanged: boolean;
770
- isBreak: boolean;
771
- };
772
- declare const getPosX: (width: number, vpos: number, long: number) => number;
773
- declare const parseFont: (font: commentFont, size: string | number) => string;
774
- declare const arrayPush: (array: {
775
- [key: number]: IComment[];
776
- }, key: string | number, push: IComment) => void;
777
- declare const hex2rgb: (hex: string) => number[];
778
- declare const hex2rgba: (hex: string) => number[];
779
- declare const replaceAll: (string: string, target: string, replace: string) => string;
780
- declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
781
- declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
782
- declare const isFlashComment: (comment: formattedComment) => boolean;
783
- declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
784
- declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
785
-
411
+
412
+
413
+
414
+
415
+
416
+
417
+ export type inputFormatType =
418
+ | "XMLDocument"
419
+ | "niconicome"
420
+ | "formatted"
421
+ | "legacy"
422
+ | "legacyOwner"
423
+ | "owner"
424
+ | "v1"
425
+ | "empty"
426
+ | "default";
427
+ export type inputFormat =
428
+ | XMLDocument
429
+ | formattedComment[]
430
+ | formattedLegacyComment[]
431
+ | rawApiResponse[]
432
+ | ownerComment[]
433
+ | v1Thread[]
434
+ | string
435
+ | undefined;
436
+ type modeType = "default" | "html5" | "flash";
437
+ type BaseOptions = {
438
+ config: Config;
439
+ debug: boolean;
440
+ enableLegacyPiP: boolean;
441
+ format: inputFormatType;
442
+ formatted: boolean;
443
+ keepCA: boolean;
444
+ mode: modeType;
445
+ scale: number;
446
+ showCollision: boolean;
447
+ showCommentCount: boolean;
448
+ showFPS: boolean;
449
+ useLegacy: boolean;
450
+ video: HTMLVideoElement | undefined;
451
+ };
452
+ export type Options = Partial<BaseOptions>;
453
+
454
+
455
+
456
+ type formattedCommentWithFont = {
457
+ id: number;
458
+ vpos: number;
459
+ date: number;
460
+ date_usec: number;
461
+ owner: boolean;
462
+ premium: boolean;
463
+ mail: string[];
464
+ user_id: number;
465
+ layer: number;
466
+ loc: commentLoc;
467
+ size: commentSize;
468
+ fontSize: number;
469
+ font: commentFont;
470
+ color: string;
471
+ strokeColor?: string;
472
+ full: boolean;
473
+ ender: boolean;
474
+ _live: boolean;
475
+ long: number;
476
+ invisible: boolean;
477
+ content: commentContentItem[];
478
+ flash: boolean;
479
+ lineCount: number;
480
+ lineOffset: number;
481
+ };
482
+ type formattedCommentWithSize = formattedCommentWithFont & {
483
+ height: number;
484
+ width: number;
485
+ lineHeight: number;
486
+ resized: boolean;
487
+ resizedX: boolean;
488
+ resizedY: boolean;
489
+ content: commentMeasuredContentItem[];
490
+ charSize: number;
491
+ };
492
+ type parsedComment = formattedCommentWithSize & {
493
+ posY: number;
494
+ image?: HTMLCanvasElement | boolean;
495
+ };
496
+ type commentContentItem = {
497
+ content: string;
498
+ font?: commentFlashFont;
499
+ width?: number[];
500
+ };
501
+ type commentMeasuredContentItem = commentContentItem & {
502
+ width: number[];
503
+ };
504
+ type commentContentIndex = {
505
+ index: number;
506
+ font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
507
+ };
508
+ type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
509
+ type commentFlashFont = "defont" | "gulim" | "simsun";
510
+ type commentSize = "big" | "medium" | "small";
511
+ type commentLoc = "ue" | "naka" | "shita";
512
+ type collision = { [key in collisionPos]: collisionItem };
513
+ type collisionPos = "ue" | "shita" | "right" | "left";
514
+ type collisionItem = { [p: number]: IComment[] };
515
+ type nicoScript = {
516
+ reverse: nicoScriptReverse[];
517
+ ban: nicoScriptBan[];
518
+ default: nicoScriptDefault[];
519
+ replace: nicoScriptReplace[];
520
+ };
521
+ type nicoScriptReverse = {
522
+ target: nicoScriptReverseTarget;
523
+ start: number;
524
+ end: number;
525
+ };
526
+ type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
527
+ type nicoScriptReplace = {
528
+ start: number;
529
+ long: number | undefined;
530
+ keyword: string;
531
+ replace: string;
532
+ range: nicoScriptReplaceRange;
533
+ target: nicoScriptReplaceTarget;
534
+ condition: nicoScriptReplaceCondition;
535
+ color: string | undefined;
536
+ size: commentSize | undefined;
537
+ font: commentFont | undefined;
538
+ loc: commentLoc | undefined;
539
+ no: number;
540
+ };
541
+ type nicoScriptReplaceRange = "単" | "全";
542
+ type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
543
+ type nicoScriptReplaceCondition = "完全一致" | "部分一致";
544
+ type nicoScriptBan = {
545
+ start: number;
546
+ end: number;
547
+ };
548
+ type nicoScriptDefault = {
549
+ start: number;
550
+ long: number | undefined;
551
+ color: string | undefined;
552
+ size: commentSize | undefined;
553
+ font: commentFont | undefined;
554
+ loc: commentLoc | undefined;
555
+ };
556
+ type measureTextResult = {
557
+ width: number;
558
+ height: number;
559
+ resized: boolean;
560
+ resizedX: boolean;
561
+ resizedY: boolean;
562
+ fontSize: number;
563
+ lineHeight: number;
564
+ content: commentMeasuredContentItem[];
565
+ charSize: number;
566
+ };
567
+ type parsedCommand = {
568
+ loc: commentLoc | undefined;
569
+ size: commentSize | undefined;
570
+ fontSize: number | undefined;
571
+ color: string | undefined;
572
+ strokeColor?: string;
573
+ font: commentFont | undefined;
574
+ full: boolean;
575
+ ender: boolean;
576
+ _live: boolean;
577
+ invisible: boolean;
578
+ long: number | undefined;
579
+ };
580
+
581
+ type measureTextInput = {
582
+ content: commentContentItem[];
583
+ resized?: boolean;
584
+ ender: boolean;
585
+ size: commentSize;
586
+ fontSize: number;
587
+ resizedY?: boolean;
588
+ resizedX?: boolean;
589
+ font: commentFont;
590
+ loc: commentLoc;
591
+ full: boolean;
592
+ flash: boolean;
593
+ lineCount: number;
594
+ lineHeight?: number;
595
+ charSize?: number;
596
+ };
597
+
598
+ type measureInput = {
599
+ font: commentFont;
600
+ content: commentContentItem[];
601
+ lineHeight: number;
602
+ charSize: number;
603
+ lineCount: number;
604
+ };
605
+
606
+
607
+
608
+ declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
609
+
610
+
611
+
612
+
613
+ declare class NiconiComments {
614
+ enableLegacyPiP: boolean;
615
+ showCollision: boolean;
616
+ showFPS: boolean;
617
+ showCommentCount: boolean;
618
+ video: HTMLVideoElement | undefined;
619
+ private lastVpos;
620
+ private readonly canvas;
621
+ private readonly collision;
622
+ private readonly context;
623
+ private readonly timeline;
624
+ static typeGuard: {
625
+ formatted: {
626
+ comment: (i: unknown) => i is formattedComment;
627
+ comments: (i: unknown) => i is formattedComment[];
628
+ legacyComment: (i: unknown) => i is formattedLegacyComment;
629
+ legacyComments: (i: unknown) => i is formattedLegacyComment[];
630
+ };
631
+ legacy: {
632
+ rawApiResponses: (i: unknown) => i is rawApiResponse[];
633
+ apiChat: (i: unknown) => i is apiChat;
634
+ apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
635
+ apiLeaf: (i: unknown) => i is apiLeaf;
636
+ apiPing: (i: unknown) => i is apiPing;
637
+ apiThread: (i: unknown) => i is apiThread;
638
+ };
639
+ xmlDocument: (i: unknown) => i is XMLDocument;
640
+ legacyOwner: {
641
+ comments: (i: unknown) => i is string;
642
+ };
643
+ owner: {
644
+ comment: (i: unknown) => i is ownerComment;
645
+ comments: (i: unknown) => i is ownerComment[];
646
+ };
647
+ v1: {
648
+ comment: (i: unknown) => i is v1Comment;
649
+ thread: (i: unknown) => i is v1Thread;
650
+ threads: (i: unknown) => i is v1Thread[];
651
+ };
652
+ nicoScript: {
653
+ range: {
654
+ target: (i: unknown) => i is nicoScriptReverseTarget;
655
+ };
656
+ replace: {
657
+ range: (i: unknown) => i is nicoScriptReplaceRange;
658
+ target: (i: unknown) => i is nicoScriptReplaceTarget;
659
+ condition: (i: unknown) => i is nicoScriptReplaceCondition;
660
+ };
661
+ };
662
+ comment: {
663
+ font: (i: unknown) => i is commentFont;
664
+ loc: (i: unknown) => i is commentLoc;
665
+ size: (i: unknown) => i is commentSize;
666
+ command: {
667
+ key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
668
+ };
669
+ 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";
670
+ colorCode: (i: unknown) => i is string;
671
+ };
672
+ config: {
673
+ initOptions: (item: unknown) => item is Partial<BaseOptions>;
674
+ };
675
+ };
676
+ constructor(canvas: HTMLCanvasElement, data: inputFormat, initOptions?: Options);
677
+ private preRendering;
678
+ private getCommentPos;
679
+ private sortComment;
680
+ addComments(...rawComments: formattedComment[]): void;
681
+ drawCanvas(vpos: number, forceRendering?: boolean): void;
682
+ clear(): void;
683
+ }
684
+ declare const _default: typeof NiconiComments | {
685
+ default: typeof NiconiComments;
686
+ };
687
+
688
+
689
+
690
+ declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
691
+ declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
692
+ declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
693
+ height: number;
694
+ width: number;
695
+ lineWidth: number[];
696
+ itemWidth: number[][];
697
+ };
698
+ declare const getFontSizeAndScale: (charSize: number) => {
699
+ scale: number;
700
+ fontSize: number;
701
+ };
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+ declare const typeGuard: {
710
+ formatted: {
711
+ comment: (i: unknown) => i is formattedComment;
712
+ comments: (i: unknown) => i is formattedComment[];
713
+ legacyComment: (i: unknown) => i is formattedLegacyComment;
714
+ legacyComments: (i: unknown) => i is formattedLegacyComment[];
715
+ };
716
+ legacy: {
717
+ rawApiResponses: (i: unknown) => i is rawApiResponse[];
718
+ apiChat: (i: unknown) => i is apiChat;
719
+ apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
720
+ apiLeaf: (i: unknown) => i is apiLeaf;
721
+ apiPing: (i: unknown) => i is apiPing;
722
+ apiThread: (i: unknown) => i is apiThread;
723
+ };
724
+ xmlDocument: (i: unknown) => i is XMLDocument;
725
+ legacyOwner: {
726
+ comments: (i: unknown) => i is string;
727
+ };
728
+ owner: {
729
+ comment: (i: unknown) => i is ownerComment;
730
+ comments: (i: unknown) => i is ownerComment[];
731
+ };
732
+ v1: {
733
+ comment: (i: unknown) => i is v1Comment;
734
+ thread: (i: unknown) => i is v1Thread;
735
+ threads: (i: unknown) => i is v1Thread[];
736
+ };
737
+ nicoScript: {
738
+ range: {
739
+ target: (i: unknown) => i is nicoScriptReverseTarget;
740
+ };
741
+ replace: {
742
+ range: (i: unknown) => i is nicoScriptReplaceRange;
743
+ target: (i: unknown) => i is nicoScriptReplaceTarget;
744
+ condition: (i: unknown) => i is nicoScriptReplaceCondition;
745
+ };
746
+ };
747
+ comment: {
748
+ font: (i: unknown) => i is commentFont;
749
+ loc: (i: unknown) => i is commentLoc;
750
+ size: (i: unknown) => i is commentSize;
751
+ command: {
752
+ key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
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;
756
+ };
757
+ config: {
758
+ initOptions: (item: unknown) => item is Partial<BaseOptions>;
759
+ };
760
+ };
761
+
762
+
763
+
764
+
765
+
766
+
767
+ declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
768
+ currentPos: number;
769
+ isChanged: boolean;
770
+ isBreak: boolean;
771
+ };
772
+ declare const getPosX: (width: number, vpos: number, long: number) => number;
773
+ declare const parseFont: (font: commentFont, size: string | number) => string;
774
+ declare const arrayPush: (array: {
775
+ [key: number]: IComment[];
776
+ }, key: string | number, push: IComment) => void;
777
+ declare const hex2rgb: (hex: string) => number[];
778
+ declare const hex2rgba: (hex: string) => number[];
779
+ declare const replaceAll: (string: string, target: string, replace: string) => string;
780
+ declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
781
+ declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
782
+ declare const isFlashComment: (comment: formattedComment) => boolean;
783
+ declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
784
+ declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
785
+
786
786
 
787
787
  export default NiconiComments;