@xpadev-net/niconicomments 0.2.53 → 0.2.55
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 +192 -188
- package/dist/bundle.js +21 -5
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class BaseComment implements IComment {
|
|
|
30
30
|
draw(vpos: number, showCollision: boolean, debug: boolean): void;
|
|
31
31
|
protected _draw(posX: number, posY: number): void;
|
|
32
32
|
protected _drawRectColor(posX: number, posY: number): void;
|
|
33
|
+
protected _drawBackgroundColor(posX: number, posY: number): void;
|
|
33
34
|
protected _drawDebugInfo(posX: number, posY: number, debug: boolean): void;
|
|
34
35
|
protected _drawCollision(posX: number, posY: number, showCollision: boolean): void;
|
|
35
36
|
protected getTextImage(): Canvas | null;
|
|
@@ -440,194 +441,197 @@ type inputFormatType = InputFormatType;
|
|
|
440
441
|
*/
|
|
441
442
|
type inputFormat = InputFormat;
|
|
442
443
|
|
|
443
|
-
type FormattedCommentWithFont = {
|
|
444
|
-
id: number;
|
|
445
|
-
vpos: number;
|
|
446
|
-
date: number;
|
|
447
|
-
date_usec: number;
|
|
448
|
-
owner: boolean;
|
|
449
|
-
premium: boolean;
|
|
450
|
-
mail: string[];
|
|
451
|
-
user_id: number;
|
|
452
|
-
layer: number;
|
|
453
|
-
loc: CommentLoc;
|
|
454
|
-
size: CommentSize;
|
|
455
|
-
fontSize: number;
|
|
456
|
-
font: CommentFont;
|
|
457
|
-
color: string;
|
|
458
|
-
strokeColor?: string;
|
|
459
|
-
wakuColor?: string;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
type
|
|
517
|
-
type
|
|
518
|
-
type
|
|
519
|
-
type
|
|
520
|
-
type
|
|
521
|
-
type
|
|
522
|
-
type
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
| "
|
|
565
|
-
| "
|
|
566
|
-
| "
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
444
|
+
type FormattedCommentWithFont = {
|
|
445
|
+
id: number;
|
|
446
|
+
vpos: number;
|
|
447
|
+
date: number;
|
|
448
|
+
date_usec: number;
|
|
449
|
+
owner: boolean;
|
|
450
|
+
premium: boolean;
|
|
451
|
+
mail: string[];
|
|
452
|
+
user_id: number;
|
|
453
|
+
layer: number;
|
|
454
|
+
loc: CommentLoc;
|
|
455
|
+
size: CommentSize;
|
|
456
|
+
fontSize: number;
|
|
457
|
+
font: CommentFont;
|
|
458
|
+
color: string;
|
|
459
|
+
strokeColor?: string;
|
|
460
|
+
wakuColor?: string;
|
|
461
|
+
fillColor?: string;
|
|
462
|
+
full: boolean;
|
|
463
|
+
ender: boolean;
|
|
464
|
+
_live: boolean;
|
|
465
|
+
long: number;
|
|
466
|
+
invisible: boolean;
|
|
467
|
+
content: CommentContentItem[];
|
|
468
|
+
rawContent: string;
|
|
469
|
+
flash: boolean;
|
|
470
|
+
lineCount: number;
|
|
471
|
+
lineOffset: number;
|
|
472
|
+
};
|
|
473
|
+
type FormattedCommentWithSize = FormattedCommentWithFont & {
|
|
474
|
+
height: number;
|
|
475
|
+
width: number;
|
|
476
|
+
lineHeight: number;
|
|
477
|
+
resized: boolean;
|
|
478
|
+
resizedX: boolean;
|
|
479
|
+
resizedY: boolean;
|
|
480
|
+
content: CommentMeasuredContentItem[];
|
|
481
|
+
charSize: number;
|
|
482
|
+
};
|
|
483
|
+
type ParseContentResult = {
|
|
484
|
+
content: CommentContentItem[];
|
|
485
|
+
lineCount: number;
|
|
486
|
+
lineOffset: number;
|
|
487
|
+
};
|
|
488
|
+
type ParseCommandAndNicoScriptResult = {
|
|
489
|
+
flash: boolean;
|
|
490
|
+
loc: CommentLoc;
|
|
491
|
+
size: CommentSize;
|
|
492
|
+
fontSize: number;
|
|
493
|
+
color: string;
|
|
494
|
+
strokeColor?: string;
|
|
495
|
+
wakuColor?: string;
|
|
496
|
+
fillColor?: string;
|
|
497
|
+
font: CommentFont;
|
|
498
|
+
full: boolean;
|
|
499
|
+
ender: boolean;
|
|
500
|
+
_live: boolean;
|
|
501
|
+
invisible: boolean;
|
|
502
|
+
long: number;
|
|
503
|
+
};
|
|
504
|
+
type CommentContentItem = {
|
|
505
|
+
content: string;
|
|
506
|
+
slicedContent: string[];
|
|
507
|
+
font?: CommentFlashFont;
|
|
508
|
+
width?: number[];
|
|
509
|
+
};
|
|
510
|
+
type CommentMeasuredContentItem = CommentContentItem & {
|
|
511
|
+
width: number[];
|
|
512
|
+
};
|
|
513
|
+
type CommentContentIndex = {
|
|
514
|
+
index: number;
|
|
515
|
+
font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
|
|
516
|
+
};
|
|
517
|
+
type CommentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
|
|
518
|
+
type CommentFlashFont = "defont" | "gulim" | "simsun";
|
|
519
|
+
type CommentSize = "big" | "medium" | "small";
|
|
520
|
+
type CommentLoc = "ue" | "naka" | "shita";
|
|
521
|
+
type Collision = { [key in CollisionPos]: CollisionItem };
|
|
522
|
+
type Timeline = { [key: number]: IComment[] };
|
|
523
|
+
type CollisionPos = "ue" | "shita" | "right" | "left";
|
|
524
|
+
type CollisionItem = { [p: number]: IComment[] };
|
|
525
|
+
type NicoScript = {
|
|
526
|
+
reverse: NicoScriptReverse[];
|
|
527
|
+
ban: NicoScriptBan[];
|
|
528
|
+
default: NicoScriptDefault[];
|
|
529
|
+
replace: NicoScriptReplace[];
|
|
530
|
+
seekDisable: NicoScriptSeekDisable[];
|
|
531
|
+
jump: NicoScriptJump[];
|
|
532
|
+
};
|
|
533
|
+
type NicoScriptSeekDisable = {
|
|
534
|
+
start: number;
|
|
535
|
+
end: number;
|
|
536
|
+
};
|
|
537
|
+
type NicoScriptJump = {
|
|
538
|
+
start: number;
|
|
539
|
+
end?: number;
|
|
540
|
+
to: string;
|
|
541
|
+
message?: string;
|
|
542
|
+
};
|
|
543
|
+
type NicoScriptReverse = {
|
|
544
|
+
target: NicoScriptReverseTarget;
|
|
545
|
+
start: number;
|
|
546
|
+
end: number;
|
|
547
|
+
};
|
|
548
|
+
type NicoScriptReverseTarget = "コメ" | "投コメ" | "全";
|
|
549
|
+
type NicoScriptReplace = {
|
|
550
|
+
start: number;
|
|
551
|
+
long: number | undefined;
|
|
552
|
+
keyword: string;
|
|
553
|
+
replace: string;
|
|
554
|
+
range: NicoScriptReplaceRange;
|
|
555
|
+
target: NicoScriptReplaceTarget;
|
|
556
|
+
condition: NicoScriptReplaceCondition;
|
|
557
|
+
color: string | undefined;
|
|
558
|
+
size: CommentSize | undefined;
|
|
559
|
+
font: CommentFont | undefined;
|
|
560
|
+
loc: CommentLoc | undefined;
|
|
561
|
+
no: number;
|
|
562
|
+
};
|
|
563
|
+
type NicoScriptReplaceRange = "単" | "全";
|
|
564
|
+
type NicoScriptReplaceTarget =
|
|
565
|
+
| "コメ"
|
|
566
|
+
| "投コメ"
|
|
567
|
+
| "全"
|
|
568
|
+
| "含まない"
|
|
569
|
+
| "含む";
|
|
570
|
+
type NicoScriptReplaceCondition = "完全一致" | "部分一致";
|
|
571
|
+
type NicoScriptBan = {
|
|
572
|
+
start: number;
|
|
573
|
+
end: number;
|
|
574
|
+
};
|
|
575
|
+
type NicoScriptDefault = {
|
|
576
|
+
start: number;
|
|
577
|
+
long: number | undefined;
|
|
578
|
+
color: string | undefined;
|
|
579
|
+
size: CommentSize | undefined;
|
|
580
|
+
font: CommentFont | undefined;
|
|
581
|
+
loc: CommentLoc | undefined;
|
|
582
|
+
};
|
|
583
|
+
type MeasureTextResult = {
|
|
584
|
+
width: number;
|
|
585
|
+
height: number;
|
|
586
|
+
resized: boolean;
|
|
587
|
+
resizedX: boolean;
|
|
588
|
+
resizedY: boolean;
|
|
589
|
+
fontSize: number;
|
|
590
|
+
lineHeight: number;
|
|
591
|
+
content: CommentMeasuredContentItem[];
|
|
592
|
+
charSize: number;
|
|
593
|
+
};
|
|
594
|
+
type ParsedCommand = {
|
|
595
|
+
loc: CommentLoc | undefined;
|
|
596
|
+
size: CommentSize | undefined;
|
|
597
|
+
fontSize: number | undefined;
|
|
598
|
+
color: string | undefined;
|
|
599
|
+
strokeColor?: string;
|
|
600
|
+
wakuColor?: string;
|
|
601
|
+
fillColor?: string;
|
|
602
|
+
font: CommentFont | undefined;
|
|
603
|
+
full: boolean;
|
|
604
|
+
ender: boolean;
|
|
605
|
+
_live: boolean;
|
|
606
|
+
invisible: boolean;
|
|
607
|
+
long: number | undefined;
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
type MeasureTextInput = {
|
|
611
|
+
content: CommentContentItem[];
|
|
612
|
+
resized?: boolean;
|
|
613
|
+
ender: boolean;
|
|
614
|
+
size: CommentSize;
|
|
615
|
+
fontSize: number;
|
|
616
|
+
resizedY?: boolean;
|
|
617
|
+
resizedX?: boolean;
|
|
618
|
+
font: CommentFont;
|
|
619
|
+
loc: CommentLoc;
|
|
620
|
+
full: boolean;
|
|
621
|
+
flash: boolean;
|
|
622
|
+
lineCount: number;
|
|
623
|
+
lineHeight?: number;
|
|
624
|
+
charSize?: number;
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
type MeasureInput = {
|
|
628
|
+
font: CommentFont;
|
|
629
|
+
content: CommentContentItem[];
|
|
630
|
+
lineHeight: number;
|
|
631
|
+
charSize: number;
|
|
632
|
+
lineCount: number;
|
|
633
|
+
};
|
|
634
|
+
|
|
631
635
|
type ValueOf<T> = T[keyof T];
|
|
632
636
|
|
|
633
637
|
declare let imageCache: {
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.55
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -187,12 +187,13 @@
|
|
|
187
187
|
};
|
|
188
188
|
const getStrokeColor = (comment) => {
|
|
189
189
|
if (comment.strokeColor) {
|
|
190
|
-
const
|
|
190
|
+
const color = comment.strokeColor.slice(1);
|
|
191
|
+
const length = color.length;
|
|
191
192
|
if (length === 3 || length === 6) {
|
|
192
|
-
return `rgba(${hex2rgb(
|
|
193
|
+
return `rgba(${hex2rgb(color).join(",")},${config.contextStrokeOpacity})`;
|
|
193
194
|
}
|
|
194
195
|
else if (length === 4 || length === 8) {
|
|
195
|
-
return `rgba(${hex2rgba(
|
|
196
|
+
return `rgba(${hex2rgba(color).join(",")})`;
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
return `rgba(${hex2rgb(comment.color === "#000000"
|
|
@@ -549,6 +550,7 @@
|
|
|
549
550
|
invisible: commands.invisible,
|
|
550
551
|
strokeColor: commands.strokeColor,
|
|
551
552
|
wakuColor: commands.wakuColor,
|
|
553
|
+
fillColor: commands.fillColor,
|
|
552
554
|
};
|
|
553
555
|
};
|
|
554
556
|
const parseBrackets = (input) => {
|
|
@@ -743,6 +745,11 @@
|
|
|
743
745
|
result.wakuColor ??= rectColor;
|
|
744
746
|
return;
|
|
745
747
|
}
|
|
748
|
+
const fillColor = getColor(command.match(/^nico:fill:(.+)$/));
|
|
749
|
+
if (fillColor) {
|
|
750
|
+
result.fillColor ??= fillColor;
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
746
753
|
if (typeGuard.comment.loc(command)) {
|
|
747
754
|
result.loc ??= command;
|
|
748
755
|
return;
|
|
@@ -777,7 +784,7 @@
|
|
|
777
784
|
return colors[value];
|
|
778
785
|
}
|
|
779
786
|
else if (typeGuard.comment.colorCodeAllowAlpha(value)) {
|
|
780
|
-
return value
|
|
787
|
+
return value;
|
|
781
788
|
}
|
|
782
789
|
return;
|
|
783
790
|
};
|
|
@@ -1381,6 +1388,7 @@
|
|
|
1381
1388
|
const posY = this.comment.loc === "shita"
|
|
1382
1389
|
? config.canvasHeight - this.posY - this.comment.height
|
|
1383
1390
|
: this.posY;
|
|
1391
|
+
this._drawBackgroundColor(posX, posY);
|
|
1384
1392
|
this._draw(posX, posY);
|
|
1385
1393
|
this._drawRectColor(posX, posY);
|
|
1386
1394
|
this._drawCollision(posX, posY, showCollision);
|
|
@@ -1410,6 +1418,14 @@
|
|
|
1410
1418
|
this.context.restore();
|
|
1411
1419
|
}
|
|
1412
1420
|
}
|
|
1421
|
+
_drawBackgroundColor(posX, posY) {
|
|
1422
|
+
if (this.comment.fillColor) {
|
|
1423
|
+
this.context.save();
|
|
1424
|
+
this.context.fillStyle = this.comment.fillColor;
|
|
1425
|
+
this.context.fillRect(posX, posY, this.comment.width, this.comment.height);
|
|
1426
|
+
this.context.restore();
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1413
1429
|
_drawDebugInfo(posX, posY, debug) {
|
|
1414
1430
|
if (debug) {
|
|
1415
1431
|
this.context.save();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.55",
|
|
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",
|