@coasys/ad4m-connect 0.8.0 → 0.8.2-prerelease
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +93 -90
- package/dist/utils.js +1 -1
- package/dist/web.js +134 -126
- package/package.json +1 -1
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a=(e,t,o)=>new Promise((n,
|
|
1
|
+
var a=(e,t,o)=>new Promise((n,r)=>{var c=s=>{try{l(o.next(s))}catch(u){r(u)}},p=s=>{try{l(o.throw(s))}catch(u){r(u)}},l=s=>s.done?n(s.value):Promise.resolve(s.value).then(c,p);l((o=o.apply(e,t)).next())});var i="0.8.2-prerelease";function b(){let e=new AbortController;return setTimeout(()=>e.abort(),20),e}function w(e,t=1e4){return a(this,null,function*(){return Promise.race([new Promise((o,n)=>{e.includes("localhost")||o(new WebSocket(e));let r=new WebSocket(e);r.onopen=()=>{o(r)},r.onerror=c=>{n(c)}}),new Promise((o,n)=>{setTimeout(()=>{n(new Error("WebSocket connection timed out"))},t)})])})}function j(e){return a(this,null,function*(){try{let t=yield fetch(`http://localhost:${e}/graphql/`,{signal:b().signal,mode:"no-cors"});if(t.status===400||t.status===0)return e;throw new Error(`Could not connect to port ${e}`)}catch(t){throw new Error(`Could not connect to port ${e}`)}})}function v(){return new Promise((e,t)=>{let o=document.querySelector("ad4m-connect"),n=o==null?void 0:o.getAd4mClient();n?e(n):t("No Ad4mClient found")})}function y(e){let t=document.querySelector("ad4m-connect");t==null||t.addEventListener("authstatechange",o=>{e(o.detail)})}function S(){let e=navigator.userAgent,t="";return e.search("Windows")!==-1?t="Windows":e.search("Mac")!==-1?t="MacOS":e.search("X11")!==-1&&e.search("Linux")===-1?t="UNIX":e.search("Linux")!==-1&&e.search("X11")!==-1&&(t="Linux"),t}function d(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(e){return!1}return!0}function x(e,t){d()&&localStorage.setItem(`${i}/${e}`,t)}function A(e){return d()?localStorage.getItem(`${i}/${e}`):null}function C(e){d()&&localStorage.removeItem(`${i}/${e}`)}export{j as checkPort,w as connectWebSocket,S as detectOS,v as getAd4mClient,A as getForVersion,y as onAuthStateChanged,C as removeForVersion,x as setForVersion};
|