lyric-romanizer 0.1.0 → 0.2.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 +190 -30
- package/dist/romanizer.d.ts.map +1 -1
- package/dist/romanizer.js +60 -32
- package/dist/romanizer.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -1,69 +1,229 @@
|
|
|
1
1
|
# lyric-romanizer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/lyric-romanizer)
|
|
4
|
+
[](https://github.com/thedavidweng/lyric-romanizer/blob/main/LICENSE)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Script detection and local romanization engine for lyrics. Supports 12 scripts across Japanese, Chinese (Mandarin and Cantonese), Korean, Cyrillic, Indic, Tamil, and Thai — all running locally with zero API calls.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Extracted from [Spotify Karaoke](https://github.com/haroldalan/spotify-karaoke). Used by [OpenKara](https://github.com/thedavidweng/openkara).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
13
|
npm install lyric-romanizer
|
|
11
14
|
```
|
|
12
15
|
|
|
16
|
+
```bash
|
|
17
|
+
yarn add lyric-romanizer
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add lyric-romanizer
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createRomanizer, detectScript } from 'lyric-romanizer';
|
|
28
|
+
|
|
29
|
+
const romanizer = createRomanizer();
|
|
30
|
+
|
|
31
|
+
// Auto-detect script and romanize
|
|
32
|
+
const result = await romanizer.romanizeLines(['你好世界', 'こんにちは']);
|
|
33
|
+
// { script: 'chinese', lines: ['nǐ hǎo shì jiè', 'こんにちは'] }
|
|
34
|
+
|
|
35
|
+
// Romanize a single line
|
|
36
|
+
const line = await romanizer.romanizeLine('안녕하세요');
|
|
37
|
+
// 'annyeonghaseyo'
|
|
38
|
+
```
|
|
39
|
+
|
|
13
40
|
## API
|
|
14
41
|
|
|
42
|
+
### Imports
|
|
43
|
+
|
|
15
44
|
```ts
|
|
45
|
+
// Main entry — full romanization engine
|
|
16
46
|
import {
|
|
17
47
|
createRomanizer,
|
|
18
48
|
detectScript,
|
|
19
49
|
isLatinScript,
|
|
20
50
|
requiresExternalRomanization,
|
|
51
|
+
UnsupportedRomanizationError,
|
|
21
52
|
} from 'lyric-romanizer';
|
|
22
53
|
|
|
23
|
-
//
|
|
24
|
-
import { detectScript } from 'lyric-romanizer/detector';
|
|
54
|
+
// Detector-only subpath — lightweight, no romanization dependencies
|
|
55
|
+
import { detectScript, isLatinScript, NON_LATIN_SCRIPT_RE } from 'lyric-romanizer/detector';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Types
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
type ScriptType =
|
|
62
|
+
| 'japanese' | 'chinese' | 'korean' | 'cyrillic'
|
|
63
|
+
| 'devanagari' | 'gujarati' | 'gurmukhi' | 'telugu'
|
|
64
|
+
| 'kannada' | 'odia' | 'tamil' | 'malayalam'
|
|
65
|
+
| 'bengali' | 'arabic' | 'hebrew' | 'thai'
|
|
66
|
+
| 'other';
|
|
67
|
+
|
|
68
|
+
interface Romanizer {
|
|
69
|
+
romanizeLine(line: string, options?: RomanizeOptions): Promise<string>;
|
|
70
|
+
romanizeLines(lines: readonly string[], options?: RomanizeOptions): Promise<RomanizeResult>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type RomanizeOptions = { script?: ScriptType; dialect?: 'mandarin' | 'cantonese' };
|
|
74
|
+
type RomanizeResult = { script: ScriptType; lines: string[] };
|
|
75
|
+
type RomanizerOptions = { japaneseDictPath?: string };
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Functions
|
|
79
|
+
|
|
80
|
+
#### `createRomanizer(options?)`
|
|
81
|
+
|
|
82
|
+
Factory that returns a `Romanizer` instance. The Kuroshiro engine (Japanese) is lazily initialized on first use and cached.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const romanizer = createRomanizer();
|
|
86
|
+
|
|
87
|
+
// Override the Kuromoji dictionary CDN path (e.g. for self-hosting)
|
|
88
|
+
const romanizer = createRomanizer({
|
|
89
|
+
japaneseDictPath: 'https://my-cdn.com/kuromoji/dict',
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### `detectScript(lines)`
|
|
94
|
+
|
|
95
|
+
Detects the dominant script in the given text lines. Checks for Japanese kana first (definitive), then scores all other scripts by character count.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
detectScript(['こんにちは']); // 'japanese'
|
|
99
|
+
detectScript(['你好世界']); // 'chinese'
|
|
100
|
+
detectScript(['Привет']); // 'cyrillic'
|
|
101
|
+
detectScript(['Hello world']); // 'latin'
|
|
102
|
+
detectScript(['123 ???']); // 'other'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### `isLatinScript(lines)`
|
|
106
|
+
|
|
107
|
+
Fast check — returns `true` if the text contains only Latin letters (no CJK, Cyrillic, Indic, etc.). Useful for skipping romanization entirely.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
isLatinScript(['Hello world']); // true
|
|
111
|
+
isLatinScript(['안녕하세요']); // false
|
|
112
|
+
isLatinScript(['♪♪♪']); // false (no letters)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### `requiresExternalRomanization(script)`
|
|
116
|
+
|
|
117
|
+
Returns `true` for scripts that cannot be romanized locally and require an external API.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
requiresExternalRomanization('chinese'); // false
|
|
121
|
+
requiresExternalRomanization('arabic'); // true
|
|
122
|
+
requiresExternalRomanization('malayalam'); // true
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `Romanizer` Interface
|
|
126
|
+
|
|
127
|
+
#### `romanizer.romanizeLine(line, options?)`
|
|
128
|
+
|
|
129
|
+
Romanizes a single line. If `script` is omitted, it is auto-detected via `detectScript`. Returns the original line unchanged for Latin text or non-letter content.
|
|
130
|
+
|
|
131
|
+
For Chinese text, the `dialect` option controls the romanization system: `'mandarin'` (default) uses Pinyin, `'cantonese'` uses [Jyutping](https://github.com/CanCLID/to-jyutping).
|
|
132
|
+
|
|
133
|
+
**Throws** `UnsupportedRomanizationError` for external scripts.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
await romanizer.romanizeLine('你好世界');
|
|
137
|
+
// 'nǐ hǎo shì jiè' (default: Mandarin/Pinyin)
|
|
138
|
+
|
|
139
|
+
await romanizer.romanizeLine('你好', { dialect: 'cantonese' });
|
|
140
|
+
// 'nei5 hou2' (Jyutping)
|
|
141
|
+
|
|
142
|
+
await romanizer.romanizeLine('Привет мир');
|
|
143
|
+
// 'Privet mir'
|
|
144
|
+
|
|
145
|
+
await romanizer.romanizeLine('Hello world');
|
|
146
|
+
// 'Hello world' (no-op)
|
|
147
|
+
|
|
148
|
+
await romanizer.romanizeLine('مرحبا');
|
|
149
|
+
// throws UnsupportedRomanizationError { script: 'arabic' }
|
|
25
150
|
```
|
|
26
151
|
|
|
27
|
-
|
|
152
|
+
#### `romanizer.romanizeLines(lines, options?)`
|
|
28
153
|
|
|
29
|
-
|
|
154
|
+
Romanizes multiple lines in parallel. Returns the detected script and romanized lines.
|
|
30
155
|
|
|
31
|
-
|
|
156
|
+
```ts
|
|
157
|
+
const { script, lines } = await romanizer.romanizeLines([
|
|
158
|
+
'สวัสดี',
|
|
159
|
+
'ชาวโลก',
|
|
160
|
+
]);
|
|
161
|
+
// { script: 'thai', lines: ['sawatdi', 'chaolok'] }
|
|
162
|
+
```
|
|
32
163
|
|
|
33
|
-
|
|
164
|
+
### `UnsupportedRomanizationError`
|
|
34
165
|
|
|
35
|
-
|
|
166
|
+
Thrown when attempting to romanize a script that requires an external API. Has a `script` property for programmatic handling.
|
|
36
167
|
|
|
37
|
-
|
|
168
|
+
```ts
|
|
169
|
+
try {
|
|
170
|
+
await romanizer.romanizeLine('مرحبا');
|
|
171
|
+
} catch (err) {
|
|
172
|
+
if (err instanceof UnsupportedRomanizationError) {
|
|
173
|
+
console.log(err.script); // 'arabic'
|
|
174
|
+
// fall back to external API
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
38
178
|
|
|
39
|
-
|
|
179
|
+
## Supported Scripts
|
|
40
180
|
|
|
41
|
-
|
|
181
|
+
### Local (fully offline)
|
|
42
182
|
|
|
43
|
-
|
|
183
|
+
| Script | Engine | Example |
|
|
184
|
+
|--------|--------|---------|
|
|
185
|
+
| Universal *(fallback)* | [transliteration](https://github.com/nickclaw/transliteration) | `Привет` → `Privet` |
|
|
186
|
+
| Japanese | [kuroshiro](https://github.com/sglkc/kuroshiro-ts) + [kuromoji](https://github.com/takuyaa/kuromoji.js) | `こんにちは` → `konnichiha` |
|
|
187
|
+
| Mandarin | [pinyin-pro](https://github.com/zh-lx/pinyin-pro) | `你好` → `nǐ hǎo` |
|
|
188
|
+
| Cantonese | [to-jyutping](https://github.com/CanCLID/to-jyutping) | `佢冇` → `keoi5 mou5` |
|
|
189
|
+
| Korean | [@romanize/korean](https://github.com/kntng/romanize) | `안녕` → `annyeong` |
|
|
190
|
+
| Cyrillic | [cyrillic-to-translit-js](https://github.com/greybax/CyrillicToTranslitJS) | `Привет` → `Privet` |
|
|
191
|
+
| Devanagari | [sanscript](https://github.com/indic-transliteration/sanscript) | `नमस्ते` → `namaste` |
|
|
192
|
+
| Gujarati | [sanscript](https://github.com/indic-transliteration/sanscript) | `નમસ્તે` → `namaste` |
|
|
193
|
+
| Gurmukhi | [sanscript](https://github.com/indic-transliteration/sanscript) | `ਨਮਸਤੇ` → `namaste` |
|
|
194
|
+
| Telugu | [sanscript](https://github.com/indic-transliteration/sanscript) | `నమస్తే` → `namaste` |
|
|
195
|
+
| Kannada | [sanscript](https://github.com/indic-transliteration/sanscript) | `నಮస్తె` → `namaste` |
|
|
196
|
+
| Odia | [sanscript](https://github.com/indic-transliteration/sanscript) | `ନମସ୍ତେ` → `namaste` |
|
|
197
|
+
| Tamil | [tamil-romanizer](https://github.com/haroldalan/tamil-romanizer) | `வணக்கம்` → `vanakkam` |
|
|
198
|
+
| Thai | [@dehoist/romanize-thai](https://github.com/Dehoist/Open-Source) | `สวัสดี` → `sawatdi` |
|
|
44
199
|
|
|
45
|
-
|
|
200
|
+
### External (requires API)
|
|
46
201
|
|
|
47
|
-
|
|
202
|
+
| Script | Method |
|
|
203
|
+
|--------|--------|
|
|
204
|
+
| Malayalam | Google Translate `dt=rm` |
|
|
205
|
+
| Bengali | Google Translate `dt=rm` |
|
|
206
|
+
| Arabic | Google Translate `dt=rm` |
|
|
207
|
+
| Hebrew | Google Translate `dt=rm` |
|
|
208
|
+
| Other | Google Translate `dt=rm` |
|
|
48
209
|
|
|
49
|
-
|
|
210
|
+
Use `requiresExternalRomanization()` to detect these and branch to your preferred API.
|
|
50
211
|
|
|
51
|
-
##
|
|
212
|
+
## Cyrillic Detection
|
|
52
213
|
|
|
53
|
-
|
|
54
|
-
|--------|---------|
|
|
55
|
-
| Japanese | [@sglkc/kuroshiro](https://github.com/sglkc/kuroshiro-ts) + [kuromoji](https://github.com/takuyaa/kuromoji.js) |
|
|
56
|
-
| Chinese | [pinyin-pro](https://github.com/zh-lx/pinyin-pro) |
|
|
57
|
-
| Korean | [@romanize/korean](https://github.com/kntng/romanize) |
|
|
58
|
-
| Cyrillic (Russian/Ukrainian) | [cyrillic-to-translit-js](https://github.com/greybax/CyrillicToTranslitJS) |
|
|
59
|
-
| Devanagari, Gujarati, Gurmukhi, Telugu, Kannada, Odia | [@indic-transliteration/sanscript](https://github.com/indic-transliteration/sanscript.js) |
|
|
60
|
-
| Tamil | [tamil-romanizer](https://github.com/haroldalan/tamil-romanizer) |
|
|
61
|
-
| Thai | [@dehoist/romanize-thai](https://github.com/Dehoist/Open-Source) |
|
|
62
|
-
| Latin | no-op (returned as-is) |
|
|
214
|
+
Cyrillic auto-detects Ukrainian-specific characters (`і`, `ї`, `є`, `ґ`) and applies the Ukrainian transliteration preset. All other Cyrillic text defaults to Russian.
|
|
63
215
|
|
|
64
|
-
##
|
|
216
|
+
## Cantonese Support
|
|
65
217
|
|
|
66
|
-
|
|
218
|
+
Chinese text defaults to Mandarin (Pinyin). Pass `dialect: 'cantonese'` in `RomanizeOptions` to romanize Chinese text to [Jyutping](https://github.com/CanCLID/to-jyutping) instead.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
const { lines } = await romanizer.romanizeLines(['你好世界', '食飯'], {
|
|
222
|
+
script: 'chinese',
|
|
223
|
+
dialect: 'cantonese',
|
|
224
|
+
});
|
|
225
|
+
// ['nei5 hou2 sai3 gaai3', 'sik6 faan6']
|
|
226
|
+
```
|
|
67
227
|
|
|
68
228
|
## License
|
|
69
229
|
|
package/dist/romanizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"romanizer.d.ts","sourceRoot":"","sources":["../src/romanizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"romanizer.d.ts","sourceRoot":"","sources":["../src/romanizer.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAGV,SAAS,EACT,gBAAgB,EAChB,UAAU,EACX,MAAM,YAAY,CAAC;AAwBpB,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAExE;AA+GD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAErE"}
|
package/dist/romanizer.js
CHANGED
|
@@ -6,6 +6,7 @@ import Sanscript from '@indic-transliteration/sanscript';
|
|
|
6
6
|
import { romanize as romanizeKorean } from '@romanize/korean';
|
|
7
7
|
import romanizeThai from '@dehoist/romanize-thai';
|
|
8
8
|
import { romanize as romanizeTamil } from 'tamil-romanizer';
|
|
9
|
+
import { transliterate } from 'transliteration';
|
|
9
10
|
import { detectScript } from './detector.js';
|
|
10
11
|
import { UnsupportedRomanizationError } from './types.js';
|
|
11
12
|
const DEFAULT_JAPANESE_DICT_PATH = 'https://cdn.jsdelivr.net/npm/kuromoji/dict';
|
|
@@ -32,6 +33,7 @@ export function requiresExternalRomanization(script) {
|
|
|
32
33
|
class DefaultRomanizer {
|
|
33
34
|
japaneseDictPath;
|
|
34
35
|
kuroshiroReady = null;
|
|
36
|
+
jyutpingReady = null;
|
|
35
37
|
constructor(options) {
|
|
36
38
|
this.japaneseDictPath = options?.japaneseDictPath ?? DEFAULT_JAPANESE_DICT_PATH;
|
|
37
39
|
}
|
|
@@ -44,39 +46,56 @@ class DefaultRomanizer {
|
|
|
44
46
|
if (requiresExternalRomanization(script)) {
|
|
45
47
|
throw new UnsupportedRomanizationError(script);
|
|
46
48
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const scheme = SANSCRIPT_SCHEME[script];
|
|
67
|
-
if (!scheme)
|
|
68
|
-
throw new Error(`Missing Sanscript scheme mapping for '${script}'.`);
|
|
69
|
-
if (!Sanscript.schemes?.[scheme]) {
|
|
70
|
-
throw new Error(`Sanscript does not support scheme '${scheme}' for '${script}'.`);
|
|
49
|
+
try {
|
|
50
|
+
switch (script) {
|
|
51
|
+
case 'japanese': {
|
|
52
|
+
const k = await this.getKuroshiro();
|
|
53
|
+
return k.convert(line, { to: 'romaji', mode: 'spaced' });
|
|
54
|
+
}
|
|
55
|
+
case 'chinese': {
|
|
56
|
+
if (options?.dialect === 'cantonese') {
|
|
57
|
+
try {
|
|
58
|
+
const jyutping = await this.getJyutpingModule();
|
|
59
|
+
const result = jyutping.getJyutpingText(line);
|
|
60
|
+
if (result)
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// fall through to pinyin
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return pinyin(line, { toneType: 'symbol', type: 'string' });
|
|
71
68
|
}
|
|
72
|
-
|
|
69
|
+
case 'korean':
|
|
70
|
+
return romanizeKorean(line);
|
|
71
|
+
case 'cyrillic':
|
|
72
|
+
return /[іїєґ]/i.test(line)
|
|
73
|
+
? cyrillicTranslitUk.transform(line)
|
|
74
|
+
: cyrillicTranslitRu.transform(line);
|
|
75
|
+
case 'devanagari':
|
|
76
|
+
case 'gujarati':
|
|
77
|
+
case 'gurmukhi':
|
|
78
|
+
case 'telugu':
|
|
79
|
+
case 'kannada':
|
|
80
|
+
case 'odia': {
|
|
81
|
+
const scheme = SANSCRIPT_SCHEME[script];
|
|
82
|
+
if (!scheme)
|
|
83
|
+
throw new Error(`Missing Sanscript scheme mapping for '${script}'.`);
|
|
84
|
+
if (!Sanscript.schemes?.[scheme]) {
|
|
85
|
+
throw new Error(`Sanscript does not support scheme '${scheme}' for '${script}'.`);
|
|
86
|
+
}
|
|
87
|
+
return Sanscript.t(line, scheme, 'iast');
|
|
88
|
+
}
|
|
89
|
+
case 'tamil':
|
|
90
|
+
return romanizeTamil(line);
|
|
91
|
+
case 'thai':
|
|
92
|
+
return romanizeThai(line);
|
|
93
|
+
default:
|
|
94
|
+
return transliterate(line);
|
|
73
95
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return romanizeThai(line);
|
|
78
|
-
default:
|
|
79
|
-
throw new UnsupportedRomanizationError(script);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return transliterate(line);
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
101
|
async romanizeLines(lines, options) {
|
|
@@ -87,7 +106,7 @@ class DefaultRomanizer {
|
|
|
87
106
|
if (script === 'latin') {
|
|
88
107
|
return { script, lines: [...lines] };
|
|
89
108
|
}
|
|
90
|
-
const romanized = await Promise.all(lines.map((line) => this.romanizeLine(line, { script })));
|
|
109
|
+
const romanized = await Promise.all(lines.map((line) => this.romanizeLine(line, { script, dialect: options?.dialect })));
|
|
91
110
|
return { script, lines: romanized };
|
|
92
111
|
}
|
|
93
112
|
async getKuroshiro() {
|
|
@@ -105,6 +124,15 @@ class DefaultRomanizer {
|
|
|
105
124
|
}
|
|
106
125
|
return this.kuroshiroReady;
|
|
107
126
|
}
|
|
127
|
+
async getJyutpingModule() {
|
|
128
|
+
if (!this.jyutpingReady) {
|
|
129
|
+
this.jyutpingReady = import('to-jyutping').catch((e) => {
|
|
130
|
+
this.jyutpingReady = null;
|
|
131
|
+
throw e;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return this.jyutpingReady;
|
|
135
|
+
}
|
|
108
136
|
}
|
|
109
137
|
export function createRomanizer(options) {
|
|
110
138
|
return new DefaultRomanizer(options);
|
package/dist/romanizer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"romanizer.js","sourceRoot":"","sources":["../src/romanizer.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,gBAAgB,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,YA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/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,SAAS,GACT,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,UAAU,GACV,UAAU,GACV,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,SAAS,GACT,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,UAAU,GACV,UAAU,GACV,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvE,aAAa,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7F;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAgB,MAAM,EAAE,UAAU,CAAC;gBAEvB,MAAM,EAAE,UAAU;CAK/B"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuCA,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrC,MAAM,CAAa;IAEnC,YAAY,MAAkB;QAC5B,KAAK,CAAC,WAAW,MAAM,mCAAmC,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lyric-romanizer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Script detection and local romanization engine for lyrics — supports Japanese, Chinese, Korean, Cyrillic, Indic scripts, Tamil, Thai, and more",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,13 +25,6 @@
|
|
|
25
25
|
"dist",
|
|
26
26
|
"README.md"
|
|
27
27
|
],
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
30
|
-
"clean": "rm -rf dist",
|
|
31
|
-
"prepack": "npm run build",
|
|
32
|
-
"test": "vitest run",
|
|
33
|
-
"test:watch": "vitest"
|
|
34
|
-
},
|
|
35
28
|
"dependencies": {
|
|
36
29
|
"@dehoist/romanize-thai": "^1.0.0",
|
|
37
30
|
"@indic-transliteration/sanscript": "^1.3.3",
|
|
@@ -40,7 +33,9 @@
|
|
|
40
33
|
"@sglkc/kuroshiro-analyzer-kuromoji": "^1.0.1",
|
|
41
34
|
"cyrillic-to-translit-js": "^3.2.1",
|
|
42
35
|
"pinyin-pro": "^3.28.0",
|
|
43
|
-
"tamil-romanizer": "^1.0.2"
|
|
36
|
+
"tamil-romanizer": "^1.0.2",
|
|
37
|
+
"to-jyutping": "^3.1.1",
|
|
38
|
+
"transliteration": "^2.6.1"
|
|
44
39
|
},
|
|
45
40
|
"devDependencies": {
|
|
46
41
|
"typescript": "^5.7.3",
|
|
@@ -67,5 +62,11 @@
|
|
|
67
62
|
"bugs": {
|
|
68
63
|
"url": "https://github.com/thedavidweng/lyric-romanizer/issues"
|
|
69
64
|
},
|
|
70
|
-
"homepage": "https://github.com/thedavidweng/lyric-romanizer#readme"
|
|
71
|
-
|
|
65
|
+
"homepage": "https://github.com/thedavidweng/lyric-romanizer#readme",
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
68
|
+
"clean": "rm -rf dist",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:watch": "vitest"
|
|
71
|
+
}
|
|
72
|
+
}
|