@xpadev-net/niconicomments 0.2.32 → 0.2.34

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.en.md ADDED
@@ -0,0 +1,41 @@
1
+ # [niconicomments](https://xpadev.net/niconicomments/)
2
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
3
+
4
+ [[日本語](https://github.com/xpadev-net/niconicomments/blob/develop/README.md)]
5
+
6
+ Comment rendering library that is somewhat compatible with the official Nico Nico Douga player
7
+ Reference: https://xpadev-net.github.io/niconicomments/
8
+ Github: https://github.com/xpadev-net/niconicomments
9
+ npm: https://www.npmjs.com/package/@xpadev-net/niconicomments
10
+
11
+ ## For users who use this library for domestic use in Japan
12
+ This library may infringe on Dwango's patents depending on how it is used
13
+ Please carefully review the following applicable patents and case law before using this library with caution.
14
+ [JP,2006-333851](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-2006-333851/7294651F33633E1EBF3DEC66FAE0ECAD878D19E1829C378FC81D26BBD0A4263B/10/en)
15
+ [JP,2010-267283](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-4734471/9085C128B7ED7D57F6C2F09D9BE4FCB496E638331DB9EC7ADE1E3A44999A3878/15/en)
16
+ [JP,2018-202475](https://www.j-platpat.inpit.go.jp/c1800/PU/JP-6526304/D8AF77CFB92D96C785FEECBD690C53E2F9023F1739E7A5BBDAB588E2ECAC5316/15/en)
17
+ [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)
18
+ [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)
19
+
20
+ ## Installation
21
+ ```html
22
+ <script src="https://cdn.jsdelivr.net/npm/@xpadev-net/niconicomments@latest/dist/bundle.min.js"></script>
23
+ ```
24
+ or
25
+ ```
26
+ npm i @xpadev-net/niconicomments
27
+ ```
28
+
29
+ ## Examples
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
+ //If video.ontimeupdate is used, the comments will be choppy due to the small number of calls.
37
+ setInterval(() => niconiComments.drawCanvas(Math.floor(video.currentTime * 100)), 10);
38
+ ```
39
+
40
+ ## Sample
41
+ [Sample](https://xpadev-net.github.io/niconicomments/sample/)
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # [niconicomments](https://xpadev.net/niconicomments/)
2
2
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
3
- [![Total alerts](https://img.shields.io/lgtm/alerts/g/xpadev-net/niconicomments.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/xpadev-net/niconicomments/alerts/)
4
- [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/xpadev-net/niconicomments.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/xpadev-net/niconicomments/context:javascript)
3
+
4
+ [[English](https://github.com/xpadev-net/niconicomments/blob/develop/README.en.md)]
5
5
 
6
6
  ニコニコ動画の公式プレイヤー互換の高パフォーマンスなコメント描画ライブラリ
7
7
  High peformance High compatibility comment drawing library
@@ -39,4 +39,3 @@ setInterval(() => niconiComments.drawCanvas(Math.floor(video.currentTime * 100))
39
39
 
40
40
  ## Sample
41
41
  [サンプル](https://xpadev-net.github.io/niconicomments/sample/)
42
- [CodePen](https://codepen.io/xpadev-net/pen/mdBdQmX)
package/dist/bundle.d.ts CHANGED
@@ -3,6 +3,7 @@ declare class FlashComment implements IComment {
3
3
  readonly comment: formattedCommentWithSize;
4
4
  private readonly _globalScale;
5
5
  private scale;
6
+ private scaleX;
6
7
  posY: number;
7
8
  image?: HTMLCanvasElement | null;
8
9
  constructor(comment: formattedComment, context: CanvasRenderingContext2D);
@@ -43,7 +44,6 @@ declare class HTML5Comment implements IComment {
43
44
  get owner(): boolean;
44
45
  get mail(): string[];
45
46
  get lineCount(): number;
46
- parseCommand(comment: formattedComment): parsedCommand;
47
47
  parseCommandAndNicoscript(comment: formattedComment): formattedCommentWithFont;
48
48
  measureText(comment: measureTextInput): measureTextResult;
49
49
  getCommentSize(parsedData: formattedCommentWithFont): formattedCommentWithSize;
@@ -61,11 +61,6 @@ declare let imageCache: {
61
61
  declare const resetImageCache: () => void;
62
62
 
63
63
 
64
- declare let canvas: HTMLCanvasElement;
65
- declare let context: CanvasRenderingContext2D;
66
- declare const initCanvas: () => void;
67
-
68
-
69
64
  declare let nicoScripts: nicoScript;
70
65
  declare const resetNicoScripts: () => void;
71
66
 
@@ -245,8 +240,8 @@ type Config = {
245
240
  canvasWidth: number;
246
241
  collisionRange: { [key in "left" | "right"]: number };
247
242
  colors: { [key: string]: string };
248
- commentDrawPadding: configItem<number>;
249
- commentDrawRange: configItem<number>;
243
+ commentDrawPadding: number;
244
+ commentDrawRange: number;
250
245
  commentScale: configItem<number>;
251
246
  commentStageSize: configItem<commentStageSize>;
252
247
  commentYMarginBottom: configSizeItem<number>;
@@ -273,6 +268,8 @@ type Config = {
273
268
  sameCAGap: number;
274
269
  sameCAMinScore: number;
275
270
  sameCARange: number;
271
+ letterSpacing: number;
272
+ scriptCharOffset: number;
276
273
  };
277
274
 
278
275
  type ConfigNullable = Partial<Config>;
@@ -608,7 +605,7 @@ declare class NiconiComments {
608
605
 
609
606
  declare const getLineHeight: (fontSize: commentSize, isFlash: boolean, resized?: boolean) => number;
610
607
  declare const getCharSize: (fontSize: commentSize, isFlash: boolean) => number;
611
- declare const measure: (comment: measureInput) => {
608
+ declare const measure: (comment: measureInput, context: CanvasRenderingContext2D) => {
612
609
  height: number;
613
610
  width: number;
614
611
  lineWidth: number[];
@@ -646,7 +643,7 @@ declare const typeGuard: {
646
643
  comments: (i: unknown) => i is ownerComment[];
647
644
  };
648
645
  v1: {
649
- comment: (i: unknown) => i is apiThread;
646
+ comment: (i: unknown) => i is v1Comment;
650
647
  thread: (i: unknown) => i is v1Thread;
651
648
  threads: (i: unknown) => i is v1Thread[];
652
649
  };
@@ -679,7 +676,7 @@ declare const getPosY: (currentPos: number, targetComment: IComment, collision:
679
676
  isChanged: boolean;
680
677
  isBreak: boolean;
681
678
  };
682
- declare const getPosX: (width: number, vpos: number, long: number, isFlash: boolean) => number;
679
+ declare const getPosX: (width: number, vpos: number, long: number) => number;
683
680
  declare const parseFont: (font: commentFont, size: string | number) => string;
684
681
  declare const arrayPush: (array: {
685
682
  [key: number]: number[];
@@ -689,6 +686,7 @@ declare const replaceAll: (string: string, target: string, replace: string) => s
689
686
  declare const changeCALayer: (rawData: formattedComment[]) => formattedComment[];
690
687
  declare const getConfig: <T>(input: configItem<T>, isFlash?: boolean) => T;
691
688
  declare const isFlashComment: (comment: formattedComment) => boolean;
689
+ declare const parseCommandAndNicoScript: (comment: formattedComment) => formattedCommentWithFont;
692
690
 
693
691
 
694
692
  export default NiconiComments;