@braccato/core 1.13.0 → 1.13.2

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 CHANGED
@@ -14,7 +14,7 @@
14
14
  import { normalizeLanguage } from "./language.js";
15
15
  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";
16
16
  import { getSeekTimeFromClick } from "./seek.js";
17
- import { testRtl } from "./text.js";
17
+ import { testJoiningScript, testRtl } from "./text.js";
18
18
  import { registerThemeSetting } from "./themeSettings.js";
19
19
  export let disableRichsync = registerThemeSetting("blyrics-disable-richsync", false, true);
20
20
  let lineSyncedAnimationDelay = registerThemeSetting("blyrics-line-synced-animation-delay", 50, true);
@@ -23,7 +23,6 @@ let longWordWrapThreshold = registerThemeSetting("blyrics-long-word-wrap-thresho
23
23
  let letterWave = registerThemeSetting("blyrics-letter-wave", true, true);
24
24
  export const hideCredits = registerThemeSetting("blyrics-hide-credits", false, true);
25
25
  const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
26
- const RTL_SCRIPT_REGEX = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}]/u;
27
26
  const LTR_SCRIPT_REGEX = /[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Han}\p{Script=Hangul}\p{Script=Hiragana}\p{Script=Katakana}]/u;
28
27
  const SPACE_REGEX = /^\s+$/u;
29
28
  export function findNearestAgent(lyrics, fromIndex) {
@@ -97,7 +96,7 @@ export function newLineData(lyricElement, startTimeMs, durationMs) {
97
96
  }
98
97
  function detectDirection(text) {
99
98
  for (const char of text) {
100
- if (RTL_SCRIPT_REGEX.test(char))
99
+ if (testRtl(char))
101
100
  return "rtl";
102
101
  if (LTR_SCRIPT_REGEX.test(char))
103
102
  return "ltr";
@@ -238,7 +237,7 @@ function createTimedWordSpan(doc, part, wrapThreshold, perLetter) {
238
237
  wordElement.classList.add(BACKGROUND_LYRIC_CLASS);
239
238
  if (part.explicit)
240
239
  wordElement.classList.add(EXPLICIT_WORD_CLASS);
241
- if (perLetter) {
240
+ if (perLetter && !testJoiningScript(part.words)) {
242
241
  const collected = appendLetters(doc, wordElement, part.words);
243
242
  if (wordElement === span) {
244
243
  letters = collected;
package/dist/text.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const testRtl: (text: string) => boolean;
2
+ export declare const testJoiningScript: (text: string) => boolean;
2
3
  /**
3
4
  * Checks if a given string contains any non-Latin characters.
4
5
  * @param text The string to check.
package/dist/text.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Script detection for the text the module renders. Pure string work, no DOM and no host state.
2
- export const testRtl = (text) => /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}]/u.test(text);
2
+ export const testRtl = (text) => /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}\p{Script=Samaritan}\p{Script=Yezidi}\p{Script=Mende_Kikakui}\p{Script=Old_Hungarian}]/u.test(text);
3
+ export const testJoiningScript = (text) => /[\p{Script_Extensions=Arabic}\p{Script_Extensions=Syriac}\p{Script_Extensions=Nko}\p{Script_Extensions=Mongolian}\p{Script_Extensions=Adlam}\p{Script_Extensions=Mandaic}\p{Script_Extensions=Hanifi_Rohingya}]/u.test(text);
3
4
  /**
4
5
  * This regex is designed to detect any characters that are outside of the
5
6
  * standard "Basic Latin" and "Latin-1 Supplement" Unicode blocks, as well
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braccato/core",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "Synchronized lyrics renderer with word-by-word animations",
5
5
  "type": "module",
6
6
  "license": "MIT",