@music-lyric-kit/plugin-transform-interlude 0.1.0 → 0.2.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.map +1 -1
- package/dist/index.ecma.d.ts +16 -16
- package/dist/index.ecma.js.map +1 -1
- package/package.json +4 -4
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 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,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,19 @@ 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 id(): string;
|
|
34
|
+
get name(): string;
|
|
35
|
+
get stage(): ParserStage;
|
|
36
|
+
check(ctx: ParserContext): boolean;
|
|
37
|
+
exec(ctx: ParserContext): void;
|
|
38
|
+
}
|
|
39
|
+
export { Plugin_2 as Plugin }
|
|
40
|
+
|
|
41
41
|
export { }
|
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 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,KAAK;AAChB,WAAO;AAAA,EACT;AAAA,EAEA,IAAa,OAAO;AAClB,WAAO;AAAA,EACT;AAAA,EAEA,IAAa,QAAQ;AACnB,WAAOI,EAAY;AAAA,EACrB;AAAA,EAES,MAAMC,GAAoB;AACjC,WAAO;AAAA,EACT;AAAA,EAES,KAAKA,GAAoB;AAChC,UAAMC,IAAQD,EAAI,OAAO,OACnBE,IAASD,EAAM;AAErB,QAAI,CAACC;AACH;AAGF,UAAM,EAAE,OAAOC,GAAgB,QAAQC,MAAoB,KAAK,OAAO,QAAQ,WAEzEC,IAAmB,CAAA,GAEnBC,IAAYL,EAAM,CAAC;AACzB,QAAIK,EAAU,KAAK,QAAQH,GAAgB;AAEzC,YAAMI,IAAMD,EAAU,KAAK;AAC3B,UAAIC,IAAM,KAAO;AACf,cAAMC,IAAY,IAAIC,EAAA;AACtB,QAAAD,EAAU,KAAK,QAAQ,KACvBA,EAAU,KAAK,MAAMD,GACrBF,EAAS,KAAKG,CAAS;AAAA,MACzB;AAAA,IACF;AAEA,aAASE,IAAI,GAAGA,IAAIR,IAAS,GAAGQ,KAAK;AACnC,YAAMC,IAAUV,EAAMS,CAAC,GACjBE,IAAOX,EAAMS,IAAI,CAAC;AAExB,MAAAL,EAAS,KAAKM,CAAO;AAErB,YAAME,IAAQF,EAAQ,KAAK,MAAM;AAGjC,UAFiBC,EAAK,KAAK,QAAQC,IAEpBT,GAAiB;AAC9B,cAAMI,IAAY,IAAIC,EAAA;AACtB,QAAAD,EAAU,KAAK,QAAQK,GACvBL,EAAU,KAAK,MAAMI,EAAK,KAAK,OAC/BP,EAAS,KAAKG,CAAS;AAAA,MACzB;AAAA,IACF;AAEA,IAAAH,EAAS,KAAKJ,EAAMC,IAAS,CAAC,CAAC,GAE/BF,EAAI,OAAO,QAAQK;AAAA,EACrB;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@music-lyric-kit/plugin-transform-interlude",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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.
|
|
32
|
-
"@music-lyric-kit/lyric": "0.2.
|
|
33
|
-
"@music-lyric-kit/utils": "0.
|
|
31
|
+
"@music-lyric-kit/core": "0.3.1",
|
|
32
|
+
"@music-lyric-kit/lyric": "0.2.1",
|
|
33
|
+
"@music-lyric-kit/utils": "0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "vite build"
|