@wexio/messenger-widget-react 1.2.1 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @wexio/messenger-widget-react
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 948dbaf: Fix website page-view tracking reporting the PREVIOUS page's title after a SPA navigation. The host router changes the URL synchronously but updates `document.title` a tick later, so the title was read too early. Both capture paths (the iframe `loader.js` and the web-component provider) now wait for `<title>` to actually update (via a `MutationObserver`, with a short timeout fallback) before reporting, so the title matches the new URL.
8
+
3
9
  ## 1.2.1
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -177,6 +177,10 @@ For plain HTML / script-injection setups, paste the loader snippet from https://
177
177
 
178
178
  Give a ⭐️ if this package helped you!
179
179
 
180
+ ## Changelog
181
+
182
+ See the [Releases](https://github.com/wexiohub/messenger-widget-react/releases) page for the full changelog.
183
+
180
184
  ## 📝 License
181
185
 
182
186
  This project is [MIT](./LICENSE) licensed.
@@ -11,7 +11,7 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { S as e, at as t, it as n, j as r, ot as i } from "./widget-react-CVLHwRZh.js";
14
+ import { S as e, at as t, it as n, j as r, ot as i } from "./widget-react-CK8xTxwO.js";
15
15
  import { n as a, r as o } from "./widget-react-krPPnv02.js";
16
16
  import * as s from "react";
17
17
  import { jsx as c } from "react/jsx-runtime";
@@ -472,4 +472,4 @@ function G(e) {
472
472
  //#endregion
473
473
  export { G as a, U as c, _ as d, f, L as i, z as l, V as n, j as o, u as p, F as r, N as s, k as t, D as u };
474
474
 
475
- //# sourceMappingURL=widget-react--D5-TDqS.js.map
475
+ //# sourceMappingURL=widget-react-AwEaD0v2.js.map
@@ -12,11 +12,11 @@ import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
14
  import { i as e } from "./widget-react-B9XrHKqv.js";
15
- import { I as t, N as n, c as r, k as i, l as a, v as o, y as s } from "./widget-react-CVLHwRZh.js";
15
+ import { I as t, N as n, c as r, k as i, l as a, v as o, y as s } from "./widget-react-CK8xTxwO.js";
16
16
  import { i as c, n as l } from "./widget-react-krPPnv02.js";
17
- import { f as u, l as d, n as f, r as p, u as m } from "./widget-react--D5-TDqS.js";
17
+ import { f as u, l as d, n as f, r as p, u as m } from "./widget-react-AwEaD0v2.js";
18
18
  import { t as h } from "./widget-react-B8rXZyxg.js";
19
- import { a as g, c as ee, i as te, l as ne, n as _, o as v, r as y, s as b, t as x } from "./widget-react-D8-Z8fvu.js";
19
+ import { a as g, c as ee, i as te, l as ne, n as _, o as v, r as y, s as b, t as x } from "./widget-react-DDEFbIbU.js";
20
20
  import { useEffect as S, useMemo as C, useRef as w, useState as re } from "react";
21
21
  import { jsx as T, jsxs as E } from "react/jsx-runtime";
22
22
  //#region components/widget/help-article-view/helpers.ts
@@ -303,4 +303,4 @@ function ie() {
303
303
  //#endregion
304
304
  export { O as HelpArticleView };
305
305
 
306
- //# sourceMappingURL=widget-react-DF5yY9sQ.js.map
306
+ //# sourceMappingURL=widget-react-CAsPo1rw.js.map
@@ -9957,7 +9957,7 @@ function ip() {
9957
9957
  return w(rp);
9958
9958
  }
9959
9959
  function ap({ children: e, tracking: t, enabled: n, token: r }) {
9960
- let i = md(), [a] = Mu(), [o] = Pu(), s = n && (t?.trackWebsitePages ?? !0), c = n && (t?.trackWidgetLinks ?? !0), l = ne([]), u = ne(null), d = ne(null), f = C((e) => {
9960
+ let i = md(), [a] = Mu(), [o] = Pu(), s = n && (t?.trackWebsitePages ?? !0), c = n && (t?.trackWidgetLinks ?? !0), l = ne([]), u = ne(null), d = ne(null), f = ne(null), p = C((e) => {
9961
9961
  td() ? e.kind === "page" ? a({ variables: { input: e.input } }).catch(() => {}) : o({ variables: { input: e.input } }).catch(() => {}) : l.current = np(l.current, e, 50);
9962
9962
  }, [a, o]);
9963
9963
  T(() => {
@@ -9972,9 +9972,9 @@ function ap({ children: e, tracking: t, enabled: n, token: r }) {
9972
9972
  ]), T(() => () => {
9973
9973
  d.current && clearTimeout(d.current);
9974
9974
  }, []);
9975
- let p = C((e, t) => {
9975
+ let m = C((e, t) => {
9976
9976
  !s || !e || u.current && tp(u.current, e) || (d.current && clearTimeout(d.current), d.current = setTimeout(() => {
9977
- u.current = e, f({
9977
+ u.current = e, p({
9978
9978
  kind: "page",
9979
9979
  input: {
9980
9980
  url: e,
@@ -9984,8 +9984,8 @@ function ap({ children: e, tracking: t, enabled: n, token: r }) {
9984
9984
  }
9985
9985
  });
9986
9986
  }, 500));
9987
- }, [s, f]), m = C((e) => {
9988
- !c || !e.url || f({
9987
+ }, [s, p]), h = C((e) => {
9988
+ !c || !e.url || p({
9989
9989
  kind: "link",
9990
9990
  input: {
9991
9991
  url: e.url,
@@ -9996,42 +9996,54 @@ function ap({ children: e, tracking: t, enabled: n, token: r }) {
9996
9996
  occurredAt: (/* @__PURE__ */ new Date()).toISOString()
9997
9997
  }
9998
9998
  });
9999
- }, [c, f]);
9999
+ }, [c, p]);
10000
10000
  return T(() => {
10001
10001
  if (!s || typeof window > "u") return;
10002
10002
  if (i.kind === "iframe") {
10003
10003
  let e = (e) => {
10004
10004
  let t = e.data;
10005
- !t || typeof t != "object" || t.type !== "wexio:host-navigation:v1" || typeof t.url == "string" && p(t.url, {
10005
+ !t || typeof t != "object" || t.type !== "wexio:host-navigation:v1" || typeof t.url == "string" && m(t.url, {
10006
10006
  title: typeof t.title == "string" ? t.title : void 0,
10007
10007
  referrer: typeof t.referrer == "string" ? t.referrer : void 0
10008
10008
  });
10009
10009
  };
10010
10010
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
10011
10011
  }
10012
- let e = () => p(window.location.href, {
10012
+ let e = () => m(window.location.href, {
10013
10013
  title: document.title,
10014
10014
  referrer: document.referrer
10015
- });
10015
+ }), t = () => {
10016
+ f.current?.();
10017
+ let t = document.querySelector("title"), n = !1, r = () => {
10018
+ o?.disconnect(), clearTimeout(a), f.current = null;
10019
+ }, i = () => {
10020
+ n || (n = !0, r(), e());
10021
+ }, a = setTimeout(i, 600), o = null;
10022
+ t && typeof MutationObserver < "u" && (o = new MutationObserver(i), o.observe(t, {
10023
+ childList: !0,
10024
+ characterData: !0,
10025
+ subtree: !0
10026
+ })), f.current = r;
10027
+ };
10016
10028
  e();
10017
- let t = window.history.pushState, n = window.history.replaceState;
10018
- return window.history.pushState = function(...n) {
10019
- let r = t.apply(this, n);
10020
- return e(), r;
10021
- }, window.history.replaceState = function(...t) {
10022
- let r = n.apply(this, t);
10023
- return e(), r;
10024
- }, window.addEventListener("popstate", e), window.addEventListener("hashchange", e), () => {
10025
- window.history.pushState = t, window.history.replaceState = n, window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
10029
+ let n = window.history.pushState, r = window.history.replaceState;
10030
+ return window.history.pushState = function(...e) {
10031
+ let r = n.apply(this, e);
10032
+ return t(), r;
10033
+ }, window.history.replaceState = function(...e) {
10034
+ let n = r.apply(this, e);
10035
+ return t(), n;
10036
+ }, window.addEventListener("popstate", t), window.addEventListener("hashchange", t), () => {
10037
+ f.current?.(), window.history.pushState = n, window.history.replaceState = r, window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
10026
10038
  };
10027
10039
  }, [
10028
10040
  s,
10029
10041
  i.kind,
10030
- p
10042
+ m
10031
10043
  ]), /* @__PURE__ */ O(rp.Provider, {
10032
10044
  value: {
10033
- trackPageView: p,
10034
- trackLinkClick: m
10045
+ trackPageView: m,
10046
+ trackLinkClick: h
10035
10047
  },
10036
10048
  children: e
10037
10049
  });
@@ -21616,4 +21628,4 @@ function RC(e) {
21616
21628
  //#endregion
21617
21629
  export { wu as $, bd as A, ed as B, Rd as C, jd as D, Nd as E, cd as F, Au as G, Tu as H, td as I, ou as J, uu as K, ad as L, pd as M, md as N, Ad as O, ud as P, Ou as Q, rd as R, Ld as S, Pd as T, fu as U, Bu as V, bu as W, Su as X, cu as Y, vu as Z, $d as _, Ly as a, xl as at, Ud as b, ip as c, Ja as ct, ff as d, A as dt, Eu as et, df as f, le as ft, Qd as g, ef as h, VS as i, Gl as it, gd as j, xd as k, $f as l, Me as lt, sf as m, FC as n, ru as nt, op as o, G as ot, lf as p, j as pt, gu as q, IC as r, tu as rt, ap as s, Ya as st, RC as t, mu as tt, pf as u, M as ut, zd as v, Fd as w, Hd as x, Wd as y, sd as z };
21618
21630
 
21619
- //# sourceMappingURL=widget-react-CVLHwRZh.js.map
21631
+ //# sourceMappingURL=widget-react-CK8xTxwO.js.map
@@ -12,7 +12,7 @@ import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
14
  import { d as e } from "./widget-react-B9XrHKqv.js";
15
- import { D as t, O as n, T as r, a as i, at as a, i as o, it as s, n as c, ot as l, rt as u, st as d, t as f } from "./widget-react-CVLHwRZh.js";
15
+ import { D as t, O as n, T as r, a as i, at as a, i as o, it as s, n as c, ot as l, rt as u, st as d, t as f } from "./widget-react-CK8xTxwO.js";
16
16
  import { i as p, n as m } from "./widget-react-krPPnv02.js";
17
17
  import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
18
18
  import { jsx as b, jsxs as x } from "react/jsx-runtime";
@@ -320,4 +320,4 @@ function V({ surface: t, itemId: n, reactionCounts: r, viewerReaction: i, groupI
320
320
  //#endregion
321
321
  export { k as a, w as c, E as i, S as l, M as n, T as o, j as r, C as s, V as t };
322
322
 
323
- //# sourceMappingURL=widget-react-D8-Z8fvu.js.map
323
+ //# sourceMappingURL=widget-react-DDEFbIbU.js.map
@@ -12,7 +12,7 @@ import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
14
  import { c as e, d as t } from "./widget-react-B9XrHKqv.js";
15
- import { N as n, at as r, b as i, j as a, l as o, ot as s, x as c } from "./widget-react-CVLHwRZh.js";
15
+ import { N as n, at as r, b as i, j as a, l as o, ot as s, x as c } from "./widget-react-CK8xTxwO.js";
16
16
  import { i as l, n as u, o as d, t as f } from "./widget-react-krPPnv02.js";
17
17
  import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
18
18
  import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
@@ -652,4 +652,4 @@ function Y({ item: e, locale: n, delay: r, onClick: a }) {
652
652
  //#endregion
653
653
  export { z as a, I as c, N as d, j as f, k as h, V as i, F as l, D as m, U as n, R as o, T as p, H as r, L as s, K as t, P as u };
654
654
 
655
- //# sourceMappingURL=widget-react-DejnNTzJ.js.map
655
+ //# sourceMappingURL=widget-react-DV3UnggB.js.map
@@ -11,11 +11,11 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { N as e, c as t, k as n, l as r } from "./widget-react-CVLHwRZh.js";
14
+ import { N as e, c as t, k as n, l as r } from "./widget-react-CK8xTxwO.js";
15
15
  import { i, n as a, o } from "./widget-react-krPPnv02.js";
16
- import { d as s, h as c, m as l, n as u, r as d } from "./widget-react-DejnNTzJ.js";
16
+ import { d as s, h as c, m as l, n as u, r as d } from "./widget-react-DV3UnggB.js";
17
17
  import { t as f } from "./widget-react-CIy9jXND.js";
18
- import { a as p, c as ee, i as m, l as h, n as g, o as _, r as v, t as y } from "./widget-react-D8-Z8fvu.js";
18
+ import { a as p, c as ee, i as m, l as h, n as g, o as _, r as v, t as y } from "./widget-react-DDEFbIbU.js";
19
19
  import { useEffect as b, useRef as x, useState as S } from "react";
20
20
  import { jsx as C, jsxs as w } from "react/jsx-runtime";
21
21
  //#region components/widget/news-article-view/helpers.ts
@@ -353,4 +353,4 @@ function O() {
353
353
  //#endregion
354
354
  export { D as NewsArticleView };
355
355
 
356
- //# sourceMappingURL=widget-react-BPNfTldJ.js.map
356
+ //# sourceMappingURL=widget-react-yTVzOzaU.js.map
@@ -12,10 +12,10 @@ import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
14
  import { S as e, a as t, d as n, i as r, l as i, n as a, r as o, t as s, u as c, w as l, y as u } from "./widget-react-B9XrHKqv.js";
15
- import { $ as d, A as f, B as p, C as m, D as h, E as g, F as _, G as v, H as y, J as b, K as x, L as S, M as C, N as w, O as T, P as E, Q as ee, R as D, S as O, T as k, U as te, V as A, W as j, X as M, Y as N, Z as ne, _ as re, a as ie, at as ae, c as oe, ct as se, d as P, dt as F, et as ce, f as le, ft as ue, g as I, h as L, i as de, it as R, k as fe, l as z, lt as pe, m as me, nt as he, o as ge, ot as _e, p as ve, pt as ye, q as be, r as xe, rt as Se, s as Ce, st as we, t as Te, tt as Ee, u as B, ut as De, v as Oe, w as ke, y as Ae, z as je } from "./widget-react-CVLHwRZh.js";
15
+ import { $ as d, A as f, B as p, C as m, D as h, E as g, F as _, G as v, H as y, J as b, K as x, L as S, M as C, N as w, O as T, P as E, Q as ee, R as D, S as O, T as k, U as te, V as A, W as j, X as M, Y as N, Z as ne, _ as re, a as ie, at as ae, c as oe, ct as se, d as P, dt as F, et as ce, f as le, ft as ue, g as I, h as L, i as de, it as R, k as fe, l as z, lt as pe, m as me, nt as he, o as ge, ot as _e, p as ve, pt as ye, q as be, r as xe, rt as Se, s as Ce, st as we, t as Te, tt as Ee, u as B, ut as De, v as Oe, w as ke, y as Ae, z as je } from "./widget-react-CK8xTxwO.js";
16
16
  import { a as Me, i as V, n as H, o as Ne, s as Pe, t as U } from "./widget-react-krPPnv02.js";
17
- import { a as Fe, c as W, d as Ie, f as Le, i as Re, l as ze, o as Be, p as Ve, s as He, t as Ue, u as We } from "./widget-react-DejnNTzJ.js";
18
- import { a as Ge, c as Ke, d as qe, f as Je, i as Ye, o as Xe, p as Ze, s as Qe, t as $e, u as et } from "./widget-react--D5-TDqS.js";
17
+ import { a as Fe, c as W, d as Ie, f as Le, i as Re, l as ze, o as Be, p as Ve, s as He, t as Ue, u as We } from "./widget-react-DV3UnggB.js";
18
+ import { a as Ge, c as Ke, d as qe, f as Je, i as Ye, o as Xe, p as Ze, s as Qe, t as $e, u as et } from "./widget-react-AwEaD0v2.js";
19
19
  import { t as tt } from "./widget-react-CIy9jXND.js";
20
20
  import { n as nt, r as rt, t as it } from "./widget-react-faSyVXFQ.js";
21
21
  import { t as at } from "./widget-react-BlTmXnei.js";
@@ -20127,7 +20127,7 @@ var fv = {
20127
20127
  x: e > 0 ? -28 : e < 0 ? 28 : 0,
20128
20128
  opacity: 0
20129
20129
  })
20130
- }, pv = ut(() => import("./widget-react-DF5yY9sQ.js").then((e) => ({ default: e.HelpArticleView }))), mv = ut(() => import("./widget-react-BPNfTldJ.js").then((e) => ({ default: e.NewsArticleView }))), hv = "wexio:panel-expanded", gv = 32, _v = 112;
20130
+ }, pv = ut(() => import("./widget-react-CAsPo1rw.js").then((e) => ({ default: e.HelpArticleView }))), mv = ut(() => import("./widget-react-yTVzOzaU.js").then((e) => ({ default: e.NewsArticleView }))), hv = "wexio:panel-expanded", gv = 32, _v = 112;
20131
20131
  function vv() {
20132
20132
  if (typeof window > "u") return !1;
20133
20133
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wexio/messenger-widget-react",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Native React component embed for the Wexio web messenger. Renders inside a Shadow DOM portal for style isolation.",
5
5
  "license": "MIT",
6
6
  "private": false,