@braccato/core 1.20.1 → 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 +0 -5
- package/dist/engine/animationConfig.js +0 -5
- package/dist/engine/animationTiming.d.ts +2 -1
- package/dist/engine/animationTiming.js +3 -2
- package/dist/engine/contextSweep.d.ts +10 -0
- package/dist/engine/contextSweep.js +102 -0
- package/dist/engine/culling.js +9 -0
- package/dist/engine/decorationSlides.d.ts +1 -1
- package/dist/engine/decorationSlides.js +13 -4
- package/dist/engine/elementMotion.d.ts +17 -0
- package/dist/engine/elementMotion.js +98 -0
- package/dist/engine/glow.js +1 -1
- package/dist/engine/instance.d.ts +5 -2
- package/dist/engine/instance.js +3 -1
- package/dist/engine/letterPlans.d.ts +0 -11
- package/dist/engine/letterPlans.js +0 -41
- package/dist/engine/lineAnimationState.js +0 -3
- package/dist/engine/lineAnimations.d.ts +1 -1
- package/dist/engine/lineAnimations.js +5 -24
- package/dist/engine/lineLifecycle.js +1 -1
- package/dist/engine/lineScroll.d.ts +5 -6
- package/dist/engine/lineScroll.js +36 -26
- package/dist/engine/lineScrollStyle.d.ts +8 -3
- package/dist/engine/lineScrollStyle.js +18 -4
- package/dist/engine/motionCurves.d.ts +19 -0
- package/dist/engine/motionCurves.js +85 -0
- package/dist/engine/renderedLines.d.ts +1 -2
- package/dist/engine/renderedLines.js +8 -15
- package/dist/engine/sweepPlans.d.ts +36 -0
- package/dist/engine/sweepPlans.js +59 -0
- package/dist/engine/tick.d.ts +4 -1
- package/dist/engine/tick.js +30 -6
- package/dist/engine/wavePool.d.ts +0 -1
- package/dist/engine/wordAnimations.d.ts +1 -5
- package/dist/engine/wordAnimations.js +88 -66
- package/dist/imageHighlights.d.ts +0 -11
- package/dist/imageHighlights.js +2 -48
- package/dist/inject.d.ts +41 -2
- package/dist/inject.js +72 -27
- package/dist/renderer.js +3 -2
- package/dist/styles/image-highlights.css +1 -59
- package/dist/styles/lyrics.css +128 -57
- package/dist/view.d.ts +1 -1
- package/dist/view.js +4 -3
- package/package.json +1 -1
- package/dist/engine/highlightKeyframes.d.ts +0 -8
- package/dist/engine/highlightKeyframes.js +0 -37
package/dist/inject.js
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
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
14
|
import { releasePart } from "./engine/lineAnimationState.js";
|
|
15
|
-
import { alignImageGlowRun, wrapImageHighlight } from "./imageHighlights.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
|
@@ -17,7 +17,7 @@ import { createAnimationEngineInstance } from "./engine/instance.js";
|
|
|
17
17
|
import { hasUnsyncedLyrics } from "./engine/passiveScroll.js";
|
|
18
18
|
import { hasContainerResized, noteUserScroll as noteEngineUserScroll, resetScrollResume } from "./engine/userScroll.js";
|
|
19
19
|
import { noteVisibilityChange as noteEngineVisibilityChange } from "./engine/timingLogs.js";
|
|
20
|
-
import { relayout, resolveTickOptions, retickFromPlaybackClock as retickEngineFromPlaybackClock, scheduleLyricPositionUpdate as scheduleEngineLyricPositionUpdate, tickView, } from "./engine/tick.js";
|
|
20
|
+
import { relayout, resolveTickOptions, retickAtLastTime, retickFromPlaybackClock as retickEngineFromPlaybackClock, scheduleLyricPositionUpdate as scheduleEngineLyricPositionUpdate, tickView, } from "./engine/tick.js";
|
|
21
21
|
import { parseThemeConfig, setThemeSettings } from "./themeSettings.js";
|
|
22
22
|
import { applyLyricLanguage, normalizeLanguage, resolveLyricLanguages } from "./language.js";
|
|
23
23
|
import { setLyrics as buildLyricsView, swapLyrics as swapLyricsView } from "./view.js";
|
|
@@ -176,7 +176,8 @@ export function createLyricsRenderer(rendererOptions) {
|
|
|
176
176
|
*/
|
|
177
177
|
function measure(measureLines = true) {
|
|
178
178
|
forgetScrollElement();
|
|
179
|
-
relayout(engine, measureLines && areLinesMeasurable(getRenderedLines(engine)))
|
|
179
|
+
if (relayout(engine, measureLines && areLinesMeasurable(getRenderedLines(engine))))
|
|
180
|
+
retickAtLastTime(engine);
|
|
180
181
|
}
|
|
181
182
|
function stopObservingContainer() {
|
|
182
183
|
containerResizeObserver?.disconnect();
|
|
@@ -1,67 +1,9 @@
|
|
|
1
|
-
/* The renderer adds
|
|
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
|
}
|
package/dist/styles/lyrics.css
CHANGED
|
@@ -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
|
-
.
|
|
186
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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-
|
|
208
|
-
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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/view.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
@@ -14,7 +14,8 @@
|
|
|
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
16
|
import {} from "./engine/instance.js";
|
|
17
|
-
import {
|
|
17
|
+
import { elementMotionOffsetPx } from "./engine/elementMotion.js";
|
|
18
|
+
import { replaceRenderedLines } from "./engine/renderedLines.js";
|
|
18
19
|
import { playerTimeForLyricTime } from "./engine/clock.js";
|
|
19
20
|
import { setupLineCullObserver } from "./engine/culling.js";
|
|
20
21
|
import { addSeekHandler, applyDirection, buildLineSyncedParts, createLyricsLine, deriveSyncType, disableRichsync, findNearestAgent, hideCredits, isNearestLyricRtl, moveDecorations, newLineData, } from "./inject.js";
|
|
@@ -354,7 +355,7 @@ export function swapLyrics(engine, mount, lyrics, options) {
|
|
|
354
355
|
line.lyricElement.dataset.lineNumber = String(lineIndex);
|
|
355
356
|
applyLyricLanguage(line.lyricElement, context.languages[lineIndex]);
|
|
356
357
|
lines.push(line);
|
|
357
|
-
positions.set(line, { position: line.position, height: line.height,
|
|
358
|
+
positions.set(line, { position: line.position, height: line.height, motionOffset: 0 });
|
|
358
359
|
continue;
|
|
359
360
|
}
|
|
360
361
|
if (unmatchedOld.length === 0) {
|
|
@@ -369,7 +370,7 @@ export function swapLyrics(engine, mount, lyrics, options) {
|
|
|
369
370
|
position: standsFor.position,
|
|
370
371
|
height: standsFor.height,
|
|
371
372
|
// A kept line finishes its own line scroll; this one starts where the line it replaced was.
|
|
372
|
-
|
|
373
|
+
motionOffset: elementMotionOffsetPx(engine, standsFor.lyricElement),
|
|
373
374
|
});
|
|
374
375
|
if (decorationKeys.get(standsFor) === decorationKeys.get(line))
|
|
375
376
|
moveDecorations(standsFor, line);
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PartData } from "../inject.js";
|
|
2
|
-
import type { AnimationConfig } from "./animationConfig.js";
|
|
3
|
-
export declare function swipeKeyframes(config: AnimationConfig): Keyframe[];
|
|
4
|
-
export declare function glowKeyframes({ highlight }: AnimationConfig, part: PartData): Keyframe[];
|
|
5
|
-
export declare function shownKeyframes(): Keyframe[];
|
|
6
|
-
export declare function shownFullySweptKeyframes(config: AnimationConfig): Keyframe[];
|
|
7
|
-
export declare function fadeInFullySweptKeyframes(config: AnimationConfig): Keyframe[];
|
|
8
|
-
export declare function fadeOutKeyframes(config: AnimationConfig, part: PartData): Keyframe[];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
function swipeAmounts({ highlight }, end) {
|
|
2
|
-
return {
|
|
3
|
-
"--lyric-transition-amount-start": end === "from" ? highlight.swipeStartFrom : highlight.swipeStartTo,
|
|
4
|
-
"--lyric-transition-amount-end": end === "from" ? highlight.swipeEndFrom : highlight.swipeEndTo,
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export function swipeKeyframes(config) {
|
|
8
|
-
return [swipeAmounts(config, "from"), swipeAmounts(config, "to")];
|
|
9
|
-
}
|
|
10
|
-
export function glowKeyframes({ highlight }, part) {
|
|
11
|
-
if (!part.imageLayers)
|
|
12
|
-
return [{ filter: highlight.glowFrom }, { filter: highlight.glowTo }];
|
|
13
|
-
return [
|
|
14
|
-
{ filter: `blur(${highlight.imageGlowFrom})`, opacity: highlight.imageGlowOpacityFrom },
|
|
15
|
-
{ filter: `blur(${highlight.imageGlowTo})`, opacity: highlight.imageGlowOpacityTo },
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
export function shownKeyframes() {
|
|
19
|
-
return [{ opacity: 1 }, { opacity: 1 }];
|
|
20
|
-
}
|
|
21
|
-
export function shownFullySweptKeyframes(config) {
|
|
22
|
-
const shown = { opacity: 1, ...swipeAmounts(config, "to") };
|
|
23
|
-
return [shown, shown];
|
|
24
|
-
}
|
|
25
|
-
export function fadeInFullySweptKeyframes(config) {
|
|
26
|
-
return [
|
|
27
|
-
{ opacity: 0, ...swipeAmounts(config, "to") },
|
|
28
|
-
{ opacity: 1, ...swipeAmounts(config, "to") },
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
export function fadeOutKeyframes(config, part) {
|
|
32
|
-
const filter = part.imageLayers ? "none" : config.highlight.glowTo;
|
|
33
|
-
return [
|
|
34
|
-
{ opacity: 1, filter, ...swipeAmounts(config, "to") },
|
|
35
|
-
{ opacity: 0, filter, ...swipeAmounts(config, "to") },
|
|
36
|
-
];
|
|
37
|
-
}
|