markdown-flow-ui 0.1.100-beta.13 → 0.1.100-beta.15
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/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
- package/dist/_virtual/index.cjs4.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.es4.js +4 -4
- package/dist/_virtual/index.es5.js +4 -4
- package/dist/_virtual/index.es6.js +5 -5
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
- package/dist/components/ContentRender/IframeSandbox.es.js +237 -199
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.cjs.js +2 -2
- package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +1 -0
- package/dist/components/ContentRender/SandboxApp.es.js +70 -66
- package/dist/components/ContentRender/SandboxApp.es.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.d.ts +1 -0
- package/dist/components/Slide/Player.es.js +157 -151
- 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.d.ts +1 -0
- package/dist/components/Slide/Slide.es.js +325 -266
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/Slide.stories.d.ts +2 -0
- package/dist/components/Slide/useSlide.cjs.js +1 -1
- package/dist/components/Slide/useSlide.cjs.js.map +1 -1
- package/dist/components/Slide/useSlide.d.ts +1 -0
- package/dist/components/Slide/useSlide.es.js +109 -87
- package/dist/components/Slide/useSlide.es.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { Loader2 } from \"lucide-react\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const [, setIsWaitingFirstDiv] = useState(true);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n @keyframes sandbox-spin { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n const hasRenderedBefore = hasRenderedContentRef.current;\n setIsWaitingFirstDiv(!hasRenderedBefore);\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n setIsWaitingFirstDiv(!hasFirstElement && !hasRenderedBefore);\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n container.innerHTML = \"\";\n const contentNodes = Array.from(wrapper.childNodes);\n container.append(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: isBlackboard ? \"space-around\" : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n };\n\n return (\n <div\n ref={wrapperRef}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(51, 51, 51, 0.80)\",\n color: \"#ffffff\",\n fontSize: 16,\n fontWeight: 700,\n gap: 10,\n pointerEvents: \"auto\",\n zIndex: 20,\n }}\n >\n <Loader2\n aria-hidden\n size={20}\n style={{ animation: \"sandbox-spin 1s linear infinite\" }}\n />\n {overlayMessage}\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","wrapperRef","useRef","containerRef","setIsWaitingFirstDiv","useState","isGeneratingStyles","setIsGeneratingStyles","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","hasRenderedBefore","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","hasFirstElement","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","Loader2"],"mappings":";;;AAYA,MAAMA,IAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,EAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,KAAwB,CAACC,MAAqB;AAClD,QAAMC,wBAAe,IAAA;AACrB,SAAAD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAML,IAAQK,GACRC,IAAMP,EAAiBC,CAAK,GAC5BO,IAASH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AAA,YACC,KAAKrD;AAAA,YACL,WAAU;AAAA,YACV,OAAOmD;AAAA,UAAA;AAAA,QAAA;AAAA,QAERH,KACCI,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,OAAO;AAAA,cACP,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,UAAU;AAAA,cACV,YAAY;AAAA,cACZ,KAAK;AAAA,cACL,eAAe;AAAA,cACf,QAAQ;AAAA,YAAA;AAAA,YAGV,UAAA;AAAA,cAAAC,gBAAAA,EAAAA;AAAAA,gBAACC;AAAAA,gBAAA;AAAA,kBACC,eAAW;AAAA,kBACX,MAAM;AAAA,kBACN,OAAO,EAAE,WAAW,kCAAA;AAAA,gBAAkC;AAAA,cAAA;AAAA,cAEvDN;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
1
|
+
{"version":3,"file":"SandboxApp.es.js","sources":["../../../src/components/ContentRender/SandboxApp.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { Loader2 } from \"lucide-react\";\n\nexport interface SandboxAppProps {\n html: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n resetToken?: number;\n mode?: \"content\" | \"blackboard\";\n hasRootVhHeight?: boolean;\n stretchRootHeight?: boolean;\n}\n\nconst IMAGE_REUSE_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"alt\",\n \"class\",\n \"width\",\n \"height\",\n \"style\",\n \"loading\",\n \"decoding\",\n \"crossorigin\",\n \"referrerpolicy\",\n];\n\nconst getImageReuseKey = (image: HTMLImageElement) =>\n IMAGE_REUSE_ATTRIBUTES.map(\n (attribute) => `${attribute}:${image.getAttribute(attribute) || \"\"}`\n ).join(\"|\");\n\nconst collectReusableImages = (root: ParentNode) => {\n const imageMap = new Map<string, HTMLImageElement[]>();\n root.querySelectorAll(\"img\").forEach((node) => {\n const image = node as HTMLImageElement;\n const key = getImageReuseKey(image);\n const bucket = imageMap.get(key) || [];\n bucket.push(image);\n imageMap.set(key, bucket);\n });\n return imageMap;\n};\n\nconst syncImageAttributes = (\n sourceImage: HTMLImageElement,\n targetImage: HTMLImageElement\n) => {\n const sourceAttributes = Array.from(sourceImage.attributes);\n const sourceAttributeNames = new Set(\n sourceAttributes.map((attribute) => attribute.name)\n );\n\n Array.from(targetImage.attributes).forEach((attribute) => {\n if (!sourceAttributeNames.has(attribute.name)) {\n targetImage.removeAttribute(attribute.name);\n }\n });\n\n sourceAttributes.forEach((attribute) => {\n targetImage.setAttribute(attribute.name, attribute.value);\n });\n};\n\nconst reuseRenderedImages = (\n root: ParentNode,\n imageMap: Map<string, HTMLImageElement[]>\n) => {\n if (!imageMap.size) return;\n\n root.querySelectorAll(\"img\").forEach((node) => {\n const nextImage = node as HTMLImageElement;\n const key = getImageReuseKey(nextImage);\n const bucket = imageMap.get(key);\n const preservedImage = bucket?.shift();\n if (!preservedImage) return;\n\n syncImageAttributes(nextImage, preservedImage);\n nextImage.replaceWith(preservedImage);\n\n if (bucket && bucket.length === 0) {\n imageMap.delete(key);\n }\n });\n};\n\nconst SandboxApp: React.FC<SandboxAppProps> = ({\n html,\n styleLoadingText,\n scriptLoadingText,\n resetToken = 0,\n mode = \"content\",\n hasRootVhHeight = false,\n stretchRootHeight = false,\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const [, setIsWaitingFirstDiv] = useState(true);\n const [isGeneratingStyles, setIsGeneratingStyles] = useState(false);\n const [isGeneratingScripts, setIsGeneratingScripts] = useState(false);\n const appendedStylesRef = useRef<HTMLStyleElement[]>([]);\n const appendedScriptsRef = useRef<HTMLScriptElement[]>([]);\n const styleStartRef = useRef(0);\n const scriptStartRef = useRef(0);\n const styleTimerRef = useRef<number | null>(null);\n const scriptTimerRef = useRef<number | null>(null);\n const hasStylesRef = useRef(false);\n const hasScriptsRef = useRef(false);\n const hasRenderedContentRef = useRef(false);\n const prevResetTokenRef = useRef(resetToken);\n const MIN_LOADING_MS = 200;\n\n const clearTimer = (timerRef: React.MutableRefObject<number | null>) => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const settleStateWithMinimumDelay = (\n setter: React.Dispatch<React.SetStateAction<boolean>>,\n timerRef: React.MutableRefObject<number | null>,\n startRef: React.MutableRefObject<number>,\n onDone?: () => void\n ) => {\n const elapsed = performance.now() - startRef.current;\n const delay = Math.max(0, MIN_LOADING_MS - elapsed);\n clearTimer(timerRef);\n timerRef.current = window.setTimeout(() => {\n setter(false);\n onDone?.();\n timerRef.current = null;\n }, delay);\n };\n\n useEffect(() => {\n const doc = containerRef.current?.ownerDocument;\n if (!doc) return;\n const styleId = \"sandbox-spinner-style\";\n let styleEl = doc.getElementById(styleId) as HTMLStyleElement | null;\n if (!styleEl) {\n styleEl = doc.createElement(\"style\");\n styleEl.id = styleId;\n doc.head?.appendChild(styleEl);\n }\n styleEl.textContent = `\n @keyframes sandbox-spin { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }\n .sandbox-wrapper { align-items: center; }\n .sandbox-container { width: 100%; }\n .sandbox-container svg,\n .sandbox-container img { display: block; margin-left: auto; margin-right: auto; }\n .justify-\\\\[safe_center\\\\]{\n justify-content: safe center;\n }\n `;\n }, []);\n\n useEffect(() => {\n if (resetToken !== prevResetTokenRef.current) {\n hasRenderedContentRef.current = false;\n prevResetTokenRef.current = resetToken;\n }\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n hasStylesRef.current = false;\n hasScriptsRef.current = false;\n\n const container = containerRef.current;\n if (!container) return;\n const doc = container.ownerDocument;\n const body = doc?.body;\n if (!body) return;\n const reusableImages = collectReusableImages(container);\n\n appendedStylesRef.current.forEach((node) => node.remove());\n appendedStylesRef.current = [];\n appendedScriptsRef.current.forEach((node) => node.remove());\n appendedScriptsRef.current = [];\n\n const hasRenderedBefore = hasRenderedContentRef.current;\n setIsWaitingFirstDiv(!hasRenderedBefore);\n setIsGeneratingStyles(false);\n setIsGeneratingScripts(false);\n const wrapper = doc.createElement(\"div\");\n wrapper.innerHTML = html;\n\n const openScriptCount = (html.match(/<script[\\s>]/gi) || []).length;\n const closeScriptCount = (html.match(/<\\/script>/gi) || []).length;\n const shouldExecuteScripts =\n openScriptCount > 0 && openScriptCount === closeScriptCount;\n\n const resourceQueue: HTMLElement[] = [];\n\n Array.from(wrapper.querySelectorAll(\"style, script\")).forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n const cloned = doc.createElement(\"style\");\n cloned.textContent = node.textContent || \"\";\n Array.from(node.attributes).forEach((attr) => {\n cloned.setAttribute(attr.name, attr.value);\n });\n resourceQueue.push(cloned);\n } else {\n const replacement = doc.createElement(\"script\");\n Array.from(node.attributes).forEach((attr) => {\n replacement.setAttribute(attr.name, attr.value);\n });\n replacement.textContent = node.textContent || \"\";\n resourceQueue.push(replacement);\n }\n node.remove();\n });\n reuseRenderedImages(wrapper, reusableImages);\n\n const hasStyles = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"style\"\n );\n const hasScripts = resourceQueue.some(\n (node) => node.tagName.toLowerCase() === \"script\"\n );\n if (hasStyles) {\n hasStylesRef.current = true;\n styleStartRef.current = performance.now();\n clearTimer(styleTimerRef);\n setIsGeneratingStyles(true);\n }\n if (hasScripts) {\n hasScriptsRef.current = true;\n scriptStartRef.current = performance.now();\n clearTimer(scriptTimerRef);\n setIsGeneratingScripts(true);\n }\n\n const hasFirstElement = !!wrapper.firstElementChild;\n setIsWaitingFirstDiv(!hasFirstElement && !hasRenderedBefore);\n if (hasFirstElement) {\n hasRenderedContentRef.current = true;\n }\n\n container.innerHTML = \"\";\n const contentNodes = Array.from(wrapper.childNodes);\n container.append(...contentNodes);\n\n resourceQueue.forEach((node) => {\n if (node.tagName.toLowerCase() === \"style\") {\n doc.head?.appendChild(node);\n appendedStylesRef.current.push(node as HTMLStyleElement);\n return;\n }\n\n if (shouldExecuteScripts) {\n const scriptNode = node as HTMLScriptElement;\n const scriptText = scriptNode.textContent || \"\";\n const shouldValidate = !scriptNode.src;\n\n if (shouldValidate) {\n try {\n // Validate script is syntactically complete before executing\n\n new Function(scriptText);\n } catch {\n scriptNode.remove();\n return;\n }\n }\n\n try {\n body.appendChild(scriptNode);\n appendedScriptsRef.current.push(scriptNode);\n } catch {\n scriptNode.remove();\n }\n } else {\n // Defer execution until all script tags are fully received\n node.remove();\n }\n });\n requestAnimationFrame(() => {\n if (hasStyles) {\n settleStateWithMinimumDelay(\n setIsGeneratingStyles,\n styleTimerRef,\n styleStartRef,\n () => {\n hasStylesRef.current = false;\n }\n );\n }\n if (hasScripts) {\n settleStateWithMinimumDelay(\n setIsGeneratingScripts,\n scriptTimerRef,\n scriptStartRef,\n () => {\n hasScriptsRef.current = false;\n }\n );\n }\n });\n }, [html, resetToken]);\n\n useEffect(\n () => () => {\n clearTimer(styleTimerRef);\n clearTimer(scriptTimerRef);\n },\n []\n );\n\n const overlayMessage = (() => {\n if (isGeneratingScripts || hasScriptsRef.current)\n return scriptLoadingText || \"Building scripts cache...\";\n if (isGeneratingStyles || hasStylesRef.current)\n return styleLoadingText || \"Building styles...\";\n return null;\n })();\n\n const isBlackboard = mode === \"blackboard\";\n const shouldStretchRootHeight = isBlackboard && stretchRootHeight;\n const sandboxWrapperStyle: React.CSSProperties = {\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n // Keep blackboard scroll behavior while centering content in non-blackboard mode\n justifyContent: shouldStretchRootHeight\n ? \"flex-start\"\n : isBlackboard\n ? \"space-around\"\n : \"flex-start\",\n };\n const sandboxContainerStyle: React.CSSProperties = {\n pointerEvents: overlayMessage ? \"none\" : undefined,\n margin: isBlackboard ? undefined : \"auto 0\",\n width: \"100%\",\n height: shouldStretchRootHeight ? \"100%\" : undefined,\n minHeight: shouldStretchRootHeight ? 0 : undefined,\n flex: shouldStretchRootHeight ? \"1 1 auto\" : undefined,\n };\n\n return (\n <div\n ref={wrapperRef}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className=\"sandbox-wrapper\"\n style={sandboxWrapperStyle}\n aria-busy={!!overlayMessage}\n >\n <div\n ref={containerRef}\n className=\"sandbox-container\"\n style={sandboxContainerStyle}\n />\n {overlayMessage && (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(51, 51, 51, 0.80)\",\n color: \"#ffffff\",\n fontSize: 16,\n fontWeight: 700,\n gap: 10,\n pointerEvents: \"auto\",\n zIndex: 20,\n }}\n >\n <Loader2\n aria-hidden\n size={20}\n style={{ animation: \"sandbox-spin 1s linear infinite\" }}\n />\n {overlayMessage}\n </div>\n )}\n </div>\n );\n};\n\nexport default SandboxApp;\n"],"names":["IMAGE_REUSE_ATTRIBUTES","getImageReuseKey","image","attribute","collectReusableImages","root","imageMap","node","key","bucket","syncImageAttributes","sourceImage","targetImage","sourceAttributes","sourceAttributeNames","reuseRenderedImages","nextImage","preservedImage","SandboxApp","html","styleLoadingText","scriptLoadingText","resetToken","mode","hasRootVhHeight","stretchRootHeight","wrapperRef","useRef","containerRef","setIsWaitingFirstDiv","useState","isGeneratingStyles","setIsGeneratingStyles","isGeneratingScripts","setIsGeneratingScripts","appendedStylesRef","appendedScriptsRef","styleStartRef","scriptStartRef","styleTimerRef","scriptTimerRef","hasStylesRef","hasScriptsRef","hasRenderedContentRef","prevResetTokenRef","MIN_LOADING_MS","clearTimer","timerRef","settleStateWithMinimumDelay","setter","startRef","onDone","elapsed","delay","useEffect","doc","styleId","styleEl","container","body","reusableImages","hasRenderedBefore","wrapper","openScriptCount","closeScriptCount","shouldExecuteScripts","resourceQueue","cloned","attr","replacement","hasStyles","hasScripts","hasFirstElement","contentNodes","scriptNode","scriptText","overlayMessage","isBlackboard","shouldStretchRootHeight","sandboxWrapperStyle","sandboxContainerStyle","jsxs","jsx","Loader2"],"mappings":";;;AAaA,MAAMA,KAAyB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEMC,IAAmB,CAACC,MACxBF,GAAuB;AAAA,EACrB,CAACG,MAAc,GAAGA,CAAS,IAAID,EAAM,aAAaC,CAAS,KAAK,EAAE;AACpE,EAAE,KAAK,GAAG,GAENC,KAAwB,CAACC,MAAqB;AAClD,QAAMC,wBAAe,IAAA;AACrB,SAAAD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAML,IAAQK,GACRC,IAAMP,EAAiBC,CAAK,GAC5BO,IAASH,EAAS,IAAIE,CAAG,KAAK,CAAA;AACpC,IAAAC,EAAO,KAAKP,CAAK,GACjBI,EAAS,IAAIE,GAAKC,CAAM;AAAA,EAC1B,CAAC,GACMH;AACT,GAEMI,KAAsB,CAC1BC,GACAC,MACG;AACH,QAAMC,IAAmB,MAAM,KAAKF,EAAY,UAAU,GACpDG,IAAuB,IAAI;AAAA,IAC/BD,EAAiB,IAAI,CAACV,MAAcA,EAAU,IAAI;AAAA,EAAA;AAGpD,QAAM,KAAKS,EAAY,UAAU,EAAE,QAAQ,CAACT,MAAc;AACxD,IAAKW,EAAqB,IAAIX,EAAU,IAAI,KAC1CS,EAAY,gBAAgBT,EAAU,IAAI;AAAA,EAE9C,CAAC,GAEDU,EAAiB,QAAQ,CAACV,MAAc;AACtC,IAAAS,EAAY,aAAaT,EAAU,MAAMA,EAAU,KAAK;AAAA,EAC1D,CAAC;AACH,GAEMY,KAAsB,CAC1BV,GACAC,MACG;AACH,EAAKA,EAAS,QAEdD,EAAK,iBAAiB,KAAK,EAAE,QAAQ,CAACE,MAAS;AAC7C,UAAMS,I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AW,kCAAA;AAAA,gBAAkC;AAAA,cAAA;AAAA,cAEvDP;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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 se=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"),ne=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"),ue=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"),le=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"),ce=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"),ae=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"),ie=()=>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"})]}),oe=()=>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"})]}),fe=({audioList:F=[],className:H,currentAudioIndex:a=-1,defaultPlaying:u=!0,onLoadingChange:q,onPrev:U,onNext:B,onFullscreen:K,onEnded:W,onPlayRequest:w,onInteractionToggle:z,hasInteraction:O=!1,isInteractionOpen:P=!1,prevDisabled:G=!1,nextDisabled:J=!1,showControls:Q=!0,...X})=>{const p=r.useRef(null),b=r.useRef(null),V=r.useRef(null),j=r.useRef(0),f=r.useRef(null),N=r.useRef(void 0),S=r.useRef([]),L=r.useRef(!1),d=r.useRef(!1),s=r.useRef(!1),o=r.useRef(null),x=r.useRef(!1),[A,l]=r.useState(u),m=a>=0?F[a]:void 0,E=m?.audioUrl,h=r.useMemo(()=>[...m?.audioSegments??[]].sort((e,i)=>e.segment_index-i.segment_index),[m?.audioSegments]),M=`${a}:${m?.sequenceNumber??"none"}:${E??""}`;r.useEffect(()=>{N.current=m},[m]),r.useEffect(()=>{S.current=h},[h]);const n=r.useCallback(e=>{L.current!==e&&(L.current=e,q?.(e))},[q]),T=r.useCallback(e=>e?e.startsWith("data:")?e:`data:audio/mpeg;base64,${e}`:"",[]),g=r.useCallback(()=>{const e=p.current;e&&(s.current=!1,o.current=null,d.current=!1,x.current=!1,e.pause(),e.removeAttribute("src"),e.load(),b.current=null,j.current=0,f.current=null,l(!1),n(!1))},[n]),R=r.useCallback(e=>{const i=p.current;if(!i)return!1;const c=i.play();return c&&typeof c.then=="function"&&c.then(()=>{s.current=!1,x.current=!1}).catch(y=>{l(!1)}),!0},[a]),_=r.useCallback((e,i)=>{const c=p.current,y=S.current[e];if(!c||!y)return!1;const C=T(y.audio_data);j.current=e,f.current=null,d.current=!1,x.current=!0,s.current=u,n(!1);const v=b.current!==C;return v&&(c.pause(),c.removeAttribute("src"),c.load(),b.current=C,c.src=C,c.load()),o.current=0,c.readyState>0&&(c.currentTime=0,o.current=null),u?v?!0:R(`start-segment:${i}`):(s.current=!1,x.current=!1,c.pause(),l(!1),!0)},[u,T,R,n]),k=r.useCallback(e=>{s.current=!1,d.current=!1,x.current=!1,l(!1),n(!1),a>=0&&W?.(a)},[a,W,n]),Z=r.useCallback(()=>{const e=j.current+1,i=S.current,c=i[e],y=N.current,C=i.some(v=>v.is_final);if(c){_(e,"ended");return}if(y?.isAudioStreaming||!C){j.current=e,f.current=e,d.current=!0,s.current=u,l(u),n(!0);return}k("segments-completed")},[u,k,_,n]);r.useEffect(()=>{if(V.current===M)return;V.current=M,j.current=0,f.current=null,d.current=!1,s.current=!1,x.current=!1,b.current=null,n(!1);const e=p.current;e&&(e.pause(),e.removeAttribute("src"),e.load(),l(!1))},[a,M,h.length,E,n]),r.useEffect(()=>{const e=p.current;if(e){if(!m){g();return}if(E){const i=b.current!==E;if(i&&(e.pause(),e.removeAttribute("src"),e.load(),b.current=E,e.src=E,e.load()),o.current=0,e.readyState>0&&(e.currentTime=0,o.current=null),s.current=u,d.current=!1,x.current=!1,n(!1),!u){s.current=!1,e.pause(),l(!1);return}i||R("sync-url");return}if(f.current!==null){if(f.current<h.length){_(f.current,"wait-resume");return}d.current=!0,s.current=u,l(u),n(!0);return}if(!h.length){if(m.isAudioStreaming){f.current=j.current,d.current=!0,s.current=u,l(u),n(!0);return}g();return}if(!b.current){_(Math.min(j.current,h.length-1),"effect-init");return}if(!u){s.current=!1,e.pause(),l(!1);return}e.paused&&(s.current=!0,R("sync-paused-retry"))}},[m,a,h,E,u,g,_,R,n]),r.useEffect(()=>g,[g]);const Y=r.useCallback(()=>{l(!0),n(!1)},[n]),D=r.useCallback(()=>{d.current||x.current||l(!1)},[a]),I=r.useCallback(()=>{const e=p.current;e&&o.current!==null&&(e.currentTime=o.current,o.current=null),!(!s.current||!u)&&R("canplay")},[a,u,R]),ee=r.useCallback(()=>{const e=p.current;e&&o.current!==null&&(e.currentTime=o.current,o.current=null)},[a]),re=r.useCallback(()=>{if(x.current=!1,N.current?.audioUrl||S.current.length===0){k("url-ended");return}Z()},[a,k,Z]),te=r.useCallback(()=>{l(!1),n(!1)},[n]);return t.jsxRuntimeExports.jsxs("div",{className:$.cn("slide-player",H),...X,children:[t.jsxRuntimeExports.jsx("audio",{ref:p,preload:"metadata",playsInline:!0,onLoadedMetadata:ee,onCanPlay:I,onPlay:Y,onPause:D,onEnded:re,onError:te}),Q?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(se.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Volume",className:"hidden",type:"button",children:t.jsxRuntimeExports.jsx(ne.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Rewind",className:"slide-player__action",disabled:G,onClick:U,type:"button",children:t.jsxRuntimeExports.jsx(ue.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":A?"Pause":"Play",className:"slide-player__toggle",onClick:()=>{const e=p.current;if(!(!e||!m)){if(f.current!==null){if(A){s.current=!1,f.current=null,d.current=!1,l(!1),e.pause();return}w?.(),s.current=!0,l(!0);return}if(!e.src&&h.length>0){w?.(),_(Math.min(j.current,h.length-1),"toggle");return}if(e.paused){w?.(),s.current=!0,R("toggle-resume");return}s.current=!1,e.pause()}},type:"button",children:A?t.jsxRuntimeExports.jsx(ie,{}):t.jsxRuntimeExports.jsx(oe,{})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Forward",className:"slide-player__action",disabled:J,onClick:B,type:"button",children:t.jsxRuntimeExports.jsx(le.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Fullscreen",className:"hidden",onClick:K,type:"button",children:t.jsxRuntimeExports.jsx(ce.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",P&&"slide-player__action--active"),disabled:!O,onClick:z,type:"button",children:t.jsxRuntimeExports.jsx(ae.default,{className:"slide-player__icon",strokeWidth:2.25})})})]}):null]})};exports.default=fe;
|
|
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\nexport type PlayerProps = React.ComponentProps<\"div\"> & {\n audioList?: SlideAudioItem[];\n currentAudioIndex?: number;\n defaultPlaying?: boolean;\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 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 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?.sequenceNumber ?? \"none\"}:${currentAudioUrl ?? \"\"}`;\n\n useEffect(() => {\n currentAudioRef.current = currentAudio;\n }, [currentAudio]);\n\n useEffect(() => {\n currentAudioSegmentsRef.current = currentAudioSegments;\n }, [currentAudioSegments]);\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 resetAudio = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n pendingAutoPlayRef.current = false;\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 }, [currentAudioIndex]);\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 pendingAutoPlayRef.current = defaultPlaying;\n\n const hasNewSrc = audioSrcRef.current !== nextAudioSrc;\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 (!defaultPlaying) {\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 [currentAudioIndex, defaultPlaying, getSegmentSrc, tryPlayCurrentAudio]\n );\n\n const finishAudioItem = useCallback(() => {\n pendingAutoPlayRef.current = false;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n setIsPlaying(false);\n\n if (currentAudioIndex >= 0) {\n onEnded?.(currentAudioIndex);\n }\n }, [currentAudioIndex, onEnded]);\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(defaultPlaying);\n\n return;\n }\n\n finishAudioItem(\"segments-completed\");\n }, [\n currentAudioIndex,\n defaultPlaying,\n finishAudioItem,\n startSegmentPlayback,\n ]);\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 pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioSrcRef.current = null;\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 ]);\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\n if (hasNewSrc) {\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = currentAudioUrl;\n audioElement.src = currentAudioUrl;\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 pendingAutoPlayRef.current = defaultPlaying;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n\n if (!defaultPlaying) {\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 startSegmentPlayback(waitingSegmentIndexRef.current, \"wait-resume\");\n return;\n }\n\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n setIsPlaying(defaultPlaying);\n return;\n }\n\n if (!currentAudioSegments.length) {\n if (currentAudio.isAudioStreaming) {\n waitingSegmentIndexRef.current = currentSegmentIndexRef.current;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n setIsPlaying(defaultPlaying);\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) {\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 ]);\n\n useEffect(() => resetAudio, [resetAudio]);\n\n const handleAudioPlay = useCallback(() => {\n setIsPlaying(true);\n }, [currentAudioIndex]);\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 isSwitchingSegmentRef.current = false;\n\n if (\n currentAudioRef.current?.audioUrl ||\n currentAudioSegmentsRef.current.length === 0\n ) {\n finishAudioItem(\"url-ended\");\n return;\n }\n\n handleSegmentEnded();\n }, [currentAudioIndex, finishAudioItem, handleSegmentEnded]);\n\n const handleAudioError = useCallback(() => {\n setIsPlaying(false);\n }, [currentAudioIndex]);\n\n return (\n <div className={cn(\"slide-player\", className)} {...props}>\n <audio\n ref={audioRef}\n preload=\"metadata\"\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 waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n setIsPlaying(false);\n audioElement.pause();\n return;\n }\n\n onPlayRequest?.();\n pendingAutoPlayRef.current = true;\n setIsPlaying(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 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 pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"toggle-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = false;\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":["PauseIcon","jsxs","jsx","PlayIcon","Player","audioList","className","currentAudioIndex","defaultPlaying","onPrev","onNext","onFullscreen","onEnded","onPlayRequest","onInteractionToggle","hasInteraction","isInteractionOpen","prevDisabled","nextDisabled","showControls","props","audioRef","useRef","audioSrcRef","currentAudioKeyRef","currentSegmentIndexRef","waitingSegmentIndexRef","currentAudioRef","currentAudioSegmentsRef","isWaitingForSegmentRef","pendingAutoPlayRef","pendingSeekTimeRef","isSwitchingSegmentRef","isPlaying","setIsPlaying","useState","currentAudio","currentAudioUrl","currentAudioSegments","useMemo","prevSegment","nextSegment","currentAudioKey","useEffect","getSegmentSrc","useCallback","audioData","resetAudio","audioElement","tryPlayCurrentAudio","_reason","playPromise","_error","startSegmentPlayback","segmentIndex","segment","nextAudioSrc","hasNewSrc","finishAudioItem","handleSegmentEnded","nextSegmentIndex","segments","activeAudio","hasFinal","handleAudioPlay","handleAudioPause","handleAudioCanPlay","handleLoadedMetadata","handleAudioEnded","handleAudioError","cn","EllipsisVertical","Volume2","RotateCcw","RotateCw","Maximize","FilePenLine"],"mappings":"kvCAqCMA,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,GAAgC,CAAC,CACrC,UAAAC,EAAY,CAAA,EACZ,UAAAC,EACA,kBAAAC,EAAoB,GACpB,eAAAC,EAAiB,GACjB,OAAAC,EACA,OAAAC,EACA,aAAAC,EACA,QAAAC,EACA,cAAAC,EACA,oBAAAC,EACA,eAAAC,EAAiB,GACjB,kBAAAC,EAAoB,GACpB,aAAAC,EAAe,GACf,aAAAC,EAAe,G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AAA,EAEhC,QAAA,EAEF,MACF,CAEA,GAAIU,EAAa,OAAQ,CACvBnC,IAAA,EACAiB,EAAmB,QAAU,GAC7BmB,EAAoB,eAAe,EACnC,MACF,CAEAnB,EAAmB,QAAU,GAC7BkB,EAAa,MAAA,EACf,EACA,KAAK,SAEJ,SAAAf,EAAY/B,wBAACF,GAAA,CAAA,CAAU,0BAAMG,GAAA,CAAA,CAAS,CAAA,CAAA,EAEzCD,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,UACX,UAAU,uBACV,SAAUgB,EACV,QAASR,EACT,KAAK,SAEL,SAAAR,EAAAA,kBAAAA,IAACwE,WAAA,CAAS,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,EAE9DxE,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,aACX,UAAU,SACV,QAASS,EACT,KAAK,SAEL,SAAAT,EAAAA,kBAAAA,IAACyE,WAAA,CAAS,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,CAC9D,EACF,EAEAzE,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yBAAA,CAA0B,EAEzCA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,sBACb,SAAAA,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,QACX,UAAWoE,EAAAA,GACT,uBACAtD,GAAqB,8BAAA,EAEvB,SAAU,CAACD,EACX,QAASD,EACT,KAAK,SAEL,SAAAZ,EAAAA,kBAAAA,IAAC0E,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\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 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?.sequenceNumber ?? \"none\"}:${currentAudioUrl ?? \"\"}`;\n\n useEffect(() => {\n currentAudioRef.current = currentAudio;\n }, [currentAudio]);\n\n useEffect(() => {\n currentAudioSegmentsRef.current = currentAudioSegments;\n }, [currentAudioSegments]);\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 resetAudio = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n pendingAutoPlayRef.current = false;\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 pendingAutoPlayRef.current = defaultPlaying;\n updateLoading(false);\n\n const hasNewSrc = audioSrcRef.current !== nextAudioSrc;\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 (!defaultPlaying) {\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(defaultPlaying);\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 pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\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\n if (hasNewSrc) {\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = currentAudioUrl;\n audioElement.src = currentAudioUrl;\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 pendingAutoPlayRef.current = defaultPlaying;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n updateLoading(false);\n\n if (!defaultPlaying) {\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 startSegmentPlayback(waitingSegmentIndexRef.current, \"wait-resume\");\n return;\n }\n\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n setIsPlaying(defaultPlaying);\n updateLoading(true);\n return;\n }\n\n if (!currentAudioSegments.length) {\n if (currentAudio.isAudioStreaming) {\n waitingSegmentIndexRef.current = currentSegmentIndexRef.current;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n setIsPlaying(defaultPlaying);\n updateLoading(true);\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) {\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 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 isSwitchingSegmentRef.current = false;\n\n if (\n currentAudioRef.current?.audioUrl ||\n currentAudioSegmentsRef.current.length === 0\n ) {\n finishAudioItem(\"url-ended\");\n return;\n }\n\n handleSegmentEnded();\n }, [currentAudioIndex, 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=\"metadata\"\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 waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n setIsPlaying(false);\n audioElement.pause();\n return;\n }\n\n onPlayRequest?.();\n pendingAutoPlayRef.current = true;\n setIsPlaying(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 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 pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"toggle-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = false;\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":["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","isWaitingForSegmentRef","pendingAutoPlayRef","pendingSeekTimeRef","isSwitchingSegmentRef","isPlaying","setIsPlaying","useState","currentAudio","currentAudioUrl","currentAudioSegments","useMemo","prevSegment","nextSegment","currentAudioKey","useEffect","updateLoading","useCallback","loading","getSegmentSrc","audioData","resetAudio","audioElement","tryPlayCurrentAudio","_reason","playPromise","_error","startSegmentPlayback","segmentIndex","segment","nextAudioSrc","hasNewSrc","finishAudioItem","handleSegmentEnded","nextSegmentIndex","segments","activeAudio","hasFinal","handleAudioPlay","handleAudioPause","handleAudioCanPlay","handleLoadedMetadata","handleAudioEnded","handleAudioError","cn","EllipsisVertical","Volume2","RotateCcw","RotateCw","Maximize","FilePenLine"],"mappings":"kvCAsCMA,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,kBAA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wBAACF,GAAA,CAAA,CAAU,0BAAMG,GAAA,CAAA,CAAS,CAAA,CAAA,EAEzCD,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,UACX,UAAU,uBACV,SAAUiB,EACV,QAASR,EACT,KAAK,SAEL,SAAAT,EAAAA,kBAAAA,IAAC4E,WAAA,CAAS,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,EAE9D5E,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,aACX,UAAU,SACV,QAASU,EACT,KAAK,SAEL,SAAAV,EAAAA,kBAAAA,IAAC6E,WAAA,CAAS,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,CAC9D,EACF,EAEA7E,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yBAAA,CAA0B,EAEzCA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,sBACb,SAAAA,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,QACX,UAAWwE,EAAAA,GACT,uBACAzD,GAAqB,8BAAA,EAEvB,SAAU,CAACD,EACX,QAASD,EACT,KAAK,SAEL,SAAAb,EAAAA,kBAAAA,IAAC8E,WAAA,CAAY,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,CACjE,CACF,CAAA,CAAA,CACF,EACE,IAAA,EACN,CAEJ"}
|
|
@@ -4,6 +4,7 @@ export type PlayerProps = React.ComponentProps<"div"> & {
|
|
|
4
4
|
audioList?: SlideAudioItem[];
|
|
5
5
|
currentAudioIndex?: number;
|
|
6
6
|
defaultPlaying?: boolean;
|
|
7
|
+
onLoadingChange?: (loading: boolean) => void;
|
|
7
8
|
onPrev?: () => void;
|
|
8
9
|
onNext?: () => void;
|
|
9
10
|
onFullscreen?: () => void;
|