UNPKG

@open-condo/bridge

Version:

A library that allows the client of your mini-application to communicate with the main user's client on different devices, using a common bridge API

3 lines (2 loc) 2.13 kB
!function(){"use strict";const e={CondoWebAppRequestAuth:1e4};function o(o,n){const t=function(){const e=function*(){let e=0;for(;;)yield e++}(),o={};return{add(n,t){const r=t||e.next().value;return o[r]=n,r},resolve(e,n,t){const r=o[e];r&&(t(n)?r.resolve(n):r.reject(n),delete o[e])}}}();return n(e=>{if(e&&e.data&&"object"==typeof e.data&&"requestId"in e.data){const o=e.data,{requestId:n}=o,r=function(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(t=Object.getOwnPropertySymbols(e);r<t.length;r++)o.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(n[t[r]]=e[t[r]])}return n}(o,["requestId"]);void 0!==n&&t.resolve(n,r,e=>!("errorType"in e))}}),function(n,r={},s){const d=s||e[n]||1e3;return Promise.race([new Promise((e,s)=>{const d=t.add({resolve:e,reject:s},r.requestId);o(n,Object.assign(Object.assign({},r),{requestId:d}))}),new Promise((e,o)=>{setTimeout(()=>o(function(e){return{errorType:"client",errorCode:5,errorReason:"TIMEOUT_REACHED",errorMessage:`Request was failed. Response was not received in ${e} ms timeout.`}}(d)),d)})])}}var n="2.3.0";const t="undefined"!=typeof window,r=[...t?["CondoWebAppCloseModalWindow","CondoWebAppGetActiveProgressBars","CondoWebAppGetFragment","CondoWebAppGetLaunchParams","CondoWebAppRedirect","CondoWebAppRequestAuth","CondoWebAppResizeWindow","CondoWebAppShowModalWindow","CondoWebAppShowNotification","CondoWebAppShowProgressBar","CondoWebAppUpdateModalWindow","CondoWebAppUpdateProgressBar"]:[]],s=t?parent:void 0;const d=function(){const e=[];function d(o){e.push(o)}return t&&"addEventListener"in window&&window.addEventListener("message",function(o){const n=o.data;"object"==typeof n&&e.forEach(e=>e(n))}),{send:o(function(e,o){s&&"function"==typeof s.postMessage&&s.postMessage({handler:e,params:o,type:"condo-bridge",version:n},"*")},d),supports:function(e){return r.includes(e)},subscribe:d,unsubscribe:function(o){const n=e.indexOf(o);n>=0&&e.splice(n,1)}}}();window.condoBridge=d}(); //# sourceMappingURL=browser.min.js.map