@convai/web-widget 0.3.1 → 0.3.2

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 CHANGED
@@ -13,7 +13,7 @@ production** — [step two](#before-you-ship) moves it to your server.
13
13
 
14
14
  ```html
15
15
  <convai-widget character-id="YOUR_CHARACTER_ID" api-key="YOUR_API_KEY"></convai-widget>
16
- <script src="https://cdn.jsdelivr.net/npm/@convai/web-widget@0.3.1/v1.js" async></script>
16
+ <script src="https://cdn.jsdelivr.net/npm/@convai/web-widget@0.3.2/v1.js" async></script>
17
17
  ```
18
18
 
19
19
  A launcher bubble appears in the bottom-right corner. Click it: the runtime
@@ -26,7 +26,7 @@ The script tag goes in your HTML shell; the element is ordinary JSX.
26
26
 
27
27
  ```html
28
28
  <!-- index.html -->
29
- <script src="https://cdn.jsdelivr.net/npm/@convai/web-widget@0.3.1/v1.js" async></script>
29
+ <script src="https://cdn.jsdelivr.net/npm/@convai/web-widget@0.3.2/v1.js" async></script>
30
30
  ```
31
31
 
32
32
  ```jsx
@@ -167,16 +167,16 @@ guide; theming and `::part()` hooks; CSP requirements; and guidance on
167
167
 
168
168
  ## Versioning
169
169
 
170
- `0.3.1` is a stable release: `npm install @convai/web-widget` and
170
+ `0.3.2` is a stable release: `npm install @convai/web-widget` and
171
171
  jsDelivr's unversioned URL both resolve it. Pin the exact version anyway for
172
172
  reproducible deploys —
173
173
 
174
174
  ```html
175
- <script src="https://cdn.jsdelivr.net/npm/@convai/web-widget@0.3.1/v1.js" async></script>
175
+ <script src="https://cdn.jsdelivr.net/npm/@convai/web-widget@0.3.2/v1.js" async></script>
176
176
  ```
177
177
 
178
178
  ```bash
179
- npm install @convai/web-widget@0.3.1 # only needed to self-host the two files
179
+ npm install @convai/web-widget@0.3.2 # only needed to self-host the two files
180
180
  ```
181
181
 
182
182
  This package is early, and it bundles a prerelease of `@convai/web-sdk`. The
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const VERSION = "0.3.1";
1
+ const VERSION = "0.3.2";
2
2
  export {
3
3
  VERSION
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convai/web-widget",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Two-line script-tag embed for the Convai chat widget. A <convai-widget> custom element with a closed shadow root and a lazily loaded runtime.",
5
5
  "homepage": "https://docs.convai.com/embed",
6
6
  "repository": {
package/runtime.js CHANGED
@@ -8246,7 +8246,7 @@ function Rp(n) {
8246
8246
  value: n.value
8247
8247
  });
8248
8248
  }
8249
- class Cv extends Pt.EventEmitter {
8249
+ class _v extends Pt.EventEmitter {
8250
8250
  constructor() {
8251
8251
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8252
8252
  super(), this.latestManuallySetKeyIndex = 0, this.onKeyRatcheted = (t, i, s) => {
@@ -17427,7 +17427,7 @@ class Wm extends ei {
17427
17427
  });
17428
17428
  }
17429
17429
  }
17430
- class _v extends Pt.EventEmitter {
17430
+ class wv extends Pt.EventEmitter {
17431
17431
  constructor(e, t) {
17432
17432
  let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
17433
17433
  super(), this.options = {}, this.checkResults = /* @__PURE__ */ new Map(), this.url = e, this.token = t, this.options = i;
@@ -25841,20 +25841,26 @@ function fv(n, e) {
25841
25841
  }
25842
25842
  function gv(n) {
25843
25843
  return new Promise((e, t) => {
25844
- const i = () => {
25845
- try {
25846
- n(), e();
25847
- } catch (s) {
25848
- t(s instanceof Error ? s : new Error(String(s)));
25844
+ let i = !1, s, r;
25845
+ const o = () => {
25846
+ if (!i) {
25847
+ i = !0, s !== void 0 && cancelAnimationFrame(s), r !== void 0 && clearTimeout(r);
25848
+ try {
25849
+ n(), e();
25850
+ } catch (a) {
25851
+ t(a instanceof Error ? a : new Error(String(a)));
25852
+ }
25849
25853
  }
25850
25854
  };
25851
- typeof requestAnimationFrame == "function" ? requestAnimationFrame(i) : i();
25855
+ if (typeof requestAnimationFrame != "function") return o();
25856
+ s = requestAnimationFrame(o), r = setTimeout(o, vv);
25852
25857
  });
25853
25858
  }
25854
- function vv(n) {
25859
+ const vv = 100;
25860
+ function bv(n) {
25855
25861
  return typeof n == "object" && n !== null && n.code === "mic-permission";
25856
25862
  }
25857
- function bv(n, e) {
25863
+ function yv(n, e) {
25858
25864
  const t = document.createElement("div");
25859
25865
  t.className = "convai-retry", t.setAttribute("role", "alert"), t.style.cssText = `
25860
25866
  position: fixed;
@@ -25886,7 +25892,7 @@ function bv(n, e) {
25886
25892
  font: inherit;
25887
25893
  `, s.addEventListener("click", e), t.append(i, s), t;
25888
25894
  }
25889
- const yv = Object.freeze({
25895
+ const Sv = Object.freeze({
25890
25896
  open() {
25891
25897
  },
25892
25898
  close() {
@@ -25899,10 +25905,10 @@ const yv = Object.freeze({
25899
25905
  },
25900
25906
  client: null
25901
25907
  });
25902
- async function wv(n) {
25908
+ async function Ev(n) {
25903
25909
  const e = [];
25904
25910
  try {
25905
- return await Sv(n, e);
25911
+ return await kv(n, e);
25906
25912
  } catch (t) {
25907
25913
  n.emitError("runtime", `mount failed: ${String(t)}`);
25908
25914
  for (const i of e.reverse())
@@ -25910,10 +25916,10 @@ async function wv(n) {
25910
25916
  i();
25911
25917
  } catch {
25912
25918
  }
25913
- return yv;
25919
+ return Sv;
25914
25920
  }
25915
25921
  }
25916
- async function Sv(n, e) {
25922
+ async function kv(n, e) {
25917
25923
  const { root: t, config: i, launcher: s, emit: r, emitError: o, engaged: a } = n, c = document.createElement("div");
25918
25924
  i.accent && c.style.setProperty("--convai-accent", i.accent);
25919
25925
  const d = Er(i) === "publication";
@@ -25966,7 +25972,7 @@ async function Sv(n, e) {
25966
25972
  let C = !1, k = null;
25967
25973
  const P = (K) => {
25968
25974
  if (!C) {
25969
- if (vv(K)) {
25975
+ if (bv(K)) {
25970
25976
  o("mic-permission", String(K));
25971
25977
  return;
25972
25978
  }
@@ -25977,7 +25983,7 @@ async function Sv(n, e) {
25977
25983
  const f = () => {
25978
25984
  E && (E.remove(), E = null);
25979
25985
  }, v = () => {
25980
- E || C || (E = bv(i, D), t.appendChild(E));
25986
+ E || C || (E = yv(i, D), t.appendChild(E));
25981
25987
  };
25982
25988
  e.push(f);
25983
25989
  let T = null, w = !1, L = !1;
@@ -26155,5 +26161,5 @@ async function Sv(n, e) {
26155
26161
  };
26156
26162
  }
26157
26163
  export {
26158
- wv as mount
26164
+ Ev as mount
26159
26165
  };