2025-10-02 16:56:10 +02:00
|
|
|
/**
|
|
|
|
|
* ### import {...} from 'xrf/level0'
|
|
|
|
|
*
|
|
|
|
|
* | function | example |
|
|
|
|
|
* |------------------------|-------------------------------------------------------------------------|
|
|
|
|
|
* | fetchSideCarFiles(...) | fetchSideCarFiles("https://f.org/a.glb") // ["https://f.org/a.png",...] |
|
|
|
|
|
*
|
|
|
|
|
*/
|
2025-09-30 13:20:59 +02:00
|
|
|
import * as http from './scheme/http.js'
|
|
|
|
|
import * as xrf from './scheme/http.js'
|
|
|
|
|
|
|
|
|
|
function defaultSchemes(){
|
|
|
|
|
return {http,xrf}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-02 16:56:10 +02:00
|
|
|
async function sideCarFiles(urlString, opts){
|
|
|
|
|
|
|
|
|
|
const sext = [".png",".ogg",".vtt",".json"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchSideCarFiles(urlString, opts){
|
2025-09-30 13:20:59 +02:00
|
|
|
|
|
|
|
|
opts = {}
|
|
|
|
|
opts.scheme = opts.scheme || defaultSchemes()
|
|
|
|
|
let p = []
|
|
|
|
|
const sext = [".png",".ogg",".vtt",".json"]
|
|
|
|
|
ext = urlString.lastIndexOf('.')
|
|
|
|
|
|
|
|
|
|
for( let i in ext) p.push(
|
|
|
|
|
new Promise( (resolve,reject) => {
|
|
|
|
|
fetch( urlString.replace(ext, sext[i] ), { method:'HEAD'} )
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
await Promise.all(p)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export {pollSideCarFiles}
|