@braccato/core 1.21.6 → 1.22.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 CHANGED
@@ -388,10 +388,12 @@ start until the next word begins.
388
388
 
389
389
  ### Browser engine
390
390
 
391
- On Firefox the container carries `data-browser-engine="gecko"`. The renderer's Gecko-only CSS keys on
392
- it, and a theme can do the same to target Firefox without sniffing the user agent. It is detected from
393
- a feature only Gecko ships, so forks of Firefox carry it too. Script reads the same answer from
394
- `isGecko()` in `@braccato/core/util`, which the renderer's Gecko-only script checks once on load.
391
+ On Firefox the container carries `data-browser-engine="gecko"`, and on WebKit (Safari and the other
392
+ WebKit browsers) it carries `data-browser-engine="webkit"`. The renderer's engine-only CSS keys on it,
393
+ and a theme can do the same to target an engine without sniffing the user agent. Each is detected from
394
+ a feature only that engine ships, so forks carry it too. Script reads the same answers from `isGecko()`
395
+ and `isWebKit()` in `@braccato/core/util`; the renderer's Gecko-only script checks `isGecko()` once on
396
+ load.
395
397
 
396
398
  ```css
397
399
  .blyrics-container[data-browser-engine="gecko"] .blyrics--line {
@@ -399,6 +401,11 @@ a feature only Gecko ships, so forks of Firefox carry it too. Script reads the s
399
401
  }
400
402
  ```
401
403
 
404
+ WebKit puts the baseline of an inline-block that clips its overflow at the box's bottom edge, where
405
+ Blink and Gecko keep the baseline of its text. Each sweep cell clips its mask boxes, so on WebKit every
406
+ wrapped row of lit text sat lower than the row it covers. There the cells use paint containment instead,
407
+ which clips the same box and keeps the text's baseline.
408
+
402
409
  The letter wave uses both. WebRender rounds text moved by a 2D translation to whole device
403
410
  pixels, and it only redraws a cached tile once something on it has moved a quarter of a pixel, so the
404
411
  wave stepped on Firefox. Lettered words on animating lines get a distant `perspective` there, and each
@@ -519,7 +526,7 @@ Four leaves import nothing at all, so taking one does not pull the engine into y
519
526
  - `@braccato/core/constants` for the class names and element ids above
520
527
  - `@braccato/core/text` for script detection: `testRtl`, `containsNonLatin`, `detectNonLatinLanguage`
521
528
  - `@braccato/core/themeSettings` for `parseThemeConfig`
522
- - `@braccato/core/util` for pure helpers such as `clamp` and `toMs`, and `isGecko` for engine-specific fixes
529
+ - `@braccato/core/util` for pure helpers such as `clamp` and `toMs`, and `isGecko` and `isWebKit` for engine-specific fixes
523
530
 
524
531
  Two notes on the element entry point. A browser extension's isolated world has no custom element
525
532
  registry, so `window.customElements` is null there and importing this file throws where it registers.
package/dist/README.md CHANGED
@@ -388,10 +388,12 @@ start until the next word begins.
388
388
 
389
389
  ### Browser engine
390
390
 
391
- On Firefox the container carries `data-browser-engine="gecko"`. The renderer's Gecko-only CSS keys on
392
- it, and a theme can do the same to target Firefox without sniffing the user agent. It is detected from
393
- a feature only Gecko ships, so forks of Firefox carry it too. Script reads the same answer from
394
- `isGecko()` in `@braccato/core/util`, which the renderer's Gecko-only script checks once on load.
391
+ On Firefox the container carries `data-browser-engine="gecko"`, and on WebKit (Safari and the other
392
+ WebKit browsers) it carries `data-browser-engine="webkit"`. The renderer's engine-only CSS keys on it,
393
+ and a theme can do the same to target an engine without sniffing the user agent. Each is detected from
394
+ a feature only that engine ships, so forks carry it too. Script reads the same answers from `isGecko()`
395
+ and `isWebKit()` in `@braccato/core/util`; the renderer's Gecko-only script checks `isGecko()` once on
396
+ load.
395
397
 
396
398
  ```css
397
399
  .blyrics-container[data-browser-engine="gecko"] .blyrics--line {
@@ -399,6 +401,11 @@ a feature only Gecko ships, so forks of Firefox carry it too. Script reads the s
399
401
  }
400
402
  ```
401
403
 
404
+ WebKit puts the baseline of an inline-block that clips its overflow at the box's bottom edge, where
405
+ Blink and Gecko keep the baseline of its text. Each sweep cell clips its mask boxes, so on WebKit every
406
+ wrapped row of lit text sat lower than the row it covers. There the cells use paint containment instead,
407
+ which clips the same box and keeps the text's baseline.
408
+
402
409
  The letter wave uses both. WebRender rounds text moved by a 2D translation to whole device
403
410
  pixels, and it only redraws a cached tile once something on it has moved a quarter of a pixel, so the
404
411
  wave stepped on Firefox. Lettered words on animating lines get a distant `perspective` there, and each
@@ -519,7 +526,7 @@ Four leaves import nothing at all, so taking one does not pull the engine into y
519
526
  - `@braccato/core/constants` for the class names and element ids above
520
527
  - `@braccato/core/text` for script detection: `testRtl`, `containsNonLatin`, `detectNonLatinLanguage`
521
528
  - `@braccato/core/themeSettings` for `parseThemeConfig`
522
- - `@braccato/core/util` for pure helpers such as `clamp` and `toMs`, and `isGecko` for engine-specific fixes
529
+ - `@braccato/core/util` for pure helpers such as `clamp` and `toMs`, and `isGecko` and `isWebKit` for engine-specific fixes
523
530
 
524
531
  Two notes on the element entry point. A browser extension's isolated world has no custom element
525
532
  registry, so `window.customElements` is null there and importing this file throws where it registers.
@@ -184,6 +184,12 @@
184
184
  position: relative;
185
185
  }
186
186
 
187
+ /* WebKit puts a clipped inline-block's baseline at its bottom edge; paint containment clips without that. */
188
+ .blyrics-container[data-browser-engine="webkit"] .blyrics-sweep-cell {
189
+ contain: paint;
190
+ overflow: visible;
191
+ }
192
+
187
193
  .blyrics-word-highlight--sweep.blyrics-rtl .blyrics-sweep-cell,
188
194
  .blyrics-sweep-window.blyrics-sweep-cell[dir="rtl"] {
189
195
  direction: rtl;
package/dist/util.d.ts CHANGED
@@ -5,6 +5,8 @@ export declare function positiveModulo(value: number, divisor: number): number;
5
5
  * spoofed user agents and Firefox forks resolve the same way.
6
6
  */
7
7
  export declare function isGecko(): boolean;
8
+ /** Whether the page renders with WebKit (Safari and the other WebKit browsers), detected the same way. */
9
+ export declare function isWebKit(): boolean;
8
10
  export declare function roundedMs(value: number): number;
9
11
  /**
10
12
  * Converts CSS duration value to milliseconds.
package/dist/util.js CHANGED
@@ -11,6 +11,10 @@ export function positiveModulo(value, divisor) {
11
11
  export function isGecko() {
12
12
  return typeof CSS !== "undefined" && CSS.supports("-moz-appearance", "none");
13
13
  }
14
+ /** Whether the page renders with WebKit (Safari and the other WebKit browsers), detected the same way. */
15
+ export function isWebKit() {
16
+ return typeof CSS !== "undefined" && CSS.supports("-webkit-nbsp-mode", "space");
17
+ }
14
18
  export function roundedMs(value) {
15
19
  return Math.round(value * 10) / 10;
16
20
  }
package/dist/view.js CHANGED
@@ -23,7 +23,7 @@ import { refreshInstrumentalImages } from "./imageHighlights.js";
23
23
  import { createInstrumentalElement } from "./instrumental.js";
24
24
  import { applyLyricLanguage, resolveLyricLanguages } from "./language.js";
25
25
  import { lyricBuildSettingsKey } from "./themeSettings.js";
26
- import { isGecko } from "./util.js";
26
+ import { isGecko, isWebKit } from "./util.js";
27
27
  const INITIAL_SKIP_SCROLLS = 2;
28
28
  const SKIP_SCROLL_DECAY_MS = 2000;
29
29
  function buildInstrumentalLine(doc, lyricElement, lyrics, lineIndex) {
@@ -211,6 +211,8 @@ export function setLyrics(engine, mount, lyrics, options) {
211
211
  container.className = LYRICS_CLASS;
212
212
  if (isGecko())
213
213
  container.dataset.browserEngine = "gecko";
214
+ else if (isWebKit())
215
+ container.dataset.browserEngine = "webkit";
214
216
  mount.replaceChildren(container);
215
217
  const context = buildContext(engine, lyrics, options);
216
218
  const lines = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braccato/core",
3
- "version": "1.21.6",
3
+ "version": "1.22.0",
4
4
  "description": "Synchronized lyrics renderer with word-by-word animations",
5
5
  "type": "module",
6
6
  "license": "MIT",