@xpadev-net/niconicomments 0.2.36 → 0.2.37

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
@@ -397,189 +397,189 @@ interface IComment {
397
397
  draw: (vpos: number, showCollision: boolean, isDebug: boolean) => void;
398
398
  }
399
399
 
400
- type inputFormatType =
401
- | "niconicome"
402
- | "formatted"
403
- | "legacy"
404
- | "legacyOwner"
405
- | "owner"
406
- | "v1"
407
- | "empty"
408
- | "default";
409
- type inputFormat =
410
- | XMLDocument
411
- | formattedComment[]
412
- | formattedLegacyComment[]
413
- | rawApiResponse[]
414
- | ownerComment[]
415
- | v1Thread[]
416
- | string
417
- | undefined;
418
- type modeType = "default" | "html5" | "flash";
419
- type Options = {
420
- config: ConfigNullable;
421
- debug: boolean;
422
- enableLegacyPiP: boolean;
423
- format: inputFormatType;
424
- formatted: boolean;
425
- keepCA: boolean;
426
- mode: modeType;
427
- scale: number;
428
- showCollision: boolean;
429
- showCommentCount: boolean;
430
- showFPS: boolean;
431
- useLegacy: boolean;
432
- video: HTMLVideoElement | undefined;
433
- };
434
- type InitOptions = Partial<Options>;
400
+ type inputFormatType =
401
+ | "niconicome"
402
+ | "formatted"
403
+ | "legacy"
404
+ | "legacyOwner"
405
+ | "owner"
406
+ | "v1"
407
+ | "empty"
408
+ | "default";
409
+ type inputFormat =
410
+ | XMLDocument
411
+ | formattedComment[]
412
+ | formattedLegacyComment[]
413
+ | rawApiResponse[]
414
+ | ownerComment[]
415
+ | v1Thread[]
416
+ | string
417
+ | undefined;
418
+ type modeType = "default" | "html5" | "flash";
419
+ type Options = {
420
+ config: ConfigNullable;
421
+ debug: boolean;
422
+ enableLegacyPiP: boolean;
423
+ format: inputFormatType;
424
+ formatted: boolean;
425
+ keepCA: boolean;
426
+ mode: modeType;
427
+ scale: number;
428
+ showCollision: boolean;
429
+ showCommentCount: boolean;
430
+ showFPS: boolean;
431
+ useLegacy: boolean;
432
+ video: HTMLVideoElement | undefined;
433
+ };
434
+ type InitOptions = Partial<Options>;
435
435
 
436
- type formattedCommentWithFont = {
437
- id: number;
438
- vpos: number;
439
- date: number;
440
- date_usec: number;
441
- owner: boolean;
442
- premium: boolean;
443
- mail: string[];
444
- user_id: number;
445
- layer: number;
446
- loc: commentLoc;
447
- size: commentSize;
448
- fontSize: number;
449
- font: commentFont;
450
- color: string;
451
- full: boolean;
452
- ender: boolean;
453
- _live: boolean;
454
- long: number;
455
- invisible: boolean;
456
- content: commentContentItem[];
457
- flash: boolean;
458
- lineCount: number;
459
- lineOffset: number;
460
- };
461
- type formattedCommentWithSize = formattedCommentWithFont & {
462
- height: number;
463
- width: number;
464
- lineHeight: number;
465
- resized: boolean;
466
- resizedX: boolean;
467
- resizedY: boolean;
468
- content: commentMeasuredContentItem[];
469
- charSize: number;
470
- };
471
- type parsedComment = formattedCommentWithSize & {
472
- posY: number;
473
- image?: HTMLCanvasElement | boolean;
474
- };
475
- type commentContentItem = {
476
- content: string;
477
- font?: commentFlashFont;
478
- width?: number[];
479
- };
480
- type commentMeasuredContentItem = commentContentItem & {
481
- width: number[];
482
- };
483
- type commentContentIndex = {
484
- index: number;
485
- font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
486
- };
487
- type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
488
- type commentFlashFont = "defont" | "gulim" | "simsun";
489
- type commentSize = "big" | "medium" | "small";
490
- type commentLoc = "ue" | "naka" | "shita";
491
- type collision = { [key in collisionPos]: collisionItem };
492
- type collisionPos = "ue" | "shita" | "right" | "left";
493
- type collisionItem = { [p: number]: IComment[] };
494
- type nicoScript = {
495
- reverse: nicoScriptReverse[];
496
- ban: nicoScriptBan[];
497
- default: nicoScriptDefault[];
498
- replace: nicoScriptReplace[];
499
- };
500
- type nicoScriptReverse = {
501
- target: nicoScriptReverseTarget;
502
- start: number;
503
- end: number;
504
- };
505
- type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
506
- type nicoScriptReplace = {
507
- start: number;
508
- long: number | undefined;
509
- keyword: string;
510
- replace: string;
511
- range: nicoScriptReplaceRange;
512
- target: nicoScriptReplaceTarget;
513
- condition: nicoScriptReplaceCondition;
514
- color: string | undefined;
515
- size: commentSize | undefined;
516
- font: commentFont | undefined;
517
- loc: commentLoc | undefined;
518
- no: number;
519
- };
520
- type nicoScriptReplaceRange = "単" | "全";
521
- type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
522
- type nicoScriptReplaceCondition = "完全一致" | "部分一致";
523
- type nicoScriptBan = {
524
- start: number;
525
- end: number;
526
- };
527
- type nicoScriptDefault = {
528
- start: number;
529
- long: number | undefined;
530
- color: string | undefined;
531
- size: commentSize | undefined;
532
- font: commentFont | undefined;
533
- loc: commentLoc | undefined;
534
- };
535
- type measureTextResult = {
536
- width: number;
537
- height: number;
538
- resized: boolean;
539
- resizedX: boolean;
540
- resizedY: boolean;
541
- fontSize: number;
542
- lineHeight: number;
543
- content: commentMeasuredContentItem[];
544
- charSize: number;
545
- };
546
- type parsedCommand = {
547
- loc: commentLoc | undefined;
548
- size: commentSize | undefined;
549
- fontSize: number | undefined;
550
- color: string | undefined;
551
- font: commentFont | undefined;
552
- full: boolean;
553
- ender: boolean;
554
- _live: boolean;
555
- invisible: boolean;
556
- long: number | undefined;
557
- };
558
-
559
- type measureTextInput = {
560
- content: commentContentItem[];
561
- resized?: boolean;
562
- ender: boolean;
563
- size: commentSize;
564
- fontSize: number;
565
- resizedY?: boolean;
566
- resizedX?: boolean;
567
- font: commentFont;
568
- loc: commentLoc;
569
- full: boolean;
570
- flash: boolean;
571
- lineCount: number;
572
- lineHeight?: number;
573
- charSize?: number;
574
- };
575
-
576
- type measureInput = {
577
- font: commentFont;
578
- content: commentContentItem[];
579
- lineHeight: number;
580
- charSize: number;
581
- lineCount: number;
582
- };
436
+ type formattedCommentWithFont = {
437
+ id: number;
438
+ vpos: number;
439
+ date: number;
440
+ date_usec: number;
441
+ owner: boolean;
442
+ premium: boolean;
443
+ mail: string[];
444
+ user_id: number;
445
+ layer: number;
446
+ loc: commentLoc;
447
+ size: commentSize;
448
+ fontSize: number;
449
+ font: commentFont;
450
+ color: string;
451
+ full: boolean;
452
+ ender: boolean;
453
+ _live: boolean;
454
+ long: number;
455
+ invisible: boolean;
456
+ content: commentContentItem[];
457
+ flash: boolean;
458
+ lineCount: number;
459
+ lineOffset: number;
460
+ };
461
+ type formattedCommentWithSize = formattedCommentWithFont & {
462
+ height: number;
463
+ width: number;
464
+ lineHeight: number;
465
+ resized: boolean;
466
+ resizedX: boolean;
467
+ resizedY: boolean;
468
+ content: commentMeasuredContentItem[];
469
+ charSize: number;
470
+ };
471
+ type parsedComment = formattedCommentWithSize & {
472
+ posY: number;
473
+ image?: HTMLCanvasElement | boolean;
474
+ };
475
+ type commentContentItem = {
476
+ content: string;
477
+ font?: commentFlashFont;
478
+ width?: number[];
479
+ };
480
+ type commentMeasuredContentItem = commentContentItem & {
481
+ width: number[];
482
+ };
483
+ type commentContentIndex = {
484
+ index: number;
485
+ font: "gothic" | "gulim" | "simsunStrong" | "simsunWeak";
486
+ };
487
+ type commentFont = "defont" | "mincho" | "gothic" | "gulim" | "simsun";
488
+ type commentFlashFont = "defont" | "gulim" | "simsun";
489
+ type commentSize = "big" | "medium" | "small";
490
+ type commentLoc = "ue" | "naka" | "shita";
491
+ type collision = { [key in collisionPos]: collisionItem };
492
+ type collisionPos = "ue" | "shita" | "right" | "left";
493
+ type collisionItem = { [p: number]: IComment[] };
494
+ type nicoScript = {
495
+ reverse: nicoScriptReverse[];
496
+ ban: nicoScriptBan[];
497
+ default: nicoScriptDefault[];
498
+ replace: nicoScriptReplace[];
499
+ };
500
+ type nicoScriptReverse = {
501
+ target: nicoScriptReverseTarget;
502
+ start: number;
503
+ end: number;
504
+ };
505
+ type nicoScriptReverseTarget = "コメ" | "投コメ" | "全";
506
+ type nicoScriptReplace = {
507
+ start: number;
508
+ long: number | undefined;
509
+ keyword: string;
510
+ replace: string;
511
+ range: nicoScriptReplaceRange;
512
+ target: nicoScriptReplaceTarget;
513
+ condition: nicoScriptReplaceCondition;
514
+ color: string | undefined;
515
+ size: commentSize | undefined;
516
+ font: commentFont | undefined;
517
+ loc: commentLoc | undefined;
518
+ no: number;
519
+ };
520
+ type nicoScriptReplaceRange = "単" | "全";
521
+ type nicoScriptReplaceTarget = "コメ" | "投コメ" | "全" | "含まない" | "含む";
522
+ type nicoScriptReplaceCondition = "完全一致" | "部分一致";
523
+ type nicoScriptBan = {
524
+ start: number;
525
+ end: number;
526
+ };
527
+ type nicoScriptDefault = {
528
+ start: number;
529
+ long: number | undefined;
530
+ color: string | undefined;
531
+ size: commentSize | undefined;
532
+ font: commentFont | undefined;
533
+ loc: commentLoc | undefined;
534
+ };
535
+ type measureTextResult = {
536
+ width: number;
537
+ height: number;
538
+ resized: boolean;
539
+ resizedX: boolean;
540
+ resizedY: boolean;
541
+ fontSize: number;
542
+ lineHeight: number;
543
+ content: commentMeasuredContentItem[];
544
+ charSize: number;
545
+ };
546
+ type parsedCommand = {
547
+ loc: commentLoc | undefined;
548
+ size: commentSize | undefined;
549
+ fontSize: number | undefined;
550
+ color: string | undefined;
551
+ font: commentFont | undefined;
552
+ full: boolean;
553
+ ender: boolean;
554
+ _live: boolean;
555
+ invisible: boolean;
556
+ long: number | undefined;
557
+ };
558
+
559
+ type measureTextInput = {
560
+ content: commentContentItem[];
561
+ resized?: boolean;
562
+ ender: boolean;
563
+ size: commentSize;
564
+ fontSize: number;
565
+ resizedY?: boolean;
566
+ resizedX?: boolean;
567
+ font: commentFont;
568
+ loc: commentLoc;
569
+ full: boolean;
570
+ flash: boolean;
571
+ lineCount: number;
572
+ lineHeight?: number;
573
+ charSize?: number;
574
+ };
575
+
576
+ type measureInput = {
577
+ font: commentFont;
578
+ content: commentContentItem[];
579
+ lineHeight: number;
580
+ charSize: number;
581
+ lineCount: number;
582
+ };
583
583
 
584
584
  declare const convert2formattedComment: (data: unknown, type: inputFormatType) => formattedComment[];
585
585
 
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.36
2
+ niconicomments.js v0.2.37
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -1577,6 +1577,9 @@
1577
1577
  item.width = itemWidth[i];
1578
1578
  }
1579
1579
  comment.fontSize = (comment.charSize || 0) * 0.8;
1580
+ var charScale = getFontSizeAndScale(comment.charSize || 0);
1581
+ if (charScale.scale < 1)
1582
+ height *= 1.01;
1580
1583
  return {
1581
1584
  width: width * scale,
1582
1585
  height: height * scale,
@@ -1674,6 +1677,7 @@
1674
1677
  this.context.strokeRect(posX, posY, this.comment.width, this.comment.height);
1675
1678
  for (var i = 0; i < this.comment.lineCount; i++) {
1676
1679
  var linePosY = (this.comment.lineHeight * (i + 1) +
1680
+ (this.comment.charSize - this.comment.lineHeight) / 2 +
1677
1681
  this.comment.lineHeight * -0.16 +
1678
1682
  (((_a = config.fonts[this.comment.font]) === null || _a === void 0 ? void 0 : _a.offset) ||
1679
1683
  0)) *
@@ -1747,6 +1751,7 @@
1747
1751
  if (line === undefined)
1748
1752
  continue;
1749
1753
  var posY = (this.comment.lineHeight * (lineCount + 1 + paddingTop) +
1754
+ (this.comment.charSize - this.comment.lineHeight) / 2 +
1750
1755
  this.comment.lineHeight * -0.16 +
1751
1756
  (((_a = config.fonts[this.comment.font]) === null || _a === void 0 ? void 0 : _a.offset) ||
1752
1757
  0)) /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpadev-net/niconicomments",
3
- "version": "0.2.36",
3
+ "version": "0.2.37",
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",