@bizkit.io/webclient 1.0.3 → 1.0.5
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Copyright (c) 2026 bizkit.io
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import e from"p-throttle";let t,n,r=!1;const
|
|
4
|
+
import e from"p-throttle";let t,n,r,i=!1;const a=e({limit:1,interval:50});async function o(e){return new Promise(t=>setTimeout(t,e))}async function s(){if(i)return;let e=0;do try{await u({op:`ping`},50),i=!0;return}catch{await o(50)}while(++e<10);return Promise.reject()}async function c(e){if(!(r&&i))return t=e?`http://w.bizkit.io`:`http://dw.bizkit.io`,n=t+`/iframe`,new Promise((e,t)=>{async function i(){await o(100),await s(),e()}r=document.createElement(`iframe`),r.src=n,r.onload=i,r.referrerPolicy=`no-referrer`,document.body.appendChild(r)})}function l(e,t){return r?new Promise((i,a)=>{let o=setTimeout(a,t),s=new MessageChannel;s.port1.onmessage=e=>{clearTimeout(o),i(e.data)},r.contentWindow?.postMessage(e,n,[s.port2])}):Promise.reject(`not initialized!`)}const u=a(l);async function d(){if(!r||!i)return Promise.reject(`not initialized!`);let e=await u({op:`get_bizkit_token`,url:location.origin},2e3);return e.url=new URL(e.url,t).toString(),e}typeof window<`u`&&window!==void 0&&(window.bizkit_init=c,window.get_bizkit_token=d);export{c as bizkit_init,d as get_bizkit_token};
|