@xpadev-net/niconicomments 0.2.10 → 0.2.13
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 +13 -2
- package/dist/bundle.js +92 -49
- package/dist/dts/main.d.ts +6 -1
- package/dist/dts/main.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
# [niconicomments](https://xpadev.net/niconicomments/)
|
|
2
|
-
[](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
|
|
2
|
+
[](https://github.com/xpadev-net/niconicomments/blob/master/LICENSE)
|
|
3
|
+
[](https://lgtm.com/projects/g/xpadev-net/niconicomments/alerts/)
|
|
4
|
+
[](https://lgtm.com/projects/g/xpadev-net/niconicomments/context:javascript)
|
|
5
|
+
|
|
3
6
|
ニコニコ動画の公式プレイヤー互換の高パフォーマンスなコメント描画ライブラリ
|
|
4
7
|
High peformance High compatibility comment drawing library
|
|
5
8
|
Reference: https://xpadev-net.github.io/niconicomments/
|
|
6
9
|
Github: https://github.com/xpadev-net/niconicomments
|
|
7
|
-
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
|
+
**※当ライブラリを削除する予定は一切ありません**
|
|
8
19
|
|
|
9
20
|
## Installation
|
|
10
21
|
```html
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.13
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
return _assign.apply(this, arguments);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
var isDebug = false;
|
|
28
29
|
var NiconiComments = (function () {
|
|
29
30
|
function NiconiComments(canvas, data, options) {
|
|
30
31
|
if (options === void 0) { options = {
|
|
@@ -34,9 +35,12 @@
|
|
|
34
35
|
showCollision: false,
|
|
35
36
|
showFPS: false,
|
|
36
37
|
showCommentCount: false,
|
|
37
|
-
drawAllImageOnLoad: false
|
|
38
|
+
drawAllImageOnLoad: false,
|
|
39
|
+
debug: false
|
|
38
40
|
}; }
|
|
39
41
|
var _this = this;
|
|
42
|
+
isDebug = options.debug;
|
|
43
|
+
var constructorStart = performance.now();
|
|
40
44
|
this.canvas = canvas;
|
|
41
45
|
var context = canvas.getContext("2d");
|
|
42
46
|
if (!context)
|
|
@@ -58,10 +62,24 @@
|
|
|
58
62
|
"resized": 38.7
|
|
59
63
|
},
|
|
60
64
|
"big": {
|
|
61
|
-
"default":
|
|
65
|
+
"default": 110,
|
|
62
66
|
"resized": 61
|
|
63
67
|
}
|
|
64
68
|
};
|
|
69
|
+
this.lineHeight = {
|
|
70
|
+
"small": {
|
|
71
|
+
"default": 1,
|
|
72
|
+
"resized": 1
|
|
73
|
+
},
|
|
74
|
+
"medium": {
|
|
75
|
+
"default": 1,
|
|
76
|
+
"resized": 1
|
|
77
|
+
},
|
|
78
|
+
"big": {
|
|
79
|
+
"default": 1.03,
|
|
80
|
+
"resized": 1.01
|
|
81
|
+
}
|
|
82
|
+
};
|
|
65
83
|
this.doubleResizeMaxWidth = {
|
|
66
84
|
full: {
|
|
67
85
|
legacy: 3020,
|
|
@@ -93,8 +111,10 @@
|
|
|
93
111
|
_this.fps = _this.fpsCount * 2;
|
|
94
112
|
_this.fpsCount = 0;
|
|
95
113
|
}, 500);
|
|
114
|
+
logger("constructor complete: ".concat(performance.now() - constructorStart, "ms"));
|
|
96
115
|
}
|
|
97
116
|
NiconiComments.prototype.parseData = function (data) {
|
|
117
|
+
var parseDataStart = performance.now();
|
|
98
118
|
var data_ = [];
|
|
99
119
|
for (var i = 0; i < data.length; i++) {
|
|
100
120
|
for (var key in data[i]) {
|
|
@@ -138,9 +158,11 @@
|
|
|
138
158
|
return 1;
|
|
139
159
|
return 0;
|
|
140
160
|
});
|
|
161
|
+
logger("parseData complete: ".concat(performance.now() - parseDataStart, "ms"));
|
|
141
162
|
return data_;
|
|
142
163
|
};
|
|
143
164
|
NiconiComments.prototype.preRendering = function (rawData, drawAll) {
|
|
165
|
+
var preRenderingStart = performance.now();
|
|
144
166
|
var parsedData = this.getCommentPos(this.getCommentSize(this.getFont(rawData)));
|
|
145
167
|
this.data = this.sortComment(parsedData);
|
|
146
168
|
if (drawAll) {
|
|
@@ -148,8 +170,10 @@
|
|
|
148
170
|
this.getTextImage(Number(i));
|
|
149
171
|
}
|
|
150
172
|
}
|
|
173
|
+
logger("preRendering complete: ".concat(performance.now() - preRenderingStart, "ms"));
|
|
151
174
|
};
|
|
152
175
|
NiconiComments.prototype.getFont = function (parsedData) {
|
|
176
|
+
var getFontStart = performance.now();
|
|
153
177
|
var result = [];
|
|
154
178
|
for (var i in parsedData) {
|
|
155
179
|
var value = parsedData[i];
|
|
@@ -158,9 +182,11 @@
|
|
|
158
182
|
value.content = value.content.replace(/\t/g, "\u2003\u2003");
|
|
159
183
|
result[i] = this.parseCommandAndNicoscript(value);
|
|
160
184
|
}
|
|
185
|
+
logger("getFont complete: ".concat(performance.now() - getFontStart, "ms"));
|
|
161
186
|
return result;
|
|
162
187
|
};
|
|
163
188
|
NiconiComments.prototype.getCommentSize = function (parsedData) {
|
|
189
|
+
var getCommentSizeStart = performance.now();
|
|
164
190
|
var tmpData = groupBy(parsedData, "font", "fontSize");
|
|
165
191
|
var result = [];
|
|
166
192
|
for (var i in tmpData) {
|
|
@@ -177,6 +203,7 @@
|
|
|
177
203
|
size.width = measure.width;
|
|
178
204
|
size.width_max = measure.width_max;
|
|
179
205
|
size.width_min = measure.width_min;
|
|
206
|
+
size.lineHeight = measure.lineHeight;
|
|
180
207
|
if (measure.resized) {
|
|
181
208
|
size.fontSize = measure.fontSize;
|
|
182
209
|
this.context.font = parseFont(i, j, this.useLegacy);
|
|
@@ -185,9 +212,11 @@
|
|
|
185
212
|
}
|
|
186
213
|
}
|
|
187
214
|
}
|
|
215
|
+
logger("getCommentSize complete: ".concat(performance.now() - getCommentSizeStart, "ms"));
|
|
188
216
|
return result;
|
|
189
217
|
};
|
|
190
218
|
NiconiComments.prototype.getCommentPos = function (parsedData) {
|
|
219
|
+
var getCommentPosStart = performance.now();
|
|
191
220
|
var data = parsedData;
|
|
192
221
|
for (var i in data) {
|
|
193
222
|
var comment = data[i];
|
|
@@ -249,7 +278,7 @@
|
|
|
249
278
|
break;
|
|
250
279
|
}
|
|
251
280
|
}
|
|
252
|
-
if (left_pos <= 40
|
|
281
|
+
if (left_pos <= 40) {
|
|
253
282
|
for (var k in this.collision_left[vpos]) {
|
|
254
283
|
var l = this.collision_left[vpos][k];
|
|
255
284
|
if ((posY < data[l].posY + data[l].height && posY + comment.height > data[l].posY) && data[l].owner === comment.owner) {
|
|
@@ -273,9 +302,9 @@
|
|
|
273
302
|
break;
|
|
274
303
|
}
|
|
275
304
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
305
|
+
}
|
|
306
|
+
if (is_break) {
|
|
307
|
+
break;
|
|
279
308
|
}
|
|
280
309
|
}
|
|
281
310
|
}
|
|
@@ -342,45 +371,51 @@
|
|
|
342
371
|
parsedData[i].posY = posY;
|
|
343
372
|
}
|
|
344
373
|
}
|
|
374
|
+
logger("getCommentPos complete: ".concat(performance.now() - getCommentPosStart, "ms"));
|
|
345
375
|
return parsedData;
|
|
346
376
|
};
|
|
347
377
|
NiconiComments.prototype.sortComment = function (parsedData) {
|
|
378
|
+
var sortCommentStart = performance.now();
|
|
348
379
|
for (var vpos in this.timeline) {
|
|
349
380
|
if (!this.timeline[vpos])
|
|
350
381
|
continue;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
var
|
|
354
|
-
if (
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
else if (A.owner && !B.owner) {
|
|
358
|
-
return 1;
|
|
382
|
+
var owner = [], user = [];
|
|
383
|
+
for (var _i = 0, _a = this.timeline[vpos]; _i < _a.length; _i++) {
|
|
384
|
+
var i = _a[_i];
|
|
385
|
+
if (parsedData[i].owner) {
|
|
386
|
+
owner.push(i);
|
|
359
387
|
}
|
|
360
388
|
else {
|
|
361
|
-
|
|
389
|
+
user.push(i);
|
|
362
390
|
}
|
|
363
|
-
}
|
|
391
|
+
}
|
|
392
|
+
this.timeline[vpos] = owner.concat(user);
|
|
364
393
|
}
|
|
394
|
+
logger("parseData complete: ".concat(performance.now() - sortCommentStart, "ms"));
|
|
365
395
|
return parsedData;
|
|
366
396
|
};
|
|
367
397
|
NiconiComments.prototype.measureText = function (comment) {
|
|
368
398
|
var width, width_max, width_min, height, width_arr = [], lines = comment.content.split("\n");
|
|
399
|
+
if (!comment.lineHeight)
|
|
400
|
+
comment.lineHeight = this.lineHeight[comment.size].default;
|
|
369
401
|
if (!comment.resized && !comment.ender) {
|
|
370
402
|
if (comment.size === "big" && lines.length > 2) {
|
|
371
403
|
comment.fontSize = this.fontSize.big.resized;
|
|
404
|
+
comment.lineHeight = this.lineHeight.big.resized;
|
|
372
405
|
comment.resized = true;
|
|
373
406
|
comment.tateresized = true;
|
|
374
407
|
this.context.font = parseFont(comment.font, comment.fontSize, this.useLegacy);
|
|
375
408
|
}
|
|
376
409
|
else if (comment.size === "medium" && lines.length > 4) {
|
|
377
410
|
comment.fontSize = this.fontSize.medium.resized;
|
|
411
|
+
comment.lineHeight = this.lineHeight.medium.resized;
|
|
378
412
|
comment.resized = true;
|
|
379
413
|
comment.tateresized = true;
|
|
380
414
|
this.context.font = parseFont(comment.font, comment.fontSize, this.useLegacy);
|
|
381
415
|
}
|
|
382
416
|
else if (comment.size === "small" && lines.length > 6) {
|
|
383
417
|
comment.fontSize = this.fontSize.small.resized;
|
|
418
|
+
comment.lineHeight = this.lineHeight.small.resized;
|
|
384
419
|
comment.resized = true;
|
|
385
420
|
comment.tateresized = true;
|
|
386
421
|
this.context.font = parseFont(comment.font, comment.fontSize, this.useLegacy);
|
|
@@ -393,9 +428,9 @@
|
|
|
393
428
|
width = width_arr.reduce(function (p, c) { return p + c; }, 0) / width_arr.length;
|
|
394
429
|
width_max = Math.max.apply(Math, width_arr);
|
|
395
430
|
width_min = Math.min.apply(Math, width_arr);
|
|
396
|
-
height = (comment.fontSize * (1 + this.commentYPaddingTop) * lines.length) + (this.commentYMarginBottom * comment.fontSize);
|
|
431
|
+
height = (comment.fontSize * comment.lineHeight * (1 + this.commentYPaddingTop) * lines.length) + (this.commentYMarginBottom * comment.fontSize);
|
|
397
432
|
if (comment.loc !== "naka" && !comment.tateresized) {
|
|
398
|
-
if (comment.full && width_max >
|
|
433
|
+
if (comment.full && width_max > 1930) {
|
|
399
434
|
comment.fontSize -= 2;
|
|
400
435
|
comment.resized = true;
|
|
401
436
|
comment.yokoResized = true;
|
|
@@ -415,7 +450,6 @@
|
|
|
415
450
|
comment.resized = true;
|
|
416
451
|
comment.yokoResized = true;
|
|
417
452
|
this.context.font = parseFont(comment.font, comment.fontSize, this.useLegacy);
|
|
418
|
-
console.log(comment);
|
|
419
453
|
return this.measureText(comment);
|
|
420
454
|
}
|
|
421
455
|
else if (comment.loc !== "naka" && comment.tateresized && comment.yokoResized) {
|
|
@@ -425,7 +459,7 @@
|
|
|
425
459
|
return this.measureText(comment);
|
|
426
460
|
}
|
|
427
461
|
else if (!comment.full && width_max > this.doubleResizeMaxWidth.normal[this.useLegacy ? "legacy" : "default"]) {
|
|
428
|
-
comment.fontSize -= 1
|
|
462
|
+
comment.fontSize -= 1;
|
|
429
463
|
this.context.font = parseFont(comment.font, comment.fontSize, this.useLegacy);
|
|
430
464
|
return this.measureText(comment);
|
|
431
465
|
}
|
|
@@ -436,7 +470,8 @@
|
|
|
436
470
|
"width_min": width_min,
|
|
437
471
|
"height": height,
|
|
438
472
|
"resized": comment.resized,
|
|
439
|
-
"fontSize": comment.fontSize
|
|
473
|
+
"fontSize": comment.fontSize,
|
|
474
|
+
"lineHeight": comment.lineHeight
|
|
440
475
|
};
|
|
441
476
|
};
|
|
442
477
|
NiconiComments.prototype.drawText = function (comment, vpos) {
|
|
@@ -468,14 +503,25 @@
|
|
|
468
503
|
else if (comment.loc === "shita") {
|
|
469
504
|
posY = 1080 - comment.posY - comment.height;
|
|
470
505
|
}
|
|
471
|
-
if (comment.image)
|
|
506
|
+
if (comment.image && comment.image !== true) {
|
|
472
507
|
this.context.drawImage(comment.image, posX, posY);
|
|
508
|
+
}
|
|
509
|
+
if (this.showCollision) {
|
|
510
|
+
this.context.strokeStyle = "rgba(0,255,255,1)";
|
|
511
|
+
this.context.strokeRect(posX, posY, comment.width_max, comment.height);
|
|
512
|
+
var lines = comment.content.split("\n");
|
|
513
|
+
for (var i in lines) {
|
|
514
|
+
var linePosY = (Number(i) + 1) * (comment.fontSize * comment.lineHeight) * (1 + this.commentYPaddingTop);
|
|
515
|
+
this.context.strokeStyle = "rgba(255,255,0,0.5)";
|
|
516
|
+
this.context.strokeRect(posX, posY + linePosY, comment.width_max, comment.fontSize * comment.lineHeight * -1);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
473
519
|
};
|
|
474
520
|
NiconiComments.prototype.getTextImage = function (i) {
|
|
521
|
+
var _this = this;
|
|
475
522
|
var value = this.data[i];
|
|
476
|
-
if (!value || value.invisible)
|
|
523
|
+
if (!value || value.invisible)
|
|
477
524
|
return;
|
|
478
|
-
}
|
|
479
525
|
var image = document.createElement("canvas");
|
|
480
526
|
image.width = value.width_max;
|
|
481
527
|
image.height = value.height;
|
|
@@ -497,34 +543,18 @@
|
|
|
497
543
|
if (value.color === "#000000") {
|
|
498
544
|
context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
499
545
|
}
|
|
500
|
-
if (this.showCollision) {
|
|
501
|
-
context.strokeStyle = "rgba(0,255,255,1)";
|
|
502
|
-
context.strokeRect(0, 0, value.width_max, value.height);
|
|
503
|
-
if (value.color === "#000000") {
|
|
504
|
-
context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
546
|
var lines = value.content.split("\n");
|
|
511
547
|
for (var i_1 in lines) {
|
|
512
548
|
var line = lines[i_1], posY = void 0;
|
|
513
|
-
posY = (Number(i_1) + 1) * (value.fontSize) * (1 + this.commentYPaddingTop);
|
|
549
|
+
posY = (Number(i_1) + 1) * (value.fontSize * value.lineHeight) * (1 + this.commentYPaddingTop);
|
|
514
550
|
context.strokeText(line, 0, posY);
|
|
515
551
|
context.fillText(line, 0, posY);
|
|
516
|
-
if (this.showCollision) {
|
|
517
|
-
context.strokeStyle = "rgba(255,255,0,0.5)";
|
|
518
|
-
context.strokeRect(0, posY, value.width_max, value.fontSize * -1);
|
|
519
|
-
if (value.color === "#000000") {
|
|
520
|
-
context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
552
|
}
|
|
527
553
|
this.data[i].image = image;
|
|
554
|
+
setTimeout(function () {
|
|
555
|
+
if (_this.data[i].image)
|
|
556
|
+
delete _this.data[i].image;
|
|
557
|
+
}, 5000);
|
|
528
558
|
};
|
|
529
559
|
NiconiComments.prototype.parseCommand = function (comment) {
|
|
530
560
|
var metadata = comment.mail, loc = null, size = null, fontSize = null, color = null, font = null, full = false, ender = false, _live = false, invisible = false, long = null;
|
|
@@ -817,6 +847,7 @@
|
|
|
817
847
|
return _assign(_assign({}, comment), data);
|
|
818
848
|
};
|
|
819
849
|
NiconiComments.prototype.drawCanvas = function (vpos) {
|
|
850
|
+
var drawCanvasStart = performance.now();
|
|
820
851
|
if (this.lastVpos === vpos)
|
|
821
852
|
return;
|
|
822
853
|
this.lastVpos = vpos;
|
|
@@ -824,7 +855,7 @@
|
|
|
824
855
|
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
825
856
|
if (this.video) {
|
|
826
857
|
var offsetX = void 0, offsetY = void 0, scale = void 0, height = this.canvas.height / this.video.videoHeight, width = this.canvas.width / this.video.videoWidth;
|
|
827
|
-
if (height
|
|
858
|
+
if (height < width) {
|
|
828
859
|
scale = width;
|
|
829
860
|
}
|
|
830
861
|
else {
|
|
@@ -841,21 +872,28 @@
|
|
|
841
872
|
if (!comment || comment.invisible) {
|
|
842
873
|
continue;
|
|
843
874
|
}
|
|
844
|
-
if (
|
|
875
|
+
if (comment.image === undefined) {
|
|
845
876
|
this.getTextImage(index);
|
|
846
877
|
}
|
|
847
|
-
|
|
878
|
+
try {
|
|
879
|
+
this.drawText(comment, vpos);
|
|
880
|
+
}
|
|
881
|
+
catch (e) {
|
|
882
|
+
comment.image = false;
|
|
883
|
+
}
|
|
848
884
|
}
|
|
849
885
|
}
|
|
850
886
|
if (this.showFPS) {
|
|
851
887
|
this.context.font = parseFont("defont", 60, this.useLegacy);
|
|
852
888
|
this.context.fillStyle = "#00FF00";
|
|
889
|
+
this.context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
853
890
|
this.context.strokeText("FPS:" + this.fps, 100, 100);
|
|
854
891
|
this.context.fillText("FPS:" + this.fps, 100, 100);
|
|
855
892
|
}
|
|
856
893
|
if (this.showCommentCount) {
|
|
857
894
|
this.context.font = parseFont("defont", 60, this.useLegacy);
|
|
858
895
|
this.context.fillStyle = "#00FF00";
|
|
896
|
+
this.context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
859
897
|
if (this.timeline[vpos]) {
|
|
860
898
|
this.context.strokeText("Count:" + this.timeline[vpos].length, 100, 200);
|
|
861
899
|
this.context.fillText("Count:" + this.timeline[vpos].length, 100, 200);
|
|
@@ -865,6 +903,7 @@
|
|
|
865
903
|
this.context.fillText("Count:0", 100, 200);
|
|
866
904
|
}
|
|
867
905
|
}
|
|
906
|
+
logger("drawCanvas complete: ".concat(performance.now() - drawCanvasStart, "ms"));
|
|
868
907
|
};
|
|
869
908
|
NiconiComments.prototype.clear = function () {
|
|
870
909
|
this.context.clearRect(0, 0, 1920, 1080);
|
|
@@ -929,6 +968,10 @@
|
|
|
929
968
|
var isApiChat = function (item) {
|
|
930
969
|
return !!item.chat;
|
|
931
970
|
};
|
|
971
|
+
var logger = function (msg) {
|
|
972
|
+
if (isDebug)
|
|
973
|
+
console.debug(msg);
|
|
974
|
+
};
|
|
932
975
|
|
|
933
976
|
return NiconiComments;
|
|
934
977
|
|
package/dist/dts/main.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare type InitOptions = {
|
|
|
6
6
|
showFPS: boolean;
|
|
7
7
|
showCommentCount: boolean;
|
|
8
8
|
drawAllImageOnLoad: boolean;
|
|
9
|
+
debug: boolean;
|
|
9
10
|
};
|
|
10
11
|
declare type rawApiResponse = {
|
|
11
12
|
[key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat;
|
|
@@ -69,10 +70,11 @@ declare type formattedCommentWithSize = formattedCommentWithFont & {
|
|
|
69
70
|
"width": number;
|
|
70
71
|
"width_max": number;
|
|
71
72
|
"width_min": number;
|
|
73
|
+
"lineHeight": number;
|
|
72
74
|
};
|
|
73
75
|
declare type parsedComment = formattedCommentWithSize & {
|
|
74
76
|
posY: number;
|
|
75
|
-
image?: HTMLCanvasElement;
|
|
77
|
+
image?: HTMLCanvasElement | boolean;
|
|
76
78
|
};
|
|
77
79
|
declare type measureTextResult = {
|
|
78
80
|
"width": number;
|
|
@@ -81,6 +83,7 @@ declare type measureTextResult = {
|
|
|
81
83
|
"height": number;
|
|
82
84
|
"resized": boolean;
|
|
83
85
|
"fontSize": number;
|
|
86
|
+
"lineHeight": number;
|
|
84
87
|
};
|
|
85
88
|
declare class NiconiComments {
|
|
86
89
|
private canvas;
|
|
@@ -88,6 +91,7 @@ declare class NiconiComments {
|
|
|
88
91
|
private readonly commentYPaddingTop;
|
|
89
92
|
private readonly commentYMarginBottom;
|
|
90
93
|
private readonly fontSize;
|
|
94
|
+
private readonly lineHeight;
|
|
91
95
|
private readonly doubleResizeMaxWidth;
|
|
92
96
|
private video;
|
|
93
97
|
private showCollision;
|
|
@@ -122,6 +126,7 @@ declare class NiconiComments {
|
|
|
122
126
|
loc: string;
|
|
123
127
|
full: any;
|
|
124
128
|
yokoResized: boolean;
|
|
129
|
+
lineHeight: number | undefined;
|
|
125
130
|
}): measureTextResult;
|
|
126
131
|
drawText(comment: parsedComment, vpos: number): void;
|
|
127
132
|
getTextImage(i: number): void;
|
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,CAAA;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":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a,EAAE;IAwBvC,WAAW,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,WAAW,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;KAAE,GAAG,iBAAiB;IAgF1O,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM;IA8C7C,YAAY,CAAC,CAAC,EAAE,MAAM;IAwCtB,YAAY,CAAC,OAAO,EAAE,GAAG;;;;;;;;;;;;IAiJzB,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,GAAG,wBAAwB;IAgK9E,UAAU,CAAC,IAAI,EAAE,MAAM;IA4DvB,KAAK;CAGR;AA0FD,eAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
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",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"homepage": "https://xpadev.net/niconicomments/docs/",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@babel/preset-env": "^7.18.2",
|
|
34
35
|
"@rollup/plugin-babel": "^5.3.0",
|
|
35
36
|
"@rollup/plugin-typescript": "^8.3.2",
|
|
36
37
|
"rollup": "^2.75.6",
|
|
37
38
|
"typedoc": "^0.22.17",
|
|
38
39
|
"typedoc-plugin-missing-exports": "^0.22.6",
|
|
39
|
-
"typescript": "^4.7.3"
|
|
40
|
-
"@babel/preset-env": "^7.18.2"
|
|
40
|
+
"typescript": "^4.7.3"
|
|
41
41
|
}
|
|
42
42
|
}
|