@bizkit.io/webclient 1.0.4 → 1.0.6
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/README.md +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ import { type BizkitToken, bizkit_init, get_bizkit_token } from '@bizkit.io/webc
|
|
|
19
19
|
- Initialize the web client:
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
await bizkit_init(false); // false for development, true for production
|
|
22
|
+
await bizkit_init(false, 'HU-A100BB'); // false for development, true for production
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
- Get a token:
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,7 @@ type BizkitToken = {
|
|
|
6
6
|
token: string;
|
|
7
7
|
url: string;
|
|
8
8
|
};
|
|
9
|
-
declare function bizkit_init(production: boolean): Promise<void>;
|
|
9
|
+
declare function bizkit_init(production: boolean, id: string): Promise<void>;
|
|
10
10
|
declare function get_bizkit_token(): Promise<BizkitToken>;
|
|
11
|
-
declare global {
|
|
12
|
-
function bizkit_init(production: boolean): Promise<void>;
|
|
13
|
-
function get_bizkit_token(): Promise<BizkitToken>;
|
|
14
|
-
}
|
|
15
11
|
//#endregion
|
|
16
12
|
export { BizkitToken, bizkit_init, get_bizkit_token };
|
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,a){if(!(r&&i))return a?(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)})):Promise.reject(`need content provider id`)}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}export{c as bizkit_init,d as get_bizkit_token};
|