@braccato/core 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/README.md +63 -0
  2. package/package.json +40 -50
  3. package/LICENSE +0 -21
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # @braccato/core
2
+
3
+ `<braccato-lyrics>` web component for synchronized lyrics rendering with word-by-word animations. Built with Lit, extracted from the [Better Lyrics](https://better-lyrics.boidu.dev) rendering engine.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i @braccato/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```html
14
+ <audio id="player" src="song.mp3" controls></audio>
15
+ <braccato-lyrics source="#player" src="lyrics.ttml"></braccato-lyrics>
16
+
17
+ <script type="module">
18
+ import "@braccato/core";
19
+ </script>
20
+ ```
21
+
22
+ The `source` attribute accepts a CSS selector for any `<audio>` or `<video>` element. The `src` attribute fetches and parses a lyrics file (TTML, LRC, SRT, QRC, or plain text are auto-detected).
23
+
24
+ For manual control, set `lyrics`, `currentTime`, and `playing` directly instead.
25
+
26
+ ## Properties
27
+
28
+ | Property | Attribute | Type | Default | Description |
29
+ |----------|-----------|------|---------|-------------|
30
+ | `source` | `source` | `string \| null` | `null` | CSS selector for the media element to sync with |
31
+ | `src` | `src` | `string \| null` | `null` | URL to a lyrics file (auto-detected format) |
32
+ | `lyrics` | | `Lyric[]` | `[]` | Parsed lyric data (set directly for manual control) |
33
+ | `currentTime` | `current-time` | `number` | `0` | Playback position in ms (ignored when `source` is set) |
34
+ | `playing` | `playing` | `boolean` | `false` | Whether playback is active (ignored when `source` is set) |
35
+ | `scrollMode` | `scroll-mode` | `'internal' \| 'external'` | `'internal'` | Scroll container ownership |
36
+ | `dir` | `dir` | `'auto' \| 'ltr' \| 'rtl'` | `'auto'` | Text direction |
37
+
38
+ ## Events
39
+
40
+ | Event | Detail | Description |
41
+ |-------|--------|-------------|
42
+ | `braccato:line-click` | `{ time, lineIndex }` | User clicked a lyric line |
43
+ | `braccato:word-click` | `{ time, lineIndex, wordIndex }` | Alt+click on a word (rich sync) |
44
+ | `braccato:lyrics-loaded` | `{ syncType, lineCount }` | Lyrics injected into the DOM |
45
+ | `braccato:scroll-state` | `{ userScrolling }` | Scroll state changed |
46
+ | `braccato:error` | `{ error }` | Fetch or parse error (when using `src`) |
47
+
48
+ ## CSS Custom Properties
49
+
50
+ ```css
51
+ braccato-lyrics {
52
+ --braccato-font-family: system-ui, sans-serif;
53
+ --braccato-font-size: 3rem;
54
+ --braccato-font-weight: 600;
55
+ --braccato-active-color: white;
56
+ --braccato-inactive-opacity: 0.3;
57
+ --braccato-glow-color: rgba(255, 255, 255, 0.5);
58
+ --braccato-timing-offset: 0.115s;
59
+ --braccato-richsync-timing-offset: 0.150s;
60
+ }
61
+ ```
62
+
63
+ See the [full documentation](https://github.com/better-lyrics/braccato) for all properties and framework examples.
package/package.json CHANGED
@@ -1,51 +1,41 @@
1
1
  {
2
- "name": "@braccato/core",
3
- "version": "0.1.0",
4
- "description": "Synchronized lyrics web component with word-by-word animations",
5
- "type": "module",
6
- "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/better-lyrics/braccato",
10
- "directory": "packages/core"
11
- },
12
- "homepage": "https://github.com/better-lyrics/braccato",
13
- "keywords": [
14
- "lyrics",
15
- "sync",
16
- "web-component",
17
- "lit",
18
- "music",
19
- "karaoke",
20
- "ttml"
21
- ],
22
- "sideEffects": true,
23
- "main": "dist/index.js",
24
- "types": "dist/index.d.ts",
25
- "exports": {
26
- ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.js"
29
- }
30
- },
31
- "files": [
32
- "dist"
33
- ],
34
- "publishConfig": {
35
- "access": "public"
36
- },
37
- "dependencies": {
38
- "lit": "^3.2.1",
39
- "@braccato/parsers": "^0.1.0"
40
- },
41
- "devDependencies": {
42
- "typescript": "^5.7.3",
43
- "vite": "^6.0.7",
44
- "vite-plugin-dts": "^4.3.0"
45
- },
46
- "scripts": {
47
- "build": "vite build",
48
- "dev": "vite build --watch",
49
- "typecheck": "tsc --noEmit"
50
- }
51
- }
2
+ "name": "@braccato/core",
3
+ "version": "0.1.1",
4
+ "description": "Synchronized lyrics web component with word-by-word animations",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/better-lyrics/braccato",
10
+ "directory": "packages/core"
11
+ },
12
+ "homepage": "https://github.com/better-lyrics/braccato",
13
+ "keywords": ["lyrics", "sync", "web-component", "lit", "music", "karaoke", "ttml"],
14
+ "sideEffects": true,
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": ["dist"],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "vite build",
29
+ "dev": "vite build --watch",
30
+ "typecheck": "tsc --noEmit"
31
+ },
32
+ "dependencies": {
33
+ "@braccato/parsers": "workspace:^",
34
+ "lit": "^3.2.1"
35
+ },
36
+ "devDependencies": {
37
+ "typescript": "^5.7.3",
38
+ "vite": "^6.0.7",
39
+ "vite-plugin-dts": "^4.3.0"
40
+ }
41
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Better Lyrics
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.