@music-lyric-kit/plugin-transform-interlude 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 - now, Folltoshe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @music-lyric-kit/plugin-transform-interlude
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @music-lyric-kit/plugin-transform-interlude
7
+ ```
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@music-lyric-kit/utils"),l=require("@music-lyric-kit/core"),m=require("@music-lyric-kit/lyric"),h={checkTime:{first:5e3,normal:1e4}};class T extends l.ParserPlugin{config=new f.ConfigManager(h);get id(){return"TRANSFORM-INTERLUDE"}get name(){return"TRANSFORM-INTERLUDE"}get stage(){return l.ParserStage.Transform}check(i){return!0}exec(i){const e=i.result.lines,o=e.length;if(!o)return;const{first:d,normal:g}=this.config.current.checkTime,n=[],u=e[0];if(u.time.start>d){const s=u.time.start;if(s>500){const t=new m.LineInterlude;t.time.start=500,t.time.end=s,n.push(t)}}for(let r=0;r<o-1;r++){const s=e[r],t=e[r+1];n.push(s);const a=s.time.end+100;if(t.time.start-a>g){const c=new m.LineInterlude;c.time.start=a,c.time.end=t.time.start,n.push(c)}}n.push(e[o-1]),i.result.lines=n}}exports.Plugin=T;
2
+ //# sourceMappingURL=index.comm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.comm.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["export interface TransformInterludeConfig {\n /**\n * If these conditions are met, add an interlude.\n */\n checkTime: {\n /**\n * First line check time.\n * @unit ms\n * @default 5000\n */\n first: number\n /**\n * Normal line check time\n * @unit ms\n * @default 10000\n */\n normal: number\n }\n}\n\nexport const DEFAULT_CONFIG: TransformInterludeConfig = {\n checkTime: {\n first: 5000,\n normal: 10000,\n },\n}\n","import type { DeepPartial } from '@music-lyric-kit/utils'\nimport type { TransformInterludeConfig } from './config'\n\nimport { DEFAULT_CONFIG } from './config'\nimport { ConfigManager } from '@music-lyric-kit/utils'\n\nimport { ParserPlugin, ParserStage, ParserContext } from '@music-lyric-kit/core'\nimport { Line, LineInterlude } from '@music-lyric-kit/lyric'\n\nexport class Plugin extends ParserPlugin {\n override config = new ConfigManager<TransformInterludeConfig, DeepPartial<TransformInterludeConfig>>(DEFAULT_CONFIG)\n\n override get id() {\n return 'TRANSFORM-INTERLUDE'\n }\n\n override get name() {\n return 'TRANSFORM-INTERLUDE'\n }\n\n override get stage() {\n return ParserStage.Transform\n }\n\n override check(ctx: ParserContext) {\n return true\n }\n\n override exec(ctx: ParserContext) {\n const lines = ctx.result.lines\n const length = lines.length\n\n if (!length) {\n return\n }\n\n const { first: firstThreshold, normal: normalThreshold } = this.config.current.checkTime\n\n const newLines: Line[] = []\n\n const firstLine = lines[0]\n if (firstLine.time.start > firstThreshold) {\n const start = 500\n const end = firstLine.time.start\n if (end > start) {\n const interlude = new LineInterlude()\n interlude.time.start = start\n interlude.time.end = end\n newLines.push(interlude)\n }\n }\n\n for (let i = 0; i < length - 1; i++) {\n const current = lines[i]\n const next = lines[i + 1]\n\n newLines.push(current)\n\n const start = current.time.end + 100\n const duration = next.time.start - start\n\n if (duration > normalThreshold) {\n const interlude = new LineInterlude()\n interlude.time.start = start\n interlude.time.end = next.time.start\n newLines.push(interlude)\n }\n }\n\n newLines.push(lines[length - 1])\n\n ctx.result.lines = newLines\n }\n}\n\nexport type { TransformInterludeConfig }\n"],"names":["DEFAULT_CONFIG","Plugin","ParserPlugin","ConfigManager","ParserStage","ctx","lines","length","firstThreshold","normalThreshold","newLines","firstLine","end","interlude","LineInterlude","i","current","next","start"],"mappings":"iMAoBaA,EAA2C,CACtD,UAAW,CACT,MAAO,IACP,OAAQ,GAAA,CAEZ,EChBO,MAAMC,UAAeC,EAAAA,YAAa,CAC9B,OAAS,IAAIC,EAAAA,cAA+EH,CAAc,EAEnH,IAAa,IAAK,CAChB,MAAO,qBACT,CAEA,IAAa,MAAO,CAClB,MAAO,qBACT,CAEA,IAAa,OAAQ,CACnB,OAAOI,EAAAA,YAAY,SACrB,CAES,MAAMC,EAAoB,CACjC,MAAO,EACT,CAES,KAAKA,EAAoB,CAChC,MAAMC,EAAQD,EAAI,OAAO,MACnBE,EAASD,EAAM,OAErB,GAAI,CAACC,EACH,OAGF,KAAM,CAAE,MAAOC,EAAgB,OAAQC,GAAoB,KAAK,OAAO,QAAQ,UAEzEC,EAAmB,CAAA,EAEnBC,EAAYL,EAAM,CAAC,EACzB,GAAIK,EAAU,KAAK,MAAQH,EAAgB,CAEzC,MAAMI,EAAMD,EAAU,KAAK,MAC3B,GAAIC,EAAM,IAAO,CACf,MAAMC,EAAY,IAAIC,gBACtBD,EAAU,KAAK,MAAQ,IACvBA,EAAU,KAAK,IAAMD,EACrBF,EAAS,KAAKG,CAAS,CACzB,CACF,CAEA,QAASE,EAAI,EAAGA,EAAIR,EAAS,EAAGQ,IAAK,CACnC,MAAMC,EAAUV,EAAMS,CAAC,EACjBE,EAAOX,EAAMS,EAAI,CAAC,EAExBL,EAAS,KAAKM,CAAO,EAErB,MAAME,EAAQF,EAAQ,KAAK,IAAM,IAGjC,GAFiBC,EAAK,KAAK,MAAQC,EAEpBT,EAAiB,CAC9B,MAAMI,EAAY,IAAIC,gBACtBD,EAAU,KAAK,MAAQK,EACvBL,EAAU,KAAK,IAAMI,EAAK,KAAK,MAC/BP,EAAS,KAAKG,CAAS,CACzB,CACF,CAEAH,EAAS,KAAKJ,EAAMC,EAAS,CAAC,CAAC,EAE/BF,EAAI,OAAO,MAAQK,CACrB,CACF"}
@@ -0,0 +1,41 @@
1
+ import { ConfigManager } from '@music-lyric-kit/utils';
2
+ import { ParserContext } from '@music-lyric-kit/core';
3
+ import { ParserPlugin } from '@music-lyric-kit/core';
4
+ import { ParserStage } from '@music-lyric-kit/core';
5
+
6
+ declare class Plugin_2 extends ParserPlugin {
7
+ config: ConfigManager<TransformInterludeConfig, {
8
+ checkTime?: {
9
+ first?: number | undefined;
10
+ normal?: number | undefined;
11
+ } | undefined;
12
+ }>;
13
+ get id(): string;
14
+ get name(): string;
15
+ get stage(): ParserStage;
16
+ check(ctx: ParserContext): boolean;
17
+ exec(ctx: ParserContext): void;
18
+ }
19
+ export { Plugin_2 as Plugin }
20
+
21
+ export declare interface TransformInterludeConfig {
22
+ /**
23
+ * If these conditions are met, add an interlude.
24
+ */
25
+ checkTime: {
26
+ /**
27
+ * First line check time.
28
+ * @unit ms
29
+ * @default 5000
30
+ */
31
+ first: number;
32
+ /**
33
+ * Normal line check time
34
+ * @unit ms
35
+ * @default 10000
36
+ */
37
+ normal: number;
38
+ };
39
+ }
40
+
41
+ export { }
@@ -0,0 +1,51 @@
1
+ import { ConfigManager as h } from "@music-lyric-kit/utils";
2
+ import { ParserPlugin as d, ParserStage as g } from "@music-lyric-kit/core";
3
+ import { LineInterlude as u } from "@music-lyric-kit/lyric";
4
+ const T = {
5
+ checkTime: {
6
+ first: 5e3,
7
+ normal: 1e4
8
+ }
9
+ };
10
+ class w extends d {
11
+ config = new h(T);
12
+ get id() {
13
+ return "TRANSFORM-INTERLUDE";
14
+ }
15
+ get name() {
16
+ return "TRANSFORM-INTERLUDE";
17
+ }
18
+ get stage() {
19
+ return g.Transform;
20
+ }
21
+ check(i) {
22
+ return !0;
23
+ }
24
+ exec(i) {
25
+ const e = i.result.lines, o = e.length;
26
+ if (!o)
27
+ return;
28
+ const { first: l, normal: f } = this.config.current.checkTime, r = [], a = e[0];
29
+ if (a.time.start > l) {
30
+ const s = a.time.start;
31
+ if (s > 500) {
32
+ const t = new u();
33
+ t.time.start = 500, t.time.end = s, r.push(t);
34
+ }
35
+ }
36
+ for (let n = 0; n < o - 1; n++) {
37
+ const s = e[n], t = e[n + 1];
38
+ r.push(s);
39
+ const m = s.time.end + 100;
40
+ if (t.time.start - m > f) {
41
+ const c = new u();
42
+ c.time.start = m, c.time.end = t.time.start, r.push(c);
43
+ }
44
+ }
45
+ r.push(e[o - 1]), i.result.lines = r;
46
+ }
47
+ }
48
+ export {
49
+ w as Plugin
50
+ };
51
+ //# sourceMappingURL=index.ecma.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.ecma.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["export interface TransformInterludeConfig {\n /**\n * If these conditions are met, add an interlude.\n */\n checkTime: {\n /**\n * First line check time.\n * @unit ms\n * @default 5000\n */\n first: number\n /**\n * Normal line check time\n * @unit ms\n * @default 10000\n */\n normal: number\n }\n}\n\nexport const DEFAULT_CONFIG: TransformInterludeConfig = {\n checkTime: {\n first: 5000,\n normal: 10000,\n },\n}\n","import type { DeepPartial } from '@music-lyric-kit/utils'\nimport type { TransformInterludeConfig } from './config'\n\nimport { DEFAULT_CONFIG } from './config'\nimport { ConfigManager } from '@music-lyric-kit/utils'\n\nimport { ParserPlugin, ParserStage, ParserContext } from '@music-lyric-kit/core'\nimport { Line, LineInterlude } from '@music-lyric-kit/lyric'\n\nexport class Plugin extends ParserPlugin {\n override config = new ConfigManager<TransformInterludeConfig, DeepPartial<TransformInterludeConfig>>(DEFAULT_CONFIG)\n\n override get id() {\n return 'TRANSFORM-INTERLUDE'\n }\n\n override get name() {\n return 'TRANSFORM-INTERLUDE'\n }\n\n override get stage() {\n return ParserStage.Transform\n }\n\n override check(ctx: ParserContext) {\n return true\n }\n\n override exec(ctx: ParserContext) {\n const lines = ctx.result.lines\n const length = lines.length\n\n if (!length) {\n return\n }\n\n const { first: firstThreshold, normal: normalThreshold } = this.config.current.checkTime\n\n const newLines: Line[] = []\n\n const firstLine = lines[0]\n if (firstLine.time.start > firstThreshold) {\n const start = 500\n const end = firstLine.time.start\n if (end > start) {\n const interlude = new LineInterlude()\n interlude.time.start = start\n interlude.time.end = end\n newLines.push(interlude)\n }\n }\n\n for (let i = 0; i < length - 1; i++) {\n const current = lines[i]\n const next = lines[i + 1]\n\n newLines.push(current)\n\n const start = current.time.end + 100\n const duration = next.time.start - start\n\n if (duration > normalThreshold) {\n const interlude = new LineInterlude()\n interlude.time.start = start\n interlude.time.end = next.time.start\n newLines.push(interlude)\n }\n }\n\n newLines.push(lines[length - 1])\n\n ctx.result.lines = newLines\n }\n}\n\nexport type { TransformInterludeConfig }\n"],"names":["DEFAULT_CONFIG","Plugin","ParserPlugin","ConfigManager","ParserStage","ctx","lines","length","firstThreshold","normalThreshold","newLines","firstLine","end","interlude","LineInterlude","i","current","next","start"],"mappings":";;;AAoBO,MAAMA,IAA2C;AAAA,EACtD,WAAW;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EAAA;AAEZ;AChBO,MAAMC,UAAeC,EAAa;AAAA,EAC9B,SAAS,IAAIC,EAA+EH,CAAc;AAAA,EAEnH,IAAa,KAAK;AAChB,WAAO;AA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"module",
6
+ "description": "Music Lyric Kit - Transform Interlude Plugin",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/music-lyric/music-lyric-kit-node#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/music-lyric/music-lyric-kit-node/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/music-lyric/music-lyric-kit-node.git",
15
+ "directory": "plugins/transform-interlude"
16
+ },
17
+ "main": "./dist/index.comm.js",
18
+ "module": "./dist/index.ecma.js",
19
+ "types": "./dist/index.ecma.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.ecma.d.ts",
23
+ "import": "./dist/index.ecma.js",
24
+ "require": "./dist/index.comm.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "dependencies": {
31
+ "@music-lyric-kit/core": "0.2.0",
32
+ "@music-lyric-kit/lyric": "0.2.0",
33
+ "@music-lyric-kit/utils": "0.2.0"
34
+ },
35
+ "scripts": {
36
+ "build": "vite build"
37
+ }
38
+ }