@braccato/core 2.0.0-beta.1 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,18 +69,34 @@ The element takes the same `Lyric[]` as `@braccato/core` and keeps most of its s
69
69
  | Property | Notes |
70
70
  | --------------- | ----- |
71
71
  | `lyrics` | `Lyric[]`. Writing it builds the view. |
72
- | `lyricsOptions` | `{ noLyrics?, language?, songwriters? }`, read by the next `lyrics` write. |
72
+ | `lyricsOptions` | `{ noLyrics?, language?, songwriters?, songKey? }`, read by the next `lyrics` write. |
73
73
  | `source` | A media element or a selector for one. It drives the clock. |
74
74
  | `currentTime`, `playing` | Drive the clock by hand when there is no `source`. |
75
- | `tickOptions` | `{ lyricOffset?, globalLyricOffset?, playbackRate?, smoothScroll?, passiveScrollEnabled? }` |
75
+ | `tickOptions` | `{ lyricOffset?, globalLyricOffset?, richsyncOffsetTrim?, lineOffsetTrim?, playbackRate?, smoothScroll?, passiveScrollEnabled? }`. The trims, in seconds, come off the theme's lead (below). |
76
76
  | `theme` | A stylesheet: `--blyrics-*` custom properties, and `/* blyrics-key = value; */` settings in comments. |
77
- | `host` | `{ getScrollElement? }`, the element autoscroll moves. |
77
+ | `host` | `{ getScrollElement? }`, the element autoscroll moves. Without it, the nearest scrollable element, which can be the element itself (`overflow-y: auto` and a height on it). |
78
78
  | `layout` | `"scroll"` or `"stage"`. Also an attribute. |
79
79
  | `decorations` | `{ translations, romanizations }`: whether to show the lyrics' own `translations` and `romanization` / `timedRomanization`. Both on by default. |
80
- | `renderer` | The Rust `Renderer`, which has `resumeAutoscroll()`, `relayout()`, `setProfiling(on)`, `stats()` and `takeProfile()`. |
80
+ | `renderer` | The Rust `Renderer`, which has `resumeAutoscroll()`, `relayout()`, `timingOffsets()`, `setProfiling(on)`, `stats()` and `takeProfile()`. |
81
+
82
+ Properties written before the element is defined, as a page that imports it lazily may write them,
83
+ are applied once it connects. `@braccato/core/element` has types, which name each event's `detail`.
81
84
 
82
85
  It dispatches the same events: `braccato:lyrics-loaded`, `braccato:line-click`,
83
- `braccato:scroll-state`, `braccato:stage-layout` and `braccato:error`.
86
+ `braccato:scroll-state`, `braccato:stage-layout` and `braccato:error`. A line click's `timeS` is the
87
+ player time to seek to, to the microsecond.
88
+
89
+ Lines light ahead of the player by the theme's `--blyrics-richsync-timing-offset` (word-synced,
90
+ 0.15s by default) and `--blyrics-timing-offset` (line-synced, 0.115s), less the trims in
91
+ `tickOptions`. `renderer.timingOffsets()` answers `{ richsync, line }`, the leads as the lines resolve
92
+ them before the trims, so a host that wants none while paused can trim them all off without reading
93
+ the theme's CSS.
94
+
95
+ A scroll of the scroll element that autoscroll did not cause pauses autoscroll, as a reader's
96
+ does, with a `braccato:scroll-state` event and `blyrics-user-scrolling` on the container. Scrolls
97
+ in the 600 ms and two frames after the lines are built or measured again are taken for the page
98
+ settling (a position clamped to new content) and ignored, so a test that scrolls as a reader waits
99
+ that long first.
84
100
 
85
101
  Anything the host puts in the container stays ordinary, visible DOM (a footer, buttons), and so does
86
102
  anything it puts in the credits (a source card), which moves with the credits on the stage. The
@@ -123,6 +139,9 @@ the line as it is:
123
139
  --blyrics-line-hover-opacity: 1; /* over the distance opacity */
124
140
  --blyrics-line-hover-blur: 0; /* over the distance blur; px, rem or blur(…) */
125
141
  --blyrics-line-hover-scale: 1.04; /* over --blyrics-scale / --blyrics-active-scale */
142
+ --blyrics-line-hover-color: white; /* the words' inactive colour; the sung part keeps its own */
143
+ --blyrics-line-hover-bg-color: rgb(255 255 255 / 0.1); /* the line's box, below */
144
+ --blyrics-line-hover-border-color: rgb(255 255 255 / 0.1);
126
145
  --blyrics-line-hover-duration: 0.2s;
127
146
  --blyrics-line-hover-easing: ease;
128
147
  }
@@ -130,6 +149,102 @@ the line as it is:
130
149
 
131
150
  Touch has no hover, so a tap never leaves a line looking hovered.
132
151
 
152
+ A few more properties stand in for rules that styled lines and words by state:
153
+
154
+ ```css
155
+ .blyrics-container {
156
+ /* other lines while the pointer is over the lyrics or a reader scrolls */
157
+ --blyrics-line-opacity-browsing: 0.5;
158
+ /* distance lists like the opacity ones, applied to the line's colours */
159
+ --blyrics-line-saturate-after: 1 0.9 0.8;
160
+ --blyrics-line-brightness-before: 1 0.8;
161
+ }
162
+
163
+ .blyrics--word {
164
+ /* a sung word, while its line is still being sung */
165
+ --blyrics-word-past-opacity: 0.6;
166
+ /* word-synced words wait here until sung, then rise out of it over their duration */
167
+ --blyrics-word-rest-transform: translateY(3px);
168
+ --blyrics-word-rise-extra-duration: 0.2s;
169
+ --blyrics-word-rise-easing: ease;
170
+ }
171
+
172
+ .blyrics--line, .blyrics--translated {
173
+ /* text-shadow's syntax; drawn once with the line */
174
+ --blyrics-text-shadow: 0 0.3rem 0.5rem rgb(0 0 0 / 0.15);
175
+ /* while the line is sung (over its scale transition), and while it is hovered; none for none */
176
+ --blyrics-active-text-shadow: 0 0 1rem rgb(255 255 255 / 0.4);
177
+ --blyrics-line-hover-text-shadow: 0 0 0.5rem rgb(255 255 255 / 0.3);
178
+ }
179
+
180
+ .blyrics--line {
181
+ /* a box behind the line, over its whole box (padding included), with the line's border-radius */
182
+ --blyrics-line-bg-color: rgb(255 255 255 / 0.06);
183
+ /* a border inside the box's edge */
184
+ --blyrics-line-border-color: rgb(255 255 255 / 0.1);
185
+ --blyrics-line-border-width: 1px;
186
+ border-radius: 1rem;
187
+ }
188
+ ```
189
+
190
+ The shadows, the box, the past opacity and the rest pose are read from each element, so selectors
191
+ scope them as they do colours: `[data-layout="stage"] > .blyrics--line` gives only the stage view's
192
+ lines a box, for instance. The box's corner is the line's `border-radius` as a length (a percentage
193
+ or an elliptical corner reads as square), and a line with nothing to draw, such as an empty blank
194
+ line, has no box. The browsing opacity and the distance lists are read from the container.
195
+ Each shadow is drawn once with the line and cross-fades with its state, so a sung or hovered shadow
196
+ eases in and out rather than moving from one offset to another.
197
+
198
+ Instrumental lines and the no-lyrics message, which themes restyled with `::before` and `::after`,
199
+ take these instead:
200
+
201
+ ```css
202
+ .blyrics-container {
203
+ /* note (the default), dots (lit one after another in reading order), or text such as "♫" */
204
+ --blyrics-instrumental-icon: dots;
205
+ /* swells to this scale and back once a period while the instrumental plays */
206
+ --blyrics-instrumental-pulse-scale: 1.14;
207
+ --blyrics-instrumental-pulse-duration: 3s;
208
+ /* in place of the host's message when there are no lyrics, and text drawn above it */
209
+ --blyrics-no-lyrics-text: "No lyrics found";
210
+ --blyrics-no-lyrics-icon: "♫";
211
+ }
212
+
213
+ /* the no-lyrics icon is an element of its own, 4em by default */
214
+ .blyrics-no-lyrics-icon { font-size: 6rem; }
215
+ ```
216
+
217
+ The wobble and the letter wave have a few more controls. A held word is one sung for longer than
218
+ `blyrics-long-word-threshold`, and with `blyrics-long-word-max-letters = 8;` one of at most 8
219
+ letters, so a long word like "everybody" is not one however long it is held.
220
+ `blyrics-letter-wave = long;` waves only held words; the rest move as one piece.
221
+
222
+ ```css
223
+ .blyrics-container {
224
+ /* held words: the outermost letters move this far out at their crest, the rest in proportion */
225
+ --blyrics-letter-wave-spread: 0.04em;
226
+ /* held words that glow: each letter's glow up to 1 + this as bright at its crest */
227
+ --blyrics-letter-wave-glow: 0.8;
228
+ /* word (the default) or syllable: each syllable wobbles on its own, about its own centre */
229
+ --blyrics-word-wobble-scope: syllable;
230
+ /* the wobble lasts --blyrics-wobble-duration plus this many times the syllable's duration */
231
+ --blyrics-word-wobble-duration-ratio: 0.5;
232
+ /* any easing can be a linear() curve, such as a spring */
233
+ --blyrics-word-wobble-easing: linear(0, 0.6 20%, 1.08 40%, 0.98 65%, 1);
234
+ }
235
+
236
+ .blyrics--romanized {
237
+ /* the box behind romanization; transparent for none */
238
+ --blyrics-romanized-bg-color: transparent;
239
+ /* the box's padding and border-radius are the theme's own, as in the DOM renderer */
240
+ padding: 0;
241
+ }
242
+ ```
243
+
244
+ The glow peak brightens a glow up to its colour fully opaque, so it shows on a translucent glow
245
+ colour such as the default. A word's text-shadow moves with the word, but not with each letter's
246
+ wave.
247
+
133
248
  ## How it works
134
249
 
135
250
  The lines are laid out by the browser in an invisible copy of `@braccato/core`'s markup, inside the
@@ -0,0 +1,122 @@
1
+ // Types for js/element.js: `@braccato/core/element`, the `<braccato-lyrics>` custom element.
2
+ import type { Lyric, LyricSyncType } from "@braccato/types";
3
+ import type { Renderer } from "../pkg/braccato_core_rs.js";
4
+ import type { LyricsLayout, SetLyricsOptions, StageBox, WasmSource } from "./renderer.js";
5
+
6
+ export { load } from "./renderer.js";
7
+ export type { Lyric, LyricsLayout, StageBox, WasmSource };
8
+
9
+ /** What the next `lyrics` write reads. */
10
+ export type LyricsElementOptions = Pick<SetLyricsOptions, "noLyrics" | "language" | "songwriters" | "songKey">;
11
+
12
+ /** What the element passes to the renderer's clock. Offsets and trims are in seconds. */
13
+ export interface LyricsElementTickOptions {
14
+ lyricOffset?: number;
15
+ globalLyricOffset?: number;
16
+ /** Taken off the theme's `--blyrics-richsync-timing-offset` lead (see `Renderer.timingOffsets()`). */
17
+ richsyncOffsetTrim?: number;
18
+ /** Taken off the theme's `--blyrics-timing-offset` lead. */
19
+ lineOffsetTrim?: number;
20
+ playbackRate?: number;
21
+ smoothScroll?: boolean;
22
+ passiveScrollEnabled?: boolean;
23
+ }
24
+
25
+ /** Where autoscroll moves. Without it, the nearest scrollable element, the element itself included. */
26
+ export interface LyricsElementHost {
27
+ getScrollElement?(): HTMLElement | null;
28
+ }
29
+
30
+ export interface LyricsElementDecorations {
31
+ translations: boolean;
32
+ romanizations: boolean;
33
+ }
34
+
35
+ export interface LyricsLoadedDetail {
36
+ lineCount: number;
37
+ syncType: LyricSyncType;
38
+ }
39
+
40
+ export interface LineClickDetail {
41
+ /** The player time the click seeks to, in seconds, to the microsecond. */
42
+ timeS: number;
43
+ }
44
+
45
+ export interface ScrollStateDetail {
46
+ userScrolling: boolean;
47
+ }
48
+
49
+ export interface StageLayoutDetail {
50
+ box: StageBox | null;
51
+ }
52
+
53
+ export interface LyricsErrorDetail {
54
+ phase: "connect" | "lyrics" | "source";
55
+ error: unknown;
56
+ }
57
+
58
+ export interface LyricsElementEventMap extends HTMLElementEventMap {
59
+ "braccato:lyrics-loaded": CustomEvent<LyricsLoadedDetail>;
60
+ "braccato:line-click": CustomEvent<LineClickDetail>;
61
+ "braccato:scroll-state": CustomEvent<ScrollStateDetail>;
62
+ "braccato:stage-layout": CustomEvent<StageLayoutDetail>;
63
+ "braccato:error": CustomEvent<LyricsErrorDetail>;
64
+ }
65
+
66
+ export class BraccatoLyricsElement extends HTMLElement {
67
+ static observedAttributes: string[];
68
+ /** The song. An empty array clears the view. */
69
+ lyrics: Lyric[] | null;
70
+ lyricsOptions: LyricsElementOptions;
71
+ /** A media element, or a selector for one, that drives the clock. */
72
+ source: HTMLMediaElement | string | null;
73
+ /** The media element `source` resolved to, once the renderer exists. */
74
+ readonly mediaElement: HTMLMediaElement | null;
75
+ /** Playback position in seconds, for hosts that drive the clock themselves. */
76
+ currentTime: number;
77
+ playing: boolean;
78
+ tickOptions: LyricsElementTickOptions;
79
+ /** A stylesheet of `--blyrics-*` properties and `blyrics-*` comment settings. */
80
+ theme: string;
81
+ host: LyricsElementHost;
82
+ layout: LyricsLayout;
83
+ decorations: LyricsElementDecorations;
84
+ /** The Rust renderer, once the element is connected and the wasm has loaded. */
85
+ readonly renderer: Renderer | null;
86
+ readonly status: "idle" | "rendering";
87
+ resumeAutoscroll(): void;
88
+ relayout(): void;
89
+ connectedCallback(): void;
90
+ disconnectedCallback(): void;
91
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
92
+
93
+ addEventListener<K extends keyof LyricsElementEventMap>(
94
+ type: K,
95
+ listener: (this: BraccatoLyricsElement, event: LyricsElementEventMap[K]) => unknown,
96
+ options?: boolean | AddEventListenerOptions,
97
+ ): void;
98
+ addEventListener(
99
+ type: string,
100
+ listener: EventListenerOrEventListenerObject,
101
+ options?: boolean | AddEventListenerOptions,
102
+ ): void;
103
+ removeEventListener<K extends keyof LyricsElementEventMap>(
104
+ type: K,
105
+ listener: (this: BraccatoLyricsElement, event: LyricsElementEventMap[K]) => unknown,
106
+ options?: boolean | EventListenerOptions,
107
+ ): void;
108
+ removeEventListener(
109
+ type: string,
110
+ listener: EventListenerOrEventListenerObject,
111
+ options?: boolean | EventListenerOptions,
112
+ ): void;
113
+ }
114
+
115
+ /** Defines the element under `tag` (default `braccato-lyrics`) unless something already holds it. */
116
+ export function defineLyricsElement(tag?: string): typeof BraccatoLyricsElement;
117
+
118
+ declare global {
119
+ interface HTMLElementTagNameMap {
120
+ "braccato-lyrics": BraccatoLyricsElement;
121
+ }
122
+ }
package/js/element.js CHANGED
@@ -8,6 +8,19 @@ import { load } from "./renderer.js";
8
8
  export { load };
9
9
 
10
10
  const OBSERVED = ["source", "theme", "current-time", "playing", "layout"];
11
+ /** What a page can write before the element is defined, in the order they are applied again. */
12
+ const UPGRADED = [
13
+ "lyricsOptions",
14
+ "lyrics",
15
+ "tickOptions",
16
+ "currentTime",
17
+ "playing",
18
+ "theme",
19
+ "host",
20
+ "layout",
21
+ "decorations",
22
+ "source",
23
+ ];
11
24
 
12
25
  export class BraccatoLyricsElement extends HTMLElement {
13
26
  static observedAttributes = OBSERVED;
@@ -27,6 +40,14 @@ export class BraccatoLyricsElement extends HTMLElement {
27
40
  #connecting = null;
28
41
 
29
42
  connectedCallback() {
43
+ // A page that writes these before `customElements.define` (a lazily imported element) leaves
44
+ // own properties that hide the accessors: they are handed to the accessors instead.
45
+ for (const name of UPGRADED) {
46
+ if (!Object.hasOwn(this, name)) continue;
47
+ const value = this[name];
48
+ delete this[name];
49
+ this[name] = value;
50
+ }
30
51
  // A disconnect, or a later connect, while the wasm loads makes this connect stale.
31
52
  const generation = Symbol();
32
53
  this.#connecting = generation;
@@ -127,7 +148,7 @@ export class BraccatoLyricsElement extends HTMLElement {
127
148
  this.#applyLyrics();
128
149
  }
129
150
 
130
- /** `{ noLyrics?, language?, songwriters? }`, read by the next `lyrics` write. */
151
+ /** `{ noLyrics?, language?, songwriters?, songKey? }`, read by the next `lyrics` write. */
131
152
  get lyricsOptions() {
132
153
  return this.#lyricsOptions;
133
154
  }
@@ -165,7 +186,10 @@ export class BraccatoLyricsElement extends HTMLElement {
165
186
  this.#renderer?.setTime(this.#currentTime, this.#playing);
166
187
  }
167
188
 
168
- /** `{ lyricOffset?, globalLyricOffset?, playbackRate?, smoothScroll? }`. */
189
+ /**
190
+ * `{ lyricOffset?, globalLyricOffset?, richsyncOffsetTrim?, lineOffsetTrim?, playbackRate?,
191
+ * smoothScroll?, passiveScrollEnabled? }`.
192
+ */
169
193
  get tickOptions() {
170
194
  return this.#tickOptions;
171
195
  }
package/js/renderer.js CHANGED
@@ -342,6 +342,9 @@ export function createLyricsRenderer(rendererOptions) {
342
342
  return rust && attached ? rust.lineIndex(lyricElement) : -1;
343
343
  }
344
344
 
345
+ /** The snapshot last handed to Rust. */
346
+ let sent = null;
347
+
345
348
  // What the records and the module-level helpers reach this renderer through.
346
349
  const view = {
347
350
  indexOf,
@@ -362,6 +365,7 @@ export function createLyricsRenderer(rendererOptions) {
362
365
  return index >= 0 ? rust.hangRomanization(index, text ?? undefined, timed ?? null) : false;
363
366
  },
364
367
  resetClock() {
368
+ sent = null;
365
369
  rust?.resetClock();
366
370
  },
367
371
  canvas() {
@@ -379,9 +383,6 @@ export function createLyricsRenderer(rendererOptions) {
379
383
  };
380
384
  live.add(view);
381
385
 
382
- /** The snapshot last handed to Rust. */
383
- let sent = null;
384
-
385
386
  function tick(currentTimeS, options) {
386
387
  if (destroyed) return "lyrics-missing";
387
388
  const resolved = resolveTickOptions(options ?? {});
@@ -443,12 +444,15 @@ export function createLyricsRenderer(rendererOptions) {
443
444
  throw new Error("A lyrics renderer needs a mount: give one to createLyricsRenderer or to setLyrics");
444
445
  }
445
446
  ensure(nextMount);
446
- rust.setLyrics(lyrics, {
447
+ const otherSong = rust.setLyrics(lyrics, {
447
448
  noLyrics: options.noLyrics ?? false,
448
449
  language: normalizeLanguage(options.language) || undefined,
449
450
  songwriters: options.songwriters ? [...options.songwriters] : undefined,
450
451
  songKey: options.songKey,
451
452
  });
453
+ // The last snapshot was the old song's. Carried forward, or held by a stop at zero (the
454
+ // player between songs), it would scroll the new song to wherever the old one had got to.
455
+ if (otherSong) view.resetClock();
452
456
  rust.container.dataset.loaderVisible = String(options.loaderVisible ?? false);
453
457
  },
454
458
  setLanguage(language) {
@@ -469,6 +473,7 @@ export function createLyricsRenderer(rendererOptions) {
469
473
  if (destroyed || !rust) return;
470
474
  rust.clear();
471
475
  attached = false;
476
+ sent = null;
472
477
  syncRecords();
473
478
  },
474
479
  destroy() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braccato/core",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.10",
4
4
  "description": "Synchronized lyrics renderer with word-by-word animations, in Rust and WebGL2",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,7 +27,10 @@
27
27
  "types": "./js/renderer.d.ts",
28
28
  "import": "./js/renderer.js"
29
29
  },
30
- "./element": "./js/element.js",
30
+ "./element": {
31
+ "types": "./js/element.d.ts",
32
+ "import": "./js/element.js"
33
+ },
31
34
  "./wasm": "./pkg/braccato_core_rs_bg.wasm",
32
35
  "./constants": {
33
36
  "types": "./dist/constants.d.ts",
@@ -72,9 +72,11 @@ export class Renderer {
72
72
  */
73
73
  setLayout(layout: string): void;
74
74
  /**
75
- * The song. `lyrics` is a `Lyric[]`, `options` a `{ noLyrics?, language?, songwriters? }`.
75
+ * The song. `lyrics` is a `Lyric[]`, `options` a `{ noLyrics?, language?, songwriters?, songKey? }`.
76
+ * Returns whether it is another song rather than lyrics swapped into the one on screen, so a
77
+ * caller whose last snapshot was the old song's can forget it with `resetClock`.
76
78
  */
77
- setLyrics(lyrics: any, options: any): void;
79
+ setLyrics(lyrics: any, options: any): boolean;
78
80
  /**
79
81
  * Binds a media element as the clock, or unbinds with `null`.
80
82
  */
@@ -138,9 +140,17 @@ export class Renderer {
138
140
  */
139
141
  takeProfile(): any;
140
142
  /**
141
- * `[start, duration]` in seconds of line `index`, or with `part` one of its parts.
143
+ * `{ richsync, line }`: how far ahead of the player word-synced and line-synced lines light, in
144
+ * seconds. They are the theme's `--blyrics-richsync-timing-offset` and `--blyrics-timing-offset`
145
+ * as the lines resolve them, or the defaults (0.15 and 0.115) where it sets none, before the
146
+ * tick options' trims. Read once the lyrics are built.
142
147
  */
143
- timing(index: number, part?: number | null): Float32Array | undefined;
148
+ timingOffsets(): { richsync: number; line: number };
149
+ /**
150
+ * `[start, duration]` in seconds of line `index`, or with `part` one of its parts, to the
151
+ * microsecond.
152
+ */
153
+ timing(index: number, part?: number | null): Float64Array | undefined;
144
154
  /**
145
155
  * The canvas the view draws on.
146
156
  */
@@ -182,7 +192,7 @@ export interface InitOutput {
182
192
  readonly renderer_setHost: (a: number, b: any) => void;
183
193
  readonly renderer_setLanguage: (a: number, b: number, c: number) => void;
184
194
  readonly renderer_setLayout: (a: number, b: number, c: number) => void;
185
- readonly renderer_setLyrics: (a: number, b: any, c: any) => [number, number];
195
+ readonly renderer_setLyrics: (a: number, b: any, c: any) => [number, number, number];
186
196
  readonly renderer_setMedia: (a: number, b: number) => void;
187
197
  readonly renderer_setProfiling: (a: number, b: number) => number;
188
198
  readonly renderer_setScrollDetection: (a: number, b: number) => void;
@@ -197,11 +207,12 @@ export interface InitOutput {
197
207
  readonly renderer_syncType: (a: number) => [number, number];
198
208
  readonly renderer_takeProfile: (a: number) => any;
199
209
  readonly renderer_timing: (a: number, b: number, c: number) => [number, number];
200
- readonly wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___f64______true_: (a: number, b: number, c: number) => void;
201
- readonly wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true_: (a: number, b: number, c: any) => void;
202
- readonly wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__39: (a: number, b: number, c: any) => void;
203
- readonly wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__40: (a: number, b: number, c: any) => void;
204
- readonly wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke_______true_: (a: number, b: number) => void;
210
+ readonly renderer_timingOffsets: (a: number) => any;
211
+ readonly wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___f64______true_: (a: number, b: number, c: number) => void;
212
+ readonly wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true_: (a: number, b: number, c: any) => void;
213
+ readonly wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__40: (a: number, b: number, c: any) => void;
214
+ readonly wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__41: (a: number, b: number, c: any) => void;
215
+ readonly wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke_______true_: (a: number, b: number) => void;
205
216
  readonly __wbindgen_malloc: (a: number, b: number) => number;
206
217
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
207
218
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -200,15 +200,19 @@ export class Renderer {
200
200
  wasm.renderer_setLayout(this.__wbg_ptr, ptr0, len0);
201
201
  }
202
202
  /**
203
- * The song. `lyrics` is a `Lyric[]`, `options` a `{ noLyrics?, language?, songwriters? }`.
203
+ * The song. `lyrics` is a `Lyric[]`, `options` a `{ noLyrics?, language?, songwriters?, songKey? }`.
204
+ * Returns whether it is another song rather than lyrics swapped into the one on screen, so a
205
+ * caller whose last snapshot was the old song's can forget it with `resetClock`.
204
206
  * @param {any} lyrics
205
207
  * @param {any} options
208
+ * @returns {boolean}
206
209
  */
207
210
  setLyrics(lyrics, options) {
208
211
  const ret = wasm.renderer_setLyrics(this.__wbg_ptr, lyrics, options);
209
- if (ret[1]) {
210
- throw takeFromExternrefTable0(ret[0]);
212
+ if (ret[2]) {
213
+ throw takeFromExternrefTable0(ret[1]);
211
214
  }
215
+ return ret[0] !== 0;
212
216
  }
213
217
  /**
214
218
  * Binds a media element as the clock, or unbinds with `null`.
@@ -333,17 +337,29 @@ export class Renderer {
333
337
  return ret;
334
338
  }
335
339
  /**
336
- * `[start, duration]` in seconds of line `index`, or with `part` one of its parts.
340
+ * `{ richsync, line }`: how far ahead of the player word-synced and line-synced lines light, in
341
+ * seconds. They are the theme's `--blyrics-richsync-timing-offset` and `--blyrics-timing-offset`
342
+ * as the lines resolve them, or the defaults (0.15 and 0.115) where it sets none, before the
343
+ * tick options' trims. Read once the lyrics are built.
344
+ * @returns {{ richsync: number; line: number }}
345
+ */
346
+ timingOffsets() {
347
+ const ret = wasm.renderer_timingOffsets(this.__wbg_ptr);
348
+ return ret;
349
+ }
350
+ /**
351
+ * `[start, duration]` in seconds of line `index`, or with `part` one of its parts, to the
352
+ * microsecond.
337
353
  * @param {number} index
338
354
  * @param {number | null} [part]
339
- * @returns {Float32Array | undefined}
355
+ * @returns {Float64Array | undefined}
340
356
  */
341
357
  timing(index, part) {
342
358
  const ret = wasm.renderer_timing(this.__wbg_ptr, index, isLikeNone(part) ? Number.MAX_SAFE_INTEGER : (part) >>> 0);
343
359
  let v1;
344
360
  if (ret[0] !== 0) {
345
- v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
346
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
361
+ v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
362
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
347
363
  }
348
364
  return v1;
349
365
  }
@@ -441,6 +457,9 @@ function __wbg_get_imports() {
441
457
  __wbg_arcTo_a347b807c468785d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
442
458
  arg0.arcTo(arg1, arg2, arg3, arg4, arg5);
443
459
  }, arguments); },
460
+ __wbg_arc_df3f7eb77e59876f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
461
+ arg0.arc(arg1, arg2, arg3, arg4, arg5);
462
+ }, arguments); },
444
463
  __wbg_attachShader_3ed301cc92db59f6: function(arg0, arg1, arg2) {
445
464
  arg0.attachShader(arg1, arg2);
446
465
  },
@@ -810,6 +829,10 @@ function __wbg_get_imports() {
810
829
  const ret = arg0.getQueryParameter(arg1, arg2 >>> 0);
811
830
  return ret;
812
831
  },
832
+ __wbg_getSelection_ebbf228892c36d69: function() { return handleError(function (arg0) {
833
+ const ret = arg0.getSelection();
834
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
835
+ }, arguments); },
813
836
  __wbg_getShaderInfoLog_3cfe5b3e097d0f2d: function(arg0, arg1, arg2) {
814
837
  const ret = arg1.getShaderInfoLog(arg2);
815
838
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -911,6 +934,10 @@ function __wbg_get_imports() {
911
934
  const ret = Array.isArray(arg0);
912
935
  return ret;
913
936
  },
937
+ __wbg_isCollapsed_94539f24146e499c: function(arg0) {
938
+ const ret = arg0.isCollapsed;
939
+ return ret;
940
+ },
914
941
  __wbg_isSafeInteger_1a35ba4d31e71d38: function(arg0) {
915
942
  const ret = Number.isSafeInteger(arg0);
916
943
  return ret;
@@ -962,6 +989,10 @@ function __wbg_get_imports() {
962
989
  const ret = arg0.matches;
963
990
  return ret;
964
991
  },
992
+ __wbg_matches_f3a9298a593d4ea9: function() { return handleError(function (arg0, arg1, arg2) {
993
+ const ret = arg0.matches(getStringFromWasm0(arg1, arg2));
994
+ return ret;
995
+ }, arguments); },
965
996
  __wbg_measureText_d831259b682a3f7d: function() { return handleError(function (arg0, arg1, arg2) {
966
997
  const ret = arg0.measureText(getStringFromWasm0(arg1, arg2));
967
998
  return ret;
@@ -1021,6 +1052,10 @@ function __wbg_get_imports() {
1021
1052
  const ret = arg0.next();
1022
1053
  return ret;
1023
1054
  }, arguments); },
1055
+ __wbg_nodeType_5c5050c6571c3463: function(arg0) {
1056
+ const ret = arg0.nodeType;
1057
+ return ret;
1058
+ },
1024
1059
  __wbg_now_043d245551b22f9c: function(arg0) {
1025
1060
  const ret = arg0.now();
1026
1061
  return ret;
@@ -1209,6 +1244,18 @@ function __wbg_get_imports() {
1209
1244
  __wbg_set_scrollTop_a01ea28563affafe: function(arg0, arg1) {
1210
1245
  arg0.scrollTop = arg1;
1211
1246
  },
1247
+ __wbg_set_shadowBlur_85cdec581d1dc1d5: function(arg0, arg1) {
1248
+ arg0.shadowBlur = arg1;
1249
+ },
1250
+ __wbg_set_shadowColor_b938633d4fa98064: function(arg0, arg1, arg2) {
1251
+ arg0.shadowColor = getStringFromWasm0(arg1, arg2);
1252
+ },
1253
+ __wbg_set_shadowOffsetX_d90df5fa6efe0d44: function(arg0, arg1) {
1254
+ arg0.shadowOffsetX = arg1;
1255
+ },
1256
+ __wbg_set_shadowOffsetY_244217183c1e23d9: function(arg0, arg1) {
1257
+ arg0.shadowOffsetY = arg1;
1258
+ },
1212
1259
  __wbg_set_src_da602cd25f3603f8: function(arg0, arg1, arg2) {
1213
1260
  arg0.src = getStringFromWasm0(arg1, arg2);
1214
1261
  },
@@ -1323,27 +1370,27 @@ function __wbg_get_imports() {
1323
1370
  },
1324
1371
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1325
1372
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1326
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true_);
1373
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true_);
1327
1374
  return ret;
1328
1375
  },
1329
1376
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
1330
1377
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [F64], shim_idx: 10, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1331
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___f64______true_);
1378
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___f64______true_);
1332
1379
  return ret;
1333
1380
  },
1334
1381
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
1335
1382
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1336
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__39);
1383
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__40);
1337
1384
  return ret;
1338
1385
  },
1339
1386
  __wbindgen_generic_0000000000000004: function(arg0, arg1) {
1340
1387
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1341
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__40);
1388
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__41);
1342
1389
  return ret;
1343
1390
  },
1344
1391
  __wbindgen_generic_0000000000000005: function(arg0, arg1) {
1345
1392
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 12, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1346
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke_______true_);
1393
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke_______true_);
1347
1394
  return ret;
1348
1395
  },
1349
1396
  __wbindgen_generic_0000000000000006: function(arg0) {
@@ -1376,24 +1423,24 @@ function __wbg_get_imports() {
1376
1423
  };
1377
1424
  }
1378
1425
 
1379
- function wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke_______true_(arg0, arg1) {
1380
- wasm.wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke_______true_(arg0, arg1);
1426
+ function wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke_______true_(arg0, arg1) {
1427
+ wasm.wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke_______true_(arg0, arg1);
1381
1428
  }
1382
1429
 
1383
- function wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true_(arg0, arg1, arg2) {
1384
- wasm.wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true_(arg0, arg1, arg2);
1430
+ function wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true_(arg0, arg1, arg2) {
1431
+ wasm.wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true_(arg0, arg1, arg2);
1385
1432
  }
1386
1433
 
1387
- function wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__39(arg0, arg1, arg2) {
1388
- wasm.wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__39(arg0, arg1, arg2);
1434
+ function wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__40(arg0, arg1, arg2) {
1435
+ wasm.wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__40(arg0, arg1, arg2);
1389
1436
  }
1390
1437
 
1391
- function wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__40(arg0, arg1, arg2) {
1392
- wasm.wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__40(arg0, arg1, arg2);
1438
+ function wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__41(arg0, arg1, arg2) {
1439
+ wasm.wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__41(arg0, arg1, arg2);
1393
1440
  }
1394
1441
 
1395
- function wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___f64______true_(arg0, arg1, arg2) {
1396
- wasm.wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___f64______true_(arg0, arg1, arg2);
1442
+ function wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___f64______true_(arg0, arg1, arg2) {
1443
+ wasm.wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___f64______true_(arg0, arg1, arg2);
1397
1444
  }
1398
1445
 
1399
1446
  const RendererFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1473,6 +1520,11 @@ function getArrayF32FromWasm0(ptr, len) {
1473
1520
  return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1474
1521
  }
1475
1522
 
1523
+ function getArrayF64FromWasm0(ptr, len) {
1524
+ ptr = ptr >>> 0;
1525
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1526
+ }
1527
+
1476
1528
  function getArrayU8FromWasm0(ptr, len) {
1477
1529
  ptr = ptr >>> 0;
1478
1530
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -1494,6 +1546,14 @@ function getFloat32ArrayMemory0() {
1494
1546
  return cachedFloat32ArrayMemory0;
1495
1547
  }
1496
1548
 
1549
+ let cachedFloat64ArrayMemory0 = null;
1550
+ function getFloat64ArrayMemory0() {
1551
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1552
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1553
+ }
1554
+ return cachedFloat64ArrayMemory0;
1555
+ }
1556
+
1497
1557
  function getStringFromWasm0(ptr, len) {
1498
1558
  ptr = ptr >>> 0;
1499
1559
  return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
@@ -1634,6 +1694,7 @@ function __wbg_finalize_init(instance, module) {
1634
1694
  wasmModule = module;
1635
1695
  cachedDataViewMemory0 = null;
1636
1696
  cachedFloat32ArrayMemory0 = null;
1697
+ cachedFloat64ArrayMemory0 = null;
1637
1698
  cachedUint8ArrayMemory0 = null;
1638
1699
  wasm.__wbindgen_start();
1639
1700
  return wasm;
Binary file
@@ -24,7 +24,7 @@ export const renderer_setHidden: (a: number, b: number) => void;
24
24
  export const renderer_setHost: (a: number, b: any) => void;
25
25
  export const renderer_setLanguage: (a: number, b: number, c: number) => void;
26
26
  export const renderer_setLayout: (a: number, b: number, c: number) => void;
27
- export const renderer_setLyrics: (a: number, b: any, c: any) => [number, number];
27
+ export const renderer_setLyrics: (a: number, b: any, c: any) => [number, number, number];
28
28
  export const renderer_setMedia: (a: number, b: number) => void;
29
29
  export const renderer_setProfiling: (a: number, b: number) => number;
30
30
  export const renderer_setScrollDetection: (a: number, b: number) => void;
@@ -39,11 +39,12 @@ export const renderer_stats: (a: number) => any;
39
39
  export const renderer_syncType: (a: number) => [number, number];
40
40
  export const renderer_takeProfile: (a: number) => any;
41
41
  export const renderer_timing: (a: number, b: number, c: number) => [number, number];
42
- export const wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___f64______true_: (a: number, b: number, c: number) => void;
43
- export const wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true_: (a: number, b: number, c: any) => void;
44
- export const wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__39: (a: number, b: number, c: any) => void;
45
- export const wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke___wasm_bindgen_662efdbedeaa8f26___JsValue______true__40: (a: number, b: number, c: any) => void;
46
- export const wasm_bindgen_662efdbedeaa8f26___convert__closures_____invoke_______true_: (a: number, b: number) => void;
42
+ export const renderer_timingOffsets: (a: number) => any;
43
+ export const wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___f64______true_: (a: number, b: number, c: number) => void;
44
+ export const wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true_: (a: number, b: number, c: any) => void;
45
+ export const wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__40: (a: number, b: number, c: any) => void;
46
+ export const wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke___wasm_bindgen_ef700d6a803fdfd7___JsValue______true__41: (a: number, b: number, c: any) => void;
47
+ export const wasm_bindgen_ef700d6a803fdfd7___convert__closures_____invoke_______true_: (a: number, b: number) => void;
47
48
  export const __wbindgen_malloc: (a: number, b: number) => number;
48
49
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
49
50
  export const __wbindgen_free: (a: number, b: number, c: number) => void;