markdown-flow-ui 0.1.100-beta.21 → 0.1.100-beta.23
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/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/_virtual/index.cjs10.js +1 -1
- package/dist/_virtual/index.cjs11.js +1 -1
- package/dist/_virtual/index.cjs7.js +1 -1
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es10.js +2 -3
- package/dist/_virtual/index.es10.js.map +1 -1
- package/dist/_virtual/index.es11.js +3 -2
- package/dist/_virtual/index.es11.js.map +1 -1
- package/dist/_virtual/index.es7.js +2 -2
- package/dist/_virtual/index.es8.js +3 -2
- package/dist/_virtual/index.es8.js.map +1 -1
- package/dist/_virtual/index.es9.js +2 -3
- package/dist/_virtual/index.es9.js.map +1 -1
- package/dist/components/Slide/Player.cjs.js +1 -1
- package/dist/components/Slide/Player.cjs.js.map +1 -1
- package/dist/components/Slide/Player.es.js +86 -86
- package/dist/components/Slide/Player.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.es.js +39 -39
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),$=require("../../lib/utils.cjs.js");;/* empty css */const ie=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js"),oe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js"),fe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js"),de=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js"),me=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js"),pe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),$=require("../../lib/utils.cjs.js");;/* empty css */const ie=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js"),oe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js"),fe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js"),de=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js"),me=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js"),pe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js"),z=new Map,O=g=>{if(typeof window>"u"||!g||z.has(g))return;const _=window.document.createElement("audio");_.preload="auto",_.setAttribute("playsinline","true"),_.src=g,_.load(),z.set(g,_)},xe=()=>t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[t.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),t.jsxRuntimeExports.jsx("path",{d:"M12 10H16V24H12V10ZM18 10H22V24H18V10Z",fill:"white"})]}),he=()=>t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[t.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),t.jsxRuntimeExports.jsx("path",{d:"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z",fill:"white"})]}),Re=({audioList:g=[],className:_,currentAudioIndex:a=-1,defaultPlaying:f=!0,onLoadingChange:q,onPrev:G,onNext:J,onFullscreen:Q,onEnded:P,onPlayRequest:U,onInteractionToggle:X,hasInteraction:Y=!1,isInteractionOpen:D=!1,prevDisabled:I=!1,nextDisabled:ee=!1,showControls:re=!0,...te})=>{const x=r.useRef(null),b=r.useRef(null),V=r.useRef(null),E=r.useRef(0),o=r.useRef(null),F=r.useRef(void 0),v=r.useRef([]),K=r.useRef(!1),i=r.useRef(!1),S=r.useRef(null),p=r.useRef(!1),u=r.useRef(!1),m=r.useRef(null),h=r.useRef(!1),[T,l]=r.useState(f),d=a>=0?g[a]:void 0,C=d?.audioUrl,R=r.useMemo(()=>[...d?.audioSegments??[]].sort((e,c)=>e.segment_index-c.segment_index),[d?.audioSegments]),W=`${a}:${d?.audioKey??"none"}`;r.useEffect(()=>{F.current=d},[d]),r.useEffect(()=>{v.current=R},[R]),r.useEffect(()=>{const e=d?.audioUrl,c=a>=0?g[a+1]?.audioUrl:void 0;O(e),O(c)},[g,d?.audioUrl,a]);const n=r.useCallback(e=>{K.current!==e&&(K.current=e,q?.(e))},[q]),Z=r.useCallback(e=>e?e.startsWith("data:")?e:`data:audio/mpeg;base64,${e}`:"",[]),B=r.useCallback(()=>{const e=o.current;return e==null||e<=0?0:v.current.slice(0,e).reduce((c,s)=>c+Math.max(Number(s.duration_ms??0),0),0)/1e3},[]),N=r.useCallback(()=>{const e=x.current;e&&(u.current=!1,i.current=!1,S.current=null,m.current=null,p.current=!1,h.current=!1,e.pause(),e.removeAttribute("src"),e.load(),b.current=null,E.current=0,o.current=null,l(!1),n(!1))},[n]),j=r.useCallback(e=>{const c=x.current;if(!c)return!1;const s=c.play();return s&&typeof s.then=="function"&&s.then(()=>{u.current=!1,h.current=!1}).catch(w=>{l(!1)}),!0},[a]),k=r.useCallback((e,c)=>{const s=x.current,w=v.current[e];if(!s||!w)return!1;const y=Z(w.audio_data);E.current=e,o.current=null,p.current=!1,h.current=!0;const M=f&&!i.current;u.current=M,n(!1);const L=b.current!==y;return S.current="segment",L&&(s.pause(),s.removeAttribute("src"),s.load(),b.current=y,s.src=y,s.load()),m.current=0,s.readyState>0&&(s.currentTime=0,m.current=null),M?L?!0:j(`start-segment:${c}`):(u.current=!1,h.current=!1,s.pause(),l(!1),!0)},[f,Z,j,n]),A=r.useCallback(e=>{u.current=!1,p.current=!1,h.current=!1,l(!1),n(!1),a>=0&&P?.(a)},[a,P,n]),H=r.useCallback(()=>{const e=E.current+1,c=v.current,s=c[e],w=F.current,y=c.some(M=>M.is_final);if(s){k(e,"ended");return}if(w?.isAudioStreaming||!y){E.current=e,o.current=e,p.current=!0,u.current=f,l(!1),n(!0);return}A("segments-completed")},[f,A,k,n]);r.useEffect(()=>{if(V.current===W)return;V.current=W,E.current=0,o.current=null,p.current=!1,i.current=!1,u.current=!1,h.current=!1,S.current=null,b.current=null,n(!1);const e=x.current;e&&(e.pause(),e.removeAttribute("src"),e.load(),l(!1))},[a,W,R.length,C,n]),r.useEffect(()=>{const e=x.current;if(e){if(!d){N();return}if(C){const c=b.current!==C,s=f&&!i.current;if(S.current==="segment"&&!!b.current&&o.current===null){if(!s){u.current=!1,e.pause(),l(!1);return}e.paused&&(u.current=!0,j("keep-segment-source"));return}if(c){const y=o.current!==null?B():0;e.pause(),e.removeAttribute("src"),e.load(),b.current=C,S.current="url",e.src=C,e.load(),m.current=y,e.readyState>0&&(e.currentTime=y,m.current=null)}if(u.current=s,p.current=!1,h.current=!1,n(!1),!s){u.current=!1,e.pause(),l(!1);return}c||j("sync-url");return}if(o.current!==null){if(o.current<R.length){if(i.current){l(!1),n(!1);return}k(o.current,"wait-resume");return}p.current=!0,u.current=f&&!i.current,l(!1),n(!i.current);return}if(!R.length){if(d.isAudioStreaming){o.current=E.current,p.current=!0,u.current=f&&!i.current,l(!1),n(!i.current);return}N();return}if(!b.current){k(Math.min(E.current,R.length-1),"effect-init");return}if(!f||i.current){u.current=!1,e.pause(),l(!1);return}e.paused&&(u.current=!0,j("sync-paused-retry"))}},[d,a,R,C,f,N,k,j,B,n]),r.useEffect(()=>N,[N]);const ne=r.useCallback(()=>{l(!0),n(!1)},[n]),se=r.useCallback(()=>{p.current||h.current||l(!1)},[a]),ue=r.useCallback(()=>{const e=x.current;e&&m.current!==null&&(e.currentTime=m.current,m.current=null),!(!u.current||!f)&&j("canplay")},[a,f,j]),le=r.useCallback(()=>{const e=x.current;e&&m.current!==null&&(e.currentTime=m.current,m.current=null)},[a]),ce=r.useCallback(()=>{const e=S.current==="url"||v.current.length===0;if(h.current=!1,e){A("url-ended");return}H()},[A,H]),ae=r.useCallback(()=>{l(!1),n(!1)},[n]);return t.jsxRuntimeExports.jsxs("div",{className:$.cn("slide-player",_),...te,children:[t.jsxRuntimeExports.jsx("audio",{ref:x,preload:"auto",playsInline:!0,onLoadedMetadata:le,onCanPlay:ue,onPlay:ne,onPause:se,onEnded:ce,onError:ae}),re?t.jsxRuntimeExports.jsxs("div",{className:"slide-player__controls",children:[t.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[t.jsxRuntimeExports.jsx("button",{"aria-label":"More options",className:"hidden",type:"button",children:t.jsxRuntimeExports.jsx(ie.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Volume",className:"hidden",type:"button",children:t.jsxRuntimeExports.jsx(oe.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Rewind",className:"slide-player__action",disabled:I,onClick:G,type:"button",children:t.jsxRuntimeExports.jsx(fe.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":T?"Pause":"Play",className:"slide-player__toggle",onClick:()=>{const e=x.current;if(!(!e||!d)){if(o.current!==null){if(T){u.current=!1,i.current=!0,o.current=null,p.current=!1,l(!1),n(!1),e.pause();return}U?.(),i.current=!1,u.current=!0,n(!0);return}if(!e.src&&R.length>0){U?.(),i.current=!1,k(Math.min(E.current,R.length-1),"toggle");return}if(e.paused){U?.(),i.current=!1,u.current=!0,j("toggle-resume");return}u.current=!1,i.current=!0,e.pause()}},type:"button",children:T?t.jsxRuntimeExports.jsx(xe,{}):t.jsxRuntimeExports.jsx(he,{})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Forward",className:"slide-player__action",disabled:ee,onClick:J,type:"button",children:t.jsxRuntimeExports.jsx(de.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Fullscreen",className:"hidden",onClick:Q,type:"button",children:t.jsxRuntimeExports.jsx(me.default,{className:"slide-player__icon",strokeWidth:2.25})})]}),t.jsxRuntimeExports.jsx("div",{className:"slide-player__separator"}),t.jsxRuntimeExports.jsx("div",{className:"slide-player__group",children:t.jsxRuntimeExports.jsx("button",{"aria-label":"Notes",className:$.cn("slide-player__action",D&&"slide-player__action--active"),disabled:!Y,onClick:X,type:"button",children:t.jsxRuntimeExports.jsx(pe.default,{className:"slide-player__icon",strokeWidth:2.25})})})]}):null]})};exports.default=Re;
|
|
2
2
|
//# sourceMappingURL=Player.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.cjs.js","sources":["../../../src/components/Slide/Player.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n EllipsisVertical,\n FilePenLine,\n Maximize,\n RotateCcw,\n RotateCw,\n Volume2,\n} from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport type { SlideAudioItem } from \"./useSlide\";\nimport \"./player.css\";\n\nconst audioPreloadLinkCache = new Set<string>();\n\nconst preloadAudioUrl = (url?: string) => {\n if (\n typeof document === \"undefined\" ||\n !url ||\n audioPreloadLinkCache.has(url)\n ) {\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"preload\";\n link.as = \"audio\";\n link.href = url;\n if (/^https?:/i.test(url)) {\n link.crossOrigin = \"anonymous\";\n }\n document.head.appendChild(link);\n audioPreloadLinkCache.add(url);\n};\n\nexport type PlayerProps = React.ComponentProps<\"div\"> & {\n audioList?: SlideAudioItem[];\n currentAudioIndex?: number;\n defaultPlaying?: boolean;\n onLoadingChange?: (loading: boolean) => void;\n onPrev?: () => void;\n onNext?: () => void;\n onFullscreen?: () => void;\n onEnded?: (audioIndex: number) => void;\n onPlayRequest?: () => void;\n onInteractionToggle?: () => void;\n hasInteraction?: boolean;\n isInteractionOpen?: boolean;\n prevDisabled?: boolean;\n nextDisabled?: boolean;\n showControls?: boolean;\n};\n\nconst PauseIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M12 10H16V24H12V10ZM18 10H22V24H18V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst PlayIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst Player: React.FC<PlayerProps> = ({\n audioList = [],\n className,\n currentAudioIndex = -1,\n defaultPlaying = true,\n onLoadingChange,\n onPrev,\n onNext,\n onFullscreen,\n onEnded,\n onPlayRequest,\n onInteractionToggle,\n hasInteraction = false,\n isInteractionOpen = false,\n prevDisabled = false,\n nextDisabled = false,\n showControls = true,\n ...props\n}) => {\n const audioRef = useRef<HTMLAudioElement | null>(null);\n const audioSrcRef = useRef<string | null>(null);\n const currentAudioKeyRef = useRef<string | null>(null);\n const currentSegmentIndexRef = useRef(0);\n const waitingSegmentIndexRef = useRef<number | null>(null);\n const currentAudioRef = useRef<SlideAudioItem | undefined>(undefined);\n const currentAudioSegmentsRef = useRef<\n NonNullable<SlideAudioItem[\"audioSegments\"]>\n >([]);\n const isLoadingRef = useRef(false);\n const isPausedByUserRef = useRef(false);\n const activeSourceTypeRef = useRef<\"url\" | \"segment\" | null>(null);\n const isWaitingForSegmentRef = useRef(false);\n const pendingAutoPlayRef = useRef(false);\n const pendingSeekTimeRef = useRef<number | null>(null);\n const isSwitchingSegmentRef = useRef(false);\n const [isPlaying, setIsPlaying] = useState(defaultPlaying);\n const currentAudio =\n currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined;\n const currentAudioUrl = currentAudio?.audioUrl;\n const currentAudioSegments = useMemo(\n () =>\n [...(currentAudio?.audioSegments ?? [])].sort(\n (prevSegment, nextSegment) =>\n prevSegment.segment_index - nextSegment.segment_index\n ),\n [currentAudio?.audioSegments]\n );\n const currentAudioKey = `${currentAudioIndex}:${currentAudio?.audioKey ?? \"none\"}`;\n\n useEffect(() => {\n currentAudioRef.current = currentAudio;\n }, [currentAudio]);\n\n useEffect(() => {\n currentAudioSegmentsRef.current = currentAudioSegments;\n }, [currentAudioSegments]);\n\n useEffect(() => {\n const currentUrl = currentAudio?.audioUrl;\n const nextUrl =\n currentAudioIndex >= 0\n ? audioList[currentAudioIndex + 1]?.audioUrl\n : undefined;\n\n preloadAudioUrl(currentUrl);\n preloadAudioUrl(nextUrl);\n }, [audioList, currentAudio?.audioUrl, currentAudioIndex]);\n\n const updateLoading = useCallback(\n (loading: boolean) => {\n if (isLoadingRef.current === loading) {\n return;\n }\n\n isLoadingRef.current = loading;\n onLoadingChange?.(loading);\n },\n [onLoadingChange]\n );\n\n const getSegmentSrc = useCallback((audioData: string) => {\n if (!audioData) {\n return \"\";\n }\n\n if (audioData.startsWith(\"data:\")) {\n return audioData;\n }\n\n return `data:audio/mpeg;base64,${audioData}`;\n }, []);\n\n const getWaitingSegmentSeekTime = useCallback(() => {\n const waitingSegmentIndex = waitingSegmentIndexRef.current;\n\n if (waitingSegmentIndex == null || waitingSegmentIndex <= 0) {\n return 0;\n }\n\n return (\n currentAudioSegmentsRef.current\n .slice(0, waitingSegmentIndex)\n .reduce(\n (totalDurationMs, segment) =>\n totalDurationMs + Math.max(Number(segment.duration_ms ?? 0), 0),\n 0\n ) / 1000\n );\n }, []);\n\n const resetAudio = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = false;\n activeSourceTypeRef.current = null;\n pendingSeekTimeRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = null;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n setIsPlaying(false);\n updateLoading(false);\n }, [updateLoading]);\n\n const tryPlayCurrentAudio = useCallback(\n (_reason: string) => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return false;\n }\n\n const playPromise = audioElement.play();\n\n if (playPromise && typeof playPromise.then === \"function\") {\n void playPromise\n .then(() => {\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n })\n .catch((_error: unknown) => {\n setIsPlaying(false);\n });\n }\n\n return true;\n },\n [currentAudioIndex]\n );\n\n const startSegmentPlayback = useCallback(\n (segmentIndex: number, _reason: string) => {\n const audioElement = audioRef.current;\n const segment = currentAudioSegmentsRef.current[segmentIndex];\n\n if (!audioElement || !segment) {\n return false;\n }\n\n const nextAudioSrc = getSegmentSrc(segment.audio_data);\n\n currentSegmentIndexRef.current = segmentIndex;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = true;\n const shouldAutoResume = defaultPlaying && !isPausedByUserRef.current;\n\n pendingAutoPlayRef.current = shouldAutoResume;\n updateLoading(false);\n\n const hasNewSrc = audioSrcRef.current !== nextAudioSrc;\n\n activeSourceTypeRef.current = \"segment\";\n\n if (hasNewSrc) {\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = nextAudioSrc;\n audioElement.src = nextAudioSrc;\n audioElement.load();\n }\n\n pendingSeekTimeRef.current = 0;\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = 0;\n pendingSeekTimeRef.current = null;\n }\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return true;\n }\n\n if (hasNewSrc) {\n return true;\n }\n\n return tryPlayCurrentAudio(`start-segment:${_reason}`);\n },\n [defaultPlaying, getSegmentSrc, tryPlayCurrentAudio, updateLoading]\n );\n\n const finishAudioItem = useCallback(\n (_reason?: string) => {\n pendingAutoPlayRef.current = false;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n setIsPlaying(false);\n updateLoading(false);\n\n if (currentAudioIndex >= 0) {\n onEnded?.(currentAudioIndex);\n }\n },\n [currentAudioIndex, onEnded, updateLoading]\n );\n\n const handleSegmentEnded = useCallback(() => {\n const nextSegmentIndex = currentSegmentIndexRef.current + 1;\n const segments = currentAudioSegmentsRef.current;\n const nextSegment = segments[nextSegmentIndex];\n const activeAudio = currentAudioRef.current;\n const hasFinal = segments.some((segment) => segment.is_final);\n\n if (nextSegment) {\n startSegmentPlayback(nextSegmentIndex, \"ended\");\n return;\n }\n\n if (activeAudio?.isAudioStreaming || !hasFinal) {\n currentSegmentIndexRef.current = nextSegmentIndex;\n waitingSegmentIndexRef.current = nextSegmentIndex;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n setIsPlaying(false);\n updateLoading(true);\n\n return;\n }\n\n finishAudioItem(\"segments-completed\");\n }, [defaultPlaying, finishAudioItem, startSegmentPlayback, updateLoading]);\n\n useEffect(() => {\n if (currentAudioKeyRef.current === currentAudioKey) {\n return;\n }\n\n currentAudioKeyRef.current = currentAudioKey;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n activeSourceTypeRef.current = null;\n audioSrcRef.current = null;\n updateLoading(false);\n\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n setIsPlaying(false);\n }, [\n currentAudioIndex,\n currentAudioKey,\n currentAudioSegments.length,\n currentAudioUrl,\n updateLoading,\n ]);\n\n useEffect(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n if (!currentAudio) {\n resetAudio();\n return;\n }\n\n if (currentAudioUrl) {\n const hasNewSrc = audioSrcRef.current !== currentAudioUrl;\n const shouldAutoResume = defaultPlaying && !isPausedByUserRef.current;\n const shouldKeepSegmentSource =\n activeSourceTypeRef.current === \"segment\" &&\n Boolean(audioSrcRef.current) &&\n waitingSegmentIndexRef.current === null;\n\n if (shouldKeepSegmentSource) {\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"keep-segment-source\");\n }\n\n return;\n }\n\n if (hasNewSrc) {\n const nextSeekTime =\n waitingSegmentIndexRef.current !== null\n ? getWaitingSegmentSeekTime()\n : 0;\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = currentAudioUrl;\n activeSourceTypeRef.current = \"url\";\n audioElement.src = currentAudioUrl;\n audioElement.load();\n pendingSeekTimeRef.current = nextSeekTime;\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = nextSeekTime;\n pendingSeekTimeRef.current = null;\n }\n }\n\n pendingAutoPlayRef.current = shouldAutoResume;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n updateLoading(false);\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (!hasNewSrc) {\n tryPlayCurrentAudio(\"sync-url\");\n }\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (waitingSegmentIndexRef.current < currentAudioSegments.length) {\n if (isPausedByUserRef.current) {\n setIsPlaying(false);\n updateLoading(false);\n return;\n }\n\n startSegmentPlayback(waitingSegmentIndexRef.current, \"wait-resume\");\n return;\n }\n\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying && !isPausedByUserRef.current;\n setIsPlaying(false);\n updateLoading(!isPausedByUserRef.current);\n return;\n }\n\n if (!currentAudioSegments.length) {\n if (currentAudio.isAudioStreaming) {\n waitingSegmentIndexRef.current = currentSegmentIndexRef.current;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current =\n defaultPlaying && !isPausedByUserRef.current;\n setIsPlaying(false);\n updateLoading(!isPausedByUserRef.current);\n return;\n }\n\n resetAudio();\n return;\n }\n\n if (!audioSrcRef.current) {\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"effect-init\"\n );\n return;\n }\n\n if (!defaultPlaying || isPausedByUserRef.current) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"sync-paused-retry\");\n }\n }, [\n currentAudio,\n currentAudioIndex,\n currentAudioSegments,\n currentAudioUrl,\n defaultPlaying,\n resetAudio,\n startSegmentPlayback,\n tryPlayCurrentAudio,\n getWaitingSegmentSeekTime,\n updateLoading,\n ]);\n\n useEffect(() => resetAudio, [resetAudio]);\n\n const handleAudioPlay = useCallback(() => {\n setIsPlaying(true);\n updateLoading(false);\n }, [updateLoading]);\n\n const handleAudioPause = useCallback(() => {\n if (isWaitingForSegmentRef.current || isSwitchingSegmentRef.current) {\n return;\n }\n\n setIsPlaying(false);\n }, [currentAudioIndex]);\n\n const handleAudioCanPlay = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n\n if (!pendingAutoPlayRef.current || !defaultPlaying) {\n return;\n }\n\n tryPlayCurrentAudio(\"canplay\");\n }, [currentAudioIndex, defaultPlaying, tryPlayCurrentAudio]);\n\n const handleLoadedMetadata = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n }, [currentAudioIndex]);\n\n const handleAudioEnded = useCallback(() => {\n const shouldFinishAsUrl =\n activeSourceTypeRef.current === \"url\" ||\n currentAudioSegmentsRef.current.length === 0;\n\n isSwitchingSegmentRef.current = false;\n\n if (shouldFinishAsUrl) {\n finishAudioItem(\"url-ended\");\n return;\n }\n\n handleSegmentEnded();\n }, [finishAudioItem, handleSegmentEnded]);\n\n const handleAudioError = useCallback(() => {\n setIsPlaying(false);\n updateLoading(false);\n }, [updateLoading]);\n\n return (\n <div className={cn(\"slide-player\", className)} {...props}>\n <audio\n ref={audioRef}\n preload=\"auto\"\n playsInline\n onLoadedMetadata={handleLoadedMetadata}\n onCanPlay={handleAudioCanPlay}\n onPlay={handleAudioPlay}\n onPause={handleAudioPause}\n onEnded={handleAudioEnded}\n onError={handleAudioError}\n />\n\n {showControls ? (\n <div className=\"slide-player__controls\">\n <div className=\"slide-player__group\">\n <button aria-label=\"More options\" className=\"hidden\" type=\"button\">\n <EllipsisVertical\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n </button>\n <button aria-label=\"Volume\" className=\"hidden\" type=\"button\">\n <Volume2 className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label=\"Rewind\"\n className=\"slide-player__action\"\n disabled={prevDisabled}\n onClick={onPrev}\n type=\"button\"\n >\n <RotateCcw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label={isPlaying ? \"Pause\" : \"Play\"}\n className=\"slide-player__toggle\"\n onClick={() => {\n const audioElement = audioRef.current;\n\n if (!audioElement || !currentAudio) {\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (isPlaying) {\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n setIsPlaying(false);\n updateLoading(false);\n audioElement.pause();\n return;\n }\n\n onPlayRequest?.();\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n updateLoading(true);\n return;\n }\n\n if (!audioElement.src && currentAudioSegments.length > 0) {\n // Only the player play button can unlock playback when autoplay is unavailable.\n onPlayRequest?.();\n isPausedByUserRef.current = false;\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"toggle\"\n );\n return;\n }\n\n if (audioElement.paused) {\n onPlayRequest?.();\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"toggle-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n audioElement.pause();\n }}\n type=\"button\"\n >\n {isPlaying ? <PauseIcon /> : <PlayIcon />}\n </button>\n <button\n aria-label=\"Forward\"\n className=\"slide-player__action\"\n disabled={nextDisabled}\n onClick={onNext}\n type=\"button\"\n >\n <RotateCw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label=\"Fullscreen\"\n className=\"hidden\"\n onClick={onFullscreen}\n type=\"button\"\n >\n <Maximize className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n </div>\n\n <div className=\"slide-player__separator\" />\n\n <div className=\"slide-player__group\">\n <button\n aria-label=\"Notes\"\n className={cn(\n \"slide-player__action\",\n isInteractionOpen && \"slide-player__action--active\"\n )}\n disabled={!hasInteraction}\n onClick={onInteractionToggle}\n type=\"button\"\n >\n <FilePenLine className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Player;\n"],"names":["audioPreloadLinkCache","preloadAudioUrl","url","link","PauseIcon","jsxs","jsx","PlayIcon","Player","audioList","className","currentAudioIndex","defaultPlaying","onLoadingChange","onPrev","onNext","onFullscreen","onEnded","onPlayRequest","onInteractionToggle","hasInteraction","isInteractionOpen","prevDisabled","nextDisabled","showControls","props","audioRef","useRef","audioSrcRef","currentAudioKeyRef","currentSegmentIndexRef","waitingSegmentIndexRef","currentAudioRef","currentAudioSegmentsRef","isLoadingRef","isPausedByUserRef","activeSourceTypeRef","isWaitingForSegmentRef","pendingAutoPlayRef","pendingSeekTimeRef","isSwitchingSegmentRef","isPlaying","setIsPlaying","useState","currentAudio","currentAudioUrl","currentAudioSegments","useMemo","prevSegment","nextSegment","currentAudioKey","useEffect","currentUrl","nextUrl","updateLoading","useCallback","loading","getSegmentSrc","audioData","getWaitingSegmentSeekTime","waitingSegmentIndex","totalDurationMs","segment","resetAudio","audioElement","tryPlayCurrentAudio","_reason","playPromise","_error","startSegmentPlayback","segmentIndex","nextAudioSrc","shouldAutoResume","hasNewSrc","finishAudioItem","handleSegmentEnded","nextSegmentIndex","segments","activeAudio","hasFinal","nextSeekTime","handleAudioPlay","handleAudioPause","handleAudioCanPlay","handleLoadedMetadata","handleAudioEnded","shouldFinishAsUrl","handleAudioError","cn","EllipsisVertical","Volume2","RotateCcw","RotateCw","Maximize","FilePenLine"],"mappings":"kvCAoBMA,MAA4B,IAE5BC,EAAmBC,GAAiB,CACxC,GACE,OAAO,SAAa,KACpB,CAACA,GACDF,EAAsB,IAAIE,CAAG,EAE7B,OAGF,MAAMC,EAAO,SAAS,cAAc,MAAM,EAC1CA,EAAK,IAAM,UACXA,EAAK,GAAK,QACVA,EAAK,KAAOD,EACR,YAAY,KAAKA,CAAG,IACtBC,EAAK,YAAc,aAErB,SAAS,KAAK,YAAYA,CAAI,EAC9BH,EAAsB,IAAIE,CAAG,CAC/B,EAoBME,GAAY,IAChBC,EAAAA,kBAAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OAEL,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,OAAA,CACC,EAAE,gLACF,KAAK,SAAA,CAAA,EAEPA,EAAAA,kBAAAA,IAAC,OAAA,CAAK,EAAE,yCAAyC,KAAK,OAAA,CAAQ,CAAA,CAAA,CAChE,EAGIC,GAAW,IACfF,EAAAA,kBAAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OAEL,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,OAAA,CACC,EAAE,gLACF,KAAK,SAAA,CAAA,EAEPA,EAAAA,kBAAAA,IAAC,OAAA,CAAK,EAAE,kDAAkD,KAAK,OAAA,CAAQ,CAAA,CAAA,CACzE,EAGIE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U,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,EAE9DtF,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,aACX,UAAU,SACV,QAASU,EACT,KAAK,SAEL,SAAAV,EAAAA,kBAAAA,IAACuF,WAAA,CAAS,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,CAC9D,EACF,EAEAvF,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yBAAA,CAA0B,EAEzCA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,sBACb,SAAAA,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,QACX,UAAWkF,EAAAA,GACT,uBACAnE,GAAqB,8BAAA,EAEvB,SAAU,CAACD,EACX,QAASD,EACT,KAAK,SAEL,SAAAb,EAAAA,kBAAAA,IAACwF,WAAA,CAAY,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,CACjE,CACF,CAAA,CAAA,CACF,EACE,IAAA,EACN,CAEJ"}
|
|
1
|
+
{"version":3,"file":"Player.cjs.js","sources":["../../../src/components/Slide/Player.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n EllipsisVertical,\n FilePenLine,\n Maximize,\n RotateCcw,\n RotateCw,\n Volume2,\n} from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport type { SlideAudioItem } from \"./useSlide\";\nimport \"./player.css\";\n\nconst audioPreloadElementCache = new Map<string, HTMLAudioElement>();\n\nconst preloadAudioUrl = (url?: string) => {\n if (typeof window === \"undefined\" || !url) {\n return;\n }\n\n if (audioPreloadElementCache.has(url)) {\n return;\n }\n\n // Use a detached audio element so warm-up follows the same media loading\n // path as the visible player instead of relying on link preload hints.\n const audio = window.document.createElement(\"audio\");\n audio.preload = \"auto\";\n audio.setAttribute(\"playsinline\", \"true\");\n audio.src = url;\n audio.load();\n\n audioPreloadElementCache.set(url, audio);\n};\n\nexport type PlayerProps = React.ComponentProps<\"div\"> & {\n audioList?: SlideAudioItem[];\n currentAudioIndex?: number;\n defaultPlaying?: boolean;\n onLoadingChange?: (loading: boolean) => void;\n onPrev?: () => void;\n onNext?: () => void;\n onFullscreen?: () => void;\n onEnded?: (audioIndex: number) => void;\n onPlayRequest?: () => void;\n onInteractionToggle?: () => void;\n hasInteraction?: boolean;\n isInteractionOpen?: boolean;\n prevDisabled?: boolean;\n nextDisabled?: boolean;\n showControls?: boolean;\n};\n\nconst PauseIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M12 10H16V24H12V10ZM18 10H22V24H18V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst PlayIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst Player: React.FC<PlayerProps> = ({\n audioList = [],\n className,\n currentAudioIndex = -1,\n defaultPlaying = true,\n onLoadingChange,\n onPrev,\n onNext,\n onFullscreen,\n onEnded,\n onPlayRequest,\n onInteractionToggle,\n hasInteraction = false,\n isInteractionOpen = false,\n prevDisabled = false,\n nextDisabled = false,\n showControls = true,\n ...props\n}) => {\n const audioRef = useRef<HTMLAudioElement | null>(null);\n const audioSrcRef = useRef<string | null>(null);\n const currentAudioKeyRef = useRef<string | null>(null);\n const currentSegmentIndexRef = useRef(0);\n const waitingSegmentIndexRef = useRef<number | null>(null);\n const currentAudioRef = useRef<SlideAudioItem | undefined>(undefined);\n const currentAudioSegmentsRef = useRef<\n NonNullable<SlideAudioItem[\"audioSegments\"]>\n >([]);\n const isLoadingRef = useRef(false);\n const isPausedByUserRef = useRef(false);\n const activeSourceTypeRef = useRef<\"url\" | \"segment\" | null>(null);\n const isWaitingForSegmentRef = useRef(false);\n const pendingAutoPlayRef = useRef(false);\n const pendingSeekTimeRef = useRef<number | null>(null);\n const isSwitchingSegmentRef = useRef(false);\n const [isPlaying, setIsPlaying] = useState(defaultPlaying);\n const currentAudio =\n currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined;\n const currentAudioUrl = currentAudio?.audioUrl;\n const currentAudioSegments = useMemo(\n () =>\n [...(currentAudio?.audioSegments ?? [])].sort(\n (prevSegment, nextSegment) =>\n prevSegment.segment_index - nextSegment.segment_index\n ),\n [currentAudio?.audioSegments]\n );\n const currentAudioKey = `${currentAudioIndex}:${currentAudio?.audioKey ?? \"none\"}`;\n\n useEffect(() => {\n currentAudioRef.current = currentAudio;\n }, [currentAudio]);\n\n useEffect(() => {\n currentAudioSegmentsRef.current = currentAudioSegments;\n }, [currentAudioSegments]);\n\n useEffect(() => {\n const currentUrl = currentAudio?.audioUrl;\n const nextUrl =\n currentAudioIndex >= 0\n ? audioList[currentAudioIndex + 1]?.audioUrl\n : undefined;\n\n preloadAudioUrl(currentUrl);\n preloadAudioUrl(nextUrl);\n }, [audioList, currentAudio?.audioUrl, currentAudioIndex]);\n\n const updateLoading = useCallback(\n (loading: boolean) => {\n if (isLoadingRef.current === loading) {\n return;\n }\n\n isLoadingRef.current = loading;\n onLoadingChange?.(loading);\n },\n [onLoadingChange]\n );\n\n const getSegmentSrc = useCallback((audioData: string) => {\n if (!audioData) {\n return \"\";\n }\n\n if (audioData.startsWith(\"data:\")) {\n return audioData;\n }\n\n return `data:audio/mpeg;base64,${audioData}`;\n }, []);\n\n const getWaitingSegmentSeekTime = useCallback(() => {\n const waitingSegmentIndex = waitingSegmentIndexRef.current;\n\n if (waitingSegmentIndex == null || waitingSegmentIndex <= 0) {\n return 0;\n }\n\n return (\n currentAudioSegmentsRef.current\n .slice(0, waitingSegmentIndex)\n .reduce(\n (totalDurationMs, segment) =>\n totalDurationMs + Math.max(Number(segment.duration_ms ?? 0), 0),\n 0\n ) / 1000\n );\n }, []);\n\n const resetAudio = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = false;\n activeSourceTypeRef.current = null;\n pendingSeekTimeRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = null;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n setIsPlaying(false);\n updateLoading(false);\n }, [updateLoading]);\n\n const tryPlayCurrentAudio = useCallback(\n (_reason: string) => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return false;\n }\n\n const playPromise = audioElement.play();\n\n if (playPromise && typeof playPromise.then === \"function\") {\n void playPromise\n .then(() => {\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n })\n .catch((_error: unknown) => {\n setIsPlaying(false);\n });\n }\n\n return true;\n },\n [currentAudioIndex]\n );\n\n const startSegmentPlayback = useCallback(\n (segmentIndex: number, _reason: string) => {\n const audioElement = audioRef.current;\n const segment = currentAudioSegmentsRef.current[segmentIndex];\n\n if (!audioElement || !segment) {\n return false;\n }\n\n const nextAudioSrc = getSegmentSrc(segment.audio_data);\n\n currentSegmentIndexRef.current = segmentIndex;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = true;\n const shouldAutoResume = defaultPlaying && !isPausedByUserRef.current;\n\n pendingAutoPlayRef.current = shouldAutoResume;\n updateLoading(false);\n\n const hasNewSrc = audioSrcRef.current !== nextAudioSrc;\n\n activeSourceTypeRef.current = \"segment\";\n\n if (hasNewSrc) {\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = nextAudioSrc;\n audioElement.src = nextAudioSrc;\n audioElement.load();\n }\n\n pendingSeekTimeRef.current = 0;\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = 0;\n pendingSeekTimeRef.current = null;\n }\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return true;\n }\n\n if (hasNewSrc) {\n return true;\n }\n\n return tryPlayCurrentAudio(`start-segment:${_reason}`);\n },\n [defaultPlaying, getSegmentSrc, tryPlayCurrentAudio, updateLoading]\n );\n\n const finishAudioItem = useCallback(\n (_reason?: string) => {\n pendingAutoPlayRef.current = false;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n setIsPlaying(false);\n updateLoading(false);\n\n if (currentAudioIndex >= 0) {\n onEnded?.(currentAudioIndex);\n }\n },\n [currentAudioIndex, onEnded, updateLoading]\n );\n\n const handleSegmentEnded = useCallback(() => {\n const nextSegmentIndex = currentSegmentIndexRef.current + 1;\n const segments = currentAudioSegmentsRef.current;\n const nextSegment = segments[nextSegmentIndex];\n const activeAudio = currentAudioRef.current;\n const hasFinal = segments.some((segment) => segment.is_final);\n\n if (nextSegment) {\n startSegmentPlayback(nextSegmentIndex, \"ended\");\n return;\n }\n\n if (activeAudio?.isAudioStreaming || !hasFinal) {\n currentSegmentIndexRef.current = nextSegmentIndex;\n waitingSegmentIndexRef.current = nextSegmentIndex;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n setIsPlaying(false);\n updateLoading(true);\n\n return;\n }\n\n finishAudioItem(\"segments-completed\");\n }, [defaultPlaying, finishAudioItem, startSegmentPlayback, updateLoading]);\n\n useEffect(() => {\n if (currentAudioKeyRef.current === currentAudioKey) {\n return;\n }\n\n currentAudioKeyRef.current = currentAudioKey;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n activeSourceTypeRef.current = null;\n audioSrcRef.current = null;\n updateLoading(false);\n\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n setIsPlaying(false);\n }, [\n currentAudioIndex,\n currentAudioKey,\n currentAudioSegments.length,\n currentAudioUrl,\n updateLoading,\n ]);\n\n useEffect(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n if (!currentAudio) {\n resetAudio();\n return;\n }\n\n if (currentAudioUrl) {\n const hasNewSrc = audioSrcRef.current !== currentAudioUrl;\n const shouldAutoResume = defaultPlaying && !isPausedByUserRef.current;\n const shouldKeepSegmentSource =\n activeSourceTypeRef.current === \"segment\" &&\n Boolean(audioSrcRef.current) &&\n waitingSegmentIndexRef.current === null;\n\n if (shouldKeepSegmentSource) {\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"keep-segment-source\");\n }\n\n return;\n }\n\n if (hasNewSrc) {\n const nextSeekTime =\n waitingSegmentIndexRef.current !== null\n ? getWaitingSegmentSeekTime()\n : 0;\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = currentAudioUrl;\n activeSourceTypeRef.current = \"url\";\n audioElement.src = currentAudioUrl;\n audioElement.load();\n pendingSeekTimeRef.current = nextSeekTime;\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = nextSeekTime;\n pendingSeekTimeRef.current = null;\n }\n }\n\n pendingAutoPlayRef.current = shouldAutoResume;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n updateLoading(false);\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (!hasNewSrc) {\n tryPlayCurrentAudio(\"sync-url\");\n }\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (waitingSegmentIndexRef.current < currentAudioSegments.length) {\n if (isPausedByUserRef.current) {\n setIsPlaying(false);\n updateLoading(false);\n return;\n }\n\n startSegmentPlayback(waitingSegmentIndexRef.current, \"wait-resume\");\n return;\n }\n\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying && !isPausedByUserRef.current;\n setIsPlaying(false);\n updateLoading(!isPausedByUserRef.current);\n return;\n }\n\n if (!currentAudioSegments.length) {\n if (currentAudio.isAudioStreaming) {\n waitingSegmentIndexRef.current = currentSegmentIndexRef.current;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current =\n defaultPlaying && !isPausedByUserRef.current;\n setIsPlaying(false);\n updateLoading(!isPausedByUserRef.current);\n return;\n }\n\n resetAudio();\n return;\n }\n\n if (!audioSrcRef.current) {\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"effect-init\"\n );\n return;\n }\n\n if (!defaultPlaying || isPausedByUserRef.current) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"sync-paused-retry\");\n }\n }, [\n currentAudio,\n currentAudioIndex,\n currentAudioSegments,\n currentAudioUrl,\n defaultPlaying,\n resetAudio,\n startSegmentPlayback,\n tryPlayCurrentAudio,\n getWaitingSegmentSeekTime,\n updateLoading,\n ]);\n\n useEffect(() => resetAudio, [resetAudio]);\n\n const handleAudioPlay = useCallback(() => {\n setIsPlaying(true);\n updateLoading(false);\n }, [updateLoading]);\n\n const handleAudioPause = useCallback(() => {\n if (isWaitingForSegmentRef.current || isSwitchingSegmentRef.current) {\n return;\n }\n\n setIsPlaying(false);\n }, [currentAudioIndex]);\n\n const handleAudioCanPlay = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n\n if (!pendingAutoPlayRef.current || !defaultPlaying) {\n return;\n }\n\n tryPlayCurrentAudio(\"canplay\");\n }, [currentAudioIndex, defaultPlaying, tryPlayCurrentAudio]);\n\n const handleLoadedMetadata = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n }, [currentAudioIndex]);\n\n const handleAudioEnded = useCallback(() => {\n const shouldFinishAsUrl =\n activeSourceTypeRef.current === \"url\" ||\n currentAudioSegmentsRef.current.length === 0;\n\n isSwitchingSegmentRef.current = false;\n\n if (shouldFinishAsUrl) {\n finishAudioItem(\"url-ended\");\n return;\n }\n\n handleSegmentEnded();\n }, [finishAudioItem, handleSegmentEnded]);\n\n const handleAudioError = useCallback(() => {\n setIsPlaying(false);\n updateLoading(false);\n }, [updateLoading]);\n\n return (\n <div className={cn(\"slide-player\", className)} {...props}>\n <audio\n ref={audioRef}\n preload=\"auto\"\n playsInline\n onLoadedMetadata={handleLoadedMetadata}\n onCanPlay={handleAudioCanPlay}\n onPlay={handleAudioPlay}\n onPause={handleAudioPause}\n onEnded={handleAudioEnded}\n onError={handleAudioError}\n />\n\n {showControls ? (\n <div className=\"slide-player__controls\">\n <div className=\"slide-player__group\">\n <button aria-label=\"More options\" className=\"hidden\" type=\"button\">\n <EllipsisVertical\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n </button>\n <button aria-label=\"Volume\" className=\"hidden\" type=\"button\">\n <Volume2 className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label=\"Rewind\"\n className=\"slide-player__action\"\n disabled={prevDisabled}\n onClick={onPrev}\n type=\"button\"\n >\n <RotateCcw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label={isPlaying ? \"Pause\" : \"Play\"}\n className=\"slide-player__toggle\"\n onClick={() => {\n const audioElement = audioRef.current;\n\n if (!audioElement || !currentAudio) {\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (isPlaying) {\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n setIsPlaying(false);\n updateLoading(false);\n audioElement.pause();\n return;\n }\n\n onPlayRequest?.();\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n updateLoading(true);\n return;\n }\n\n if (!audioElement.src && currentAudioSegments.length > 0) {\n // Only the player play button can unlock playback when autoplay is unavailable.\n onPlayRequest?.();\n isPausedByUserRef.current = false;\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"toggle\"\n );\n return;\n }\n\n if (audioElement.paused) {\n onPlayRequest?.();\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"toggle-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n audioElement.pause();\n }}\n type=\"button\"\n >\n {isPlaying ? <PauseIcon /> : <PlayIcon />}\n </button>\n <button\n aria-label=\"Forward\"\n className=\"slide-player__action\"\n disabled={nextDisabled}\n onClick={onNext}\n type=\"button\"\n >\n <RotateCw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label=\"Fullscreen\"\n className=\"hidden\"\n onClick={onFullscreen}\n type=\"button\"\n >\n <Maximize className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n </div>\n\n <div className=\"slide-player__separator\" />\n\n <div className=\"slide-player__group\">\n <button\n aria-label=\"Notes\"\n className={cn(\n \"slide-player__action\",\n isInteractionOpen && \"slide-player__action--active\"\n )}\n disabled={!hasInteraction}\n onClick={onInteractionToggle}\n type=\"button\"\n >\n <FilePenLine className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Player;\n"],"names":["audioPreloadElementCache","preloadAudioUrl","url","audio","PauseIcon","jsxs","jsx","PlayIcon","Player","audioList","className","currentAudioIndex","defaultPlaying","onLoadingChange","onPrev","onNext","onFullscreen","onEnded","onPlayRequest","onInteractionToggle","hasInteraction","isInteractionOpen","prevDisabled","nextDisabled","showControls","props","audioRef","useRef","audioSrcRef","currentAudioKeyRef","currentSegmentIndexRef","waitingSegmentIndexRef","currentAudioRef","currentAudioSegmentsRef","isLoadingRef","isPausedByUserRef","activeSourceTypeRef","isWaitingForSegmentRef","pendingAutoPlayRef","pendingSeekTimeRef","isSwitchingSegmentRef","isPlaying","setIsPlaying","useState","currentAudio","currentAudioUrl","currentAudioSegments","useMemo","prevSegment","nextSegment","currentAudioKey","useEffect","currentUrl","nextUrl","updateLoading","useCallback","loading","getSegmentSrc","audioData","getWaitingSegmentSeekTime","waitingSegmentIndex","totalDurationMs","segment","resetAudio","audioElement","tryPlayCurrentAudio","_reason","playPromise","_error","startSegmentPlayback","segmentIndex","nextAudioSrc","shouldAutoResume","hasNewSrc","finishAudioItem","handleSegmentEnded","nextSegmentIndex","segments","activeAudio","hasFinal","nextSeekTime","handleAudioPlay","handleAudioPause","handleAudioCanPlay","handleLoadedMetadata","handleAudioEnded","shouldFinishAsUrl","handleAudioError","cn","EllipsisVertical","Volume2","RotateCcw","RotateCw","Maximize","FilePenLine"],"mappings":"kvCAoBMA,MAA+B,IAE/BC,EAAmBC,GAAiB,CAKxC,GAJI,OAAO,OAAW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AU,CAACD,EACX,QAASD,EACT,KAAK,SAEL,SAAAb,EAAAA,kBAAAA,IAACwF,WAAA,CAAY,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,CACjE,CACF,CAAA,CAAA,CACF,EACE,IAAA,EACN,CAEJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as r } from "../../_virtual/jsx-runtime.es.js";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
2
|
+
import { useRef as o, useState as fe, useMemo as de, useEffect as k, useCallback as i } from "react";
|
|
3
|
+
import { cn as J } from "../../lib/utils.es.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import me from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js";
|
|
6
6
|
import pe from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.es.js";
|
|
@@ -8,11 +8,11 @@ import he from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/luc
|
|
|
8
8
|
import ge from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js";
|
|
9
9
|
import ye from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.es.js";
|
|
10
10
|
import _e from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js";
|
|
11
|
-
const
|
|
12
|
-
if (typeof
|
|
11
|
+
const O = /* @__PURE__ */ new Map(), Q = (b) => {
|
|
12
|
+
if (typeof window > "u" || !b || O.has(b))
|
|
13
13
|
return;
|
|
14
|
-
const v = document.createElement("
|
|
15
|
-
v.
|
|
14
|
+
const v = window.document.createElement("audio");
|
|
15
|
+
v.preload = "auto", v.setAttribute("playsinline", "true"), v.src = b, v.load(), O.set(b, v);
|
|
16
16
|
}, Se = () => /* @__PURE__ */ r.jsxs(
|
|
17
17
|
"svg",
|
|
18
18
|
{
|
|
@@ -52,7 +52,7 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
52
52
|
]
|
|
53
53
|
}
|
|
54
54
|
), Me = ({
|
|
55
|
-
audioList:
|
|
55
|
+
audioList: b = [],
|
|
56
56
|
className: v,
|
|
57
57
|
currentAudioIndex: c = -1,
|
|
58
58
|
defaultPlaying: d = !0,
|
|
@@ -70,130 +70,130 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
70
70
|
showControls: ne = !0,
|
|
71
71
|
...se
|
|
72
72
|
}) => {
|
|
73
|
-
const
|
|
73
|
+
const g = o(null), x = o(null), Z = o(null), j = o(0), f = o(null), B = o(void 0), E = o([]), H = o(!1), a = o(!1), N = o(null), h = o(!1), s = o(!1), p = o(null), y = o(!1), [V, u] = fe(d), m = c >= 0 ? b[c] : void 0, A = m?.audioUrl, _ = de(
|
|
74
74
|
() => [...m?.audioSegments ?? []].sort(
|
|
75
75
|
(e, l) => e.segment_index - l.segment_index
|
|
76
76
|
),
|
|
77
77
|
[m?.audioSegments]
|
|
78
78
|
), P = `${c}:${m?.audioKey ?? "none"}`;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, [m]),
|
|
82
|
-
E.current =
|
|
83
|
-
}, [
|
|
84
|
-
const e = m?.audioUrl, l = c >= 0 ?
|
|
79
|
+
k(() => {
|
|
80
|
+
B.current = m;
|
|
81
|
+
}, [m]), k(() => {
|
|
82
|
+
E.current = _;
|
|
83
|
+
}, [_]), k(() => {
|
|
84
|
+
const e = m?.audioUrl, l = c >= 0 ? b[c + 1]?.audioUrl : void 0;
|
|
85
85
|
Q(e), Q(l);
|
|
86
|
-
}, [
|
|
87
|
-
const t =
|
|
86
|
+
}, [b, m?.audioUrl, c]);
|
|
87
|
+
const t = i(
|
|
88
88
|
(e) => {
|
|
89
|
-
|
|
89
|
+
H.current !== e && (H.current = e, F?.(e));
|
|
90
90
|
},
|
|
91
91
|
[F]
|
|
92
|
-
),
|
|
92
|
+
), L = i((e) => e ? e.startsWith("data:") ? e : `data:audio/mpeg;base64,${e}` : "", []), $ = i(() => {
|
|
93
93
|
const e = f.current;
|
|
94
94
|
return e == null || e <= 0 ? 0 : E.current.slice(0, e).reduce(
|
|
95
95
|
(l, n) => l + Math.max(Number(n.duration_ms ?? 0), 0),
|
|
96
96
|
0
|
|
97
97
|
) / 1e3;
|
|
98
|
-
}, []), M =
|
|
99
|
-
const e =
|
|
100
|
-
e && (s.current = !1, a.current = !1, N.current = null, p.current = null, h.current = !1,
|
|
101
|
-
}, [t]),
|
|
98
|
+
}, []), M = i(() => {
|
|
99
|
+
const e = g.current;
|
|
100
|
+
e && (s.current = !1, a.current = !1, N.current = null, p.current = null, h.current = !1, y.current = !1, e.pause(), e.removeAttribute("src"), e.load(), x.current = null, j.current = 0, f.current = null, u(!1), t(!1));
|
|
101
|
+
}, [t]), S = i(
|
|
102
102
|
(e) => {
|
|
103
|
-
const l =
|
|
103
|
+
const l = g.current;
|
|
104
104
|
if (!l)
|
|
105
105
|
return !1;
|
|
106
106
|
const n = l.play();
|
|
107
107
|
return n && typeof n.then == "function" && n.then(() => {
|
|
108
|
-
s.current = !1,
|
|
109
|
-
}).catch((
|
|
108
|
+
s.current = !1, y.current = !1;
|
|
109
|
+
}).catch((R) => {
|
|
110
110
|
u(!1);
|
|
111
111
|
}), !0;
|
|
112
112
|
},
|
|
113
113
|
[c]
|
|
114
|
-
),
|
|
114
|
+
), C = i(
|
|
115
115
|
(e, l) => {
|
|
116
|
-
const n =
|
|
117
|
-
if (!n || !
|
|
116
|
+
const n = g.current, R = E.current[e];
|
|
117
|
+
if (!n || !R)
|
|
118
118
|
return !1;
|
|
119
|
-
const w =
|
|
120
|
-
j.current = e, f.current = null, h.current = !1,
|
|
119
|
+
const w = L(R.audio_data);
|
|
120
|
+
j.current = e, f.current = null, h.current = !1, y.current = !0;
|
|
121
121
|
const W = d && !a.current;
|
|
122
122
|
s.current = W, t(!1);
|
|
123
|
-
const
|
|
124
|
-
return N.current = "segment",
|
|
123
|
+
const G = x.current !== w;
|
|
124
|
+
return N.current = "segment", G && (n.pause(), n.removeAttribute("src"), n.load(), x.current = w, n.src = w, n.load()), p.current = 0, n.readyState > 0 && (n.currentTime = 0, p.current = null), W ? G ? !0 : S(`start-segment:${l}`) : (s.current = !1, y.current = !1, n.pause(), u(!1), !0);
|
|
125
125
|
},
|
|
126
|
-
[d,
|
|
127
|
-
), U =
|
|
126
|
+
[d, L, S, t]
|
|
127
|
+
), U = i(
|
|
128
128
|
(e) => {
|
|
129
|
-
s.current = !1, h.current = !1,
|
|
129
|
+
s.current = !1, h.current = !1, y.current = !1, u(!1), t(!1), c >= 0 && K?.(c);
|
|
130
130
|
},
|
|
131
131
|
[c, K, t]
|
|
132
|
-
), z =
|
|
133
|
-
const e = j.current + 1, l = E.current, n = l[e],
|
|
132
|
+
), z = i(() => {
|
|
133
|
+
const e = j.current + 1, l = E.current, n = l[e], R = B.current, w = l.some((W) => W.is_final);
|
|
134
134
|
if (n) {
|
|
135
|
-
|
|
135
|
+
C(e, "ended");
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
if (
|
|
138
|
+
if (R?.isAudioStreaming || !w) {
|
|
139
139
|
j.current = e, f.current = e, h.current = !0, s.current = d, u(!1), t(!0);
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
U("segments-completed");
|
|
143
|
-
}, [d, U,
|
|
144
|
-
|
|
145
|
-
if (
|
|
143
|
+
}, [d, U, C, t]);
|
|
144
|
+
k(() => {
|
|
145
|
+
if (Z.current === P)
|
|
146
146
|
return;
|
|
147
|
-
|
|
148
|
-
const e =
|
|
147
|
+
Z.current = P, j.current = 0, f.current = null, h.current = !1, a.current = !1, s.current = !1, y.current = !1, N.current = null, x.current = null, t(!1);
|
|
148
|
+
const e = g.current;
|
|
149
149
|
e && (e.pause(), e.removeAttribute("src"), e.load(), u(!1));
|
|
150
150
|
}, [
|
|
151
151
|
c,
|
|
152
152
|
P,
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
_.length,
|
|
154
|
+
A,
|
|
155
155
|
t
|
|
156
|
-
]),
|
|
157
|
-
const e =
|
|
156
|
+
]), k(() => {
|
|
157
|
+
const e = g.current;
|
|
158
158
|
if (e) {
|
|
159
159
|
if (!m) {
|
|
160
160
|
M();
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
if (
|
|
164
|
-
const l = x.current !==
|
|
163
|
+
if (A) {
|
|
164
|
+
const l = x.current !== A, n = d && !a.current;
|
|
165
165
|
if (N.current === "segment" && !!x.current && f.current === null) {
|
|
166
166
|
if (!n) {
|
|
167
167
|
s.current = !1, e.pause(), u(!1);
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
-
e.paused && (s.current = !0,
|
|
170
|
+
e.paused && (s.current = !0, S("keep-segment-source"));
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
173
|
if (l) {
|
|
174
174
|
const w = f.current !== null ? $() : 0;
|
|
175
|
-
e.pause(), e.removeAttribute("src"), e.load(), x.current =
|
|
175
|
+
e.pause(), e.removeAttribute("src"), e.load(), x.current = A, N.current = "url", e.src = A, e.load(), p.current = w, e.readyState > 0 && (e.currentTime = w, p.current = null);
|
|
176
176
|
}
|
|
177
|
-
if (s.current = n, h.current = !1,
|
|
177
|
+
if (s.current = n, h.current = !1, y.current = !1, t(!1), !n) {
|
|
178
178
|
s.current = !1, e.pause(), u(!1);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
|
-
l ||
|
|
181
|
+
l || S("sync-url");
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
184
|
if (f.current !== null) {
|
|
185
|
-
if (f.current <
|
|
185
|
+
if (f.current < _.length) {
|
|
186
186
|
if (a.current) {
|
|
187
187
|
u(!1), t(!1);
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
|
-
|
|
190
|
+
C(f.current, "wait-resume");
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
h.current = !0, s.current = d && !a.current, u(!1), t(!a.current);
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
|
-
if (!
|
|
196
|
+
if (!_.length) {
|
|
197
197
|
if (m.isAudioStreaming) {
|
|
198
198
|
f.current = j.current, h.current = !0, s.current = d && !a.current, u(!1), t(!a.current);
|
|
199
199
|
return;
|
|
@@ -202,10 +202,10 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
if (!x.current) {
|
|
205
|
-
|
|
205
|
+
C(
|
|
206
206
|
Math.min(
|
|
207
207
|
j.current,
|
|
208
|
-
|
|
208
|
+
_.length - 1
|
|
209
209
|
),
|
|
210
210
|
"effect-init"
|
|
211
211
|
);
|
|
@@ -215,53 +215,53 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
215
215
|
s.current = !1, e.pause(), u(!1);
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
-
e.paused && (s.current = !0,
|
|
218
|
+
e.paused && (s.current = !0, S("sync-paused-retry"));
|
|
219
219
|
}
|
|
220
220
|
}, [
|
|
221
221
|
m,
|
|
222
222
|
c,
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
_,
|
|
224
|
+
A,
|
|
225
225
|
d,
|
|
226
226
|
M,
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
C,
|
|
228
|
+
S,
|
|
229
229
|
$,
|
|
230
230
|
t
|
|
231
|
-
]),
|
|
232
|
-
const ue =
|
|
231
|
+
]), k(() => M, [M]);
|
|
232
|
+
const ue = i(() => {
|
|
233
233
|
u(!0), t(!1);
|
|
234
|
-
}, [t]), le =
|
|
235
|
-
h.current ||
|
|
236
|
-
}, [c]), ce =
|
|
237
|
-
const e =
|
|
238
|
-
e && p.current !== null && (e.currentTime = p.current, p.current = null), !(!s.current || !d) &&
|
|
239
|
-
}, [c, d,
|
|
240
|
-
const e =
|
|
234
|
+
}, [t]), le = i(() => {
|
|
235
|
+
h.current || y.current || u(!1);
|
|
236
|
+
}, [c]), ce = i(() => {
|
|
237
|
+
const e = g.current;
|
|
238
|
+
e && p.current !== null && (e.currentTime = p.current, p.current = null), !(!s.current || !d) && S("canplay");
|
|
239
|
+
}, [c, d, S]), ae = i(() => {
|
|
240
|
+
const e = g.current;
|
|
241
241
|
e && p.current !== null && (e.currentTime = p.current, p.current = null);
|
|
242
|
-
}, [c]),
|
|
242
|
+
}, [c]), oe = i(() => {
|
|
243
243
|
const e = N.current === "url" || E.current.length === 0;
|
|
244
|
-
if (
|
|
244
|
+
if (y.current = !1, e) {
|
|
245
245
|
U("url-ended");
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
z();
|
|
249
|
-
}, [U, z]),
|
|
249
|
+
}, [U, z]), ie = i(() => {
|
|
250
250
|
u(!1), t(!1);
|
|
251
251
|
}, [t]);
|
|
252
|
-
return /* @__PURE__ */ r.jsxs("div", { className:
|
|
252
|
+
return /* @__PURE__ */ r.jsxs("div", { className: J("slide-player", v), ...se, children: [
|
|
253
253
|
/* @__PURE__ */ r.jsx(
|
|
254
254
|
"audio",
|
|
255
255
|
{
|
|
256
|
-
ref:
|
|
256
|
+
ref: g,
|
|
257
257
|
preload: "auto",
|
|
258
258
|
playsInline: !0,
|
|
259
259
|
onLoadedMetadata: ae,
|
|
260
260
|
onCanPlay: ce,
|
|
261
261
|
onPlay: ue,
|
|
262
262
|
onPause: le,
|
|
263
|
-
onEnded:
|
|
264
|
-
onError:
|
|
263
|
+
onEnded: oe,
|
|
264
|
+
onError: ie
|
|
265
265
|
}
|
|
266
266
|
),
|
|
267
267
|
ne ? /* @__PURE__ */ r.jsxs("div", { className: "slide-player__controls", children: [
|
|
@@ -291,7 +291,7 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
291
291
|
"aria-label": V ? "Pause" : "Play",
|
|
292
292
|
className: "slide-player__toggle",
|
|
293
293
|
onClick: () => {
|
|
294
|
-
const e =
|
|
294
|
+
const e = g.current;
|
|
295
295
|
if (!(!e || !m)) {
|
|
296
296
|
if (f.current !== null) {
|
|
297
297
|
if (V) {
|
|
@@ -301,18 +301,18 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
301
301
|
T?.(), a.current = !1, s.current = !0, t(!0);
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
|
-
if (!e.src &&
|
|
305
|
-
T?.(), a.current = !1,
|
|
304
|
+
if (!e.src && _.length > 0) {
|
|
305
|
+
T?.(), a.current = !1, C(
|
|
306
306
|
Math.min(
|
|
307
307
|
j.current,
|
|
308
|
-
|
|
308
|
+
_.length - 1
|
|
309
309
|
),
|
|
310
310
|
"toggle"
|
|
311
311
|
);
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
if (e.paused) {
|
|
315
|
-
T?.(), a.current = !1, s.current = !0,
|
|
315
|
+
T?.(), a.current = !1, s.current = !0, S("toggle-resume");
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
318
318
|
s.current = !1, a.current = !0, e.pause();
|
|
@@ -349,7 +349,7 @@ const J = /* @__PURE__ */ new Set(), Q = (g) => {
|
|
|
349
349
|
"button",
|
|
350
350
|
{
|
|
351
351
|
"aria-label": "Notes",
|
|
352
|
-
className:
|
|
352
|
+
className: J(
|
|
353
353
|
"slide-player__action",
|
|
354
354
|
ee && "slide-player__action--active"
|
|
355
355
|
),
|