@braccato/core 1.16.8 → 1.16.10
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/inject.js +10 -3
- package/dist/styles/lyrics.css +8 -2
- package/dist/text.d.ts +1 -0
- package/dist/text.js +2 -0
- package/package.json +1 -1
package/dist/inject.js
CHANGED
|
@@ -15,7 +15,7 @@ import { alignImageGlowRun, wrapImageHighlight } from "./imageHighlights.js";
|
|
|
15
15
|
import { normalizeLanguage } from "./language.js";
|
|
16
16
|
import { BACKGROUND_LINE_CLASS, BACKGROUND_LYRIC_CLASS, BIDI_RUN_CLASS, BIDI_SENSITIVE_CLASS, CONTENT_LINE_CLASS, EXPLICIT_WORD_CLASS, HIGHLIGHT_RUN_CLASS, LETTER_CLASS, LINE_MAIN_CLASS, LINE_SYNCED_WORD_CLASS, LONG_WORD_GROUP_CLASS, ROMANIZED_LYRICS_CLASS, RTL_CLASS, TRANSLATED_LYRICS_CLASS, WORD_CLASS, WORD_GROUP_CLASS, WORD_HIGHLIGHT_CLASS, WORD_HIGHLIGHT_LETTERED_CLASS, WORD_STATE_ATTR, WORD_STATE_UPCOMING, ZERO_DURATION_ANIMATION_CLASS, } from "./constants.js";
|
|
17
17
|
import { getSeekTimeFromClick } from "./seek.js";
|
|
18
|
-
import { testJoiningScript, testRtl } from "./text.js";
|
|
18
|
+
import { isSameText, testJoiningScript, testRtl } from "./text.js";
|
|
19
19
|
import { registerThemeSetting } from "./themeSettings.js";
|
|
20
20
|
export let disableRichsync = registerThemeSetting("blyrics-disable-richsync", false, true);
|
|
21
21
|
let lineSyncedAnimationDelay = registerThemeSetting("blyrics-line-synced-animation-delay", 50, true);
|
|
@@ -414,8 +414,15 @@ export function addSeekHandler(seek, lyricElement, allZero) {
|
|
|
414
414
|
seek(seekTime);
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
+
function repeatsLine(lyricElement, text) {
|
|
418
|
+
const mainRun = [
|
|
419
|
+
...(lyricElement.querySelector(`:scope > .${LINE_MAIN_CLASS}`)?.querySelectorAll(`:scope > .${BIDI_RUN_CLASS}`) ??
|
|
420
|
+
[]),
|
|
421
|
+
].find(run => !run.classList.contains(HIGHLIGHT_RUN_CLASS));
|
|
422
|
+
return mainRun?.textContent != null && isSameText(mainRun.textContent, text);
|
|
423
|
+
}
|
|
417
424
|
export function injectRomanization(doc, lyricElement, lineData, text, timedRomanization = null) {
|
|
418
|
-
if (lyricElement.querySelector(`.${ROMANIZED_LYRICS_CLASS}`))
|
|
425
|
+
if (lyricElement.querySelector(`.${ROMANIZED_LYRICS_CLASS}`) || repeatsLine(lyricElement, text))
|
|
419
426
|
return;
|
|
420
427
|
const romanizedLine = doc.createElement("div");
|
|
421
428
|
romanizedLine.classList.add(ROMANIZED_LYRICS_CLASS, CONTENT_LINE_CLASS);
|
|
@@ -433,7 +440,7 @@ export function injectRomanization(doc, lyricElement, lineData, text, timedRoman
|
|
|
433
440
|
lyricElement.insertBefore(romanizedLine, translation);
|
|
434
441
|
}
|
|
435
442
|
export function injectTranslation(doc, lyricElement, text, language) {
|
|
436
|
-
if (lyricElement.querySelector(`.${TRANSLATED_LYRICS_CLASS}`))
|
|
443
|
+
if (lyricElement.querySelector(`.${TRANSLATED_LYRICS_CLASS}`) || repeatsLine(lyricElement, text))
|
|
437
444
|
return;
|
|
438
445
|
const translatedLine = doc.createElement("div");
|
|
439
446
|
translatedLine.classList.add(TRANSLATED_LYRICS_CLASS, CONTENT_LINE_CLASS);
|
package/dist/styles/lyrics.css
CHANGED
|
@@ -211,9 +211,15 @@
|
|
|
211
211
|
mask-position: 100% 0%;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
/* text-decoration skips inline-block letters and rides the wave, so draw on the word box instead, from its
|
|
215
|
+
center (fixed against the text at any line-height), with layout-neutral padding so a tight box can hold it. */
|
|
214
216
|
[blyrics-alt-hover] .blyrics--word:hover {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
padding-block: 0.25em;
|
|
218
|
+
margin-block: -0.25em;
|
|
219
|
+
background-image: linear-gradient(currentColor, currentColor);
|
|
220
|
+
background-position: 0 calc(50% + 0.54em);
|
|
221
|
+
background-repeat: no-repeat;
|
|
222
|
+
background-size: 100% 0.06em;
|
|
217
223
|
}
|
|
218
224
|
|
|
219
225
|
.blyrics--line > .blyrics-line-main > .blyrics-background-lyric,
|
package/dist/text.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export declare function containsNonLatin(text: string): boolean;
|
|
|
9
9
|
declare const SCRIPT_TO_LANG: readonly [readonly [RegExp, "ja"], readonly [RegExp, "ko"], readonly [RegExp, "zh"], readonly [RegExp, "ru"], readonly [RegExp, "hi"], readonly [RegExp, "ar"], readonly [RegExp, "th"], readonly [RegExp, "el"], readonly [RegExp, "he"], readonly [RegExp, "bn"], readonly [RegExp, "ta"], readonly [RegExp, "te"], readonly [RegExp, "ml"], readonly [RegExp, "kn"], readonly [RegExp, "gu"], readonly [RegExp, "pa"], readonly [RegExp, "si"], readonly [RegExp, "my"], readonly [RegExp, "ka"], readonly [RegExp, "km"], readonly [RegExp, "lo"]];
|
|
10
10
|
type NonLatinLanguageCode = (typeof SCRIPT_TO_LANG)[number][1];
|
|
11
11
|
export declare function detectNonLatinLanguage(text: string): NonLatinLanguageCode | null;
|
|
12
|
+
export declare const isSameText: (a: string, b: string) => boolean;
|
|
12
13
|
export {};
|
package/dist/text.js
CHANGED