music-lyric-kit 0.11.2 → 0.12.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/dist/index.comm.js +1 -1
- package/dist/index.comm.js.map +1 -1
- package/dist/index.ecma.d.ts +13 -20
- package/dist/index.ecma.js +27 -30
- package/dist/index.ecma.js.map +1 -1
- package/package.json +12 -12
package/dist/index.comm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@music-lyric-kit/lyric"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@music-lyric-kit/lyric"),P=require("@music-lyric-kit/plugin-format-lrc"),b=require("@music-lyric-kit/plugin-format-ttml"),y=require("@music-lyric-kit/plugin-transform-interlude"),_=require("@music-lyric-kit/plugin-transform-background"),T=require("@music-lyric-kit/plugin-transform-agent"),w=require("@music-lyric-kit/plugin-transform-space"),k=require("@music-lyric-kit/plugin-transform-pure"),C=require("@music-lyric-kit/plugin-transform-stress"),a=require("@music-lyric-kit/core");function s(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,c.get?c:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const f=s(P),p=s(b),h=s(y),i=s(_),g=s(T),d=s(w),o=s(k),m=s(C),E=Object.freeze(Object.defineProperty({__proto__:null,Lrc:f,Ttml:p},Symbol.toStringTag,{value:"Module"})),O=Object.freeze(Object.defineProperty({__proto__:null,Agent:g,Background:i,Interlude:h,Pure:o,Space:d,Stress:m},Symbol.toStringTag,{value:"Module"})),l=[new f.Parser,new p.AmllParser],r={agent:{extract:new g.Extract},background:{extract:new i.Extract,clean:new i.Clean},pure:{extract:new o.ExtractCreator,clean:new o.Clean},space:{insert:new d.Insert},interlude:{insert:new h.Insert},stress:{mark:new m.Mark}};class x{context;format;input;done;constructor(e){this.done=!1,this.input=e,this.format=this.input.format||"";const t=new u.Lyric.Info;this.context=new a.ParserContext({content:this.input.content,musicInfo:this.input.musicInfo},t)}handleApplyConfig(e,t){e.config&&(e.config.reset(),t&&e.config.update(t))}handleExecPlugin(e){this.done=!1;try{if(!e.check(this.context))return}catch(t){console.warn(`plugin check failed id=${e.id} err=${t?.message}`);return}try{e.exec(this.context)}catch(t){console.warn(`plugin call failed id=${e.id} err=${t?.message}`)}}infer(){if(this.format)return this;for(const e of l)try{if(e.check(this.context)){this.format=e.format;break}}catch{continue}return this}parse(){if(!this.format)throw new Error("no format detected. call .infer() before .parse()");const e=l.find(t=>t.format===this.format);if(!e)throw new Error(`parser plugin not found: "${this.format}"`);this.done=!1;try{e.exec(this.context)}catch(t){console.warn(`plugin call failed id=${e.id} err=${t?.message}`)}return this}backgroundExtract(e){return this.handleApplyConfig(r.background.extract,e),this.handleExecPlugin(r.background.extract),this}backgroundClean(){return this.handleExecPlugin(r.background.clean),this}agentExtract(e){return this.handleApplyConfig(r.agent.extract,e),this.handleExecPlugin(r.agent.extract),this}pureExtract(e){return this.handleApplyConfig(r.pure.extract,e),this.handleExecPlugin(r.pure.extract),this}pureClean(e){return this.handleApplyConfig(r.pure.clean,e),this.handleExecPlugin(r.pure.clean),this}interludeInsert(e){return this.handleApplyConfig(r.interlude.insert,e),this.handleExecPlugin(r.interlude.insert),this}spaceInsert(e){return this.handleApplyConfig(r.space.insert,e),this.handleExecPlugin(r.space.insert),this}stressMark(e){return this.handleApplyConfig(r.stress.mark,e),this.handleExecPlugin(r.stress.mark),this}final(){return this.done||(this.context.cleanWord(),this.context.calcAgentIndex(),this.context.syncLineTimeWithWord(),this.context.sort(),this.context.syncLineTimeWithBackground(),this.done=!0),{format:this.format,result:this.context.result}}}const j=n=>new x(n);Object.defineProperty(exports,"Lyric",{enumerable:!0,get:()=>u.Lyric});Object.defineProperty(exports,"Generator",{enumerable:!0,get:()=>a.Generator});Object.defineProperty(exports,"GeneratorContext",{enumerable:!0,get:()=>a.GeneratorContext});Object.defineProperty(exports,"Parser",{enumerable:!0,get:()=>a.Parser});Object.defineProperty(exports,"ParserContext",{enumerable:!0,get:()=>a.ParserContext});exports.Format=E;exports.ParserPipeline=x;exports.Transform=O;exports.createParserPipeline=j;
|
|
2
2
|
//# sourceMappingURL=index.comm.js.map
|
package/dist/index.comm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.comm.js","sources":["../src/parser/pipeline.ts"],"sourcesContent":["import type { ParserParams } from '@music-lyric-kit/core'\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.comm.js","sources":["../src/parser/pipeline.ts"],"sourcesContent":["import type { ParserParams } from '@music-lyric-kit/core'\n\nimport { Lyric } from '@music-lyric-kit/lyric'\nimport { ParserContext, ParserPlugin } from '@music-lyric-kit/core'\n\nimport { Format, Transform } from '@root/plugin'\n\nexport interface ParserPipelineInput {\n format?: string\n content: any\n musicInfo?: ParserParams['musicInfo']\n}\n\nexport interface ParserPipelineResult {\n format: string\n result: Lyric.Info\n}\n\nconst BuiltInFormats = [new Format.Lrc.Parser(), new Format.Ttml.AmllParser()]\n\nconst BuiltInPlugins = {\n agent: {\n extract: new Transform.Agent.Extract(),\n },\n background: {\n extract: new Transform.Background.Extract(),\n clean: new Transform.Background.Clean(),\n },\n pure: {\n extract: new Transform.Pure.ExtractCreator(),\n clean: new Transform.Pure.Clean(),\n },\n space: {\n insert: new Transform.Space.Insert(),\n },\n interlude: {\n insert: new Transform.Interlude.Insert(),\n },\n stress: {\n mark: new Transform.Stress.Mark(),\n },\n}\n\nexport class ParserPipeline {\n private context: ParserContext\n private format: string\n private input: ParserPipelineInput\n private done: boolean\n\n constructor(input: ParserPipelineInput) {\n this.done = false\n this.input = input\n this.format = this.input.format || ''\n\n const init = new Lyric.Info()\n this.context = new ParserContext({ content: this.input.content, musicInfo: this.input.musicInfo }, init)\n }\n\n private handleApplyConfig(plugin: ParserPlugin, options?: any) {\n if (!plugin.config) {\n return\n }\n\n // reset config first\n plugin.config.reset()\n\n if (options) {\n plugin.config.update(options)\n }\n }\n\n private handleExecPlugin(plugin: ParserPlugin) {\n this.done = false\n\n try {\n const result = plugin.check(this.context)\n if (!result) {\n return\n }\n } catch (e: any) {\n console.warn(`plugin check failed id=${plugin.id} err=${e?.message}`)\n return\n }\n\n try {\n plugin.exec(this.context)\n } catch (e: any) {\n console.warn(`plugin call failed id=${plugin.id} err=${e?.message}`)\n }\n }\n\n infer(): this {\n if (this.format) {\n return this\n }\n for (const plugin of BuiltInFormats) {\n try {\n const result = plugin.check(this.context)\n if (result) {\n this.format = plugin.format\n break\n }\n } catch {\n continue\n }\n }\n return this\n }\n\n parse(): this {\n if (!this.format) {\n throw new Error('no format detected. call .infer() before .parse()')\n }\n\n const parser = BuiltInFormats.find((item) => item.format === this.format)\n if (!parser) {\n throw new Error(`parser plugin not found: \"${this.format}\"`)\n }\n\n this.done = false\n\n try {\n parser.exec(this.context)\n } catch (e: any) {\n console.warn(`plugin call failed id=${parser.id} err=${e?.message}`)\n }\n\n return this\n }\n\n backgroundExtract(options?: Transform.Background.ExtractConfig): this {\n this.handleApplyConfig(BuiltInPlugins.background.extract, options)\n this.handleExecPlugin(BuiltInPlugins.background.extract)\n return this\n }\n\n backgroundClean(): this {\n this.handleExecPlugin(BuiltInPlugins.background.clean)\n return this\n }\n\n agentExtract(options?: Transform.Agent.ExtractConfig): this {\n this.handleApplyConfig(BuiltInPlugins.agent.extract, options)\n this.handleExecPlugin(BuiltInPlugins.agent.extract)\n return this\n }\n\n pureExtract(options?: Transform.Pure.ExtractCreatorConfig): this {\n this.handleApplyConfig(BuiltInPlugins.pure.extract, options)\n this.handleExecPlugin(BuiltInPlugins.pure.extract)\n return this\n }\n\n pureClean(options?: Transform.Pure.CleanConfig): this {\n this.handleApplyConfig(BuiltInPlugins.pure.clean, options)\n this.handleExecPlugin(BuiltInPlugins.pure.clean)\n return this\n }\n\n interludeInsert(options?: Transform.Interlude.InsertConfig): this {\n this.handleApplyConfig(BuiltInPlugins.interlude.insert, options)\n this.handleExecPlugin(BuiltInPlugins.interlude.insert)\n return this\n }\n\n spaceInsert(options?: Transform.Space.SpaceConfig): this {\n this.handleApplyConfig(BuiltInPlugins.space.insert, options)\n this.handleExecPlugin(BuiltInPlugins.space.insert)\n return this\n }\n\n stressMark(options?: Transform.Stress.MarkConfig): this {\n this.handleApplyConfig(BuiltInPlugins.stress.mark, options)\n this.handleExecPlugin(BuiltInPlugins.stress.mark)\n return this\n }\n\n final(): ParserPipelineResult {\n if (!this.done) {\n this.context.cleanWord()\n this.context.calcAgentIndex()\n this.context.syncLineTimeWithWord()\n this.context.sort()\n this.context.syncLineTimeWithBackground()\n this.done = true\n }\n\n return {\n format: this.format,\n result: this.context.result,\n }\n }\n}\n\nexport const createParserPipeline = (input: ParserPipelineInput) => {\n return new ParserPipeline(input)\n}\n"],"names":["BuiltInFormats","Format.Lrc","Format.Ttml","BuiltInPlugins","Transform.Agent","Transform.Background","Transform.Pure","Transform.Space","Transform.Interlude","Transform.Stress","ParserPipeline","input","init","Lyric","ParserContext","plugin","options","e","parser","item","createParserPipeline"],"mappings":"gpCAkBMA,EAAiB,CAAC,IAAIC,EAAW,OAAU,IAAIC,EAAY,UAAY,EAEvEC,EAAiB,CACrB,MAAO,CACL,QAAS,IAAIC,EAAgB,OAAQ,EAEvC,WAAY,CACV,QAAS,IAAIC,EAAqB,QAClC,MAAO,IAAIA,EAAqB,KAAM,EAExC,KAAM,CACJ,QAAS,IAAIC,EAAe,eAC5B,MAAO,IAAIA,EAAe,KAAM,EAElC,MAAO,CACL,OAAQ,IAAIC,EAAgB,MAAO,EAErC,UAAW,CACT,OAAQ,IAAIC,EAAoB,MAAO,EAEzC,OAAQ,CACN,KAAM,IAAIC,EAAiB,IAAK,CAEpC,EAEO,MAAMC,CAAe,CAClB,QACA,OACA,MACA,KAER,YAAYC,EAA4B,CACt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@@ -5,10 +5,9 @@ import { GeneratorContext } from '@music-lyric-kit/core';
|
|
|
5
5
|
import { GeneratorOptions } from '@music-lyric-kit/core';
|
|
6
6
|
import { GeneratorParams } from '@music-lyric-kit/core';
|
|
7
7
|
import { GeneratorResult } from '@music-lyric-kit/core';
|
|
8
|
-
import { Info } from '@music-lyric-kit/lyric';
|
|
9
8
|
import * as Interlude from '@music-lyric-kit/plugin-transform-interlude';
|
|
10
9
|
import * as Lrc from '@music-lyric-kit/plugin-format-lrc';
|
|
11
|
-
import
|
|
10
|
+
import { Lyric } from '@music-lyric-kit/lyric';
|
|
12
11
|
import { Parser } from '@music-lyric-kit/core';
|
|
13
12
|
import { ParserContext } from '@music-lyric-kit/core';
|
|
14
13
|
import { ParserOptions } from '@music-lyric-kit/core';
|
|
@@ -21,12 +20,13 @@ import * as Ttml from '@music-lyric-kit/plugin-format-ttml';
|
|
|
21
20
|
|
|
22
21
|
export declare const createParserPipeline: (input: ParserPipelineInput) => ParserPipeline;
|
|
23
22
|
|
|
24
|
-
declare namespace
|
|
23
|
+
declare namespace Format {
|
|
25
24
|
export {
|
|
26
25
|
Lrc,
|
|
27
26
|
Ttml
|
|
28
27
|
}
|
|
29
28
|
}
|
|
29
|
+
export { Format }
|
|
30
30
|
|
|
31
31
|
export { Generator_2 as Generator }
|
|
32
32
|
|
|
@@ -58,14 +58,14 @@ export declare class ParserPipeline {
|
|
|
58
58
|
private handleExecPlugin;
|
|
59
59
|
infer(): this;
|
|
60
60
|
parse(): this;
|
|
61
|
-
backgroundExtract(options?:
|
|
61
|
+
backgroundExtract(options?: Transform.Background.ExtractConfig): this;
|
|
62
62
|
backgroundClean(): this;
|
|
63
|
-
agentExtract(options?:
|
|
64
|
-
pureExtract(options?:
|
|
65
|
-
pureClean(options?:
|
|
66
|
-
interludeInsert(options?:
|
|
67
|
-
spaceInsert(options?:
|
|
68
|
-
stressMark(options?:
|
|
63
|
+
agentExtract(options?: Transform.Agent.ExtractConfig): this;
|
|
64
|
+
pureExtract(options?: Transform.Pure.ExtractCreatorConfig): this;
|
|
65
|
+
pureClean(options?: Transform.Pure.CleanConfig): this;
|
|
66
|
+
interludeInsert(options?: Transform.Interlude.InsertConfig): this;
|
|
67
|
+
spaceInsert(options?: Transform.Space.SpaceConfig): this;
|
|
68
|
+
stressMark(options?: Transform.Stress.MarkConfig): this;
|
|
69
69
|
final(): ParserPipelineResult;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -77,20 +77,12 @@ export declare interface ParserPipelineInput {
|
|
|
77
77
|
|
|
78
78
|
export declare interface ParserPipelineResult {
|
|
79
79
|
format: string;
|
|
80
|
-
result: Info;
|
|
80
|
+
result: Lyric.Info;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export { ParserResult }
|
|
84
84
|
|
|
85
|
-
declare namespace
|
|
86
|
-
export {
|
|
87
|
-
Formats,
|
|
88
|
-
Transforms
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export { Plugins }
|
|
92
|
-
|
|
93
|
-
declare namespace Transforms {
|
|
85
|
+
declare namespace Transform {
|
|
94
86
|
export {
|
|
95
87
|
Interlude,
|
|
96
88
|
Background,
|
|
@@ -100,5 +92,6 @@ declare namespace Transforms {
|
|
|
100
92
|
Stress
|
|
101
93
|
}
|
|
102
94
|
}
|
|
95
|
+
export { Transform }
|
|
103
96
|
|
|
104
97
|
export { }
|
package/dist/index.ecma.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
1
|
+
import { Lyric as p } from "@music-lyric-kit/lyric";
|
|
2
|
+
import { Lyric as C } from "@music-lyric-kit/lyric";
|
|
3
|
+
import * as o from "@music-lyric-kit/plugin-format-lrc";
|
|
4
4
|
import * as c from "@music-lyric-kit/plugin-format-ttml";
|
|
5
5
|
import * as l from "@music-lyric-kit/plugin-transform-interlude";
|
|
6
6
|
import * as n from "@music-lyric-kit/plugin-transform-background";
|
|
@@ -9,12 +9,12 @@ import * as h from "@music-lyric-kit/plugin-transform-space";
|
|
|
9
9
|
import * as i from "@music-lyric-kit/plugin-transform-pure";
|
|
10
10
|
import * as f from "@music-lyric-kit/plugin-transform-stress";
|
|
11
11
|
import { ParserContext as m } from "@music-lyric-kit/core";
|
|
12
|
-
import { Generator as T, GeneratorContext as A, Parser as I, ParserContext as
|
|
13
|
-
const
|
|
12
|
+
import { Generator as T, GeneratorContext as A, Parser as I, ParserContext as S } from "@music-lyric-kit/core";
|
|
13
|
+
const P = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
14
14
|
__proto__: null,
|
|
15
|
-
Lrc:
|
|
15
|
+
Lrc: o,
|
|
16
16
|
Ttml: c
|
|
17
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
17
|
+
}, Symbol.toStringTag, { value: "Module" })), w = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
18
18
|
__proto__: null,
|
|
19
19
|
Agent: u,
|
|
20
20
|
Background: n,
|
|
@@ -22,40 +22,36 @@ const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
22
22
|
Pure: i,
|
|
23
23
|
Space: h,
|
|
24
24
|
Stress: f
|
|
25
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
26
|
-
__proto__: null,
|
|
27
|
-
Formats: g,
|
|
28
|
-
Transforms: d
|
|
29
|
-
}, Symbol.toStringTag, { value: "Module" })), o = [new a.Parser(), new c.AmllParser()], e = {
|
|
25
|
+
}, Symbol.toStringTag, { value: "Module" })), a = [new o.Parser(), new c.AmllParser()], e = {
|
|
30
26
|
agent: {
|
|
31
|
-
extract: new u.
|
|
27
|
+
extract: new u.Extract()
|
|
32
28
|
},
|
|
33
29
|
background: {
|
|
34
|
-
extract: new n.
|
|
35
|
-
clean: new n.
|
|
30
|
+
extract: new n.Extract(),
|
|
31
|
+
clean: new n.Clean()
|
|
36
32
|
},
|
|
37
33
|
pure: {
|
|
38
|
-
extract: new i.
|
|
39
|
-
clean: new i.
|
|
34
|
+
extract: new i.ExtractCreator(),
|
|
35
|
+
clean: new i.Clean()
|
|
40
36
|
},
|
|
41
37
|
space: {
|
|
42
|
-
insert: new h.
|
|
38
|
+
insert: new h.Insert()
|
|
43
39
|
},
|
|
44
40
|
interlude: {
|
|
45
|
-
insert: new l.
|
|
41
|
+
insert: new l.Insert()
|
|
46
42
|
},
|
|
47
43
|
stress: {
|
|
48
|
-
mark: new f.
|
|
44
|
+
mark: new f.Mark()
|
|
49
45
|
}
|
|
50
46
|
};
|
|
51
|
-
class
|
|
47
|
+
class d {
|
|
52
48
|
context;
|
|
53
49
|
format;
|
|
54
50
|
input;
|
|
55
51
|
done;
|
|
56
52
|
constructor(t) {
|
|
57
53
|
this.done = !1, this.input = t, this.format = this.input.format || "";
|
|
58
|
-
const r = new p();
|
|
54
|
+
const r = new p.Info();
|
|
59
55
|
this.context = new m({ content: this.input.content, musicInfo: this.input.musicInfo }, r);
|
|
60
56
|
}
|
|
61
57
|
handleApplyConfig(t, r) {
|
|
@@ -79,7 +75,7 @@ class x {
|
|
|
79
75
|
infer() {
|
|
80
76
|
if (this.format)
|
|
81
77
|
return this;
|
|
82
|
-
for (const t of
|
|
78
|
+
for (const t of a)
|
|
83
79
|
try {
|
|
84
80
|
if (t.check(this.context)) {
|
|
85
81
|
this.format = t.format;
|
|
@@ -93,7 +89,7 @@ class x {
|
|
|
93
89
|
parse() {
|
|
94
90
|
if (!this.format)
|
|
95
91
|
throw new Error("no format detected. call .infer() before .parse()");
|
|
96
|
-
const t =
|
|
92
|
+
const t = a.find((r) => r.format === this.format);
|
|
97
93
|
if (!t)
|
|
98
94
|
throw new Error(`parser plugin not found: "${this.format}"`);
|
|
99
95
|
this.done = !1;
|
|
@@ -135,15 +131,16 @@ class x {
|
|
|
135
131
|
};
|
|
136
132
|
}
|
|
137
133
|
}
|
|
138
|
-
const
|
|
134
|
+
const y = (s) => new d(s);
|
|
139
135
|
export {
|
|
136
|
+
P as Format,
|
|
140
137
|
T as Generator,
|
|
141
138
|
A as GeneratorContext,
|
|
142
|
-
|
|
139
|
+
C as Lyric,
|
|
143
140
|
I as Parser,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
141
|
+
S as ParserContext,
|
|
142
|
+
d as ParserPipeline,
|
|
143
|
+
w as Transform,
|
|
144
|
+
y as createParserPipeline
|
|
148
145
|
};
|
|
149
146
|
//# sourceMappingURL=index.ecma.js.map
|
package/dist/index.ecma.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.ecma.js","sources":["../src/parser/pipeline.ts"],"sourcesContent":["import type { ParserParams } from '@music-lyric-kit/core'\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.ecma.js","sources":["../src/parser/pipeline.ts"],"sourcesContent":["import type { ParserParams } from '@music-lyric-kit/core'\n\nimport { Lyric } from '@music-lyric-kit/lyric'\nimport { ParserContext, ParserPlugin } from '@music-lyric-kit/core'\n\nimport { Format, Transform } from '@root/plugin'\n\nexport interface ParserPipelineInput {\n format?: string\n content: any\n musicInfo?: ParserParams['musicInfo']\n}\n\nexport interface ParserPipelineResult {\n format: string\n result: Lyric.Info\n}\n\nconst BuiltInFormats = [new Format.Lrc.Parser(), new Format.Ttml.AmllParser()]\n\nconst BuiltInPlugins = {\n agent: {\n extract: new Transform.Agent.Extract(),\n },\n background: {\n extract: new Transform.Background.Extract(),\n clean: new Transform.Background.Clean(),\n },\n pure: {\n extract: new Transform.Pure.ExtractCreator(),\n clean: new Transform.Pure.Clean(),\n },\n space: {\n insert: new Transform.Space.Insert(),\n },\n interlude: {\n insert: new Transform.Interlude.Insert(),\n },\n stress: {\n mark: new Transform.Stress.Mark(),\n },\n}\n\nexport class ParserPipeline {\n private context: ParserContext\n private format: string\n private input: ParserPipelineInput\n private done: boolean\n\n constructor(input: ParserPipelineInput) {\n this.done = false\n this.input = input\n this.format = this.input.format || ''\n\n const init = new Lyric.Info()\n this.context = new ParserContext({ content: this.input.content, musicInfo: this.input.musicInfo }, init)\n }\n\n private handleApplyConfig(plugin: ParserPlugin, options?: any) {\n if (!plugin.config) {\n return\n }\n\n // reset config first\n plugin.config.reset()\n\n if (options) {\n plugin.config.update(options)\n }\n }\n\n private handleExecPlugin(plugin: ParserPlugin) {\n this.done = false\n\n try {\n const result = plugin.check(this.context)\n if (!result) {\n return\n }\n } catch (e: any) {\n console.warn(`plugin check failed id=${plugin.id} err=${e?.message}`)\n return\n }\n\n try {\n plugin.exec(this.context)\n } catch (e: any) {\n console.warn(`plugin call failed id=${plugin.id} err=${e?.message}`)\n }\n }\n\n infer(): this {\n if (this.format) {\n return this\n }\n for (const plugin of BuiltInFormats) {\n try {\n const result = plugin.check(this.context)\n if (result) {\n this.format = plugin.format\n break\n }\n } catch {\n continue\n }\n }\n return this\n }\n\n parse(): this {\n if (!this.format) {\n throw new Error('no format detected. call .infer() before .parse()')\n }\n\n const parser = BuiltInFormats.find((item) => item.format === this.format)\n if (!parser) {\n throw new Error(`parser plugin not found: \"${this.format}\"`)\n }\n\n this.done = false\n\n try {\n parser.exec(this.context)\n } catch (e: any) {\n console.warn(`plugin call failed id=${parser.id} err=${e?.message}`)\n }\n\n return this\n }\n\n backgroundExtract(options?: Transform.Background.ExtractConfig): this {\n this.handleApplyConfig(BuiltInPlugins.background.extract, options)\n this.handleExecPlugin(BuiltInPlugins.background.extract)\n return this\n }\n\n backgroundClean(): this {\n this.handleExecPlugin(BuiltInPlugins.background.clean)\n return this\n }\n\n agentExtract(options?: Transform.Agent.ExtractConfig): this {\n this.handleApplyConfig(BuiltInPlugins.agent.extract, options)\n this.handleExecPlugin(BuiltInPlugins.agent.extract)\n return this\n }\n\n pureExtract(options?: Transform.Pure.ExtractCreatorConfig): this {\n this.handleApplyConfig(BuiltInPlugins.pure.extract, options)\n this.handleExecPlugin(BuiltInPlugins.pure.extract)\n return this\n }\n\n pureClean(options?: Transform.Pure.CleanConfig): this {\n this.handleApplyConfig(BuiltInPlugins.pure.clean, options)\n this.handleExecPlugin(BuiltInPlugins.pure.clean)\n return this\n }\n\n interludeInsert(options?: Transform.Interlude.InsertConfig): this {\n this.handleApplyConfig(BuiltInPlugins.interlude.insert, options)\n this.handleExecPlugin(BuiltInPlugins.interlude.insert)\n return this\n }\n\n spaceInsert(options?: Transform.Space.SpaceConfig): this {\n this.handleApplyConfig(BuiltInPlugins.space.insert, options)\n this.handleExecPlugin(BuiltInPlugins.space.insert)\n return this\n }\n\n stressMark(options?: Transform.Stress.MarkConfig): this {\n this.handleApplyConfig(BuiltInPlugins.stress.mark, options)\n this.handleExecPlugin(BuiltInPlugins.stress.mark)\n return this\n }\n\n final(): ParserPipelineResult {\n if (!this.done) {\n this.context.cleanWord()\n this.context.calcAgentIndex()\n this.context.syncLineTimeWithWord()\n this.context.sort()\n this.context.syncLineTimeWithBackground()\n this.done = true\n }\n\n return {\n format: this.format,\n result: this.context.result,\n }\n }\n}\n\nexport const createParserPipeline = (input: ParserPipelineInput) => {\n return new ParserPipeline(input)\n}\n"],"names":["BuiltInFormats","Format.Lrc","Format.Ttml","BuiltInPlugins","Transform.Agent","Transform.Background","Transform.Pure","Transform.Space","Transform.Interlude","Transform.Stress","ParserPipeline","input","init","Lyric","ParserContext","plugin","options","e","parser","item","createParserPipeline"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;8CAkBMA,IAAiB,CAAC,IAAIC,EAAW,OAAA,GAAU,IAAIC,EAAY,YAAY,GAEvEC,IAAiB;AAAA,EACrB,OAAO;AAAA,IACL,SAAS,IAAIC,EAAgB,QAAA;AAAA,EAAQ;AAAA,EAEvC,YAAY;AAAA,IACV,SAAS,IAAIC,EAAqB,QAAA;AAAA,IAClC,OAAO,IAAIA,EAAqB,MAAA;AAAA,EAAM;AAAA,EAExC,MAAM;AAAA,IACJ,SAAS,IAAIC,EAAe,eAAA;AAAA,IAC5B,OAAO,IAAIA,EAAe,MAAA;AAAA,EAAM;AAAA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AAM,QAAQa,CAAO,GAC3D,KAAK,iBAAiBb,EAAe,MAAM,MAAM,GAC1C;AAAA,EACT;AAAA,EAEA,WAAWa,GAA6C;AACtD,gBAAK,kBAAkBb,EAAe,OAAO,MAAMa,CAAO,GAC1D,KAAK,iBAAiBb,EAAe,OAAO,IAAI,GACzC;AAAA,EACT;AAAA,EAEA,QAA8B;AAC5B,WAAK,KAAK,SACR,KAAK,QAAQ,UAAA,GACb,KAAK,QAAQ,eAAA,GACb,KAAK,QAAQ,qBAAA,GACb,KAAK,QAAQ,KAAA,GACb,KAAK,QAAQ,2BAAA,GACb,KAAK,OAAO,KAGP;AAAA,MACL,QAAQ,KAAK;AAAA,MACb,QAAQ,KAAK,QAAQ;AAAA,IAAA;AAAA,EAEzB;AACF;AAEO,MAAMiB,IAAuB,CAACT,MAC5B,IAAID,EAAeC,CAAK;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "music-lyric-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"author": "folltoshe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Music Lyric Kit",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@music-lyric-kit/
|
|
38
|
-
"@music-lyric-kit/
|
|
39
|
-
"@music-lyric-kit/
|
|
40
|
-
"@music-lyric-kit/plugin-format-
|
|
41
|
-
"@music-lyric-kit/
|
|
42
|
-
"@music-lyric-kit/plugin-transform-
|
|
43
|
-
"@music-lyric-kit/plugin-transform-
|
|
44
|
-
"@music-lyric-kit/plugin-transform-
|
|
45
|
-
"@music-lyric-kit/plugin-transform-
|
|
46
|
-
"@music-lyric-kit/plugin-transform-
|
|
47
|
-
"@music-lyric-kit/plugin-transform-
|
|
37
|
+
"@music-lyric-kit/core": "0.12.0",
|
|
38
|
+
"@music-lyric-kit/lyric": "0.12.0",
|
|
39
|
+
"@music-lyric-kit/plugin-format-lrc": "0.12.0",
|
|
40
|
+
"@music-lyric-kit/plugin-format-ttml": "0.12.0",
|
|
41
|
+
"@music-lyric-kit/utils": "0.12.0",
|
|
42
|
+
"@music-lyric-kit/plugin-transform-interlude": "0.12.0",
|
|
43
|
+
"@music-lyric-kit/plugin-transform-pure": "0.12.0",
|
|
44
|
+
"@music-lyric-kit/plugin-transform-agent": "0.12.0",
|
|
45
|
+
"@music-lyric-kit/plugin-transform-stress": "0.12.0",
|
|
46
|
+
"@music-lyric-kit/plugin-transform-space": "0.12.0",
|
|
47
|
+
"@music-lyric-kit/plugin-transform-background": "0.12.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "vite build"
|