@applemusic-like-lyrics/react 0.0.11 → 0.0.13

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  > 警告:此为个人项目,且尚未完成开发,可能仍有大量问题,所以请勿直接用于生产环境!
4
4
 
5
+ ![AMLL-React](https://img.shields.io/badge/React-%23149eca?label=Apple%20Music-like%20Lyrics&labelColor=%23FB5C74)
6
+ [![npm](https://img.shields.io/npm/dt/%40applemusic-like-lyrics/react)](https://www.npmjs.com/package/@applemusic-like-lyrics/react)
7
+ [![npm](https://img.shields.io/npm/v/%40applemusic-like-lyrics%2Freact)](https://www.npmjs.com/package/@applemusic-like-lyrics/react)
8
+
5
9
  AMLL 组件库的 React 绑定,你可以通过此库来更加方便地使用 AMLL 歌词组件。
6
10
 
7
11
  详情可以访问 [Core 核心组件的 README.md](../core/README.md)。
@@ -1,2 +1,2 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),x=require("@applemusic-like-lyrics/core"),r=require("react"),k=require("react-dom"),H=r.forwardRef(({albumImageUrl:l,fps:d,playing:E,flowSpeed:o,renderScale:a,staticMode:v,...m},p)=>{const n=r.useRef(),i=r.useRef(null);return r.useEffect(()=>(n.current=new x.BackgroundRender,()=>{var u;(u=n.current)==null||u.dispose()}),[]),r.useEffect(()=>{var u;l&&((u=n.current)==null||u.setAlbumImage(l))},[l]),r.useEffect(()=>{var u;d&&((u=n.current)==null||u.setFPS(d))},[d]),r.useEffect(()=>{var u,s,w;E===void 0?(u=n.current)==null||u.resume():E?(s=n.current)==null||s.resume():(w=n.current)==null||w.pause()},[E]),r.useEffect(()=>{var u;o&&((u=n.current)==null||u.setFlowSpeed(o))},[o]),r.useEffect(()=>{var u;(u=n.current)==null||u.setStaticMode(v)},[v]),r.useEffect(()=>{var u;a&&((u=n.current)==null||u.setRenderScale(a))},[a]),r.useEffect(()=>{var u;if(n.current){const s=n.current.getElement();s.style.width="100%",s.style.height="100%",(u=i.current)==null||u.appendChild(s)}}),r.useImperativeHandle(p,()=>({wrapperEl:i.current,bgRender:n.current}),[i.current,n.current]),q.jsx("div",{...m,ref:i})}),T=r.forwardRef(({disabled:l,alignAnchor:d,alignPosition:E,enableSpring:o,enableBlur:a,enableScale:v,hidePassedLines:m,lyricLines:p,currentTime:n,linePosXSpringParams:i,linePosYSpringParams:u,lineScaleSpringParams:s,bottomLine:w,onLyricLineClick:B,onLyricLineContextMenu:F,...A},L)=>{var h,j;const t=r.useRef(),y=r.useRef(null);return r.useEffect(()=>(t.current=new x.LyricPlayer,()=>{var e;(e=t.current)==null||e.dispose()}),[]),r.useEffect(()=>{if(!l){let e=!1,c=-1;const f=R=>{var g;e||(c===-1&&(c=R),(g=t.current)==null||g.update(R-c),c=R,requestAnimationFrame(f))};return requestAnimationFrame(f),()=>{e=!0}}},[l]),r.useEffect(()=>{var e;t.current&&((e=y.current)==null||e.appendChild(t.current.getElement()))},[y.current]),r.useEffect(()=>{var e;d!==void 0&&((e=t.current)==null||e.setAlignAnchor(d))},[d]),r.useEffect(()=>{var e;m!==void 0&&((e=t.current)==null||e.setHidePassedLines(m))},[m]),r.useEffect(()=>{var e;E!==void 0&&((e=t.current)==null||e.setAlignPosition(E))},[E]),r.useEffect(()=>{var e,c;o!==void 0?(e=t.current)==null||e.setEnableSpring(o):(c=t.current)==null||c.setEnableSpring(!0)},[o]),r.useEffect(()=>{var e,c;v!==void 0?(e=t.current)==null||e.setEnableScale(v):(c=t.current)==null||c.setEnableScale(!0)},[v]),r.useEffect(()=>{var e;(e=t.current)==null||e.setEnableBlur(a??!0)},[a]),r.useEffect(()=>{var e,c,f,R;p!==void 0?((e=t.current)==null||e.setLyricLines(p),(c=t.current)==null||c.update()):((f=t.current)==null||f.setLyricLines([]),(R=t.current)==null||R.update())},[p]),r.useEffect(()=>{var e,c;n!==void 0?(e=t.current)==null||e.setCurrentTime(n):(c=t.current)==null||c.setCurrentTime(0)},[n]),r.useEffect(()=>{var e;i!==void 0&&((e=t.current)==null||e.setLinePosXSpringParams(i))},[i]),r.useEffect(()=>{var e;u!==void 0&&((e=t.current)==null||e.setLinePosYSpringParams(u))},[u]),r.useEffect(()=>{var e;s!==void 0&&((e=t.current)==null||e.setLineScaleSpringParams(s))},[s]),r.useEffect(()=>{var e;if(B){const c=f=>B(f);return(e=t.current)==null||e.addEventListener("line-click",c),()=>{var f;return(f=t.current)==null?void 0:f.removeEventListener("line-click",c)}}},[B]),r.useEffect(()=>{var e;if(F){const c=f=>F(f);return(e=t.current)==null||e.addEventListener("line-contextmenu",c),()=>{var f;return(f=t.current)==null?void 0:f.removeEventListener("line-contextmenu",c)}}},[F]),r.useImperativeHandle(L,()=>({wrapperEl:y.current,lyricPlayer:t.current}),[y.current,t.current]),q.jsxs(q.Fragment,{children:[q.jsx("div",{...A,ref:y}),(h=t.current)!=null&&h.getBottomLineElement()&&w?k.createPortal(w,(j=t.current)==null?void 0:j.getBottomLineElement()):null]})});exports.BackgroundRender=H;exports.LyricPlayer=T;
2
2
  //# sourceMappingURL=amll-react.js.map
@@ -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\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,MAAAM,EAAyB,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,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"}
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 LyricLineMouseEvent,\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\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableScale?: boolean;\n\t/**\n\t * 设置是否隐藏已经播放过的歌词行,默认不隐藏\n\t */\n\thidePassedLines?: 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\t/**\n\t * 当某个歌词行被左键点击时触发的事件\n\t * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引\n\t */\n\tonLyricLineClick?: (line: LyricLineMouseEvent) => void;\n\t/**\n\t * 当某个歌词行被右键点击时触发的事件\n\t * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引\n\t */\n\tonLyricLineContextMenu?: (line: LyricLineMouseEvent) => void;\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\tenableScale,\n\t\t\thidePassedLines,\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\tonLyricLineClick,\n\t\t\tonLyricLineContextMenu,\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 !== undefined)\n\t\t\t\tcorePlayerRef.current?.setAlignAnchor(alignAnchor);\n\t\t}, [alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (hidePassedLines !== undefined)\n\t\t\t\tcorePlayerRef.current?.setHidePassedLines(hidePassedLines);\n\t\t}, [hidePassedLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignPosition !== undefined)\n\t\t\t\tcorePlayerRef.current?.setAlignPosition(alignPosition);\n\t\t}, [alignPosition]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring !== undefined)\n\t\t\t\tcorePlayerRef.current?.setEnableSpring(enableSpring);\n\t\t\telse corePlayerRef.current?.setEnableSpring(true);\n\t\t}, [enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableScale !== undefined)\n\t\t\t\tcorePlayerRef.current?.setEnableScale(enableScale);\n\t\t\telse corePlayerRef.current?.setEnableScale(true);\n\t\t}, [enableScale]);\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 !== undefined) {\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 !== undefined)\n\t\t\t\tcorePlayerRef.current?.setCurrentTime(currentTime);\n\t\t\telse corePlayerRef.current?.setCurrentTime(0);\n\t\t}, [currentTime]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams !== undefined)\n\t\t\t\tcorePlayerRef.current?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams !== undefined)\n\t\t\t\tcorePlayerRef.current?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams !== undefined)\n\t\t\t\tcorePlayerRef.current?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [lineScaleSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (onLyricLineClick) {\n\t\t\t\tconst handler = (e: Event) =>\n\t\t\t\t\tonLyricLineClick(e as LyricLineMouseEvent);\n\t\t\t\tcorePlayerRef.current?.addEventListener(\"line-click\", handler);\n\t\t\t\treturn () =>\n\t\t\t\t\tcorePlayerRef.current?.removeEventListener(\"line-click\", handler);\n\t\t\t}\n\t\t}, [onLyricLineClick]);\n\n\t\tuseEffect(() => {\n\t\t\tif (onLyricLineContextMenu) {\n\t\t\t\tconst handler = (e: Event) =>\n\t\t\t\t\tonLyricLineContextMenu(e as LyricLineMouseEvent);\n\t\t\t\tcorePlayerRef.current?.addEventListener(\"line-contextmenu\", handler);\n\t\t\t\treturn () =>\n\t\t\t\t\tcorePlayerRef.current?.removeEventListener(\n\t\t\t\t\t\t\"line-contextmenu\",\n\t\t\t\t\t\thandler,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}, [onLyricLineContextMenu]);\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","enableScale","hidePassedLines","lyricLines","currentTime","linePosXSpringParams","linePosYSpringParams","lineScaleSpringParams","bottomLine","onLyricLineClick","onLyricLineContextMenu","corePlayerRef","CoreLyricPlayer","canceled","lastTime","onFrame","time","_d","handler","e","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,MAAAM,EAAyB,UAEzBC,EAAAP,EAAgB,UAAhB,MAAAO,EAAyB,OAC1B,EACE,CAACb,CAAO,CAAC,EAEZS,EAAAA,UAAU,IAAM,OACXR,KAA2BU,EAAAL,EAAA,UAAA,MAAAK,EAAS,aAAaV,GAAS,EAC5D,CAACA,CAAS,CAAC,EAEdQ,EAAAA,UAAU,IAAM,QACCE,EAAAL,EAAA,UAAA,MAAAK,EAAS,cAAc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EAAW,QACtB,YAAayB,EAAc,OAAA,GAE5B,CAACzB,EAAW,QAASyB,EAAc,OAAO,CAAA,EAKzCS,EAAA,KAAAC,WAAA,CAAA,SAAA,CAAA3B,EAAA,IAAC,MAAK,CAAA,GAAGZ,EAAO,IAAKI,CAAY,CAAA,GAChCG,EAAAsB,EAAc,UAAd,MAAAtB,EAAuB,wBAA0BmB,EAC/Cc,EAAA,aACAd,GACAlB,EAAAqB,EAAc,UAAd,YAAArB,EAAuB,sBAAqB,EAE5C,IACJ,CAAA,CAAA,CAEF,CACD"}
@@ -1,133 +1,164 @@
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(
1
+ import { jsx as x, jsxs as $, Fragment as G } from "react/jsx-runtime";
2
+ import { BackgroundRender as T, LyricPlayer as z } from "@applemusic-like-lyrics/core";
3
+ import { forwardRef as g, useRef as F, useEffect as n, useImperativeHandle as j } from "react";
4
+ import { createPortal as C } from "react-dom";
5
+ const N = g(
6
6
  ({
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();
7
+ albumImageUrl: m,
8
+ fps: d,
9
+ playing: f,
10
+ flowSpeed: l,
11
+ renderScale: v,
12
+ staticMode: a,
13
+ ...E
14
+ }, R) => {
15
+ const c = F(), o = F(null);
16
+ return n(() => (c.current = new T(), () => {
17
+ var t;
18
+ (t = c.current) == null || t.dispose();
19
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);
20
+ var t;
21
+ m && ((t = c.current) == null || t.setAlbumImage(m));
34
22
  }, [m]), n(() => {
35
- var r;
36
- a && ((r = u.current) == null || r.setRenderScale(a));
23
+ var t;
24
+ d && ((t = c.current) == null || t.setFPS(d));
25
+ }, [d]), n(() => {
26
+ var t, i, w;
27
+ f === void 0 ? (t = c.current) == null || t.resume() : f ? (i = c.current) == null || i.resume() : (w = c.current) == null || w.pause();
28
+ }, [f]), n(() => {
29
+ var t;
30
+ l && ((t = c.current) == null || t.setFlowSpeed(l));
31
+ }, [l]), n(() => {
32
+ var t;
33
+ (t = c.current) == null || t.setStaticMode(a);
37
34
  }, [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);
35
+ var t;
36
+ v && ((t = c.current) == null || t.setRenderScale(v));
37
+ }, [v]), n(() => {
38
+ var t;
39
+ if (c.current) {
40
+ const i = c.current.getElement();
41
+ i.style.width = "100%", i.style.height = "100%", (t = o.current) == null || t.appendChild(i);
42
42
  }
43
- }), k(
44
- E,
43
+ }), j(
44
+ R,
45
45
  () => ({
46
- wrapperEl: s.current,
47
- bgRender: u.current
46
+ wrapperEl: o.current,
47
+ bgRender: c.current
48
48
  }),
49
- [s.current, u.current]
50
- ), /* @__PURE__ */ A("div", { ...R, ref: s });
49
+ [o.current, c.current]
50
+ ), /* @__PURE__ */ x("div", { ...E, ref: o });
51
51
  }
52
- ), D = C(
52
+ ), O = g(
53
53
  ({
54
- disabled: l,
55
- alignAnchor: i,
56
- alignPosition: o,
57
- enableSpring: d,
58
- enableBlur: a,
59
- lyricLines: m,
60
- currentTime: R,
61
- linePosXSpringParams: E,
62
- linePosYSpringParams: u,
63
- lineScaleSpringParams: s,
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(), () => {
54
+ disabled: m,
55
+ alignAnchor: d,
56
+ alignPosition: f,
57
+ enableSpring: l,
58
+ enableBlur: v,
59
+ enableScale: a,
60
+ hidePassedLines: E,
61
+ lyricLines: R,
62
+ currentTime: c,
63
+ linePosXSpringParams: o,
64
+ linePosYSpringParams: t,
65
+ lineScaleSpringParams: i,
66
+ bottomLine: w,
67
+ onLyricLineClick: h,
68
+ onLyricLineContextMenu: y,
69
+ ...q
70
+ }, H) => {
71
+ var A, L;
72
+ const r = F(), B = F(null);
73
+ return n(() => (r.current = new z(), () => {
70
74
  var e;
71
- (e = t.current) == null || e.dispose();
75
+ (e = r.current) == null || e.dispose();
72
76
  }), []), n(() => {
73
- if (!l) {
74
- let e = !1, c = -1;
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));
77
+ if (!m) {
78
+ let e = !1, u = -1;
79
+ const s = (p) => {
80
+ var k;
81
+ e || (u === -1 && (u = p), (k = r.current) == null || k.update(p - u), u = p, requestAnimationFrame(s));
78
82
  };
79
- return requestAnimationFrame(L), () => {
83
+ return requestAnimationFrame(s), () => {
80
84
  e = !0;
81
85
  };
82
86
  }
83
- }, [l]), n(() => {
84
- var e;
85
- t.current && ((e = y.current) == null || e.appendChild(t.current.getElement()));
86
- }, [y.current]), n(() => {
87
+ }, [m]), n(() => {
87
88
  var e;
88
- i && ((e = t.current) == null || e.setAlignAnchor(i));
89
- }, [i]), n(() => {
89
+ r.current && ((e = B.current) == null || e.appendChild(r.current.getElement()));
90
+ }, [B.current]), n(() => {
90
91
  var e;
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);
92
+ d !== void 0 && ((e = r.current) == null || e.setAlignAnchor(d));
95
93
  }, [d]), n(() => {
96
94
  var e;
97
- (e = t.current) == null || e.setEnableBlur(a ?? !0);
95
+ E !== void 0 && ((e = r.current) == null || e.setHidePassedLines(E));
96
+ }, [E]), n(() => {
97
+ var e;
98
+ f !== void 0 && ((e = r.current) == null || e.setAlignPosition(f));
99
+ }, [f]), n(() => {
100
+ var e, u;
101
+ l !== void 0 ? (e = r.current) == null || e.setEnableSpring(l) : (u = r.current) == null || u.setEnableSpring(!0);
102
+ }, [l]), n(() => {
103
+ var e, u;
104
+ a !== void 0 ? (e = r.current) == null || e.setEnableScale(a) : (u = r.current) == null || u.setEnableScale(!0);
98
105
  }, [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(() => {
102
- var e, c;
103
- R ? (e = t.current) == null || e.setCurrentTime(R) : (c = t.current) == null || c.setCurrentTime(0);
106
+ var e;
107
+ (e = r.current) == null || e.setEnableBlur(v ?? !0);
108
+ }, [v]), n(() => {
109
+ var e, u, s, p;
110
+ R !== void 0 ? ((e = r.current) == null || e.setLyricLines(R), (u = r.current) == null || u.update()) : ((s = r.current) == null || s.setLyricLines([]), (p = r.current) == null || p.update());
104
111
  }, [R]), n(() => {
112
+ var e, u;
113
+ c !== void 0 ? (e = r.current) == null || e.setCurrentTime(c) : (u = r.current) == null || u.setCurrentTime(0);
114
+ }, [c]), n(() => {
105
115
  var e;
106
- E && ((e = t.current) == null || e.setLinePosXSpringParams(E));
107
- }, [E]), n(() => {
116
+ o !== void 0 && ((e = r.current) == null || e.setLinePosXSpringParams(o));
117
+ }, [o]), n(() => {
118
+ var e;
119
+ t !== void 0 && ((e = r.current) == null || e.setLinePosYSpringParams(t));
120
+ }, [t]), n(() => {
108
121
  var e;
109
- u && ((e = t.current) == null || e.setLinePosYSpringParams(u));
110
- }, [u]), n(() => {
122
+ i !== void 0 && ((e = r.current) == null || e.setLineScaleSpringParams(i));
123
+ }, [i]), n(() => {
124
+ var e;
125
+ if (h) {
126
+ const u = (s) => h(s);
127
+ return (e = r.current) == null || e.addEventListener("line-click", u), () => {
128
+ var s;
129
+ return (s = r.current) == null ? void 0 : s.removeEventListener("line-click", u);
130
+ };
131
+ }
132
+ }, [h]), n(() => {
111
133
  var e;
112
- s && ((e = t.current) == null || e.setLineScaleSpringParams(s));
113
- }, [s]), k(
114
- w,
134
+ if (y) {
135
+ const u = (s) => y(s);
136
+ return (e = r.current) == null || e.addEventListener("line-contextmenu", u), () => {
137
+ var s;
138
+ return (s = r.current) == null ? void 0 : s.removeEventListener(
139
+ "line-contextmenu",
140
+ u
141
+ );
142
+ };
143
+ }
144
+ }, [y]), j(
145
+ H,
115
146
  () => ({
116
- wrapperEl: y.current,
117
- lyricPlayer: t.current
147
+ wrapperEl: B.current,
148
+ lyricPlayer: r.current
118
149
  }),
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()
150
+ [B.current, r.current]
151
+ ), /* @__PURE__ */ $(G, { children: [
152
+ /* @__PURE__ */ x("div", { ...q, ref: B }),
153
+ (A = r.current) != null && A.getBottomLineElement() && w ? C(
154
+ w,
155
+ (L = r.current) == null ? void 0 : L.getBottomLineElement()
125
156
  ) : null
126
157
  ] });
127
158
  }
128
159
  );
129
160
  export {
130
- z as BackgroundRender,
131
- D as LyricPlayer
161
+ N as BackgroundRender,
162
+ O as LyricPlayer
132
163
  };
133
164
  //# sourceMappingURL=amll-react.mjs.map
@@ -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\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,UAAMC,IAAkBC,KAClBC,IAAaD,EAAuB,IAAI;AAE9C,WAAAE,EAAU,OACOH,EAAA,UAAU,IAAII,KACvB,MAAM;;AACZ,OAAAC,IAAAL,EAAgB,YAAhB,QAAAK,EAAyB;AAAA,IAAQ,IAEhC,CAAE,CAAA,GAELF,EAAU,MAAM;;AACX,MAAAX,OAA+Ba,IAAAL,EAAA,YAAA,QAAAK,EAAS,cAAcb;AAAA,IAAa,GACrE,CAACA,CAAa,CAAC,GAElBW,EAAU,MAAM;;AACX,MAAAV,OAAqBY,IAAAL,EAAA,YAAA,QAAAK,EAAS,OAAOZ;AAAA,IAAG,GAC1C,CAACA,CAAG,CAAC,GAERU,EAAU,MAAM;;AACf,MAAIT,MAAY,UACfW,IAAAL,EAAgB,YAAhB,QAAAK,EAAyB,WACfX,KACVY,IAAAN,EAAgB,YAAhB,QAAAM,EAAyB,YAEzBC,IAAAP,EAAgB,YAAhB,QAAAO,EAAyB;AAAA,IAC1B,GACE,CAACb,CAAO,CAAC,GAEZS,EAAU,MAAM;;AACX,MAAAR,OAA2BU,IAAAL,EAAA,YAAA,QAAAK,EAAS,aAAaV;AAAA,IAAS,GAC5D,CAACA,CAAS,CAAC,GAEdQ,EAAU,MAAM;;AACC,OAAAE,IAAAL,EAAA,YAAA,QAAAK,EAAS,cAAcR;AAAA,IAAU,GAC/C,CA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EAAA,YAAA,QAAAjB,EAAS,eAAe;AAAA,IAAC,GAC1C,CAACY,CAAW,CAAC,GAEhBf,EAAU,MAAM;;AACX,MAAAgB,OACWd,IAAAkB,EAAA,YAAA,QAAAlB,EAAS,wBAAwBc;AAAA,IAAoB,GAClE,CAACA,CAAoB,CAAC,GAEzBhB,EAAU,MAAM;;AACX,MAAAiB,OACWf,IAAAkB,EAAA,YAAA,QAAAlB,EAAS,wBAAwBe;AAAA,IAAoB,GAClE,CAACA,CAAoB,CAAC,GAEzBjB,EAAU,MAAM;;AACX,MAAAkB,OACWhB,IAAAkB,EAAA,YAAA,QAAAlB,EAAS,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;"}
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 LyricLineMouseEvent,\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\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableScale?: boolean;\n\t/**\n\t * 设置是否隐藏已经播放过的歌词行,默认不隐藏\n\t */\n\thidePassedLines?: 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\t/**\n\t * 当某个歌词行被左键点击时触发的事件\n\t * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引\n\t */\n\tonLyricLineClick?: (line: LyricLineMouseEvent) => void;\n\t/**\n\t * 当某个歌词行被右键点击时触发的事件\n\t * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引\n\t */\n\tonLyricLineContextMenu?: (line: LyricLineMouseEvent) => void;\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\tenableScale,\n\t\t\thidePassedLines,\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\tonLyricLineClick,\n\t\t\tonLyricLineContextMenu,\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 !== undefined)\n\t\t\t\tcorePlayerRef.current?.setAlignAnchor(alignAnchor);\n\t\t}, [alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (hidePassedLines !== undefined)\n\t\t\t\tcorePlayerRef.current?.setHidePassedLines(hidePassedLines);\n\t\t}, [hidePassedLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignPosition !== undefined)\n\t\t\t\tcorePlayerRef.current?.setAlignPosition(alignPosition);\n\t\t}, [alignPosition]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring !== undefined)\n\t\t\t\tcorePlayerRef.current?.setEnableSpring(enableSpring);\n\t\t\telse corePlayerRef.current?.setEnableSpring(true);\n\t\t}, [enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableScale !== undefined)\n\t\t\t\tcorePlayerRef.current?.setEnableScale(enableScale);\n\t\t\telse corePlayerRef.current?.setEnableScale(true);\n\t\t}, [enableScale]);\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 !== undefined) {\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 !== undefined)\n\t\t\t\tcorePlayerRef.current?.setCurrentTime(currentTime);\n\t\t\telse corePlayerRef.current?.setCurrentTime(0);\n\t\t}, [currentTime]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams !== undefined)\n\t\t\t\tcorePlayerRef.current?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams !== undefined)\n\t\t\t\tcorePlayerRef.current?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams !== undefined)\n\t\t\t\tcorePlayerRef.current?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [lineScaleSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (onLyricLineClick) {\n\t\t\t\tconst handler = (e: Event) =>\n\t\t\t\t\tonLyricLineClick(e as LyricLineMouseEvent);\n\t\t\t\tcorePlayerRef.current?.addEventListener(\"line-click\", handler);\n\t\t\t\treturn () =>\n\t\t\t\t\tcorePlayerRef.current?.removeEventListener(\"line-click\", handler);\n\t\t\t}\n\t\t}, [onLyricLineClick]);\n\n\t\tuseEffect(() => {\n\t\t\tif (onLyricLineContextMenu) {\n\t\t\t\tconst handler = (e: Event) =>\n\t\t\t\t\tonLyricLineContextMenu(e as LyricLineMouseEvent);\n\t\t\t\tcorePlayerRef.current?.addEventListener(\"line-contextmenu\", handler);\n\t\t\t\treturn () =>\n\t\t\t\t\tcorePlayerRef.current?.removeEventListener(\n\t\t\t\t\t\t\"line-contextmenu\",\n\t\t\t\t\t\thandler,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}, [onLyricLineContextMenu]);\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","enableScale","hidePassedLines","lyricLines","currentTime","linePosXSpringParams","linePosYSpringParams","lineScaleSpringParams","bottomLine","onLyricLineClick","onLyricLineContextMenu","corePlayerRef","CoreLyricPlayer","canceled","lastTime","onFrame","time","_d","handler","e","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,UAAMC,IAAkBC,KAClBC,IAAaD,EAAuB,IAAI;AAE9C,WAAAE,EAAU,OACOH,EAAA,UAAU,IAAII,KACvB,MAAM;;AACZ,OAAAC,IAAAL,EAAgB,YAAhB,QAAAK,EAAyB;AAAA,IAAQ,IAEhC,CAAE,CAAA,GAELF,EAAU,MAAM;;AACX,MAAAX,OAA+Ba,IAAAL,EAAA,YAAA,QAAAK,EAAS,cAAcb;AAAA,IAAa,GACrE,CAACA,CAAa,CAAC,GAElBW,EAAU,MAAM;;AACX,MAAAV,OAAqBY,IAAAL,EAAA,YAAA,QAAAK,EAAS,OAAOZ;AAAA,IAAG,GAC1C,CAACA,CAAG,CAAC,GAERU,EAAU,MAAM;;AACf,MAAIT,MAAY,UACfW,IAAAL,EAAgB,YAAhB,QAAAK,EAAyB,WACfX,KACVY,IAAAN,EAAgB,YAAhB,QAAAM,EAAyB,YAEzBC,IAAAP,EAAgB,YAAhB,QAAAO,EAAyB;AAAA,IAC1B,GACE,CAACb,CAAO,CAAC,GAEZS,EAAU,MAAM;;AACX,MAAAR,OAA2BU,IAAAL,EAAA,YAAA,QAAAK,EAAS,aAAaV;AAAA,IAAS,GAC5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A;AAAA,MAC3D;AAAA,IAAA,GACE,CAACT,CAAgB,CAAC,GAErBtB,EAAU,MAAM;;AACf,UAAIuB,GAAwB;AAC3B,cAAMQ,IAAU,CAACC,MAChBT,EAAuBS,CAAwB;AAClC,gBAAA9B,IAAAsB,EAAA,YAAA,QAAAtB,EAAS,iBAAiB,oBAAoB6B,IACrD,MACN;;AAAA,kBAAA7B,IAAAsB,EAAc,YAAd,gBAAAtB,EAAuB;AAAA,YACtB;AAAA,YACA6B;AAAA;AAAA;AAAA,MAEH;AAAA,IAAA,GACE,CAACR,CAAsB,CAAC,GAE3BjB;AAAA,MACCV;AAAA,MACA,OAAO;AAAA,QACN,WAAWG,EAAW;AAAA,QACtB,aAAayB,EAAc;AAAA,MAAA;AAAA,MAE5B,CAACzB,EAAW,SAASyB,EAAc,OAAO;AAAA,IAAA,GAKzC,gBAAAS,EAAAC,GAAA,EAAA,UAAA;AAAA,MAAA,gBAAA3B,EAAC,OAAK,EAAA,GAAGZ,GAAO,KAAKI,EAAY,CAAA;AAAA,OAChCG,IAAAsB,EAAc,YAAd,QAAAtB,EAAuB,0BAA0BmB,IAC/Cc;AAAA,QACAd;AAAA,SACAlB,IAAAqB,EAAc,YAAd,gBAAArB,EAAuB;AAAA,MAAqB,IAE5C;AAAA,IACJ,EAAA,CAAA;AAAA,EAEF;AACD;"}
@@ -1,4 +1,4 @@
1
- import { LyricPlayer as CoreLyricPlayer, type LyricLine, type spring } from "@applemusic-like-lyrics/core";
1
+ import { LyricPlayer as CoreLyricPlayer, type LyricLineMouseEvent, type LyricLine, type spring } from "@applemusic-like-lyrics/core";
2
2
  import { type HTMLProps, type ReactNode } from "react";
3
3
  /**
4
4
  * 歌词播放组件的属性
@@ -37,6 +37,18 @@ export interface LyricPlayerProps {
37
37
  * 设置是否启用歌词行的模糊效果,默认为 `true`
38
38
  */
39
39
  enableBlur?: boolean;
40
+ /**
41
+ * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
42
+ *
43
+ * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行
44
+ *
45
+ * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一
46
+ */
47
+ enableScale?: boolean;
48
+ /**
49
+ * 设置是否隐藏已经播放过的歌词行,默认不隐藏
50
+ */
51
+ hidePassedLines?: boolean;
40
52
  /**
41
53
  * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误
42
54
  */
@@ -70,6 +82,16 @@ export interface LyricPlayerProps {
70
82
  * 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息
71
83
  */
72
84
  bottomLine?: ReactNode;
85
+ /**
86
+ * 当某个歌词行被左键点击时触发的事件
87
+ * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引
88
+ */
89
+ onLyricLineClick?: (line: LyricLineMouseEvent) => void;
90
+ /**
91
+ * 当某个歌词行被右键点击时触发的事件
92
+ * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引
93
+ */
94
+ onLyricLineContextMenu?: (line: LyricLineMouseEvent) => void;
73
95
  }
74
96
  /**
75
97
  * 歌词播放组件的引用
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.11",
4
+ "version": "0.0.13",
5
5
  "description": "AMLL 组件库的 React 绑定",
6
6
  "repository": {
7
7
  "url": "https://github.com/Steve-xmh/applemusic-like-lyrics.git",
@@ -15,6 +15,7 @@
15
15
  "scripts": {
16
16
  "build:docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts",
17
17
  "build": "vite build",
18
+ "build:dev": "vite build",
18
19
  "fmt": "rome format --write ./src",
19
20
  "dev": "vite dev"
20
21
  },
@@ -41,14 +42,14 @@
41
42
  "react": "^18.2.0",
42
43
  "react-dom": "^18.2.0",
43
44
  "rome": "^12.1.3",
44
- "typedoc": "^0.24.8",
45
- "typedoc-plugin-markdown": "^3.15.3",
46
- "typescript": "^5.1.6",
47
- "vite": "^4.4.7",
48
- "vite-plugin-dts": "^3.3.1"
45
+ "typedoc": "^0.25.2",
46
+ "typedoc-plugin-markdown": "^3.16.0",
47
+ "typescript": "^5.2.2",
48
+ "vite": "^4.4.11",
49
+ "vite-plugin-dts": "^3.6.0"
49
50
  },
50
51
  "dependencies": {
51
- "@applemusic-like-lyrics/core": "^0.0.11"
52
+ "@applemusic-like-lyrics/core": "^0.0.13"
52
53
  },
53
54
  "peerDependencies": {
54
55
  "react": "*",