@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.16 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});const e={CondoWebAppRequestAuth:1e4};function o(o,t){const n=function(){const e=function*(){let e=0;for(;;)yield e++}(),o={};return{add(t,n){const r=n||e.next().value;return o[r]=t,r},resolve(e,t,n){const r=o[e];r&&(n(t)?r.resolve(t):r.reject(t),delete o[e])}}}();return t(e=>{if(e&&e.data&&"object"==typeof e.data&&"requestId"in e.data){const o=e.data,{requestId:t}=o,r=function(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}(o,["requestId"]);void 0!==t&&n.resolve(t,r,e=>!("errorType"in e))}}),function(t,r={},s){const d=s||e[t]||1e3;return Promise.race([new Promise((e,s)=>{const d=n.add({resolve:e,reject:s},r.requestId);o(t,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 t="2.3.0";const n="undefined"!=typeof window,r=[...n?["CondoWebAppCloseModalWindow","CondoWebAppGetActiveProgressBars","CondoWebAppGetFragment","CondoWebAppGetLaunchParams","CondoWebAppRedirect","CondoWebAppRequestAuth","CondoWebAppResizeWindow","CondoWebAppShowModalWindow","CondoWebAppShowNotification","CondoWebAppShowProgressBar","CondoWebAppUpdateModalWindow","CondoWebAppUpdateProgressBar"]:[]],s=n?parent:void 0;const d=function(){const e=[];function d(o){e.push(o)}return n&&"addEventListener"in window&&window.addEventListener("message",function(o){const t=o.data;"object"==typeof t&&e.forEach(e=>e(t))}),{send:o(function(e,o){s&&"function"==typeof s.postMessage&&s.postMessage({handler:e,params:o,type:"condo-bridge",version:t},"*")},d),supports:function(e){return r.includes(e)},subscribe:d,unsubscribe:function(o){const t=e.indexOf(o);t>=0&&e.splice(t,1)}}}();exports.default=d;
//# sourceMappingURL=index.js.map