@xpadev-net/niconicomments 0.2.46 → 0.2.48

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,260 +1,228 @@
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
- parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
25
- measureText(comment: measureTextInput): measureTextResult;
26
- getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
27
- draw(vpos: number, showCollision: boolean, debug: boolean): void;
28
- getTextImage(): HTMLCanvasElement | null;
29
- }
30
-
31
-
32
-
33
-
34
-
35
- declare class HTML5Comment implements IComment {
36
- private readonly context;
37
- readonly comment: formattedCommentWithSize;
38
- posY: number;
39
- image?: HTMLCanvasElement | null;
40
- constructor(comment: formattedComment, context: CanvasRenderingContext2D);
41
- get invisible(): boolean;
42
- get loc(): commentLoc;
43
- get long(): number;
44
- get vpos(): number;
45
- get width(): number;
46
- get height(): number;
47
- get flash(): boolean;
48
- get layer(): number;
49
- get owner(): boolean;
50
- get mail(): string[];
51
- get lineCount(): number;
52
- parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
53
- measureText(comment: measureTextInput): measureTextResult;
54
- getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
55
- draw(vpos: number, showCollision: boolean, debug: boolean): void;
56
- getTextImage(): HTMLCanvasElement | null;
57
- }
58
-
59
-
60
- declare let imageCache: {
61
- [key: string]: {
62
- image: HTMLCanvasElement;
63
- timeout: number;
64
- };
65
- };
66
- declare const resetImageCache: () => void;
67
-
68
-
69
-
70
- declare let nicoScripts: nicoScript;
71
- declare const resetNicoScripts: () => void;
72
-
73
-
74
-
75
- declare let plugins: IPlugin[];
76
- declare const setPlugins: (input: IPlugin[]) => void;
77
-
78
-
79
- declare const colors: {
80
- white: string;
81
- red: string;
82
- pink: string;
83
- orange: string;
84
- yellow: string;
85
- green: string;
86
- cyan: string;
87
- blue: string;
88
- purple: string;
89
- black: string;
90
- white2: string;
91
- niconicowhite: string;
92
- red2: string;
93
- truered: string;
94
- pink2: string;
95
- orange2: string;
96
- passionorange: string;
97
- yellow2: string;
98
- madyellow: string;
99
- green2: string;
100
- elementalgreen: string;
101
- cyan2: string;
102
- blue2: string;
103
- marinblue: string;
104
- purple2: string;
105
- nobleviolet: string;
106
- black2: string;
107
- };
108
-
109
-
110
-
111
-
112
- declare let defaultConfig: BaseConfig;
113
- declare const initConfig: () => void;
114
- declare const defaultOptions: BaseOptions;
115
- declare let config: BaseConfig;
116
- declare let options: BaseOptions;
117
- declare const setConfig: (value: BaseConfig) => BaseConfig;
118
- declare const setOptions: (value: BaseOptions) => BaseOptions;
119
-
120
-
121
- declare const fontTemplates: {
122
- arial: {
123
- font: string;
124
- offset: number;
125
- weight: number;
126
- };
127
- gothic: {
128
- font: string;
129
- offset: number;
130
- weight: number;
131
- };
132
- gulim: {
133
- font: string;
134
- offset: number;
135
- weight: number;
136
- };
137
- mincho: {
138
- font: string;
139
- offset: number;
140
- weight: number;
141
- };
142
- simsun: {
143
- font: string;
144
- offset: number;
145
- weight: number;
146
- };
147
- macGothicPro6: {
148
- font: string;
149
- offset: number;
150
- weight: number;
151
- };
152
- macGothicPro3: {
153
- font: string;
154
- offset: number;
155
- weight: number;
156
- };
157
- macMincho: {
158
- font: string;
159
- offset: number;
160
- weight: number;
161
- };
162
- macGothic1: {
163
- font: string;
164
- offset: number;
165
- weight: number;
166
- };
167
- macGothic2: {
168
- font: string;
169
- offset: number;
170
- weight: number;
171
- };
172
- sansSerif600: {
173
- font: string;
174
- offset: number;
175
- weight: number;
176
- };
177
- sansSerif400: {
178
- font: string;
179
- offset: number;
180
- weight: number;
181
- };
182
- serif: {
183
- font: string;
184
- offset: number;
185
- weight: number;
186
- };
187
- };
188
- declare const fonts: {
189
- win7: {
190
- defont: FontItem;
191
- gothic: FontItem;
192
- mincho: FontItem;
193
- };
194
- win8_1: {
195
- defont: FontItem;
196
- gothic: FontItem;
197
- mincho: FontItem;
198
- };
199
- win: {
200
- defont: FontItem;
201
- gothic: FontItem;
202
- mincho: FontItem;
203
- };
204
- mac10_9: {
205
- defont: FontItem;
206
- gothic: FontItem;
207
- mincho: FontItem;
208
- };
209
- mac10_11: {
210
- defont: FontItem;
211
- gothic: FontItem;
212
- mincho: FontItem;
213
- };
214
- mac: {
215
- defont: FontItem;
216
- gothic: FontItem;
217
- mincho: FontItem;
218
- };
219
- other: {
220
- defont: FontItem;
221
- gothic: FontItem;
222
- mincho: FontItem;
223
- };
224
- };
225
-
226
-
227
-
228
-
229
- export interface IComment {
230
- comment: formattedCommentWithSize;
231
- invisible: boolean;
232
- loc: commentLoc;
233
- width: number;
234
- long: number;
235
- height: number;
236
- vpos: number;
237
- flash: boolean;
238
- posY: number;
239
- owner: boolean;
240
- layer: number;
241
- mail: string[];
242
- image?: HTMLCanvasElement | null;
243
- getTextImage: (vpos: number) => void;
244
- draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
245
- }
246
-
247
-
248
-
249
- export interface IPluginConstructor {
250
- id: string;
251
- new (Canvas: HTMLCanvasElement, comments: formattedComment[]): IPlugin;
252
- }
253
-
254
- export interface IPlugin {
255
- draw(vpos: number): void;
256
- addComments(comments: formattedComment[]): void;
257
- }
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
+ parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
25
+ measureText(comment: measureTextInput): measureTextResult;
26
+ getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
27
+ draw(vpos: number, showCollision: boolean, debug: boolean): void;
28
+ getTextImage(): HTMLCanvasElement | null;
29
+ }
30
+
31
+
32
+
33
+
34
+
35
+ declare class HTML5Comment implements IComment {
36
+ private readonly context;
37
+ readonly comment: formattedCommentWithSize;
38
+ posY: number;
39
+ image?: HTMLCanvasElement | null;
40
+ constructor(comment: formattedComment, context: CanvasRenderingContext2D);
41
+ get invisible(): boolean;
42
+ get loc(): commentLoc;
43
+ get long(): number;
44
+ get vpos(): number;
45
+ get width(): number;
46
+ get height(): number;
47
+ get flash(): boolean;
48
+ get layer(): number;
49
+ get owner(): boolean;
50
+ get mail(): string[];
51
+ get lineCount(): number;
52
+ parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
53
+ measureText(comment: measureTextInput): measureTextResult;
54
+ getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
55
+ draw(vpos: number, showCollision: boolean, debug: boolean): void;
56
+ getTextImage(): HTMLCanvasElement | null;
57
+ }
58
+
59
+
60
+ declare let imageCache: {
61
+ [key: string]: {
62
+ image: HTMLCanvasElement;
63
+ timeout: number;
64
+ };
65
+ };
66
+ declare const resetImageCache: () => void;
67
+
68
+
69
+
70
+ declare let nicoScripts: nicoScript;
71
+ declare const resetNicoScripts: () => void;
72
+
73
+
74
+
75
+ declare let plugins: IPlugin[];
76
+ declare const setPlugins: (input: IPlugin[]) => void;
77
+
78
+
79
+ declare const colors: {
80
+ white: string;
81
+ red: string;
82
+ pink: string;
83
+ orange: string;
84
+ yellow: string;
85
+ green: string;
86
+ cyan: string;
87
+ blue: string;
88
+ purple: string;
89
+ black: string;
90
+ white2: string;
91
+ niconicowhite: string;
92
+ red2: string;
93
+ truered: string;
94
+ pink2: string;
95
+ orange2: string;
96
+ passionorange: string;
97
+ yellow2: string;
98
+ madyellow: string;
99
+ green2: string;
100
+ elementalgreen: string;
101
+ cyan2: string;
102
+ blue2: string;
103
+ marinblue: string;
104
+ purple2: string;
105
+ nobleviolet: string;
106
+ black2: string;
107
+ };
108
+
109
+
110
+
111
+
112
+ declare let defaultConfig: BaseConfig;
113
+ declare const initConfig: () => void;
114
+ declare const defaultOptions: BaseOptions;
115
+ declare let config: BaseConfig;
116
+ declare let options: BaseOptions;
117
+ declare const setConfig: (value: BaseConfig) => BaseConfig;
118
+ declare const setOptions: (value: BaseOptions) => BaseOptions;
119
+
120
+
121
+ declare const fontTemplates: {
122
+ arial: {
123
+ font: string;
124
+ offset: number;
125
+ weight: number;
126
+ };
127
+ gothic: {
128
+ font: string;
129
+ offset: number;
130
+ weight: number;
131
+ };
132
+ gulim: {
133
+ font: string;
134
+ offset: number;
135
+ weight: number;
136
+ };
137
+ mincho: {
138
+ font: string;
139
+ offset: number;
140
+ weight: number;
141
+ };
142
+ simsun: {
143
+ font: string;
144
+ offset: number;
145
+ weight: number;
146
+ };
147
+ macGothicPro6: {
148
+ font: string;
149
+ offset: number;
150
+ weight: number;
151
+ };
152
+ macGothicPro3: {
153
+ font: string;
154
+ offset: number;
155
+ weight: number;
156
+ };
157
+ macMincho: {
158
+ font: string;
159
+ offset: number;
160
+ weight: number;
161
+ };
162
+ macGothic1: {
163
+ font: string;
164
+ offset: number;
165
+ weight: number;
166
+ };
167
+ macGothic2: {
168
+ font: string;
169
+ offset: number;
170
+ weight: number;
171
+ };
172
+ sansSerif600: {
173
+ font: string;
174
+ offset: number;
175
+ weight: number;
176
+ };
177
+ sansSerif400: {
178
+ font: string;
179
+ offset: number;
180
+ weight: number;
181
+ };
182
+ serif: {
183
+ font: string;
184
+ offset: number;
185
+ weight: number;
186
+ };
187
+ };
188
+ declare const fonts: {
189
+ win7: {
190
+ defont: FontItem;
191
+ gothic: FontItem;
192
+ mincho: FontItem;
193
+ };
194
+ win8_1: {
195
+ defont: FontItem;
196
+ gothic: FontItem;
197
+ mincho: FontItem;
198
+ };
199
+ win: {
200
+ defont: FontItem;
201
+ gothic: FontItem;
202
+ mincho: FontItem;
203
+ };
204
+ mac10_9: {
205
+ defont: FontItem;
206
+ gothic: FontItem;
207
+ mincho: FontItem;
208
+ };
209
+ mac10_11: {
210
+ defont: FontItem;
211
+ gothic: FontItem;
212
+ mincho: FontItem;
213
+ };
214
+ mac: {
215
+ defont: FontItem;
216
+ gothic: FontItem;
217
+ mincho: FontItem;
218
+ };
219
+ other: {
220
+ defont: FontItem;
221
+ gothic: FontItem;
222
+ mincho: FontItem;
223
+ };
224
+ };
225
+
258
226
 
259
227
 
260
228
 
@@ -322,6 +290,63 @@ type BaseConfig = {
322
290
 
323
291
  export type Config = Partial<BaseConfig>;
324
292
 
293
+ export interface CommentEventBase {
294
+ type: CommentEventName;
295
+ timeStamp: number;
296
+ vpos: number;
297
+ }
298
+
299
+ export interface SeekDisableEvent extends CommentEventBase {
300
+ type: "seekDisable";
301
+ }
302
+
303
+ export type SeekDisableEventHandler = (event: SeekDisableEvent) => unknown;
304
+
305
+ export interface SeekEnableEvent extends CommentEventBase {
306
+ type: "seekEnable";
307
+ }
308
+ export type SeekEnableEventHandler = (event: SeekEnableEvent) => unknown;
309
+
310
+ export interface CommentDisableEvent extends CommentEventBase {
311
+ type: "commentDisable";
312
+ }
313
+ export type CommentDisableEventHandler = (
314
+ event: CommentDisableEvent
315
+ ) => unknown;
316
+
317
+ export interface CommentEnableEvent extends CommentEventBase {
318
+ type: "commentEnable";
319
+ }
320
+ export type CommentEnableEventHandler = (event: CommentEnableEvent) => unknown;
321
+
322
+ export interface JumpEvent extends CommentEventBase {
323
+ type: "jump";
324
+ to: string;
325
+ message?: string;
326
+ }
327
+ export type JumpEventHandler = (event: JumpEvent) => unknown;
328
+
329
+ export type CommentEventName =
330
+ | "seekDisable"
331
+ | "seekEnable"
332
+ | "commentDisable"
333
+ | "commentEnable"
334
+ | "jump";
335
+ export interface CommentEventHandlerMap {
336
+ seekDisable: SeekDisableEventHandler;
337
+ seekEnable: SeekEnableEventHandler;
338
+ commentDisable: CommentDisableEventHandler;
339
+ commentEnable: CommentEnableEventHandler;
340
+ jump: JumpEventHandler;
341
+ }
342
+ export interface CommentEventMap {
343
+ seekDisable: SeekDisableEvent;
344
+ seekEnable: SeekEnableEvent;
345
+ commentDisable: CommentDisableEvent;
346
+ commentEnable: CommentEnableEvent;
347
+ jump: JumpEvent;
348
+ }
349
+
325
350
  type platform =
326
351
  | "win7"
327
352
  | "win8_1"
@@ -429,6 +454,38 @@ type v1Comment = {
429
454
 
430
455
 
431
456
 
457
+ export interface IComment {
458
+ comment: formattedCommentWithSize;
459
+ invisible: boolean;
460
+ loc: commentLoc;
461
+ width: number;
462
+ long: number;
463
+ height: number;
464
+ vpos: number;
465
+ flash: boolean;
466
+ posY: number;
467
+ owner: boolean;
468
+ layer: number;
469
+ mail: string[];
470
+ image?: HTMLCanvasElement | null;
471
+ getTextImage: (vpos: number) => void;
472
+ draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
473
+ }
474
+
475
+
476
+
477
+ export interface IPluginConstructor {
478
+ id: string;
479
+ new (Canvas: HTMLCanvasElement, comments: formattedComment[]): IPlugin;
480
+ }
481
+
482
+ export interface IPlugin {
483
+ draw(vpos: number): void;
484
+ addComments(comments: formattedComment[]): void;
485
+ }
486
+
487
+
488
+
432
489
 
433
490
 
434
491
 
@@ -470,342 +527,365 @@ type BaseOptions = {
470
527
  };
471
528
  export type Options = Partial<BaseOptions>;
472
529
 
473
-
474
-
475
- type formattedCommentWithFont = {
476
- id: number;
477
- vpos: number;
478
- date: number;
479
- date_usec: number;
480
- owner: boolean;
481
- premium: boolean;
482
- mail: string[];
483
- user_id: number;
484
- layer: number;
485
- loc: commentLoc;
486
- size: commentSize;
487
- fontSize: number;
488
- font: commentFont;
489
- color: string;
490
- strokeColor?: string;
491
- wakuColor?: string;
492
- full: boolean;
493
- ender: boolean;
494
- _live: boolean;
495
- long: number;
496
- invisible: boolean;
497
- content: commentContentItem[];
498
- flash: boolean;
499
- lineCount: number;
500
- lineOffset: number;
501
- };
502
- type formattedCommentWithSize = formattedCommentWithFont & {
503
- height: number;
504
- width: number;
505
- lineHeight: number;
506
- resized: boolean;
507
- resizedX: boolean;
508
- resizedY: boolean;
509
- content: commentMeasuredContentItem[];
510
- charSize: number;
511
- };
512
- type parsedComment = formattedCommentWithSize & {
513
- posY: number;
514
- image?: HTMLCanvasElement | boolean;
515
- };
516
- type commentContentItem = {
517
- content: string;
518
- font?: commentFlashFont;
519
- width?: number[];
520
- };
521
- type commentMeasuredContentItem = commentContentItem & {
522
- width: number[];
523
- };
524
- type commentContentIndex = {
525
- index: number;
526
- font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
527
- };
528
- type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
529
- type commentFlashFont = "defont" | "gulim" | "simsun";
530
- type commentSize = "big" | "medium" | "small";
531
- type commentLoc = "ue" | "naka" | "shita";
532
- type collision = { [key in collisionPos]: collisionItem };
533
- type collisionPos = "ue" | "shita" | "right" | "left";
534
- type collisionItem = { [p: number]: IComment[] };
535
- type nicoScript = {
536
- reverse: nicoScriptReverse[];
537
- ban: nicoScriptBan[];
538
- default: nicoScriptDefault[];
539
- replace: nicoScriptReplace[];
540
- };
541
- type nicoScriptReverse = {
542
- target: nicoScriptReverseTarget;
543
- start: number;
544
- end: number;
545
- };
546
- type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
547
- type nicoScriptReplace = {
548
- start: number;
549
- long: number | undefined;
550
- keyword: string;
551
- replace: string;
552
- range: nicoScriptReplaceRange;
553
- target: nicoScriptReplaceTarget;
554
- condition: nicoScriptReplaceCondition;
555
- color: string | undefined;
556
- size: commentSize | undefined;
557
- font: commentFont | undefined;
558
- loc: commentLoc | undefined;
559
- no: number;
560
- };
561
- type nicoScriptReplaceRange = "単" | "全";
562
- type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
563
- type nicoScriptReplaceCondition = "完全一致" | "部分一致";
564
- type nicoScriptBan = {
565
- start: number;
566
- end: number;
567
- };
568
- type nicoScriptDefault = {
569
- start: number;
570
- long: number | undefined;
571
- color: string | undefined;
572
- size: commentSize | undefined;
573
- font: commentFont | undefined;
574
- loc: commentLoc | undefined;
575
- };
576
- type measureTextResult = {
577
- width: number;
578
- height: number;
579
- resized: boolean;
580
- resizedX: boolean;
581
- resizedY: boolean;
582
- fontSize: number;
583
- lineHeight: number;
584
- content: commentMeasuredContentItem[];
585
- charSize: number;
586
- };
587
- type parsedCommand = {
588
- loc: commentLoc | undefined;
589
- size: commentSize | undefined;
590
- fontSize: number | undefined;
591
- color: string | undefined;
592
- strokeColor?: string;
593
- wakuColor?: string;
594
- font: commentFont | undefined;
595
- full: boolean;
596
- ender: boolean;
597
- _live: boolean;
598
- invisible: boolean;
599
- long: number | undefined;
600
- };
601
-
602
- type measureTextInput = {
603
- content: commentContentItem[];
604
- resized?: boolean;
605
- ender: boolean;
606
- size: commentSize;
607
- fontSize: number;
608
- resizedY?: boolean;
609
- resizedX?: boolean;
610
- font: commentFont;
611
- loc: commentLoc;
612
- full: boolean;
613
- flash: boolean;
614
- lineCount: number;
615
- lineHeight?: number;
616
- charSize?: number;
617
- };
618
-
619
- type measureInput = {
620
- font: commentFont;
621
- content: commentContentItem[];
622
- lineHeight: number;
623
- charSize: number;
624
- lineCount: number;
625
- };
626
-
627
-
628
-
629
- declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
630
-
631
-
632
-
633
-
634
- declare class NiconiComments {
635
- enableLegacyPiP: boolean;
636
- showCollision: boolean;
637
- showFPS: boolean;
638
- showCommentCount: boolean;
639
- video: HTMLVideoElement | undefined;
640
- private lastVpos;
641
- private readonly canvas;
642
- private readonly collision;
643
- private readonly context;
644
- private readonly timeline;
645
- static typeGuard: {
646
- formatted: {
647
- comment: (i: unknown) => i is formattedComment;
648
- comments: (i: unknown) => i is formattedComment[];
649
- legacyComment: (i: unknown) => i is formattedLegacyComment;
650
- legacyComments: (i: unknown) => i is formattedLegacyComment[];
651
- };
652
- legacy: {
653
- rawApiResponses: (i: unknown) => i is rawApiResponse[];
654
- apiChat: (i: unknown) => i is apiChat;
655
- apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
656
- apiLeaf: (i: unknown) => i is apiLeaf;
657
- apiPing: (i: unknown) => i is apiPing;
658
- apiThread: (i: unknown) => i is apiThread;
659
- };
660
- xmlDocument: (i: unknown) => i is XMLDocument;
661
- legacyOwner: {
662
- comments: (i: unknown) => i is string;
663
- };
664
- owner: {
665
- comment: (i: unknown) => i is ownerComment;
666
- comments: (i: unknown) => i is ownerComment[];
667
- };
668
- v1: {
669
- comment: (i: unknown) => i is v1Comment;
670
- thread: (i: unknown) => i is v1Thread;
671
- threads: (i: unknown) => i is v1Thread[];
672
- };
673
- nicoScript: {
674
- range: {
675
- target: (i: unknown) => i is nicoScriptReverseTarget;
676
- };
677
- replace: {
678
- range: (i: unknown) => i is nicoScriptReplaceRange;
679
- target: (i: unknown) => i is nicoScriptReplaceTarget;
680
- condition: (i: unknown) => i is nicoScriptReplaceCondition;
681
- };
682
- };
683
- comment: {
684
- font: (i: unknown) => i is commentFont;
685
- loc: (i: unknown) => i is commentLoc;
686
- size: (i: unknown) => i is commentSize;
687
- command: {
688
- key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
689
- };
690
- 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";
691
- colorCode: (i: unknown) => i is string;
692
- };
693
- config: {
694
- initOptions: (item: unknown) => item is Partial<BaseOptions>;
695
- };
696
- };
697
- static default: typeof NiconiComments;
698
- constructor(canvas: HTMLCanvasElement, data: inputFormat, initOptions?: Options);
699
- private preRendering;
700
- private getCommentPos;
701
- private sortComment;
702
- addComments(...rawComments: formattedComment[]): void;
703
- drawCanvas(vpos: number, forceRendering?: boolean): boolean;
704
- clear(): void;
705
- }
706
-
707
-
708
-
709
- declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
710
- declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
711
- declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
712
- height: number;
713
- width: number;
714
- lineWidth: number[];
715
- itemWidth: number[][];
716
- };
717
- declare const getFontSizeAndScale: (charSize: number) => {
718
- scale: number;
719
- fontSize: number;
720
- };
721
-
722
-
723
-
724
-
725
-
726
-
727
-
728
- declare const typeGuard: {
729
- formatted: {
730
- comment: (i: unknown) => i is formattedComment;
731
- comments: (i: unknown) => i is formattedComment[];
732
- legacyComment: (i: unknown) => i is formattedLegacyComment;
733
- legacyComments: (i: unknown) => i is formattedLegacyComment[];
734
- };
735
- legacy: {
736
- rawApiResponses: (i: unknown) => i is rawApiResponse[];
737
- apiChat: (i: unknown) => i is apiChat;
738
- apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
739
- apiLeaf: (i: unknown) => i is apiLeaf;
740
- apiPing: (i: unknown) => i is apiPing;
741
- apiThread: (i: unknown) => i is apiThread;
742
- };
743
- xmlDocument: (i: unknown) => i is XMLDocument;
744
- legacyOwner: {
745
- comments: (i: unknown) => i is string;
746
- };
747
- owner: {
748
- comment: (i: unknown) => i is ownerComment;
749
- comments: (i: unknown) => i is ownerComment[];
750
- };
751
- v1: {
752
- comment: (i: unknown) => i is v1Comment;
753
- thread: (i: unknown) => i is v1Thread;
754
- threads: (i: unknown) => i is v1Thread[];
755
- };
756
- nicoScript: {
757
- range: {
758
- target: (i: unknown) => i is nicoScriptReverseTarget;
759
- };
760
- replace: {
761
- range: (i: unknown) => i is nicoScriptReplaceRange;
762
- target: (i: unknown) => i is nicoScriptReplaceTarget;
763
- condition: (i: unknown) => i is nicoScriptReplaceCondition;
764
- };
765
- };
766
- comment: {
767
- font: (i: unknown) => i is commentFont;
768
- loc: (i: unknown) => i is commentLoc;
769
- size: (i: unknown) => i is commentSize;
770
- command: {
771
- key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
772
- };
773
- 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";
774
- colorCode: (i: unknown) => i is string;
775
- };
776
- config: {
777
- initOptions: (item: unknown) => item is Partial<BaseOptions>;
778
- };
779
- };
780
-
781
-
782
-
783
-
784
-
785
-
786
-
787
- declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
788
- currentPos: number;
789
- isChanged: boolean;
790
- isBreak: boolean;
791
- };
792
- declare const getPosX: (width: number, vpos: number, long: number) => number;
793
- declare const parseFont: (font: commentFont, size: string | number) => string;
794
- declare const arrayPush: (array: {
795
- [key: number]: IComment[];
796
- }, key: string | number, push: IComment) => void;
797
- declare const hex2rgb: (hex: string) => number[];
798
- declare const hex2rgba: (hex: string) => number[];
799
- declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
800
- declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
801
- declare const isFlashComment: (comment: formattedComment) => boolean;
802
- declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
803
- declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
804
- declare const ArrayEqual: (a: unknown[], b: unknown[]) => boolean;
805
- declare const getFlashFontIndex: (part: string) => commentContentIndex[];
806
- declare const getFlashFontName: (font: string) => commentFlashFont;
807
- declare const getValue: <T>(value: T | null | undefined, alternative: T) => T;
808
- declare const nativeSort: <T>(getter: (input: T) => number) => (a: T, b: T) => 0 | 1 | -1;
809
-
530
+
531
+
532
+ type formattedCommentWithFont = {
533
+ id: number;
534
+ vpos: number;
535
+ date: number;
536
+ date_usec: number;
537
+ owner: boolean;
538
+ premium: boolean;
539
+ mail: string[];
540
+ user_id: number;
541
+ layer: number;
542
+ loc: commentLoc;
543
+ size: commentSize;
544
+ fontSize: number;
545
+ font: commentFont;
546
+ color: string;
547
+ strokeColor?: string;
548
+ wakuColor?: string;
549
+ full: boolean;
550
+ ender: boolean;
551
+ _live: boolean;
552
+ long: number;
553
+ invisible: boolean;
554
+ content: commentContentItem[];
555
+ flash: boolean;
556
+ lineCount: number;
557
+ lineOffset: number;
558
+ };
559
+ type formattedCommentWithSize = formattedCommentWithFont & {
560
+ height: number;
561
+ width: number;
562
+ lineHeight: number;
563
+ resized: boolean;
564
+ resizedX: boolean;
565
+ resizedY: boolean;
566
+ content: commentMeasuredContentItem[];
567
+ charSize: number;
568
+ };
569
+ type parsedComment = formattedCommentWithSize & {
570
+ posY: number;
571
+ image?: HTMLCanvasElement | boolean;
572
+ };
573
+ type commentContentItem = {
574
+ content: string;
575
+ font?: commentFlashFont;
576
+ width?: number[];
577
+ };
578
+ type commentMeasuredContentItem = commentContentItem & {
579
+ width: number[];
580
+ };
581
+ type commentContentIndex = {
582
+ index: number;
583
+ font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
584
+ };
585
+ type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
586
+ type commentFlashFont = "defont" | "gulim" | "simsun";
587
+ type commentSize = "big" | "medium" | "small";
588
+ type commentLoc = "ue" | "naka" | "shita";
589
+ type collision = { [key in collisionPos]: collisionItem };
590
+ type collisionPos = "ue" | "shita" | "right" | "left";
591
+ type collisionItem = { [p: number]: IComment[] };
592
+ type nicoScript = {
593
+ reverse: nicoScriptReverse[];
594
+ ban: nicoScriptBan[];
595
+ default: nicoScriptDefault[];
596
+ replace: nicoScriptReplace[];
597
+ seekDisable: nicoScriptSeekDisable[];
598
+ jump: nicoScriptJump[];
599
+ };
600
+ type nicoScriptSeekDisable = {
601
+ start: number;
602
+ end: number;
603
+ };
604
+ type nicoScriptJump = {
605
+ start: number;
606
+ end?: number;
607
+ to: string;
608
+ message?: string;
609
+ };
610
+ type nicoScriptReverse = {
611
+ target: nicoScriptReverseTarget;
612
+ start: number;
613
+ end: number;
614
+ };
615
+ type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
616
+ type nicoScriptReplace = {
617
+ start: number;
618
+ long: number | undefined;
619
+ keyword: string;
620
+ replace: string;
621
+ range: nicoScriptReplaceRange;
622
+ target: nicoScriptReplaceTarget;
623
+ condition: nicoScriptReplaceCondition;
624
+ color: string | undefined;
625
+ size: commentSize | undefined;
626
+ font: commentFont | undefined;
627
+ loc: commentLoc | undefined;
628
+ no: number;
629
+ };
630
+ type nicoScriptReplaceRange = "単" | "全";
631
+ type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
632
+ type nicoScriptReplaceCondition = "完全一致" | "部分一致";
633
+ type nicoScriptBan = {
634
+ start: number;
635
+ end: number;
636
+ };
637
+ type nicoScriptDefault = {
638
+ start: number;
639
+ long: number | undefined;
640
+ color: string | undefined;
641
+ size: commentSize | undefined;
642
+ font: commentFont | undefined;
643
+ loc: commentLoc | undefined;
644
+ };
645
+ type measureTextResult = {
646
+ width: number;
647
+ height: number;
648
+ resized: boolean;
649
+ resizedX: boolean;
650
+ resizedY: boolean;
651
+ fontSize: number;
652
+ lineHeight: number;
653
+ content: commentMeasuredContentItem[];
654
+ charSize: number;
655
+ };
656
+ type parsedCommand = {
657
+ loc: commentLoc | undefined;
658
+ size: commentSize | undefined;
659
+ fontSize: number | undefined;
660
+ color: string | undefined;
661
+ strokeColor?: string;
662
+ wakuColor?: string;
663
+ font: commentFont | undefined;
664
+ full: boolean;
665
+ ender: boolean;
666
+ _live: boolean;
667
+ invisible: boolean;
668
+ long: number | undefined;
669
+ };
670
+
671
+ type measureTextInput = {
672
+ content: commentContentItem[];
673
+ resized?: boolean;
674
+ ender: boolean;
675
+ size: commentSize;
676
+ fontSize: number;
677
+ resizedY?: boolean;
678
+ resizedX?: boolean;
679
+ font: commentFont;
680
+ loc: commentLoc;
681
+ full: boolean;
682
+ flash: boolean;
683
+ lineCount: number;
684
+ lineHeight?: number;
685
+ charSize?: number;
686
+ };
687
+
688
+ type measureInput = {
689
+ font: commentFont;
690
+ content: commentContentItem[];
691
+ lineHeight: number;
692
+ charSize: number;
693
+ lineCount: number;
694
+ };
695
+
696
+ type valueOf<T> = T[keyof T];
697
+
698
+
699
+ declare const registerHandler: <K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]) => void;
700
+ declare const removeHandler: <K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]) => void;
701
+ declare const triggerHandler: (vpos: number, lastVpos: number) => void;
702
+
703
+
704
+
705
+
706
+ declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
707
+
708
+
709
+
710
+
711
+
712
+ declare class NiconiComments {
713
+ enableLegacyPiP: boolean;
714
+ showCollision: boolean;
715
+ showFPS: boolean;
716
+ showCommentCount: boolean;
717
+ video: HTMLVideoElement | undefined;
718
+ private lastVpos;
719
+ private readonly canvas;
720
+ private readonly collision;
721
+ private readonly context;
722
+ private readonly timeline;
723
+ static typeGuard: {
724
+ formatted: {
725
+ comment: (i: unknown) => i is formattedComment;
726
+ comments: (i: unknown) => i is formattedComment[];
727
+ legacyComment: (i: unknown) => i is formattedLegacyComment;
728
+ legacyComments: (i: unknown) => i is formattedLegacyComment[];
729
+ };
730
+ legacy: {
731
+ rawApiResponses: (i: unknown) => i is rawApiResponse[];
732
+ apiChat: (i: unknown) => i is apiChat;
733
+ apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
734
+ apiLeaf: (i: unknown) => i is apiLeaf;
735
+ apiPing: (i: unknown) => i is apiPing;
736
+ apiThread: (i: unknown) => i is apiThread;
737
+ };
738
+ xmlDocument: (i: unknown) => i is XMLDocument;
739
+ legacyOwner: {
740
+ comments: (i: unknown) => i is string;
741
+ };
742
+ owner: {
743
+ comment: (i: unknown) => i is ownerComment;
744
+ comments: (i: unknown) => i is ownerComment[];
745
+ };
746
+ v1: {
747
+ comment: (i: unknown) => i is v1Comment;
748
+ thread: (i: unknown) => i is v1Thread;
749
+ threads: (i: unknown) => i is v1Thread[];
750
+ };
751
+ nicoScript: {
752
+ range: {
753
+ target: (i: unknown) => i is nicoScriptReverseTarget;
754
+ };
755
+ replace: {
756
+ range: (i: unknown) => i is nicoScriptReplaceRange;
757
+ target: (i: unknown) => i is nicoScriptReplaceTarget;
758
+ condition: (i: unknown) => i is nicoScriptReplaceCondition;
759
+ };
760
+ };
761
+ comment: {
762
+ font: (i: unknown) => i is commentFont;
763
+ loc: (i: unknown) => i is commentLoc;
764
+ size: (i: unknown) => i is commentSize;
765
+ command: {
766
+ key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
767
+ };
768
+ 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";
769
+ colorCode: (i: unknown) => i is string;
770
+ };
771
+ config: {
772
+ initOptions: (item: unknown) => item is Partial<BaseOptions>;
773
+ };
774
+ };
775
+ static default: typeof NiconiComments;
776
+ constructor(canvas: HTMLCanvasElement, data: inputFormat, initOptions?: Options);
777
+ private preRendering;
778
+ private getCommentPos;
779
+ private sortComment;
780
+ addComments(...rawComments: formattedComment[]): void;
781
+ drawCanvas(vpos: number, forceRendering?: boolean): boolean;
782
+ addEventListener<K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]): void;
783
+ removeEventListener<K extends keyof CommentEventHandlerMap>(eventName: K, handler: CommentEventHandlerMap[K]): void;
784
+ clear(): void;
785
+ }
786
+
787
+
788
+
789
+ declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
790
+ declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
791
+ declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
792
+ height: number;
793
+ width: number;
794
+ lineWidth: number[];
795
+ itemWidth: number[][];
796
+ };
797
+ declare const getFontSizeAndScale: (charSize: number) => {
798
+ scale: number;
799
+ fontSize: number;
800
+ };
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+ declare const typeGuard: {
809
+ formatted: {
810
+ comment: (i: unknown) => i is formattedComment;
811
+ comments: (i: unknown) => i is formattedComment[];
812
+ legacyComment: (i: unknown) => i is formattedLegacyComment;
813
+ legacyComments: (i: unknown) => i is formattedLegacyComment[];
814
+ };
815
+ legacy: {
816
+ rawApiResponses: (i: unknown) => i is rawApiResponse[];
817
+ apiChat: (i: unknown) => i is apiChat;
818
+ apiGlobalNumRes: (i: unknown) => i is apiGlobalNumRes;
819
+ apiLeaf: (i: unknown) => i is apiLeaf;
820
+ apiPing: (i: unknown) => i is apiPing;
821
+ apiThread: (i: unknown) => i is apiThread;
822
+ };
823
+ xmlDocument: (i: unknown) => i is XMLDocument;
824
+ legacyOwner: {
825
+ comments: (i: unknown) => i is string;
826
+ };
827
+ owner: {
828
+ comment: (i: unknown) => i is ownerComment;
829
+ comments: (i: unknown) => i is ownerComment[];
830
+ };
831
+ v1: {
832
+ comment: (i: unknown) => i is v1Comment;
833
+ thread: (i: unknown) => i is v1Thread;
834
+ threads: (i: unknown) => i is v1Thread[];
835
+ };
836
+ nicoScript: {
837
+ range: {
838
+ target: (i: unknown) => i is nicoScriptReverseTarget;
839
+ };
840
+ replace: {
841
+ range: (i: unknown) => i is nicoScriptReplaceRange;
842
+ target: (i: unknown) => i is nicoScriptReplaceTarget;
843
+ condition: (i: unknown) => i is nicoScriptReplaceCondition;
844
+ };
845
+ };
846
+ comment: {
847
+ font: (i: unknown) => i is commentFont;
848
+ loc: (i: unknown) => i is commentLoc;
849
+ size: (i: unknown) => i is commentSize;
850
+ command: {
851
+ key: (i: unknown) => i is "full" | "ender" | "_live" | "invisible";
852
+ };
853
+ 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";
854
+ colorCode: (i: unknown) => i is string;
855
+ };
856
+ config: {
857
+ initOptions: (item: unknown) => item is Partial<BaseOptions>;
858
+ };
859
+ };
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+ declare const getPosY: (currentPos: number, targetComment: IComment, collision: IComment[] | undefined) => {
868
+ currentPos: number;
869
+ isChanged: boolean;
870
+ isBreak: boolean;
871
+ };
872
+ declare const getPosX: (width: number, vpos: number, long: number) => number;
873
+ declare const parseFont: (font: commentFont, size: string | number) => string;
874
+ declare const arrayPush: (array: {
875
+ [key: number]: IComment[];
876
+ }, key: string | number, push: IComment) => void;
877
+ declare const hex2rgb: (hex: string) => number[];
878
+ declare const hex2rgba: (hex: string) => number[];
879
+ declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
880
+ declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
881
+ declare const isFlashComment: (comment: formattedComment) => boolean;
882
+ declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
883
+ declare const getStrokeColor: (comment: formattedCommentWithSize) => string;
884
+ declare const ArrayEqual: (a: unknown[], b: unknown[]) => boolean;
885
+ declare const getFlashFontIndex: (part: string) => commentContentIndex[];
886
+ declare const getFlashFontName: (font: string) => commentFlashFont;
887
+ declare const getValue: <T>(value: T | null | undefined, alternative: T) => T;
888
+ declare const nativeSort: <T>(getter: (input: T) => number) => (a: T, b: T) => 0 | 1 | -1;
889
+
810
890
 
811
891
  export default NiconiComments;