@braccato/core 1.9.0 → 1.11.0

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/README.md CHANGED
@@ -7,6 +7,9 @@ than a shadow root, so the CSS already on your page reaches them.
7
7
  Extracted from the [Better Lyrics](https://better-lyrics.boidu.dev) rendering engine, which is still
8
8
  where it runs.
9
9
 
10
+ The [renderer guide](https://docs.betterlyrics.org/braccato/renderer) on the docs site covers properties, events,
11
+ scrolling and theming with lyrics from the Better Lyrics API. This README is still the full reference.
12
+
10
13
  ## Install
11
14
 
12
15
  ```bash
@@ -150,6 +153,20 @@ stylesheet must not be able to configure the module by accident. An empty theme
150
153
  back to its default. The stylesheet itself goes into the document head under the
151
154
  `blyrics-custom-style` id.
152
155
 
156
+ A comment setting holds one value for every view in the bundle. The target scroll position can
157
+ also be set per view: when `--blyrics-target-scroll-pos-ratio` resolves on `.blyrics-container`, it
158
+ wins over `blyrics-target-scroll-pos-ratio`, so an ordinary selector scopes it to one view. It takes
159
+ a unitless number, clamped to `0` to `1`; anything else falls back to the comment setting. Like the
160
+ other custom properties the module reads, it is read once per theme, so the selector has to match
161
+ before the theme is applied.
162
+
163
+ ```css
164
+ /* blyrics-target-scroll-pos-ratio = 0.5; */
165
+ .pip-view .blyrics-container {
166
+ --blyrics-target-scroll-pos-ratio: 0.37;
167
+ }
168
+ ```
169
+
153
170
  ### Autoscroll grouping and animation
154
171
 
155
172
  `blyrics-early-scroll-consider-s` is a comment setting with an independent default of `0.54`
@@ -278,6 +295,7 @@ refactor. Import them from `@braccato/core/constants` instead of typing them out
278
295
  | `BACKGROUND_LYRIC_CLASS` | `blyrics-background-lyric` | A background vocal, sung over the line it answers. |
279
296
  | `USER_SCROLLING_CLASS` | `blyrics-user-scrolling` | Set while a reader has scrolled away and autoscroll waits. |
280
297
  | `TRANSLATED_LYRICS_CLASS` | `blyrics--translated` | A translation hung off a line that was already built. |
298
+ | `EXPLICIT_WORD_CLASS` | `blyrics-explicit` | A word the lyrics flag as explicit. Unstyled unless a theme styles it. |
281
299
  | `CUSTOM_THEME_STYLE_ID` | `blyrics-custom-style` | The id of the `<style>` the theme lands in. |
282
300
 
283
301
  ## Stylesheets
package/dist/README.md CHANGED
@@ -7,6 +7,9 @@ than a shadow root, so the CSS already on your page reaches them.
7
7
  Extracted from the [Better Lyrics](https://better-lyrics.boidu.dev) rendering engine, which is still
8
8
  where it runs.
9
9
 
10
+ The [renderer guide](https://docs.betterlyrics.org/braccato/renderer) on the docs site covers properties, events,
11
+ scrolling and theming with lyrics from the Better Lyrics API. This README is still the full reference.
12
+
10
13
  ## Install
11
14
 
12
15
  ```bash
@@ -150,6 +153,20 @@ stylesheet must not be able to configure the module by accident. An empty theme
150
153
  back to its default. The stylesheet itself goes into the document head under the
151
154
  `blyrics-custom-style` id.
152
155
 
156
+ A comment setting holds one value for every view in the bundle. The target scroll position can
157
+ also be set per view: when `--blyrics-target-scroll-pos-ratio` resolves on `.blyrics-container`, it
158
+ wins over `blyrics-target-scroll-pos-ratio`, so an ordinary selector scopes it to one view. It takes
159
+ a unitless number, clamped to `0` to `1`; anything else falls back to the comment setting. Like the
160
+ other custom properties the module reads, it is read once per theme, so the selector has to match
161
+ before the theme is applied.
162
+
163
+ ```css
164
+ /* blyrics-target-scroll-pos-ratio = 0.5; */
165
+ .pip-view .blyrics-container {
166
+ --blyrics-target-scroll-pos-ratio: 0.37;
167
+ }
168
+ ```
169
+
153
170
  ### Autoscroll grouping and animation
154
171
 
155
172
  `blyrics-early-scroll-consider-s` is a comment setting with an independent default of `0.54`
@@ -278,6 +295,7 @@ refactor. Import them from `@braccato/core/constants` instead of typing them out
278
295
  | `BACKGROUND_LYRIC_CLASS` | `blyrics-background-lyric` | A background vocal, sung over the line it answers. |
279
296
  | `USER_SCROLLING_CLASS` | `blyrics-user-scrolling` | Set while a reader has scrolled away and autoscroll waits. |
280
297
  | `TRANSLATED_LYRICS_CLASS` | `blyrics--translated` | A translation hung off a line that was already built. |
298
+ | `EXPLICIT_WORD_CLASS` | `blyrics-explicit` | A word the lyrics flag as explicit. Unstyled unless a theme styles it. |
281
299
  | `CUSTOM_THEME_STYLE_ID` | `blyrics-custom-style` | The id of the `<style>` the theme lands in. |
282
300
 
283
301
  ## Stylesheets
package/dist/engine.js CHANGED
@@ -1116,6 +1116,11 @@ function getCSSBoolean(engine, lyricsElement, property, fallback) {
1116
1116
  function getCSSOffset(engine, lyricsElement, property, fallback) {
1117
1117
  return Math.max(0, Math.min(1, getCSSNumber(engine, lyricsElement, property, fallback)));
1118
1118
  }
1119
+ // The comment setting is shared by every view in a bundle; the custom property lets a theme scope it to one.
1120
+ function getTargetScrollRatio(engine, lyricsElement) {
1121
+ const scoped = Number.parseFloat(getCSSValue(engine, lyricsElement, "--blyrics-target-scroll-pos-ratio", ""));
1122
+ return Number.isFinite(scoped) ? Math.max(0, Math.min(1, scoped)) : SCROLL_POS_OFFSET_RATIO.getNumberValue();
1123
+ }
1119
1124
  // Compose the glow filter so the color stays an unresolved var(--blyrics-glow-color).
1120
1125
  // Reading a fully composed --blyrics-highlight-glow-filter-* off the container resolves the
1121
1126
  // nested color there, which would defeat per-word overrides like
@@ -1989,7 +1994,7 @@ export function tickView(engine, currentTime, options) {
1989
1994
  activeElems.push(lines[0]);
1990
1995
  }
1991
1996
  // Offset so lyrics appear towards the center of the screen.
1992
- const scrollPosOffset = tabRendererHeight * SCROLL_POS_OFFSET_RATIO.getNumberValue();
1997
+ const scrollPosOffset = tabRendererHeight * getTargetScrollRatio(engine, lyricsElement);
1993
1998
  let lastActiveLyric = activeElems[activeElems.length - 1];
1994
1999
  let lyricPositions = activeElems
1995
2000
  .filter((lineData, index) => {
@@ -2172,7 +2177,7 @@ function applyScrollPadding(engine) {
2172
2177
  if (!lyricsElement || !tabRenderer)
2173
2178
  return;
2174
2179
  const tabRendererHeight = tabRenderer.getBoundingClientRect().height;
2175
- const scrollPosOffsetRatio = SCROLL_POS_OFFSET_RATIO.getNumberValue();
2180
+ const scrollPosOffsetRatio = getTargetScrollRatio(engine, lyricsElement);
2176
2181
  const currentPaddingBottom = Number.parseFloat(engine.window.getComputedStyle(lyricsElement).paddingBottom) || 0;
2177
2182
  const lyricsHeightWithoutBottomPadding = Math.max(0, lyricsElement.scrollHeight - currentPaddingBottom);
2178
2183
  const lyricLines = lyricsElement.querySelectorAll(`:scope > .${LINE_CLASS}`);
@@ -215,11 +215,6 @@
215
215
  color: color-mix(in srgb, var(--blyrics-lyric-inactive-color) 78%, transparent);
216
216
  }
217
217
 
218
- .blyrics-explicit {
219
- text-decoration: line-through;
220
- text-decoration-thickness: 0.08em;
221
- }
222
-
223
218
  .blyrics--translated,
224
219
  .blyrics--romanized {
225
220
  animation: blyrics-decoration-in calc(var(--blyrics-animate-decoration-entry) * 0.35s)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braccato/core",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "Synchronized lyrics renderer with word-by-word animations",
5
5
  "type": "module",
6
6
  "license": "MIT",