@xpadev-net/niconicomments 0.2.74 → 0.2.76

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
@@ -2612,7 +2612,7 @@ interface IRenderer {
2612
2612
  stroke(): void;
2613
2613
  save(): void;
2614
2614
  restore(): void;
2615
- getCanvas(): IRenderer;
2615
+ getCanvas(padding?: number): IRenderer;
2616
2616
  drawImage(image: IRenderer, x: number, y: number, width?: number, height?: number): void;
2617
2617
  }
2618
2618
 
@@ -3204,7 +3204,10 @@ declare class CanvasRenderer implements IRenderer {
3204
3204
  readonly canvas: HTMLCanvasElement;
3205
3205
  readonly video?: HTMLVideoElement;
3206
3206
  private readonly context;
3207
- constructor(canvas?: HTMLCanvasElement, video?: HTMLVideoElement);
3207
+ private padding;
3208
+ private width;
3209
+ private height;
3210
+ constructor(canvas?: HTMLCanvasElement, video?: HTMLVideoElement, padding?: number);
3208
3211
  drawVideo(enableLegacyPip: boolean): void;
3209
3212
  getFont(): string;
3210
3213
  getFillStyle(): string | CanvasGradient | CanvasPattern;
@@ -3234,7 +3237,7 @@ declare class CanvasRenderer implements IRenderer {
3234
3237
  stroke(): void;
3235
3238
  save(): void;
3236
3239
  restore(): void;
3237
- getCanvas(): IRenderer;
3240
+ getCanvas(padding?: number): IRenderer;
3238
3241
  destroy(): void;
3239
3242
  }
3240
3243
 
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.74
2
+ niconicomments.js v0.2.76
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -2063,9 +2063,12 @@
2063
2063
  const options = RegExp(/\s*((?:sm|so|nm|\uff53\uff4d|\uff53\uff4f|\uff4e\uff4d)?[1-9\uff11-\uff19][0-9\uff11-\uff19]*|#[0-9]+:[0-9]+(?:\.[0-9]+)?)\s+(.*)/).exec(input);
2064
2064
  if (!options?.[1])
2065
2065
  return;
2066
+ const end = commands.long === undefined
2067
+ ? undefined
2068
+ : commands.long * 100 + comment.vpos;
2066
2069
  nicoScripts.jump.unshift({
2067
2070
  start: comment.vpos,
2068
- end: commands.long === undefined ? undefined : commands.long * 100,
2071
+ end,
2069
2072
  to: options[1],
2070
2073
  message: options[2],
2071
2074
  });
@@ -3755,9 +3758,9 @@
3755
3758
  const drawScale = getConfig(config.commentScale, false) *
3756
3759
  scale *
3757
3760
  (this.comment.layer === -1 ? options.scale : 1);
3758
- const image = this.renderer.getCanvas();
3759
- image.setSize(this.comment.width + 2 * 2 * this.comment.charSize, this.comment.height +
3760
- (((paddingTop + 1) * this.comment.lineHeight) / scale) * drawScale);
3761
+ const DEFAULT_COMMENT_PADDING = 4;
3762
+ const image = this.renderer.getCanvas(DEFAULT_COMMENT_PADDING);
3763
+ image.setSize(this.comment.width, this.comment.height);
3761
3764
  image.setStrokeStyle(getStrokeColor(this.comment));
3762
3765
  image.setFillStyle(this.comment.color);
3763
3766
  image.setLineWidth(getConfig(config.contextLineWidth, false));
@@ -4621,7 +4624,10 @@
4621
4624
  canvas;
4622
4625
  video;
4623
4626
  context;
4624
- constructor(canvas, video) {
4627
+ padding = 0;
4628
+ width = 0;
4629
+ height = 0;
4630
+ constructor(canvas, video, padding = 0) {
4625
4631
  this.canvas = canvas ?? document.createElement("canvas");
4626
4632
  const context = this.canvas.getContext("2d");
4627
4633
  if (!context)
@@ -4629,7 +4635,16 @@
4629
4635
  this.context = context;
4630
4636
  this.context.textAlign = "start";
4631
4637
  this.context.textBaseline = "alphabetic";
4638
+ this.context.lineJoin = "round";
4632
4639
  this.video = video;
4640
+ this.padding = padding;
4641
+ this.width = this.canvas.width;
4642
+ this.height = this.canvas.height;
4643
+ if (this.padding > 0) {
4644
+ this.canvas.width += this.padding * 2;
4645
+ this.canvas.height += this.padding * 2;
4646
+ this.context.translate(this.padding, this.padding);
4647
+ }
4633
4648
  }
4634
4649
  drawVideo(enableLegacyPip) {
4635
4650
  if (this.video) {
@@ -4699,11 +4714,16 @@
4699
4714
  this.context.globalAlpha = alpha;
4700
4715
  }
4701
4716
  setSize(width, height) {
4702
- this.canvas.width = width;
4703
- this.canvas.height = height;
4717
+ this.width = width;
4718
+ this.height = height;
4719
+ this.canvas.width = width + this.padding * 2;
4720
+ this.canvas.height = height + this.padding * 2;
4704
4721
  }
4705
4722
  getSize() {
4706
- return { width: this.canvas.width, height: this.canvas.height };
4723
+ return {
4724
+ width: this.width,
4725
+ height: this.height,
4726
+ };
4707
4727
  }
4708
4728
  measureText(text) {
4709
4729
  return this.context.measureText(text);
@@ -4729,8 +4749,8 @@
4729
4749
  restore() {
4730
4750
  this.context.restore();
4731
4751
  }
4732
- getCanvas() {
4733
- return new CanvasRenderer();
4752
+ getCanvas(padding = 0) {
4753
+ return new CanvasRenderer(undefined, undefined, padding);
4734
4754
  }
4735
4755
  destroy() {
4736
4756
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.74",
3
+ "version": "0.2.76",
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",
@@ -45,27 +45,30 @@
45
45
  "homepage": "https://xpadev-net.github.io/niconicomments/",
46
46
  "license": "MIT",
47
47
  "devDependencies": {
48
- "@babel/core": "^7.27.1",
48
+ "@babel/core": "^7.27.4",
49
49
  "@babel/preset-env": "^7.27.2",
50
50
  "@biomejs/biome": "^1.9.4",
51
- "@playwright/test": "^1.52.0",
51
+ "@playwright/test": "^1.53.1",
52
52
  "@rollup/plugin-babel": "^6.0.4",
53
- "@rollup/plugin-commonjs": "^28.0.3",
53
+ "@rollup/plugin-commonjs": "^28.0.6",
54
54
  "@rollup/plugin-json": "^6.1.0",
55
55
  "@rollup/plugin-node-resolve": "^15.3.1",
56
56
  "@rollup/plugin-typescript": "^11.1.6",
57
- "@types/node": "^22.15.21",
57
+ "@types/node": "^22.15.32",
58
58
  "copyfiles": "^2.4.1",
59
59
  "http-server": "^14.1.1",
60
- "lefthook": "^1.11.13",
60
+ "lefthook": "^1.11.14",
61
61
  "rimraf": "^6.0.1",
62
- "rollup": "^4.41.0",
62
+ "rollup": "^4.44.0",
63
63
  "rollup-plugin-dts": "^6.2.1",
64
64
  "rollup-plugin-typescript-paths": "^1.5.0",
65
65
  "tslib": "^2.8.1",
66
66
  "typedoc": "^0.26.11",
67
67
  "typedoc-plugin-missing-exports": "^3.1.0",
68
68
  "typescript": "^5.8.3",
69
- "valibot": "^1"
69
+ "valibot": "^1.1.0"
70
+ },
71
+ "engines": {
72
+ "node": ">=20.0.0"
70
73
  }
71
74
  }