@applemusic-like-lyrics/lyric 0.0.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.
- package/README.md +19 -0
- package/lyric.d.ts +118 -0
- package/lyric.js +4 -0
- package/lyric_bg.js +631 -0
- package/lyric_bg.wasm +0 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Lyric parser/writer for AMLL
|
|
2
|
+
|
|
3
|
+
一个 AMLL 的歌词解析/生成模块,使用 Rust 编写,并通过 `wasm-pack`
|
|
4
|
+
构建成 WASM 模块以提供给其他项目使用。
|
|
5
|
+
|
|
6
|
+
本模块由于只着重于歌词内容,所以会丢弃一切和歌词无关的信息,如需获取一个歌词文件中的详细信息(例如歌手)请考虑使用其他框架。
|
|
7
|
+
|
|
8
|
+
支持以下歌词格式的解析:
|
|
9
|
+
- LyRiC 格式 `.lrc`
|
|
10
|
+
- 网易云音乐逐词歌词格式 `.yrc`
|
|
11
|
+
- QQ 音乐逐词歌词格式 `.qrc`
|
|
12
|
+
- Lyricify Syllable 逐词歌词格式 `.lys`
|
|
13
|
+
|
|
14
|
+
支持以下歌词格式的导出:
|
|
15
|
+
- LyRiC 格式 `.lrc`
|
|
16
|
+
- 网易云音乐逐词歌词格式 `.yrc`
|
|
17
|
+
- QQ 音乐逐词歌词格式 `.qrc`
|
|
18
|
+
- Lyricify Syllable 逐词歌词格式 `.lys`
|
|
19
|
+
- ASS 字幕格式 `.ass`
|
package/lyric.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* When the `console_error_panic_hook` feature is enabled, we can call the
|
|
5
|
+
* `set_panic_hook` function at least once during initialization, and then
|
|
6
|
+
* we will get better error messages if our code ever panics.
|
|
7
|
+
*
|
|
8
|
+
* For more details see
|
|
9
|
+
* https://github.com/rustwasm/console_error_panic_hook#readme
|
|
10
|
+
*/
|
|
11
|
+
export function set_panic_hook(): void;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 解析 LyRiC 格式的歌词字符串
|
|
16
|
+
* @param src 歌词字符串
|
|
17
|
+
* @returns 成功解析出来的歌词
|
|
18
|
+
*/
|
|
19
|
+
export function parseLrc(src: string): LyricLine[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 将歌词数组转换为 LyRiC 格式的字符串
|
|
23
|
+
* @param lines 歌词数组
|
|
24
|
+
* @returns LyRiC 格式的字符串
|
|
25
|
+
*/
|
|
26
|
+
export function stringifyLrc(lines: LyricLine[]): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 解析 YRC 格式的歌词字符串
|
|
30
|
+
* @param src 歌词字符串
|
|
31
|
+
* @returns 成功解析出来的歌词
|
|
32
|
+
*/
|
|
33
|
+
export function parseYrc(src: string): LyricLine[];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 将歌词数组转换为 YRC 格式的字符串
|
|
37
|
+
* @param lines 歌词数组
|
|
38
|
+
* @returns YRC 格式的字符串
|
|
39
|
+
*/
|
|
40
|
+
export function stringifyYrc(lines: LyricLine[]): string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 解析 QRC 格式的歌词字符串
|
|
44
|
+
* @param src 歌词字符串
|
|
45
|
+
* @returns 成功解析出来的歌词
|
|
46
|
+
*/
|
|
47
|
+
export function parseQrc(src: string): LyricLine[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 将歌词数组转换为 QRC 格式的字符串
|
|
51
|
+
* @param lines 歌词数组
|
|
52
|
+
* @returns QRC 格式的字符串
|
|
53
|
+
*/
|
|
54
|
+
export function stringifyQrc(lines: LyricLine[]): string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 解析 Lyricify Syllable 格式的歌词字符串
|
|
58
|
+
* @param src 歌词字符串
|
|
59
|
+
* @returns 成功解析出来的歌词
|
|
60
|
+
*/
|
|
61
|
+
export function parseLys(src: string): LyricLine[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 将歌词数组转换为 Lyricify Syllable 格式的字符串
|
|
65
|
+
* @param lines 歌词数组
|
|
66
|
+
* @returns Lyricify Syllable 格式的字符串
|
|
67
|
+
*/
|
|
68
|
+
export function stringifyLys(lines: LyricLine[]): string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 将歌词数组转换为 ASS 字幕格式的字符串
|
|
72
|
+
*
|
|
73
|
+
* 注意导出会损失 10 毫秒以内的精度
|
|
74
|
+
*
|
|
75
|
+
* 主唱名称会变为 `v1`,对唱会变为 `v2`
|
|
76
|
+
*
|
|
77
|
+
* 如果是背景歌词则会在名称后面加上后缀 `-bg`
|
|
78
|
+
* @param lines 歌词数组
|
|
79
|
+
* @returns ASS 字幕格式的字符串
|
|
80
|
+
*/
|
|
81
|
+
export function stringifyAss(lines: LyricLine[]): string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 一个歌词单词
|
|
85
|
+
*/
|
|
86
|
+
export interface LyricWord {
|
|
87
|
+
/** 单词的起始时间 */
|
|
88
|
+
startTime: number;
|
|
89
|
+
/** 单词的结束时间 */
|
|
90
|
+
endTime: number;
|
|
91
|
+
/** 单词 */
|
|
92
|
+
word: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 一行歌词,存储多个单词
|
|
97
|
+
* 如果是 LyRiC 等只能表达一行歌词的格式,则会将整行当做一个单词存储起来
|
|
98
|
+
*/
|
|
99
|
+
export interface LyricLine {
|
|
100
|
+
/**
|
|
101
|
+
* 该行的所有单词
|
|
102
|
+
* 如果是 LyRiC 等只能表达一行歌词的格式,这里就只会有一个单词
|
|
103
|
+
*/
|
|
104
|
+
words: LyricWord[];
|
|
105
|
+
/**
|
|
106
|
+
* 该行是否为背景歌词行
|
|
107
|
+
* 此选项只有作为 Lyricify Syllable 文件格式导入导出时才有意义
|
|
108
|
+
*/
|
|
109
|
+
isBG?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* 该行是否为对唱歌词行(即歌词行靠右对齐)
|
|
112
|
+
* 此选项只有作为 Lyricify Syllable 文件格式导入导出时才有意义
|
|
113
|
+
*/
|
|
114
|
+
isDuet?: boolean;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
package/lyric.js
ADDED
package/lyric_bg.js
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const heap = new Array(128).fill(undefined);
|
|
8
|
+
|
|
9
|
+
heap.push(undefined, null, true, false);
|
|
10
|
+
|
|
11
|
+
function getObject(idx) { return heap[idx]; }
|
|
12
|
+
|
|
13
|
+
let heap_next = heap.length;
|
|
14
|
+
|
|
15
|
+
function dropObject(idx) {
|
|
16
|
+
if (idx < 132) return;
|
|
17
|
+
heap[idx] = heap_next;
|
|
18
|
+
heap_next = idx;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function takeObject(idx) {
|
|
22
|
+
const ret = getObject(idx);
|
|
23
|
+
dropObject(idx);
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function addHeapObject(obj) {
|
|
28
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
29
|
+
const idx = heap_next;
|
|
30
|
+
heap_next = heap[idx];
|
|
31
|
+
|
|
32
|
+
heap[idx] = obj;
|
|
33
|
+
return idx;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
37
|
+
|
|
38
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
39
|
+
|
|
40
|
+
cachedTextDecoder.decode();
|
|
41
|
+
|
|
42
|
+
let cachedUint8Memory0 = null;
|
|
43
|
+
|
|
44
|
+
function getUint8Memory0() {
|
|
45
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
46
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
47
|
+
}
|
|
48
|
+
return cachedUint8Memory0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getStringFromWasm0(ptr, len) {
|
|
52
|
+
ptr = ptr >>> 0;
|
|
53
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let WASM_VECTOR_LEN = 0;
|
|
57
|
+
|
|
58
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
59
|
+
|
|
60
|
+
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
61
|
+
|
|
62
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
63
|
+
? function (arg, view) {
|
|
64
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
65
|
+
}
|
|
66
|
+
: function (arg, view) {
|
|
67
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
68
|
+
view.set(buf);
|
|
69
|
+
return {
|
|
70
|
+
read: arg.length,
|
|
71
|
+
written: buf.length
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
76
|
+
|
|
77
|
+
if (realloc === undefined) {
|
|
78
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
79
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
80
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
81
|
+
WASM_VECTOR_LEN = buf.length;
|
|
82
|
+
return ptr;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let len = arg.length;
|
|
86
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
87
|
+
|
|
88
|
+
const mem = getUint8Memory0();
|
|
89
|
+
|
|
90
|
+
let offset = 0;
|
|
91
|
+
|
|
92
|
+
for (; offset < len; offset++) {
|
|
93
|
+
const code = arg.charCodeAt(offset);
|
|
94
|
+
if (code > 0x7F) break;
|
|
95
|
+
mem[ptr + offset] = code;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (offset !== len) {
|
|
99
|
+
if (offset !== 0) {
|
|
100
|
+
arg = arg.slice(offset);
|
|
101
|
+
}
|
|
102
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
103
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
104
|
+
const ret = encodeString(arg, view);
|
|
105
|
+
|
|
106
|
+
offset += ret.written;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
WASM_VECTOR_LEN = offset;
|
|
110
|
+
return ptr;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function isLikeNone(x) {
|
|
114
|
+
return x === undefined || x === null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let cachedInt32Memory0 = null;
|
|
118
|
+
|
|
119
|
+
function getInt32Memory0() {
|
|
120
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
121
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
122
|
+
}
|
|
123
|
+
return cachedInt32Memory0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let cachedFloat64Memory0 = null;
|
|
127
|
+
|
|
128
|
+
function getFloat64Memory0() {
|
|
129
|
+
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
130
|
+
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
131
|
+
}
|
|
132
|
+
return cachedFloat64Memory0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let cachedBigInt64Memory0 = null;
|
|
136
|
+
|
|
137
|
+
function getBigInt64Memory0() {
|
|
138
|
+
if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
|
|
139
|
+
cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
|
|
140
|
+
}
|
|
141
|
+
return cachedBigInt64Memory0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function debugString(val) {
|
|
145
|
+
// primitive types
|
|
146
|
+
const type = typeof val;
|
|
147
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
148
|
+
return `${val}`;
|
|
149
|
+
}
|
|
150
|
+
if (type == 'string') {
|
|
151
|
+
return `"${val}"`;
|
|
152
|
+
}
|
|
153
|
+
if (type == 'symbol') {
|
|
154
|
+
const description = val.description;
|
|
155
|
+
if (description == null) {
|
|
156
|
+
return 'Symbol';
|
|
157
|
+
} else {
|
|
158
|
+
return `Symbol(${description})`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (type == 'function') {
|
|
162
|
+
const name = val.name;
|
|
163
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
164
|
+
return `Function(${name})`;
|
|
165
|
+
} else {
|
|
166
|
+
return 'Function';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// objects
|
|
170
|
+
if (Array.isArray(val)) {
|
|
171
|
+
const length = val.length;
|
|
172
|
+
let debug = '[';
|
|
173
|
+
if (length > 0) {
|
|
174
|
+
debug += debugString(val[0]);
|
|
175
|
+
}
|
|
176
|
+
for(let i = 1; i < length; i++) {
|
|
177
|
+
debug += ', ' + debugString(val[i]);
|
|
178
|
+
}
|
|
179
|
+
debug += ']';
|
|
180
|
+
return debug;
|
|
181
|
+
}
|
|
182
|
+
// Test for built-in
|
|
183
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
184
|
+
let className;
|
|
185
|
+
if (builtInMatches.length > 1) {
|
|
186
|
+
className = builtInMatches[1];
|
|
187
|
+
} else {
|
|
188
|
+
// Failed to match the standard '[object ClassName]'
|
|
189
|
+
return toString.call(val);
|
|
190
|
+
}
|
|
191
|
+
if (className == 'Object') {
|
|
192
|
+
// we're a user defined class or Object
|
|
193
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
194
|
+
// easier than looping through ownProperties of `val`.
|
|
195
|
+
try {
|
|
196
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
197
|
+
} catch (_) {
|
|
198
|
+
return 'Object';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// errors
|
|
202
|
+
if (val instanceof Error) {
|
|
203
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
204
|
+
}
|
|
205
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
206
|
+
return className;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @param {string} src
|
|
210
|
+
* @returns {any}
|
|
211
|
+
*/
|
|
212
|
+
export function parseLrc(src) {
|
|
213
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
214
|
+
const len0 = WASM_VECTOR_LEN;
|
|
215
|
+
const ret = wasm.parseLrc(ptr0, len0);
|
|
216
|
+
return takeObject(ret);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @param {any} lrc
|
|
221
|
+
* @returns {string}
|
|
222
|
+
*/
|
|
223
|
+
export function stringifyLrc(lrc) {
|
|
224
|
+
let deferred1_0;
|
|
225
|
+
let deferred1_1;
|
|
226
|
+
try {
|
|
227
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
228
|
+
wasm.stringifyLrc(retptr, addHeapObject(lrc));
|
|
229
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
230
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
231
|
+
deferred1_0 = r0;
|
|
232
|
+
deferred1_1 = r1;
|
|
233
|
+
return getStringFromWasm0(r0, r1);
|
|
234
|
+
} finally {
|
|
235
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
236
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @param {string} src
|
|
242
|
+
* @returns {any}
|
|
243
|
+
*/
|
|
244
|
+
export function parseQrc(src) {
|
|
245
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
246
|
+
const len0 = WASM_VECTOR_LEN;
|
|
247
|
+
const ret = wasm.parseQrc(ptr0, len0);
|
|
248
|
+
return takeObject(ret);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @param {any} lrc
|
|
253
|
+
* @returns {string}
|
|
254
|
+
*/
|
|
255
|
+
export function stringifyQrc(lrc) {
|
|
256
|
+
let deferred1_0;
|
|
257
|
+
let deferred1_1;
|
|
258
|
+
try {
|
|
259
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
260
|
+
wasm.stringifyQrc(retptr, addHeapObject(lrc));
|
|
261
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
262
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
263
|
+
deferred1_0 = r0;
|
|
264
|
+
deferred1_1 = r1;
|
|
265
|
+
return getStringFromWasm0(r0, r1);
|
|
266
|
+
} finally {
|
|
267
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
268
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* When the `console_error_panic_hook` feature is enabled, we can call the
|
|
274
|
+
* `set_panic_hook` function at least once during initialization, and then
|
|
275
|
+
* we will get better error messages if our code ever panics.
|
|
276
|
+
*
|
|
277
|
+
* For more details see
|
|
278
|
+
* https://github.com/rustwasm/console_error_panic_hook#readme
|
|
279
|
+
*/
|
|
280
|
+
export function set_panic_hook() {
|
|
281
|
+
wasm.set_panic_hook();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @param {string} src
|
|
286
|
+
* @returns {any}
|
|
287
|
+
*/
|
|
288
|
+
export function parseYrc(src) {
|
|
289
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
290
|
+
const len0 = WASM_VECTOR_LEN;
|
|
291
|
+
const ret = wasm.parseYrc(ptr0, len0);
|
|
292
|
+
return takeObject(ret);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @param {any} lrc
|
|
297
|
+
* @returns {string}
|
|
298
|
+
*/
|
|
299
|
+
export function stringifyYrc(lrc) {
|
|
300
|
+
let deferred1_0;
|
|
301
|
+
let deferred1_1;
|
|
302
|
+
try {
|
|
303
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
304
|
+
wasm.stringifyYrc(retptr, addHeapObject(lrc));
|
|
305
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
306
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
307
|
+
deferred1_0 = r0;
|
|
308
|
+
deferred1_1 = r1;
|
|
309
|
+
return getStringFromWasm0(r0, r1);
|
|
310
|
+
} finally {
|
|
311
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
312
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @param {string} src
|
|
318
|
+
* @returns {any}
|
|
319
|
+
*/
|
|
320
|
+
export function parseLys(src) {
|
|
321
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
322
|
+
const len0 = WASM_VECTOR_LEN;
|
|
323
|
+
const ret = wasm.parseLys(ptr0, len0);
|
|
324
|
+
return takeObject(ret);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @param {any} lrc
|
|
329
|
+
* @returns {string}
|
|
330
|
+
*/
|
|
331
|
+
export function stringifyLys(lrc) {
|
|
332
|
+
let deferred1_0;
|
|
333
|
+
let deferred1_1;
|
|
334
|
+
try {
|
|
335
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
336
|
+
wasm.stringifyLys(retptr, addHeapObject(lrc));
|
|
337
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
338
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
339
|
+
deferred1_0 = r0;
|
|
340
|
+
deferred1_1 = r1;
|
|
341
|
+
return getStringFromWasm0(r0, r1);
|
|
342
|
+
} finally {
|
|
343
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
344
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @param {any} lrc
|
|
350
|
+
* @returns {string}
|
|
351
|
+
*/
|
|
352
|
+
export function stringifyAss(lrc) {
|
|
353
|
+
let deferred1_0;
|
|
354
|
+
let deferred1_1;
|
|
355
|
+
try {
|
|
356
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
357
|
+
wasm.stringifyAss(retptr, addHeapObject(lrc));
|
|
358
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
359
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
360
|
+
deferred1_0 = r0;
|
|
361
|
+
deferred1_1 = r1;
|
|
362
|
+
return getStringFromWasm0(r0, r1);
|
|
363
|
+
} finally {
|
|
364
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
365
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function handleError(f, args) {
|
|
370
|
+
try {
|
|
371
|
+
return f.apply(this, args);
|
|
372
|
+
} catch (e) {
|
|
373
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
378
|
+
takeObject(arg0);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export function __wbindgen_is_bigint(arg0) {
|
|
382
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
383
|
+
return ret;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export function __wbindgen_bigint_from_u64(arg0) {
|
|
387
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
388
|
+
return addHeapObject(ret);
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
export function __wbindgen_jsval_eq(arg0, arg1) {
|
|
392
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
393
|
+
return ret;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
export function __wbindgen_error_new(arg0, arg1) {
|
|
397
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
398
|
+
return addHeapObject(ret);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export function __wbindgen_is_object(arg0) {
|
|
402
|
+
const val = getObject(arg0);
|
|
403
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
404
|
+
return ret;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
export function __wbindgen_is_undefined(arg0) {
|
|
408
|
+
const ret = getObject(arg0) === undefined;
|
|
409
|
+
return ret;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export function __wbindgen_in(arg0, arg1) {
|
|
413
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
414
|
+
return ret;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
export function __wbindgen_string_get(arg0, arg1) {
|
|
418
|
+
const obj = getObject(arg1);
|
|
419
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
420
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
421
|
+
var len1 = WASM_VECTOR_LEN;
|
|
422
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
423
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
export function __wbindgen_boolean_get(arg0) {
|
|
427
|
+
const v = getObject(arg0);
|
|
428
|
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
429
|
+
return ret;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export function __wbg_new_abda76e883ba8a5f() {
|
|
433
|
+
const ret = new Error();
|
|
434
|
+
return addHeapObject(ret);
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
export function __wbg_stack_658279fe44541cf6(arg0, arg1) {
|
|
438
|
+
const ret = getObject(arg1).stack;
|
|
439
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
440
|
+
const len1 = WASM_VECTOR_LEN;
|
|
441
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
442
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
export function __wbg_error_f851667af71bcfc6(arg0, arg1) {
|
|
446
|
+
let deferred0_0;
|
|
447
|
+
let deferred0_1;
|
|
448
|
+
try {
|
|
449
|
+
deferred0_0 = arg0;
|
|
450
|
+
deferred0_1 = arg1;
|
|
451
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
452
|
+
} finally {
|
|
453
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
export function __wbindgen_jsval_loose_eq(arg0, arg1) {
|
|
458
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
459
|
+
return ret;
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
export function __wbindgen_number_get(arg0, arg1) {
|
|
463
|
+
const obj = getObject(arg1);
|
|
464
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
465
|
+
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
466
|
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
export function __wbindgen_number_new(arg0) {
|
|
470
|
+
const ret = arg0;
|
|
471
|
+
return addHeapObject(ret);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
475
|
+
const ret = getObject(arg0);
|
|
476
|
+
return addHeapObject(ret);
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
export function __wbindgen_string_new(arg0, arg1) {
|
|
480
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
481
|
+
return addHeapObject(ret);
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
export function __wbg_getwithrefkey_5e6d9547403deab8(arg0, arg1) {
|
|
485
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
486
|
+
return addHeapObject(ret);
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
export function __wbg_set_841ac57cff3d672b(arg0, arg1, arg2) {
|
|
490
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
export function __wbg_get_44be0491f933a435(arg0, arg1) {
|
|
494
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
495
|
+
return addHeapObject(ret);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export function __wbg_length_fff51ee6522a1a18(arg0) {
|
|
499
|
+
const ret = getObject(arg0).length;
|
|
500
|
+
return ret;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
export function __wbg_new_898a68150f225f2e() {
|
|
504
|
+
const ret = new Array();
|
|
505
|
+
return addHeapObject(ret);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
export function __wbindgen_is_function(arg0) {
|
|
509
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
510
|
+
return ret;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
export function __wbg_next_526fc47e980da008(arg0) {
|
|
514
|
+
const ret = getObject(arg0).next;
|
|
515
|
+
return addHeapObject(ret);
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
export function __wbg_next_ddb3312ca1c4e32a() { return handleError(function (arg0) {
|
|
519
|
+
const ret = getObject(arg0).next();
|
|
520
|
+
return addHeapObject(ret);
|
|
521
|
+
}, arguments) };
|
|
522
|
+
|
|
523
|
+
export function __wbg_done_5c1f01fb660d73b5(arg0) {
|
|
524
|
+
const ret = getObject(arg0).done;
|
|
525
|
+
return ret;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export function __wbg_value_1695675138684bd5(arg0) {
|
|
529
|
+
const ret = getObject(arg0).value;
|
|
530
|
+
return addHeapObject(ret);
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
export function __wbg_iterator_97f0c81209c6c35a() {
|
|
534
|
+
const ret = Symbol.iterator;
|
|
535
|
+
return addHeapObject(ret);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
export function __wbg_get_97b561fb56f034b5() { return handleError(function (arg0, arg1) {
|
|
539
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
540
|
+
return addHeapObject(ret);
|
|
541
|
+
}, arguments) };
|
|
542
|
+
|
|
543
|
+
export function __wbg_call_cb65541d95d71282() { return handleError(function (arg0, arg1) {
|
|
544
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
545
|
+
return addHeapObject(ret);
|
|
546
|
+
}, arguments) };
|
|
547
|
+
|
|
548
|
+
export function __wbg_new_b51585de1b234aff() {
|
|
549
|
+
const ret = new Object();
|
|
550
|
+
return addHeapObject(ret);
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
export function __wbg_set_502d29070ea18557(arg0, arg1, arg2) {
|
|
554
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
export function __wbg_isArray_4c24b343cb13cfb1(arg0) {
|
|
558
|
+
const ret = Array.isArray(getObject(arg0));
|
|
559
|
+
return ret;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
export function __wbg_instanceof_ArrayBuffer_39ac22089b74fddb(arg0) {
|
|
563
|
+
let result;
|
|
564
|
+
try {
|
|
565
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
566
|
+
} catch {
|
|
567
|
+
result = false;
|
|
568
|
+
}
|
|
569
|
+
const ret = result;
|
|
570
|
+
return ret;
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
export function __wbg_isSafeInteger_bb8e18dd21c97288(arg0) {
|
|
574
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
575
|
+
return ret;
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
export function __wbg_buffer_085ec1f694018c4f(arg0) {
|
|
579
|
+
const ret = getObject(arg0).buffer;
|
|
580
|
+
return addHeapObject(ret);
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
export function __wbg_new_8125e318e6245eed(arg0) {
|
|
584
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
585
|
+
return addHeapObject(ret);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
export function __wbg_set_5cf90238115182c3(arg0, arg1, arg2) {
|
|
589
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
export function __wbg_length_72e2208bbc0efc61(arg0) {
|
|
593
|
+
const ret = getObject(arg0).length;
|
|
594
|
+
return ret;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
export function __wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4(arg0) {
|
|
598
|
+
let result;
|
|
599
|
+
try {
|
|
600
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
601
|
+
} catch {
|
|
602
|
+
result = false;
|
|
603
|
+
}
|
|
604
|
+
const ret = result;
|
|
605
|
+
return ret;
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export function __wbindgen_bigint_get_as_i64(arg0, arg1) {
|
|
609
|
+
const v = getObject(arg1);
|
|
610
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
611
|
+
getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
|
|
612
|
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
export function __wbindgen_debug_string(arg0, arg1) {
|
|
616
|
+
const ret = debugString(getObject(arg1));
|
|
617
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
618
|
+
const len1 = WASM_VECTOR_LEN;
|
|
619
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
620
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
export function __wbindgen_throw(arg0, arg1) {
|
|
624
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
export function __wbindgen_memory() {
|
|
628
|
+
const ret = wasm.memory;
|
|
629
|
+
return addHeapObject(ret);
|
|
630
|
+
};
|
|
631
|
+
|
package/lyric_bg.wasm
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@applemusic-like-lyrics/lyric",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"SteveXMH <39523898+Steve-xmh@users.noreply.github.com>"
|
|
5
|
+
],
|
|
6
|
+
"description": "一个歌词解析/生成模块,着重于歌词内容解析,支持多种格式",
|
|
7
|
+
"version": "0.0.1",
|
|
8
|
+
"files": [
|
|
9
|
+
"lyric_bg.wasm",
|
|
10
|
+
"lyric.js",
|
|
11
|
+
"lyric_bg.js",
|
|
12
|
+
"lyric.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"module": "lyric.js",
|
|
15
|
+
"types": "lyric.d.ts",
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./lyric.js",
|
|
18
|
+
"./snippets/*"
|
|
19
|
+
]
|
|
20
|
+
}
|