vue-intlayer 9.4.0-canary.0 → 9.4.1

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
@@ -214,6 +214,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
214
214
  <li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
215
215
  <li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
216
216
  <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
217
+ <li><a href="https://intlayer.org/doc/environment/solid-start" rel=''>Solid Start</a></li>
217
218
  <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
218
219
  <li>
219
220
  <a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
@@ -223,7 +224,9 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
223
224
  <li><a href="https://intlayer.org/doc/environment/fastify" rel=''>Fastify</a></li>
224
225
  <li><a href="https://intlayer.org/doc/environment/adonisjs" rel=''>AdonisJS</a></li>
225
226
  <li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
227
+ <li><a href="https://intlayer.org/doc/environment/elysia" rel=''>Elysia</a></li>
226
228
  </ul>
229
+
227
230
  </li>
228
231
  </ul>
229
232
  </details>
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exposureSink.cjs"),t=require("../../isEnabled-B9hPiyif.js"),n=require("../client/installIntlayer.cjs");let r=require("vue");var i=t=>{let n=null,i=!1,a=!1;return Promise.resolve().then(()=>require("../../esm-B3cLgaxc.js")).then(({initAnalyticsClient:o,buildContentExposure:s})=>{if(i)return;let c=o();a=!0,t?.value&&c.setLocale(t.value),c.trackPageView({reason:`initial`}),e.setExposureSink(e=>c.trackContentExposure(s(e))),t&&(n=(0,r.watch)(t,e=>{e&&(c.setLocale(e),c.trackPageView({reason:`locale_change`}))}))}).catch(()=>{}),()=>{i=!0,n?.(),e.setExposureSink(null),Promise.resolve().then(()=>require("../../esm-B3cLgaxc.js")).then(({stopAnalyticsClient:e})=>{a&&e()}).catch(()=>{})}},a=e=>{if(process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!t.t)return;if(e){let t=null;e.mixin({inject:{_intlayerClient:{from:n.INTLAYER_SYMBOL,default:null}},mounted(){if(this.$parent!==null)return;let e=this._intlayerClient;t=i(e?.locale)},unmounted(){this.$parent===null&&t?.()}});return}let a=(0,r.inject)(n.INTLAYER_SYMBOL),o=null;(0,r.onMounted)(()=>{o=i(a?.locale)}),(0,r.onUnmounted)(()=>{o?.()})};exports.useAnalytics=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exposureSink.cjs"),t=require("../../isEnabled-CuTKz0YA.js"),n=require("../client/installIntlayer.cjs");let r=require("vue");var i=t=>{let n=null,i=!1,a=!1;return Promise.resolve().then(()=>require("../../esm-BeJJ8BHD.js")).then(({initAnalyticsClient:o,buildContentExposure:s})=>{if(i)return;let c=o();a=!0,t?.value&&c.setLocale(t.value),c.trackPageView({reason:`initial`}),e.setExposureSink(e=>c.trackContentExposure(s(e))),t&&(n=(0,r.watch)(t,e=>{e&&(c.setLocale(e),c.trackPageView({reason:`locale_change`}))}))}).catch(()=>{}),()=>{i=!0,n?.(),e.setExposureSink(null),Promise.resolve().then(()=>require("../../esm-BeJJ8BHD.js")).then(({stopAnalyticsClient:e})=>{a&&e()}).catch(()=>{})}},a=e=>{if(process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!t.t)return;if(e){let t=null;e.mixin({inject:{_intlayerClient:{from:n.INTLAYER_SYMBOL,default:null}},mounted(){if(this.$parent!==null)return;let e=this._intlayerClient;t=i(e?.locale)},unmounted(){this.$parent===null&&t?.()}});return}let a=(0,r.inject)(n.INTLAYER_SYMBOL),o=null;(0,r.onMounted)(()=>{o=i(a?.locale)}),(0,r.onUnmounted)(()=>{o?.()})};exports.useAnalytics=a;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../isEnabled-B9hPiyif.js");var t=()=>t=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-B3cLgaxc.js")).then(({getGlobalAnalyticsClient:e})=>{e()?.trackConversion(t)}).catch(()=>{})};exports.useConversion=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../isEnabled-CuTKz0YA.js");var t=()=>t=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-BeJJ8BHD.js")).then(({getGlobalAnalyticsClient:e})=>{e()?.trackConversion(t)}).catch(()=>{})};exports.useConversion=t;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../isEnabled-B9hPiyif.js");let t=require("vue");var n=(n,r,i)=>{let a=(0,t.ref)(r[0]??``),o=(0,t.ref)(!1),s=!1,c=!1;return(0,t.onMounted)(()=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-B3cLgaxc.js")).then(({initAnalyticsClient:e})=>{if(s)return;let t=e();c=!0;let l=t.getVariant(n,r,i);a.value=l,o.value=!0,t.trackContentExposure({dictionaryKey:n,keyPath:``,nodeType:`experiment`,experimentKey:n,variant:l})}).catch(()=>{})}),(0,t.onUnmounted)(()=>{s=!0,Promise.resolve().then(()=>require("../../esm-B3cLgaxc.js")).then(({stopAnalyticsClient:e})=>{c&&e()}).catch(()=>{})}),{variant:a,isAssigned:o}};exports.useExperiment=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../isEnabled-CuTKz0YA.js");let t=require("vue");var n=(n,r,i)=>{let a=(0,t.ref)(r[0]??``),o=(0,t.ref)(!1),s=!1,c=!1;return(0,t.onMounted)(()=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-BeJJ8BHD.js")).then(({initAnalyticsClient:e})=>{if(s)return;let t=e();c=!0;let l=t.getVariant(n,r,i);a.value=l,o.value=!0,t.trackContentExposure({dictionaryKey:n,keyPath:``,nodeType:`experiment`,experimentKey:n,variant:l})}).catch(()=>{})}),(0,t.onUnmounted)(()=>{s=!0,Promise.resolve().then(()=>require("../../esm-BeJJ8BHD.js")).then(({stopAnalyticsClient:e})=>{c&&e()}).catch(()=>{})}),{variant:a,isAssigned:o}};exports.useExperiment=n;
@@ -1,18 +1,18 @@
1
1
  import { setExposureSink as e } from "./exposureSink.mjs";
2
- import { t } from "../../isEnabled-C5NavXyG.mjs";
2
+ import { t } from "../../isEnabled-BbWU6Ox5.mjs";
3
3
  import { INTLAYER_SYMBOL as n } from "../client/installIntlayer.mjs";
4
4
  import { inject as r, onMounted as i, onUnmounted as a, watch as o } from "vue";
5
5
  //#region src/analytics/useAnalytics.ts
6
6
  var s = (t) => {
7
7
  let n = null, r = !1, i = !1;
8
- return import("../../esm-CDrDEj00.mjs").then(({ initAnalyticsClient: a, buildContentExposure: s }) => {
8
+ return import("../../esm-yuHc2Obh.mjs").then(({ initAnalyticsClient: a, buildContentExposure: s }) => {
9
9
  if (r) return;
10
10
  let c = a();
11
11
  i = !0, t?.value && c.setLocale(t.value), c.trackPageView({ reason: "initial" }), e((e) => c.trackContentExposure(s(e))), t && (n = o(t, (e) => {
12
12
  e && (c.setLocale(e), c.trackPageView({ reason: "locale_change" }));
13
13
  }));
14
14
  }).catch(() => {}), () => {
15
- r = !0, n?.(), e(null), import("../../esm-CDrDEj00.mjs").then(({ stopAnalyticsClient: e }) => {
15
+ r = !0, n?.(), e(null), import("../../esm-yuHc2Obh.mjs").then(({ stopAnalyticsClient: e }) => {
16
16
  i && e();
17
17
  }).catch(() => {});
18
18
  };
@@ -1,7 +1,7 @@
1
- import { t as e } from "../../isEnabled-C5NavXyG.mjs";
1
+ import { t as e } from "../../isEnabled-BbWU6Ox5.mjs";
2
2
  //#region src/analytics/useConversion.ts
3
3
  var t = () => (t) => {
4
- process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-CDrDEj00.mjs").then(({ getGlobalAnalyticsClient: e }) => {
4
+ process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-yuHc2Obh.mjs").then(({ getGlobalAnalyticsClient: e }) => {
5
5
  e()?.trackConversion(t);
6
6
  }).catch(() => {});
7
7
  };
@@ -1,10 +1,10 @@
1
- import { t as e } from "../../isEnabled-C5NavXyG.mjs";
1
+ import { t as e } from "../../isEnabled-BbWU6Ox5.mjs";
2
2
  import { onMounted as t, onUnmounted as n, ref as r } from "vue";
3
3
  //#region src/analytics/useExperiment.ts
4
4
  var i = (i, a, o) => {
5
5
  let s = r(a[0] ?? ""), c = r(!1), l = !1, u = !1;
6
6
  return t(() => {
7
- process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-CDrDEj00.mjs").then(({ initAnalyticsClient: e }) => {
7
+ process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-yuHc2Obh.mjs").then(({ initAnalyticsClient: e }) => {
8
8
  if (l) return;
9
9
  let t = e();
10
10
  u = !0;
@@ -18,7 +18,7 @@ var i = (i, a, o) => {
18
18
  });
19
19
  }).catch(() => {});
20
20
  }), n(() => {
21
- l = !0, import("../../esm-CDrDEj00.mjs").then(({ stopAnalyticsClient: e }) => {
21
+ l = !0, import("../../esm-yuHc2Obh.mjs").then(({ stopAnalyticsClient: e }) => {
22
22
  u && e();
23
23
  }).catch(() => {});
24
24
  }), {
@@ -0,0 +1 @@
1
+ const e=require("./isEnabled-CuTKz0YA.js");let t=require("@intlayer/config/built");var n=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},r=(e,t,r,i)=>{if(r.length===0)throw Error(`assignVariant requires at least one variant`);if(r.length===1)return r[0];let a=n(`${e}:${t}`)/4294967296;if(!i||i.length!==r.length){let e=Math.floor(a*r.length);return r[Math.min(e,r.length-1)]}let o=i.reduce((e,t)=>e+t,0);if(o<=0)return r[Math.floor(a*r.length)];let s=0,c=a*o;for(let e=0;e<r.length;e++)if(s+=i[e],c<s)return r[e];return r[r.length-1]},i=``,a=e=>[e.url,e.dictionaryKey,e.keyPath,e.locale,e.experimentKey??``,e.variant??``].join(i),o=({max:e})=>{let t=[],n=new Map,r=()=>t.length+n.size,i=()=>{for(;r()>e&&n.size>0;){let e=n.keys().next().value;n.delete(e)}r()>e&&(t=t.slice(r()-e))};return{push:e=>{if(e.type===`content_exposure`){let t=a(e),r=n.get(t);r?(r.count=(r.count??1)+(e.count??1),r.t=e.t):n.set(t,{...e,count:e.count??1})}else t.push(e);return i(),r()},drain:()=>{let e=[...t,...n.values()];return t=[],n.clear(),e},size:r}},s=(e,t)=>t>=1?!0:t<=0?!1:n(e)/4294967295<t,c=`__intlayer_analytics_sid__`,l=()=>{let e=typeof globalThis<`u`?globalThis.crypto:void 0;return e?.randomUUID?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`},u=()=>{if(typeof window>`u`||!window.sessionStorage)return l();try{let e=window.sessionStorage.getItem(c);if(e)return e;let t=l();return window.sessionStorage.setItem(c,t),t}catch{return l()}},d=(e,t,{useBeacon:n=!1,token:r}={})=>{try{let i=JSON.stringify(t);return n&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`?navigator.sendBeacon(e,i):typeof fetch==`function`&&(fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},body:i,keepalive:!0,credentials:`omit`,mode:`cors`}).catch(()=>{}),!0)}catch{return!1}},f=e=>{if(typeof window>`u`)return;let t=window.requestIdleCallback;if(typeof t==`function`){t(()=>e());return}setTimeout(e,1)},p=`__intlayer_public_token__`,m=6e4,h=()=>{try{let e=window.sessionStorage?.getItem(p);if(!e)return null;let t=JSON.parse(e);return typeof t?.token!=`string`||typeof t?.expiresAt!=`number`?null:t}catch{return null}},g=e=>{try{window.sessionStorage?.setItem(p,JSON.stringify(e))}catch{}},_=({backendURL:e,clientId:t})=>{let n=`${e.replace(/\/$/,``)}/api/public/token`,r=null,i=null,a=e=>e!==null&&e.expiresAt-m>Date.now(),o=()=>{if(a(r))return r.token;if(typeof window<`u`){let e=h();if(a(e))return r=e,e.token}},s=async()=>{try{let e=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t}),credentials:`omit`,mode:`cors`});if(!e.ok)return;let i=await e.json(),a=i?.data?.token,o=i?.data?.expiresIn??0;if(!a||o<=0)return;r={token:a,expiresAt:Date.now()+o*1e3},typeof window<`u`&&g(r)}catch{}finally{i=null}};return{getToken:o,prime:()=>{!t||typeof fetch!=`function`||o()||(i||=s())}}},v=`intlayer-analytics/1`,y=()=>typeof window>`u`||!window.location?``:window.location.pathname,b=()=>{if(!(typeof document>`u`||!document.referrer))try{return new URL(document.referrer).host}catch{return}},x=t=>{let n=u(),i=e.r(),a=!i&&s(n,t.sampleRate),c=o({max:t.maxBufferSize}),l=`${t.backendURL.replace(/\/$/,``)}/api/analytics/events`,p=_({backendURL:t.backendURL,clientId:t.clientId}),m=``,h=null,g=!1,x=null,S=null,C=new Set,w=(e=!1)=>{let r=c.drain(),i=p.getToken();for(let a=0;a<r.length;a+=200)d(l,{token:i,clientId:i?void 0:t.clientId,sessionId:n,sdkVersion:v,events:r.slice(a,a+200)},{useBeacon:e,token:i})},T=e=>{c.push(e)>=t.maxBufferSize&&w()},E=e=>{m=e},D=(e={})=>{if(!a)return;let t=e.url??y(),n=e.reason??`initial`;(n!==`route_change`||t!==S)&&(S=t,C=new Set,T({type:`page_view`,t:Date.now(),url:t,locale:e.locale??m,ref:e.ref??b(),vw:e.vw??(typeof window<`u`?window.innerWidth:void 0),vh:e.vh??(typeof window<`u`?window.innerHeight:void 0),reason:n}))},O=e=>{if(!a)return;let t=e.locale??m,n=[e.dictionaryKey,e.keyPath,t,e.experimentKey??``,e.variant??``].join(``);C.has(n)||(C.add(n),T({...e,type:`content_exposure`,t:Date.now(),url:y(),locale:t}))},k=e=>{i||(T({...e,type:`conversion`,t:Date.now(),url:y(),locale:e.locale??m}),w())},A=(e,t,i)=>r(n,e,t,i),j=()=>{if(typeof window>`u`)return;let e=()=>{document.visibilityState===`hidden`&&w(!0)},t=()=>w(!0),n=()=>D({reason:`route_change`});document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t,{capture:!0}),window.addEventListener(`popstate`,n);let r=window.history,i=r.pushState,a=function(...e){let t=i.apply(this,e);return D({reason:`route_change`}),t};r.pushState=a,x=()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t,{capture:!0}),window.removeEventListener(`popstate`,n),r.pushState===a&&(r.pushState=i)}};return{setLocale:E,trackPageView:D,trackContentExposure:O,trackConversion:k,getVariant:A,flush:w,start:()=>{g||i||(g=!0,p.prime(),h=setInterval(w,t.flushInterval),h?.unref?.(),f(j))},stop:()=>{g&&(g=!1,h&&=(clearInterval(h),null),x?.(),x=null,w(!0))}}},S=`__intlayer_analytics_client__`,C=`__intlayer_analytics_ref_count__`,w=()=>typeof window>`u`?null:window[S]??null,T=e=>{typeof window>`u`||(window[S]=e)},E=()=>{if(typeof window>`u`)return 0;let e=window;return e[C]=(e[C]??0)+1,e[C]},D=()=>{if(typeof window>`u`)return 0;let e=window;return e[C]=Math.max(0,(e[C]??0)-1),e[C]},O=()=>{E();let e=w();if(e)return e;let n=x({backendURL:t.editor?.backendURL??``,clientId:t.editor?.clientId,flushInterval:t.analytics?.flushInterval??2e4,maxBufferSize:500,sampleRate:t.analytics?.sampleRate??1});return T(n),n.start(),n},k=()=>{D()>0||(w()?.stop(),T(null))},A=e=>e.map(e=>e.key===void 0?`*`:String(e.key)).join(`.`),j=e=>({dictionaryKey:e.dictionaryKey,keyPath:A(e.keyPath),locale:e.locale,nodeType:e.nodeType,experimentKey:e.experimentKey,variant:e.variant});exports.buildContentExposure=j,exports.getGlobalAnalyticsClient=w,exports.initAnalyticsClient=O,exports.stopAnalyticsClient=k;
@@ -0,0 +1,261 @@
1
+ import { r as e } from "./isEnabled-BbWU6Ox5.mjs";
2
+ import { analytics as t, editor as n } from "@intlayer/config/built";
3
+ //#region ../@intlayer/analytics/dist/esm/utils/hash.mjs
4
+ var r = (e) => {
5
+ let t = 2166136261;
6
+ for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
7
+ return t >>> 0;
8
+ }, i = (e, t, n, i) => {
9
+ if (n.length === 0) throw Error("assignVariant requires at least one variant");
10
+ if (n.length === 1) return n[0];
11
+ let a = r(`${e}:${t}`) / 4294967296;
12
+ if (!i || i.length !== n.length) {
13
+ let e = Math.floor(a * n.length);
14
+ return n[Math.min(e, n.length - 1)];
15
+ }
16
+ let o = i.reduce((e, t) => e + t, 0);
17
+ if (o <= 0) return n[Math.floor(a * n.length)];
18
+ let s = 0, c = a * o;
19
+ for (let e = 0; e < n.length; e++) if (s += i[e], c < s) return n[e];
20
+ return n[n.length - 1];
21
+ }, a = "", o = (e) => [
22
+ e.url,
23
+ e.dictionaryKey,
24
+ e.keyPath,
25
+ e.locale,
26
+ e.experimentKey ?? "",
27
+ e.variant ?? ""
28
+ ].join(a), s = ({ max: e }) => {
29
+ let t = [], n = /* @__PURE__ */ new Map(), r = () => t.length + n.size, i = () => {
30
+ for (; r() > e && n.size > 0;) {
31
+ let e = n.keys().next().value;
32
+ n.delete(e);
33
+ }
34
+ r() > e && (t = t.slice(r() - e));
35
+ };
36
+ return {
37
+ push: (e) => {
38
+ if (e.type === "content_exposure") {
39
+ let t = o(e), r = n.get(t);
40
+ r ? (r.count = (r.count ?? 1) + (e.count ?? 1), r.t = e.t) : n.set(t, {
41
+ ...e,
42
+ count: e.count ?? 1
43
+ });
44
+ } else t.push(e);
45
+ return i(), r();
46
+ },
47
+ drain: () => {
48
+ let e = [...t, ...n.values()];
49
+ return t = [], n.clear(), e;
50
+ },
51
+ size: r
52
+ };
53
+ }, c = (e, t) => t >= 1 ? !0 : t <= 0 ? !1 : r(e) / 4294967295 < t, l = "__intlayer_analytics_sid__", u = () => {
54
+ let e = typeof globalThis < "u" ? globalThis.crypto : void 0;
55
+ return e?.randomUUID ? e.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
56
+ }, d = () => {
57
+ if (typeof window > "u" || !window.sessionStorage) return u();
58
+ try {
59
+ let e = window.sessionStorage.getItem(l);
60
+ if (e) return e;
61
+ let t = u();
62
+ return window.sessionStorage.setItem(l, t), t;
63
+ } catch {
64
+ return u();
65
+ }
66
+ }, f = (e, t, { useBeacon: n = !1, token: r } = {}) => {
67
+ try {
68
+ let i = JSON.stringify(t);
69
+ return n && typeof navigator < "u" && typeof navigator.sendBeacon == "function" ? navigator.sendBeacon(e, i) : typeof fetch == "function" && (fetch(e, {
70
+ method: "POST",
71
+ headers: {
72
+ "Content-Type": "application/json",
73
+ ...r ? { Authorization: `Bearer ${r}` } : {}
74
+ },
75
+ body: i,
76
+ keepalive: !0,
77
+ credentials: "omit",
78
+ mode: "cors"
79
+ }).catch(() => {}), !0);
80
+ } catch {
81
+ return !1;
82
+ }
83
+ }, p = (e) => {
84
+ if (typeof window > "u") return;
85
+ let t = window.requestIdleCallback;
86
+ if (typeof t == "function") {
87
+ t(() => e());
88
+ return;
89
+ }
90
+ setTimeout(e, 1);
91
+ }, m = "__intlayer_public_token__", h = 6e4, g = () => {
92
+ try {
93
+ let e = window.sessionStorage?.getItem(m);
94
+ if (!e) return null;
95
+ let t = JSON.parse(e);
96
+ return typeof t?.token != "string" || typeof t?.expiresAt != "number" ? null : t;
97
+ } catch {
98
+ return null;
99
+ }
100
+ }, _ = (e) => {
101
+ try {
102
+ window.sessionStorage?.setItem(m, JSON.stringify(e));
103
+ } catch {}
104
+ }, v = ({ backendURL: e, clientId: t }) => {
105
+ let n = `${e.replace(/\/$/, "")}/api/public/token`, r = null, i = null, a = (e) => e !== null && e.expiresAt - h > Date.now(), o = () => {
106
+ if (a(r)) return r.token;
107
+ if (typeof window < "u") {
108
+ let e = g();
109
+ if (a(e)) return r = e, e.token;
110
+ }
111
+ }, s = async () => {
112
+ try {
113
+ let e = await fetch(n, {
114
+ method: "POST",
115
+ headers: { "Content-Type": "application/json" },
116
+ body: JSON.stringify({ clientId: t }),
117
+ credentials: "omit",
118
+ mode: "cors"
119
+ });
120
+ if (!e.ok) return;
121
+ let i = await e.json(), a = i?.data?.token, o = i?.data?.expiresIn ?? 0;
122
+ if (!a || o <= 0) return;
123
+ r = {
124
+ token: a,
125
+ expiresAt: Date.now() + o * 1e3
126
+ }, typeof window < "u" && _(r);
127
+ } catch {} finally {
128
+ i = null;
129
+ }
130
+ };
131
+ return {
132
+ getToken: o,
133
+ prime: () => {
134
+ !t || typeof fetch != "function" || o() || (i ||= s());
135
+ }
136
+ };
137
+ }, y = "intlayer-analytics/1", b = () => typeof window > "u" || !window.location ? "" : window.location.pathname, x = () => {
138
+ if (!(typeof document > "u" || !document.referrer)) try {
139
+ return new URL(document.referrer).host;
140
+ } catch {
141
+ return;
142
+ }
143
+ }, S = (t) => {
144
+ let n = d(), r = e(), a = !r && c(n, t.sampleRate), o = s({ max: t.maxBufferSize }), l = `${t.backendURL.replace(/\/$/, "")}/api/analytics/events`, u = v({
145
+ backendURL: t.backendURL,
146
+ clientId: t.clientId
147
+ }), m = "", h = null, g = !1, _ = null, S = null, C = /* @__PURE__ */ new Set(), w = (e = !1) => {
148
+ let r = o.drain(), i = u.getToken();
149
+ for (let a = 0; a < r.length; a += 200) f(l, {
150
+ token: i,
151
+ clientId: i ? void 0 : t.clientId,
152
+ sessionId: n,
153
+ sdkVersion: y,
154
+ events: r.slice(a, a + 200)
155
+ }, {
156
+ useBeacon: e,
157
+ token: i
158
+ });
159
+ }, T = (e) => {
160
+ o.push(e) >= t.maxBufferSize && w();
161
+ }, E = (e) => {
162
+ m = e;
163
+ }, D = (e = {}) => {
164
+ if (!a) return;
165
+ let t = e.url ?? b(), n = e.reason ?? "initial";
166
+ (n !== "route_change" || t !== S) && (S = t, C = /* @__PURE__ */ new Set(), T({
167
+ type: "page_view",
168
+ t: Date.now(),
169
+ url: t,
170
+ locale: e.locale ?? m,
171
+ ref: e.ref ?? x(),
172
+ vw: e.vw ?? (typeof window < "u" ? window.innerWidth : void 0),
173
+ vh: e.vh ?? (typeof window < "u" ? window.innerHeight : void 0),
174
+ reason: n
175
+ }));
176
+ }, O = (e) => {
177
+ if (!a) return;
178
+ let t = e.locale ?? m, n = [
179
+ e.dictionaryKey,
180
+ e.keyPath,
181
+ t,
182
+ e.experimentKey ?? "",
183
+ e.variant ?? ""
184
+ ].join("");
185
+ C.has(n) || (C.add(n), T({
186
+ ...e,
187
+ type: "content_exposure",
188
+ t: Date.now(),
189
+ url: b(),
190
+ locale: t
191
+ }));
192
+ }, k = (e) => {
193
+ r || (T({
194
+ ...e,
195
+ type: "conversion",
196
+ t: Date.now(),
197
+ url: b(),
198
+ locale: e.locale ?? m
199
+ }), w());
200
+ }, A = (e, t, r) => i(n, e, t, r), j = () => {
201
+ if (typeof window > "u") return;
202
+ let e = () => {
203
+ document.visibilityState === "hidden" && w(!0);
204
+ }, t = () => w(!0), n = () => D({ reason: "route_change" });
205
+ document.addEventListener("visibilitychange", e), window.addEventListener("pagehide", t, { capture: !0 }), window.addEventListener("popstate", n);
206
+ let r = window.history, i = r.pushState, a = function(...e) {
207
+ let t = i.apply(this, e);
208
+ return D({ reason: "route_change" }), t;
209
+ };
210
+ r.pushState = a, _ = () => {
211
+ document.removeEventListener("visibilitychange", e), window.removeEventListener("pagehide", t, { capture: !0 }), window.removeEventListener("popstate", n), r.pushState === a && (r.pushState = i);
212
+ };
213
+ };
214
+ return {
215
+ setLocale: E,
216
+ trackPageView: D,
217
+ trackContentExposure: O,
218
+ trackConversion: k,
219
+ getVariant: A,
220
+ flush: w,
221
+ start: () => {
222
+ g || r || (g = !0, u.prime(), h = setInterval(w, t.flushInterval), h?.unref?.(), p(j));
223
+ },
224
+ stop: () => {
225
+ g && (g = !1, h &&= (clearInterval(h), null), _?.(), _ = null, w(!0));
226
+ }
227
+ };
228
+ }, C = "__intlayer_analytics_client__", w = "__intlayer_analytics_ref_count__", T = () => typeof window > "u" ? null : window[C] ?? null, E = (e) => {
229
+ typeof window > "u" || (window[C] = e);
230
+ }, D = () => {
231
+ if (typeof window > "u") return 0;
232
+ let e = window;
233
+ return e[w] = (e[w] ?? 0) + 1, e[w];
234
+ }, O = () => {
235
+ if (typeof window > "u") return 0;
236
+ let e = window;
237
+ return e[w] = Math.max(0, (e[w] ?? 0) - 1), e[w];
238
+ }, k = () => {
239
+ D();
240
+ let e = T();
241
+ if (e) return e;
242
+ let r = S({
243
+ backendURL: n?.backendURL ?? "",
244
+ clientId: n?.clientId,
245
+ flushInterval: t?.flushInterval ?? 2e4,
246
+ maxBufferSize: 500,
247
+ sampleRate: t?.sampleRate ?? 1
248
+ });
249
+ return E(r), r.start(), r;
250
+ }, A = () => {
251
+ O() > 0 || (T()?.stop(), E(null));
252
+ }, j = (e) => e.map((e) => e.key === void 0 ? "*" : String(e.key)).join("."), M = (e) => ({
253
+ dictionaryKey: e.dictionaryKey,
254
+ keyPath: j(e.keyPath),
255
+ locale: e.locale,
256
+ nodeType: e.nodeType,
257
+ experimentKey: e.experimentKey,
258
+ variant: e.variant
259
+ });
260
+ //#endregion
261
+ export { M as buildContentExposure, T as getGlobalAnalyticsClient, k as initAnalyticsClient, A as stopAnalyticsClient };
@@ -0,0 +1,19 @@
1
+ import { analytics as e, editor as t } from "@intlayer/config/built";
2
+ //#region ../@intlayer/analytics/dist/esm/utils/isBot.mjs
3
+ var n = /cubot/i, r = /bot\b|bot[/\-\s]|crawler|crawling|spider|scraper|slurp|archiver|feedfetcher|validator|curl\/|wget\/|python-requests|python-urllib|okhttp|axios\/|node-fetch|got \(|go-http-client|java\/|libwww|httpunit|http_request|apache-httpclient|headless|phantomjs|puppeteer|playwright|selenium|webdriver|cypress|lighthouse|pagespeed|gtmetrix|prerender|pingdom|uptime|statuscake|site24x7|bingpreview|yandex|baiduspider|sogou|exabot|semrush|ahrefs|mj12|dotbot|petalbot|applebot|amazonbot|bytespider|facebookexternalhit|meta-externalagent|embedly|outbrain|quora link preview|skypeuripreview|vkshare|w3c_validator|apis-google|mediapartners|adsbot|storebot-google|google-inspectiontool|google-read-aloud|google-extended|duplexweb-google|gptbot|oai-searchbot|chatgpt-user|perplexity|claudebot|claude-web|anthropic-ai|cohere-ai|ccbot|diffbot|imagesift|omgili|timpi|youbot/i, i = (e) => !e || !n.test(e) && r.test(e), a = [
4
+ "_phantom",
5
+ "__nightmare",
6
+ "callPhantom",
7
+ "__selenium_unwrapped",
8
+ "__webdriver_evaluate",
9
+ "__driver_evaluate",
10
+ "domAutomation",
11
+ "Cypress"
12
+ ], o = () => {
13
+ if (typeof navigator > "u") return !1;
14
+ if (navigator.webdriver === !0) return !0;
15
+ let e = globalThis;
16
+ return a.some((t) => t in e) ? !0 : navigator.userAgent ? i(navigator.userAgent) : !1;
17
+ }, s = process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e?.enabled === !0 && !!t?.clientId && typeof window < "u" && window.self === window.top && !o();
18
+ //#endregion
19
+ export { i, r as n, o as r, s as t };
@@ -0,0 +1 @@
1
+ let e=require("@intlayer/config/built");var t=/cubot/i,n=/bot\b|bot[/\-\s]|crawler|crawling|spider|scraper|slurp|archiver|feedfetcher|validator|curl\/|wget\/|python-requests|python-urllib|okhttp|axios\/|node-fetch|got \(|go-http-client|java\/|libwww|httpunit|http_request|apache-httpclient|headless|phantomjs|puppeteer|playwright|selenium|webdriver|cypress|lighthouse|pagespeed|gtmetrix|prerender|pingdom|uptime|statuscake|site24x7|bingpreview|yandex|baiduspider|sogou|exabot|semrush|ahrefs|mj12|dotbot|petalbot|applebot|amazonbot|bytespider|facebookexternalhit|meta-externalagent|embedly|outbrain|quora link preview|skypeuripreview|vkshare|w3c_validator|apis-google|mediapartners|adsbot|storebot-google|google-inspectiontool|google-read-aloud|google-extended|duplexweb-google|gptbot|oai-searchbot|chatgpt-user|perplexity|claudebot|claude-web|anthropic-ai|cohere-ai|ccbot|diffbot|imagesift|omgili|timpi|youbot/i,r=e=>!e||!t.test(e)&&n.test(e),i=[`_phantom`,`__nightmare`,`callPhantom`,`__selenium_unwrapped`,`__webdriver_evaluate`,`__driver_evaluate`,`domAutomation`,`Cypress`],a=()=>{if(typeof navigator>`u`)return!1;if(navigator.webdriver===!0)return!0;let e=globalThis;return i.some(t=>t in e)?!0:navigator.userAgent?r(navigator.userAgent):!1},o=process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&e.analytics?.enabled===!0&&!!e.editor?.clientId&&typeof window<`u`&&window.self===window.top&&!a();Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-intlayer",
3
- "version": "9.4.0-canary.0",
3
+ "version": "9.4.1",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -102,14 +102,14 @@
102
102
  "typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
103
103
  },
104
104
  "dependencies": {
105
- "@intlayer/api": "9.4.0-canary.0",
106
- "@intlayer/config": "9.4.0-canary.0",
107
- "@intlayer/core": "9.4.0-canary.0",
108
- "@intlayer/editor": "9.4.0-canary.0",
109
- "@intlayer/types": "9.4.0-canary.0"
105
+ "@intlayer/api": "9.4.1",
106
+ "@intlayer/config": "9.4.1",
107
+ "@intlayer/core": "9.4.1",
108
+ "@intlayer/editor": "9.4.1",
109
+ "@intlayer/types": "9.4.1"
110
110
  },
111
111
  "devDependencies": {
112
- "@types/node": "26.2.0",
112
+ "@types/node": "26.3.0",
113
113
  "@utils/ts-config": "1.0.4",
114
114
  "@utils/ts-config-types": "1.0.4",
115
115
  "@utils/tsdown-config": "1.0.4",
@@ -125,7 +125,7 @@
125
125
  "vue-tsc": "3.3.9"
126
126
  },
127
127
  "peerDependencies": {
128
- "intlayer": "9.4.0-canary.0",
128
+ "intlayer": "9.4.1",
129
129
  "vue": ">=3.0.0"
130
130
  },
131
131
  "peerDependenciesMeta": {
@@ -134,7 +134,7 @@
134
134
  }
135
135
  },
136
136
  "optionalDependencies": {
137
- "@intlayer/analytics": "9.4.0-canary.0"
137
+ "@intlayer/analytics": "9.4.1"
138
138
  },
139
139
  "engines": {
140
140
  "node": ">=14.18"
@@ -1 +0,0 @@
1
- let e=require("@intlayer/config/built");var t=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},n=(e,n,r,i)=>{if(r.length===0)throw Error(`assignVariant requires at least one variant`);if(r.length===1)return r[0];let a=t(`${e}:${n}`)/4294967296;if(!i||i.length!==r.length){let e=Math.floor(a*r.length);return r[Math.min(e,r.length-1)]}let o=i.reduce((e,t)=>e+t,0);if(o<=0)return r[Math.floor(a*r.length)];let s=0,c=a*o;for(let e=0;e<r.length;e++)if(s+=i[e],c<s)return r[e];return r[r.length-1]},r=``,i=e=>[e.url,e.dictionaryKey,e.keyPath,e.locale,e.experimentKey??``,e.variant??``].join(r),a=({max:e})=>{let t=[],n=new Map,r=()=>t.length+n.size,a=()=>{for(;r()>e&&n.size>0;){let e=n.keys().next().value;n.delete(e)}r()>e&&(t=t.slice(r()-e))};return{push:e=>{if(e.type===`content_exposure`){let t=i(e),r=n.get(t);r?(r.count=(r.count??1)+(e.count??1),r.t=e.t):n.set(t,{...e,count:e.count??1})}else t.push(e);return a(),r()},drain:()=>{let e=[...t,...n.values()];return t=[],n.clear(),e},size:r}},o=(e,n)=>n>=1?!0:n<=0?!1:t(e)/4294967295<n,s=`__intlayer_analytics_sid__`,c=()=>{let e=typeof globalThis<`u`?globalThis.crypto:void 0;return e?.randomUUID?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`},l=()=>{if(typeof window>`u`||!window.sessionStorage)return c();try{let e=window.sessionStorage.getItem(s);if(e)return e;let t=c();return window.sessionStorage.setItem(s,t),t}catch{return c()}},u=(e,t,{useBeacon:n=!1}={})=>{try{let r=JSON.stringify(t);return n&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`?navigator.sendBeacon(e,r):typeof fetch==`function`&&(fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0,credentials:`omit`,mode:`cors`}).catch(()=>{}),!0)}catch{return!1}},d=e=>{if(typeof window>`u`)return;let t=window.requestIdleCallback;if(typeof t==`function`){t(()=>e());return}setTimeout(e,1)},f=`intlayer-analytics/1`,p=()=>typeof window>`u`||!window.location?``:window.location.pathname,m=()=>{if(!(typeof document>`u`||!document.referrer))try{return new URL(document.referrer).host}catch{return}},h=e=>{let t=l(),r=o(t,e.sampleRate),i=a({max:e.maxBufferSize}),s=`${e.backendURL.replace(/\/$/,``)}/api/analytics/events`,c=``,h=null,g=!1,_=null,v=new Set,y=(n=!1)=>{let r=i.drain();for(let i=0;i<r.length;i+=200)u(s,{clientId:e.clientId,sessionId:t,sdkVersion:f,events:r.slice(i,i+200)},{useBeacon:n})},b=t=>{i.push(t)>=e.maxBufferSize&&y()},x=e=>{c=e},S=(e={})=>{r&&(v=new Set,b({type:`page_view`,t:Date.now(),url:e.url??p(),locale:e.locale??c,ref:e.ref??m(),vw:e.vw??(typeof window<`u`?window.innerWidth:void 0),vh:e.vh??(typeof window<`u`?window.innerHeight:void 0),reason:e.reason??`initial`}))},C=e=>{if(!r)return;let t=e.locale??c,n=[e.dictionaryKey,e.keyPath,t,e.experimentKey??``,e.variant??``].join(``);v.has(n)||(v.add(n),b({...e,type:`content_exposure`,t:Date.now(),url:p(),locale:t}))},w=e=>{b({...e,type:`conversion`,t:Date.now(),url:p(),locale:e.locale??c}),y()},T=(e,r,i)=>n(t,e,r,i),E=()=>{if(typeof window>`u`)return;let e=()=>{document.visibilityState===`hidden`&&y(!0)},t=()=>y(!0),n=()=>S({reason:`route_change`});document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t,{capture:!0}),window.addEventListener(`popstate`,n);let r=window.history,i=r.pushState,a=function(...e){let t=i.apply(this,e);return S({reason:`route_change`}),t};r.pushState=a,_=()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t,{capture:!0}),window.removeEventListener(`popstate`,n),r.pushState===a&&(r.pushState=i)}};return{setLocale:x,trackPageView:S,trackContentExposure:C,trackConversion:w,getVariant:T,flush:y,start:()=>{g||(g=!0,h=setInterval(y,e.flushInterval),h?.unref?.(),d(E))},stop:()=>{g&&(g=!1,h&&=(clearInterval(h),null),_?.(),_=null,y(!0))}}},g=`__intlayer_analytics_client__`,_=`__intlayer_analytics_ref_count__`,v=()=>typeof window>`u`?null:window[g]??null,y=e=>{typeof window>`u`||(window[g]=e)},b=()=>{if(typeof window>`u`)return 0;let e=window;return e[_]=(e[_]??0)+1,e[_]},x=()=>{if(typeof window>`u`)return 0;let e=window;return e[_]=Math.max(0,(e[_]??0)-1),e[_]},S=()=>{b();let t=v();if(t)return t;let n=h({backendURL:e.editor?.backendURL??``,clientId:e.editor?.clientId,flushInterval:e.analytics?.flushInterval??2e4,maxBufferSize:500,sampleRate:e.analytics?.sampleRate??1});return y(n),n.start(),n},C=()=>{x()>0||(v()?.stop(),y(null))},w=e=>e.map(e=>e.key===void 0?`*`:String(e.key)).join(`.`),T=e=>({dictionaryKey:e.dictionaryKey,keyPath:w(e.keyPath),locale:e.locale,nodeType:e.nodeType,experimentKey:e.experimentKey,variant:e.variant});exports.buildContentExposure=T,exports.getGlobalAnalyticsClient=v,exports.initAnalyticsClient=S,exports.stopAnalyticsClient=C;
@@ -1,202 +0,0 @@
1
- import { analytics as e, editor as t } from "@intlayer/config/built";
2
- //#region ../@intlayer/analytics/dist/esm/utils/hash.mjs
3
- var n = (e) => {
4
- let t = 2166136261;
5
- for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
6
- return t >>> 0;
7
- }, r = (e, t, r, i) => {
8
- if (r.length === 0) throw Error("assignVariant requires at least one variant");
9
- if (r.length === 1) return r[0];
10
- let a = n(`${e}:${t}`) / 4294967296;
11
- if (!i || i.length !== r.length) {
12
- let e = Math.floor(a * r.length);
13
- return r[Math.min(e, r.length - 1)];
14
- }
15
- let o = i.reduce((e, t) => e + t, 0);
16
- if (o <= 0) return r[Math.floor(a * r.length)];
17
- let s = 0, c = a * o;
18
- for (let e = 0; e < r.length; e++) if (s += i[e], c < s) return r[e];
19
- return r[r.length - 1];
20
- }, i = "", a = (e) => [
21
- e.url,
22
- e.dictionaryKey,
23
- e.keyPath,
24
- e.locale,
25
- e.experimentKey ?? "",
26
- e.variant ?? ""
27
- ].join(i), o = ({ max: e }) => {
28
- let t = [], n = /* @__PURE__ */ new Map(), r = () => t.length + n.size, i = () => {
29
- for (; r() > e && n.size > 0;) {
30
- let e = n.keys().next().value;
31
- n.delete(e);
32
- }
33
- r() > e && (t = t.slice(r() - e));
34
- };
35
- return {
36
- push: (e) => {
37
- if (e.type === "content_exposure") {
38
- let t = a(e), r = n.get(t);
39
- r ? (r.count = (r.count ?? 1) + (e.count ?? 1), r.t = e.t) : n.set(t, {
40
- ...e,
41
- count: e.count ?? 1
42
- });
43
- } else t.push(e);
44
- return i(), r();
45
- },
46
- drain: () => {
47
- let e = [...t, ...n.values()];
48
- return t = [], n.clear(), e;
49
- },
50
- size: r
51
- };
52
- }, s = (e, t) => t >= 1 ? !0 : t <= 0 ? !1 : n(e) / 4294967295 < t, c = "__intlayer_analytics_sid__", l = () => {
53
- let e = typeof globalThis < "u" ? globalThis.crypto : void 0;
54
- return e?.randomUUID ? e.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
55
- }, u = () => {
56
- if (typeof window > "u" || !window.sessionStorage) return l();
57
- try {
58
- let e = window.sessionStorage.getItem(c);
59
- if (e) return e;
60
- let t = l();
61
- return window.sessionStorage.setItem(c, t), t;
62
- } catch {
63
- return l();
64
- }
65
- }, d = (e, t, { useBeacon: n = !1 } = {}) => {
66
- try {
67
- let r = JSON.stringify(t);
68
- return n && typeof navigator < "u" && typeof navigator.sendBeacon == "function" ? navigator.sendBeacon(e, r) : typeof fetch == "function" && (fetch(e, {
69
- method: "POST",
70
- headers: { "Content-Type": "application/json" },
71
- body: r,
72
- keepalive: !0,
73
- credentials: "omit",
74
- mode: "cors"
75
- }).catch(() => {}), !0);
76
- } catch {
77
- return !1;
78
- }
79
- }, f = (e) => {
80
- if (typeof window > "u") return;
81
- let t = window.requestIdleCallback;
82
- if (typeof t == "function") {
83
- t(() => e());
84
- return;
85
- }
86
- setTimeout(e, 1);
87
- }, p = "intlayer-analytics/1", m = () => typeof window > "u" || !window.location ? "" : window.location.pathname, h = () => {
88
- if (!(typeof document > "u" || !document.referrer)) try {
89
- return new URL(document.referrer).host;
90
- } catch {
91
- return;
92
- }
93
- }, g = (e) => {
94
- let t = u(), n = s(t, e.sampleRate), i = o({ max: e.maxBufferSize }), a = `${e.backendURL.replace(/\/$/, "")}/api/analytics/events`, c = "", l = null, g = !1, _ = null, v = /* @__PURE__ */ new Set(), y = (n = !1) => {
95
- let r = i.drain();
96
- for (let i = 0; i < r.length; i += 200) d(a, {
97
- clientId: e.clientId,
98
- sessionId: t,
99
- sdkVersion: p,
100
- events: r.slice(i, i + 200)
101
- }, { useBeacon: n });
102
- }, b = (t) => {
103
- i.push(t) >= e.maxBufferSize && y();
104
- }, x = (e) => {
105
- c = e;
106
- }, S = (e = {}) => {
107
- n && (v = /* @__PURE__ */ new Set(), b({
108
- type: "page_view",
109
- t: Date.now(),
110
- url: e.url ?? m(),
111
- locale: e.locale ?? c,
112
- ref: e.ref ?? h(),
113
- vw: e.vw ?? (typeof window < "u" ? window.innerWidth : void 0),
114
- vh: e.vh ?? (typeof window < "u" ? window.innerHeight : void 0),
115
- reason: e.reason ?? "initial"
116
- }));
117
- }, C = (e) => {
118
- if (!n) return;
119
- let t = e.locale ?? c, r = [
120
- e.dictionaryKey,
121
- e.keyPath,
122
- t,
123
- e.experimentKey ?? "",
124
- e.variant ?? ""
125
- ].join("");
126
- v.has(r) || (v.add(r), b({
127
- ...e,
128
- type: "content_exposure",
129
- t: Date.now(),
130
- url: m(),
131
- locale: t
132
- }));
133
- }, w = (e) => {
134
- b({
135
- ...e,
136
- type: "conversion",
137
- t: Date.now(),
138
- url: m(),
139
- locale: e.locale ?? c
140
- }), y();
141
- }, T = (e, n, i) => r(t, e, n, i), E = () => {
142
- if (typeof window > "u") return;
143
- let e = () => {
144
- document.visibilityState === "hidden" && y(!0);
145
- }, t = () => y(!0), n = () => S({ reason: "route_change" });
146
- document.addEventListener("visibilitychange", e), window.addEventListener("pagehide", t, { capture: !0 }), window.addEventListener("popstate", n);
147
- let r = window.history, i = r.pushState, a = function(...e) {
148
- let t = i.apply(this, e);
149
- return S({ reason: "route_change" }), t;
150
- };
151
- r.pushState = a, _ = () => {
152
- document.removeEventListener("visibilitychange", e), window.removeEventListener("pagehide", t, { capture: !0 }), window.removeEventListener("popstate", n), r.pushState === a && (r.pushState = i);
153
- };
154
- };
155
- return {
156
- setLocale: x,
157
- trackPageView: S,
158
- trackContentExposure: C,
159
- trackConversion: w,
160
- getVariant: T,
161
- flush: y,
162
- start: () => {
163
- g || (g = !0, l = setInterval(y, e.flushInterval), l?.unref?.(), f(E));
164
- },
165
- stop: () => {
166
- g && (g = !1, l &&= (clearInterval(l), null), _?.(), _ = null, y(!0));
167
- }
168
- };
169
- }, _ = "__intlayer_analytics_client__", v = "__intlayer_analytics_ref_count__", y = () => typeof window > "u" ? null : window[_] ?? null, b = (e) => {
170
- typeof window > "u" || (window[_] = e);
171
- }, x = () => {
172
- if (typeof window > "u") return 0;
173
- let e = window;
174
- return e[v] = (e[v] ?? 0) + 1, e[v];
175
- }, S = () => {
176
- if (typeof window > "u") return 0;
177
- let e = window;
178
- return e[v] = Math.max(0, (e[v] ?? 0) - 1), e[v];
179
- }, C = () => {
180
- x();
181
- let n = y();
182
- if (n) return n;
183
- let r = g({
184
- backendURL: t?.backendURL ?? "",
185
- clientId: t?.clientId,
186
- flushInterval: e?.flushInterval ?? 2e4,
187
- maxBufferSize: 500,
188
- sampleRate: e?.sampleRate ?? 1
189
- });
190
- return b(r), r.start(), r;
191
- }, w = () => {
192
- S() > 0 || (y()?.stop(), b(null));
193
- }, T = (e) => e.map((e) => e.key === void 0 ? "*" : String(e.key)).join("."), E = (e) => ({
194
- dictionaryKey: e.dictionaryKey,
195
- keyPath: T(e.keyPath),
196
- locale: e.locale,
197
- nodeType: e.nodeType,
198
- experimentKey: e.experimentKey,
199
- variant: e.variant
200
- });
201
- //#endregion
202
- export { E as buildContentExposure, y as getGlobalAnalyticsClient, C as initAnalyticsClient, w as stopAnalyticsClient };
@@ -1 +0,0 @@
1
- let e=require("@intlayer/config/built");var t=process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&e.analytics?.enabled===!0&&!!e.editor?.clientId&&typeof window<`u`&&window.self===window.top;Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
@@ -1,5 +0,0 @@
1
- import { analytics as e, editor as t } from "@intlayer/config/built";
2
- //#region ../@intlayer/analytics/dist/esm/isEnabled.mjs
3
- var n = process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e?.enabled === !0 && !!t?.clientId && typeof window < "u" && window.self === window.top;
4
- //#endregion
5
- export { n as t };