@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 862 B
JavaScript
export function createStyleTransform(p,a,c){if(typeof p!="string")return c?(e,o)=>c(o):void 0;const y=new URL(p,window.location.href).href,n=e=>new URL(e,y).href.replace(/%7B/g,"{").replace(/%7D/g,"}"),l=e=>{if(!e.startsWith("pmtiles://"))return n(e);const o=n(e.slice(10));return a?.(o),`pmtiles://${o}`};return(e,o)=>{const r={...o};typeof r.sprite=="string"?r.sprite=n(r.sprite):Array.isArray(r.sprite)&&(r.sprite=r.sprite.map(t=>{if(!t||typeof t!="object")return t;const s=t;return typeof s.url!="string"?t:{...s,url:n(s.url)}})),typeof r.glyphs=="string"&&(r.glyphs=n(r.glyphs));const f=r.sources;if(f){r.sources={...f};for(const[t,s]of Object.entries(f)){if(!s||typeof s!="object")continue;const i={...s};typeof i.url=="string"&&(i.url=l(i.url)),Array.isArray(i.tiles)&&(i.tiles=i.tiles.map(u=>typeof u=="string"?l(u):u)),r.sources[t]=i}}return c?c(r):r}}