1import { SourceCatalogue } from "./SourceCatalogue.mjs"; 2import { HasRegions } from "./SourceFeatures.mjs"; 3 4export class NebulaCatalogue extends SourceCatalogue 5{ 6 7 async Fetch(source) 8 { 9 await source.Resolve(); 10 11 if (!HasRegions(source.target)) return UniverseSkies(source); 12 13 const answer = await source.Fetch("map/regions?expand=scene"); 14 15 if (!answer.ok) return []; 16 17 const doc = await answer.json(); 18 const regions = Array.isArray(doc) ? doc : doc?.regions ?? []; 19 20 return regions 21 22 .filter(region => region?.derived?.nebula?.graphics?.scene) 23 .map(region => ({ 24 id: region.id, 25 name: String(region.name || region.id).toUpperCase(), 26 path: region.derived.nebula.graphics.scene 27 })) 28 .sort((left, right) => left.name.localeCompare(right.name)); 29 } 30 31} 32 33async function UniverseSkies(source) 34{ 35 let children; 36 37 try 38 { 39 const answer = await source.FetchResource("resources/dx9/scene/universe/"); 40 41 if (!answer.ok) return []; 42 43 children = (await answer.json())?.children ?? []; 44 } 45 catch 46 { 47 return []; 48 } 49 50 const names = new Set(children.map(child => child.name)); 51 52 return children 53 .filter(child => child.name.endsWith(".black")) 54 .map(child => child.name.replace(/.black$/u, "")) 55 .filter(stem => names.has(`${stem}.dds`)) 56 .map(stem => ({ 57 id: stem, 58 name: stem.replace(/_cube$/u, "").replace(/_/gu, " ").toUpperCase(), 59 path: `res:/dx9/scene/universe/${stem}.black` 60 })) 61 .sort((left, right) => left.name.localeCompare(right.name)); 62} 63 64export const nebulaCatalogue = new NebulaCatalogue(); 65 66export default nebulaCatalogue;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.