@applemusic-like-lyrics/vue 0.0.3

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/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # AMLL for Vue
2
+
3
+ AMLL 组件库的 Vue 绑定,你可以通过此库来更加方便地使用 AMLL 歌词组件。
4
+
5
+ 详情可以访问 [Core 核心组件的 README.md](../core/README.md)。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install @applemusic-like-lyrics/vue # 使用 npm
11
+ yarn add @applemusic-like-lyrics/vue # 使用 yarn
12
+ ```
13
+
14
+ ## 使用方式摘要
15
+
16
+ 由于 Vue 组件不方便生成 API 文档,所以还请自行查阅类型定义文件确定用法。
17
+
18
+ (或者参考 React 绑定,二者属性和引用方式完全一致)
19
+
20
+ 一个测试用途的程序可以在 [./src/test.ts](./src/test.ts) 里找到。
21
+
22
+ ```vue
23
+ <tamplate>
24
+ <LyricPlayer enable :lyric-lines="[]" :current-time="0" />
25
+ </tamplate>
26
+
27
+ <script setup lang="ts">
28
+ import { LyricPlayer } from "@applemusic-like-lyrics/vue";
29
+
30
+ </script>
31
+ ```
@@ -0,0 +1,38 @@
1
+ import { BackgroundRender } from "@applemusic-like-lyrics/core";
2
+ declare const _default: import("vue").DefineComponent<{
3
+ albumImageUrl: {
4
+ type: import("vue").PropType<string>;
5
+ };
6
+ fps: {
7
+ type: import("vue").PropType<number>;
8
+ };
9
+ playing: {
10
+ type: import("vue").PropType<boolean>;
11
+ };
12
+ flowSpeed: {
13
+ type: import("vue").PropType<number>;
14
+ };
15
+ renderScale: {
16
+ type: import("vue").PropType<number>;
17
+ };
18
+ }, {
19
+ bgRender: import("vue").Ref<BackgroundRender | undefined>;
20
+ wrapperEl: import("vue").Ref<HTMLDivElement | undefined>;
21
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
22
+ albumImageUrl: {
23
+ type: import("vue").PropType<string>;
24
+ };
25
+ fps: {
26
+ type: import("vue").PropType<number>;
27
+ };
28
+ playing: {
29
+ type: import("vue").PropType<boolean>;
30
+ };
31
+ flowSpeed: {
32
+ type: import("vue").PropType<number>;
33
+ };
34
+ renderScale: {
35
+ type: import("vue").PropType<number>;
36
+ };
37
+ }>>, {}, {}>;
38
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import { LyricPlayer } from "@applemusic-like-lyrics/core";
2
+ declare const _default: import("vue").DefineComponent<{
3
+ enable: {
4
+ type: import("vue").PropType<boolean>;
5
+ };
6
+ alignAnchor: {
7
+ type: import("vue").PropType<number | "top" | "bottom">;
8
+ };
9
+ enableSpring: {
10
+ type: import("vue").PropType<boolean>;
11
+ };
12
+ enableBlur: {
13
+ type: import("vue").PropType<boolean>;
14
+ };
15
+ lyricLines: {
16
+ type: import("vue").PropType<import("@applemusic-like-lyrics/core").LyricLine[]>;
17
+ };
18
+ currentTime: {
19
+ type: import("vue").PropType<number>;
20
+ };
21
+ linePosXSpringParams: {
22
+ type: import("vue").PropType<Partial<import("@applemusic-like-lyrics/core/dist/utils/spring").SpringParams>>;
23
+ };
24
+ linePosYSpringParams: {
25
+ type: import("vue").PropType<Partial<import("@applemusic-like-lyrics/core/dist/utils/spring").SpringParams>>;
26
+ };
27
+ lineScaleSpringParams: {
28
+ type: import("vue").PropType<Partial<import("@applemusic-like-lyrics/core/dist/utils/spring").SpringParams>>;
29
+ };
30
+ }, {
31
+ lyricPlayer: import("vue").Ref<LyricPlayer | undefined>;
32
+ wrapperEl: import("vue").Ref<HTMLDivElement | undefined>;
33
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
34
+ enable: {
35
+ type: import("vue").PropType<boolean>;
36
+ };
37
+ alignAnchor: {
38
+ type: import("vue").PropType<number | "top" | "bottom">;
39
+ };
40
+ enableSpring: {
41
+ type: import("vue").PropType<boolean>;
42
+ };
43
+ enableBlur: {
44
+ type: import("vue").PropType<boolean>;
45
+ };
46
+ lyricLines: {
47
+ type: import("vue").PropType<import("@applemusic-like-lyrics/core").LyricLine[]>;
48
+ };
49
+ currentTime: {
50
+ type: import("vue").PropType<number>;
51
+ };
52
+ linePosXSpringParams: {
53
+ type: import("vue").PropType<Partial<import("@applemusic-like-lyrics/core/dist/utils/spring").SpringParams>>;
54
+ };
55
+ linePosYSpringParams: {
56
+ type: import("vue").PropType<Partial<import("@applemusic-like-lyrics/core/dist/utils/spring").SpringParams>>;
57
+ };
58
+ lineScaleSpringParams: {
59
+ type: import("vue").PropType<Partial<import("@applemusic-like-lyrics/core/dist/utils/spring").SpringParams>>;
60
+ };
61
+ }>>, {}, {}>;
62
+ export default _default;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("vue"),u=require("@applemusic-like-lyrics/core"),m=a.defineComponent({__name:"LyricPlayer",props:{enable:{type:Boolean},alignAnchor:{},enableSpring:{type:Boolean},enableBlur:{type:Boolean},lyricLines:{},currentTime:{},linePosXSpringParams:{},linePosYSpringParams:{},lineScaleSpringParams:{}},setup(c,{expose:s}){const n=c,l=a.ref(),r=a.ref();return a.onMounted(()=>{l.value&&(r.value=new u.LyricPlayer,l.value.appendChild(r.value.getElement()))}),a.onUnmounted(()=>{r.value&&r.value.dispose()}),a.watchEffect(e=>{if(n.enable){let t=!1,i=-1;const o=f=>{var p;t||(i===-1&&(i=f),(p=r.value)==null||p.update(f-i),i=f,requestAnimationFrame(o))};requestAnimationFrame(o),e(()=>{t=!0})}}),a.watchEffect(()=>{var e;n.alignAnchor&&((e=r.value)==null||e.setAlignAnchor(n.alignAnchor))}),a.watchEffect(()=>{var e;n.enableSpring&&((e=r.value)==null||e.setEnableSpring(n.enableSpring))}),a.watchEffect(()=>{var e;n.enableBlur&&((e=r.value)==null||e.setEnableBlur(n.enableBlur))}),a.watchEffect(()=>{var e;n.lyricLines&&((e=r.value)==null||e.setLyricLines(n.lyricLines))}),a.watchEffect(()=>{var e;n.currentTime&&((e=r.value)==null||e.setCurrentTime(n.currentTime))}),a.watchEffect(()=>{var e;n.linePosXSpringParams&&((e=r.value)==null||e.setLinePosXSpringParams(n.linePosXSpringParams))}),a.watchEffect(()=>{var e;n.linePosYSpringParams&&((e=r.value)==null||e.setLinePosYSpringParams(n.linePosYSpringParams))}),a.watchEffect(()=>{var e;n.lineScaleSpringParams&&((e=r.value)==null||e.setLineScaleSpringParams(n.lineScaleSpringParams))}),s({lyricPlayer:r,wrapperEl:l}),(e,t)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"wrapperRef",ref:l},null,512))}}),g=a.defineComponent({__name:"BackgroundRender",props:{albumImageUrl:{},fps:{},playing:{type:Boolean},flowSpeed:{},renderScale:{}},setup(c,{expose:s}){const n=c,l=a.ref(),r=a.ref();return a.onMounted(()=>{if(l.value){r.value=new u.BackgroundRender;const e=r.value.getElement();e.style.width="100%",e.style.height="100%",l.value.appendChild(e)}}),a.onUnmounted(()=>{r.value&&r.value.dispose()}),a.watchEffect(()=>{var e;n.albumImageUrl&&((e=r.value)==null||e.setAlbumImage(n.albumImageUrl))}),a.watchEffect(()=>{var e;n.fps&&((e=r.value)==null||e.setFPS(n.fps))}),a.watchEffect(()=>{var e,t;n.playing?(e=r.value)==null||e.pause():(t=r.value)==null||t.resume()}),a.watchEffect(()=>{var e;n.flowSpeed&&((e=r.value)==null||e.setFlowSpeed(n.flowSpeed))}),a.watchEffect(()=>{var e;n.renderScale&&((e=r.value)==null||e.setRenderScale(n.renderScale))}),s({bgRender:r,wrapperEl:l}),(e,t)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"wrapperRef",ref:l},null,512))}});exports.BackgroundRender=g;exports.LyricPlayer=m;
2
+ //# sourceMappingURL=amll-vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amll-vue.js","sources":["../src/LyricPlayer.vue","../src/BackgroundRender.vue"],"sourcesContent":["<template>\n <div ref=\"wrapperRef\"></div>\n</template>\n\n<script setup lang=\"ts\">\nimport { LyricPlayer } from \"@applemusic-like-lyrics/core\";\nimport { onMounted, onUnmounted, ref, watchEffect } from \"vue\";\nimport type { LyricPlayerProps, LyricPlayerRef } from \".\";\n\nconst props = defineProps<LyricPlayerProps>();\nconst wrapperRef = ref<HTMLDivElement>();\nconst playerRef = ref<LyricPlayer>();\n\nonMounted(() => {\n if (wrapperRef.value) {\n playerRef.value = new LyricPlayer();\n wrapperRef.value.appendChild(playerRef.value.getElement());\n }\n});\n\nonUnmounted(() => {\n if (playerRef.value) {\n playerRef.value.dispose();\n }\n});\n\nwatchEffect((onCleanup) => {\n if (props.enable) {\n let canceled = false;\n let lastTime = -1;\n const onFrame = (time: number) => {\n if (canceled) return;\n if (lastTime === -1) {\n lastTime = time;\n }\n playerRef.value?.update(time - lastTime);\n lastTime = time;\n requestAnimationFrame(onFrame);\n };\n requestAnimationFrame(onFrame);\n onCleanup(() => {\n canceled = true;\n });\n }\n});\n\nwatchEffect(() => {\n if (props.alignAnchor)\n playerRef.value?.setAlignAnchor(props.alignAnchor);\n});\n\nwatchEffect(() => {\n if (props.enableSpring)\n playerRef.value?.setEnableSpring(props.enableSpring);\n});\n\nwatchEffect(() => {\n if (props.enableBlur)\n playerRef.value?.setEnableBlur(props.enableBlur);\n});\n\nwatchEffect(() => {\n if (props.lyricLines)\n playerRef.value?.setLyricLines(props.lyricLines);\n});\n\nwatchEffect(() => {\n if (props.currentTime)\n playerRef.value?.setCurrentTime(props.currentTime);\n});\n\nwatchEffect(() => {\n if (props.linePosXSpringParams)\n playerRef.value?.setLinePosXSpringParams(props.linePosXSpringParams);\n});\n\nwatchEffect(() => {\n if (props.linePosYSpringParams)\n playerRef.value?.setLinePosYSpringParams(props.linePosYSpringParams);\n});\n\nwatchEffect(() => {\n if (props.lineScaleSpringParams)\n playerRef.value?.setLineScaleSpringParams(props.lineScaleSpringParams);\n});\n\ndefineExpose<LyricPlayerRef>({\n lyricPlayer: playerRef,\n wrapperEl: wrapperRef,\n});\n\n</script>","<template>\n <div ref=\"wrapperRef\"></div>\n</template>\n\n<script setup lang=\"ts\">\nimport { BackgroundRender } from \"@applemusic-like-lyrics/core\";\nimport { onMounted, onUnmounted, ref, watchEffect } from \"vue\";\nimport type { BackgroundRenderProps, BackgroundRenderRef } from \".\";\n\nconst props = defineProps<BackgroundRenderProps>();\nconst wrapperRef = ref<HTMLDivElement>();\nconst bgRenderRef = ref<BackgroundRender>();\n\nonMounted(() => {\n if (wrapperRef.value) {\n bgRenderRef.value = new BackgroundRender();\n const el = bgRenderRef.value.getElement();\n el.style.width = \"100%\";\n el.style.height = \"100%\";\n wrapperRef.value.appendChild(el);\n }\n});\n\nonUnmounted(() => {\n if (bgRenderRef.value) {\n bgRenderRef.value.dispose();\n }\n});\n\nwatchEffect(() => {\n if (props.albumImageUrl)\n bgRenderRef.value?.setAlbumImage(props.albumImageUrl);\n});\n\nwatchEffect(() => {\n if (props.fps)\n bgRenderRef.value?.setFPS(props.fps);\n});\n\nwatchEffect(() => {\n if (props.playing)\n bgRenderRef.value?.pause();\n else\n bgRenderRef.value?.resume();\n});\n\nwatchEffect(() => {\n if (props.flowSpeed)\n bgRenderRef.value?.setFlowSpeed(props.flowSpeed);\n});\n\nwatchEffect(() => {\n if (props.renderScale)\n bgRenderRef.value?.setRenderScale(props.renderScale);\n});\n\ndefineExpose<BackgroundRenderRef>({\n bgRender: bgRenderRef,\n wrapperEl: wrapperRef,\n});\n\n</script>"],"names":["wrapperRef","ref","playerRef","onMounted","LyricPlayer","onUnmounted","watchEffect","onCleanup","props","canceled","lastTime","onFrame","time","_a","__expose","bgRenderRef","BackgroundRender","el","_b"],"mappings":"kaAUMA,EAAaC,EAAAA,MACbC,EAAYD,EAAAA,MAElBE,OAAAA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BAAoB,CAC1E,EAEDF,EAAAA,YAAY,IAAM,OACVE,EAAM,yBACIK,EAAAX,EAAA,QAAA,MAAAW,EAAO,yBAAyBL,EAAM,uBAAqB,CAC5E,EAE4BM,EAAA,CACzB,YAAaZ,EACb,UAAWF,CAAA,CACd,8PC/EKA,EAAaC,EAAAA,MACbc,EAAcd,EAAAA,MAEpBE,OAAAA,EAAAA,UAAU,IAAM,CACZ,GAAIH,EAAW,MAAO,CACNe,EAAA,MAAQ,IAAIC,EAAAA,iBAClB,MAAAC,EAAKF,EAAY,MAAM,WAAW,EACxCE,EAAG,MAAM,MAAQ,OACjBA,EAAG,MAAM,OAAS,OACPjB,EAAA,MAAM,YAAYiB,CAAE,CACnC,CAAA,CACH,EAEDZ,EAAAA,YAAY,IAAM,CACVU,EAAY,OACZA,EAAY,MAAM,SACtB,CACH,EAEDT,EAAAA,YAAY,IAAM,OACVE,EAAM,iBACMK,EAAAE,EAAA,QAAA,MAAAF,EAAO,cAAcL,EAAM,eAAa,CAC3D,EAEDF,EAAAA,YAAY,IAAM,OACVE,EAAM,OACMK,EAAAE,EAAA,QAAA,MAAAF,EAAO,OAAOL,EAAM,KAAG,CAC1C,EAEDF,EAAAA,YAAY,IAAM,SACVE,EAAM,SACNK,EAAAE,EAAY,QAAZ,MAAAF,EAAmB,SAEnBK,EAAAH,EAAY,QAAZ,MAAAG,EAAmB,QAAO,CACjC,EAEDZ,EAAAA,YAAY,IAAM,OACVE,EAAM,aACMK,EAAAE,EAAA,QAAA,MAAAF,EAAO,aAAaL,EAAM,WAAS,CACtD,EAEDF,EAAAA,YAAY,IAAM,OACVE,EAAM,eACMK,EAAAE,EAAA,QAAA,MAAAF,EAAO,eAAeL,EAAM,aAAW,CAC1D,EAEiCM,EAAA,CAC9B,SAAUC,EACV,UAAWf,CAAA,CACd"}
@@ -0,0 +1,112 @@
1
+ import { defineComponent as m, ref as p, onMounted as g, onUnmounted as d, watchEffect as n, openBlock as v, createElementBlock as S } from "vue";
2
+ import { LyricPlayer as P, BackgroundRender as y } from "@applemusic-like-lyrics/core";
3
+ const _ = /* @__PURE__ */ m({
4
+ __name: "LyricPlayer",
5
+ props: {
6
+ enable: { type: Boolean },
7
+ alignAnchor: {},
8
+ enableSpring: { type: Boolean },
9
+ enableBlur: { type: Boolean },
10
+ lyricLines: {},
11
+ currentTime: {},
12
+ linePosXSpringParams: {},
13
+ linePosYSpringParams: {},
14
+ lineScaleSpringParams: {}
15
+ },
16
+ setup(t, { expose: o }) {
17
+ const a = t, l = p(), r = p();
18
+ return g(() => {
19
+ l.value && (r.value = new P(), l.value.appendChild(r.value.getElement()));
20
+ }), d(() => {
21
+ r.value && r.value.dispose();
22
+ }), n((e) => {
23
+ if (a.enable) {
24
+ let i = !1, s = -1;
25
+ const c = (u) => {
26
+ var f;
27
+ i || (s === -1 && (s = u), (f = r.value) == null || f.update(u - s), s = u, requestAnimationFrame(c));
28
+ };
29
+ requestAnimationFrame(c), e(() => {
30
+ i = !0;
31
+ });
32
+ }
33
+ }), n(() => {
34
+ var e;
35
+ a.alignAnchor && ((e = r.value) == null || e.setAlignAnchor(a.alignAnchor));
36
+ }), n(() => {
37
+ var e;
38
+ a.enableSpring && ((e = r.value) == null || e.setEnableSpring(a.enableSpring));
39
+ }), n(() => {
40
+ var e;
41
+ a.enableBlur && ((e = r.value) == null || e.setEnableBlur(a.enableBlur));
42
+ }), n(() => {
43
+ var e;
44
+ a.lyricLines && ((e = r.value) == null || e.setLyricLines(a.lyricLines));
45
+ }), n(() => {
46
+ var e;
47
+ a.currentTime && ((e = r.value) == null || e.setCurrentTime(a.currentTime));
48
+ }), n(() => {
49
+ var e;
50
+ a.linePosXSpringParams && ((e = r.value) == null || e.setLinePosXSpringParams(a.linePosXSpringParams));
51
+ }), n(() => {
52
+ var e;
53
+ a.linePosYSpringParams && ((e = r.value) == null || e.setLinePosYSpringParams(a.linePosYSpringParams));
54
+ }), n(() => {
55
+ var e;
56
+ a.lineScaleSpringParams && ((e = r.value) == null || e.setLineScaleSpringParams(a.lineScaleSpringParams));
57
+ }), o({
58
+ lyricPlayer: r,
59
+ wrapperEl: l
60
+ }), (e, i) => (v(), S("div", {
61
+ ref_key: "wrapperRef",
62
+ ref: l
63
+ }, null, 512));
64
+ }
65
+ }), B = /* @__PURE__ */ m({
66
+ __name: "BackgroundRender",
67
+ props: {
68
+ albumImageUrl: {},
69
+ fps: {},
70
+ playing: { type: Boolean },
71
+ flowSpeed: {},
72
+ renderScale: {}
73
+ },
74
+ setup(t, { expose: o }) {
75
+ const a = t, l = p(), r = p();
76
+ return g(() => {
77
+ if (l.value) {
78
+ r.value = new y();
79
+ const e = r.value.getElement();
80
+ e.style.width = "100%", e.style.height = "100%", l.value.appendChild(e);
81
+ }
82
+ }), d(() => {
83
+ r.value && r.value.dispose();
84
+ }), n(() => {
85
+ var e;
86
+ a.albumImageUrl && ((e = r.value) == null || e.setAlbumImage(a.albumImageUrl));
87
+ }), n(() => {
88
+ var e;
89
+ a.fps && ((e = r.value) == null || e.setFPS(a.fps));
90
+ }), n(() => {
91
+ var e, i;
92
+ a.playing ? (e = r.value) == null || e.pause() : (i = r.value) == null || i.resume();
93
+ }), n(() => {
94
+ var e;
95
+ a.flowSpeed && ((e = r.value) == null || e.setFlowSpeed(a.flowSpeed));
96
+ }), n(() => {
97
+ var e;
98
+ a.renderScale && ((e = r.value) == null || e.setRenderScale(a.renderScale));
99
+ }), o({
100
+ bgRender: r,
101
+ wrapperEl: l
102
+ }), (e, i) => (v(), S("div", {
103
+ ref_key: "wrapperRef",
104
+ ref: l
105
+ }, null, 512));
106
+ }
107
+ });
108
+ export {
109
+ B as BackgroundRender,
110
+ _ as LyricPlayer
111
+ };
112
+ //# sourceMappingURL=amll-vue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amll-vue.mjs","sources":["../src/LyricPlayer.vue","../src/BackgroundRender.vue"],"sourcesContent":["<template>\n <div ref=\"wrapperRef\"></div>\n</template>\n\n<script setup lang=\"ts\">\nimport { LyricPlayer } from \"@applemusic-like-lyrics/core\";\nimport { onMounted, onUnmounted, ref, watchEffect } from \"vue\";\nimport type { LyricPlayerProps, LyricPlayerRef } from \".\";\n\nconst props = defineProps<LyricPlayerProps>();\nconst wrapperRef = ref<HTMLDivElement>();\nconst playerRef = ref<LyricPlayer>();\n\nonMounted(() => {\n if (wrapperRef.value) {\n playerRef.value = new LyricPlayer();\n wrapperRef.value.appendChild(playerRef.value.getElement());\n }\n});\n\nonUnmounted(() => {\n if (playerRef.value) {\n playerRef.value.dispose();\n }\n});\n\nwatchEffect((onCleanup) => {\n if (props.enable) {\n let canceled = false;\n let lastTime = -1;\n const onFrame = (time: number) => {\n if (canceled) return;\n if (lastTime === -1) {\n lastTime = time;\n }\n playerRef.value?.update(time - lastTime);\n lastTime = time;\n requestAnimationFrame(onFrame);\n };\n requestAnimationFrame(onFrame);\n onCleanup(() => {\n canceled = true;\n });\n }\n});\n\nwatchEffect(() => {\n if (props.alignAnchor)\n playerRef.value?.setAlignAnchor(props.alignAnchor);\n});\n\nwatchEffect(() => {\n if (props.enableSpring)\n playerRef.value?.setEnableSpring(props.enableSpring);\n});\n\nwatchEffect(() => {\n if (props.enableBlur)\n playerRef.value?.setEnableBlur(props.enableBlur);\n});\n\nwatchEffect(() => {\n if (props.lyricLines)\n playerRef.value?.setLyricLines(props.lyricLines);\n});\n\nwatchEffect(() => {\n if (props.currentTime)\n playerRef.value?.setCurrentTime(props.currentTime);\n});\n\nwatchEffect(() => {\n if (props.linePosXSpringParams)\n playerRef.value?.setLinePosXSpringParams(props.linePosXSpringParams);\n});\n\nwatchEffect(() => {\n if (props.linePosYSpringParams)\n playerRef.value?.setLinePosYSpringParams(props.linePosYSpringParams);\n});\n\nwatchEffect(() => {\n if (props.lineScaleSpringParams)\n playerRef.value?.setLineScaleSpringParams(props.lineScaleSpringParams);\n});\n\ndefineExpose<LyricPlayerRef>({\n lyricPlayer: playerRef,\n wrapperEl: wrapperRef,\n});\n\n</script>","<template>\n <div ref=\"wrapperRef\"></div>\n</template>\n\n<script setup lang=\"ts\">\nimport { BackgroundRender } from \"@applemusic-like-lyrics/core\";\nimport { onMounted, onUnmounted, ref, watchEffect } from \"vue\";\nimport type { BackgroundRenderProps, BackgroundRenderRef } from \".\";\n\nconst props = defineProps<BackgroundRenderProps>();\nconst wrapperRef = ref<HTMLDivElement>();\nconst bgRenderRef = ref<BackgroundRender>();\n\nonMounted(() => {\n if (wrapperRef.value) {\n bgRenderRef.value = new BackgroundRender();\n const el = bgRenderRef.value.getElement();\n el.style.width = \"100%\";\n el.style.height = \"100%\";\n wrapperRef.value.appendChild(el);\n }\n});\n\nonUnmounted(() => {\n if (bgRenderRef.value) {\n bgRenderRef.value.dispose();\n }\n});\n\nwatchEffect(() => {\n if (props.albumImageUrl)\n bgRenderRef.value?.setAlbumImage(props.albumImageUrl);\n});\n\nwatchEffect(() => {\n if (props.fps)\n bgRenderRef.value?.setFPS(props.fps);\n});\n\nwatchEffect(() => {\n if (props.playing)\n bgRenderRef.value?.pause();\n else\n bgRenderRef.value?.resume();\n});\n\nwatchEffect(() => {\n if (props.flowSpeed)\n bgRenderRef.value?.setFlowSpeed(props.flowSpeed);\n});\n\nwatchEffect(() => {\n if (props.renderScale)\n bgRenderRef.value?.setRenderScale(props.renderScale);\n});\n\ndefineExpose<BackgroundRenderRef>({\n bgRender: bgRenderRef,\n wrapperEl: wrapperRef,\n});\n\n</script>"],"names":["wrapperRef","ref","playerRef","onMounted","LyricPlayer","onUnmounted","watchEffect","onCleanup","props","canceled","lastTime","onFrame","time","_a","__expose","bgRenderRef","BackgroundRender","el","_b"],"mappings":";;;;;;;;;;;;;;;;iBAUMA,IAAaC,KACbC,IAAYD;AAElB,WAAAE,EAAU,MAAM;AACZ,MAAIH,EAAW,UACDE,EAAA,QAAQ,IAAIE,KACtBJ,EAAW,MAAM,YAAYE,EAAU,MAAM,YAAY;AAAA,IAC7D,CACH,GAEDG,EAAY,MAAM;AACd,MAAIH,EAAU,SACVA,EAA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core";
2
+ import type { Ref } from "vue";
3
+ import LyricPlayer from "./LyricPlayer.vue";
4
+ import BackgroundRender from "./BackgroundRender.vue";
5
+ export { LyricPlayer, BackgroundRender };
6
+ /**
7
+ * 歌词播放组件的属性
8
+ */
9
+ export interface LyricPlayerProps {
10
+ /**
11
+ * 是否启用歌词播放组件,默认为 `true`,设置为 `true` 将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。
12
+ *
13
+ * 如果不设置该选项,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。
14
+ */
15
+ enable?: boolean;
16
+ /**
17
+ * 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `top`
18
+ *
19
+ * - 设置成 `top` 的话歌词将会向组件顶部对齐
20
+ * - 设置成 `bottom` 的话歌词将会向组件底部对齐
21
+ * - 设置成 [0.0-1.0] 之间任意数字的话则会根据当前组件高度从顶部向下位移为对齐位置垂直居中对齐
22
+ */
23
+ alignAnchor?: "top" | "bottom" | number;
24
+ /**
25
+ * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
26
+ *
27
+ * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行
28
+ *
29
+ * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一
30
+ */
31
+ enableSpring?: boolean;
32
+ /**
33
+ * 设置是否启用歌词行的模糊效果,默认为 `true`
34
+ */
35
+ enableBlur?: boolean;
36
+ /**
37
+ * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误
38
+ */
39
+ lyricLines?: LyricLine[];
40
+ /**
41
+ * 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息
42
+ * 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好
43
+ */
44
+ currentTime?: number;
45
+ /**
46
+ * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
47
+ *
48
+ * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
49
+ */
50
+ linePosXSpringParams?: Partial<spring.SpringParams>;
51
+ /**
52
+ * 设置所有歌词行在​纵坐标上的弹簧属性,包括重量、弹力和阻力。
53
+ *
54
+ * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
55
+ */
56
+ linePosYSpringParams?: Partial<spring.SpringParams>;
57
+ /**
58
+ * 设置所有歌词行在​缩放大小上的弹簧属性,包括重量、弹力和阻力。
59
+ *
60
+ * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
61
+ */
62
+ lineScaleSpringParams?: Partial<spring.SpringParams>;
63
+ }
64
+ /**
65
+ * 歌词播放组件的引用
66
+ */
67
+ export interface LyricPlayerRef {
68
+ /**
69
+ * 歌词播放实例
70
+ */
71
+ lyricPlayer: Ref<CoreLyricPlayer | undefined>;
72
+ /**
73
+ * 将歌词播放实例的元素包裹起来的 DIV 元素实例
74
+ */
75
+ wrapperEl: Ref<HTMLDivElement | undefined>;
76
+ }
77
+ /**
78
+ * 背景渲染组件的属性
79
+ */
80
+ export interface BackgroundRenderProps {
81
+ /**
82
+ * 设置背景专辑图片
83
+ */
84
+ albumImageUrl?: string;
85
+ /**
86
+ * 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`
87
+ */
88
+ fps?: number;
89
+ /**
90
+ * 设置当前播放状态,如果为 `undefined` 则默认为 `true`
91
+ */
92
+ playing?: boolean;
93
+ /**
94
+ * 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`
95
+ */
96
+ flowSpeed?: number;
97
+ /**
98
+ * 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`
99
+ */
100
+ renderScale?: number;
101
+ }
102
+ /**
103
+ * 背景渲染组件的引用
104
+ */
105
+ export interface BackgroundRenderRef {
106
+ /**
107
+ * 背景渲染实例引用
108
+ */
109
+ bgRender?: Ref<CoreBackgroundRender | undefined>;
110
+ /**
111
+ * 将背景渲染实例的元素包裹起来的 DIV 元素实例
112
+ */
113
+ wrapperEl: Ref<HTMLDivElement | undefined>;
114
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@applemusic-like-lyrics/vue",
3
+ "packageManager": "yarn@3.6.1",
4
+ "version": "0.0.3",
5
+ "description": "AMLL 组件库的 Vue 绑定",
6
+ "repository": {
7
+ "url": "https://github.com/Steve-xmh/applemusic-like-lyrics.git",
8
+ "directory": "packages/vue",
9
+ "type": "git"
10
+ },
11
+ "license": "GPL-3.0",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "vite build",
17
+ "fmt": "rome format --write ./src",
18
+ "dev": "vite dev"
19
+ },
20
+ "main": "./dist/amll-vue.cjs",
21
+ "module": "./dist/amll-vue.mjs",
22
+ "typings": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./dist/amll-vue.mjs",
26
+ "require": "./dist/amll-vue.cjs"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@applemusic-like-lyrics/core": "^0.0.3",
31
+ "vue": "^3.3.4"
32
+ },
33
+ "devDependencies": {
34
+ "@vitejs/plugin-vue": "^4.2.3",
35
+ "@vue/tsconfig": "^0.4.0",
36
+ "rome": "^12.1.3",
37
+ "typedoc": "^0.24.8",
38
+ "typedoc-plugin-markdown": "^3.15.3",
39
+ "vite": "^4.4.7",
40
+ "vite-plugin-dts": "^3.3.1"
41
+ }
42
+ }