@music-lyric-kit/plugin-transform-interlude 0.1.0 → 0.3.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 +17 -16
- package/dist/index.ecma.js +8 -5
- package/dist/index.ecma.js.map +1 -1
- package/package.json +4 -4
package/dist/index.comm.js
CHANGED
|
@@ -1,2 +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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@music-lyric-kit/utils"),l=require("@music-lyric-kit/core"),g=require("@music-lyric-kit/lyric"),h={checkTime:{first:5e3,normal:1e4}};class T extends l.ParserPlugin{config=new f.ConfigManager(h);get priority(){return 500}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:m,normal:d}=this.config.current.checkTime,r=[],u=e[0];if(u.time.start>m){const s=u.time.start;if(s>500){const t=new g.LineInterlude;t.time.start=500,t.time.end=s,r.push(t)}}for(let n=0;n<o-1;n++){const s=e[n],t=e[n+1];r.push(s);const a=s.time.end+100;if(t.time.start-a>d){const c=new g.LineInterlude;c.time.start=a,c.time.end=t.time.start,r.push(c)}}r.push(e[o-1]),i.result.lines=r}}exports.Plugin=T;
|
|
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/config.ts","../src/index.ts"],"sourcesContent":["export interface
|
|
1
|
+
{"version":3,"file":"index.comm.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["export interface InterludeConfig {\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: InterludeConfig = {\n checkTime: {\n first: 5000,\n normal: 10000,\n },\n}\n","import type { DeepPartial } from '@music-lyric-kit/utils'\nimport type { InterludeConfig } 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<InterludeConfig, DeepPartial<InterludeConfig>>(DEFAULT_CONFIG)\n\n override get priority() {\n return 500\n }\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 { InterludeConfig }\n"],"names":["DEFAULT_CONFIG","Plugin","ParserPlugin","ConfigManager","ParserStage","ctx","lines","length","firstThreshold","normalThreshold","newLines","firstLine","end","interlude","LineInterlude","i","current","next","start"],"mappings":"iMAoBaA,EAAkC,CAC7C,UAAW,CACT,MAAO,IACP,OAAQ,GAAA,CAEZ,EChBO,MAAMC,UAAeC,EAAAA,YAAa,CAC9B,OAAS,IAAIC,EAAAA,cAA6DH,CAAc,EAEjG,IAAa,UAAW,CACtB,MAAO,IACT,CAEA,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"}
|
package/dist/index.ecma.d.ts
CHANGED
|
@@ -3,22 +3,7 @@ import { ParserContext } from '@music-lyric-kit/core';
|
|
|
3
3
|
import { ParserPlugin } from '@music-lyric-kit/core';
|
|
4
4
|
import { ParserStage } from '@music-lyric-kit/core';
|
|
5
5
|
|
|
6
|
-
declare
|
|
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 {
|
|
6
|
+
export declare interface InterludeConfig {
|
|
22
7
|
/**
|
|
23
8
|
* If these conditions are met, add an interlude.
|
|
24
9
|
*/
|
|
@@ -38,4 +23,20 @@ export declare interface TransformInterludeConfig {
|
|
|
38
23
|
};
|
|
39
24
|
}
|
|
40
25
|
|
|
26
|
+
declare class Plugin_2 extends ParserPlugin {
|
|
27
|
+
config: ConfigManager<InterludeConfig, {
|
|
28
|
+
checkTime?: {
|
|
29
|
+
first?: number | undefined;
|
|
30
|
+
normal?: number | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
get priority(): number;
|
|
34
|
+
get id(): string;
|
|
35
|
+
get name(): string;
|
|
36
|
+
get stage(): ParserStage;
|
|
37
|
+
check(ctx: ParserContext): boolean;
|
|
38
|
+
exec(ctx: ParserContext): void;
|
|
39
|
+
}
|
|
40
|
+
export { Plugin_2 as Plugin }
|
|
41
|
+
|
|
41
42
|
export { }
|
package/dist/index.ecma.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigManager as
|
|
2
|
-
import { ParserPlugin as
|
|
1
|
+
import { ConfigManager as g } from "@music-lyric-kit/utils";
|
|
2
|
+
import { ParserPlugin as h, ParserStage as d } from "@music-lyric-kit/core";
|
|
3
3
|
import { LineInterlude as u } from "@music-lyric-kit/lyric";
|
|
4
4
|
const T = {
|
|
5
5
|
checkTime: {
|
|
@@ -7,8 +7,11 @@ const T = {
|
|
|
7
7
|
normal: 1e4
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
class w extends
|
|
11
|
-
config = new
|
|
10
|
+
class w extends h {
|
|
11
|
+
config = new g(T);
|
|
12
|
+
get priority() {
|
|
13
|
+
return 500;
|
|
14
|
+
}
|
|
12
15
|
get id() {
|
|
13
16
|
return "TRANSFORM-INTERLUDE";
|
|
14
17
|
}
|
|
@@ -16,7 +19,7 @@ class w extends d {
|
|
|
16
19
|
return "TRANSFORM-INTERLUDE";
|
|
17
20
|
}
|
|
18
21
|
get stage() {
|
|
19
|
-
return
|
|
22
|
+
return d.Transform;
|
|
20
23
|
}
|
|
21
24
|
check(i) {
|
|
22
25
|
return !0;
|
package/dist/index.ecma.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.ecma.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["export interface
|
|
1
|
+
{"version":3,"file":"index.ecma.js","sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["export interface InterludeConfig {\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: InterludeConfig = {\n checkTime: {\n first: 5000,\n normal: 10000,\n },\n}\n","import type { DeepPartial } from '@music-lyric-kit/utils'\nimport type { InterludeConfig } 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<InterludeConfig, DeepPartial<InterludeConfig>>(DEFAULT_CONFIG)\n\n override get priority() {\n return 500\n }\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 { InterludeConfig }\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,IAAkC;AAAA,EAC7C,WAAW;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EAAA;AAEZ;AChBO,MAAMC,UAAeC,EAAa;AAAA,EAC9B,SAAS,IAAIC,EAA6DH,CAAc;AAAA,EAEjG,IAAa,WAAW;A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
2
2
|
"name": "@music-lyric-kit/plugin-transform-interlude",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "folltoshe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Music Lyric Kit - Transform Interlude Plugin",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@music-lyric-kit/core": "0.2
|
|
32
|
-
"@music-lyric-kit/lyric": "0.
|
|
33
|
-
"@music-lyric-kit/utils": "0.
|
|
31
|
+
"@music-lyric-kit/core": "0.3.2",
|
|
32
|
+
"@music-lyric-kit/lyric": "0.3.0",
|
|
33
|
+
"@music-lyric-kit/utils": "0.4.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "vite build"
|