@xpadev-net/niconicomments 0.2.11 → 0.2.14
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/README.md +9 -1
- package/dist/bundle.js +23 -32
- package/dist/dts/main.d.ts +2 -0
- package/dist/dts/main.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
High peformance High compatibility comment drawing library
|
|
8
8
|
Reference: https://xpadev-net.github.io/niconicomments/
|
|
9
9
|
Github: https://github.com/xpadev-net/niconicomments
|
|
10
|
-
npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
|
|
10
|
+
npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
|
|
11
|
+
|
|
12
|
+
## [重要]このライブラリを使用される方へ
|
|
13
|
+
ニコニコ運営が画面にコメントを流すアドオンを特許侵害だと騒ぎ立てて潰して回っているようです
|
|
14
|
+
このライブラリ本体は描画部分のみのため特許侵害に当たるとは考えていませんが、ニコニコ動画運営(とその近辺の人)に叩かれる可能性があります
|
|
15
|
+
(名前は出しませんがすでにいくつかのOSSに被害が出ています)
|
|
16
|
+
また、このライブラリを使用するかどうかに関わらず、リアルタイムでコメントを取得、画面を描画、コメントの投稿という一連の流れを実装した場合、ニコニコの特許を侵害する可能性があります
|
|
17
|
+
詳しくはこちら[ニコニコが保有する特許について](https://github.com/xpadev-net/niconicomments/blob/master/ABOUT_PATENT.md)を参照してください
|
|
18
|
+
**※当ライブラリを削除する予定は一切ありません**
|
|
11
19
|
|
|
12
20
|
## Installation
|
|
13
21
|
```html
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.14
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
showFPS: false,
|
|
37
37
|
showCommentCount: false,
|
|
38
38
|
drawAllImageOnLoad: false,
|
|
39
|
-
debug: false
|
|
39
|
+
debug: false,
|
|
40
|
+
enableLegacyPiP: false
|
|
40
41
|
}; }
|
|
41
42
|
var _this = this;
|
|
42
43
|
isDebug = options.debug;
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"resized": 38.7
|
|
63
64
|
},
|
|
64
65
|
"big": {
|
|
65
|
-
"default":
|
|
66
|
+
"default": 110,
|
|
66
67
|
"resized": 61
|
|
67
68
|
}
|
|
68
69
|
};
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
"resized": 1
|
|
77
78
|
},
|
|
78
79
|
"big": {
|
|
79
|
-
"default": 1,
|
|
80
|
+
"default": 1.03,
|
|
80
81
|
"resized": 1.01
|
|
81
82
|
}
|
|
82
83
|
};
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
this.showCollision = options.showCollision;
|
|
96
97
|
this.showFPS = options.showFPS;
|
|
97
98
|
this.showCommentCount = options.showCommentCount;
|
|
99
|
+
this.enableLegacyPiP = options.enableLegacyPiP;
|
|
98
100
|
this.timeline = {};
|
|
99
101
|
this.nicoScripts = { reverse: [], default: [], replace: [], ban: [] };
|
|
100
102
|
this.collision_right = {};
|
|
@@ -278,7 +280,7 @@
|
|
|
278
280
|
break;
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
|
-
if (left_pos <= 40
|
|
283
|
+
if (left_pos <= 40) {
|
|
282
284
|
for (var k in this.collision_left[vpos]) {
|
|
283
285
|
var l = this.collision_left[vpos][k];
|
|
284
286
|
if ((posY < data[l].posY + data[l].height && posY + comment.height > data[l].posY) && data[l].owner === comment.owner) {
|
|
@@ -302,9 +304,6 @@
|
|
|
302
304
|
break;
|
|
303
305
|
}
|
|
304
306
|
}
|
|
305
|
-
if (is_break) {
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
307
|
}
|
|
309
308
|
if (is_break) {
|
|
310
309
|
break;
|
|
@@ -433,7 +432,7 @@
|
|
|
433
432
|
width_min = Math.min.apply(Math, width_arr);
|
|
434
433
|
height = (comment.fontSize * comment.lineHeight * (1 + this.commentYPaddingTop) * lines.length) + (this.commentYMarginBottom * comment.fontSize);
|
|
435
434
|
if (comment.loc !== "naka" && !comment.tateresized) {
|
|
436
|
-
if (comment.full && width_max >
|
|
435
|
+
if (comment.full && width_max > 1930) {
|
|
437
436
|
comment.fontSize -= 2;
|
|
438
437
|
comment.resized = true;
|
|
439
438
|
comment.yokoResized = true;
|
|
@@ -509,11 +508,21 @@
|
|
|
509
508
|
if (comment.image && comment.image !== true) {
|
|
510
509
|
this.context.drawImage(comment.image, posX, posY);
|
|
511
510
|
}
|
|
511
|
+
if (this.showCollision) {
|
|
512
|
+
this.context.strokeStyle = "rgba(0,255,255,1)";
|
|
513
|
+
this.context.strokeRect(posX, posY, comment.width_max, comment.height);
|
|
514
|
+
var lines = comment.content.split("\n");
|
|
515
|
+
for (var i in lines) {
|
|
516
|
+
var linePosY = (Number(i) + 1) * (comment.fontSize * comment.lineHeight) * (1 + this.commentYPaddingTop);
|
|
517
|
+
this.context.strokeStyle = "rgba(255,255,0,0.5)";
|
|
518
|
+
this.context.strokeRect(posX, posY + linePosY, comment.width_max, comment.fontSize * comment.lineHeight * -1);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
512
521
|
};
|
|
513
522
|
NiconiComments.prototype.getTextImage = function (i) {
|
|
514
523
|
var _this = this;
|
|
515
524
|
var value = this.data[i];
|
|
516
|
-
if (!value || value.invisible
|
|
525
|
+
if (!value || value.invisible)
|
|
517
526
|
return;
|
|
518
527
|
var image = document.createElement("canvas");
|
|
519
528
|
image.width = value.width_max;
|
|
@@ -536,32 +545,12 @@
|
|
|
536
545
|
if (value.color === "#000000") {
|
|
537
546
|
context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
538
547
|
}
|
|
539
|
-
if (this.showCollision) {
|
|
540
|
-
context.strokeStyle = "rgba(0,255,255,1)";
|
|
541
|
-
context.strokeRect(0, 0, value.width_max, value.height);
|
|
542
|
-
if (value.color === "#000000") {
|
|
543
|
-
context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
548
|
var lines = value.content.split("\n");
|
|
550
549
|
for (var i_1 in lines) {
|
|
551
550
|
var line = lines[i_1], posY = void 0;
|
|
552
551
|
posY = (Number(i_1) + 1) * (value.fontSize * value.lineHeight) * (1 + this.commentYPaddingTop);
|
|
553
552
|
context.strokeText(line, 0, posY);
|
|
554
553
|
context.fillText(line, 0, posY);
|
|
555
|
-
if (this.showCollision) {
|
|
556
|
-
context.strokeStyle = "rgba(255,255,0,0.5)";
|
|
557
|
-
context.strokeRect(0, posY, value.width_max, value.fontSize * value.lineHeight * -1);
|
|
558
|
-
if (value.color === "#000000") {
|
|
559
|
-
context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
554
|
}
|
|
566
555
|
this.data[i].image = image;
|
|
567
556
|
setTimeout(function () {
|
|
@@ -868,7 +857,7 @@
|
|
|
868
857
|
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
869
858
|
if (this.video) {
|
|
870
859
|
var offsetX = void 0, offsetY = void 0, scale = void 0, height = this.canvas.height / this.video.videoHeight, width = this.canvas.width / this.video.videoWidth;
|
|
871
|
-
if (height > width) {
|
|
860
|
+
if (this.enableLegacyPiP ? height > width : height < width) {
|
|
872
861
|
scale = width;
|
|
873
862
|
}
|
|
874
863
|
else {
|
|
@@ -882,7 +871,7 @@
|
|
|
882
871
|
for (var i in this.timeline[vpos]) {
|
|
883
872
|
var index = this.timeline[vpos][Number(i)];
|
|
884
873
|
var comment = this.data[index];
|
|
885
|
-
if (!comment || comment.invisible
|
|
874
|
+
if (!comment || comment.invisible) {
|
|
886
875
|
continue;
|
|
887
876
|
}
|
|
888
877
|
if (comment.image === undefined) {
|
|
@@ -899,12 +888,14 @@
|
|
|
899
888
|
if (this.showFPS) {
|
|
900
889
|
this.context.font = parseFont("defont", 60, this.useLegacy);
|
|
901
890
|
this.context.fillStyle = "#00FF00";
|
|
891
|
+
this.context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
902
892
|
this.context.strokeText("FPS:" + this.fps, 100, 100);
|
|
903
893
|
this.context.fillText("FPS:" + this.fps, 100, 100);
|
|
904
894
|
}
|
|
905
895
|
if (this.showCommentCount) {
|
|
906
896
|
this.context.font = parseFont("defont", 60, this.useLegacy);
|
|
907
897
|
this.context.fillStyle = "#00FF00";
|
|
898
|
+
this.context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
908
899
|
if (this.timeline[vpos]) {
|
|
909
900
|
this.context.strokeText("Count:" + this.timeline[vpos].length, 100, 200);
|
|
910
901
|
this.context.fillText("Count:" + this.timeline[vpos].length, 100, 200);
|
package/dist/dts/main.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare type InitOptions = {
|
|
|
7
7
|
showCommentCount: boolean;
|
|
8
8
|
drawAllImageOnLoad: boolean;
|
|
9
9
|
debug: boolean;
|
|
10
|
+
enableLegacyPiP: boolean;
|
|
10
11
|
};
|
|
11
12
|
declare type rawApiResponse = {
|
|
12
13
|
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
@@ -97,6 +98,7 @@ declare class NiconiComments {
|
|
|
97
98
|
private showCollision;
|
|
98
99
|
showFPS: boolean;
|
|
99
100
|
showCommentCount: boolean;
|
|
101
|
+
enableLegacyPiP: boolean;
|
|
100
102
|
private data;
|
|
101
103
|
private timeline;
|
|
102
104
|
private nicoScripts;
|
package/dist/dts/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,aAAK,WAAW,GAAG;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,aAAK,WAAW,GAAG;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,eAAe,EAAE,OAAO,CAAA;CAC3B,CAAA;AACD,aAAK,cAAc,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,eAAe,GAAG,OAAO,CAAA;CAC3E,CAAA;AACD,aAAK,OAAO,GAAG;IACX,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AACD,aAAK,SAAS,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AACD,aAAK,OAAO,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAA;CAClB,CAAA;AACD,aAAK,eAAe,GAA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2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
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/dts/main.d.ts",
|