{"version":3,"names":["postMessage","message","Promise","resolve","reject","channel","MessageChannel","port1","onmessage","navigator","serviceWorker","controller","port2","window","addEventListener","error","console","log"],"sources":["messaging.js"],"sourcesContent":["\"use strict\";\n\nwindow.addEventListener('error', function(error) {\n    console.log(\"Error:\",  error);\n});\n\n/**\n * Send a message to the ServiceWorker and waits for an answer\n * @param message\n * @returns {Promise} A Promise resolving with the answer from the ServiceWorker\n */\nexport function postMessage (message) {\n    // TODO: what about rejecting the Promise onerror\n    return new Promise(function(resolve, reject) {\n        var channel = new MessageChannel();\n        channel.port1.onmessage = resolve;\n\n        navigator.serviceWorker.controller.postMessage(message, [channel.port2])\n    });\n}\n"],"mappings":"AAAA,YAAY;;AAAC;EAAA;;EAAA;EAMb;AACA;AACA;AACA;AACA;EACO,SAASA,WAAW,CAAEC,OAAO,EAAE;IAClC;IACA,OAAO,IAAIC,OAAO,CAAC,UAASC,OAAO,EAAEC,MAAM,EAAE;MACzC,IAAIC,OAAO,GAAG,IAAIC,cAAc,EAAE;MAClCD,OAAO,CAACE,KAAK,CAACC,SAAS,GAAGL,OAAO;MAEjCM,SAAS,CAACC,aAAa,CAACC,UAAU,CAACX,WAAW,CAACC,OAAO,EAAE,CAACI,OAAO,CAACO,KAAK,CAAC,CAAC;IAC5E,CAAC,CAAC;EACN;EAAC,uBAReZ,WAAW;EAAA;IAAA;IAAA;MAAA;MAAA;MAAA;QAAA;UAAA;QAAA;QAAA;UAAA,uBAAXA,4CAAW;UAAA;QAAA;QAAA;QAAA;MAAA;MAT3Ba,MAAM,CAACC,gBAAgB,CAAC,OAAO,EAAE,UAASC,KAAK,EAAE;QAC7CC,OAAO,CAACC,GAAG,CAAC,QAAQ,EAAGF,KAAK,CAAC;MACjC,CAAC,CAAC;IAAC;EAAA;AAAA"}