music-lyric-kit 0.14.0 → 0.14.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@music-lyric-kit/lyric"),x=require("@music-lyric-kit/plugin-format-lrc"),P=require("@music-lyric-kit/plugin-format-ttml"),w=require("@music-lyric-kit/plugin-transform-interlude"),b=require("@music-lyric-kit/plugin-transform-background"),y=require("@music-lyric-kit/plugin-transform-agent"),T=require("@music-lyric-kit/plugin-transform-space"),k=require("@music-lyric-kit/plugin-transform-pure"),S=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 u=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,u.get?u:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const f=n(x),i=n(P),m=n(w),c=n(b),g=n(y),p=n(T),a=n(k),d=n(S),o=n(O),j=Object.freeze(Object.defineProperty({__proto__:null,Lrc:f,Ttml:i},Symbol.toStringTag,{value:"Module"})),C=Object.freeze(Object.defineProperty({__proto__:null,Agent:g,Background:c,Interlude:m,Language:o,Pure:a,Space:p,Stress:d},Symbol.toStringTag,{value:"Module"})),l=[new f.Parser,new i.AmllParser,new i.ItunesParser];class I{constructor(e){this.client=e}_extract=new g.Extract;extract(e){return this.client.run(this._extract,e)}}class L{constructor(e){this.client=e}_extract=new c.Extract;_clean=new c.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 a.ExtractCreator;_clean=new a.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 p.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 F{constructor(e){this.client=e}_infer=new o.Infer;_calculatePercent=new o.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=new h.Lyric.Info;this.context=new s.ParserContext({content:this.input.content,musicInfo:this.input.musicInfo},t),this.agent=new I(this),this.background=new L(this),this.pure=new q(this),this.interlude=new A(this),this.space=new $(this),this.stress=new B(this),this.language=new F(this)}applyConfig(e,t){e.config&&(e.config.reset(),t&&e.config.update(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 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.context.finalizeAnnotation(),this}final(){return this.done||(this.context.cleanWord(),this.context.finalizeAnnotation(),this.context.syncLineTimeWithWord(),this.context.sort(),this.context.calcAgentIndex(),this.context.syncLineTimeWithBackground(),this.done=!0),{format:this.format,result:this.context.result}}}const z=r=>new _(r);Object.defineProperty(exports,"Lyric",{enumerable:!0,get:()=>h.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=j;exports.ParserPipeline=_;exports.Transform=C;exports.createParserPipeline=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@music-lyric-kit/lyric"),x=require("@music-lyric-kit/plugin-format-lrc"),P=require("@music-lyric-kit/plugin-format-ttml"),w=require("@music-lyric-kit/plugin-transform-interlude"),b=require("@music-lyric-kit/plugin-transform-background"),y=require("@music-lyric-kit/plugin-transform-agent"),T=require("@music-lyric-kit/plugin-transform-space"),k=require("@music-lyric-kit/plugin-transform-pure"),S=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 u=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,u.get?u:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const f=n(x),i=n(P),m=n(w),c=n(b),p=n(y),g=n(T),a=n(k),d=n(S),o=n(O),j=Object.freeze(Object.defineProperty({__proto__:null,Lrc:f,Ttml:i},Symbol.toStringTag,{value:"Module"})),C=Object.freeze(Object.defineProperty({__proto__:null,Agent:p,Background:c,Interlude:m,Language:o,Pure:a,Space:g,Stress:d},Symbol.toStringTag,{value:"Module"})),l=[new f.Parser,new i.AmllParser,new i.ItunesParser];class I{constructor(e){this.client=e}_extract=new p.Extract;extract(e){return this.client.run(this._extract,e)}}class L{constructor(e){this.client=e}_extract=new c.Extract;_clean=new c.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 a.ExtractCreator;_clean=new a.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 F{constructor(e){this.client=e}_infer=new o.Infer;_calculatePercent=new o.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=new h.Lyric.Info;this.context=new s.ParserContext({content:this.input.content,musicInfo:this.input.musicInfo},t),this.agent=new I(this),this.background=new L(this),this.pure=new q(this),this.interlude=new A(this),this.space=new $(this),this.stress=new B(this),this.language=new F(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 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.context.finalizeAnnotation(),this}final(){return this.done||(this.context.cleanWord(),this.context.finalizeAnnotation(),this.context.syncLineTimeWithWord(),this.context.sort(),this.context.calcAgentIndex(),this.context.syncLineTimeWithBackground(),this.done=!0),{format:this.format,result:this.context.result}}}const z=r=>new _(r);Object.defineProperty(exports,"Lyric",{enumerable:!0,get:()=>h.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=j;exports.ParserPipeline=_;exports.Transform=C;exports.createParserPipeline=z;
2
2
  //# sourceMappingURL=index.comm.js.map
@@ -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 = 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 config first\n plugin.config.reset()\n\n if (options) {\n plugin.config.update(options)\n }\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","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,EAAq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AUxB,EACnB,GAAI,CAEF,GADewB,EAAO,MAAM,KAAK,OAAO,EAC5B,CACV,KAAK,OAASA,EAAO,OACrB,KACF,CACF,MAAQ,CACN,QACF,CAEF,OAAO,IACT,CAEA,OAAc,CACZ,GAAI,CAAC,KAAK,OACR,MAAM,IAAI,MAAM,mDAAmD,EAGrE,MAAME,EAAS1B,EAAe,KAAM2B,GAASA,EAAK,SAAW,KAAK,MAAM,EACxE,GAAI,CAACD,EACH,MAAM,IAAI,MAAM,6BAA6B,KAAK,MAAM,GAAG,EAG7D,KAAK,KAAO,GAEZ,GAAI,CACFA,EAAO,KAAK,KAAK,OAAO,CAC1B,OAASD,EAAQ,CACf,QAAQ,KAAK,yBAAyBC,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,eAAA,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"}
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 = 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","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,KAAA,OAAAA,CAAyB,CAFrC,QAAU,IAAIQ,EAAoB,OAI1C,OAAON,EAA4C,CACjD,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K,QAAQ,mBAAA,EACb,KAAK,QAAQ,qBAAA,EACb,KAAK,QAAQ,KAAA,EACb,KAAK,QAAQ,eAAA,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"}
@@ -87,7 +87,7 @@ class P {
87
87
  return this.client.run(this._mark, t);
88
88
  }
89
89
  }
90
- class k {
90
+ class y {
91
91
  constructor(t) {
92
92
  this.client = t;
93
93
  }
@@ -100,7 +100,7 @@ class k {
100
100
  return this.client.run(this._calculatePercent, t);
101
101
  }
102
102
  }
103
- class y {
103
+ class k {
104
104
  context;
105
105
  format;
106
106
  input;
@@ -115,10 +115,10 @@ class y {
115
115
  constructor(t) {
116
116
  this.done = !1, this.input = t, this.format = this.input.format || "";
117
117
  const e = new m.Info();
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 k(this);
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) {
121
- t.config && (t.config.reset(), e && t.config.update(e));
121
+ t.config && t.config.apply(e);
122
122
  }
123
123
  exec(t) {
124
124
  this.done = !1;
@@ -177,7 +177,7 @@ class y {
177
177
  };
178
178
  }
179
179
  }
180
- const S = (r) => new y(r);
180
+ const S = (r) => new k(r);
181
181
  export {
182
182
  I as Format,
183
183
  E as Generator,
@@ -185,7 +185,7 @@ export {
185
185
  $ as Lyric,
186
186
  z as Parser,
187
187
  F as ParserContext,
188
- y as ParserPipeline,
188
+ k as ParserPipeline,
189
189
  b as Transform,
190
190
  S as createParserPipeline
191
191
  };
@@ -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 config first\n plugin.config.reset()\n\n if (options) {\n plugin.config.update(options)\n }\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,QAAA;AAAA,EAIvC,QAAQC,GAAyC;AAC/C,WAAO,KAAK,OAAO,IAAI,KAAK,UAAUA,CAAO;AAAA,EAC/C;AACF;AAEA,MAAMC,EAAW;AAAA,EAIf,YAAoBH,GAAwB;AAAxB,SAAA,SAAAA;AAAA,EAAyB;AAAA,EAHrC,WAAW,IAAII,EAAqB,QAAA;AAAA,EACpC,SAAS,IAAIA,EAAqB,MAAA;AAAA,EAI1C,QAAQF,GAA8C;AACpD,WA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,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 = 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,QAAA;AAAA,EAIvC,QAAQC,GAAyC;AAC/C,WAAO,KAAK,OAAO,IAAI,KAAK,UAAUA,CAAO;AAAA,EAC/C;AACF;AAEA,MAAMC,EAAW;AAAA,EAIf,YAAoBH,GAAwB;AAAxB,SAAA,SAAAA;AAAA,EAAyB;AAAA,EAHrC,WAAW,IAAII,EAAqB,QAAA;AAAA,EAC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Q,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.14.0",
3
+ "version": "0.14.1",
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.14.0",
38
- "@music-lyric-kit/lyric": "0.14.0",
39
- "@music-lyric-kit/utils": "0.14.0",
40
- "@music-lyric-kit/plugin-format-ttml": "0.14.0",
41
- "@music-lyric-kit/plugin-format-lrc": "0.14.0",
42
- "@music-lyric-kit/plugin-transform-interlude": "0.14.0",
43
- "@music-lyric-kit/plugin-transform-background": "0.14.0",
44
- "@music-lyric-kit/plugin-transform-space": "0.14.0",
45
- "@music-lyric-kit/plugin-transform-agent": "0.14.0",
46
- "@music-lyric-kit/plugin-transform-pure": "0.14.0",
47
- "@music-lyric-kit/plugin-transform-stress": "0.14.0",
48
- "@music-lyric-kit/plugin-transform-language": "0.14.0"
37
+ "@music-lyric-kit/core": "0.14.1",
38
+ "@music-lyric-kit/plugin-format-lrc": "0.14.1",
39
+ "@music-lyric-kit/utils": "0.14.1",
40
+ "@music-lyric-kit/plugin-format-ttml": "0.14.1",
41
+ "@music-lyric-kit/plugin-transform-interlude": "0.14.1",
42
+ "@music-lyric-kit/plugin-transform-background": "0.14.1",
43
+ "@music-lyric-kit/lyric": "0.14.1",
44
+ "@music-lyric-kit/plugin-transform-space": "0.14.1",
45
+ "@music-lyric-kit/plugin-transform-pure": "0.14.1",
46
+ "@music-lyric-kit/plugin-transform-agent": "0.14.1",
47
+ "@music-lyric-kit/plugin-transform-language": "0.14.1",
48
+ "@music-lyric-kit/plugin-transform-stress": "0.14.1"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "vite build"