@braccato/core 1.20.0 → 1.21.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.
Files changed (85) hide show
  1. package/README.md +40 -37
  2. package/dist/README.md +40 -37
  3. package/dist/constants.d.ts +10 -0
  4. package/dist/constants.js +10 -0
  5. package/dist/engine/animationConfig.d.ts +83 -0
  6. package/dist/engine/animationConfig.js +93 -0
  7. package/dist/engine/animationDrift.d.ts +11 -0
  8. package/dist/engine/animationDrift.js +43 -0
  9. package/dist/engine/animationTiming.d.ts +26 -0
  10. package/dist/engine/animationTiming.js +120 -0
  11. package/dist/engine/autoScroll.d.ts +24 -0
  12. package/dist/engine/autoScroll.js +103 -0
  13. package/dist/engine/clock.d.ts +29 -0
  14. package/dist/engine/clock.js +70 -0
  15. package/dist/engine/contextSweep.d.ts +10 -0
  16. package/dist/engine/contextSweep.js +102 -0
  17. package/dist/engine/cssValues.d.ts +13 -0
  18. package/dist/engine/cssValues.js +47 -0
  19. package/dist/engine/culling.d.ts +6 -0
  20. package/dist/engine/culling.js +76 -0
  21. package/dist/engine/debugOverlay.d.ts +14 -0
  22. package/dist/engine/debugOverlay.js +58 -0
  23. package/dist/engine/decorationSlides.d.ts +6 -0
  24. package/dist/engine/decorationSlides.js +53 -0
  25. package/dist/engine/elementMotion.d.ts +17 -0
  26. package/dist/engine/elementMotion.js +98 -0
  27. package/dist/engine/glow.d.ts +7 -0
  28. package/dist/engine/glow.js +59 -0
  29. package/dist/engine/instance.d.ts +105 -0
  30. package/dist/engine/instance.js +89 -0
  31. package/dist/engine/instrumentalAnimations.d.ts +7 -0
  32. package/dist/engine/instrumentalAnimations.js +59 -0
  33. package/dist/engine/letterPlans.d.ts +31 -0
  34. package/dist/engine/letterPlans.js +62 -0
  35. package/dist/engine/lineAnimationState.d.ts +10 -0
  36. package/dist/engine/lineAnimationState.js +82 -0
  37. package/dist/engine/lineAnimations.d.ts +5 -0
  38. package/dist/engine/lineAnimations.js +63 -0
  39. package/dist/engine/lineLifecycle.d.ts +12 -0
  40. package/dist/engine/lineLifecycle.js +92 -0
  41. package/dist/engine/lineScroll.d.ts +47 -0
  42. package/dist/engine/lineScroll.js +184 -0
  43. package/dist/engine/lineScrollStyle.d.ts +32 -0
  44. package/dist/engine/lineScrollStyle.js +133 -0
  45. package/dist/engine/liveViews.d.ts +3 -0
  46. package/dist/engine/liveViews.js +5 -0
  47. package/dist/engine/motionCurves.d.ts +19 -0
  48. package/dist/engine/motionCurves.js +85 -0
  49. package/dist/engine/motionPreference.d.ts +1 -0
  50. package/dist/engine/motionPreference.js +1 -0
  51. package/dist/engine/passiveScroll.d.ts +10 -0
  52. package/dist/engine/passiveScroll.js +93 -0
  53. package/dist/engine/renderedLines.d.ts +16 -0
  54. package/dist/engine/renderedLines.js +130 -0
  55. package/dist/engine/scrollViewport.d.ts +36 -0
  56. package/dist/engine/scrollViewport.js +104 -0
  57. package/dist/engine/stageMotion.d.ts +7 -0
  58. package/dist/engine/stageMotion.js +319 -0
  59. package/dist/engine/sweepPlans.d.ts +36 -0
  60. package/dist/engine/sweepPlans.js +59 -0
  61. package/dist/engine/tick.d.ts +16 -0
  62. package/dist/engine/tick.js +270 -0
  63. package/dist/engine/timingLogs.d.ts +7 -0
  64. package/dist/engine/timingLogs.js +81 -0
  65. package/dist/engine/userScroll.d.ts +12 -0
  66. package/dist/engine/userScroll.js +62 -0
  67. package/dist/engine/wavePool.d.ts +7 -0
  68. package/dist/engine/wavePool.js +22 -0
  69. package/dist/engine/wordAnimations.d.ts +5 -0
  70. package/dist/engine/wordAnimations.js +238 -0
  71. package/dist/imageHighlights.d.ts +0 -11
  72. package/dist/imageHighlights.js +2 -48
  73. package/dist/index.d.ts +3 -2
  74. package/dist/index.js +2 -1
  75. package/dist/inject.d.ts +41 -2
  76. package/dist/inject.js +73 -28
  77. package/dist/renderer.js +10 -3
  78. package/dist/styles/image-highlights.css +1 -59
  79. package/dist/styles/lyrics.css +128 -57
  80. package/dist/types.d.ts +1 -1
  81. package/dist/view.d.ts +2 -2
  82. package/dist/view.js +7 -3
  83. package/package.json +1 -1
  84. package/dist/engine.d.ts +0 -471
  85. package/dist/engine.js +0 -3133
package/README.md CHANGED
@@ -239,9 +239,12 @@ resuming autoscroll and relayout can still reposition the view.
239
239
  /* blyrics-line-scroll-duration = 750ms; */
240
240
  ```
241
241
 
242
- New groups scroll immediately. Previous per-line `translate` animations continue and compose
243
- additively, so their duration does not block the next scroll. The line-scroll duration knobs
244
- control visual motion. The legacy `--blyrics-lyric-scroll-duration` variable and its
242
+ New groups scroll immediately. A line still moving from an earlier scroll keeps that motion: what
243
+ is left of it and the new scroll are added together into one `translate` animation, so their
244
+ durations do not block the next scroll and the browser can run the motion off the main thread.
245
+ Decoration slides join the same animation. While a line scrolls or slides, that animation replaces
246
+ any `translate` a theme sets on the line itself. The line-scroll duration knobs control visual
247
+ motion. The legacy `--blyrics-lyric-scroll-duration` variable and its
245
248
  `--blyrics-lyric-transition-duration` alias have been removed, along with the container transform
246
249
  transition. `blyrics-queue-scroll-ms` is ignored, and no timing equation needs balancing.
247
250
  Missing or invalid line durations fall back to an internal `750ms` duration; nonpositive resolved
@@ -281,6 +284,27 @@ The ones a theme reaches for first. `variables.css` declares the rest.
281
284
  `line-height`. Every word is given the glow, so a theme that wants it to mean something selects on
282
285
  `data-long-word`, which the module sets on any part held past `blyrics-long-word-threshold`.
283
286
 
287
+ The sweep and the glow run off the main thread. Each word, or each letter of a word that wraps, holds
288
+ a fixed soft-edged mask over a copy of its text in `--blyrics-lyric-active-color`, and the two slide
289
+ against each other so only the edge moves. A word in a joining script, or one mixing directions, is
290
+ drawn from copies of its line placed over each box it breaks into. The swipe stops
291
+ (`--blyrics-highlight-swipe-*`) set where the edge starts and ends, and the soft edge is as wide as the
292
+ swipe's last start and end stops are apart. The glow is two copies of the word inside the same mask,
293
+ with a `text-shadow` of `--blyrics-highlight-glow-radius-from` and a tighter one in
294
+ `--blyrics-glow-color`, crossfaded as it fades; it starts where the edge reaches the word or letter,
295
+ and the `--blyrics-highlight-glow-filter-*` overrides are not read.
296
+ `--lyric-transition-amount-*` no longer animate, so a theme cannot draw its own sweep from them.
297
+
298
+ A word longer than twice `blyrics-long-word-wrap-threshold` (default `10` characters) gets
299
+ `blyrics-word-group-long` on its group. Its syllables become `display: inline` and take `<wbr>`
300
+ break points, so a word like `Oh-oh-oh-oh-oh-oh-oh-oh` wraps instead of overflowing. Browsers ignore
301
+ `transform` on inline boxes, so a per-syllable animation and the word wobble both stop on those
302
+ words. Raising `blyrics-long-word-wrap-threshold` (say to `1000`) brings both back, but then a word
303
+ wider than the view overflows instead of wrapping. To keep the wrap, set
304
+ `.blyrics-word-group-long .blyrics--word:not(.blyrics-bidi-sensitive *)` back to `display: inline-block`.
305
+ The syllables still wrap between each other and per-syllable animations return. The wobble stays off,
306
+ since it moves the group and the group is still inline.
307
+
284
308
  The instrumental ripple is the one place a property carries geometry rather than a value.
285
309
  `--blyrics-instrumental-wave-path-high` and `--blyrics-instrumental-wave-path-low` are the two shapes
286
310
  it morphs between, each a `path()`, and a theme redrawing them is how the wave changes amplitude or
@@ -333,8 +357,8 @@ swells each letter with a transient scale at the crest.
333
357
  }
334
358
  ```
335
359
 
336
- The split multiplies the DOM per character and reruns the karaoke sweep per letter, so a theme that
337
- does not want the cost turns it off with `/* blyrics-letter-wave = false; */`. `blyrics-letter-wave`
360
+ The split multiplies the DOM per character, three times over with the glow's two copies, so a theme
361
+ that does not want the cost turns it off with `/* blyrics-letter-wave = false; */`. `blyrics-letter-wave`
338
362
  reloads the lines when it changes, the way every build-time setting does.
339
363
 
340
364
  ### Word state
@@ -405,6 +429,7 @@ refactor. Import them from `@braccato/core/constants` instead of typing them out
405
429
  | `BACKGROUND_LYRIC_CLASS` | `blyrics-background-lyric` | A background vocal, sung over the line it answers. |
406
430
  | `USER_SCROLLING_CLASS` | `blyrics-user-scrolling` | Set while a reader has scrolled away and autoscroll waits. |
407
431
  | `TRANSLATED_LYRICS_CLASS` | `blyrics--translated` | A translation hung off a line that was already built. |
432
+ | `LONG_WORD_GROUP_CLASS` | `blyrics-word-group-long` | A word longer than twice `blyrics-long-word-wrap-threshold`. Its syllables go inline so it can wrap, and browsers ignore `transform` on inline boxes. |
408
433
  | `EXPLICIT_WORD_CLASS` | `blyrics-explicit` | A word the lyrics flag as explicit. Unstyled unless a theme styles it. |
409
434
  | `CREDITS_CLASS` | `blyrics-credits` | The songwriter credits after the last line. |
410
435
  | `CUSTOM_THEME_STYLE_ID` | `blyrics-custom-style` | The id of the `<style>` the theme lands in. |
@@ -417,7 +442,7 @@ them out and you get lines that are in the document and unstyled, rather than li
417
442
  | File | What it carries |
418
443
  | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
419
444
  | `@braccato/core/styles/variables.css` | Every `--blyrics-*` default. It goes first, because the others read from it. |
420
- | `@braccato/core/styles/lyrics.css` | The container, the lines, the words and the sweep, plus two `@property` registrations the word animation interpolates through. |
445
+ | `@braccato/core/styles/lyrics.css` | The container, the lines, the words and the sweep. |
421
446
  | `@braccato/core/styles/instrumental.css` | The waveform that fills a bar nobody sings over, and the animation that walks it. |
422
447
  | `@braccato/core/styles/stage.css` | Placement for the stage layout, and nothing else. Only a renderer created with `layout: "stage"` needs it. |
423
448
 
@@ -587,43 +612,21 @@ loading regional CJK web fonts should set `--noto-sans-universal` on these eleme
587
612
  They are unset by default; custom CSS that reads them directly should use
588
613
  `var(--blyrics-font-family, var(--blyrics-default-font-family))` for the default stack.
589
614
 
590
- ### Theme-provided image fills
615
+ ### Theme-provided instrumental image
591
616
 
592
- Image highlights are optional. Enable them in a theme comment:
617
+ A theme can paint the instrumental note with an image. Enable it in a theme comment:
593
618
 
594
619
  ```css
595
620
  /* blyrics-image-highlights = true; */
596
621
  .blyrics-container {
597
622
  --blyrics-highlight-image: url("my-image.jpg");
598
- --blyrics-image-glow-opacity-from: 0.5;
599
- --blyrics-image-glow-opacity-to: 0;
600
623
  }
601
624
  ```
602
625
 
603
- Changing this setting requests a lyric rebuild through the existing `setTheme` return value.
604
- Without it, the renderer adds no image or glow layers and keeps its shadow animation. With it,
605
- the sharp fill and a separate blurred copy share the word reveal, letter motion, opacity, pause,
606
- seek and playback-rate handling. Existing glow radius, duration and easing properties still apply;
607
- the two image-glow opacity properties replace the solid shadow color's alpha.
608
-
609
- The image may be an SDR texture or an HDR gain-map asset. The theme owns HDR media queries
610
- and `dynamic-range-limit`; the core never opts into extra display brightness. Ordinary active
611
- text color backs up the image fill, while the note keeps its original color path until its
612
- SVG image loads. The note image reuses the original animated wave clip and fade group.
613
-
614
- The glow layer is outside the paint's mask, avoiding clipped halos at word edges. Bidi-sensitive
615
- runs and fragmented long words use a parallel inline text run for the glow, so the browser
616
- reproduces the same ordering and wrapped fragments. Its reveal and visibility use the same
617
- animation clock as the sharp text. No generated text or per-frame geometry reads are needed.
618
- Joining-script word groups retain contextual joining by using whole-word sweeps instead of
619
- inline-block letter waves, including when image highlights are disabled.
620
- Forced colors suppress the image and halo in favor of system text colors.
621
-
622
- For real-browser regression checks, build the package, serve the repository root and open
623
- `tooling/browser/image-highlights.html`. Import `image-highlights-checks.js` from that page and
624
- call `runImageHighlightChecks(testView)`. The default fixture uses an SDR image; a `theme` query
625
- parameter can point at a consumer's HDR stylesheet for physical-display testing.
626
- `runLetterInkChecks(testView)` in the same module checks that letter masks cover glyph overhang,
627
- such as a `j`'s hook or an italic `f`, without moving any letter.
628
-
629
- Words that mix RTL characters with LTR letters or numbers retain native text shaping instead of per-letter motion. Image glow, letter masks and letter motion retain their current paint during the line exit fade.
626
+ Changing this setting requests a lyric rebuild through the existing `setTheme` return value. The
627
+ image may be an SDR texture or an HDR gain-map asset. The theme owns HDR media queries and
628
+ `dynamic-range-limit`; the core never opts into extra display brightness. The note keeps its original
629
+ color path until its SVG image loads, reuses the original animated wave clip and fade group, and
630
+ forced colors fall back to system colors. Words no longer take an image fill.
631
+
632
+ Words that mix RTL characters with LTR letters or numbers retain native text shaping instead of per-letter motion.
package/dist/README.md CHANGED
@@ -239,9 +239,12 @@ resuming autoscroll and relayout can still reposition the view.
239
239
  /* blyrics-line-scroll-duration = 750ms; */
240
240
  ```
241
241
 
242
- New groups scroll immediately. Previous per-line `translate` animations continue and compose
243
- additively, so their duration does not block the next scroll. The line-scroll duration knobs
244
- control visual motion. The legacy `--blyrics-lyric-scroll-duration` variable and its
242
+ New groups scroll immediately. A line still moving from an earlier scroll keeps that motion: what
243
+ is left of it and the new scroll are added together into one `translate` animation, so their
244
+ durations do not block the next scroll and the browser can run the motion off the main thread.
245
+ Decoration slides join the same animation. While a line scrolls or slides, that animation replaces
246
+ any `translate` a theme sets on the line itself. The line-scroll duration knobs control visual
247
+ motion. The legacy `--blyrics-lyric-scroll-duration` variable and its
245
248
  `--blyrics-lyric-transition-duration` alias have been removed, along with the container transform
246
249
  transition. `blyrics-queue-scroll-ms` is ignored, and no timing equation needs balancing.
247
250
  Missing or invalid line durations fall back to an internal `750ms` duration; nonpositive resolved
@@ -281,6 +284,27 @@ The ones a theme reaches for first. `variables.css` declares the rest.
281
284
  `line-height`. Every word is given the glow, so a theme that wants it to mean something selects on
282
285
  `data-long-word`, which the module sets on any part held past `blyrics-long-word-threshold`.
283
286
 
287
+ The sweep and the glow run off the main thread. Each word, or each letter of a word that wraps, holds
288
+ a fixed soft-edged mask over a copy of its text in `--blyrics-lyric-active-color`, and the two slide
289
+ against each other so only the edge moves. A word in a joining script, or one mixing directions, is
290
+ drawn from copies of its line placed over each box it breaks into. The swipe stops
291
+ (`--blyrics-highlight-swipe-*`) set where the edge starts and ends, and the soft edge is as wide as the
292
+ swipe's last start and end stops are apart. The glow is two copies of the word inside the same mask,
293
+ with a `text-shadow` of `--blyrics-highlight-glow-radius-from` and a tighter one in
294
+ `--blyrics-glow-color`, crossfaded as it fades; it starts where the edge reaches the word or letter,
295
+ and the `--blyrics-highlight-glow-filter-*` overrides are not read.
296
+ `--lyric-transition-amount-*` no longer animate, so a theme cannot draw its own sweep from them.
297
+
298
+ A word longer than twice `blyrics-long-word-wrap-threshold` (default `10` characters) gets
299
+ `blyrics-word-group-long` on its group. Its syllables become `display: inline` and take `<wbr>`
300
+ break points, so a word like `Oh-oh-oh-oh-oh-oh-oh-oh` wraps instead of overflowing. Browsers ignore
301
+ `transform` on inline boxes, so a per-syllable animation and the word wobble both stop on those
302
+ words. Raising `blyrics-long-word-wrap-threshold` (say to `1000`) brings both back, but then a word
303
+ wider than the view overflows instead of wrapping. To keep the wrap, set
304
+ `.blyrics-word-group-long .blyrics--word:not(.blyrics-bidi-sensitive *)` back to `display: inline-block`.
305
+ The syllables still wrap between each other and per-syllable animations return. The wobble stays off,
306
+ since it moves the group and the group is still inline.
307
+
284
308
  The instrumental ripple is the one place a property carries geometry rather than a value.
285
309
  `--blyrics-instrumental-wave-path-high` and `--blyrics-instrumental-wave-path-low` are the two shapes
286
310
  it morphs between, each a `path()`, and a theme redrawing them is how the wave changes amplitude or
@@ -333,8 +357,8 @@ swells each letter with a transient scale at the crest.
333
357
  }
334
358
  ```
335
359
 
336
- The split multiplies the DOM per character and reruns the karaoke sweep per letter, so a theme that
337
- does not want the cost turns it off with `/* blyrics-letter-wave = false; */`. `blyrics-letter-wave`
360
+ The split multiplies the DOM per character, three times over with the glow's two copies, so a theme
361
+ that does not want the cost turns it off with `/* blyrics-letter-wave = false; */`. `blyrics-letter-wave`
338
362
  reloads the lines when it changes, the way every build-time setting does.
339
363
 
340
364
  ### Word state
@@ -405,6 +429,7 @@ refactor. Import them from `@braccato/core/constants` instead of typing them out
405
429
  | `BACKGROUND_LYRIC_CLASS` | `blyrics-background-lyric` | A background vocal, sung over the line it answers. |
406
430
  | `USER_SCROLLING_CLASS` | `blyrics-user-scrolling` | Set while a reader has scrolled away and autoscroll waits. |
407
431
  | `TRANSLATED_LYRICS_CLASS` | `blyrics--translated` | A translation hung off a line that was already built. |
432
+ | `LONG_WORD_GROUP_CLASS` | `blyrics-word-group-long` | A word longer than twice `blyrics-long-word-wrap-threshold`. Its syllables go inline so it can wrap, and browsers ignore `transform` on inline boxes. |
408
433
  | `EXPLICIT_WORD_CLASS` | `blyrics-explicit` | A word the lyrics flag as explicit. Unstyled unless a theme styles it. |
409
434
  | `CREDITS_CLASS` | `blyrics-credits` | The songwriter credits after the last line. |
410
435
  | `CUSTOM_THEME_STYLE_ID` | `blyrics-custom-style` | The id of the `<style>` the theme lands in. |
@@ -417,7 +442,7 @@ them out and you get lines that are in the document and unstyled, rather than li
417
442
  | File | What it carries |
418
443
  | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
419
444
  | `@braccato/core/styles/variables.css` | Every `--blyrics-*` default. It goes first, because the others read from it. |
420
- | `@braccato/core/styles/lyrics.css` | The container, the lines, the words and the sweep, plus two `@property` registrations the word animation interpolates through. |
445
+ | `@braccato/core/styles/lyrics.css` | The container, the lines, the words and the sweep. |
421
446
  | `@braccato/core/styles/instrumental.css` | The waveform that fills a bar nobody sings over, and the animation that walks it. |
422
447
  | `@braccato/core/styles/stage.css` | Placement for the stage layout, and nothing else. Only a renderer created with `layout: "stage"` needs it. |
423
448
 
@@ -587,43 +612,21 @@ loading regional CJK web fonts should set `--noto-sans-universal` on these eleme
587
612
  They are unset by default; custom CSS that reads them directly should use
588
613
  `var(--blyrics-font-family, var(--blyrics-default-font-family))` for the default stack.
589
614
 
590
- ### Theme-provided image fills
615
+ ### Theme-provided instrumental image
591
616
 
592
- Image highlights are optional. Enable them in a theme comment:
617
+ A theme can paint the instrumental note with an image. Enable it in a theme comment:
593
618
 
594
619
  ```css
595
620
  /* blyrics-image-highlights = true; */
596
621
  .blyrics-container {
597
622
  --blyrics-highlight-image: url("my-image.jpg");
598
- --blyrics-image-glow-opacity-from: 0.5;
599
- --blyrics-image-glow-opacity-to: 0;
600
623
  }
601
624
  ```
602
625
 
603
- Changing this setting requests a lyric rebuild through the existing `setTheme` return value.
604
- Without it, the renderer adds no image or glow layers and keeps its shadow animation. With it,
605
- the sharp fill and a separate blurred copy share the word reveal, letter motion, opacity, pause,
606
- seek and playback-rate handling. Existing glow radius, duration and easing properties still apply;
607
- the two image-glow opacity properties replace the solid shadow color's alpha.
608
-
609
- The image may be an SDR texture or an HDR gain-map asset. The theme owns HDR media queries
610
- and `dynamic-range-limit`; the core never opts into extra display brightness. Ordinary active
611
- text color backs up the image fill, while the note keeps its original color path until its
612
- SVG image loads. The note image reuses the original animated wave clip and fade group.
613
-
614
- The glow layer is outside the paint's mask, avoiding clipped halos at word edges. Bidi-sensitive
615
- runs and fragmented long words use a parallel inline text run for the glow, so the browser
616
- reproduces the same ordering and wrapped fragments. Its reveal and visibility use the same
617
- animation clock as the sharp text. No generated text or per-frame geometry reads are needed.
618
- Joining-script word groups retain contextual joining by using whole-word sweeps instead of
619
- inline-block letter waves, including when image highlights are disabled.
620
- Forced colors suppress the image and halo in favor of system text colors.
621
-
622
- For real-browser regression checks, build the package, serve the repository root and open
623
- `tooling/browser/image-highlights.html`. Import `image-highlights-checks.js` from that page and
624
- call `runImageHighlightChecks(testView)`. The default fixture uses an SDR image; a `theme` query
625
- parameter can point at a consumer's HDR stylesheet for physical-display testing.
626
- `runLetterInkChecks(testView)` in the same module checks that letter masks cover glyph overhang,
627
- such as a `j`'s hook or an italic `f`, without moving any letter.
628
-
629
- Words that mix RTL characters with LTR letters or numbers retain native text shaping instead of per-letter motion. Image glow, letter masks and letter motion retain their current paint during the line exit fade.
626
+ Changing this setting requests a lyric rebuild through the existing `setTheme` return value. The
627
+ image may be an SDR texture or an HDR gain-map asset. The theme owns HDR media queries and
628
+ `dynamic-range-limit`; the core never opts into extra display brightness. The note keeps its original
629
+ color path until its SVG image loads, reuses the original animated wave clip and fade group, and
630
+ forced colors fall back to system colors. Words no longer take an image fill.
631
+
632
+ Words that mix RTL characters with LTR letters or numbers retain native text shaping instead of per-letter motion.
@@ -29,6 +29,16 @@ export declare const WORD_GROUP_CLASS: "blyrics-word-group";
29
29
  export declare const LONG_WORD_GROUP_CLASS: "blyrics-word-group-long";
30
30
  export declare const WORD_HIGHLIGHT_CLASS: "blyrics-word-highlight";
31
31
  export declare const WORD_HIGHLIGHT_LETTERED_CLASS: "blyrics-word-highlight--lettered";
32
+ export declare const WORD_HIGHLIGHT_SWEEP_CLASS: "blyrics-word-highlight--sweep";
33
+ export declare const WORD_HIGHLIGHT_CONTEXT_CLASS: "blyrics-word-highlight--context";
34
+ export declare const SWEEP_CELL_CLASS: "blyrics-sweep-cell";
35
+ export declare const SWEEP_CONTEXT_CLASS: "blyrics-sweep-context";
36
+ export declare const SWEEP_WINDOW_CLASS: "blyrics-sweep-window";
37
+ export declare const SWEEP_CLONE_CLASS: "blyrics-sweep-clone";
38
+ export declare const SWEEP_TARGET_CLASS: "blyrics-sweep-target";
39
+ export declare const SWEEP_MASK_CLASS: "blyrics-sweep-mask";
40
+ export declare const SWEEP_TEXT_CLASS: "blyrics-sweep-text";
41
+ export declare const SWEEP_GLOW_CLASS: "blyrics-sweep-glow";
32
42
  export declare const HIGHLIGHT_RUN_CLASS: "blyrics-highlight-run";
33
43
  export declare const LINE_SYNCED_WORD_CLASS: "blyrics-line-synced-word";
34
44
  export declare const BIDI_RUN_CLASS: "blyrics-bidi-run";
package/dist/constants.js CHANGED
@@ -34,6 +34,16 @@ export const WORD_GROUP_CLASS = "blyrics-word-group";
34
34
  export const LONG_WORD_GROUP_CLASS = "blyrics-word-group-long";
35
35
  export const WORD_HIGHLIGHT_CLASS = "blyrics-word-highlight";
36
36
  export const WORD_HIGHLIGHT_LETTERED_CLASS = "blyrics-word-highlight--lettered";
37
+ export const WORD_HIGHLIGHT_SWEEP_CLASS = "blyrics-word-highlight--sweep";
38
+ export const WORD_HIGHLIGHT_CONTEXT_CLASS = "blyrics-word-highlight--context";
39
+ export const SWEEP_CELL_CLASS = "blyrics-sweep-cell";
40
+ export const SWEEP_CONTEXT_CLASS = "blyrics-sweep-context";
41
+ export const SWEEP_WINDOW_CLASS = "blyrics-sweep-window";
42
+ export const SWEEP_CLONE_CLASS = "blyrics-sweep-clone";
43
+ export const SWEEP_TARGET_CLASS = "blyrics-sweep-target";
44
+ export const SWEEP_MASK_CLASS = "blyrics-sweep-mask";
45
+ export const SWEEP_TEXT_CLASS = "blyrics-sweep-text";
46
+ export const SWEEP_GLOW_CLASS = "blyrics-sweep-glow";
37
47
  export const HIGHLIGHT_RUN_CLASS = "blyrics-highlight-run";
38
48
  export const LINE_SYNCED_WORD_CLASS = "blyrics-line-synced-word";
39
49
  export const BIDI_RUN_CLASS = "blyrics-bidi-run";
@@ -0,0 +1,83 @@
1
+ import type { AnimationEngineInstance } from "./instance.js";
2
+ export interface AnimationConfig {
3
+ enabled: {
4
+ lineScale: boolean;
5
+ wordWobble: boolean;
6
+ highlightSwipe: boolean;
7
+ highlightGlow: boolean;
8
+ highlightFade: boolean;
9
+ scroll: boolean;
10
+ instrumental: boolean;
11
+ };
12
+ line: {
13
+ durationMs: number;
14
+ enterEasing: string;
15
+ exitEasing: string;
16
+ enterFrom: string;
17
+ enterTo: string;
18
+ exitFrom: string;
19
+ exitTo: string;
20
+ };
21
+ highlight: {
22
+ fadeInDurationMs: number;
23
+ fadeOutDurationMs: number;
24
+ fadeInEasing: string;
25
+ fadeOutEasing: string;
26
+ swipeEasing: string;
27
+ swipeStartFrom: string;
28
+ swipeEndFrom: string;
29
+ swipeStartTo: string;
30
+ swipeEndTo: string;
31
+ glowTo: string;
32
+ glowDurationRatio: number;
33
+ glowMinDurationMs: number;
34
+ glowEasing: string;
35
+ glowContainerAlpha: number;
36
+ glowRestingInvisible: boolean;
37
+ };
38
+ word: {
39
+ wobbleDurationMs: number;
40
+ wobbleEasing: string;
41
+ wobblePeakEasing: string;
42
+ wobbleEndEasing: string;
43
+ wobbleFrom: string;
44
+ wobblePeak: string;
45
+ wobbleSettle: string;
46
+ wobbleTo: string;
47
+ wobblePeakOffset: number;
48
+ wobbleSettleOffset: number;
49
+ };
50
+ letterWave: {
51
+ transform: string;
52
+ settle: string;
53
+ emphasisScale: string;
54
+ durationMs: number;
55
+ riseEasing: string;
56
+ fallEasing: string;
57
+ };
58
+ instrumental: {
59
+ fillFadeDurationMs: number;
60
+ fillFadeEasing: string;
61
+ fillFrom: string;
62
+ fillTo: string;
63
+ fillEasing: string;
64
+ waveFrom: string;
65
+ waveTo: string;
66
+ waveEasing: string;
67
+ wavePathHigh: string;
68
+ wavePathLow: string;
69
+ waveOscillationDurationMs: number;
70
+ waveOscillationEasing: string;
71
+ };
72
+ lineScroll: {
73
+ easing: string;
74
+ differentialEffects: boolean;
75
+ };
76
+ }
77
+ export interface AnimationSettings {
78
+ config: AnimationConfig;
79
+ scrollTiming: {
80
+ earlyScrollConsiderS: number;
81
+ };
82
+ }
83
+ export declare function getAnimationSettings(engine: AnimationEngineInstance, lyricsElement: HTMLElement): AnimationSettings;
@@ -0,0 +1,93 @@
1
+ import { registerThemeSetting } from "../themeSettings.js";
2
+ import { REDUCED_MOTION_QUERY } from "./motionPreference.js";
3
+ import { createThemeReader } from "./cssValues.js";
4
+ import { isGlowRestingInvisible, parseColorAlpha, resolveGlowFilter } from "./glow.js";
5
+ import { INSTRUMENTAL_WAVE_PATH_HIGH_FALLBACK, INSTRUMENTAL_WAVE_PATH_LOW_FALLBACK } from "./instrumentalAnimations.js";
6
+ const EARLY_SCROLL_CONSIDER = registerThemeSetting("blyrics-early-scroll-consider-s", 0.54);
7
+ const DEFAULT_SCROLL_EASING = "cubic-bezier(0.86, 0, 0.2, 1)";
8
+ export function getAnimationSettings(engine, lyricsElement) {
9
+ engine.cachedAnimationSettings ??= {
10
+ config: readAnimationConfig(engine, lyricsElement),
11
+ scrollTiming: { earlyScrollConsiderS: Math.max(0, EARLY_SCROLL_CONSIDER.getNumberValue()) },
12
+ };
13
+ return engine.cachedAnimationSettings;
14
+ }
15
+ function readAnimationConfig(engine, lyricsElement) {
16
+ const css = createThemeReader(engine, lyricsElement);
17
+ const glowTo = resolveGlowFilter(engine, lyricsElement, "to", "0");
18
+ return {
19
+ enabled: {
20
+ lineScale: css.flag("--blyrics-animate-line-scale", true),
21
+ wordWobble: css.flag("--blyrics-animate-word-wobble", true),
22
+ highlightSwipe: css.flag("--blyrics-animate-highlight-swipe", true),
23
+ highlightGlow: css.flag("--blyrics-animate-highlight-glow", true),
24
+ highlightFade: css.flag("--blyrics-animate-highlight-fade", true),
25
+ scroll: css.flag("--blyrics-animate-scroll", true),
26
+ instrumental: css.flag("--blyrics-animate-instrumental", true),
27
+ },
28
+ line: {
29
+ durationMs: css.durationMs("--blyrics-scale-transition-duration", "0.166s"),
30
+ enterEasing: css.string("--blyrics-line-enter-easing", "ease"),
31
+ exitEasing: css.string("--blyrics-line-exit-easing", "ease"),
32
+ enterFrom: css.string("--blyrics-line-enter-transform-from", "scale(var(--blyrics-scale))"),
33
+ enterTo: css.string("--blyrics-line-enter-transform-to", "scale(var(--blyrics-active-scale))"),
34
+ exitFrom: css.string("--blyrics-line-exit-transform-from", "scale(var(--blyrics-active-scale))"),
35
+ exitTo: css.string("--blyrics-line-exit-transform-to", "scale(var(--blyrics-scale))"),
36
+ },
37
+ highlight: {
38
+ fadeInDurationMs: css.durationMs("--blyrics-lyric-highlight-fade-in-duration", "0.33s"),
39
+ fadeOutDurationMs: css.durationMs("--blyrics-lyric-highlight-fade-out-duration", "0.5s"),
40
+ fadeInEasing: css.string("--blyrics-lyric-highlight-fade-in-easing", "ease"),
41
+ fadeOutEasing: css.string("--blyrics-lyric-highlight-fade-out-easing", "ease"),
42
+ swipeEasing: css.string("--blyrics-highlight-swipe-easing", "linear"),
43
+ swipeStartFrom: css.string("--blyrics-highlight-swipe-start-from", "-0.2"),
44
+ swipeEndFrom: css.string("--blyrics-highlight-swipe-end-from", "-0.1"),
45
+ swipeStartTo: css.string("--blyrics-highlight-swipe-start-to", "1.4"),
46
+ swipeEndTo: css.string("--blyrics-highlight-swipe-end-to", "1.5"),
47
+ glowTo,
48
+ glowDurationRatio: css.number("--blyrics-highlight-glow-duration-ratio", 1.2),
49
+ glowMinDurationMs: css.durationMs("--blyrics-highlight-glow-min-duration", "1.2s"),
50
+ glowEasing: css.string("--blyrics-highlight-glow-easing", "ease"),
51
+ glowContainerAlpha: parseColorAlpha(css.string("--blyrics-glow-color", "")) ?? 1,
52
+ glowRestingInvisible: isGlowRestingInvisible(glowTo),
53
+ },
54
+ word: {
55
+ wobbleDurationMs: css.durationMs("--blyrics-wobble-duration", "1s"),
56
+ wobbleEasing: css.string("--blyrics-word-wobble-easing", "ease"),
57
+ wobblePeakEasing: css.string("--blyrics-word-wobble-peak-easing", "ease-in-out"),
58
+ wobbleEndEasing: css.string("--blyrics-word-wobble-end-easing", "ease-out"),
59
+ wobbleFrom: css.string("--blyrics-word-wobble-transform-from", "scaleX(1)"),
60
+ wobblePeak: css.string("--blyrics-word-wobble-transform-peak", "translateX(0.05em) scaleX(1.025)"),
61
+ wobbleSettle: css.string("--blyrics-word-wobble-transform-settle", "translateX(0) scaleX(1)"),
62
+ wobbleTo: css.string("--blyrics-word-wobble-transform-to", "scaleX(1)"),
63
+ wobblePeakOffset: css.fraction("--blyrics-word-wobble-peak-offset", 0.125),
64
+ wobbleSettleOffset: css.fraction("--blyrics-word-wobble-settle-offset", 0.75),
65
+ },
66
+ letterWave: {
67
+ transform: css.string("--blyrics-letter-wave-transform", "translateY(-0.06em)"),
68
+ settle: css.string("--blyrics-letter-wave-settle", "translateY(-0.05em)"),
69
+ emphasisScale: css.string("--blyrics-letter-wave-emphasis-scale", "1.08"),
70
+ durationMs: css.durationMs("--blyrics-letter-wave-duration", "0.9s"),
71
+ riseEasing: css.string("--blyrics-letter-wave-rise-easing", "ease-in-out"),
72
+ fallEasing: css.string("--blyrics-letter-wave-fall-easing", "ease-in-out"),
73
+ },
74
+ instrumental: {
75
+ fillFadeDurationMs: css.durationMs("--blyrics-instrumental-fill-fade-duration", "150ms"),
76
+ fillFadeEasing: css.string("--blyrics-instrumental-fill-fade-easing", "ease"),
77
+ fillFrom: css.string("--blyrics-instrumental-fill-transform-from", "translateY(78%)"),
78
+ fillTo: css.string("--blyrics-instrumental-fill-transform-to", "translateY(-4%)"),
79
+ fillEasing: css.string("--blyrics-instrumental-fill-easing", "linear"),
80
+ waveFrom: css.string("--blyrics-instrumental-wave-transform-from", "scaleY(1.2)"),
81
+ waveTo: css.string("--blyrics-instrumental-wave-transform-to", "scaleY(0.0001)"),
82
+ waveEasing: css.string("--blyrics-instrumental-wave-easing", "ease-in"),
83
+ wavePathHigh: css.string("--blyrics-instrumental-wave-path-high", INSTRUMENTAL_WAVE_PATH_HIGH_FALLBACK),
84
+ wavePathLow: css.string("--blyrics-instrumental-wave-path-low", INSTRUMENTAL_WAVE_PATH_LOW_FALLBACK),
85
+ waveOscillationDurationMs: css.durationMs("--blyrics-instrumental-wave-oscillation-duration", "1.25s"),
86
+ waveOscillationEasing: css.string("--blyrics-instrumental-wave-oscillation-easing", "ease-in-out"),
87
+ },
88
+ lineScroll: {
89
+ easing: css.string("--blyrics-lyric-scroll-timing-function", DEFAULT_SCROLL_EASING),
90
+ differentialEffects: !engine.window.matchMedia(REDUCED_MOTION_QUERY).matches,
91
+ },
92
+ };
93
+ }
@@ -0,0 +1,11 @@
1
+ import type { LineData } from "../inject.js";
2
+ import type { AnimationEngineInstance } from "./instance.js";
3
+ export interface DriftCheck {
4
+ engine: AnimationEngineInstance;
5
+ line: LineData;
6
+ lineIndex: number;
7
+ lyricTimeS: number;
8
+ isPlaying: boolean;
9
+ now: number;
10
+ }
11
+ export declare function correctLineDrift({ engine, line, lineIndex, lyricTimeS, isPlaying, now }: DriftCheck): void;
@@ -0,0 +1,43 @@
1
+ import { clamp } from "../util.js";
2
+ import { largestDriftSample } from "./animationTiming.js";
3
+ import { resetLineAnimationState } from "./lineAnimationState.js";
4
+ import { logAnimationTiming, shouldLogAnimationTiming } from "./timingLogs.js";
5
+ const LEARN_RATE = 0.08;
6
+ const LEARN_SAMPLE_LIMIT_MS = 80;
7
+ const MAX_LEARNED_OFFSET_MS = 80;
8
+ const ACCUMULATION_DECAY = 1.08;
9
+ const ACCUMULATION_WEIGHT = 0.4;
10
+ const RESET_THRESHOLD_MS = 100;
11
+ export function correctLineDrift({ engine, line, lineIndex, lyricTimeS, isPlaying, now }) {
12
+ const sample = largestDriftSample(line, lyricTimeS);
13
+ line.accumulatedOffsetMs /= ACCUMULATION_DECAY;
14
+ if (sample === null)
15
+ return;
16
+ if (!isUsableForDrift(sample, isPlaying)) {
17
+ if (shouldLogAnimationTiming(engine, line, sample, now)) {
18
+ logAnimationTiming(engine, "ignored-sample", line, lineIndex, sample, lyricTimeS, line.accumulatedOffsetMs);
19
+ }
20
+ return;
21
+ }
22
+ const learnedOffsetMs = learnTimingOffset(engine, sample);
23
+ line.accumulatedOffsetMs += sample.offsetMs * ACCUMULATION_WEIGHT;
24
+ if (shouldLogAnimationTiming(engine, line, sample, now)) {
25
+ const accumulatedMs = line.accumulatedOffsetMs;
26
+ logAnimationTiming(engine, "sample", line, lineIndex, sample, lyricTimeS, accumulatedMs, learnedOffsetMs);
27
+ }
28
+ const drifted = Math.abs(line.accumulatedOffsetMs) > RESET_THRESHOLD_MS;
29
+ if (line.isAnimating && isPlaying && drifted) {
30
+ logAnimationTiming(engine, "drift-reset", line, lineIndex, sample, lyricTimeS, line.accumulatedOffsetMs);
31
+ resetLineAnimationState(line);
32
+ }
33
+ }
34
+ function isUsableForDrift(sample, isPlaying) {
35
+ return isPlaying && (sample.playState === "running" || sample.playState === "finished");
36
+ }
37
+ function learnTimingOffset(engine, sample) {
38
+ if (Math.abs(sample.biasOffsetMs) > LEARN_SAMPLE_LIMIT_MS)
39
+ return engine.learnedAnimationTimingOffsetMs;
40
+ const learned = engine.learnedAnimationTimingOffsetMs;
41
+ engine.learnedAnimationTimingOffsetMs = clamp(learned + (sample.biasOffsetMs - learned) * LEARN_RATE, -MAX_LEARNED_OFFSET_MS, MAX_LEARNED_OFFSET_MS);
42
+ return engine.learnedAnimationTimingOffsetMs;
43
+ }
@@ -0,0 +1,26 @@
1
+ import type { LineData, PartData } from "../inject.js";
2
+ import type { AnimationEngineInstance } from "./instance.js";
3
+ export interface SongClockTrack {
4
+ offsetMs: number;
5
+ appliedTimingOffsetMs: number;
6
+ skipDriftSample?: boolean;
7
+ wrapDurationMs?: number;
8
+ }
9
+ export interface DriftSample {
10
+ actualTimeMs: number;
11
+ appliedTimingOffsetMs: number;
12
+ biasOffsetMs: number;
13
+ expectedTimeMs: number;
14
+ offsetMs: number;
15
+ playState: AnimationPlayState;
16
+ }
17
+ export declare function followSongClock(engine: AnimationEngineInstance, animation: Animation, track: Omit<SongClockTrack, "appliedTimingOffsetMs"> & {
18
+ appliedTimingOffsetMs?: number;
19
+ }): Animation;
20
+ /** Repeats a word's own animations on the cells of a sweep drawn for it from copies of its line. */
21
+ export declare function mirrorHighlightAnimations(part: PartData, animations: Animation[]): Animation[];
22
+ export declare function applyPlaybackRateToRunningAnimations(engine: AnimationEngineInstance): void;
23
+ export declare function correctedAnimationTimeMs(targetTimeMs: number, appliedTimingOffsetMs: number, maxTimeMs?: number): number;
24
+ export declare function correctedWrappedAnimationTimeMs(targetTimeMs: number, appliedTimingOffsetMs: number, wrapDurationMs: number): number;
25
+ export declare function correctedScrollTimeS(engine: AnimationEngineInstance, lyricTimeS: number): number;
26
+ export declare function largestDriftSample(line: LineData, lyricTimeS: number): DriftSample | null;