38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * import {...} from 'xrf/level0'
 | 
						|
 *
 | 
						|
 * | function               | example                                                                 |
 | 
						|
 * |------------------------|-------------------------------------------------------------------------|
 | 
						|
 * | sideCarFiles(...)      | sideCarFiles("https://f.org/a.glb") `// ["https://f.org/a.png",...]`    |
 | 
						|
 * | fetchSideCarFiles(...) | await fetchSideCarFiles("https://f.org/a.glb") `// [{code:200},...]`    |
 | 
						|
 *  
 | 
						|
 */ 
 | 
						|
import * as http from './scheme/http.js'
 | 
						|
import * as xrf  from './scheme/http.js'
 | 
						|
 | 
						|
function defaultSchemes(){
 | 
						|
  return {http,xrf}
 | 
						|
}
 | 
						|
 | 
						|
async function sideCarFiles(urlString, opts){
 | 
						|
 | 
						|
  const sext  = [".png",".ogg",".vtt",".json"]
 | 
						|
}
 | 
						|
 | 
						|
async function fetchSideCarFiles(urlString, opts){
 | 
						|
 | 
						|
  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.allSettled(p)
 | 
						|
}
 | 
						|
 | 
						|
export {pollSideCarFiles}
 |