vue-intlayer 9.5.0 → 9.5.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/dist/cjs/analytics/useAnalytics.cjs +1 -1
- package/dist/cjs/analytics/useConversion.cjs +1 -1
- package/dist/cjs/analytics/useExperiment.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/esm/analytics/useAnalytics.mjs +2 -2
- package/dist/esm/analytics/useConversion.mjs +1 -1
- package/dist/esm/analytics/useExperiment.mjs +2 -2
- package/dist/esm/client/useLocale.mjs +8 -8
- package/dist/esm-DXg1m_y3.js +1 -0
- package/dist/esm-DZ1bEPA6.mjs +261 -0
- package/dist/types/client/useLocaleStorage.d.ts +4 -4
- package/dist/types/format/useCompact.d.ts +1 -1
- package/dist/types/format/useCurrency.d.ts +1 -1
- package/dist/types/format/useDate.d.ts +1 -1
- package/dist/types/format/useList.d.ts +1 -1
- package/dist/types/format/useNumber.d.ts +1 -1
- package/dist/types/format/usePercentage.d.ts +1 -1
- package/dist/types/format/useRelativeTime.d.ts +1 -1
- package/dist/types/format/useUnit.d.ts +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-DXg1m_y3.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-DXg1m_y3.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-CuTKz0YA.js");var t=()=>t=>{process.env.INTLAYER_ANALYTICS_ENABLED
|
|
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-DXg1m_y3.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-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
|
|
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-DXg1m_y3.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-DXg1m_y3.js")).then(({stopAnalyticsClient:e})=>{c&&e()}).catch(()=>{})}),{variant:a,isAssigned:o}};exports.useExperiment=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./installIntlayer.cjs"),t=require("./useLocaleStorage.cjs");let n=require("vue"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./installIntlayer.cjs"),t=require("./useLocaleStorage.cjs");let n=require("vue");var{defaultLocale:r,locales:i}=require("@intlayer/config/built").internationalization??{},a=({isCookieEnabled:a,onLocaleChange:o}={})=>{let s=(0,n.inject)(e.INTLAYER_SYMBOL);return{locale:(0,n.computed)(()=>s?.locale?.value??r),defaultLocale:r,availableLocales:i,setLocale:e=>{if(!i?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}s&&s.setLocale(e),t.setLocaleInStorage(e,a??s?.isCookieEnabled??!0),o?.(e)}}};exports.useLocale=a;
|
|
@@ -5,14 +5,14 @@ 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-
|
|
8
|
+
return import("../../esm-DZ1bEPA6.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-
|
|
15
|
+
r = !0, n?.(), e(null), import("../../esm-DZ1bEPA6.mjs").then(({ stopAnalyticsClient: e }) => {
|
|
16
16
|
i && e();
|
|
17
17
|
}).catch(() => {});
|
|
18
18
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
|
4
|
+
process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e && import("../../esm-DZ1bEPA6.mjs").then(({ getGlobalAnalyticsClient: e }) => {
|
|
5
5
|
e()?.trackConversion(t);
|
|
6
6
|
}).catch(() => {});
|
|
7
7
|
};
|
|
@@ -4,7 +4,7 @@ import { onMounted as t, onUnmounted as n, ref as r } from "vue";
|
|
|
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
|
|
7
|
+
process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e && import("../../esm-DZ1bEPA6.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-
|
|
21
|
+
l = !0, import("../../esm-DZ1bEPA6.mjs").then(({ stopAnalyticsClient: e }) => {
|
|
22
22
|
u && e();
|
|
23
23
|
}).catch(() => {});
|
|
24
24
|
}), {
|
|
@@ -3,20 +3,20 @@ import { setLocaleInStorage as t } from "./useLocaleStorage.mjs";
|
|
|
3
3
|
import { computed as n, inject as r } from "vue";
|
|
4
4
|
import { internationalization as i } from "@intlayer/config/built";
|
|
5
5
|
//#region src/client/useLocale.ts
|
|
6
|
-
var a = ({ isCookieEnabled:
|
|
7
|
-
let
|
|
6
|
+
var { defaultLocale: a, locales: o } = i ?? {}, s = ({ isCookieEnabled: i, onLocaleChange: s } = {}) => {
|
|
7
|
+
let c = r(e);
|
|
8
8
|
return {
|
|
9
|
-
locale: n(() =>
|
|
10
|
-
defaultLocale:
|
|
11
|
-
availableLocales:
|
|
9
|
+
locale: n(() => c?.locale?.value ?? a),
|
|
10
|
+
defaultLocale: a,
|
|
11
|
+
availableLocales: o,
|
|
12
12
|
setLocale: (e) => {
|
|
13
|
-
if (!
|
|
13
|
+
if (!o?.map(String).includes(e)) {
|
|
14
14
|
console.error(`Locale ${e} is not available`);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
c && c.setLocale(e), t(e, i ?? c?.isCookieEnabled ?? !0), s?.(e);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
|
-
export {
|
|
22
|
+
export { s as useLocale };
|
|
@@ -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 };
|
|
@@ -2,13 +2,13 @@ import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the locale cookie
|
|
4
4
|
*/
|
|
5
|
-
export declare const localeInStorage: import('
|
|
5
|
+
export declare const localeInStorage: import('intlayer').Locale | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Use localeInStorage instead
|
|
8
8
|
*
|
|
9
9
|
* Get the locale cookie
|
|
10
10
|
*/
|
|
11
|
-
export declare const localeCookie: import('
|
|
11
|
+
export declare const localeCookie: import('intlayer').Locale | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Set the locale cookie
|
|
14
14
|
*/
|
|
@@ -23,7 +23,7 @@ export declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: b
|
|
|
23
23
|
* Composable that provides the locale storage and a function to set it
|
|
24
24
|
*/
|
|
25
25
|
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
26
|
-
localeStorage: import('vue').ComputedRef<import('
|
|
26
|
+
localeStorage: import('vue').ComputedRef<import('intlayer').Locale>;
|
|
27
27
|
setLocaleStorage: (locale: LocalesValues) => void;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
@@ -34,6 +34,6 @@ export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
34
34
|
* Composable that provides the locale cookie and a function to set it
|
|
35
35
|
*/
|
|
36
36
|
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
37
|
-
localeStorage: import('vue').ComputedRef<import('
|
|
37
|
+
localeStorage: import('vue').ComputedRef<import('intlayer').Locale>;
|
|
38
38
|
setLocaleStorage: (locale: LocalesValues) => void;
|
|
39
39
|
};
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
11
|
export declare const useCompact: () => import('vue').ComputedRef<(value: string | number, options?: (Intl.NumberFormatOptions & {
|
|
12
|
-
locale?: import('
|
|
12
|
+
locale?: import('intlayer').LocalesValues;
|
|
13
13
|
}) | undefined) => string>;
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare const useCurrency: () => import('vue').ComputedRef<(value: string | number, options?: (Intl.NumberFormatOptions & {
|
|
23
|
-
locale?: import('
|
|
23
|
+
locale?: import('intlayer').LocalesValues;
|
|
24
24
|
}) | undefined) => string>;
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export declare const useDate: () => import('vue').ComputedRef<(date: string | number | Date, options?: (Intl.DateTimeFormatOptions & {
|
|
21
|
-
locale?: import('
|
|
21
|
+
locale?: import('intlayer').LocalesValues;
|
|
22
22
|
}) | import('@intlayer/core/formatters').DateTimePreset | undefined) => string>;
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export declare const useList: () => import('vue').ComputedRef<(values: (string | number)[], options?: (import('@intlayer/core/formatters').ListFormatOptions & {
|
|
20
|
-
locale?: import('
|
|
20
|
+
locale?: import('intlayer').LocalesValues;
|
|
21
21
|
}) | undefined) => string>;
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export declare const useNumber: () => import('vue').ComputedRef<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
|
|
21
|
-
locale?: import('
|
|
21
|
+
locale?: import('intlayer').LocalesValues;
|
|
22
22
|
}) | undefined) => string>;
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare const usePercentage: () => import('vue').ComputedRef<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
|
|
15
|
-
locale?: import('
|
|
15
|
+
locale?: import('intlayer').LocalesValues;
|
|
16
16
|
}) | undefined) => string>;
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export declare const useRelativeTime: () => import('vue').ComputedRef<(from: string | number | Date, to?: string | number | Date | undefined, options?: (Intl.RelativeTimeFormatOptions & {
|
|
18
|
-
locale?: import('
|
|
18
|
+
locale?: import('intlayer').LocalesValues;
|
|
19
19
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
20
20
|
}) | undefined) => string>;
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
export declare const useUnit: () => import('vue').ComputedRef<(value: string | number, options?: (Intl.NumberFormatOptions & {
|
|
17
|
-
locale?: import('
|
|
17
|
+
locale?: import('intlayer').LocalesValues;
|
|
18
18
|
}) | undefined) => string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.2",
|
|
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.5.
|
|
106
|
-
"@intlayer/config": "9.5.
|
|
107
|
-
"@intlayer/core": "9.5.
|
|
108
|
-
"@intlayer/editor": "9.5.
|
|
109
|
-
"@intlayer/types": "9.5.
|
|
105
|
+
"@intlayer/api": "9.5.2",
|
|
106
|
+
"@intlayer/config": "9.5.2",
|
|
107
|
+
"@intlayer/core": "9.5.2",
|
|
108
|
+
"@intlayer/editor": "9.5.2",
|
|
109
|
+
"@intlayer/types": "9.5.2"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@types/node": "
|
|
112
|
+
"@types/node": "^22",
|
|
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",
|
|
@@ -119,13 +119,13 @@
|
|
|
119
119
|
"rimraf": "6.1.3",
|
|
120
120
|
"tsdown": "0.23.0",
|
|
121
121
|
"typescript": "7.0.2",
|
|
122
|
-
"vite": "8.
|
|
122
|
+
"vite": "8.3.0",
|
|
123
123
|
"vite-plugin-dts": "5.1.0",
|
|
124
124
|
"vitest": "5.0.0",
|
|
125
125
|
"vue-tsc": "3.3.9"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
|
-
"intlayer": "9.5.
|
|
128
|
+
"intlayer": "9.5.2",
|
|
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.5.
|
|
137
|
+
"@intlayer/analytics": "9.5.2"
|
|
138
138
|
},
|
|
139
139
|
"engines": {
|
|
140
140
|
"node": ">=14.18"
|