onconnect = function( e ) {
    const port = e.ports[0];
    url = port.url;
    port.onmessage = onmessage.bind(port);
}
onmessage = async function (e) { switch(e.data?.type){
    case 'init':{
        url = e.data.url;
        phrases = await fetch(url + '/dictionary/phrases.json');
        phrases = await phrases.json();
        console.log(phrases)

    } break;
    case 'setlanguage':{
        console.log('setlanguage')
        // let language = e.data.language
        dictionary = await fetch(url + '/dictionary/' + e.data.language + '.json');
        dictionary = await dictionary.json();
        console.log(dictionary)

    } break;
    case 'translate':{
        console.log('translate')

    } break;
    case 'edit':{
        console.log('edit')

    } break;

    case 'save':{
        console.log('save')

    } break;    
    
    default:{
        
    } break; 
}}

let url;
let language; // -- ?
let dictionary = {};
let phrases = {};

// const resolves = {};
// let resId = 0;