@xpadev-net/niconicomments 0.2.75 → 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 +6 -3
- package/dist/bundle.js +26 -10
- package/package.json +11 -8
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
|
-
|
|
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.
|
|
2
|
+
niconicomments.js v0.2.76
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -3758,9 +3758,9 @@
|
|
|
3758
3758
|
const drawScale = getConfig(config.commentScale, false) *
|
|
3759
3759
|
scale *
|
|
3760
3760
|
(this.comment.layer === -1 ? options.scale : 1);
|
|
3761
|
-
const
|
|
3762
|
-
image
|
|
3763
|
-
|
|
3761
|
+
const DEFAULT_COMMENT_PADDING = 4;
|
|
3762
|
+
const image = this.renderer.getCanvas(DEFAULT_COMMENT_PADDING);
|
|
3763
|
+
image.setSize(this.comment.width, this.comment.height);
|
|
3764
3764
|
image.setStrokeStyle(getStrokeColor(this.comment));
|
|
3765
3765
|
image.setFillStyle(this.comment.color);
|
|
3766
3766
|
image.setLineWidth(getConfig(config.contextLineWidth, false));
|
|
@@ -4624,7 +4624,10 @@
|
|
|
4624
4624
|
canvas;
|
|
4625
4625
|
video;
|
|
4626
4626
|
context;
|
|
4627
|
-
|
|
4627
|
+
padding = 0;
|
|
4628
|
+
width = 0;
|
|
4629
|
+
height = 0;
|
|
4630
|
+
constructor(canvas, video, padding = 0) {
|
|
4628
4631
|
this.canvas = canvas ?? document.createElement("canvas");
|
|
4629
4632
|
const context = this.canvas.getContext("2d");
|
|
4630
4633
|
if (!context)
|
|
@@ -4634,6 +4637,14 @@
|
|
|
4634
4637
|
this.context.textBaseline = "alphabetic";
|
|
4635
4638
|
this.context.lineJoin = "round";
|
|
4636
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
|
+
}
|
|
4637
4648
|
}
|
|
4638
4649
|
drawVideo(enableLegacyPip) {
|
|
4639
4650
|
if (this.video) {
|
|
@@ -4703,11 +4714,16 @@
|
|
|
4703
4714
|
this.context.globalAlpha = alpha;
|
|
4704
4715
|
}
|
|
4705
4716
|
setSize(width, height) {
|
|
4706
|
-
this.
|
|
4707
|
-
this.
|
|
4717
|
+
this.width = width;
|
|
4718
|
+
this.height = height;
|
|
4719
|
+
this.canvas.width = width + this.padding * 2;
|
|
4720
|
+
this.canvas.height = height + this.padding * 2;
|
|
4708
4721
|
}
|
|
4709
4722
|
getSize() {
|
|
4710
|
-
return {
|
|
4723
|
+
return {
|
|
4724
|
+
width: this.width,
|
|
4725
|
+
height: this.height,
|
|
4726
|
+
};
|
|
4711
4727
|
}
|
|
4712
4728
|
measureText(text) {
|
|
4713
4729
|
return this.context.measureText(text);
|
|
@@ -4733,8 +4749,8 @@
|
|
|
4733
4749
|
restore() {
|
|
4734
4750
|
this.context.restore();
|
|
4735
4751
|
}
|
|
4736
|
-
getCanvas() {
|
|
4737
|
-
return new CanvasRenderer();
|
|
4752
|
+
getCanvas(padding = 0) {
|
|
4753
|
+
return new CanvasRenderer(undefined, undefined, padding);
|
|
4738
4754
|
}
|
|
4739
4755
|
destroy() {
|
|
4740
4756
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
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.
|
|
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.
|
|
51
|
+
"@playwright/test": "^1.53.1",
|
|
52
52
|
"@rollup/plugin-babel": "^6.0.4",
|
|
53
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
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.
|
|
57
|
+
"@types/node": "^22.15.32",
|
|
58
58
|
"copyfiles": "^2.4.1",
|
|
59
59
|
"http-server": "^14.1.1",
|
|
60
|
-
"lefthook": "^1.11.
|
|
60
|
+
"lefthook": "^1.11.14",
|
|
61
61
|
"rimraf": "^6.0.1",
|
|
62
|
-
"rollup": "^4.
|
|
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
|
}
|