import pako from 'pako'

self.onmessage = function({ data }) {
    let result = null;
    let mapName = null;
    try {
        const {type, msg} = data;
        let [, , name] = type.split('/')
        mapName = name
        let charData = msg.split('').map( x => x.charCodeAt(0));
        let binData = new Uint8Array(charData);
        result = pako.inflate(binData, {to: 'string'});
    } catch(error) {
        console.log(error)
    }
    self.postMessage({mapName, result, mapVersion: data.version})
    data = null;
    result = null;
}