@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.
- package/README.md +40 -37
- package/dist/README.md +40 -37
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +10 -0
- package/dist/engine/animationConfig.d.ts +83 -0
- package/dist/engine/animationConfig.js +93 -0
- package/dist/engine/animationDrift.d.ts +11 -0
- package/dist/engine/animationDrift.js +43 -0
- package/dist/engine/animationTiming.d.ts +26 -0
- package/dist/engine/animationTiming.js +120 -0
- package/dist/engine/autoScroll.d.ts +24 -0
- package/dist/engine/autoScroll.js +103 -0
- package/dist/engine/clock.d.ts +29 -0
- package/dist/engine/clock.js +70 -0
- package/dist/engine/contextSweep.d.ts +10 -0
- package/dist/engine/contextSweep.js +102 -0
- package/dist/engine/cssValues.d.ts +13 -0
- package/dist/engine/cssValues.js +47 -0
- package/dist/engine/culling.d.ts +6 -0
- package/dist/engine/culling.js +76 -0
- package/dist/engine/debugOverlay.d.ts +14 -0
- package/dist/engine/debugOverlay.js +58 -0
- package/dist/engine/decorationSlides.d.ts +6 -0
- package/dist/engine/decorationSlides.js +53 -0
- package/dist/engine/elementMotion.d.ts +17 -0
- package/dist/engine/elementMotion.js +98 -0
- package/dist/engine/glow.d.ts +7 -0
- package/dist/engine/glow.js +59 -0
- package/dist/engine/instance.d.ts +105 -0
- package/dist/engine/instance.js +89 -0
- package/dist/engine/instrumentalAnimations.d.ts +7 -0
- package/dist/engine/instrumentalAnimations.js +59 -0
- package/dist/engine/letterPlans.d.ts +31 -0
- package/dist/engine/letterPlans.js +62 -0
- package/dist/engine/lineAnimationState.d.ts +10 -0
- package/dist/engine/lineAnimationState.js +82 -0
- package/dist/engine/lineAnimations.d.ts +5 -0
- package/dist/engine/lineAnimations.js +63 -0
- package/dist/engine/lineLifecycle.d.ts +12 -0
- package/dist/engine/lineLifecycle.js +92 -0
- package/dist/engine/lineScroll.d.ts +47 -0
- package/dist/engine/lineScroll.js +184 -0
- package/dist/engine/lineScrollStyle.d.ts +32 -0
- package/dist/engine/lineScrollStyle.js +133 -0
- package/dist/engine/liveViews.d.ts +3 -0
- package/dist/engine/liveViews.js +5 -0
- package/dist/engine/motionCurves.d.ts +19 -0
- package/dist/engine/motionCurves.js +85 -0
- package/dist/engine/motionPreference.d.ts +1 -0
- package/dist/engine/motionPreference.js +1 -0
- package/dist/engine/passiveScroll.d.ts +10 -0
- package/dist/engine/passiveScroll.js +93 -0
- package/dist/engine/renderedLines.d.ts +16 -0
- package/dist/engine/renderedLines.js +130 -0
- package/dist/engine/scrollViewport.d.ts +36 -0
- package/dist/engine/scrollViewport.js +104 -0
- package/dist/engine/stageMotion.d.ts +7 -0
- package/dist/engine/stageMotion.js +319 -0
- package/dist/engine/sweepPlans.d.ts +36 -0
- package/dist/engine/sweepPlans.js +59 -0
- package/dist/engine/tick.d.ts +16 -0
- package/dist/engine/tick.js +270 -0
- package/dist/engine/timingLogs.d.ts +7 -0
- package/dist/engine/timingLogs.js +81 -0
- package/dist/engine/userScroll.d.ts +12 -0
- package/dist/engine/userScroll.js +62 -0
- package/dist/engine/wavePool.d.ts +7 -0
- package/dist/engine/wavePool.js +22 -0
- package/dist/engine/wordAnimations.d.ts +5 -0
- package/dist/engine/wordAnimations.js +238 -0
- package/dist/imageHighlights.d.ts +0 -11
- package/dist/imageHighlights.js +2 -48
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/inject.d.ts +41 -2
- package/dist/inject.js +73 -28
- package/dist/renderer.js +10 -3
- package/dist/styles/image-highlights.css +1 -59
- package/dist/styles/lyrics.css +128 -57
- package/dist/types.d.ts +1 -1
- package/dist/view.d.ts +2 -2
- package/dist/view.js +7 -3
- package/package.json +1 -1
- package/dist/engine.d.ts +0 -471
- package/dist/engine.js +0 -3133
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { RTL_CLASS } from "../constants.js";
|
|
2
|
+
import { registerThemeSetting } from "../themeSettings.js";
|
|
3
|
+
import { correctedAnimationTimeMs, mirrorHighlightAnimations, followSongClock } from "./animationTiming.js";
|
|
4
|
+
import { GECKO_REDRAW, GECKO_REDRAW_KEYFRAMES, GECKO_REDRAW_PERIOD_MS, LETTER_WAVE_CREST_OFFSET, planLetterWave, swipeRamp, } from "./letterPlans.js";
|
|
5
|
+
import { resetPartAnimations } from "./lineAnimationState.js";
|
|
6
|
+
import { cellReachedAt, planCellSweep } from "./sweepPlans.js";
|
|
7
|
+
import { acquireWaveAnimation } from "./wavePool.js";
|
|
8
|
+
const SWIPE_LEAD_RATIO = registerThemeSetting("blyrics-swipe-lead-ratio", 0.1);
|
|
9
|
+
const SWIPE_DURATION_RATIO = registerThemeSetting("blyrics-swipe-duration-ratio", 1.6);
|
|
10
|
+
const LINE_SYNCED_WORD_CLASS = "blyrics-line-synced-word";
|
|
11
|
+
const INSTANT_MS = 1;
|
|
12
|
+
// The sweep holds a word's reveal in its own layers, so the word's own opacity is all that animates on it.
|
|
13
|
+
const SHOWN = [{ opacity: 1 }, { opacity: 1 }];
|
|
14
|
+
const FADE_IN = [{ opacity: 0 }, { opacity: 1 }];
|
|
15
|
+
const FADE_OUT = [{ opacity: 1 }, { opacity: 0 }];
|
|
16
|
+
export function startWordAnimations(engine, part, config, lyricTimeS, appliedTimingOffsetMs) {
|
|
17
|
+
resetPartAnimations(part);
|
|
18
|
+
const word = wordTimeline(engine, part, config, lyricTimeS, appliedTimingOffsetMs);
|
|
19
|
+
const highlight = part.lyricElement.classList.contains(LINE_SYNCED_WORD_CLASS)
|
|
20
|
+
? lineSyncedHighlight(word)
|
|
21
|
+
: richSyncedHighlight(word);
|
|
22
|
+
const motion = config.enabled.wordWobble ? [...wobble(word), ...letterWave(word)] : [];
|
|
23
|
+
part.animations = [...highlight, ...mirrorHighlightAnimations(part, highlight), ...motion];
|
|
24
|
+
}
|
|
25
|
+
export function startWordExitAnimation(part, config) {
|
|
26
|
+
resetPartAnimations(part);
|
|
27
|
+
const fades = config.enabled.highlightFade;
|
|
28
|
+
const durationMs = fades ? config.highlight.fadeOutDurationMs : INSTANT_MS;
|
|
29
|
+
const fadeOut = part.highlightElement.animate(FADE_OUT, {
|
|
30
|
+
duration: durationMs,
|
|
31
|
+
easing: fades ? config.highlight.fadeOutEasing : "linear",
|
|
32
|
+
fill: "none",
|
|
33
|
+
});
|
|
34
|
+
part.animations = [fadeOut, ...mirrorHighlightAnimations(part, [fadeOut])];
|
|
35
|
+
fadeOut.addEventListener("finish", () => resetPartAnimations(part), { once: true });
|
|
36
|
+
}
|
|
37
|
+
function wordTimeline(engine, part, config, lyricTimeS, appliedTimingOffsetMs) {
|
|
38
|
+
const durationMs = Math.max(0, part.duration * 1000);
|
|
39
|
+
return {
|
|
40
|
+
engine,
|
|
41
|
+
part,
|
|
42
|
+
config,
|
|
43
|
+
appliedTimingOffsetMs,
|
|
44
|
+
elapsedMs: (lyricTimeS - part.time) * 1000,
|
|
45
|
+
durationMs,
|
|
46
|
+
swipeLeadMs: durationMs * SWIPE_LEAD_RATIO.getNumberValue(),
|
|
47
|
+
swipeDurationMs: durationMs * SWIPE_DURATION_RATIO.getNumberValue(),
|
|
48
|
+
glowDurationMs: Math.max(durationMs * config.highlight.glowDurationRatio, config.highlight.glowMinDurationMs),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function scheduledTimeMs(word, elapsedMs, durationMs) {
|
|
52
|
+
return correctedAnimationTimeMs(elapsedMs, word.appliedTimingOffsetMs, durationMs);
|
|
53
|
+
}
|
|
54
|
+
function followSong(word, animation, currentTimeMs, { offsetMs = 0, skipDriftSample = false } = {}) {
|
|
55
|
+
const { appliedTimingOffsetMs } = word;
|
|
56
|
+
followSongClock(word.engine, animation, { appliedTimingOffsetMs, offsetMs, skipDriftSample });
|
|
57
|
+
animation.currentTime = currentTimeMs;
|
|
58
|
+
return animation;
|
|
59
|
+
}
|
|
60
|
+
function glowShows(part, config) {
|
|
61
|
+
return config.enabled.highlightGlow && !part.glowSuppressed;
|
|
62
|
+
}
|
|
63
|
+
function richSyncedHighlight(word) {
|
|
64
|
+
const { part, config } = word;
|
|
65
|
+
const swipes = config.enabled.highlightSwipe;
|
|
66
|
+
const animations = swipes ? swipe(word) : [];
|
|
67
|
+
const show = part.highlightElement.animate(SHOWN, { duration: INSTANT_MS, easing: "linear", fill: "forwards" });
|
|
68
|
+
animations.push(followSong(word, show, scheduledTimeMs(word, word.elapsedMs, INSTANT_MS)));
|
|
69
|
+
if (glowShows(part, config))
|
|
70
|
+
animations.push(...glow(word, word.glowDurationMs, swipes));
|
|
71
|
+
return animations;
|
|
72
|
+
}
|
|
73
|
+
function lineSyncedHighlight(word) {
|
|
74
|
+
const { part, config } = word;
|
|
75
|
+
const fades = config.enabled.highlightFade;
|
|
76
|
+
const durationMs = fades ? config.highlight.fadeInDurationMs : INSTANT_MS;
|
|
77
|
+
const fadeIn = part.highlightElement.animate(FADE_IN, {
|
|
78
|
+
duration: durationMs,
|
|
79
|
+
easing: fades ? config.highlight.fadeInEasing : "linear",
|
|
80
|
+
fill: "forwards",
|
|
81
|
+
});
|
|
82
|
+
const animations = [followSong(word, fadeIn, scheduledTimeMs(word, word.elapsedMs, durationMs))];
|
|
83
|
+
if (glowShows(part, config))
|
|
84
|
+
animations.push(...glow(word, config.highlight.glowMinDurationMs, false));
|
|
85
|
+
return animations;
|
|
86
|
+
}
|
|
87
|
+
function swipe(word) {
|
|
88
|
+
const { part, swipeLeadMs, swipeDurationMs } = word;
|
|
89
|
+
const currentTimeMs = scheduledTimeMs(word, word.elapsedMs + swipeLeadMs, swipeDurationMs);
|
|
90
|
+
return part.sweep ? compositedSwipe(word, part.sweep, currentTimeMs) : [];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Slides each cell's mask from where the swipe begins back to its resting place and its text the other
|
|
94
|
+
* way. Filled backwards because the resting pose is the lit one. Only the first mask's animation feeds
|
|
95
|
+
* the drift check; the others carry the same timing and would repeat it.
|
|
96
|
+
*/
|
|
97
|
+
function compositedSwipe(word, cells, currentTimeMs) {
|
|
98
|
+
const { part, config, swipeLeadMs, swipeDurationMs } = word;
|
|
99
|
+
const rtl = part.highlightElement.classList.contains(RTL_CLASS);
|
|
100
|
+
const timing = {
|
|
101
|
+
duration: swipeDurationMs,
|
|
102
|
+
easing: config.highlight.swipeEasing,
|
|
103
|
+
fill: "both",
|
|
104
|
+
};
|
|
105
|
+
const animations = [];
|
|
106
|
+
cells.forEach((cell, index) => {
|
|
107
|
+
const span = cell.span ?? { start: index / cells.length, width: 1 / cells.length };
|
|
108
|
+
const plan = planCellSweep(swipeRamp(config), span, rtl);
|
|
109
|
+
if (!plan)
|
|
110
|
+
return;
|
|
111
|
+
for (const [element, keyframes] of [
|
|
112
|
+
[cell.mask, plan.mask],
|
|
113
|
+
[cell.text, plan.text],
|
|
114
|
+
]) {
|
|
115
|
+
const slide = element.animate(keyframes, timing);
|
|
116
|
+
animations.push(followSong(word, slide, currentTimeMs, { offsetMs: swipeLeadMs, skipDriftSample: animations.length > 0 }));
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return animations;
|
|
120
|
+
}
|
|
121
|
+
function glow(word, durationMs, followsSwipe) {
|
|
122
|
+
return word.part.sweep ? sweepGlow(word, word.part.sweep, durationMs, followsSwipe) : [];
|
|
123
|
+
}
|
|
124
|
+
// Where the shrinking radius reaches the tight halo's, as a fraction of the glow's eased progress.
|
|
125
|
+
const TIGHT_GLOW_AT = 0.6;
|
|
126
|
+
/**
|
|
127
|
+
* Stands in for a glow whose radius shrinks to nothing: the wide halo crossfades into the tight one
|
|
128
|
+
* while the radius would shrink between them, and the tight one then fades out. The keyframe offsets
|
|
129
|
+
* are in eased progress, since the glow's easing applies to the whole effect. Under a swipe each
|
|
130
|
+
* cell's glow starts when the edge reaches it, so a halo never shows ahead of its lit text. The wait
|
|
131
|
+
* is exact for a linear swipe and taken as linear for any other.
|
|
132
|
+
*/
|
|
133
|
+
function sweepGlow(word, cells, durationMs, followsSwipe) {
|
|
134
|
+
const { config, swipeLeadMs, swipeDurationMs } = word;
|
|
135
|
+
const fades = config.highlight.glowRestingInvisible;
|
|
136
|
+
const wide = fades
|
|
137
|
+
? [{ opacity: 1 }, { opacity: 0, offset: TIGHT_GLOW_AT }, { opacity: 0 }]
|
|
138
|
+
: [{ opacity: 1 }, { opacity: 1 }];
|
|
139
|
+
const tight = fades
|
|
140
|
+
? [{ opacity: 0 }, { opacity: 1, offset: TIGHT_GLOW_AT }, { opacity: 0 }]
|
|
141
|
+
: [{ opacity: 0 }, { opacity: 0 }];
|
|
142
|
+
return cells.flatMap((cell, cellIndex) => {
|
|
143
|
+
const span = cell.span ?? { start: cellIndex / cells.length, width: 1 / cells.length };
|
|
144
|
+
const delayMs = followsSwipe
|
|
145
|
+
? Math.max(0, cellReachedAt(swipeRamp(config), span) * swipeDurationMs - swipeLeadMs)
|
|
146
|
+
: 0;
|
|
147
|
+
const timing = {
|
|
148
|
+
delay: delayMs,
|
|
149
|
+
duration: durationMs,
|
|
150
|
+
easing: config.highlight.glowEasing,
|
|
151
|
+
fill: fades ? "none" : "forwards",
|
|
152
|
+
};
|
|
153
|
+
const currentTimeMs = scheduledTimeMs(word, word.elapsedMs, delayMs + durationMs);
|
|
154
|
+
return cell.glows.map((halo, index) => {
|
|
155
|
+
const fade = halo.glow.animate(index === 0 ? wide : tight, timing);
|
|
156
|
+
return followSong(word, fade, currentTimeMs, { skipDriftSample: true });
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function wobble(word) {
|
|
161
|
+
const { wobbleFrom, wobblePeak, wobblePeakOffset, wobblePeakEasing, wobbleSettle, wobbleSettleOffset } = word.config.word;
|
|
162
|
+
const { wobbleTo, wobbleEndEasing, wobbleDurationMs, wobbleEasing } = word.config.word;
|
|
163
|
+
const keyframes = [
|
|
164
|
+
{ transform: wobbleFrom },
|
|
165
|
+
{ transform: wobblePeak, offset: wobblePeakOffset, easing: wobblePeakEasing },
|
|
166
|
+
{ transform: wobbleSettle, offset: Math.max(wobblePeakOffset, wobbleSettleOffset) },
|
|
167
|
+
{ transform: wobbleTo, easing: wobbleEndEasing },
|
|
168
|
+
];
|
|
169
|
+
const timing = { duration: wobbleDurationMs, easing: wobbleEasing, fill: "forwards" };
|
|
170
|
+
const currentTimeMs = scheduledTimeMs(word, word.elapsedMs, wobbleDurationMs);
|
|
171
|
+
return word.part.wobbleElements.map(element => followSong(word, element.animate(keyframes, timing), currentTimeMs));
|
|
172
|
+
}
|
|
173
|
+
function letterWave(word) {
|
|
174
|
+
const { part, config } = word;
|
|
175
|
+
const letterCount = part.letterElements?.length ?? 0;
|
|
176
|
+
if (letterCount === 0)
|
|
177
|
+
return [];
|
|
178
|
+
const run = planLetterWaveRun(word, letterCount);
|
|
179
|
+
const glowLetterSets = glowShows(part, config)
|
|
180
|
+
? (part.sweep?.flatMap(cell => cell.glows.map(glow => glow.letters)) ?? [])
|
|
181
|
+
: [];
|
|
182
|
+
const animations = [];
|
|
183
|
+
floatLetters(word, run, part.letterElements, true, animations);
|
|
184
|
+
floatLetters(word, run, part.highlightLetterElements, false, animations);
|
|
185
|
+
for (const glowLetters of glowLetterSets)
|
|
186
|
+
floatLetters(word, run, glowLetters, false, animations);
|
|
187
|
+
return animations;
|
|
188
|
+
}
|
|
189
|
+
function planLetterWaveRun(word, letterCount) {
|
|
190
|
+
const { config } = word;
|
|
191
|
+
const emphasise = word.part.lyricElement.dataset.longWord === "true";
|
|
192
|
+
const emphasisPeak = emphasise ? ` scale(${config.letterWave.emphasisScale})` : "";
|
|
193
|
+
const emphasisRest = emphasise ? " scale(1)" : "";
|
|
194
|
+
const keyframes = [
|
|
195
|
+
{ transform: `translateY(0)${emphasisRest}`, easing: config.letterWave.riseEasing },
|
|
196
|
+
{
|
|
197
|
+
transform: `${config.letterWave.transform}${emphasisPeak}`,
|
|
198
|
+
offset: LETTER_WAVE_CREST_OFFSET,
|
|
199
|
+
easing: config.letterWave.fallEasing,
|
|
200
|
+
},
|
|
201
|
+
{ transform: `${config.letterWave.settle}${emphasisRest}` },
|
|
202
|
+
];
|
|
203
|
+
const waves = planLetterWave(swipeRamp(config), letterCount, word.durationMs, word.swipeDurationMs, word.swipeLeadMs, config.letterWave.durationMs);
|
|
204
|
+
// Carry early starts in the clock offset; negative delays make finished waves appear late to drift sampling.
|
|
205
|
+
const headStartMs = Math.max(0, -Math.min(...waves.map(wave => wave.delayMs)));
|
|
206
|
+
const waveEndsMs = waves.map(wave => wave.delayMs + wave.durationMs);
|
|
207
|
+
const lastWaveEndMs = Math.max(...waveEndsMs);
|
|
208
|
+
return {
|
|
209
|
+
waves,
|
|
210
|
+
keyframes,
|
|
211
|
+
signature: JSON.stringify(keyframes),
|
|
212
|
+
headStartMs,
|
|
213
|
+
lastEndingWaveIndex: waveEndsMs.lastIndexOf(lastWaveEndMs),
|
|
214
|
+
startAtMs: scheduledTimeMs(word, word.elapsedMs + headStartMs, headStartMs + lastWaveEndMs),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function floatLetters(word, run, letters, isBaseText, animations) {
|
|
218
|
+
letters?.forEach((letterElement, index) => {
|
|
219
|
+
const wave = run.waves[index];
|
|
220
|
+
const delayMs = wave.delayMs + run.headStartMs;
|
|
221
|
+
const float = acquireWaveAnimation(word.engine, letterElement, run.keyframes, run.signature, {
|
|
222
|
+
duration: wave.durationMs,
|
|
223
|
+
delay: delayMs,
|
|
224
|
+
fill: "forwards",
|
|
225
|
+
});
|
|
226
|
+
const skipDriftSample = !isBaseText || index !== run.lastEndingWaveIndex;
|
|
227
|
+
animations.push(followSong(word, float, run.startAtMs, { offsetMs: run.headStartMs, skipDriftSample }));
|
|
228
|
+
if (!GECKO_REDRAW || !isBaseText)
|
|
229
|
+
return;
|
|
230
|
+
const redraw = letterElement.animate(GECKO_REDRAW_KEYFRAMES, {
|
|
231
|
+
duration: GECKO_REDRAW_PERIOD_MS,
|
|
232
|
+
iterations: wave.durationMs / GECKO_REDRAW_PERIOD_MS,
|
|
233
|
+
delay: delayMs,
|
|
234
|
+
composite: "add",
|
|
235
|
+
});
|
|
236
|
+
animations.push(followSong(word, redraw, run.startAtMs, { offsetMs: run.headStartMs, skipDriftSample: true }));
|
|
237
|
+
});
|
|
238
|
+
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import type { PartData } from "./inject.js";
|
|
2
1
|
export declare const imageHighlights: import("./themeSettings.js").Setting;
|
|
3
|
-
export interface ImageHighlightLayers {
|
|
4
|
-
glow: HTMLElement;
|
|
5
|
-
glowLetters: HTMLElement[];
|
|
6
|
-
/** A separate inline layout host, only for runs that can fragment. */
|
|
7
|
-
highlight?: HTMLElement;
|
|
8
|
-
}
|
|
9
|
-
export declare function wrapImageHighlight(highlight: HTMLElement): ImageHighlightLayers | undefined;
|
|
10
|
-
/** Keep bidi ordering and inline fragments in the browser's normal text layout. An
|
|
11
|
-
* absolutely positioned copy inside an inline word cannot reproduce those fragments. */
|
|
12
|
-
export declare function alignImageGlowRun(run: HTMLElement, parts: PartData[]): void;
|
|
13
2
|
/** A single CSS url(), not gradients or an arbitrary list of background layers. */
|
|
14
3
|
export declare function imageURL(value: string): string | null;
|
|
15
4
|
export declare function refreshInstrumentalImages(container: HTMLElement | null, view: Window): void;
|
package/dist/imageHighlights.js
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
// Optional image paint, independent of HDR: a theme supplies the image and
|
|
2
|
-
//
|
|
3
|
-
// cannot be cut off by the karaoke mask. Both copies are driven by the engine's own animations.
|
|
1
|
+
// Optional image paint for the instrumental note, independent of HDR: a theme supplies the image and
|
|
2
|
+
// its dynamic range.
|
|
4
3
|
import { registerThemeSetting } from "./themeSettings.js";
|
|
5
4
|
export const imageHighlights = registerThemeSetting("blyrics-image-highlights", false, true);
|
|
6
|
-
export function wrapImageHighlight(highlight) {
|
|
7
|
-
if (!imageHighlights.getBooleanValue())
|
|
8
|
-
return;
|
|
9
|
-
const doc = highlight.ownerDocument;
|
|
10
|
-
const paint = doc.createElement("span");
|
|
11
|
-
paint.classList.add("blyrics-image-fill");
|
|
12
|
-
while (highlight.firstChild)
|
|
13
|
-
paint.appendChild(highlight.firstChild);
|
|
14
|
-
const glow = doc.createElement("span");
|
|
15
|
-
glow.classList.add("blyrics-image-glow");
|
|
16
|
-
glow.setAttribute("aria-hidden", "true");
|
|
17
|
-
glow.appendChild(paint.cloneNode(true));
|
|
18
|
-
highlight.classList.add("blyrics-image-highlight");
|
|
19
|
-
highlight.appendChild(glow);
|
|
20
|
-
highlight.appendChild(paint);
|
|
21
|
-
return { glow, glowLetters: Array.from(glow.querySelectorAll(".blyrics--letter")) };
|
|
22
|
-
}
|
|
23
|
-
/** Keep bidi ordering and inline fragments in the browser's normal text layout. An
|
|
24
|
-
* absolutely positioned copy inside an inline word cannot reproduce those fragments. */
|
|
25
|
-
export function alignImageGlowRun(run, parts) {
|
|
26
|
-
if (!imageHighlights.getBooleanValue())
|
|
27
|
-
return;
|
|
28
|
-
if (!run.parentElement?.classList.contains("blyrics-bidi-sensitive") &&
|
|
29
|
-
!run.querySelector(".blyrics-word-group-long"))
|
|
30
|
-
return;
|
|
31
|
-
const originals = Array.from(run.querySelectorAll(".blyrics-word-highlight"));
|
|
32
|
-
const byHighlight = new Map(parts.map(part => [part.highlightElement, part]));
|
|
33
|
-
const glowRun = run.cloneNode(true);
|
|
34
|
-
glowRun.classList.add("blyrics-image-glow-run");
|
|
35
|
-
const copies = glowRun.querySelectorAll(".blyrics-word-highlight");
|
|
36
|
-
originals.forEach((original, index) => {
|
|
37
|
-
const part = byHighlight.get(original);
|
|
38
|
-
if (!part?.imageLayers)
|
|
39
|
-
return;
|
|
40
|
-
const copy = copies[index];
|
|
41
|
-
copy.replaceChildren(part.imageLayers.glow);
|
|
42
|
-
part.imageLayers.highlight = copy;
|
|
43
|
-
// Non-fragmented groups in a mixed run can still wobble. Give their glow the
|
|
44
|
-
// identical group transform, rather than letting it drift from the sharp copy.
|
|
45
|
-
const group = original.parentElement;
|
|
46
|
-
if (group && part.wobbleElements.includes(group) && copy.parentElement)
|
|
47
|
-
part.wobbleElements.push(copy.parentElement);
|
|
48
|
-
});
|
|
49
|
-
run.parentElement.insertBefore(glowRun, run);
|
|
50
|
-
}
|
|
51
5
|
/** A single CSS url(), not gradients or an arbitrary list of background layers. */
|
|
52
6
|
export function imageURL(value) {
|
|
53
7
|
const match = /^url\(\s*(?:"([^"]*)"|'([^']*)'|([^\s'"()]+))\s*\)$/i.exec(value.trim());
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { resetPlaybackClock
|
|
1
|
+
export { resetPlaybackClock } from "./engine/clock.js";
|
|
2
|
+
export { resumeAllAutoscroll } from "./engine/userScroll.js";
|
|
2
3
|
export { injectRomanization, injectTranslation, type LineData, removeRomanization, removeTranslation, } from "./inject.js";
|
|
3
4
|
export { createLyricsRenderer } from "./renderer.js";
|
|
4
5
|
export type { Lyric, LyricsRenderer, LyricsRendererHost, TickOptions } from "./types.js";
|
|
5
6
|
/** @public */
|
|
6
|
-
export type { AnimationTickStatus } from "./engine.js";
|
|
7
|
+
export type { AnimationTickStatus } from "./engine/tick.js";
|
|
7
8
|
/** @public */
|
|
8
9
|
export type { PartData } from "./inject.js";
|
|
9
10
|
/** @public */
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// `createLyricsRenderer` is the way in. The four values beside it are what one instance cannot
|
|
7
7
|
// answer for on its own: the song level operations address every live view at once, and the
|
|
8
8
|
// injection helpers decorate lines that are already built.
|
|
9
|
-
export { resetPlaybackClock
|
|
9
|
+
export { resetPlaybackClock } from "./engine/clock.js";
|
|
10
|
+
export { resumeAllAutoscroll } from "./engine/userScroll.js";
|
|
10
11
|
export { injectRomanization, injectTranslation, removeRomanization, removeTranslation, } from "./inject.js";
|
|
11
12
|
export { createLyricsRenderer } from "./renderer.js";
|
package/dist/inject.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ImageHighlightLayers } from "./imageHighlights.js";
|
|
2
1
|
import { type WordState } from "./constants.js";
|
|
3
2
|
import type { Lyric, LyricPart, LyricSyncType } from "./types.js";
|
|
4
3
|
export declare let disableRichsync: import("./themeSettings.js").Setting;
|
|
@@ -18,9 +17,46 @@ export interface AnimationData {
|
|
|
18
17
|
lyricElement: HTMLElement;
|
|
19
18
|
animations: Animation[];
|
|
20
19
|
}
|
|
20
|
+
/** A copy of the word under a text shadow that never changes, faded in and out by opacity. */
|
|
21
|
+
export interface SweepGlow {
|
|
22
|
+
glow: HTMLElement;
|
|
23
|
+
letters?: HTMLElement[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One box of a word's sweep, run by the compositor: the whole word when it is its own inline-block
|
|
27
|
+
* box, or one letter of a word that flows inline. Its mask holds a static soft edge and slides one way
|
|
28
|
+
* while the text inside it slides the other, so the glyphs hold still and only the edge crosses them.
|
|
29
|
+
* The glow is a pair of halos at two radii inside the same text, so the edge reveals them with it,
|
|
30
|
+
* crossfaded so the glow tightens as it fades. With nothing animating, the mask rests with the cell
|
|
31
|
+
* fully lit.
|
|
32
|
+
*/
|
|
33
|
+
export interface SweepCell {
|
|
34
|
+
mask: HTMLElement;
|
|
35
|
+
text: HTMLElement;
|
|
36
|
+
letters?: HTMLElement[];
|
|
37
|
+
glows: SweepGlow[];
|
|
38
|
+
/** Where the cell sits along the word, as fractions of the word's width; equal shares if unset. */
|
|
39
|
+
span?: {
|
|
40
|
+
start: number;
|
|
41
|
+
width: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The sweep of a word that flows inline without letters: a word in a bidi-sensitive row or a long
|
|
46
|
+
* group whose script joins or whose letters are not split. Such a word can break across lines and
|
|
47
|
+
* shape with its neighbours, so no box of its own can hold the sweep. The engine places a cell over
|
|
48
|
+
* each box the word breaks into, drawing the word from a copy of its line, once the line is laid out.
|
|
49
|
+
*/
|
|
50
|
+
export interface SweepContext {
|
|
51
|
+
host?: HTMLElement;
|
|
52
|
+
placedAt?: string;
|
|
53
|
+
unplaced?: boolean;
|
|
54
|
+
}
|
|
21
55
|
export interface PartData extends AnimationData {
|
|
22
56
|
highlightElement: HTMLElement;
|
|
23
|
-
|
|
57
|
+
/** The sweep's cells in reading order. */
|
|
58
|
+
sweep?: SweepCell[];
|
|
59
|
+
sweepContext?: SweepContext;
|
|
24
60
|
letterElements?: HTMLElement[];
|
|
25
61
|
highlightLetterElements?: HTMLElement[];
|
|
26
62
|
wobbleElements: HTMLElement[];
|
|
@@ -41,6 +77,9 @@ export type LineData = {
|
|
|
41
77
|
} & AnimationData;
|
|
42
78
|
export declare function newLineData(lyricElement: HTMLElement, startTimeMs: number, durationMs: number): LineData;
|
|
43
79
|
export declare function applyDirection(element: HTMLElement, text: string): void;
|
|
80
|
+
/** Puts a copy of the cell's text into an element, returning its letters if the word is split. */
|
|
81
|
+
export type FillSweepText = (into: HTMLElement) => HTMLElement[] | undefined;
|
|
82
|
+
export declare function createSweepCell(doc: Document, host: HTMLElement, fill: FillSweepText): SweepCell;
|
|
44
83
|
export declare function createLyricsLine(doc: Document, parts: LyricPart[], line: LineData, lyricElement: HTMLElement, options?: {
|
|
45
84
|
splitBackgroundLine: boolean;
|
|
46
85
|
}): HTMLElement;
|
package/dist/inject.js
CHANGED
|
@@ -11,10 +11,9 @@
|
|
|
11
11
|
// animates is one word, so every part is split on whitespace with its timing pro-rated across the
|
|
12
12
|
// split by character count. A line that arrives with no timed parts at all is rebuilt the same way
|
|
13
13
|
// into zero duration words, so line synced lyrics reach the DOM the sweep already knows.
|
|
14
|
-
import { releasePart } from "./engine.js";
|
|
15
|
-
import { alignImageGlowRun, wrapImageHighlight } from "./imageHighlights.js";
|
|
14
|
+
import { releasePart } from "./engine/lineAnimationState.js";
|
|
16
15
|
import { normalizeLanguage } from "./language.js";
|
|
17
|
-
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
|
+
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, SWEEP_CELL_CLASS, SWEEP_GLOW_CLASS, SWEEP_MASK_CLASS, SWEEP_TEXT_CLASS, TRANSLATED_LYRICS_CLASS, WORD_CLASS, WORD_GROUP_CLASS, WORD_HIGHLIGHT_CLASS, WORD_HIGHLIGHT_CONTEXT_CLASS, WORD_HIGHLIGHT_LETTERED_CLASS, WORD_HIGHLIGHT_SWEEP_CLASS, WORD_STATE_ATTR, WORD_STATE_UPCOMING, ZERO_DURATION_ANIMATION_CLASS, } from "./constants.js";
|
|
18
17
|
import { getSeekTimeFromClick } from "./seek.js";
|
|
19
18
|
import { isSameText, testJoiningScript, testRtl } from "./text.js";
|
|
20
19
|
import { registerThemeSetting } from "./themeSettings.js";
|
|
@@ -65,13 +64,14 @@ export function deriveSyncType(lyrics) {
|
|
|
65
64
|
return "richsync";
|
|
66
65
|
return lyrics.every(item => item.startTimeMs === 0) ? "none" : "synced";
|
|
67
66
|
}
|
|
68
|
-
function newPartData(part, span, highlight, wobbleElements, letterElements, highlightLetterElements) {
|
|
67
|
+
function newPartData(part, span, highlight, wobbleElements, letterElements, highlightLetterElements, sweep) {
|
|
69
68
|
return {
|
|
70
69
|
time: part.startTimeMs / 1000,
|
|
71
70
|
duration: part.durationMs / 1000,
|
|
72
71
|
lyricElement: span,
|
|
73
72
|
highlightElement: highlight,
|
|
74
|
-
|
|
73
|
+
sweep,
|
|
74
|
+
sweepContext: highlight.classList.contains(WORD_HIGHLIGHT_CONTEXT_CLASS) ? {} : undefined,
|
|
75
75
|
letterElements,
|
|
76
76
|
highlightLetterElements,
|
|
77
77
|
wobbleElements,
|
|
@@ -210,9 +210,6 @@ function appendLongWordBreaks(doc, span, text, threshold) {
|
|
|
210
210
|
function appendLetters(doc, wordElement, text) {
|
|
211
211
|
const chars = [...graphemeSegmenter.segment(text)].map(segment => segment.segment);
|
|
212
212
|
wordElement.style.setProperty("--letters", String(chars.length));
|
|
213
|
-
// Width of the reveal mask's soft edge as a percentage of its (n+2)-letter-wide box, so the fade
|
|
214
|
-
// spans the same 0.1*letters of a letter that the old gradient did. See the mask rule in lyrics.css.
|
|
215
|
-
wordElement.style.setProperty("--mask-fade", `${(10 * chars.length) / (chars.length + 2)}%`);
|
|
216
213
|
return chars.map(char => {
|
|
217
214
|
const letter = doc.createElement("span");
|
|
218
215
|
letter.classList.add(LETTER_CLASS);
|
|
@@ -221,10 +218,50 @@ function appendLetters(doc, wordElement, text) {
|
|
|
221
218
|
return letter;
|
|
222
219
|
});
|
|
223
220
|
}
|
|
224
|
-
function
|
|
221
|
+
function fillWordText(doc, host, text, wrapThreshold, perLetter, preserveJoining) {
|
|
222
|
+
if (perLetter)
|
|
223
|
+
return appendLetters(doc, host, text);
|
|
224
|
+
if (preserveJoining)
|
|
225
|
+
host.textContent = text;
|
|
226
|
+
else
|
|
227
|
+
appendLongWordBreaks(doc, host, text, wrapThreshold);
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
const SWEEP_GLOW_RADII = ["wide", "tight"];
|
|
231
|
+
export function createSweepCell(doc, host, fill) {
|
|
232
|
+
const mask = doc.createElement("span");
|
|
233
|
+
mask.classList.add(SWEEP_MASK_CLASS);
|
|
234
|
+
const text = doc.createElement("span");
|
|
235
|
+
text.classList.add(SWEEP_TEXT_CLASS);
|
|
236
|
+
mask.appendChild(text);
|
|
237
|
+
const letters = fill(text);
|
|
238
|
+
const glows = SWEEP_GLOW_RADII.map(radius => {
|
|
239
|
+
const glow = doc.createElement("span");
|
|
240
|
+
glow.classList.add(SWEEP_GLOW_CLASS, `${SWEEP_GLOW_CLASS}--${radius}`);
|
|
241
|
+
const glowLetters = fill(glow);
|
|
242
|
+
text.appendChild(glow);
|
|
243
|
+
return { glow, letters: glowLetters };
|
|
244
|
+
});
|
|
245
|
+
host.classList.add(SWEEP_CELL_CLASS);
|
|
246
|
+
host.appendChild(mask);
|
|
247
|
+
return { mask, text, letters, glows };
|
|
248
|
+
}
|
|
249
|
+
/** Makes each letter of a word that flows inline its own sweep cell, holding the letter's text. */
|
|
250
|
+
function createLetterSweepCells(doc, letters) {
|
|
251
|
+
return letters.map(letter => {
|
|
252
|
+
const text = letter.textContent ?? "";
|
|
253
|
+
letter.textContent = "";
|
|
254
|
+
return createSweepCell(doc, letter, into => {
|
|
255
|
+
into.appendChild(doc.createTextNode(text));
|
|
256
|
+
return undefined;
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function createTimedWordSpan(doc, part, wrapThreshold, perLetter, preserveJoining, atomic) {
|
|
225
261
|
const span = doc.createElement("span");
|
|
226
262
|
const highlight = doc.createElement("span");
|
|
227
263
|
highlight.classList.add(WORD_HIGHLIGHT_CLASS);
|
|
264
|
+
let sweep;
|
|
228
265
|
let letters;
|
|
229
266
|
let highlightLetters;
|
|
230
267
|
for (const wordElement of [span, highlight]) {
|
|
@@ -244,30 +281,36 @@ function createTimedWordSpan(doc, part, wrapThreshold, perLetter, preserveJoinin
|
|
|
244
281
|
wordElement.classList.add(EXPLICIT_WORD_CLASS);
|
|
245
282
|
if (perLetter) {
|
|
246
283
|
wordElement.classList.add("blyrics-word--lettered");
|
|
247
|
-
|
|
248
|
-
if (wordElement === span) {
|
|
249
|
-
letters = collected;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
highlightLetters = collected;
|
|
284
|
+
if (wordElement === highlight)
|
|
253
285
|
wordElement.classList.add(WORD_HIGHLIGHT_LETTERED_CLASS);
|
|
254
|
-
}
|
|
255
286
|
}
|
|
256
|
-
|
|
257
|
-
|
|
287
|
+
if (wordElement === highlight && atomic) {
|
|
288
|
+
const cell = createSweepCell(doc, highlight, into => fillWordText(doc, into, part.words, wrapThreshold, perLetter, preserveJoining));
|
|
289
|
+
sweep = [cell];
|
|
290
|
+
highlightLetters = cell.letters;
|
|
258
291
|
}
|
|
259
292
|
else {
|
|
260
|
-
|
|
293
|
+
const collected = fillWordText(doc, wordElement, part.words, wrapThreshold, perLetter, preserveJoining);
|
|
294
|
+
if (wordElement === span)
|
|
295
|
+
letters = collected;
|
|
296
|
+
else
|
|
297
|
+
highlightLetters = collected;
|
|
298
|
+
if (wordElement === highlight && collected)
|
|
299
|
+
sweep = createLetterSweepCells(doc, collected);
|
|
261
300
|
}
|
|
301
|
+
if (wordElement === highlight && sweep)
|
|
302
|
+
highlight.classList.add(WORD_HIGHLIGHT_SWEEP_CLASS);
|
|
303
|
+
else if (wordElement === highlight)
|
|
304
|
+
highlight.classList.add(WORD_HIGHLIGHT_CONTEXT_CLASS);
|
|
262
305
|
wordElement.dataset.time = String(part.startTimeMs / 1000);
|
|
263
306
|
wordElement.dataset.duration = String(part.durationMs / 1000);
|
|
264
307
|
wordElement.dataset.content = part.words;
|
|
265
308
|
wordElement.setAttribute(WORD_STATE_ATTR, WORD_STATE_UPCOMING);
|
|
266
309
|
wordElement.style.setProperty("--blyrics-duration", part.durationMs + "ms");
|
|
267
310
|
}
|
|
268
|
-
return { span, highlight, letters, highlightLetters };
|
|
311
|
+
return { span, highlight, letters, highlightLetters, sweep };
|
|
269
312
|
}
|
|
270
|
-
function createWordGroup(doc, group, lineData) {
|
|
313
|
+
function createWordGroup(doc, group, lineData, wordsFlowInline) {
|
|
271
314
|
const wrapThreshold = Math.max(1, longWordWrapThreshold.getNumberValue());
|
|
272
315
|
// Atomic grapheme spans disrupt the browser's bidi ordering inside a mixed word.
|
|
273
316
|
const mixedDirection = testRtl(group.text) && [...group.text].some(char => /[\p{Letter}\p{Number}]/u.test(char) && !testRtl(char));
|
|
@@ -275,11 +318,15 @@ function createWordGroup(doc, group, lineData) {
|
|
|
275
318
|
const perLetter = letterWave.getBooleanValue() && !preserveJoining && !mixedDirection;
|
|
276
319
|
const lyricGroup = doc.createElement("span");
|
|
277
320
|
const highlightGroup = doc.createElement("span");
|
|
321
|
+
const isLongGroup = group.text.length > wrapThreshold * 2;
|
|
322
|
+
// A word that is its own inline-block box can hold the sweep's block layers. Long groups and
|
|
323
|
+
// bidi-sensitive rows lay their words out inline, where a word can break across lines.
|
|
324
|
+
const atomic = !wordsFlowInline && !isLongGroup;
|
|
278
325
|
for (const groupElement of [lyricGroup, highlightGroup]) {
|
|
279
326
|
groupElement.classList.add(WORD_GROUP_CLASS);
|
|
280
327
|
groupElement.dir = "auto";
|
|
281
328
|
groupElement.dataset.content = group.text;
|
|
282
|
-
if (
|
|
329
|
+
if (isLongGroup) {
|
|
283
330
|
groupElement.classList.add(LONG_WORD_GROUP_CLASS);
|
|
284
331
|
}
|
|
285
332
|
if (group.isBackground) {
|
|
@@ -289,9 +336,9 @@ function createWordGroup(doc, group, lineData) {
|
|
|
289
336
|
for (const token of group.tokens) {
|
|
290
337
|
if (token.kind === "space")
|
|
291
338
|
continue;
|
|
292
|
-
const { span, highlight, letters, highlightLetters } = createTimedWordSpan(doc, token.part, wrapThreshold, perLetter, preserveJoining);
|
|
339
|
+
const { span, highlight, letters, highlightLetters, sweep } = createTimedWordSpan(doc, token.part, wrapThreshold, perLetter, preserveJoining, atomic);
|
|
293
340
|
const wobbleElements = lyricGroup.childNodes.length === 0 ? [lyricGroup, highlightGroup] : [];
|
|
294
|
-
lineData.parts.push(newPartData(token.part, span, highlight, wobbleElements, letters, highlightLetters));
|
|
341
|
+
lineData.parts.push(newPartData(token.part, span, highlight, wobbleElements, letters, highlightLetters, sweep));
|
|
295
342
|
lyricGroup.appendChild(span);
|
|
296
343
|
highlightGroup.appendChild(highlight);
|
|
297
344
|
}
|
|
@@ -379,7 +426,8 @@ export function createLyricsLine(doc, parts, line, lyricElement, options = { spl
|
|
|
379
426
|
target.appendChild(createSpaceNode(doc, pendingSpace, shouldUseBackgroundLine));
|
|
380
427
|
highlightRun.appendChild(createSpaceNode(doc, pendingSpace, shouldUseBackgroundLine));
|
|
381
428
|
}
|
|
382
|
-
const
|
|
429
|
+
const contentLine = backgroundRow ? backgroundRow.line : main;
|
|
430
|
+
const { lyricGroup, highlightGroup } = createWordGroup(doc, item, line, contentLine.classList.contains(BIDI_SENSITIVE_CLASS));
|
|
383
431
|
target.appendChild(lyricGroup);
|
|
384
432
|
highlightRun.appendChild(highlightGroup);
|
|
385
433
|
if (backgroundRow) {
|
|
@@ -395,9 +443,6 @@ export function createLyricsLine(doc, parts, line, lyricElement, options = { spl
|
|
|
395
443
|
.filter(([, row]) => row.used)
|
|
396
444
|
.sort(([a], [b]) => a - b)
|
|
397
445
|
.map(([, row]) => row);
|
|
398
|
-
alignImageGlowRun(mainHighlightRun, line.parts);
|
|
399
|
-
for (const row of usedBackgroundRows)
|
|
400
|
-
alignImageGlowRun(row.highlightRun, line.parts);
|
|
401
446
|
lyricElement.appendChild(main);
|
|
402
447
|
for (const row of usedBackgroundRows)
|
|
403
448
|
lyricElement.appendChild(row.line);
|
package/dist/renderer.js
CHANGED
|
@@ -11,7 +11,13 @@
|
|
|
11
11
|
// diagnostic overlay supplies the sink, and one that says nothing draws nothing.
|
|
12
12
|
import { imageHighlights, refreshInstrumentalImages } from "./imageHighlights.js";
|
|
13
13
|
import { CUSTOM_THEME_STYLE_ID } from "./constants.js";
|
|
14
|
-
import { clearLyrics, clearOnScreenLyrics as clearEngineOnScreenLyrics,
|
|
14
|
+
import { clearLyrics, clearOnScreenLyrics as clearEngineOnScreenLyrics, getRenderedLines, getRenderedSyncType, settleSwappedLines, } from "./engine/renderedLines.js";
|
|
15
|
+
import { clearStyleCaches as clearEngineStyleCaches } from "./engine/cssValues.js";
|
|
16
|
+
import { createAnimationEngineInstance } from "./engine/instance.js";
|
|
17
|
+
import { hasUnsyncedLyrics } from "./engine/passiveScroll.js";
|
|
18
|
+
import { hasContainerResized, noteUserScroll as noteEngineUserScroll, resetScrollResume } from "./engine/userScroll.js";
|
|
19
|
+
import { noteVisibilityChange as noteEngineVisibilityChange } from "./engine/timingLogs.js";
|
|
20
|
+
import { relayout, resolveTickOptions, retickAtLastTime, retickFromPlaybackClock as retickEngineFromPlaybackClock, scheduleLyricPositionUpdate as scheduleEngineLyricPositionUpdate, tickView, } from "./engine/tick.js";
|
|
15
21
|
import { parseThemeConfig, setThemeSettings } from "./themeSettings.js";
|
|
16
22
|
import { applyLyricLanguage, normalizeLanguage, resolveLyricLanguages } from "./language.js";
|
|
17
23
|
import { setLyrics as buildLyricsView, swapLyrics as swapLyricsView } from "./view.js";
|
|
@@ -170,7 +176,8 @@ export function createLyricsRenderer(rendererOptions) {
|
|
|
170
176
|
*/
|
|
171
177
|
function measure(measureLines = true) {
|
|
172
178
|
forgetScrollElement();
|
|
173
|
-
relayout(engine, measureLines && areLinesMeasurable(getRenderedLines(engine)))
|
|
179
|
+
if (relayout(engine, measureLines && areLinesMeasurable(getRenderedLines(engine))))
|
|
180
|
+
retickAtLastTime(engine);
|
|
174
181
|
}
|
|
175
182
|
function stopObservingContainer() {
|
|
176
183
|
containerResizeObserver?.disconnect();
|
|
@@ -199,7 +206,7 @@ export function createLyricsRenderer(rendererOptions) {
|
|
|
199
206
|
const target = entries[entries.length - 1]?.target;
|
|
200
207
|
if (!target)
|
|
201
208
|
return;
|
|
202
|
-
if (
|
|
209
|
+
if (hasContainerResized(engine, target.clientWidth, target.clientHeight))
|
|
203
210
|
measure();
|
|
204
211
|
});
|
|
205
212
|
observer.observe(container);
|