@xpadev-net/niconicomments 0.2.52 → 0.2.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 xpadev-net
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 xpadev-net
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md CHANGED
@@ -1,53 +1,53 @@
1
- # [niconicomments](https://xpadev.net/niconicomments/)
2
-
3
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
4
- [![CodeQL](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
5
- [![TypeDoc](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
6
-
7
- [[日本語](https://github.com/xpadev-net/niconicomments/blob/develop/README.md)]
8
-
9
- Comment rendering library that is somewhat compatible with the official Nico Nico Douga player
10
- Reference: https://xpadev-net.github.io/niconicomments/
11
- Github: https://github.com/xpadev-net/niconicomments
12
- npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
13
-
14
- ## Installation
15
-
16
- ```html
17
- <script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@latest/dist/bundle.min.js"></script>
18
- ```
19
-
20
- or
21
-
22
- ```
23
- npm i @xpadev-net/niconicomments
24
- ```
25
-
26
- ## Examples
27
-
28
- ```javascript
29
- const canvas = document.getElementById("canvas");
30
- const video = document.getElementById("video");
31
- const req = await fetch("sample.json");
32
- const res = await req.json();
33
- const niconiComments = new NiconiComments(canvas, res);
34
- //If video.ontimeupdate is used, the comments will be choppy due to the small number of calls.
35
- setInterval(
36
- () => niconiComments.drawCanvas(Math.floor(video.currentTime * 100)),
37
- 10
38
- );
39
- ```
40
-
41
- ## Sample
42
-
43
- [Sample](https://xpadev-net.github.io/niconicomments/sample/)
44
-
45
- ### For users who use this library for domestic use in Japan
46
-
47
- This library may infringe on Dwango's patents depending on how it is used
48
- Please carefully review the following applicable patents and case law before using this library with caution.
49
- [JP,2006-333851](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-2006-333851/7294651F33633E1EBF3DEC66FAE0ECAD878D19E1829C378FC81D26BBD0A4263B/10/en)
50
- [JP,2010-267283](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-4734471/9085C128B7ED7D57F6C2F09D9BE4FCB496E638331DB9EC7ADE1E3A44999A3878/15/en)
51
- [JP,2018-202475](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-6526304/D8AF77CFB92D96C785FEECBD690C53E2F9023F1739E7A5BBDAB588E2ECAC5316/15/en)
52
- [2018: Case No. Heisei 28 (wa) 38565, Patent Infringement Injunction, etc. Patent Right Civil Litigation](https://www.courts.go.jp/app/files/hanrei_jp/073/088073_hanrei.pdf)
53
- [2022: Heisei 30 (ne) 10077 Appeal for Patent Infringement Injunction, etc. Patent Right Civil Litigation](https://www.courts.go.jp/app/files/hanrei_jp/418/091418_hanrei.pdf)
1
+ # [niconicomments](https://xpadev.net/niconicomments/)
2
+
3
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
4
+ [![CodeQL](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
5
+ [![TypeDoc](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
6
+
7
+ [[日本語](https://github.com/xpadev-net/niconicomments/blob/develop/README.md)]
8
+
9
+ Comment rendering library that is somewhat compatible with the official Nico Nico Douga player
10
+ Reference: https://xpadev-net.github.io/niconicomments/
11
+ Github: https://github.com/xpadev-net/niconicomments
12
+ npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
13
+
14
+ ## Installation
15
+
16
+ ```html
17
+ <script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@latest/dist/bundle.min.js"></script>
18
+ ```
19
+
20
+ or
21
+
22
+ ```
23
+ npm i @xpadev-net/niconicomments
24
+ ```
25
+
26
+ ## Examples
27
+
28
+ ```javascript
29
+ const canvas = document.getElementById("canvas");
30
+ const video = document.getElementById("video");
31
+ const req = await fetch("sample.json");
32
+ const res = await req.json();
33
+ const niconiComments = new NiconiComments(canvas, res);
34
+ //If video.ontimeupdate is used, the comments will be choppy due to the small number of calls.
35
+ setInterval(
36
+ () => niconiComments.drawCanvas(Math.floor(video.currentTime * 100)),
37
+ 10
38
+ );
39
+ ```
40
+
41
+ ## Sample
42
+
43
+ [Sample](https://xpadev-net.github.io/niconicomments/sample/)
44
+
45
+ ### For users who use this library for domestic use in Japan
46
+
47
+ This library may infringe on Dwango's patents depending on how it is used
48
+ Please carefully review the following applicable patents and case law before using this library with caution.
49
+ [JP,2006-333851](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-2006-333851/7294651F33633E1EBF3DEC66FAE0ECAD878D19E1829C378FC81D26BBD0A4263B/10/en)
50
+ [JP,2010-267283](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-4734471/9085C128B7ED7D57F6C2F09D9BE4FCB496E638331DB9EC7ADE1E3A44999A3878/15/en)
51
+ [JP,2018-202475](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-6526304/D8AF77CFB92D96C785FEECBD690C53E2F9023F1739E7A5BBDAB588E2ECAC5316/15/en)
52
+ [2018: Case No. Heisei 28 (wa) 38565, Patent Infringement Injunction, etc. Patent Right Civil Litigation](https://www.courts.go.jp/app/files/hanrei_jp/073/088073_hanrei.pdf)
53
+ [2022: Heisei 30 (ne) 10077 Appeal for Patent Infringement Injunction, etc. Patent Right Civil Litigation](https://www.courts.go.jp/app/files/hanrei_jp/418/091418_hanrei.pdf)
package/README.md CHANGED
@@ -1,51 +1,51 @@
1
- # [niconicomments](https://xpadev.net/niconicomments/)
2
-
3
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
4
- [![CodeQL](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
5
- [![TypeDoc](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
6
-
7
- [[English](https://github.com/xpadev-net/niconicomments/blob/develop/README.en.md)]
8
-
9
- ニコニコ動画の公式プレイヤー互換の高パフォーマンスなコメント描画ライブラリ
10
- High peformance High compatibility comment drawing library
11
- Reference: https://xpadev-net.github.io/niconicomments/
12
- Github: https://github.com/xpadev-net/niconicomments
13
- npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
14
-
15
-
16
- ## Installation
17
-
18
- ```html
19
- <script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@latest/dist/bundle.min.js"></script>
20
- ```
21
-
22
- or
23
-
24
- ```
25
- npm i @xpadev-net/niconicomments
26
- ```
27
-
28
- ## Examples
29
-
30
- ```javascript
31
- const canvas = document.getElementById("canvas");
32
- const video = document.getElementById("video");
33
- const req = await fetch("sample.json");
34
- const res = await req.json();
35
- const niconiComments = new NiconiComments(canvas, res);
36
- //video.ontimeupdateを使用すると、呼び出し回数の関係でコメントカクつく
37
- setInterval(
38
- () => niconiComments.drawCanvas(Math.floor(video.currentTime * 100)),
39
- 10
40
- );
41
- ```
42
-
43
- ## Sample
44
-
45
- [サンプル](https://xpadev-net.github.io/niconicomments/sample/)
46
-
47
-
48
- ### このライブラリを使用される方へ
49
-
50
- このライブラリを使用するかどうかに関わらず、リアルタイムでコメントを取得、画面を描画、コメントの投稿という一連の流れを実装した場合、ニコニコの特許を侵害する可能性があります
1
+ # [niconicomments](https://xpadev.net/niconicomments/)
2
+
3
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
4
+ [![CodeQL](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/codeql-analysis.yml)
5
+ [![TypeDoc](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml/badge.svg?branch=master)](https://github.com/xpadev-net/niconicomments/actions/workflows/typedoc.yml)
6
+
7
+ [[English](https://github.com/xpadev-net/niconicomments/blob/develop/README.en.md)]
8
+
9
+ ニコニコ動画の公式プレイヤー互換の高パフォーマンスなコメント描画ライブラリ
10
+ High peformance High compatibility comment drawing library
11
+ Reference: https://xpadev-net.github.io/niconicomments/
12
+ Github: https://github.com/xpadev-net/niconicomments
13
+ npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
14
+
15
+
16
+ ## Installation
17
+
18
+ ```html
19
+ <script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@latest/dist/bundle.min.js"></script>
20
+ ```
21
+
22
+ or
23
+
24
+ ```
25
+ npm i @xpadev-net/niconicomments
26
+ ```
27
+
28
+ ## Examples
29
+
30
+ ```javascript
31
+ const canvas = document.getElementById("canvas");
32
+ const video = document.getElementById("video");
33
+ const req = await fetch("sample.json");
34
+ const res = await req.json();
35
+ const niconiComments = new NiconiComments(canvas, res);
36
+ //video.ontimeupdateを使用すると、呼び出し回数の関係でコメントカクつく
37
+ setInterval(
38
+ () => niconiComments.drawCanvas(Math.floor(video.currentTime * 100)),
39
+ 10
40
+ );
41
+ ```
42
+
43
+ ## Sample
44
+
45
+ [サンプル](https://xpadev-net.github.io/niconicomments/sample/)
46
+
47
+
48
+ ### このライブラリを使用される方へ
49
+
50
+ このライブラリを使用するかどうかに関わらず、リアルタイムでコメントを取得、画面を描画、コメントの投稿という一連の流れを実装した場合、ニコニコの特許を侵害する可能性があります
51
51
  詳しくはこちら[ニコニコが保有する特許について](https://github.com/xpadev-net/niconicomments/blob/develop/ABOUT_PATENT.md)を参照してください
package/dist/bundle.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- type Canvas = HTMLCanvasElement;
2
+ type Canvas = HTMLCanvasElement;
3
3
  type Context2D = CanvasRenderingContext2D;
4
4
 
5
5
  declare class BaseComment implements IComment {
@@ -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;
@@ -457,6 +458,7 @@ type FormattedCommentWithFont = {
457
458
  color: string;
458
459
  strokeColor?: string;
459
460
  wakuColor?: string;
461
+ fillColor?: string;
460
462
  full: boolean;
461
463
  ender: boolean;
462
464
  _live: boolean;
@@ -491,6 +493,7 @@ type ParseCommandAndNicoScriptResult = {
491
493
  color: string;
492
494
  strokeColor?: string;
493
495
  wakuColor?: string;
496
+ fillColor?: string;
494
497
  font: CommentFont;
495
498
  full: boolean;
496
499
  ender: boolean;
@@ -595,6 +598,7 @@ type ParsedCommand = {
595
598
  color: string | undefined;
596
599
  strokeColor?: string;
597
600
  wakuColor?: string;
601
+ fillColor?: string;
598
602
  font: CommentFont | undefined;
599
603
  full: boolean;
600
604
  ender: boolean;
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.52
2
+ niconicomments.js v0.2.54
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -549,6 +549,7 @@
549
549
  invisible: commands.invisible,
550
550
  strokeColor: commands.strokeColor,
551
551
  wakuColor: commands.wakuColor,
552
+ fillColor: commands.fillColor,
552
553
  };
553
554
  };
554
555
  const parseBrackets = (input) => {
@@ -743,6 +744,11 @@
743
744
  result.wakuColor ??= rectColor;
744
745
  return;
745
746
  }
747
+ const fillColor = getColor(command.match(/^nico:fill:(.+)$/));
748
+ if (fillColor) {
749
+ result.fillColor ??= fillColor;
750
+ return;
751
+ }
746
752
  if (typeGuard.comment.loc(command)) {
747
753
  result.loc ??= command;
748
754
  return;
@@ -1381,6 +1387,7 @@
1381
1387
  const posY = this.comment.loc === "shita"
1382
1388
  ? config.canvasHeight - this.posY - this.comment.height
1383
1389
  : this.posY;
1390
+ this._drawBackgroundColor(posX, posY);
1384
1391
  this._draw(posX, posY);
1385
1392
  this._drawRectColor(posX, posY);
1386
1393
  this._drawCollision(posX, posY, showCollision);
@@ -1410,6 +1417,14 @@
1410
1417
  this.context.restore();
1411
1418
  }
1412
1419
  }
1420
+ _drawBackgroundColor(posX, posY) {
1421
+ if (this.comment.fillColor) {
1422
+ this.context.save();
1423
+ this.context.fillStyle = this.comment.fillColor;
1424
+ this.context.fillRect(posX, posY, this.comment.width, this.comment.height);
1425
+ this.context.restore();
1426
+ }
1427
+ }
1413
1428
  _drawDebugInfo(posX, posY, debug) {
1414
1429
  if (debug) {
1415
1430
  this.context.save();
@@ -2534,7 +2549,7 @@
2534
2549
  }
2535
2550
  const tmpParam = {
2536
2551
  id: i,
2537
- vpos: Number(commentData[0]),
2552
+ vpos: Number(commentData[0]) * 100,
2538
2553
  content: commentData[2] || "",
2539
2554
  date: i,
2540
2555
  date_usec: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.52",
3
+ "version": "0.2.54",
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",