music-lyric-kit 0.14.1 → 0.15.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.js +45 -45
- package/dist/index.ecma.js.map +1 -1
- package/package.json +13 -13
package/dist/index.comm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@music-lyric-kit/lyric"),x=require("@music-lyric-kit/plugin-format-lrc"),P=require("@music-lyric-kit/plugin-format-ttml"),y=require("@music-lyric-kit/plugin-transform-interlude"),w=require("@music-lyric-kit/plugin-transform-background"),b=require("@music-lyric-kit/plugin-transform-agent"),T=require("@music-lyric-kit/plugin-transform-space"),k=require("@music-lyric-kit/plugin-transform-pure"),I=require("@music-lyric-kit/plugin-transform-stress"),O=require("@music-lyric-kit/plugin-transform-language"),s=require("@music-lyric-kit/core");function n(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,l.get?l:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const f=n(x),c=n(P),m=n(y),a=n(w),p=n(b),g=n(T),o=n(k),d=n(I),u=n(O),S=Object.freeze(Object.defineProperty({__proto__:null,Lrc:f,Ttml:c},Symbol.toStringTag,{value:"Module"})),L=Object.freeze(Object.defineProperty({__proto__:null,Agent:p,Background:a,Interlude:m,Language:u,Pure:o,Space:g,Stress:d},Symbol.toStringTag,{value:"Module"})),h=[new f.Parser,new c.AmllParser,new c.ItunesParser];class j{constructor(e){this.client=e}_extract=new p.Extract;extract(e){return this.client.run(this._extract,e)}}class C{constructor(e){this.client=e}_extract=new a.Extract;_clean=new a.Clean;extract(e){return this.client.run(this._extract,e)}clean(){return this.client.run(this._clean)}}class q{constructor(e){this.client=e}_extractCreator=new o.ExtractCreator;_clean=new o.Clean;extractCreator(e){return this.client.run(this._extractCreator,e)}clean(e){return this.client.run(this._clean,e)}}class A{constructor(e){this.client=e}_insert=new m.Insert;insert(e){return this.client.run(this._insert,e)}}class ${constructor(e){this.client=e}_insert=new g.Insert;insert(e){return this.client.run(this._insert,e)}}class B{constructor(e){this.client=e}_mark=new d.Mark;mark(e){return this.client.run(this._mark,e)}}class E{constructor(e){this.client=e}_infer=new u.Infer;_calculatePercent=new u.CalculatePercent;infer(e){return this.client.run(this._infer,e)}calculatePercent(e){return this.client.run(this._calculatePercent,e)}}class _{context;format;input;done;agent;background;pure;interlude;space;stress;language;constructor(e){this.done=!1,this.input=e,this.format=this.input.format||"";const t=i.Lyric.makeInfo({type:i.Lyric.InfoType.INVALID,timing:i.Lyric.InfoTiming.NONE});this.context=new s.ParserContext({content:this.input.content,musicInfo:this.input.musicInfo},t),this.agent=new j(this),this.background=new C(this),this.pure=new q(this),this.interlude=new A(this),this.space=new $(this),this.stress=new B(this),this.language=new E(this)}applyConfig(e,t){e.config&&e.config.apply(t)}exec(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}`)}}run(e,t){return this.applyConfig(e,t),this.exec(e),this}infer(){if(this.format)return this;for(const e of h)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=h.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.context.finalizeAnnotation(),this}final(){return this.done||(this.context.cleanWord(),this.context.finalizeAnnotation(),this.context.syncLineTimeWithWord(),this.context.sort(),this.context.syncLineTimeWithBackground(),this.done=!0),{format:this.format,result:this.context.result}}}const F=r=>new _(r);Object.defineProperty(exports,"Lyric",{enumerable:!0,get:()=>i.Lyric});Object.defineProperty(exports,"Generator",{enumerable:!0,get:()=>s.Generator});Object.defineProperty(exports,"GeneratorContext",{enumerable:!0,get:()=>s.GeneratorContext});Object.defineProperty(exports,"Parser",{enumerable:!0,get:()=>s.Parser});Object.defineProperty(exports,"ParserContext",{enumerable:!0,get:()=>s.ParserContext});exports.Format=S;exports.ParserPipeline=_;exports.Transform=L;exports.createParserPipeline=F;
|
|
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 { 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(), new Format.Ttml.ItunesParser()]\n\nclass Agent {\n private _extract = new Transform.Agent.Extract()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Agent.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n}\n\nclass Background {\n private _extract = new Transform.Background.Extract()\n private _clean = new Transform.Background.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Background.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n\n clean() {\n return this.client.run(this._clean)\n }\n}\n\nclass Pure {\n private _extractCreator = new Transform.Pure.ExtractCreator()\n private _clean = new Transform.Pure.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extractCreator(options?: Transform.Pure.ExtractCreatorConfig) {\n return this.client.run(this._extractCreator, options)\n }\n\n clean(options?: Transform.Pure.CleanConfig) {\n return this.client.run(this._clean, options)\n }\n}\n\nclass Interlude {\n private _insert = new Transform.Interlude.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Interlude.InsertConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Space {\n private _insert = new Transform.Space.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Space.SpaceConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Stress {\n private _mark = new Transform.Stress.Mark()\n\n constructor(private client: ParserPipeline) {}\n\n mark(options?: Transform.Stress.MarkConfig) {\n return this.client.run(this._mark, options)\n }\n}\n\nclass Language {\n private _infer = new Transform.Language.Infer()\n private _calculatePercent = new Transform.Language.CalculatePercent()\n\n constructor(private client: ParserPipeline) {}\n\n infer(options?: Transform.Language.InferConfig) {\n return this.client.run(this._infer, options)\n }\n\n calculatePercent(options?: Transform.Language.CalculateConfig) {\n return this.client.run(this._calculatePercent, options)\n }\n}\n\nexport class ParserPipeline {\n private context: ParserContext\n private format: string\n private input: ParserPipelineInput\n private done: boolean\n\n readonly agent: Agent\n readonly background: Background\n readonly pure: Pure\n readonly interlude: Interlude\n readonly space: Space\n readonly stress: Stress\n readonly language: Language\n\n constructor(input: ParserPipelineInput) {\n this.done = false\n this.input = input\n this.format = this.input.format || ''\n\n const init =
|
|
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(), new Format.Ttml.ItunesParser()]\n\nclass Agent {\n private _extract = new Transform.Agent.Extract()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Agent.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n}\n\nclass Background {\n private _extract = new Transform.Background.Extract()\n private _clean = new Transform.Background.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Background.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n\n clean() {\n return this.client.run(this._clean)\n }\n}\n\nclass Pure {\n private _extractCreator = new Transform.Pure.ExtractCreator()\n private _clean = new Transform.Pure.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extractCreator(options?: Transform.Pure.ExtractCreatorConfig) {\n return this.client.run(this._extractCreator, options)\n }\n\n clean(options?: Transform.Pure.CleanConfig) {\n return this.client.run(this._clean, options)\n }\n}\n\nclass Interlude {\n private _insert = new Transform.Interlude.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Interlude.InsertConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Space {\n private _insert = new Transform.Space.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Space.SpaceConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Stress {\n private _mark = new Transform.Stress.Mark()\n\n constructor(private client: ParserPipeline) {}\n\n mark(options?: Transform.Stress.MarkConfig) {\n return this.client.run(this._mark, options)\n }\n}\n\nclass Language {\n private _infer = new Transform.Language.Infer()\n private _calculatePercent = new Transform.Language.CalculatePercent()\n\n constructor(private client: ParserPipeline) {}\n\n infer(options?: Transform.Language.InferConfig) {\n return this.client.run(this._infer, options)\n }\n\n calculatePercent(options?: Transform.Language.CalculateConfig) {\n return this.client.run(this._calculatePercent, options)\n }\n}\n\nexport class ParserPipeline {\n private context: ParserContext\n private format: string\n private input: ParserPipelineInput\n private done: boolean\n\n readonly agent: Agent\n readonly background: Background\n readonly pure: Pure\n readonly interlude: Interlude\n readonly space: Space\n readonly stress: Stress\n readonly language: Language\n\n constructor(input: ParserPipelineInput) {\n this.done = false\n this.input = input\n this.format = this.input.format || ''\n\n const init = Lyric.makeInfo({ type: Lyric.InfoType.INVALID, timing: Lyric.InfoTiming.NONE })\n this.context = new ParserContext({ content: this.input.content, musicInfo: this.input.musicInfo }, init)\n\n this.agent = new Agent(this)\n this.background = new Background(this)\n this.pure = new Pure(this)\n this.interlude = new Interlude(this)\n this.space = new Space(this)\n this.stress = new Stress(this)\n this.language = new Language(this)\n }\n\n private applyConfig(plugin: ParserPlugin, options?: any) {\n if (!plugin.config) {\n return\n }\n\n // reset to defaults and apply this run's options in a single update.\n plugin.config.apply(options)\n }\n\n private exec(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 /**\n * Apply optional config to a plugin and execute it against the current context.\n * Intended for use by the pipeline plugin scopes.\n */\n run(plugin: ParserPlugin, options?: any): this {\n this.applyConfig(plugin, options)\n this.exec(plugin)\n return this\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 this.context.finalizeAnnotation()\n\n return this\n }\n\n final(): ParserPipelineResult {\n if (!this.done) {\n this.context.cleanWord()\n this.context.finalizeAnnotation()\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","Agent","client","Transform.Agent","options","Background","Transform.Background","Pure","Transform.Pure","Interlude","Transform.Interlude","Space","Transform.Space","Stress","Transform.Stress","Language","Transform.Language","ParserPipeline","input","init","Lyric","ParserContext","plugin","e","parser","item","createParserPipeline"],"mappings":"0tCAkBMA,EAAiB,CAAC,IAAIC,EAAW,OAAU,IAAIC,EAAY,WAAc,IAAIA,EAAY,YAAc,EAE7G,MAAMC,CAAM,CAGV,YAAoBC,EAAwB,CAAxB,KAAA,OAAAA,CAAyB,CAFrC,SAAW,IAAIC,EAAgB,QAIvC,QAAQC,EAAyC,CAC/C,OAAO,KAAK,OAAO,IAAI,KAAK,SAAUA,CAAO,CAC/C,CACF,CAEA,MAAMC,CAAW,CAIf,YAAoBH,EAAwB,CAAxB,KAAA,OAAAA,CAAyB,CAHrC,SAAW,IAAII,EAAqB,QACpC,OAAS,IAAIA,EAAqB,MAI1C,QAAQF,EAA8C,CACpD,OAAO,KAAK,OAAO,IAAI,KAAK,SAAUA,CAAO,CAC/C,CAEA,OAAQ,CACN,OAAO,KAAK,OAAO,IAAI,KAAK,MAAM,CACpC,CACF,CAEA,MAAMG,CAAK,CAIT,YAAoBL,EAAwB,CAAxB,KAAA,OAAAA,CAAyB,CAHrC,gBAAkB,IAAIM,EAAe,eACrC,OAAS,IAAIA,EAAe,MAIpC,eAAeJ,EAA+C,CAC5D,OAAO,KAAK,OAAO,IAAI,KAAK,gBAAiBA,CAAO,CACtD,CAEA,MAAMA,EAAsC,CAC1C,OAAO,KAAK,OAAO,IAAI,KAAK,OAAQA,CAAO,CAC7C,CACF,CAEA,MAAMK,CAAU,CAGd,YAAoBP,EAAwB,CAAxB,KA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AyBC,EAAO,EAAE,QAAQD,GAAG,OAAO,EAAE,CACrE,CAEA,YAAK,QAAQ,mBAAA,EAEN,IACT,CAEA,OAA8B,CAC5B,OAAK,KAAK,OACR,KAAK,QAAQ,UAAA,EACb,KAAK,QAAQ,mBAAA,EACb,KAAK,QAAQ,qBAAA,EACb,KAAK,QAAQ,KAAA,EACb,KAAK,QAAQ,2BAAA,EACb,KAAK,KAAO,IAGP,CACL,OAAQ,KAAK,OACb,OAAQ,KAAK,QAAQ,MAAA,CAEzB,CACF,CAEO,MAAMG,EAAwBR,GAC5B,IAAID,EAAeC,CAAK"}
|
package/dist/index.ecma.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Lyric as
|
|
1
|
+
import { Lyric as n } from "@music-lyric-kit/lyric";
|
|
2
2
|
import { Lyric as $ } from "@music-lyric-kit/lyric";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
3
|
+
import * as l from "@music-lyric-kit/plugin-format-lrc";
|
|
4
|
+
import * as s from "@music-lyric-kit/plugin-format-ttml";
|
|
5
|
+
import * as u from "@music-lyric-kit/plugin-transform-interlude";
|
|
6
|
+
import * as i from "@music-lyric-kit/plugin-transform-background";
|
|
7
|
+
import * as h from "@music-lyric-kit/plugin-transform-agent";
|
|
8
|
+
import * as f from "@music-lyric-kit/plugin-transform-space";
|
|
9
|
+
import * as o from "@music-lyric-kit/plugin-transform-pure";
|
|
10
|
+
import * as m from "@music-lyric-kit/plugin-transform-stress";
|
|
11
|
+
import * as a from "@music-lyric-kit/plugin-transform-language";
|
|
12
12
|
import { ParserContext as p } from "@music-lyric-kit/core";
|
|
13
|
-
import { Generator as
|
|
14
|
-
const
|
|
13
|
+
import { Generator as B, GeneratorContext as O, Parser as j, ParserContext as z } from "@music-lyric-kit/core";
|
|
14
|
+
const C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
15
15
|
__proto__: null,
|
|
16
|
-
Lrc:
|
|
17
|
-
Ttml:
|
|
16
|
+
Lrc: l,
|
|
17
|
+
Ttml: s
|
|
18
18
|
}, Symbol.toStringTag, { value: "Module" })), b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
19
19
|
__proto__: null,
|
|
20
|
-
Agent:
|
|
21
|
-
Background:
|
|
22
|
-
Interlude:
|
|
23
|
-
Language:
|
|
24
|
-
Pure:
|
|
25
|
-
Space:
|
|
26
|
-
Stress:
|
|
27
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
20
|
+
Agent: h,
|
|
21
|
+
Background: i,
|
|
22
|
+
Interlude: u,
|
|
23
|
+
Language: a,
|
|
24
|
+
Pure: o,
|
|
25
|
+
Space: f,
|
|
26
|
+
Stress: m
|
|
27
|
+
}, Symbol.toStringTag, { value: "Module" })), c = [new l.Parser(), new s.AmllParser(), new s.ItunesParser()];
|
|
28
28
|
class g {
|
|
29
29
|
constructor(t) {
|
|
30
30
|
this.client = t;
|
|
31
31
|
}
|
|
32
|
-
_extract = new
|
|
32
|
+
_extract = new h.Extract();
|
|
33
33
|
extract(t) {
|
|
34
34
|
return this.client.run(this._extract, t);
|
|
35
35
|
}
|
|
@@ -38,8 +38,8 @@ class d {
|
|
|
38
38
|
constructor(t) {
|
|
39
39
|
this.client = t;
|
|
40
40
|
}
|
|
41
|
-
_extract = new
|
|
42
|
-
_clean = new
|
|
41
|
+
_extract = new i.Extract();
|
|
42
|
+
_clean = new i.Clean();
|
|
43
43
|
extract(t) {
|
|
44
44
|
return this.client.run(this._extract, t);
|
|
45
45
|
}
|
|
@@ -51,8 +51,8 @@ class x {
|
|
|
51
51
|
constructor(t) {
|
|
52
52
|
this.client = t;
|
|
53
53
|
}
|
|
54
|
-
_extractCreator = new
|
|
55
|
-
_clean = new
|
|
54
|
+
_extractCreator = new o.ExtractCreator();
|
|
55
|
+
_clean = new o.Clean();
|
|
56
56
|
extractCreator(t) {
|
|
57
57
|
return this.client.run(this._extractCreator, t);
|
|
58
58
|
}
|
|
@@ -64,7 +64,7 @@ class w {
|
|
|
64
64
|
constructor(t) {
|
|
65
65
|
this.client = t;
|
|
66
66
|
}
|
|
67
|
-
_insert = new
|
|
67
|
+
_insert = new u.Insert();
|
|
68
68
|
insert(t) {
|
|
69
69
|
return this.client.run(this._insert, t);
|
|
70
70
|
}
|
|
@@ -73,7 +73,7 @@ class _ {
|
|
|
73
73
|
constructor(t) {
|
|
74
74
|
this.client = t;
|
|
75
75
|
}
|
|
76
|
-
_insert = new
|
|
76
|
+
_insert = new f.Insert();
|
|
77
77
|
insert(t) {
|
|
78
78
|
return this.client.run(this._insert, t);
|
|
79
79
|
}
|
|
@@ -82,7 +82,7 @@ class P {
|
|
|
82
82
|
constructor(t) {
|
|
83
83
|
this.client = t;
|
|
84
84
|
}
|
|
85
|
-
_mark = new
|
|
85
|
+
_mark = new m.Mark();
|
|
86
86
|
mark(t) {
|
|
87
87
|
return this.client.run(this._mark, t);
|
|
88
88
|
}
|
|
@@ -91,8 +91,8 @@ class y {
|
|
|
91
91
|
constructor(t) {
|
|
92
92
|
this.client = t;
|
|
93
93
|
}
|
|
94
|
-
_infer = new
|
|
95
|
-
_calculatePercent = new
|
|
94
|
+
_infer = new a.Infer();
|
|
95
|
+
_calculatePercent = new a.CalculatePercent();
|
|
96
96
|
infer(t) {
|
|
97
97
|
return this.client.run(this._infer, t);
|
|
98
98
|
}
|
|
@@ -100,7 +100,7 @@ class y {
|
|
|
100
100
|
return this.client.run(this._calculatePercent, t);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class T {
|
|
104
104
|
context;
|
|
105
105
|
format;
|
|
106
106
|
input;
|
|
@@ -114,7 +114,7 @@ class k {
|
|
|
114
114
|
language;
|
|
115
115
|
constructor(t) {
|
|
116
116
|
this.done = !1, this.input = t, this.format = this.input.format || "";
|
|
117
|
-
const e =
|
|
117
|
+
const e = n.makeInfo({ type: n.InfoType.INVALID, timing: n.InfoTiming.NONE });
|
|
118
118
|
this.context = new p({ content: this.input.content, musicInfo: this.input.musicInfo }, e), this.agent = new g(this), this.background = new d(this), this.pure = new x(this), this.interlude = new w(this), this.space = new _(this), this.stress = new P(this), this.language = new y(this);
|
|
119
119
|
}
|
|
120
120
|
applyConfig(t, e) {
|
|
@@ -145,7 +145,7 @@ class k {
|
|
|
145
145
|
infer() {
|
|
146
146
|
if (this.format)
|
|
147
147
|
return this;
|
|
148
|
-
for (const t of
|
|
148
|
+
for (const t of c)
|
|
149
149
|
try {
|
|
150
150
|
if (t.check(this.context)) {
|
|
151
151
|
this.format = t.format;
|
|
@@ -159,7 +159,7 @@ class k {
|
|
|
159
159
|
parse() {
|
|
160
160
|
if (!this.format)
|
|
161
161
|
throw new Error("no format detected. call .infer() before .parse()");
|
|
162
|
-
const t =
|
|
162
|
+
const t = c.find((e) => e.format === this.format);
|
|
163
163
|
if (!t)
|
|
164
164
|
throw new Error(`parser plugin not found: "${this.format}"`);
|
|
165
165
|
this.done = !1;
|
|
@@ -171,22 +171,22 @@ class k {
|
|
|
171
171
|
return this.context.finalizeAnnotation(), this;
|
|
172
172
|
}
|
|
173
173
|
final() {
|
|
174
|
-
return this.done || (this.context.cleanWord(), this.context.finalizeAnnotation(), this.context.syncLineTimeWithWord(), this.context.sort(), this.context.
|
|
174
|
+
return this.done || (this.context.cleanWord(), this.context.finalizeAnnotation(), this.context.syncLineTimeWithWord(), this.context.sort(), this.context.syncLineTimeWithBackground(), this.done = !0), {
|
|
175
175
|
format: this.format,
|
|
176
176
|
result: this.context.result
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
const
|
|
180
|
+
const L = (r) => new T(r);
|
|
181
181
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
C as Format,
|
|
183
|
+
B as Generator,
|
|
184
|
+
O as GeneratorContext,
|
|
185
185
|
$ as Lyric,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
j as Parser,
|
|
187
|
+
z as ParserContext,
|
|
188
|
+
T as ParserPipeline,
|
|
189
189
|
b as Transform,
|
|
190
|
-
|
|
190
|
+
L as createParserPipeline
|
|
191
191
|
};
|
|
192
192
|
//# 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 { 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(), new Format.Ttml.ItunesParser()]\n\nclass Agent {\n private _extract = new Transform.Agent.Extract()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Agent.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n}\n\nclass Background {\n private _extract = new Transform.Background.Extract()\n private _clean = new Transform.Background.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Background.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n\n clean() {\n return this.client.run(this._clean)\n }\n}\n\nclass Pure {\n private _extractCreator = new Transform.Pure.ExtractCreator()\n private _clean = new Transform.Pure.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extractCreator(options?: Transform.Pure.ExtractCreatorConfig) {\n return this.client.run(this._extractCreator, options)\n }\n\n clean(options?: Transform.Pure.CleanConfig) {\n return this.client.run(this._clean, options)\n }\n}\n\nclass Interlude {\n private _insert = new Transform.Interlude.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Interlude.InsertConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Space {\n private _insert = new Transform.Space.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Space.SpaceConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Stress {\n private _mark = new Transform.Stress.Mark()\n\n constructor(private client: ParserPipeline) {}\n\n mark(options?: Transform.Stress.MarkConfig) {\n return this.client.run(this._mark, options)\n }\n}\n\nclass Language {\n private _infer = new Transform.Language.Infer()\n private _calculatePercent = new Transform.Language.CalculatePercent()\n\n constructor(private client: ParserPipeline) {}\n\n infer(options?: Transform.Language.InferConfig) {\n return this.client.run(this._infer, options)\n }\n\n calculatePercent(options?: Transform.Language.CalculateConfig) {\n return this.client.run(this._calculatePercent, options)\n }\n}\n\nexport class ParserPipeline {\n private context: ParserContext\n private format: string\n private input: ParserPipelineInput\n private done: boolean\n\n readonly agent: Agent\n readonly background: Background\n readonly pure: Pure\n readonly interlude: Interlude\n readonly space: Space\n readonly stress: Stress\n readonly language: Language\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 this.agent = new Agent(this)\n this.background = new Background(this)\n this.pure = new Pure(this)\n this.interlude = new Interlude(this)\n this.space = new Space(this)\n this.stress = new Stress(this)\n this.language = new Language(this)\n }\n\n private applyConfig(plugin: ParserPlugin, options?: any) {\n if (!plugin.config) {\n return\n }\n\n // reset to defaults and apply this run's options in a single update.\n plugin.config.apply(options)\n }\n\n private exec(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 /**\n * Apply optional config to a plugin and execute it against the current context.\n * Intended for use by the pipeline plugin scopes.\n */\n run(plugin: ParserPlugin, options?: any): this {\n this.applyConfig(plugin, options)\n this.exec(plugin)\n return this\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 this.context.finalizeAnnotation()\n\n return this\n }\n\n final(): ParserPipelineResult {\n if (!this.done) {\n this.context.cleanWord()\n this.context.finalizeAnnotation()\n this.context.syncLineTimeWithWord()\n this.context.sort()\n this.context.calcAgentIndex()\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","Agent","client","Transform.Agent","options","Background","Transform.Background","Pure","Transform.Pure","Interlude","Transform.Interlude","Space","Transform.Space","Stress","Transform.Stress","Language","Transform.Language","ParserPipeline","input","init","Lyric","ParserContext","plugin","parser","item","createParserPipeline"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;8CAkBMA,IAAiB,CAAC,IAAIC,EAAW,UAAU,IAAIC,EAAY,cAAc,IAAIA,EAAY,cAAc;AAE7G,MAAMC,EAAM;AAAA,EAGV,YAAoBC,GAAwB;AAAxB,SAAA,SAAAA;AAAA,EAAyB;AAAA,EAFrC,WAAW,IAAIC,EAAgB,QA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ACT;AAAA,EAEA,QAA8B;AAC5B,WAAK,KAAK,SACR,KAAK,QAAQ,UAAA,GACb,KAAK,QAAQ,mBAAA,GACb,KAAK,QAAQ,qBAAA,GACb,KAAK,QAAQ,KAAA,GACb,KAAK,QAAQ,eAAA,GACb,KAAK,QAAQ,2BAAA,GACb,KAAK,OAAO,KAGP;AAAA,MACL,QAAQ,KAAK;AAAA,MACb,QAAQ,KAAK,QAAQ;AAAA,IAAA;AAAA,EAEzB;AACF;AAEO,MAAME,IAAuB,CAACP,MAC5B,IAAID,EAAeC,CAAK;"}
|
|
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(), new Format.Ttml.ItunesParser()]\n\nclass Agent {\n private _extract = new Transform.Agent.Extract()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Agent.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n}\n\nclass Background {\n private _extract = new Transform.Background.Extract()\n private _clean = new Transform.Background.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extract(options?: Transform.Background.ExtractConfig) {\n return this.client.run(this._extract, options)\n }\n\n clean() {\n return this.client.run(this._clean)\n }\n}\n\nclass Pure {\n private _extractCreator = new Transform.Pure.ExtractCreator()\n private _clean = new Transform.Pure.Clean()\n\n constructor(private client: ParserPipeline) {}\n\n extractCreator(options?: Transform.Pure.ExtractCreatorConfig) {\n return this.client.run(this._extractCreator, options)\n }\n\n clean(options?: Transform.Pure.CleanConfig) {\n return this.client.run(this._clean, options)\n }\n}\n\nclass Interlude {\n private _insert = new Transform.Interlude.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Interlude.InsertConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Space {\n private _insert = new Transform.Space.Insert()\n\n constructor(private client: ParserPipeline) {}\n\n insert(options?: Transform.Space.SpaceConfig) {\n return this.client.run(this._insert, options)\n }\n}\n\nclass Stress {\n private _mark = new Transform.Stress.Mark()\n\n constructor(private client: ParserPipeline) {}\n\n mark(options?: Transform.Stress.MarkConfig) {\n return this.client.run(this._mark, options)\n }\n}\n\nclass Language {\n private _infer = new Transform.Language.Infer()\n private _calculatePercent = new Transform.Language.CalculatePercent()\n\n constructor(private client: ParserPipeline) {}\n\n infer(options?: Transform.Language.InferConfig) {\n return this.client.run(this._infer, options)\n }\n\n calculatePercent(options?: Transform.Language.CalculateConfig) {\n return this.client.run(this._calculatePercent, options)\n }\n}\n\nexport class ParserPipeline {\n private context: ParserContext\n private format: string\n private input: ParserPipelineInput\n private done: boolean\n\n readonly agent: Agent\n readonly background: Background\n readonly pure: Pure\n readonly interlude: Interlude\n readonly space: Space\n readonly stress: Stress\n readonly language: Language\n\n constructor(input: ParserPipelineInput) {\n this.done = false\n this.input = input\n this.format = this.input.format || ''\n\n const init = Lyric.makeInfo({ type: Lyric.InfoType.INVALID, timing: Lyric.InfoTiming.NONE })\n this.context = new ParserContext({ content: this.input.content, musicInfo: this.input.musicInfo }, init)\n\n this.agent = new Agent(this)\n this.background = new Background(this)\n this.pure = new Pure(this)\n this.interlude = new Interlude(this)\n this.space = new Space(this)\n this.stress = new Stress(this)\n this.language = new Language(this)\n }\n\n private applyConfig(plugin: ParserPlugin, options?: any) {\n if (!plugin.config) {\n return\n }\n\n // reset to defaults and apply this run's options in a single update.\n plugin.config.apply(options)\n }\n\n private exec(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 /**\n * Apply optional config to a plugin and execute it against the current context.\n * Intended for use by the pipeline plugin scopes.\n */\n run(plugin: ParserPlugin, options?: any): this {\n this.applyConfig(plugin, options)\n this.exec(plugin)\n return this\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 this.context.finalizeAnnotation()\n\n return this\n }\n\n final(): ParserPipelineResult {\n if (!this.done) {\n this.context.cleanWord()\n this.context.finalizeAnnotation()\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","Agent","client","Transform.Agent","options","Background","Transform.Background","Pure","Transform.Pure","Interlude","Transform.Interlude","Space","Transform.Space","Stress","Transform.Stress","Language","Transform.Language","ParserPipeline","input","init","Lyric","ParserContext","plugin","parser","item","createParserPipeline"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;8CAkBMA,IAAiB,CAAC,IAAIC,EAAW,UAAU,IAAIC,EAAY,cAAc,IAAIA,EAAY,cAAc;AAE7G,MAAMC,EAAM;AAAA,EAGV,YAAoBC,GAAwB;A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,GAAQ;AACf,cAAQ,KAAK,yBAAyBA,EAAO,EAAE,QAAQ,GAAG,OAAO,EAAE;AAAA,IACrE;AAEA,gBAAK,QAAQ,mBAAA,GAEN;AAAA,EACT;AAAA,EAEA,QAA8B;AAC5B,WAAK,KAAK,SACR,KAAK,QAAQ,UAAA,GACb,KAAK,QAAQ,mBAAA,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,MAAME,IAAuB,CAACP,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.15.0",
|
|
4
4
|
"author": "folltoshe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Music Lyric Kit",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@music-lyric-kit/core": "0.
|
|
38
|
-
"@music-lyric-kit/plugin-format-lrc": "0.
|
|
39
|
-
"@music-lyric-kit/
|
|
40
|
-
"@music-lyric-kit/
|
|
41
|
-
"@music-lyric-kit/
|
|
42
|
-
"@music-lyric-kit/plugin-transform-
|
|
43
|
-
"@music-lyric-kit/
|
|
44
|
-
"@music-lyric-kit/plugin-transform-
|
|
45
|
-
"@music-lyric-kit/plugin-transform-
|
|
46
|
-
"@music-lyric-kit/plugin-transform-agent": "0.
|
|
47
|
-
"@music-lyric-kit/plugin-transform-
|
|
48
|
-
"@music-lyric-kit/plugin-transform-
|
|
37
|
+
"@music-lyric-kit/core": "0.15.0",
|
|
38
|
+
"@music-lyric-kit/plugin-format-lrc": "0.15.0",
|
|
39
|
+
"@music-lyric-kit/plugin-format-ttml": "0.15.0",
|
|
40
|
+
"@music-lyric-kit/utils": "0.15.0",
|
|
41
|
+
"@music-lyric-kit/lyric": "0.15.0",
|
|
42
|
+
"@music-lyric-kit/plugin-transform-interlude": "0.15.0",
|
|
43
|
+
"@music-lyric-kit/plugin-transform-background": "0.15.0",
|
|
44
|
+
"@music-lyric-kit/plugin-transform-pure": "0.15.0",
|
|
45
|
+
"@music-lyric-kit/plugin-transform-space": "0.15.0",
|
|
46
|
+
"@music-lyric-kit/plugin-transform-agent": "0.15.0",
|
|
47
|
+
"@music-lyric-kit/plugin-transform-stress": "0.15.0",
|
|
48
|
+
"@music-lyric-kit/plugin-transform-language": "0.15.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "vite build"
|