@uimaxbai/am-lyrics 1.0.6 → 1.0.8

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
@@ -4,6 +4,8 @@
4
4
 
5
5
  This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
6
6
 
7
+ This web component utilises the [lyricsplus](https://github.com/ibratabian17/YouLyPlus) API to fetch lyrics and the animations are heavily inspired by [YouLy+](https://github.com/ibratabian17/YouLyPlus).
8
+
7
9
  ## Installation
8
10
 
9
11
  ```bash
@@ -37,23 +39,23 @@ Or, just use the CDN.
37
39
 
38
40
  ## Properties & Attributes
39
41
 
40
- | Property/Attribute | Type | Default | Description |
41
- |-------------------|------|---------|-------------|
42
- | `query` | `string` | `undefined` | Search phrase that resolves metadata via LyricsPlus catalog (falls back to Apple Music search) |
43
- | `music-id` | `string` | `undefined` | Specific Apple Music song ID (served through the backup Apple endpoint) |
44
- | `isrc` | `string` | `undefined` | ISRC code to verify correct song match |
45
- | `song-title` | `string` | `undefined` | Preferred title for LyricsPlus (primary) provider |
46
- | `song-artist` | `string` | `undefined` | Preferred artist name for LyricsPlus provider |
47
- | `song-album` | `string` | `undefined` | Optional album name passed to LyricsPlus provider |
48
- | `song-duration` | `number` | `undefined` | Optional song duration in milliseconds sent to LyricsPlus |
49
- | `current-time` | `number` | `0` | Current playback time in milliseconds |
50
- | `duration` | `number` | `undefined` | Playback timer duration in milliseconds. **Set to `-1` to reset/stop playback** |
51
- | `highlight-color` | `string` | `"#000"` | Color for highlighted/active lyrics |
52
- | `hover-background-color` | `string` | `"#f0f0f0"` | Background color on line hover |
53
- | ~~`hide-source-footer`~~ | `boolean` | `false` | Hide/show the source attribution footer |
54
- | `font-family` | `string` | `undefined` | Custom font family for lyrics |
55
- | `autoscroll` | `boolean` | `true` | Enable automatic scrolling to active lyrics |
56
- | `interpolate` | `boolean` | `true` | Enable smooth word-by-word highlighting animation |
42
+ | Property/Attribute | Type | Default | Description |
43
+ | ------------------------ | --------- | ----------- | ---------------------------------------------------------------------------------------------- |
44
+ | `query` | `string` | `undefined` | Search phrase that resolves metadata via LyricsPlus catalog (falls back to Apple Music search) |
45
+ | `music-id` | `string` | `undefined` | Specific Apple Music song ID (served through the backup Apple endpoint) |
46
+ | `isrc` | `string` | `undefined` | ISRC code to verify correct song match |
47
+ | `song-title` | `string` | `undefined` | Preferred title for LyricsPlus (primary) provider |
48
+ | `song-artist` | `string` | `undefined` | Preferred artist name for LyricsPlus provider |
49
+ | `song-album` | `string` | `undefined` | Optional album name passed to LyricsPlus provider |
50
+ | `song-duration` | `number` | `undefined` | Optional song duration in milliseconds sent to LyricsPlus |
51
+ | `current-time` | `number` | `0` | Current playback time in milliseconds |
52
+ | `duration` | `number` | `undefined` | Playback timer duration in milliseconds. **Set to `-1` to reset/stop playback** |
53
+ | `highlight-color` | `string` | `"#000"` | Color for highlighted/active lyrics |
54
+ | `hover-background-color` | `string` | `"#f0f0f0"` | Background color on line hover |
55
+ | ~~`hide-source-footer`~~ | `boolean` | `false` | Hide/show the source attribution footer |
56
+ | `font-family` | `string` | `undefined` | Custom font family for lyrics |
57
+ | `autoscroll` | `boolean` | `true` | Enable automatic scrolling to active lyrics |
58
+ | `interpolate` | `boolean` | `true` | Enable smooth word-by-word highlighting animation |
57
59
 
58
60
  ## CSS Custom Properties (CSS Variables)
59
61
 
@@ -63,10 +65,10 @@ You can customize the appearance using CSS custom properties:
63
65
  am-lyrics {
64
66
  /* Highlight color for active lyrics */
65
67
  --am-lyrics-highlight-color: #007aff;
66
-
68
+
67
69
  /* Hover background color (fallback) */
68
70
  --hover-background-color: #f5f5f5;
69
-
71
+
70
72
  /* Alternative highlight color (fallback) */
71
73
  --highlight-color: #000;
72
74
  }
@@ -74,7 +76,6 @@ am-lyrics {
74
76
 
75
77
  **Note**: The CSS variables take precedent over the set properties above.
76
78
 
77
-
78
79
  ## Lyrics providers
79
80
 
80
81
  The component now only uses the LyricsPlus (KPoe) API that powers [YouLyPlus](https://github.com/ibratabian17/YouLyPlus).
@@ -82,8 +83,7 @@ The component now only uses the LyricsPlus (KPoe) API that powers [YouLyPlus](ht
82
83
  1. Provide `song-title` and `song-artist` (plus optional `song-album`/`song-duration`) to request word-synced lyrics from LyricsPlus. A standalone `query` such as `"Bad Habit - Steve Lacy"` also works—the component looks up the metadata through LyricsPlus' `/v1/songlist/search` endpoint.
83
84
  2. If LyricsPlus cannot serve lyrics or metadata is missing, the component automatically falls back to the legacy Apple Music endpoint using the best available identifiers (`query`, `music-id`, `isrc`). Requests that rely solely on `music-id` are handled exclusively by this backup service because LyricsPlus does not support Apple IDs.
84
85
 
85
- The footer shows the active provider (e.g. “LyricsPlus (KPoe)” or “Apple Music”) so you always know which service responded. Supplying both metadata *and* a `query` gives the best results because the query remains available for the Apple Music backup.
86
-
86
+ The footer shows the active provider (e.g. “LyricsPlus (KPoe)” or “Apple Music”) so you always know which service responded. Supplying both metadata _and_ a `query` gives the best results because the query remains available for the Apple Music backup.
87
87
 
88
88
  ## Events
89
89
 
@@ -92,7 +92,7 @@ The footer shows the active provider (e.g. “LyricsPlus (KPoe)” or “Apple M
92
92
  Fired when a user clicks on a lyrics line.
93
93
 
94
94
  ```javascript
95
- amLyrics.addEventListener('line-click', (event) => {
95
+ amLyrics.addEventListener('line-click', event => {
96
96
  console.log('Seek to:', event.detail.timestamp); // timestamp in milliseconds
97
97
  });
98
98
  ```
@@ -295,7 +295,7 @@ You can synchronize the lyrics with an HTML `<audio>` element.
295
295
  });
296
296
 
297
297
  // Seek audio when a lyric line is clicked
298
- amLyrics.addEventListener('line-click', (e) => {
298
+ amLyrics.addEventListener('line-click', e => {
299
299
  // The event detail contains the timestamp in milliseconds
300
300
  audioPlayer.currentTime = e.detail.timestamp / 1000;
301
301
  audioPlayer.play();
package/demo/index.html CHANGED
@@ -37,8 +37,8 @@
37
37
  </div>
38
38
 
39
39
  <am-lyrics
40
- song-title="Paradise"
41
- song-artist="Coldplay"
40
+ song-title="Gangnam Style"
41
+ song-artist="PSY"
42
42
  song-album=""
43
43
  song-duration=""
44
44
  query=""
@@ -62,6 +62,21 @@ export declare class AmLyrics extends LitElement {
62
62
  private static parseQueryMetadata;
63
63
  private static searchLyricsPlusCatalog;
64
64
  private static fetchLyricsFromYouLyPlus;
65
+ /**
66
+ * Parse LRC subtitle format into LyricsLine[].
67
+ * Handles "[mm:ss.xx] text" lines.
68
+ */
69
+ private static parseLrcSubtitles;
70
+ /**
71
+ * Fetch lyrics from Tidal API.
72
+ * Picks 2 random servers, tries search + lyrics on each.
73
+ */
74
+ private static fetchLyricsFromTidal;
75
+ /**
76
+ * Fetch lyrics from LRCLIB.
77
+ * Uses search endpoint, prefers synced lyrics.
78
+ */
79
+ private static fetchLyricsFromLrclib;
65
80
  private static convertKPoeLyrics;
66
81
  private static toMilliseconds;
67
82
  firstUpdated(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"AmLyrics.d.ts","sourceRoot":"","sources":["../../src/AmLyrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AA6E5C,qBAAa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,MAAM,0BA2mCX;IAGF,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,OAAO,CAAC,cAAc,CAAmC;IAGzD,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,cAAc,SAAa;IAG3B,oBAAoB,SAA+B;IAGnD,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,UAAU,UAAQ;IAGlB,WAAW,UAAQ;IAGnB,OAAO,CAAC,gBAAgB,CAAS;IAGjC,OAAO,CAAC,eAAe,CAAS;Y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