@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
@@ -1,67 +1,9 @@
1
- /* The renderer adds these classes only for blyrics-image-highlights = true.
1
+ /* The renderer adds the instrumental image only for blyrics-image-highlights = true.
2
2
  An SDR image is equally valid. HDR assets and dynamic-range-limit belong to the theme. */
3
- .blyrics--word.blyrics-word-highlight.blyrics-image-highlight {
4
- background: none;
5
- mask: none;
6
- -webkit-mask: none;
7
- color: transparent;
8
- }
9
- .blyrics-image-fill,
10
- .blyrics-word-highlight.blyrics-image-highlight .blyrics--letter {
11
- background-image: var(--blyrics-highlight-image, none);
12
- background-color: var(--blyrics-lyric-active-color, white);
13
- background-size: 100% 100%;
14
- background-repeat: no-repeat;
15
- background-clip: text;
16
- -webkit-background-clip: text;
17
- color: transparent;
18
- -webkit-text-fill-color: transparent;
19
- }
20
- /* The content-box copy keeps each letter's image; the padding-box copy carries it under glyph overhang. */
21
- .blyrics-word-highlight.blyrics-image-highlight .blyrics--letter {
22
- background-image: var(--blyrics-highlight-image, none), var(--blyrics-highlight-image, none);
23
- background-origin: content-box, padding-box;
24
- }
25
- .blyrics-image-highlight:not(.blyrics-word-highlight--lettered) .blyrics-image-fill {
26
- --blyrics-image-sweep-angle: 90deg;
27
- mask-image: linear-gradient(var(--blyrics-image-sweep-angle),
28
- #000 calc(100% * var(--lyric-transition-amount-start)),
29
- transparent calc(100% * var(--lyric-transition-amount-end) + 1px));
30
- mask-repeat: no-repeat;
31
- }
32
- .blyrics-image-highlight.blyrics-rtl:not(.blyrics-word-highlight--lettered) .blyrics-image-fill {
33
- --blyrics-image-sweep-angle: 270deg;
34
- }
35
- .blyrics-image-highlight.blyrics-word-highlight--lettered .blyrics-image-fill {
36
- background: none;
37
- }
38
- .blyrics-image-glow {
39
- position: absolute;
40
- inset: 0;
41
- pointer-events: none;
42
- user-select: none;
43
- opacity: 0;
44
- overflow: visible;
45
- }
46
- /* A parallel run reproduces the full inline formatting context, including bidi
47
- reordering and every wrapped fragment. No generated text or per-frame measuring. */
48
- .blyrics-image-glow-run .blyrics-image-glow {
49
- position: static;
50
- inset: auto;
51
- display: inline;
52
- }
53
3
  .blyrics-instrumental-image { display: none; }
54
4
  .blyrics--instrumental-icon[data-image-ready] .blyrics-instrumental-image { display: inline; }
55
5
  .blyrics--instrumental-icon[data-image-ready] .blyrics-instrumental-color { display: none; }
56
6
  @media (forced-colors: active) {
57
- .blyrics-image-glow,
58
- .blyrics-image-glow-run .blyrics-image-glow { display: none; }
59
- .blyrics-image-fill,
60
- .blyrics-word-highlight.blyrics-image-highlight .blyrics--letter {
61
- background: none;
62
- color: CanvasText;
63
- -webkit-text-fill-color: CanvasText;
64
- }
65
7
  .blyrics--instrumental-icon[data-image-ready] .blyrics-instrumental-image { display: none; }
66
8
  .blyrics--instrumental-icon[data-image-ready] .blyrics-instrumental-color { display: inline; }
67
9
  }
@@ -127,44 +127,9 @@
127
127
  white-space: inherit;
128
128
  }
129
129
 
130
- @property --lyric-transition-amount-start {
131
- syntax: "<number>";
132
- inherits: true;
133
- initial-value: -0.2;
134
- }
135
-
136
- @property --lyric-transition-amount-end {
137
- syntax: "<number>";
138
- inherits: true;
139
- initial-value: -0.1;
140
- }
141
-
142
130
  .blyrics--word.blyrics-word-highlight {
143
- color: transparent;
144
- background-image: linear-gradient(
145
- 90deg,
146
- var(--blyrics-lyric-active-color)
147
- calc(100% * var(--lyric-transition-amount-start)),
148
- #00000000
149
- calc(100% * var(--lyric-transition-amount-end) + 1px)
150
- );
151
- background-clip: text;
152
131
  opacity: 0;
153
132
  pointer-events: none;
154
- --lyric-transition-amount-start: var(
155
- --blyrics-highlight-swipe-start-from,
156
- -0.2
157
- );
158
- --lyric-transition-amount-end: var(--blyrics-highlight-swipe-end-from, -0.1);
159
- }
160
- .blyrics-word-highlight.blyrics-rtl {
161
- background-image: linear-gradient(
162
- 270deg,
163
- var(--blyrics-lyric-active-color)
164
- calc(100% * var(--lyric-transition-amount-start)),
165
- #00000000
166
- calc(100% * var(--lyric-transition-amount-end) + 1px)
167
- );
168
133
  }
169
134
 
170
135
  .blyrics--letter {
@@ -182,33 +147,138 @@
182
147
  perspective: 100000px;
183
148
  }
184
149
 
185
- .blyrics-word-highlight.blyrics-word-highlight--lettered {
186
- background-image: none;
150
+ /* The compositor's sweep. A cell is a word that is its own inline-block box, or one letter of a word
151
+ that flows inline. Its mask box is 3 + fade cells wide and starts a cell before the cell: opaque up
152
+ to half a cell past the cell's end (SWEEP_REST in sweepPlans.ts), then a soft edge `fade` cells
153
+ wide, where fade is the swipe's width from its last start stop to its last end stop, in cells. The
154
+ engine slides the mask back to where the swipe begins and the text inside it the other way by the
155
+ same distance, so the glyphs hold still while the edge crosses them. The glow's two halos sit in
156
+ that same text, so the edge reveals them with it. With nothing animating the mask rests with the
157
+ cell lit and its halos whole. */
158
+ .blyrics--word.blyrics-word-highlight.blyrics-word-highlight--sweep {
159
+ color: var(--blyrics-lyric-active-color);
160
+ --blyrics-sweep-angle: 90deg;
161
+ --blyrics-sweep-fade: calc(
162
+ var(--blyrics-highlight-swipe-end-to, 1.5) - var(--blyrics-highlight-swipe-start-to, 1.4)
163
+ );
187
164
  }
188
165
 
189
- /* A mask clips to the border box, cutting off glyph overhang (a j's hook, italics). The padding
190
- widens that clip without moving layout, and the content-box origin keeps the sweep geometry. */
191
- .blyrics-word-highlight .blyrics--letter {
192
- padding-inline: 0.25em;
193
- margin-inline: -0.25em;
194
- -webkit-mask-origin: content-box;
195
- mask-origin: content-box;
196
- color: var(--blyrics-lyric-active-color);
197
- -webkit-mask-image: linear-gradient(90deg, #000 0, #000 50%, #0000 calc(50% + var(--mask-fade, 3%)));
198
- mask-image: linear-gradient(90deg, #000 0, #000 50%, #0000 calc(50% + var(--mask-fade, 3%)));
166
+ .blyrics--word.blyrics-word-highlight.blyrics-word-highlight--sweep.blyrics-rtl,
167
+ .blyrics-sweep-window.blyrics-sweep-cell[dir="rtl"] {
168
+ --blyrics-sweep-angle: 270deg;
169
+ }
170
+
171
+ .blyrics-word-highlight--sweep .blyrics--letter.blyrics-sweep-cell {
172
+ --blyrics-sweep-fade: calc(
173
+ (var(--blyrics-highlight-swipe-end-to, 1.5) - var(--blyrics-highlight-swipe-start-to, 1.4)) *
174
+ var(--letters, 1)
175
+ );
176
+ }
177
+
178
+ /* The mask boxes are laid out by direction, which a `dir="auto"` word does not hand down to its letters,
179
+ so each cell takes the direction of the word the engine sweeps it for. */
180
+ .blyrics-sweep-cell {
181
+ direction: ltr;
182
+ /* The mask boxes add nothing to the row's scroll width; the margin keeps the glow's halo. */
183
+ overflow: clip;
184
+ overflow-clip-margin: 2rem;
185
+ position: relative;
186
+ }
187
+
188
+ .blyrics-word-highlight--sweep.blyrics-rtl .blyrics-sweep-cell,
189
+ .blyrics-sweep-window.blyrics-sweep-cell[dir="rtl"] {
190
+ direction: rtl;
191
+ }
192
+
193
+ .blyrics-sweep-mask {
194
+ --blyrics-sweep-widths: calc(3 + var(--blyrics-sweep-fade));
195
+ box-sizing: content-box;
196
+ display: block;
197
+ margin-inline-start: -100%;
198
+ width: calc(var(--blyrics-sweep-widths) * 100%);
199
+ /* Room above and below for the halo, the letter wave and glyphs that reach past the line box. */
200
+ padding-block: calc(0.5em + var(--blyrics-highlight-glow-radius-from, 0.8rem));
201
+ margin-block: calc(-0.5em - var(--blyrics-highlight-glow-radius-from, 0.8rem));
202
+ --blyrics-sweep-solid: calc(250% / var(--blyrics-sweep-widths));
203
+ --blyrics-sweep-clear: calc((2.5 + var(--blyrics-sweep-fade)) * 100% / var(--blyrics-sweep-widths));
204
+ -webkit-mask-image: linear-gradient(var(--blyrics-sweep-angle), #000 var(--blyrics-sweep-solid), #0000 var(--blyrics-sweep-clear));
205
+ mask-image: linear-gradient(var(--blyrics-sweep-angle), #000 var(--blyrics-sweep-solid), #0000 var(--blyrics-sweep-clear));
199
206
  -webkit-mask-repeat: no-repeat;
200
207
  mask-repeat: no-repeat;
201
- -webkit-mask-size: calc((var(--letters, 1) + 2) * 100%) 100%;
202
- mask-size: calc((var(--letters, 1) + 2) * 100%) 100%;
203
- -webkit-mask-position: 0% 0%;
204
- mask-position: 0% 0%;
205
208
  }
206
209
 
207
- .blyrics-word-highlight.blyrics-rtl .blyrics--letter {
208
- -webkit-mask-image: linear-gradient(270deg, #000 0, #000 50%, #0000 calc(50% + var(--mask-fade, 3%)));
209
- mask-image: linear-gradient(270deg, #000 0, #000 50%, #0000 calc(50% + var(--mask-fade, 3%)));
210
- -webkit-mask-position: 100% 0%;
211
- mask-position: 100% 0%;
210
+ .blyrics-sweep-text {
211
+ box-sizing: content-box;
212
+ display: block;
213
+ isolation: isolate;
214
+ margin-inline-start: calc(100% / var(--blyrics-sweep-widths));
215
+ position: relative;
216
+ width: calc(100% / var(--blyrics-sweep-widths));
217
+ }
218
+
219
+ /* A halo is a copy of the text whose own glyphs are clear, under a text shadow that never changes; the
220
+ engine fades it by opacity. */
221
+ .blyrics-sweep-glow {
222
+ --blyrics-sweep-glow-radius: var(--blyrics-highlight-glow-radius-from, 0.8rem);
223
+ color: transparent;
224
+ inset: 0;
225
+ opacity: 0;
226
+ pointer-events: none;
227
+ position: absolute;
228
+ text-shadow: 0 0 var(--blyrics-sweep-glow-radius) var(--blyrics-glow-color);
229
+ user-select: none;
230
+ z-index: -1;
231
+ }
232
+
233
+ /* The glow shrinks as it fades. The engine crossfades from the wide halo to this one, which sits where
234
+ the radius has shrunk to by the time the wide one is gone. */
235
+ .blyrics-sweep-glow--tight {
236
+ --blyrics-sweep-glow-radius: calc(var(--blyrics-highlight-glow-radius-from, 0.8rem) * 0.4);
237
+ }
238
+
239
+ /* A word that flows inline keeps its text here only for layout; its sweep is drawn by cells placed over
240
+ each box it breaks into, which show the word from copies of its line. */
241
+ .blyrics--word.blyrics-word-highlight.blyrics-word-highlight--context {
242
+ color: transparent;
243
+ }
244
+
245
+ .blyrics-sweep-context {
246
+ inset: 0;
247
+ opacity: 0;
248
+ pointer-events: none;
249
+ position: absolute;
250
+ user-select: none;
251
+ z-index: 1;
252
+ }
253
+
254
+ .blyrics-sweep-window {
255
+ --blyrics-sweep-angle: 90deg;
256
+ position: absolute;
257
+ }
258
+
259
+ .blyrics-sweep-window .blyrics-sweep-mask,
260
+ .blyrics-sweep-window .blyrics-sweep-text {
261
+ height: 100%;
262
+ }
263
+
264
+ .blyrics-sweep-clone {
265
+ color: transparent;
266
+ max-width: none;
267
+ position: absolute;
268
+ text-shadow: none;
269
+ }
270
+
271
+ .blyrics-sweep-clone .blyrics--word {
272
+ color: transparent;
273
+ }
274
+
275
+ .blyrics-sweep-clone .blyrics--word.blyrics-sweep-target {
276
+ color: var(--blyrics-lyric-active-color);
277
+ }
278
+
279
+ .blyrics-sweep-glow .blyrics-sweep-clone .blyrics--word.blyrics-sweep-target {
280
+ color: transparent;
281
+ text-shadow: 0 0 var(--blyrics-sweep-glow-radius) var(--blyrics-glow-color);
212
282
  }
213
283
 
214
284
  /* text-decoration skips inline-block letters and rides the wave, so draw on the word box instead, from its
@@ -225,7 +295,8 @@
225
295
  .blyrics--line > .blyrics-line-main > .blyrics-background-lyric,
226
296
  .blyrics--line > .blyrics-background-line > .blyrics-background-lyric,
227
297
  .blyrics--line > .blyrics-line-main > .blyrics-bidi-run > .blyrics-background-lyric,
228
- .blyrics--line > .blyrics-background-line > .blyrics-bidi-run > .blyrics-background-lyric {
298
+ .blyrics--line > .blyrics-background-line > .blyrics-bidi-run > .blyrics-background-lyric,
299
+ .blyrics-sweep-clone > .blyrics-background-lyric {
229
300
  font-size: 0.75em;
230
301
  font-weight: 500;
231
302
  }
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Lyric, LyricPart, LyricSyncType } from "@braccato/types";
2
- import type { AnimationTickStatus } from "./engine.js";
2
+ import type { AnimationTickStatus } from "./engine/tick.js";
3
3
  import type { LineData } from "./inject.js";
4
4
  import type { StageBox } from "./stage.js";
5
5
  import type { SetLyricsOptions } from "./view.js";
package/dist/view.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type AnimationEngineInstance } from "./engine.js";
1
+ import { type AnimationEngineInstance } from "./engine/instance.js";
2
2
  import { type LineData } from "./inject.js";
3
3
  import type { Lyric } from "./types.js";
4
4
  export interface SetLyricsOptions {
@@ -38,7 +38,7 @@ export declare function setLyrics(engine: AnimationEngineInstance, mount: HTMLEl
38
38
  export type SwapPositions = Map<LineData, {
39
39
  position: number;
40
40
  height: number;
41
- offset: number;
41
+ motionOffset: number;
42
42
  }>;
43
43
  /**
44
44
  * Swaps these lyrics into the view already on screen, rebuilding only the lines that differ, and
package/dist/view.js CHANGED
@@ -13,7 +13,11 @@
13
13
  // lines is where those values are first knowable: the container, the records, the sync type, the
14
14
  // size they were measured at, and the scrolls to swallow before the view has settled.
15
15
  import { CREDITS_CLASS, CREDITS_NAMES_CLASS, CREDITS_TEXT_CLASS, LINE_CLASS, LYRICS_CLASS, RTL_CLASS, } from "./constants.js";
16
- import { lineScrollOffset, playerTimeForLyricTime, replaceRenderedLines, setupLineCullObserver, } from "./engine.js";
16
+ import {} from "./engine/instance.js";
17
+ import { elementMotionOffsetPx } from "./engine/elementMotion.js";
18
+ import { replaceRenderedLines } from "./engine/renderedLines.js";
19
+ import { playerTimeForLyricTime } from "./engine/clock.js";
20
+ import { setupLineCullObserver } from "./engine/culling.js";
17
21
  import { addSeekHandler, applyDirection, buildLineSyncedParts, createLyricsLine, deriveSyncType, disableRichsync, findNearestAgent, hideCredits, isNearestLyricRtl, moveDecorations, newLineData, } from "./inject.js";
18
22
  import { refreshInstrumentalImages } from "./imageHighlights.js";
19
23
  import { createInstrumentalElement } from "./instrumental.js";
@@ -351,7 +355,7 @@ export function swapLyrics(engine, mount, lyrics, options) {
351
355
  line.lyricElement.dataset.lineNumber = String(lineIndex);
352
356
  applyLyricLanguage(line.lyricElement, context.languages[lineIndex]);
353
357
  lines.push(line);
354
- positions.set(line, { position: line.position, height: line.height, offset: 0 });
358
+ positions.set(line, { position: line.position, height: line.height, motionOffset: 0 });
355
359
  continue;
356
360
  }
357
361
  if (unmatchedOld.length === 0) {
@@ -366,7 +370,7 @@ export function swapLyrics(engine, mount, lyrics, options) {
366
370
  position: standsFor.position,
367
371
  height: standsFor.height,
368
372
  // A kept line finishes its own line scroll; this one starts where the line it replaced was.
369
- offset: lineScrollOffset(engine, standsFor.lyricElement),
373
+ motionOffset: elementMotionOffsetPx(engine, standsFor.lyricElement),
370
374
  });
371
375
  if (decorationKeys.get(standsFor) === decorationKeys.get(line))
372
376
  moveDecorations(standsFor, line);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braccato/core",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "Synchronized lyrics renderer with word-by-word animations",
5
5
  "type": "module",
6
6
  "license": "MIT",