@uimaxbai/am-lyrics 1.2.8 → 1.2.9
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/src/AmLyrics.d.ts.map +1 -1
- package/dist/src/am-lyrics.js +25 -9
- package/dist/src/am-lyrics.js.map +1 -1
- package/dist/src/react.js +25 -9
- package/dist/src/react.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/AmLyrics.ts +34 -10
package/dist/src/react.js
CHANGED
|
@@ -322,7 +322,7 @@ class GoogleService {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
const VERSION = '1.2.
|
|
325
|
+
const VERSION = '1.2.9';
|
|
326
326
|
const INSTRUMENTAL_THRESHOLD_MS = 7000; // Show dots for gaps >= 7s
|
|
327
327
|
const FETCH_TIMEOUT_MS = 8000; // Timeout for all lyrics fetch requests
|
|
328
328
|
const SEEK_THRESHOLD_MS = 500;
|
|
@@ -2046,9 +2046,22 @@ let AmLyrics$1 = class AmLyrics extends i {
|
|
|
2046
2046
|
if (targetLineIndex === null)
|
|
2047
2047
|
return;
|
|
2048
2048
|
const targetLine = this._getLineElement(targetLineIndex);
|
|
2049
|
-
if (targetLine)
|
|
2050
|
-
|
|
2049
|
+
if (!targetLine)
|
|
2050
|
+
return;
|
|
2051
|
+
// Only scroll snappily when lines are essentially back-to-back.
|
|
2052
|
+
// If there is any noticeable gap between them, scroll slower.
|
|
2053
|
+
let scrollDuration;
|
|
2054
|
+
const prevPrimaryIndex = AmLyrics.getLineIndexFromElement(this.currentPrimaryActiveLine);
|
|
2055
|
+
if (prevPrimaryIndex !== null &&
|
|
2056
|
+
targetLineIndex > prevPrimaryIndex &&
|
|
2057
|
+
this.lyrics) {
|
|
2058
|
+
const gap = this.lyrics[targetLineIndex].timestamp -
|
|
2059
|
+
this.lyrics[prevPrimaryIndex].endtime;
|
|
2060
|
+
if (gap > 200) {
|
|
2061
|
+
scrollDuration = Math.min(Math.max(gap * 0.6, SCROLL_ANIMATION_DURATION_MS), 2000);
|
|
2062
|
+
}
|
|
2051
2063
|
}
|
|
2064
|
+
this.focusLine(targetLine, forceScroll, scrollDuration);
|
|
2052
2065
|
}
|
|
2053
2066
|
_getTextWidth(text, font) {
|
|
2054
2067
|
if (!this._textWidthCanvas) {
|
|
@@ -2161,16 +2174,14 @@ let AmLyrics$1 = class AmLyrics extends i {
|
|
|
2161
2174
|
if (isGrowableVW) {
|
|
2162
2175
|
if (wordLen < 3) {
|
|
2163
2176
|
isGrowableVW =
|
|
2164
|
-
combinedDuration >=
|
|
2177
|
+
combinedDuration >= 1000 && combinedDuration >= wordLen * 500;
|
|
2165
2178
|
}
|
|
2166
2179
|
else {
|
|
2167
2180
|
isGrowableVW =
|
|
2168
|
-
combinedDuration >=
|
|
2181
|
+
combinedDuration >= 800 && combinedDuration >= wordLen * 180;
|
|
2169
2182
|
}
|
|
2170
2183
|
}
|
|
2171
|
-
const isGlowingVW = isGrowableVW
|
|
2172
|
-
combinedDuration >= 1000 &&
|
|
2173
|
-
combinedDuration >= combinedText.length * 250;
|
|
2184
|
+
const isGlowingVW = isGrowableVW;
|
|
2174
2185
|
let charOff = 0;
|
|
2175
2186
|
for (let gi = vwStart; gi <= vwEnd; gi += 1) {
|
|
2176
2187
|
groupGrowable[gi] = isGrowableVW;
|
|
@@ -3443,6 +3454,9 @@ let AmLyrics$1 = class AmLyrics extends i {
|
|
|
3443
3454
|
// as the main vocal, so we intentionally do NOT render a separate
|
|
3444
3455
|
// translation/romanization block for background — it would just duplicate
|
|
3445
3456
|
// the main line's text.
|
|
3457
|
+
const bgPlacement = hasBackground
|
|
3458
|
+
? AmLyrics.getBackgroundTextPlacement(line)
|
|
3459
|
+
: 'after';
|
|
3446
3460
|
const lineData = this.cachedLineData?.[lineIndex];
|
|
3447
3461
|
const wordGroups = lineData?.wordGroups ?? [];
|
|
3448
3462
|
const groupGrowable = lineData?.groupGrowable ?? [];
|
|
@@ -3672,7 +3686,9 @@ let AmLyrics$1 = class AmLyrics extends i {
|
|
|
3672
3686
|
}}
|
|
3673
3687
|
>
|
|
3674
3688
|
<div class="lyrics-line-container">
|
|
3675
|
-
${
|
|
3689
|
+
${bgPlacement === 'before' ? backgroundVocalElement : ''}
|
|
3690
|
+
${mainVocalElement}
|
|
3691
|
+
${bgPlacement === 'after' ? backgroundVocalElement : ''}
|
|
3676
3692
|
${translationElement} ${lineRomanizationElement}
|
|
3677
3693
|
</div>
|
|
3678
3694
|
</div>
|