@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.29 kB
JavaScript
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self)["@open-condo/bridge"]={})}(this,function(e){"use strict";const d=1e3,i={errorType:"client",errorCode:5,errorReason:"TIMEOUT_REACHED",errorMessage:`Request was failed. Response was not received in ${d} ms timeout.`};function o(){const n=function*(){let e=0;for(;;)yield e++}(),r={};return{add(e,o){o=o||n.next().value;return r[o]=e,o},resolve(e,o,n){var t=r[e];t&&(n(o)?t.resolve(o):t.reject(o),delete r[e])}}}function t(r,e){const s=o();return e(e=>{var o;e&&e.data&&"object"==typeof e.data&&"requestId"in e.data&&(o=(e=e.data)["requestId"],e=function(e,o){var n={};for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var t=0,r=Object.getOwnPropertySymbols(e);t<r.length;t++)o.indexOf(r[t])<0&&Object.prototype.propertyIsEnumerable.call(e,r[t])&&(n[r[t]]=e[r[t]]);return n}(e,["requestId"]),void 0!==o)&&s.resolve(o,e,e=>!("errorType"in e))}),function(n,t={}){return Promise.race([new Promise((e,o)=>{e=s.add({resolve:e,reject:o},t.requestId);r(n,Object.assign(Object.assign({},t),{requestId:e}))}),new Promise((e,o)=>{setTimeout(()=>o(i),d)})])}}var r="2.0.0";const s="undefined"!=typeof window;const p=[...s?["CondoWebAppCloseModalWindow","CondoWebAppGetActiveProgressBars","CondoWebAppGetLaunchParams","CondoWebAppRedirect","CondoWebAppRequestAuth","CondoWebAppResizeWindow","CondoWebAppShowModalWindow","CondoWebAppShowNotification","CondoWebAppShowProgressBar","CondoWebAppUpdateModalWindow","CondoWebAppUpdateProgressBar"]:[]],a=s?parent:void 0;var n=function(){const n=[];function e(e){n.push(e)}return s&&"addEventListener"in window&&window.addEventListener("message",function(e){const o=e.data;"object"==typeof o&&n.forEach(e=>e(o))}),{send:t(function(e,o){a&&"function"==typeof a.postMessage&&a.postMessage({handler:e,params:o,type:"condo-bridge",version:r},"*")},e),supports:function(e){return p.includes(e)},subscribe:e,unsubscribe:function(e){0<=(e=n.indexOf(e))&&n.splice(e,1)}}}();e.default=n,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=index.umd.js.map