ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
import {useEffect,useState} from 'react'
import {resolveVerifiedPreview} from './previewOrigin'
export default function useVerifiedPreview(preview,fallback,refresh=0) {
const [result,setResult]=useState(null)
const key=preview?`${preview.siteId}/${preview.sha256}/${preview.entrySha256}/${preview.url}/${preview.port}/${preview.files}/${preview.bytes}/${refresh}`:''
useEffect(()=>{
if(!preview || !fallback)return
let current=true
const controller=new AbortController()
const timer=setTimeout(()=>controller.abort(new DOMException('Preview probe timed out','TimeoutError')),5000)
resolveVerifiedPreview(preview,fallback,controller.signal)
.then(access=>{if(current)setResult({key,access})})
.catch(()=>{if(current)setResult({key,access:{...fallback,frameUrl:null,unavailable:true}})})
.finally(()=>clearTimeout(timer))
return()=>{current=false;controller.abort();clearTimeout(timer)}
// The receipt and refresh key, not an ephemeral access object, own the probe.
},[key])
return result?.key===key?result.access:{...fallback,frameUrl:null,checking:true}
}