@applemusic-like-lyrics/react 0.0.9 → 0.0.11
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/amll-react.js +1 -1
- package/dist/amll-react.js.map +1 -1
- package/dist/amll-react.mjs +101 -75
- package/dist/amll-react.mjs.map +1 -1
- package/dist/bg-render.d.ts +6 -1
- package/dist/lyric-player.d.ts +20 -7
- package/package.json +14 -3
package/dist/amll-react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),h=require("@applemusic-like-lyrics/core"),r=require("react"),j=require("react-dom"),g=r.forwardRef(({albumImageUrl:d,fps:i,playing:E,flowSpeed:o,renderScale:a,staticMode:l,...p},m)=>{const c=r.useRef(),f=r.useRef(null);return r.useEffect(()=>(c.current=new h.BackgroundRender,()=>{var t;(t=c.current)==null||t.dispose()}),[]),r.useEffect(()=>{var t;d&&((t=c.current)==null||t.setAlbumImage(d))},[d]),r.useEffect(()=>{var t;i&&((t=c.current)==null||t.setFPS(i))},[i]),r.useEffect(()=>{var t,s,w;E===void 0?(t=c.current)==null||t.resume():E?(s=c.current)==null||s.resume():(w=c.current)==null||w.pause()},[E]),r.useEffect(()=>{var t;o&&((t=c.current)==null||t.setFlowSpeed(o))},[o]),r.useEffect(()=>{var t;(t=c.current)==null||t.setStaticMode(l)},[l]),r.useEffect(()=>{var t;a&&((t=c.current)==null||t.setRenderScale(a))},[a]),r.useEffect(()=>{var t;if(c.current){const s=c.current.getElement();s.style.width="100%",s.style.height="100%",(t=f.current)==null||t.appendChild(s)}}),r.useImperativeHandle(m,()=>({wrapperEl:f.current,bgRender:c.current}),[f.current,c.current]),q.jsx("div",{...p,ref:f})}),x=r.forwardRef(({disabled:d,alignAnchor:i,alignPosition:E,enableSpring:o,enableBlur:a,lyricLines:l,currentTime:p,linePosXSpringParams:m,linePosYSpringParams:c,lineScaleSpringParams:f,bottomLine:t,...s},w)=>{var v,B;const u=r.useRef(),y=r.useRef(null);return r.useEffect(()=>(u.current=new h.LyricPlayer,()=>{var e;(e=u.current)==null||e.dispose()}),[]),r.useEffect(()=>{if(!d){let e=!1,n=-1;const L=R=>{var F;e||(n===-1&&(n=R),(F=u.current)==null||F.update(R-n),n=R,requestAnimationFrame(L))};return requestAnimationFrame(L),()=>{e=!0}}},[d]),r.useEffect(()=>{var e;u.current&&((e=y.current)==null||e.appendChild(u.current.getElement()))},[y.current]),r.useEffect(()=>{var e;i&&((e=u.current)==null||e.setAlignAnchor(i))},[i]),r.useEffect(()=>{var e;E&&((e=u.current)==null||e.setAlignPosition(E))},[E]),r.useEffect(()=>{var e,n;o?(e=u.current)==null||e.setEnableSpring(o):(n=u.current)==null||n.setEnableSpring(!0)},[o]),r.useEffect(()=>{var e;(e=u.current)==null||e.setEnableBlur(a??!0)},[a]),r.useEffect(()=>{var e,n,L,R;l?((e=u.current)==null||e.setLyricLines(l),(n=u.current)==null||n.update()):((L=u.current)==null||L.setLyricLines([]),(R=u.current)==null||R.update())},[l]),r.useEffect(()=>{var e,n;p?(e=u.current)==null||e.setCurrentTime(p):(n=u.current)==null||n.setCurrentTime(0)},[p]),r.useEffect(()=>{var e;m&&((e=u.current)==null||e.setLinePosXSpringParams(m))},[m]),r.useEffect(()=>{var e;c&&((e=u.current)==null||e.setLinePosYSpringParams(c))},[c]),r.useEffect(()=>{var e;f&&((e=u.current)==null||e.setLineScaleSpringParams(f))},[f]),r.useImperativeHandle(w,()=>({wrapperEl:y.current,lyricPlayer:u.current}),[y.current,u.current]),q.jsxs(q.Fragment,{children:[q.jsx("div",{...s,ref:y}),(v=u.current)!=null&&v.getBottomLineElement()&&t?j.createPortal(t,(B=u.current)==null?void 0:B.getBottomLineElement()):null]})});exports.BackgroundRender=g;exports.LyricPlayer=x;
|
|
2
2
|
//# sourceMappingURL=amll-react.js.map
|
package/dist/amll-react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amll-react.js","sources":["../src/bg-render.tsx","../src/lyric-player.tsx"],"sourcesContent":["import { BackgroundRender as CoreBackgroundRender } from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n} from \"react\";\n\n/**\n * 背景渲染组件的属性\n */\nexport interface BackgroundRenderProps {\n\t/**\n\t * 设置背景专辑图片\n\t */\n\talbumImageUrl?: string;\n\t/**\n\t * 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`\n\t */\n\tfps?: number;\n\t/**\n\t * 设置当前播放状态,如果为 `undefined` 则默认为 `true`\n\t */\n\tplaying?: boolean;\n\t/**\n\t * 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`\n\t */\n\tflowSpeed?: number;\n\t/**\n\t * 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`\n\t */\n\trenderScale?: number;\n}\n\n/**\n * 背景渲染组件的引用\n */\nexport interface BackgroundRenderRef {\n\t/**\n\t * 背景渲染实例引用\n\t */\n\tbgRender?: CoreBackgroundRender;\n\t/**\n\t * 将背景渲染实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果\n */\nexport const BackgroundRender = forwardRef<\n\tBackgroundRenderRef,\n\tHTMLProps<HTMLDivElement> & BackgroundRenderProps\n>(({ albumImageUrl, fps, playing, flowSpeed, renderScale, ...props }, ref) => {\n\tconst coreBGRenderRef = useRef<CoreBackgroundRender>();\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\tuseEffect(() => {\n\t\tcoreBGRenderRef.current = new CoreBackgroundRender();\n\t\treturn () => {\n\t\t\tcoreBGRenderRef.current?.dispose();\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (albumImageUrl) coreBGRenderRef.current?.setAlbumImage(albumImageUrl);\n\t}, [albumImageUrl]);\n\n\tuseEffect(() => {\n\t\tif (fps) coreBGRenderRef.current?.setFPS(fps);\n\t}, [fps]);\n\n\tuseEffect(() => {\n\t\tif (playing === undefined) {\n\t\t\tcoreBGRenderRef.current?.resume();\n\t\t} else if (playing) {\n\t\t\tcoreBGRenderRef.current?.resume();\n\t\t} else {\n\t\t\tcoreBGRenderRef.current?.pause();\n\t\t}\n\t}, [playing]);\n\n\tuseEffect(() => {\n\t\tif (flowSpeed) coreBGRenderRef.current?.setFlowSpeed(flowSpeed);\n\t}, [flowSpeed]);\n\n\tuseEffect(() => {\n\t\tif (renderScale) coreBGRenderRef.current?.setRenderScale(renderScale);\n\t}, [renderScale]);\n\n\tuseEffect(() => {\n\t\tif (coreBGRenderRef.current) {\n\t\t\tconst el = coreBGRenderRef.current.getElement();\n\t\t\tel.style.width = \"100%\";\n\t\t\tel.style.height = \"100%\";\n\t\t\twrapperRef.current?.appendChild(el);\n\t\t}\n\t});\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\twrapperEl: wrapperRef.current,\n\t\t\tbgRender: coreBGRenderRef.current,\n\t\t}),\n\t\t[wrapperRef.current, coreBGRenderRef.current],\n\t);\n\n\treturn <div {...props} ref={wrapperRef} />;\n});\n","import {\n\tLyricPlayer as CoreLyricPlayer,\n\ttype LyricLine,\n\ttype spring,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n} from \"react\";\n\n/**\n * 歌词播放组件的属性\n */\nexport interface LyricPlayerProps {\n\t/**\n\t * 是否禁用歌词播放组件,默认为 `false`,歌词组件启用后将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。\n\t *\n\t * 如果禁用了歌词组件动画,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `top`\n\t *\n\t * - 设置成 `top` 的话歌词将会向组件顶部对齐\n\t * - 设置成 `bottom` 的话歌词将会向组件底部对齐\n\t * - 设置成 [0.0-1.0] 之间任意数字的话则会根据当前组件高度从顶部向下位移为对齐位置垂直居中对齐\n\t */\n\talignAnchor?: \"top\" | \"bottom\" | number;\n\t/**\n\t * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用\n\t *\n\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableSpring?: boolean;\n\t/**\n\t * 设置是否启用歌词行的模糊效果,默认为 `true`\n\t */\n\tenableBlur?: boolean;\n\t/**\n\t * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误\n\t */\n\tlyricLines?: LyricLine[];\n\t/**\n\t * 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息\n\t * 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好\n\t */\n\tcurrentTime?: number;\n\t/**\n\t * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosXSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在纵坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosYSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在缩放大小上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlineScaleSpringParams?: Partial<spring.SpringParams>;\n}\n\n/**\n * 歌词播放组件的引用\n */\nexport interface LyricPlayerRef {\n\t/**\n\t * 歌词播放实例\n\t */\n\tlyricPlayer?: CoreLyricPlayer;\n\t/**\n\t * 将歌词播放实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 歌词播放组件,本框架的核心组件\n *\n * 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施\n */\nexport const LyricPlayer = forwardRef<\n\tLyricPlayerRef,\n\tHTMLProps<HTMLDivElement> & LyricPlayerProps\n>(\n\t(\n\t\t{\n\t\t\tdisabled,\n\t\t\talignAnchor,\n\t\t\tenableSpring,\n\t\t\tenableBlur,\n\t\t\tlyricLines,\n\t\t\tcurrentTime,\n\t\t\tlinePosXSpringParams,\n\t\t\tlinePosYSpringParams,\n\t\t\tlineScaleSpringParams,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst corePlayerRef = useRef<CoreLyricPlayer>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current = new CoreLyricPlayer();\n\t\t\treturn () => {\n\t\t\t\tcorePlayerRef.current?.dispose();\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tif (!disabled) {\n\t\t\t\tlet canceled = false;\n\t\t\t\tlet lastTime = -1;\n\t\t\t\tconst onFrame = (time: number) => {\n\t\t\t\t\tif (canceled) return;\n\t\t\t\t\tif (lastTime === -1) {\n\t\t\t\t\t\tlastTime = time;\n\t\t\t\t\t}\n\t\t\t\t\tcorePlayerRef.current?.update(time - lastTime);\n\t\t\t\t\tlastTime = time;\n\t\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\t};\n\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\treturn () => {\n\t\t\t\t\tcanceled = true;\n\t\t\t\t};\n\t\t\t}\n\t\t}, [disabled]);\n\n\t\tuseEffect(() => {\n\t\t\tif (corePlayerRef.current)\n\t\t\t\twrapperRef.current?.appendChild(corePlayerRef.current.getElement());\n\t\t}, [wrapperRef.current]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignAnchor) corePlayerRef.current?.setAlignAnchor(alignAnchor);\n\t\t}, [alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring) corePlayerRef.current?.setEnableSpring(enableSpring);\n\t\t\telse corePlayerRef.current?.setEnableSpring(true);\n\t\t}, [enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current?.setEnableBlur(enableBlur ?? true);\n\t\t}, [enableBlur]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lyricLines) {\n\t\t\t\tcorePlayerRef.current?.setLyricLines(lyricLines);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t} else {\n\t\t\t\tcorePlayerRef.current?.setLyricLines([]);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t}\n\t\t}, [lyricLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (currentTime) corePlayerRef.current?.setCurrentTime(currentTime);\n\t\t\telse corePlayerRef.current?.setCurrentTime(0);\n\t\t}, [currentTime]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [lineScaleSpringParams]);\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tlyricPlayer: corePlayerRef.current,\n\t\t\t}),\n\t\t\t[wrapperRef.current, corePlayerRef.current],\n\t\t);\n\n\t\treturn <div {...props} ref={wrapperRef} />;\n\t},\n);\n"],"names":["BackgroundRender","forwardRef","albumImageUrl","fps","playing","flowSpeed","renderScale","props","ref","coreBGRenderRef","useRef","wrapperRef","useEffect","CoreBackgroundRender","_a","_b","_c","el","useImperativeHandle","jsx","LyricPlayer","disabled","alignAnchor","enableSpring","enableBlur","lyricLines","currentTime","linePosXSpringParams","linePosYSpringParams","lineScaleSpringParams","corePlayerRef","CoreLyricPlayer","canceled","lastTime","onFrame","time","_d"],"mappings":"kLAoDaA,EAAmBC,EAAA,WAG9B,CAAC,CAAE,cAAAC,EAAe,IAAAC,EAAK,QAAAC,EAAS,UAAAC,EAAW,YAAAC,EAAa,GAAGC,CAAM,EAAGC,IAAQ,CAC7E,MAAMC,EAAkBC,EAAAA,SAClBC,EAAaD,SAAuB,IAAI,EAE9CE,OAAAA,EAAAA,UAAU,KACOH,EAAA,QAAU,IAAII,EAAAA,iBACvB,IAAM,QACZC,EAAAL,EAAgB,UAAhB,MAAAK,EAAyB,SAAQ,GAEhC,CAAE,CAAA,EAELF,EAAAA,UAAU,IAAM,OACXV,KAA+BY,EAAAL,EAAA,UAAA,MAAAK,EAAS,cAAcZ,GAAa,EACrE,CAACA,CAAa,CAAC,EAElBU,EAAAA,UAAU,IAAM,OACXT,KAAqBW,EAAAL,EAAA,UAAA,MAAAK,EAAS,OAAOX,GAAG,EAC1C,CAACA,CAAG,CAAC,EAERS,EAAAA,UAAU,IAAM,WACXR,IAAY,QACfU,EAAAL,EAAgB,UAAhB,MAAAK,EAAyB,SACfV,GACVW,EAAAN,EAAgB,UAAhB,MAAAM,EAAyB,UAEzBC,EAAAP,EAAgB,UAAhB,MAAAO,EAAyB,OAC1B,EACE,CAACZ,CAAO,CAAC,EAEZQ,EAAAA,UAAU,IAAM,OACXP,KA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A,CAAoB,CAAC,EAEzBhB,EAAAA,UAAU,IAAM,OACXiB,KACWf,EAAAgB,EAAA,UAAA,MAAAhB,EAAS,yBAAyBe,GAAqB,EACpE,CAACA,CAAqB,CAAC,EAE1BX,EAAA,oBACCV,EACA,KAAO,CACN,UAAWG,EAAW,QACtB,YAAamB,EAAc,OAAA,GAE5B,CAACnB,EAAW,QAASmB,EAAc,OAAO,CAAA,EAGnCX,EAAAA,IAAA,MAAA,CAAK,GAAGZ,EAAO,IAAKI,CAAY,CAAA,CACzC,CACD"}
|
|
1
|
+
{"version":3,"file":"amll-react.js","sources":["../src/bg-render.tsx","../src/lyric-player.tsx"],"sourcesContent":["import { BackgroundRender as CoreBackgroundRender } from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n} from \"react\";\n\n/**\n * 背景渲染组件的属性\n */\nexport interface BackgroundRenderProps {\n\t/**\n\t * 设置背景专辑图片\n\t */\n\talbumImageUrl?: string;\n\t/**\n\t * 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`\n\t */\n\tfps?: number;\n\t/**\n\t * 设置当前播放状态,如果为 `undefined` 则默认为 `true`\n\t */\n\tplaying?: boolean;\n\t/**\n\t * 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`\n\t */\n\tflowSpeed?: number;\n\t/**\n\t * 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`\n\t */\n\trenderScale?: number;\n\t/**\n\t * 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能\n\t * 默认为 `false`\n\t */\n\tstaticMode?: boolean;\n}\n\n/**\n * 背景渲染组件的引用\n */\nexport interface BackgroundRenderRef {\n\t/**\n\t * 背景渲染实例引用\n\t */\n\tbgRender?: CoreBackgroundRender;\n\t/**\n\t * 将背景渲染实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果\n */\nexport const BackgroundRender = forwardRef<\n\tBackgroundRenderRef,\n\tHTMLProps<HTMLDivElement> & BackgroundRenderProps\n>(\n\t(\n\t\t{\n\t\t\talbumImageUrl,\n\t\t\tfps,\n\t\t\tplaying,\n\t\t\tflowSpeed,\n\t\t\trenderScale,\n\t\t\tstaticMode,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst coreBGRenderRef = useRef<CoreBackgroundRender>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t\tuseEffect(() => {\n\t\t\tcoreBGRenderRef.current = new CoreBackgroundRender();\n\t\t\treturn () => {\n\t\t\t\tcoreBGRenderRef.current?.dispose();\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tif (albumImageUrl) coreBGRenderRef.current?.setAlbumImage(albumImageUrl);\n\t\t}, [albumImageUrl]);\n\n\t\tuseEffect(() => {\n\t\t\tif (fps) coreBGRenderRef.current?.setFPS(fps);\n\t\t}, [fps]);\n\n\t\tuseEffect(() => {\n\t\t\tif (playing === undefined) {\n\t\t\t\tcoreBGRenderRef.current?.resume();\n\t\t\t} else if (playing) {\n\t\t\t\tcoreBGRenderRef.current?.resume();\n\t\t\t} else {\n\t\t\t\tcoreBGRenderRef.current?.pause();\n\t\t\t}\n\t\t}, [playing]);\n\n\t\tuseEffect(() => {\n\t\t\tif (flowSpeed) coreBGRenderRef.current?.setFlowSpeed(flowSpeed);\n\t\t}, [flowSpeed]);\n\n\t\tuseEffect(() => {\n\t\t\tcoreBGRenderRef.current?.setStaticMode(staticMode);\n\t\t}, [staticMode]);\n\n\t\tuseEffect(() => {\n\t\t\tif (renderScale) coreBGRenderRef.current?.setRenderScale(renderScale);\n\t\t}, [renderScale]);\n\n\t\tuseEffect(() => {\n\t\t\tif (coreBGRenderRef.current) {\n\t\t\t\tconst el = coreBGRenderRef.current.getElement();\n\t\t\t\tel.style.width = \"100%\";\n\t\t\t\tel.style.height = \"100%\";\n\t\t\t\twrapperRef.current?.appendChild(el);\n\t\t\t}\n\t\t});\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tbgRender: coreBGRenderRef.current,\n\t\t\t}),\n\t\t\t[wrapperRef.current, coreBGRenderRef.current],\n\t\t);\n\n\t\treturn <div {...props} ref={wrapperRef} />;\n\t},\n);\n","import {\n\tLyricPlayer as CoreLyricPlayer,\n\ttype LyricLine,\n\ttype spring,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n\ttype ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\n/**\n * 歌词播放组件的属性\n */\nexport interface LyricPlayerProps {\n\t/**\n\t * 是否禁用歌词播放组件,默认为 `false`,歌词组件启用后将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。\n\t *\n\t * 如果禁用了歌词组件动画,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `center`\n\t *\n\t * - 设置成 `top` 的话将会向目标歌词行的顶部对齐\n\t * - 设置成 `bottom` 的话将会向目标歌词行的底部对齐\n\t * - 设置成 `center` 的话将会向目标歌词行的垂直中心对齐\n\t */\n\talignAnchor?: \"top\" | \"bottom\" | \"center\";\n\t/**\n\t * 设置默认的歌词行对齐位置,相对于整个歌词播放组件的大小位置,如果为 `undefined`\n\t * 则默认为 `0.5`\n\t *\n\t * 可以设置一个 `[0.0-1.0]` 之间的任意数字,代表组件高度由上到下的比例位置\n\t */\n\talignPosition?: number;\n\t/**\n\t * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用\n\t *\n\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableSpring?: boolean;\n\t/**\n\t * 设置是否启用歌词行的模糊效果,默认为 `true`\n\t */\n\tenableBlur?: boolean;\n\t/**\n\t * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误\n\t */\n\tlyricLines?: LyricLine[];\n\t/**\n\t * 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息\n\t * 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好\n\t */\n\tcurrentTime?: number;\n\t/**\n\t * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosXSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在纵坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosYSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在缩放大小上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlineScaleSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 在一个特殊的底栏元素内加入指定元素,默认是空白的,可以往内部添加任意元素\n\t *\n\t * 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息\n\t */\n\tbottomLine?: ReactNode;\n}\n\n/**\n * 歌词播放组件的引用\n */\nexport interface LyricPlayerRef {\n\t/**\n\t * 歌词播放实例\n\t */\n\tlyricPlayer?: CoreLyricPlayer;\n\t/**\n\t * 将歌词播放实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 歌词播放组件,本框架的核心组件\n *\n * 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施\n */\nexport const LyricPlayer = forwardRef<\n\tLyricPlayerRef,\n\tHTMLProps<HTMLDivElement> & LyricPlayerProps\n>(\n\t(\n\t\t{\n\t\t\tdisabled,\n\t\t\talignAnchor,\n\t\t\talignPosition,\n\t\t\tenableSpring,\n\t\t\tenableBlur,\n\t\t\tlyricLines,\n\t\t\tcurrentTime,\n\t\t\tlinePosXSpringParams,\n\t\t\tlinePosYSpringParams,\n\t\t\tlineScaleSpringParams,\n\t\t\tbottomLine,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst corePlayerRef = useRef<CoreLyricPlayer>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current = new CoreLyricPlayer();\n\t\t\treturn () => {\n\t\t\t\tcorePlayerRef.current?.dispose();\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tif (!disabled) {\n\t\t\t\tlet canceled = false;\n\t\t\t\tlet lastTime = -1;\n\t\t\t\tconst onFrame = (time: number) => {\n\t\t\t\t\tif (canceled) return;\n\t\t\t\t\tif (lastTime === -1) {\n\t\t\t\t\t\tlastTime = time;\n\t\t\t\t\t}\n\t\t\t\t\tcorePlayerRef.current?.update(time - lastTime);\n\t\t\t\t\tlastTime = time;\n\t\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\t};\n\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\treturn () => {\n\t\t\t\t\tcanceled = true;\n\t\t\t\t};\n\t\t\t}\n\t\t}, [disabled]);\n\n\t\tuseEffect(() => {\n\t\t\tif (corePlayerRef.current)\n\t\t\t\twrapperRef.current?.appendChild(corePlayerRef.current.getElement());\n\t\t}, [wrapperRef.current]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignAnchor) corePlayerRef.current?.setAlignAnchor(alignAnchor);\n\t\t}, [alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignPosition) corePlayerRef.current?.setAlignPosition(alignPosition);\n\t\t}, [alignPosition]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring) corePlayerRef.current?.setEnableSpring(enableSpring);\n\t\t\telse corePlayerRef.current?.setEnableSpring(true);\n\t\t}, [enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current?.setEnableBlur(enableBlur ?? true);\n\t\t}, [enableBlur]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lyricLines) {\n\t\t\t\tcorePlayerRef.current?.setLyricLines(lyricLines);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t} else {\n\t\t\t\tcorePlayerRef.current?.setLyricLines([]);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t}\n\t\t}, [lyricLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (currentTime) corePlayerRef.current?.setCurrentTime(currentTime);\n\t\t\telse corePlayerRef.current?.setCurrentTime(0);\n\t\t}, [currentTime]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [lineScaleSpringParams]);\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tlyricPlayer: corePlayerRef.current,\n\t\t\t}),\n\t\t\t[wrapperRef.current, corePlayerRef.current],\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div {...props} ref={wrapperRef} />\n\t\t\t\t{corePlayerRef.current?.getBottomLineElement() && bottomLine\n\t\t\t\t\t? createPortal(\n\t\t\t\t\t\t\tbottomLine,\n\t\t\t\t\t\t\tcorePlayerRef.current?.getBottomLineElement(),\n\t\t\t\t\t )\n\t\t\t\t\t: null}\n\t\t\t</>\n\t\t);\n\t},\n);\n"],"names":["BackgroundRender","forwardRef","albumImageUrl","fps","playing","flowSpeed","renderScale","staticMode","props","ref","coreBGRenderRef","useRef","wrapperRef","useEffect","CoreBackgroundRender","_a","_b","_c","el","useImperativeHandle","jsx","LyricPlayer","disabled","alignAnchor","alignPosition","enableSpring","enableBlur","lyricLines","currentTime","linePosXSpringParams","linePosYSpringParams","lineScaleSpringParams","bottomLine","corePlayerRef","CoreLyricPlayer","canceled","lastTime","onFrame","time","_d","jsxs","Fragment","createPortal"],"mappings":"yMAyDaA,EAAmBC,EAAA,WAI/B,CACC,CACC,cAAAC,EACA,IAAAC,EACA,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,WAAAC,EACA,GAAGC,GAEJC,IACI,CACJ,MAAMC,EAAkBC,EAAAA,SAClBC,EAAaD,SAAuB,IAAI,EAE9CE,OAAAA,EAAAA,UAAU,KACOH,EAAA,QAAU,IAAII,EAAAA,iBACvB,IAAM,QACZC,EAAAL,EAAgB,UAAhB,MAAAK,EAAyB,SAAQ,GAEhC,CAAE,CAAA,EAELF,EAAAA,UAAU,IAAM,OACXX,KAA+Ba,EAAAL,EAAA,UAAA,MAAAK,EAAS,cAAcb,GAAa,EACrE,CAACA,CAAa,CAAC,EAElBW,EAAAA,UAAU,IAAM,OACXV,KAAqBY,EAAAL,EAAA,UAAA,MAAAK,EAAS,OAAOZ,GAAG,EAC1C,CAACA,CAAG,CAAC,EAERU,EAAAA,UAAU,IAAM,WACXT,IAAY,QACfW,EAAAL,EAAgB,UAAhB,MAAAK,EAAyB,SACfX,GACVY,EAAAN,EAAgB,UAAhB,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d,EAAAA,UAAU,IAAM,SACXe,GAA2Bb,EAAAkB,EAAA,UAAA,MAAAlB,EAAS,eAAea,IACpCZ,EAAAiB,EAAA,UAAA,MAAAjB,EAAS,eAAe,EAAC,EAC1C,CAACY,CAAW,CAAC,EAEhBf,EAAAA,UAAU,IAAM,OACXgB,KACWd,EAAAkB,EAAA,UAAA,MAAAlB,EAAS,wBAAwBc,GAAoB,EAClE,CAACA,CAAoB,CAAC,EAEzBhB,EAAAA,UAAU,IAAM,OACXiB,KACWf,EAAAkB,EAAA,UAAA,MAAAlB,EAAS,wBAAwBe,GAAoB,EAClE,CAACA,CAAoB,CAAC,EAEzBjB,EAAAA,UAAU,IAAM,OACXkB,KACWhB,EAAAkB,EAAA,UAAA,MAAAlB,EAAS,yBAAyBgB,GAAqB,EACpE,CAACA,CAAqB,CAAC,EAE1BZ,EAAA,oBACCV,EACA,KAAO,CACN,UAAWG,EAAW,QACtB,YAAaqB,EAAc,OAAA,GAE5B,CAACrB,EAAW,QAASqB,EAAc,OAAO,CAAA,EAKzCO,EAAA,KAAAC,WAAA,CAAA,SAAA,CAAArB,EAAA,IAAC,MAAK,CAAA,GAAGZ,EAAO,IAAKI,CAAY,CAAA,GAChCG,EAAAkB,EAAc,UAAd,MAAAlB,EAAuB,wBAA0BiB,EAC/CU,EAAA,aACAV,GACAhB,EAAAiB,EAAc,UAAd,YAAAjB,EAAuB,sBAAqB,EAE5C,IACJ,CAAA,CAAA,CAEF,CACD"}
|
package/dist/amll-react.mjs
CHANGED
|
@@ -1,107 +1,133 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { BackgroundRender as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return n(() => (u.current = new B(), () => {
|
|
7
|
-
var t;
|
|
8
|
-
(t = u.current) == null || t.dispose();
|
|
9
|
-
}), []), n(() => {
|
|
10
|
-
var t;
|
|
11
|
-
a && ((t = u.current) == null || t.setAlbumImage(a));
|
|
12
|
-
}, [a]), n(() => {
|
|
13
|
-
var t;
|
|
14
|
-
i && ((t = u.current) == null || t.setFPS(i));
|
|
15
|
-
}, [i]), n(() => {
|
|
16
|
-
var t, f, r;
|
|
17
|
-
o === void 0 ? (t = u.current) == null || t.resume() : o ? (f = u.current) == null || f.resume() : (r = u.current) == null || r.pause();
|
|
18
|
-
}, [o]), n(() => {
|
|
19
|
-
var t;
|
|
20
|
-
p && ((t = u.current) == null || t.setFlowSpeed(p));
|
|
21
|
-
}, [p]), n(() => {
|
|
22
|
-
var t;
|
|
23
|
-
d && ((t = u.current) == null || t.setRenderScale(d));
|
|
24
|
-
}, [d]), n(() => {
|
|
25
|
-
var t;
|
|
26
|
-
if (u.current) {
|
|
27
|
-
const f = u.current.getElement();
|
|
28
|
-
f.style.width = "100%", f.style.height = "100%", (t = s.current) == null || t.appendChild(f);
|
|
29
|
-
}
|
|
30
|
-
}), v(
|
|
31
|
-
m,
|
|
32
|
-
() => ({
|
|
33
|
-
wrapperEl: s.current,
|
|
34
|
-
bgRender: u.current
|
|
35
|
-
}),
|
|
36
|
-
[s.current, u.current]
|
|
37
|
-
), /* @__PURE__ */ F("div", { ...R, ref: s });
|
|
38
|
-
}), $ = h(
|
|
1
|
+
import { jsx as A, jsxs as x, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import { BackgroundRender as j, LyricPlayer as q } from "@applemusic-like-lyrics/core";
|
|
3
|
+
import { forwardRef as C, useRef as B, useEffect as n, useImperativeHandle as k } from "react";
|
|
4
|
+
import { createPortal as $ } from "react-dom";
|
|
5
|
+
const z = C(
|
|
39
6
|
({
|
|
40
|
-
|
|
7
|
+
albumImageUrl: l,
|
|
8
|
+
fps: i,
|
|
9
|
+
playing: o,
|
|
10
|
+
flowSpeed: d,
|
|
11
|
+
renderScale: a,
|
|
12
|
+
staticMode: m,
|
|
13
|
+
...R
|
|
14
|
+
}, E) => {
|
|
15
|
+
const u = B(), s = B(null);
|
|
16
|
+
return n(() => (u.current = new j(), () => {
|
|
17
|
+
var r;
|
|
18
|
+
(r = u.current) == null || r.dispose();
|
|
19
|
+
}), []), n(() => {
|
|
20
|
+
var r;
|
|
21
|
+
l && ((r = u.current) == null || r.setAlbumImage(l));
|
|
22
|
+
}, [l]), n(() => {
|
|
23
|
+
var r;
|
|
24
|
+
i && ((r = u.current) == null || r.setFPS(i));
|
|
25
|
+
}, [i]), n(() => {
|
|
26
|
+
var r, f, w;
|
|
27
|
+
o === void 0 ? (r = u.current) == null || r.resume() : o ? (f = u.current) == null || f.resume() : (w = u.current) == null || w.pause();
|
|
28
|
+
}, [o]), n(() => {
|
|
29
|
+
var r;
|
|
30
|
+
d && ((r = u.current) == null || r.setFlowSpeed(d));
|
|
31
|
+
}, [d]), n(() => {
|
|
32
|
+
var r;
|
|
33
|
+
(r = u.current) == null || r.setStaticMode(m);
|
|
34
|
+
}, [m]), n(() => {
|
|
35
|
+
var r;
|
|
36
|
+
a && ((r = u.current) == null || r.setRenderScale(a));
|
|
37
|
+
}, [a]), n(() => {
|
|
38
|
+
var r;
|
|
39
|
+
if (u.current) {
|
|
40
|
+
const f = u.current.getElement();
|
|
41
|
+
f.style.width = "100%", f.style.height = "100%", (r = s.current) == null || r.appendChild(f);
|
|
42
|
+
}
|
|
43
|
+
}), k(
|
|
44
|
+
E,
|
|
45
|
+
() => ({
|
|
46
|
+
wrapperEl: s.current,
|
|
47
|
+
bgRender: u.current
|
|
48
|
+
}),
|
|
49
|
+
[s.current, u.current]
|
|
50
|
+
), /* @__PURE__ */ A("div", { ...R, ref: s });
|
|
51
|
+
}
|
|
52
|
+
), D = C(
|
|
53
|
+
({
|
|
54
|
+
disabled: l,
|
|
41
55
|
alignAnchor: i,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
alignPosition: o,
|
|
57
|
+
enableSpring: d,
|
|
58
|
+
enableBlur: a,
|
|
59
|
+
lyricLines: m,
|
|
45
60
|
currentTime: R,
|
|
46
|
-
linePosXSpringParams:
|
|
61
|
+
linePosXSpringParams: E,
|
|
47
62
|
linePosYSpringParams: u,
|
|
48
63
|
lineScaleSpringParams: s,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
64
|
+
bottomLine: r,
|
|
65
|
+
...f
|
|
66
|
+
}, w) => {
|
|
67
|
+
var F, h;
|
|
68
|
+
const t = B(), y = B(null);
|
|
69
|
+
return n(() => (t.current = new q(), () => {
|
|
53
70
|
var e;
|
|
54
|
-
(e =
|
|
71
|
+
(e = t.current) == null || e.dispose();
|
|
55
72
|
}), []), n(() => {
|
|
56
|
-
if (!
|
|
73
|
+
if (!l) {
|
|
57
74
|
let e = !1, c = -1;
|
|
58
|
-
const
|
|
59
|
-
var
|
|
60
|
-
e || (c === -1 && (c =
|
|
75
|
+
const L = (p) => {
|
|
76
|
+
var v;
|
|
77
|
+
e || (c === -1 && (c = p), (v = t.current) == null || v.update(p - c), c = p, requestAnimationFrame(L));
|
|
61
78
|
};
|
|
62
|
-
return requestAnimationFrame(
|
|
79
|
+
return requestAnimationFrame(L), () => {
|
|
63
80
|
e = !0;
|
|
64
81
|
};
|
|
65
82
|
}
|
|
66
|
-
}, [
|
|
83
|
+
}, [l]), n(() => {
|
|
67
84
|
var e;
|
|
68
|
-
|
|
85
|
+
t.current && ((e = y.current) == null || e.appendChild(t.current.getElement()));
|
|
69
86
|
}, [y.current]), n(() => {
|
|
70
87
|
var e;
|
|
71
|
-
i && ((e =
|
|
88
|
+
i && ((e = t.current) == null || e.setAlignAnchor(i));
|
|
72
89
|
}, [i]), n(() => {
|
|
73
|
-
var e, c;
|
|
74
|
-
o ? (e = r.current) == null || e.setEnableSpring(o) : (c = r.current) == null || c.setEnableSpring(!0);
|
|
75
|
-
}, [o]), n(() => {
|
|
76
90
|
var e;
|
|
77
|
-
(e =
|
|
78
|
-
}, [
|
|
79
|
-
var e, c
|
|
80
|
-
d ? (
|
|
91
|
+
o && ((e = t.current) == null || e.setAlignPosition(o));
|
|
92
|
+
}, [o]), n(() => {
|
|
93
|
+
var e, c;
|
|
94
|
+
d ? (e = t.current) == null || e.setEnableSpring(d) : (c = t.current) == null || c.setEnableSpring(!0);
|
|
81
95
|
}, [d]), n(() => {
|
|
96
|
+
var e;
|
|
97
|
+
(e = t.current) == null || e.setEnableBlur(a ?? !0);
|
|
98
|
+
}, [a]), n(() => {
|
|
99
|
+
var e, c, L, p;
|
|
100
|
+
m ? ((e = t.current) == null || e.setLyricLines(m), (c = t.current) == null || c.update()) : ((L = t.current) == null || L.setLyricLines([]), (p = t.current) == null || p.update());
|
|
101
|
+
}, [m]), n(() => {
|
|
82
102
|
var e, c;
|
|
83
|
-
R ? (e =
|
|
103
|
+
R ? (e = t.current) == null || e.setCurrentTime(R) : (c = t.current) == null || c.setCurrentTime(0);
|
|
84
104
|
}, [R]), n(() => {
|
|
85
105
|
var e;
|
|
86
|
-
|
|
87
|
-
}, [
|
|
106
|
+
E && ((e = t.current) == null || e.setLinePosXSpringParams(E));
|
|
107
|
+
}, [E]), n(() => {
|
|
88
108
|
var e;
|
|
89
|
-
u && ((e =
|
|
109
|
+
u && ((e = t.current) == null || e.setLinePosYSpringParams(u));
|
|
90
110
|
}, [u]), n(() => {
|
|
91
111
|
var e;
|
|
92
|
-
s && ((e =
|
|
93
|
-
}, [s]),
|
|
94
|
-
|
|
112
|
+
s && ((e = t.current) == null || e.setLineScaleSpringParams(s));
|
|
113
|
+
}, [s]), k(
|
|
114
|
+
w,
|
|
95
115
|
() => ({
|
|
96
116
|
wrapperEl: y.current,
|
|
97
|
-
lyricPlayer:
|
|
117
|
+
lyricPlayer: t.current
|
|
98
118
|
}),
|
|
99
|
-
[y.current,
|
|
100
|
-
), /* @__PURE__ */
|
|
119
|
+
[y.current, t.current]
|
|
120
|
+
), /* @__PURE__ */ x(g, { children: [
|
|
121
|
+
/* @__PURE__ */ A("div", { ...f, ref: y }),
|
|
122
|
+
(F = t.current) != null && F.getBottomLineElement() && r ? $(
|
|
123
|
+
r,
|
|
124
|
+
(h = t.current) == null ? void 0 : h.getBottomLineElement()
|
|
125
|
+
) : null
|
|
126
|
+
] });
|
|
101
127
|
}
|
|
102
128
|
);
|
|
103
129
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
130
|
+
z as BackgroundRender,
|
|
131
|
+
D as LyricPlayer
|
|
106
132
|
};
|
|
107
133
|
//# sourceMappingURL=amll-react.mjs.map
|
package/dist/amll-react.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amll-react.mjs","sources":["../src/bg-render.tsx","../src/lyric-player.tsx"],"sourcesContent":["import { BackgroundRender as CoreBackgroundRender } from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n} from \"react\";\n\n/**\n * 背景渲染组件的属性\n */\nexport interface BackgroundRenderProps {\n\t/**\n\t * 设置背景专辑图片\n\t */\n\talbumImageUrl?: string;\n\t/**\n\t * 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`\n\t */\n\tfps?: number;\n\t/**\n\t * 设置当前播放状态,如果为 `undefined` 则默认为 `true`\n\t */\n\tplaying?: boolean;\n\t/**\n\t * 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`\n\t */\n\tflowSpeed?: number;\n\t/**\n\t * 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`\n\t */\n\trenderScale?: number;\n}\n\n/**\n * 背景渲染组件的引用\n */\nexport interface BackgroundRenderRef {\n\t/**\n\t * 背景渲染实例引用\n\t */\n\tbgRender?: CoreBackgroundRender;\n\t/**\n\t * 将背景渲染实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果\n */\nexport const BackgroundRender = forwardRef<\n\tBackgroundRenderRef,\n\tHTMLProps<HTMLDivElement> & BackgroundRenderProps\n>(({ albumImageUrl, fps, playing, flowSpeed, renderScale, ...props }, ref) => {\n\tconst coreBGRenderRef = useRef<CoreBackgroundRender>();\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\tuseEffect(() => {\n\t\tcoreBGRenderRef.current = new CoreBackgroundRender();\n\t\treturn () => {\n\t\t\tcoreBGRenderRef.current?.dispose();\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (albumImageUrl) coreBGRenderRef.current?.setAlbumImage(albumImageUrl);\n\t}, [albumImageUrl]);\n\n\tuseEffect(() => {\n\t\tif (fps) coreBGRenderRef.current?.setFPS(fps);\n\t}, [fps]);\n\n\tuseEffect(() => {\n\t\tif (playing === undefined) {\n\t\t\tcoreBGRenderRef.current?.resume();\n\t\t} else if (playing) {\n\t\t\tcoreBGRenderRef.current?.resume();\n\t\t} else {\n\t\t\tcoreBGRenderRef.current?.pause();\n\t\t}\n\t}, [playing]);\n\n\tuseEffect(() => {\n\t\tif (flowSpeed) coreBGRenderRef.current?.setFlowSpeed(flowSpeed);\n\t}, [flowSpeed]);\n\n\tuseEffect(() => {\n\t\tif (renderScale) coreBGRenderRef.current?.setRenderScale(renderScale);\n\t}, [renderScale]);\n\n\tuseEffect(() => {\n\t\tif (coreBGRenderRef.current) {\n\t\t\tconst el = coreBGRenderRef.current.getElement();\n\t\t\tel.style.width = \"100%\";\n\t\t\tel.style.height = \"100%\";\n\t\t\twrapperRef.current?.appendChild(el);\n\t\t}\n\t});\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\twrapperEl: wrapperRef.current,\n\t\t\tbgRender: coreBGRenderRef.current,\n\t\t}),\n\t\t[wrapperRef.current, coreBGRenderRef.current],\n\t);\n\n\treturn <div {...props} ref={wrapperRef} />;\n});\n","import {\n\tLyricPlayer as CoreLyricPlayer,\n\ttype LyricLine,\n\ttype spring,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n} from \"react\";\n\n/**\n * 歌词播放组件的属性\n */\nexport interface LyricPlayerProps {\n\t/**\n\t * 是否禁用歌词播放组件,默认为 `false`,歌词组件启用后将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。\n\t *\n\t * 如果禁用了歌词组件动画,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `top`\n\t *\n\t * - 设置成 `top` 的话歌词将会向组件顶部对齐\n\t * - 设置成 `bottom` 的话歌词将会向组件底部对齐\n\t * - 设置成 [0.0-1.0] 之间任意数字的话则会根据当前组件高度从顶部向下位移为对齐位置垂直居中对齐\n\t */\n\talignAnchor?: \"top\" | \"bottom\" | number;\n\t/**\n\t * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用\n\t *\n\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableSpring?: boolean;\n\t/**\n\t * 设置是否启用歌词行的模糊效果,默认为 `true`\n\t */\n\tenableBlur?: boolean;\n\t/**\n\t * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误\n\t */\n\tlyricLines?: LyricLine[];\n\t/**\n\t * 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息\n\t * 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好\n\t */\n\tcurrentTime?: number;\n\t/**\n\t * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosXSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在纵坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosYSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在缩放大小上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlineScaleSpringParams?: Partial<spring.SpringParams>;\n}\n\n/**\n * 歌词播放组件的引用\n */\nexport interface LyricPlayerRef {\n\t/**\n\t * 歌词播放实例\n\t */\n\tlyricPlayer?: CoreLyricPlayer;\n\t/**\n\t * 将歌词播放实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 歌词播放组件,本框架的核心组件\n *\n * 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施\n */\nexport const LyricPlayer = forwardRef<\n\tLyricPlayerRef,\n\tHTMLProps<HTMLDivElement> & LyricPlayerProps\n>(\n\t(\n\t\t{\n\t\t\tdisabled,\n\t\t\talignAnchor,\n\t\t\tenableSpring,\n\t\t\tenableBlur,\n\t\t\tlyricLines,\n\t\t\tcurrentTime,\n\t\t\tlinePosXSpringParams,\n\t\t\tlinePosYSpringParams,\n\t\t\tlineScaleSpringParams,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst corePlayerRef = useRef<CoreLyricPlayer>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current = new CoreLyricPlayer();\n\t\t\treturn () => {\n\t\t\t\tcorePlayerRef.current?.dispose();\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tif (!disabled) {\n\t\t\t\tlet canceled = false;\n\t\t\t\tlet lastTime = -1;\n\t\t\t\tconst onFrame = (time: number) => {\n\t\t\t\t\tif (canceled) return;\n\t\t\t\t\tif (lastTime === -1) {\n\t\t\t\t\t\tlastTime = time;\n\t\t\t\t\t}\n\t\t\t\t\tcorePlayerRef.current?.update(time - lastTime);\n\t\t\t\t\tlastTime = time;\n\t\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\t};\n\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\treturn () => {\n\t\t\t\t\tcanceled = true;\n\t\t\t\t};\n\t\t\t}\n\t\t}, [disabled]);\n\n\t\tuseEffect(() => {\n\t\t\tif (corePlayerRef.current)\n\t\t\t\twrapperRef.current?.appendChild(corePlayerRef.current.getElement());\n\t\t}, [wrapperRef.current]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignAnchor) corePlayerRef.current?.setAlignAnchor(alignAnchor);\n\t\t}, [alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring) corePlayerRef.current?.setEnableSpring(enableSpring);\n\t\t\telse corePlayerRef.current?.setEnableSpring(true);\n\t\t}, [enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current?.setEnableBlur(enableBlur ?? true);\n\t\t}, [enableBlur]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lyricLines) {\n\t\t\t\tcorePlayerRef.current?.setLyricLines(lyricLines);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t} else {\n\t\t\t\tcorePlayerRef.current?.setLyricLines([]);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t}\n\t\t}, [lyricLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (currentTime) corePlayerRef.current?.setCurrentTime(currentTime);\n\t\t\telse corePlayerRef.current?.setCurrentTime(0);\n\t\t}, [currentTime]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [lineScaleSpringParams]);\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tlyricPlayer: corePlayerRef.current,\n\t\t\t}),\n\t\t\t[wrapperRef.current, corePlayerRef.current],\n\t\t);\n\n\t\treturn <div {...props} ref={wrapperRef} />;\n\t},\n);\n"],"names":["BackgroundRender","forwardRef","albumImageUrl","fps","playing","flowSpeed","renderScale","props","ref","coreBGRenderRef","useRef","wrapperRef","useEffect","CoreBackgroundRender","_a","_b","_c","el","useImperativeHandle","jsx","LyricPlayer","disabled","alignAnchor","enableSpring","enableBlur","lyricLines","currentTime","linePosXSpringParams","linePosYSpringParams","lineScaleSpringParams","corePlayerRef","CoreLyricPlayer","canceled","lastTime","onFrame","time","_d"],"mappings":";;;AAoDO,MAAMA,IAAmBC,EAG9B,CAAC,EAAE,eAAAC,GAAe,KAAAC,GAAK,SAAAC,GAAS,WAAAC,GAAW,aAAAC,GAAa,GAAGC,EAAM,GAAGC,MAAQ;AAC7E,QAAMC,IAAkBC,KAClBC,IAAaD,EAAuB,IAAI;AAE9C,SAAAE,EAAU,OACOH,EAAA,UAAU,IAAII,KACvB,MAAM;;AACZ,KAAAC,IAAAL,EAAgB,YAAhB,QAAAK,EAAyB;AAAA,EAAQ,IAEhC,CAAE,CAAA,GAELF,EAAU,MAAM;;AACX,IAAAV,OAA+BY,IAAAL,EAAA,YAAA,QAAAK,EAAS,cAAcZ;AAAA,EAAa,GACrE,CAACA,CAAa,CAAC,GAElBU,EAAU,MAAM;;AACX,IAAAT,OAAqBW,IAAAL,EAAA,YAAA,QAAAK,EAAS,OAAOX;AAAA,EAAG,GAC1C,CAACA,CAAG,CAAC,GAERS,EAAU,MAAM;;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ACE,CAACX,CAAU,CAAC,GAEfb,EAAU,MAAM;;AACX,MAAAc,KAA2BZ,IAAAgB,EAAA,YAAA,QAAAhB,EAAS,eAAeY,MACpCX,IAAAe,EAAA,YAAA,QAAAf,EAAS,eAAe;AAAA,IAAC,GAC1C,CAACW,CAAW,CAAC,GAEhBd,EAAU,MAAM;;AACX,MAAAe,OACWb,IAAAgB,EAAA,YAAA,QAAAhB,EAAS,wBAAwBa;AAAA,IAAoB,GAClE,CAACA,CAAoB,CAAC,GAEzBf,EAAU,MAAM;;AACX,MAAAgB,OACWd,IAAAgB,EAAA,YAAA,QAAAhB,EAAS,wBAAwBc;AAAA,IAAoB,GAClE,CAACA,CAAoB,CAAC,GAEzBhB,EAAU,MAAM;;AACX,MAAAiB,OACWf,IAAAgB,EAAA,YAAA,QAAAhB,EAAS,yBAAyBe;AAAA,IAAqB,GACpE,CAACA,CAAqB,CAAC,GAE1BX;AAAA,MACCV;AAAA,MACA,OAAO;AAAA,QACN,WAAWG,EAAW;AAAA,QACtB,aAAamB,EAAc;AAAA,MAAA;AAAA,MAE5B,CAACnB,EAAW,SAASmB,EAAc,OAAO;AAAA,IAAA,GAGnC,gBAAAX,EAAA,OAAA,EAAK,GAAGZ,GAAO,KAAKI,EAAY,CAAA;AAAA,EACzC;AACD;"}
|
|
1
|
+
{"version":3,"file":"amll-react.mjs","sources":["../src/bg-render.tsx","../src/lyric-player.tsx"],"sourcesContent":["import { BackgroundRender as CoreBackgroundRender } from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n} from \"react\";\n\n/**\n * 背景渲染组件的属性\n */\nexport interface BackgroundRenderProps {\n\t/**\n\t * 设置背景专辑图片\n\t */\n\talbumImageUrl?: string;\n\t/**\n\t * 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`\n\t */\n\tfps?: number;\n\t/**\n\t * 设置当前播放状态,如果为 `undefined` 则默认为 `true`\n\t */\n\tplaying?: boolean;\n\t/**\n\t * 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`\n\t */\n\tflowSpeed?: number;\n\t/**\n\t * 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`\n\t */\n\trenderScale?: number;\n\t/**\n\t * 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能\n\t * 默认为 `false`\n\t */\n\tstaticMode?: boolean;\n}\n\n/**\n * 背景渲染组件的引用\n */\nexport interface BackgroundRenderRef {\n\t/**\n\t * 背景渲染实例引用\n\t */\n\tbgRender?: CoreBackgroundRender;\n\t/**\n\t * 将背景渲染实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果\n */\nexport const BackgroundRender = forwardRef<\n\tBackgroundRenderRef,\n\tHTMLProps<HTMLDivElement> & BackgroundRenderProps\n>(\n\t(\n\t\t{\n\t\t\talbumImageUrl,\n\t\t\tfps,\n\t\t\tplaying,\n\t\t\tflowSpeed,\n\t\t\trenderScale,\n\t\t\tstaticMode,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst coreBGRenderRef = useRef<CoreBackgroundRender>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t\tuseEffect(() => {\n\t\t\tcoreBGRenderRef.current = new CoreBackgroundRender();\n\t\t\treturn () => {\n\t\t\t\tcoreBGRenderRef.current?.dispose();\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tif (albumImageUrl) coreBGRenderRef.current?.setAlbumImage(albumImageUrl);\n\t\t}, [albumImageUrl]);\n\n\t\tuseEffect(() => {\n\t\t\tif (fps) coreBGRenderRef.current?.setFPS(fps);\n\t\t}, [fps]);\n\n\t\tuseEffect(() => {\n\t\t\tif (playing === undefined) {\n\t\t\t\tcoreBGRenderRef.current?.resume();\n\t\t\t} else if (playing) {\n\t\t\t\tcoreBGRenderRef.current?.resume();\n\t\t\t} else {\n\t\t\t\tcoreBGRenderRef.current?.pause();\n\t\t\t}\n\t\t}, [playing]);\n\n\t\tuseEffect(() => {\n\t\t\tif (flowSpeed) coreBGRenderRef.current?.setFlowSpeed(flowSpeed);\n\t\t}, [flowSpeed]);\n\n\t\tuseEffect(() => {\n\t\t\tcoreBGRenderRef.current?.setStaticMode(staticMode);\n\t\t}, [staticMode]);\n\n\t\tuseEffect(() => {\n\t\t\tif (renderScale) coreBGRenderRef.current?.setRenderScale(renderScale);\n\t\t}, [renderScale]);\n\n\t\tuseEffect(() => {\n\t\t\tif (coreBGRenderRef.current) {\n\t\t\t\tconst el = coreBGRenderRef.current.getElement();\n\t\t\t\tel.style.width = \"100%\";\n\t\t\t\tel.style.height = \"100%\";\n\t\t\t\twrapperRef.current?.appendChild(el);\n\t\t\t}\n\t\t});\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tbgRender: coreBGRenderRef.current,\n\t\t\t}),\n\t\t\t[wrapperRef.current, coreBGRenderRef.current],\n\t\t);\n\n\t\treturn <div {...props} ref={wrapperRef} />;\n\t},\n);\n","import {\n\tLyricPlayer as CoreLyricPlayer,\n\ttype LyricLine,\n\ttype spring,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n\tuseImperativeHandle,\n\ttype HTMLProps,\n\ttype ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\n/**\n * 歌词播放组件的属性\n */\nexport interface LyricPlayerProps {\n\t/**\n\t * 是否禁用歌词播放组件,默认为 `false`,歌词组件启用后将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。\n\t *\n\t * 如果禁用了歌词组件动画,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `center`\n\t *\n\t * - 设置成 `top` 的话将会向目标歌词行的顶部对齐\n\t * - 设置成 `bottom` 的话将会向目标歌词行的底部对齐\n\t * - 设置成 `center` 的话将会向目标歌词行的垂直中心对齐\n\t */\n\talignAnchor?: \"top\" | \"bottom\" | \"center\";\n\t/**\n\t * 设置默认的歌词行对齐位置,相对于整个歌词播放组件的大小位置,如果为 `undefined`\n\t * 则默认为 `0.5`\n\t *\n\t * 可以设置一个 `[0.0-1.0]` 之间的任意数字,代表组件高度由上到下的比例位置\n\t */\n\talignPosition?: number;\n\t/**\n\t * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用\n\t *\n\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableSpring?: boolean;\n\t/**\n\t * 设置是否启用歌词行的模糊效果,默认为 `true`\n\t */\n\tenableBlur?: boolean;\n\t/**\n\t * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误\n\t */\n\tlyricLines?: LyricLine[];\n\t/**\n\t * 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息\n\t * 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好\n\t */\n\tcurrentTime?: number;\n\t/**\n\t * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosXSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在纵坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosYSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在缩放大小上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlineScaleSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 在一个特殊的底栏元素内加入指定元素,默认是空白的,可以往内部添加任意元素\n\t *\n\t * 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息\n\t */\n\tbottomLine?: ReactNode;\n}\n\n/**\n * 歌词播放组件的引用\n */\nexport interface LyricPlayerRef {\n\t/**\n\t * 歌词播放实例\n\t */\n\tlyricPlayer?: CoreLyricPlayer;\n\t/**\n\t * 将歌词播放实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 歌词播放组件,本框架的核心组件\n *\n * 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施\n */\nexport const LyricPlayer = forwardRef<\n\tLyricPlayerRef,\n\tHTMLProps<HTMLDivElement> & LyricPlayerProps\n>(\n\t(\n\t\t{\n\t\t\tdisabled,\n\t\t\talignAnchor,\n\t\t\talignPosition,\n\t\t\tenableSpring,\n\t\t\tenableBlur,\n\t\t\tlyricLines,\n\t\t\tcurrentTime,\n\t\t\tlinePosXSpringParams,\n\t\t\tlinePosYSpringParams,\n\t\t\tlineScaleSpringParams,\n\t\t\tbottomLine,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst corePlayerRef = useRef<CoreLyricPlayer>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current = new CoreLyricPlayer();\n\t\t\treturn () => {\n\t\t\t\tcorePlayerRef.current?.dispose();\n\t\t\t};\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tif (!disabled) {\n\t\t\t\tlet canceled = false;\n\t\t\t\tlet lastTime = -1;\n\t\t\t\tconst onFrame = (time: number) => {\n\t\t\t\t\tif (canceled) return;\n\t\t\t\t\tif (lastTime === -1) {\n\t\t\t\t\t\tlastTime = time;\n\t\t\t\t\t}\n\t\t\t\t\tcorePlayerRef.current?.update(time - lastTime);\n\t\t\t\t\tlastTime = time;\n\t\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\t};\n\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\treturn () => {\n\t\t\t\t\tcanceled = true;\n\t\t\t\t};\n\t\t\t}\n\t\t}, [disabled]);\n\n\t\tuseEffect(() => {\n\t\t\tif (corePlayerRef.current)\n\t\t\t\twrapperRef.current?.appendChild(corePlayerRef.current.getElement());\n\t\t}, [wrapperRef.current]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignAnchor) corePlayerRef.current?.setAlignAnchor(alignAnchor);\n\t\t}, [alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignPosition) corePlayerRef.current?.setAlignPosition(alignPosition);\n\t\t}, [alignPosition]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring) corePlayerRef.current?.setEnableSpring(enableSpring);\n\t\t\telse corePlayerRef.current?.setEnableSpring(true);\n\t\t}, [enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayerRef.current?.setEnableBlur(enableBlur ?? true);\n\t\t}, [enableBlur]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lyricLines) {\n\t\t\t\tcorePlayerRef.current?.setLyricLines(lyricLines);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t} else {\n\t\t\t\tcorePlayerRef.current?.setLyricLines([]);\n\t\t\t\tcorePlayerRef.current?.update();\n\t\t\t}\n\t\t}, [lyricLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (currentTime) corePlayerRef.current?.setCurrentTime(currentTime);\n\t\t\telse corePlayerRef.current?.setCurrentTime(0);\n\t\t}, [currentTime]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams)\n\t\t\t\tcorePlayerRef.current?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [lineScaleSpringParams]);\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tlyricPlayer: corePlayerRef.current,\n\t\t\t}),\n\t\t\t[wrapperRef.current, corePlayerRef.current],\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div {...props} ref={wrapperRef} />\n\t\t\t\t{corePlayerRef.current?.getBottomLineElement() && bottomLine\n\t\t\t\t\t? createPortal(\n\t\t\t\t\t\t\tbottomLine,\n\t\t\t\t\t\t\tcorePlayerRef.current?.getBottomLineElement(),\n\t\t\t\t\t )\n\t\t\t\t\t: null}\n\t\t\t</>\n\t\t);\n\t},\n);\n"],"names":["BackgroundRender","forwardRef","albumImageUrl","fps","playing","flowSpeed","renderScale","staticMode","props","ref","coreBGRenderRef","useRef","wrapperRef","useEffect","CoreBackgroundRender","_a","_b","_c","el","useImperativeHandle","jsx","LyricPlayer","disabled","alignAnchor","alignPosition","enableSpring","enableBlur","lyricLines","currentTime","linePosXSpringParams","linePosYSpringParams","lineScaleSpringParams","bottomLine","corePlayerRef","CoreLyricPlayer","canceled","lastTime","onFrame","time","_d","jsxs","Fragment","createPortal"],"mappings":";;;;AAyDO,MAAMA,IAAmBC;AAAA,EAI/B,CACC;AAAA,IACC,eAAAC;AAAA,IACA,KAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,GAAGC;AAAA,KAEJC,MACI;AACJ,UA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S,yBAAyBgB;AAAA,IAAqB,GACpE,CAACA,CAAqB,CAAC,GAE1BZ;AAAA,MACCV;AAAA,MACA,OAAO;AAAA,QACN,WAAWG,EAAW;AAAA,QACtB,aAAaqB,EAAc;AAAA,MAAA;AAAA,MAE5B,CAACrB,EAAW,SAASqB,EAAc,OAAO;AAAA,IAAA,GAKzC,gBAAAO,EAAAC,GAAA,EAAA,UAAA;AAAA,MAAA,gBAAArB,EAAC,OAAK,EAAA,GAAGZ,GAAO,KAAKI,EAAY,CAAA;AAAA,OAChCG,IAAAkB,EAAc,YAAd,QAAAlB,EAAuB,0BAA0BiB,IAC/CU;AAAA,QACAV;AAAA,SACAhB,IAAAiB,EAAc,YAAd,gBAAAjB,EAAuB;AAAA,MAAqB,IAE5C;AAAA,IACJ,EAAA,CAAA;AAAA,EAEF;AACD;"}
|
package/dist/bg-render.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ export interface BackgroundRenderProps {
|
|
|
24
24
|
* 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`
|
|
25
25
|
*/
|
|
26
26
|
renderScale?: number;
|
|
27
|
+
/**
|
|
28
|
+
* 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能
|
|
29
|
+
* 默认为 `false`
|
|
30
|
+
*/
|
|
31
|
+
staticMode?: boolean;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* 背景渲染组件的引用
|
|
@@ -41,4 +46,4 @@ export interface BackgroundRenderRef {
|
|
|
41
46
|
/**
|
|
42
47
|
* 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果
|
|
43
48
|
*/
|
|
44
|
-
export declare const BackgroundRender: import("react").ForwardRefExoticComponent<
|
|
49
|
+
export declare const BackgroundRender: import("react").ForwardRefExoticComponent<Omit<HTMLProps<HTMLDivElement> & BackgroundRenderProps, "ref"> & import("react").RefAttributes<BackgroundRenderRef>>;
|
package/dist/lyric-player.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LyricPlayer as CoreLyricPlayer, type LyricLine, type spring } from "@applemusic-like-lyrics/core";
|
|
2
|
-
import { type HTMLProps } from "react";
|
|
2
|
+
import { type HTMLProps, type ReactNode } from "react";
|
|
3
3
|
/**
|
|
4
4
|
* 歌词播放组件的属性
|
|
5
5
|
*/
|
|
@@ -11,13 +11,20 @@ export interface LyricPlayerProps {
|
|
|
11
11
|
*/
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `
|
|
14
|
+
* 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `center`
|
|
15
15
|
*
|
|
16
|
-
* - 设置成 `top`
|
|
17
|
-
* - 设置成 `bottom`
|
|
18
|
-
* - 设置成
|
|
16
|
+
* - 设置成 `top` 的话将会向目标歌词行的顶部对齐
|
|
17
|
+
* - 设置成 `bottom` 的话将会向目标歌词行的底部对齐
|
|
18
|
+
* - 设置成 `center` 的话将会向目标歌词行的垂直中心对齐
|
|
19
19
|
*/
|
|
20
|
-
alignAnchor?: "top" | "bottom" |
|
|
20
|
+
alignAnchor?: "top" | "bottom" | "center";
|
|
21
|
+
/**
|
|
22
|
+
* 设置默认的歌词行对齐位置,相对于整个歌词播放组件的大小位置,如果为 `undefined`
|
|
23
|
+
* 则默认为 `0.5`
|
|
24
|
+
*
|
|
25
|
+
* 可以设置一个 `[0.0-1.0]` 之间的任意数字,代表组件高度由上到下的比例位置
|
|
26
|
+
*/
|
|
27
|
+
alignPosition?: number;
|
|
21
28
|
/**
|
|
22
29
|
* 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
|
|
23
30
|
*
|
|
@@ -57,6 +64,12 @@ export interface LyricPlayerProps {
|
|
|
57
64
|
* @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
|
|
58
65
|
*/
|
|
59
66
|
lineScaleSpringParams?: Partial<spring.SpringParams>;
|
|
67
|
+
/**
|
|
68
|
+
* 在一个特殊的底栏元素内加入指定元素,默认是空白的,可以往内部添加任意元素
|
|
69
|
+
*
|
|
70
|
+
* 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息
|
|
71
|
+
*/
|
|
72
|
+
bottomLine?: ReactNode;
|
|
60
73
|
}
|
|
61
74
|
/**
|
|
62
75
|
* 歌词播放组件的引用
|
|
@@ -76,4 +89,4 @@ export interface LyricPlayerRef {
|
|
|
76
89
|
*
|
|
77
90
|
* 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施
|
|
78
91
|
*/
|
|
79
|
-
export declare const LyricPlayer: import("react").ForwardRefExoticComponent<
|
|
92
|
+
export declare const LyricPlayer: import("react").ForwardRefExoticComponent<Omit<HTMLProps<HTMLDivElement> & LyricPlayerProps, "ref"> & import("react").RefAttributes<LyricPlayerRef>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applemusic-like-lyrics/react",
|
|
3
3
|
"packageManager": "yarn@3.6.1",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"description": "AMLL 组件库的 React 绑定",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "https://github.com/Steve-xmh/applemusic-like-lyrics.git",
|
|
@@ -28,19 +28,30 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@pixi/app": "^7.2.4",
|
|
32
|
+
"@pixi/core": "^7.2.4",
|
|
33
|
+
"@pixi/display": "^7.2.4",
|
|
34
|
+
"@pixi/filter-blur": "^7.2.4",
|
|
35
|
+
"@pixi/filter-color-matrix": "^7.2.4",
|
|
36
|
+
"@pixi/sprite": "^7.2.4",
|
|
37
|
+
"@types/react-dom": "^18.2.7",
|
|
31
38
|
"@vitejs/plugin-react": "^4.0.3",
|
|
39
|
+
"jss": "^10.10.0",
|
|
40
|
+
"jss-preset-default": "^10.10.0",
|
|
32
41
|
"react": "^18.2.0",
|
|
33
42
|
"react-dom": "^18.2.0",
|
|
34
43
|
"rome": "^12.1.3",
|
|
35
44
|
"typedoc": "^0.24.8",
|
|
36
45
|
"typedoc-plugin-markdown": "^3.15.3",
|
|
46
|
+
"typescript": "^5.1.6",
|
|
37
47
|
"vite": "^4.4.7",
|
|
38
48
|
"vite-plugin-dts": "^3.3.1"
|
|
39
49
|
},
|
|
40
50
|
"dependencies": {
|
|
41
|
-
"@applemusic-like-lyrics/core": "^0.0.
|
|
51
|
+
"@applemusic-like-lyrics/core": "^0.0.11"
|
|
42
52
|
},
|
|
43
53
|
"peerDependencies": {
|
|
44
|
-
"react": "*"
|
|
54
|
+
"react": "*",
|
|
55
|
+
"react-dom": "*"
|
|
45
56
|
}
|
|
46
57
|
}
|