@xpadev-net/niconicomments 0.2.58 → 0.2.59
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 +1 -1
- package/dist/bundle.js +31 -26
- package/package.json +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ type BaseConfig = {
|
|
|
187
187
|
commentYOffset: ConfigSizeItem<ConfigResizedItem<number>>;
|
|
188
188
|
commentYPaddingTop: ConfigResizedItem<number>;
|
|
189
189
|
contextFillLiveOpacity: number;
|
|
190
|
-
contextLineWidth: number
|
|
190
|
+
contextLineWidth: ConfigItem<number>;
|
|
191
191
|
contextStrokeColor: string;
|
|
192
192
|
contextStrokeInversionColor: string;
|
|
193
193
|
contextStrokeOpacity: number;
|
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.2.
|
|
2
|
+
niconicomments.js v0.2.59
|
|
3
3
|
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -645,7 +645,7 @@
|
|
|
645
645
|
});
|
|
646
646
|
};
|
|
647
647
|
const processNicoscript = (comment, commands) => {
|
|
648
|
-
const nicoscript = RegExp(/^[@\uff20](
|
|
648
|
+
const nicoscript = RegExp(/^[@\uff20](.*)(?:\s(.+))?/).exec(comment.content);
|
|
649
649
|
if (!nicoscript)
|
|
650
650
|
return;
|
|
651
651
|
if (nicoscript[1] === "\u30dc\u30bf\u30f3" && nicoscript[2]) {
|
|
@@ -1333,7 +1333,7 @@
|
|
|
1333
1333
|
if (!comment.button || comment.button.limit <= 0)
|
|
1334
1334
|
return;
|
|
1335
1335
|
comment.button.limit -= 1;
|
|
1336
|
-
const mail = [...comment.button.commentMail];
|
|
1336
|
+
const mail = [...comment.button.commentMail, "from_button"];
|
|
1337
1337
|
if (!comment.button.commentVisible) {
|
|
1338
1338
|
mail.push("invisible");
|
|
1339
1339
|
}
|
|
@@ -1740,7 +1740,7 @@
|
|
|
1740
1740
|
this.cacheKey =
|
|
1741
1741
|
JSON.stringify(this.comment.content) +
|
|
1742
1742
|
`@@${this.pluginName}@@` +
|
|
1743
|
-
[...this.comment.mail].sort().join(",");
|
|
1743
|
+
[...this.comment.mail].sort((a, b) => a.localeCompare(b)).join(",");
|
|
1744
1744
|
delete this.image;
|
|
1745
1745
|
}
|
|
1746
1746
|
convertComment(comment) {
|
|
@@ -1947,7 +1947,6 @@
|
|
|
1947
1947
|
this.comment.lineHeight *
|
|
1948
1948
|
config.commentYOffset[this.comment.size][offsetKey];
|
|
1949
1949
|
let lastFont = this.comment.font, leftOffset = 0, lineCount = 0, isLastButton = false;
|
|
1950
|
-
console.log(this.comment);
|
|
1951
1950
|
for (const item of this.comment.content) {
|
|
1952
1951
|
const font = item.font ?? this.comment.font;
|
|
1953
1952
|
if (lastFont !== font) {
|
|
@@ -1955,23 +1954,20 @@
|
|
|
1955
1954
|
context.font = parseFont(font, this.comment.fontSize);
|
|
1956
1955
|
}
|
|
1957
1956
|
const lines = item.slicedContent;
|
|
1958
|
-
for (let
|
|
1959
|
-
const line = lines[
|
|
1957
|
+
for (let lineIndex = 0, lineLength = lines.length; lineIndex < lineLength; lineIndex++) {
|
|
1958
|
+
const line = lines[lineIndex];
|
|
1960
1959
|
if (line === undefined)
|
|
1961
1960
|
continue;
|
|
1962
1961
|
const posY = (lineOffset + lineCount + 1) * lineHeight + offsetY;
|
|
1963
|
-
const partWidth = item.width[
|
|
1964
|
-
if (this.comment.button &&
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
else if (isLastButton && !item.isButton) {
|
|
1969
|
-
leftOffset += atButtonPadding * 2;
|
|
1970
|
-
}
|
|
1962
|
+
const partWidth = item.width[lineIndex] ?? 0;
|
|
1963
|
+
if (this.comment.button &&
|
|
1964
|
+
!this.comment.button.hidden &&
|
|
1965
|
+
((!isLastButton && item.isButton) || (isLastButton && !item.isButton))) {
|
|
1966
|
+
leftOffset += atButtonPadding * 2;
|
|
1971
1967
|
}
|
|
1972
1968
|
context.strokeText(line, leftOffset, posY);
|
|
1973
1969
|
context.fillText(line, leftOffset, posY);
|
|
1974
|
-
if (
|
|
1970
|
+
if (lineIndex < lineLength - 1) {
|
|
1975
1971
|
leftOffset = 0;
|
|
1976
1972
|
lineCount += 1;
|
|
1977
1973
|
continue;
|
|
@@ -1992,7 +1988,12 @@
|
|
|
1992
1988
|
const atButtonRadius = getConfig(config.atButtonRadius, true);
|
|
1993
1989
|
const isHover = this.isHovered(cursor, posX, posY);
|
|
1994
1990
|
context.save();
|
|
1995
|
-
context.strokeStyle =
|
|
1991
|
+
context.strokeStyle =
|
|
1992
|
+
this.comment.button.limit < 1
|
|
1993
|
+
? "#777777"
|
|
1994
|
+
: isHover
|
|
1995
|
+
? this.comment.color
|
|
1996
|
+
: "white";
|
|
1996
1997
|
drawLeftBorder(context, parts.left.left, parts.left.top, parts.left.width, parts.left.height, atButtonRadius);
|
|
1997
1998
|
for (const part of parts.middle) {
|
|
1998
1999
|
drawMiddleBorder(context, part.left, part.top, part.width, part.height);
|
|
@@ -2007,6 +2008,7 @@
|
|
|
2007
2008
|
const { left, middle, right } = this.comment.buttonObjects;
|
|
2008
2009
|
const scale = this._globalScale *
|
|
2009
2010
|
this.comment.scale *
|
|
2011
|
+
this.comment.scaleX *
|
|
2010
2012
|
(this.comment.layer === -1 ? options.scale : 1);
|
|
2011
2013
|
const posX = (_posX ?? this.pos.x) / scale;
|
|
2012
2014
|
const posY = (_posY ?? this.pos.y) / scale;
|
|
@@ -2030,7 +2032,7 @@
|
|
|
2030
2032
|
return true;
|
|
2031
2033
|
}
|
|
2032
2034
|
}
|
|
2033
|
-
return (between(cursor.x, posX + right.right - atButtonPadding, posX + right.right +
|
|
2035
|
+
return (between(cursor.x, posX + right.right - atButtonPadding, posX + right.right + getConfig(config.contextLineWidth, true) / 2) && between(cursor.y, posY + right.top, posY + right.top + right.height));
|
|
2034
2036
|
}
|
|
2035
2037
|
_setupCanvas(image, context) {
|
|
2036
2038
|
const atButtonPadding = getConfig(config.atButtonPadding, true);
|
|
@@ -2041,7 +2043,7 @@
|
|
|
2041
2043
|
context.fillStyle = this.comment.color;
|
|
2042
2044
|
context.textAlign = "start";
|
|
2043
2045
|
context.textBaseline = "alphabetic";
|
|
2044
|
-
context.lineWidth =
|
|
2046
|
+
context.lineWidth = getConfig(config.contextLineWidth, true);
|
|
2045
2047
|
context.font = parseFont(this.comment.font, this.comment.fontSize);
|
|
2046
2048
|
const scale = this._globalScale *
|
|
2047
2049
|
this.comment.scale *
|
|
@@ -2282,7 +2284,7 @@
|
|
|
2282
2284
|
context.fillStyle = this.comment.color;
|
|
2283
2285
|
context.textAlign = "start";
|
|
2284
2286
|
context.textBaseline = "alphabetic";
|
|
2285
|
-
context.lineWidth = config.contextLineWidth;
|
|
2287
|
+
context.lineWidth = getConfig(config.contextLineWidth, false);
|
|
2286
2288
|
context.font = parseFont(this.comment.font, fontSize);
|
|
2287
2289
|
const drawScale = getConfig(config.commentScale, false) *
|
|
2288
2290
|
scale *
|
|
@@ -2490,7 +2492,10 @@
|
|
|
2490
2492
|
contextStrokeInversionColor: "#FFFFFF",
|
|
2491
2493
|
contextStrokeOpacity: 0.4,
|
|
2492
2494
|
contextFillLiveOpacity: 0.5,
|
|
2493
|
-
contextLineWidth:
|
|
2495
|
+
contextLineWidth: {
|
|
2496
|
+
html5: 2.8,
|
|
2497
|
+
flash: 4,
|
|
2498
|
+
},
|
|
2494
2499
|
commentScale: {
|
|
2495
2500
|
html5: 1920 / 683,
|
|
2496
2501
|
flash: 1920 / 683,
|
|
@@ -3074,7 +3079,7 @@
|
|
|
3074
3079
|
this.context = getContext(canvas);
|
|
3075
3080
|
this.context.textAlign = "start";
|
|
3076
3081
|
this.context.textBaseline = "alphabetic";
|
|
3077
|
-
this.context.lineWidth = config.contextLineWidth;
|
|
3082
|
+
this.context.lineWidth = getConfig(config.contextLineWidth, false);
|
|
3078
3083
|
let formatType = options.format;
|
|
3079
3084
|
if (options.formatted) {
|
|
3080
3085
|
console.warn("Deprecated: options.formatted is no longer recommended. Please use options.format. https://xpadev-net.github.io/niconicomments/#p_format");
|
|
@@ -3174,13 +3179,12 @@
|
|
|
3174
3179
|
pv.push(createCommentInstance(val, this.context));
|
|
3175
3180
|
return pv;
|
|
3176
3181
|
}, []);
|
|
3177
|
-
console.log(comments);
|
|
3178
3182
|
for (const plugin of plugins) {
|
|
3179
3183
|
try {
|
|
3180
3184
|
plugin.instance.addComments?.(comments);
|
|
3181
3185
|
}
|
|
3182
3186
|
catch (e) {
|
|
3183
|
-
console.error("Failed to add comments");
|
|
3187
|
+
console.error("Failed to add comments", e);
|
|
3184
3188
|
}
|
|
3185
3189
|
}
|
|
3186
3190
|
for (const comment of comments) {
|
|
@@ -3269,12 +3273,12 @@
|
|
|
3269
3273
|
this.context.fillStyle = "red";
|
|
3270
3274
|
if (leftCollision) {
|
|
3271
3275
|
for (const comment of leftCollision) {
|
|
3272
|
-
this.context.fillRect(config.collisionRange.left, comment.posY, config.contextLineWidth, comment.height);
|
|
3276
|
+
this.context.fillRect(config.collisionRange.left, comment.posY, getConfig(config.contextLineWidth, comment.flash), comment.height);
|
|
3273
3277
|
}
|
|
3274
3278
|
}
|
|
3275
3279
|
if (rightCollision) {
|
|
3276
3280
|
for (const comment of rightCollision) {
|
|
3277
|
-
this.context.fillRect(config.collisionRange.right, comment.posY, config.contextLineWidth * -1, comment.height);
|
|
3281
|
+
this.context.fillRect(config.collisionRange.right, comment.posY, getConfig(config.contextLineWidth, comment.flash) * -1, comment.height);
|
|
3278
3282
|
}
|
|
3279
3283
|
}
|
|
3280
3284
|
this.context.restore();
|
|
@@ -3321,6 +3325,7 @@
|
|
|
3321
3325
|
for (const comment of comments) {
|
|
3322
3326
|
if (comment.isHovered(pos)) {
|
|
3323
3327
|
const newComment = buildAtButtonComment(comment.comment, vpos);
|
|
3328
|
+
console.log(newComment);
|
|
3324
3329
|
if (!newComment)
|
|
3325
3330
|
continue;
|
|
3326
3331
|
this.addComments(newComment);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.59",
|
|
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",
|