vue-intlayer 9.5.1 → 9.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/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/installIntlayer.cjs +1 -1
- package/dist/cjs/devtools/formatDictionaryForInspector.cjs +1 -0
- package/dist/cjs/devtools/index.cjs +1 -0
- 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/installIntlayer.mjs +2 -0
- package/dist/esm/devtools/formatDictionaryForInspector.mjs +35 -0
- package/dist/esm/devtools/index.mjs +65 -0
- package/dist/esm-DXg1m_y3.js +1 -0
- package/dist/{esm-yuHc2Obh.mjs → esm-DZ1bEPA6.mjs} +1 -1
- package/dist/types/devtools/formatDictionaryForInspector.d.ts +13 -0
- package/dist/types/devtools/index.d.ts +12 -0
- package/package.json +12 -10
- package/dist/esm-BeJJ8BHD.js +0 -1
package/README.md
CHANGED
|
@@ -328,4 +328,4 @@ Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https:/
|
|
|
328
328
|
|
|
329
329
|
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
330
330
|
|
|
331
|
-
[](https://
|
|
331
|
+
[](https://star-history.com/#aymericzip/intlayer&Date)
|
|
@@ -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`});let e=require("vue"),t=require("@intlayer/config/built"),n=require("@intlayer/config/client");var r=Symbol(`intlayer`),i=null,a=(r,a=!0,o)=>{if(i)return i;(0,n.setIntlayerIdentifier)();let{defaultLocale:s}=t.internationalization??{},c=(0,e.ref)(r??s),l=e=>{c.value=e},u=(0,e.ref)(o);return i={locale:(0,e.readonly)(c),setLocale:l,variant:(0,e.readonly)(u),setVariant:e=>{u.value=e},isCookieEnabled:a},i},o=(e,t)=>{let{locale:n,isCookieEnabled:i,variant:o}=t??{},s=a(n,i,o);return e.provide(r,s),process.env.INTLAYER_EDITOR_ENABLED!==`false`&&Promise.resolve().then(()=>require("../editor/useEditor.cjs")).then(({useEditor:t})=>{t(e)}).catch(()=>{}),process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&Promise.resolve().then(()=>require("../analytics/useAnalytics.cjs")).then(({useAnalytics:t})=>{t(e)}).catch(()=>{}),e},s={install:o};exports.INTLAYER_SYMBOL=r,exports.createIntlayerClient=a,exports.installIntlayer=o,exports.intlayer=s;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@intlayer/config/built"),n=require("@intlayer/config/client");var r=Symbol(`intlayer`),i=null,a=(r,a=!0,o)=>{if(i)return i;(0,n.setIntlayerIdentifier)();let{defaultLocale:s}=t.internationalization??{},c=(0,e.ref)(r??s),l=e=>{c.value=e},u=(0,e.ref)(o);return i={locale:(0,e.readonly)(c),setLocale:l,variant:(0,e.readonly)(u),setVariant:e=>{u.value=e},isCookieEnabled:a},i},o=(e,t)=>{let{locale:n,isCookieEnabled:i,variant:o}=t??{},s=a(n,i,o);return e.provide(r,s),process.env.INTLAYER_EDITOR_ENABLED!==`false`&&Promise.resolve().then(()=>require("../editor/useEditor.cjs")).then(({useEditor:t})=>{t(e)}).catch(()=>{}),process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&Promise.resolve().then(()=>require("../analytics/useAnalytics.cjs")).then(({useAnalytics:t})=>{t(e)}).catch(()=>{}),process.env.INTLAYER_DEVTOOLS_ENABLED!==`false`&&Promise.resolve().then(()=>require("../devtools/index.cjs")).then(({enableIntlayerDevtools:t})=>{t(e)}).catch(()=>{}),e},s={install:o};exports.INTLAYER_SYMBOL=r,exports.createIntlayerClient=a,exports.installIntlayer=o,exports.intlayer=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>typeof e==`object`&&!!e&&!Array.isArray(e),t=t=>e(t)&&t.nodeType===`translation`&&e(t.translation),n=e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}},r=(i,a,o)=>{let s=a.length===0?`(root)`:a.join(`.`);if(t(i)){o[s]=i.translation;return}if(e(i)&&typeof i.nodeType==`string`){o[s]=n(i[i.nodeType]);return}if(Array.isArray(i)){i.forEach((e,t)=>{r(e,[...a,String(t)],o)});return}if(e(i)){for(let[e,t]of Object.entries(i))r(t,[...a,e],o);return}a.length>0&&(o[a.join(`.`)]=n(i))},i=e=>{let t={};return r(e.content,[],t),t};exports.formatDictionaryForInspector=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./formatDictionaryForInspector.cjs");let t=require("@intlayer/dictionaries-entry"),n=require("@vue/devtools-api");var r=`intlayer`,i=`intlayer-dictionaries-inspector`,a=a=>{(0,n.setupDevtoolsPlugin)({id:r,label:`Intlayer`,packageName:`vue-intlayer`,homepage:`https://intlayer.org`,componentStateTypes:[r],app:a},n=>{n.addInspector({id:i,label:`Intlayer`,icon:`language`,treeFilterPlaceholder:`Search dictionaries`}),n.on.getInspectorTree(e=>{if(e.inspectorId!==`intlayer-dictionaries-inspector`)return;let n=(0,t.getDictionaries)(),r=Object.keys(n);e.rootNodes=r.length===0?[{id:`intlayer-no-dictionaries`,label:`No dictionaries loaded. Add an Intlayer build plugin (e.g. vite-intlayer) to generate them.`}]:r.map(e=>({id:e,label:e}))}),n.on.getInspectorState(n=>{if(n.inspectorId!==`intlayer-dictionaries-inspector`)return;let r=(0,t.getDictionaries)()[n.nodeId];if(!r){n.state={};return}let i=e.formatDictionaryForInspector(r);n.state={Translations:Object.entries(i).map(([e,t])=>({key:e,value:t,editable:!1})),Metadata:[{key:`key`,value:r.key,editable:!1},{key:`title`,value:r.title??``,editable:!1},{key:`description`,value:r.description??``,editable:!1}]}})})};exports.INTLAYER_DEVTOOLS_PLUGIN_ID=r,exports.INTLAYER_DICTIONARIES_INSPECTOR_ID=i,exports.enableIntlayerDevtools=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
|
}), {
|
|
@@ -23,6 +23,8 @@ var i = Symbol("intlayer"), a = null, o = (i, o = !0, s) => {
|
|
|
23
23
|
t(e);
|
|
24
24
|
}).catch(() => {}), process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && import("../analytics/useAnalytics.mjs").then(({ useAnalytics: t }) => {
|
|
25
25
|
t(e);
|
|
26
|
+
}).catch(() => {}), process.env.INTLAYER_DEVTOOLS_ENABLED !== "false" && import("../devtools/index.mjs").then(({ enableIntlayerDevtools: t }) => {
|
|
27
|
+
t(e);
|
|
26
28
|
}).catch(() => {}), e;
|
|
27
29
|
}, c = { install: s };
|
|
28
30
|
//#endregion
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/devtools/formatDictionaryForInspector.ts
|
|
2
|
+
var e = (e) => typeof e == "object" && !!e && !Array.isArray(e), t = (t) => e(t) && t.nodeType === "translation" && e(t.translation), n = (e) => {
|
|
3
|
+
if (typeof e == "string") return e;
|
|
4
|
+
try {
|
|
5
|
+
return JSON.stringify(e) ?? String(e);
|
|
6
|
+
} catch {
|
|
7
|
+
return String(e);
|
|
8
|
+
}
|
|
9
|
+
}, r = (i, a, o) => {
|
|
10
|
+
let s = a.length === 0 ? "(root)" : a.join(".");
|
|
11
|
+
if (t(i)) {
|
|
12
|
+
o[s] = i.translation;
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (e(i) && typeof i.nodeType == "string") {
|
|
16
|
+
o[s] = n(i[i.nodeType]);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(i)) {
|
|
20
|
+
i.forEach((e, t) => {
|
|
21
|
+
r(e, [...a, String(t)], o);
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (e(i)) {
|
|
26
|
+
for (let [e, t] of Object.entries(i)) r(t, [...a, e], o);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
a.length > 0 && (o[a.join(".")] = n(i));
|
|
30
|
+
}, i = (e) => {
|
|
31
|
+
let t = {};
|
|
32
|
+
return r(e.content, [], t), t;
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { i as formatDictionaryForInspector };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { formatDictionaryForInspector as e } from "./formatDictionaryForInspector.mjs";
|
|
2
|
+
import { getDictionaries as t } from "@intlayer/dictionaries-entry";
|
|
3
|
+
import { setupDevtoolsPlugin as n } from "@vue/devtools-api";
|
|
4
|
+
//#region src/devtools/index.ts
|
|
5
|
+
var r = "intlayer", i = "intlayer-dictionaries-inspector", a = (a) => {
|
|
6
|
+
n({
|
|
7
|
+
id: r,
|
|
8
|
+
label: "Intlayer",
|
|
9
|
+
packageName: "vue-intlayer",
|
|
10
|
+
homepage: "https://intlayer.org",
|
|
11
|
+
componentStateTypes: [r],
|
|
12
|
+
app: a
|
|
13
|
+
}, (n) => {
|
|
14
|
+
n.addInspector({
|
|
15
|
+
id: i,
|
|
16
|
+
label: "Intlayer",
|
|
17
|
+
icon: "language",
|
|
18
|
+
treeFilterPlaceholder: "Search dictionaries"
|
|
19
|
+
}), n.on.getInspectorTree((e) => {
|
|
20
|
+
if (e.inspectorId !== "intlayer-dictionaries-inspector") return;
|
|
21
|
+
let n = t(), r = Object.keys(n);
|
|
22
|
+
e.rootNodes = r.length === 0 ? [{
|
|
23
|
+
id: "intlayer-no-dictionaries",
|
|
24
|
+
label: "No dictionaries loaded. Add an Intlayer build plugin (e.g. vite-intlayer) to generate them."
|
|
25
|
+
}] : r.map((e) => ({
|
|
26
|
+
id: e,
|
|
27
|
+
label: e
|
|
28
|
+
}));
|
|
29
|
+
}), n.on.getInspectorState((n) => {
|
|
30
|
+
if (n.inspectorId !== "intlayer-dictionaries-inspector") return;
|
|
31
|
+
let r = t()[n.nodeId];
|
|
32
|
+
if (!r) {
|
|
33
|
+
n.state = {};
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let i = e(r);
|
|
37
|
+
n.state = {
|
|
38
|
+
Translations: Object.entries(i).map(([e, t]) => ({
|
|
39
|
+
key: e,
|
|
40
|
+
value: t,
|
|
41
|
+
editable: !1
|
|
42
|
+
})),
|
|
43
|
+
Metadata: [
|
|
44
|
+
{
|
|
45
|
+
key: "key",
|
|
46
|
+
value: r.key,
|
|
47
|
+
editable: !1
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: "title",
|
|
51
|
+
value: r.title ?? "",
|
|
52
|
+
editable: !1
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "description",
|
|
56
|
+
value: r.description ?? "",
|
|
57
|
+
editable: !1
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { r as INTLAYER_DEVTOOLS_PLUGIN_ID, i as INTLAYER_DICTIONARIES_INSPECTOR_ID, a as enableIntlayerDevtools };
|
|
@@ -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;
|
|
@@ -131,7 +131,7 @@ var r = (e) => {
|
|
|
131
131
|
return {
|
|
132
132
|
getToken: o,
|
|
133
133
|
prime: () => {
|
|
134
|
-
|
|
134
|
+
t && typeof fetch == "function" && (o() || (i ||= s()));
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
}, y = "intlayer-analytics/1", b = () => typeof window > "u" || !window.location ? "" : window.location.pathname, x = () => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
+
/**
|
|
3
|
+
* Flattened representation of a dictionary content for the devtools
|
|
4
|
+
* inspector: each leaf path maps to its per-locale translations, or to a
|
|
5
|
+
* stringified fallback for non-translation content.
|
|
6
|
+
*/
|
|
7
|
+
export type FlattenedDictionary = Record<string, Record<string, string> | string>;
|
|
8
|
+
/**
|
|
9
|
+
* Recursively flatten a dictionary content into leaf-path entries.
|
|
10
|
+
* Translation nodes are exposed as their locale-to-string map; any other
|
|
11
|
+
* node type falls back to a string rendering.
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatDictionaryForInspector: (dictionary: Dictionary) => FlattenedDictionary;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
export declare const INTLAYER_DEVTOOLS_PLUGIN_ID = "intlayer";
|
|
3
|
+
export declare const INTLAYER_DICTIONARIES_INSPECTOR_ID = "intlayer-dictionaries-inspector";
|
|
4
|
+
/**
|
|
5
|
+
* Register the Intlayer plugin in Vue Devtools with a read-only inspector
|
|
6
|
+
* listing the loaded dictionaries and their translations.
|
|
7
|
+
*
|
|
8
|
+
* Lazy-loaded by `installIntlayer`; safe to call only in a browser
|
|
9
|
+
* environment where the devtools hook may exist — `setupDevtoolsPlugin`
|
|
10
|
+
* no-ops when Vue Devtools is not installed.
|
|
11
|
+
*/
|
|
12
|
+
export declare const enableIntlayerDevtools: (app: App) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.3",
|
|
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,16 @@
|
|
|
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/
|
|
109
|
-
"@intlayer/
|
|
105
|
+
"@intlayer/api": "9.5.3",
|
|
106
|
+
"@intlayer/config": "9.5.3",
|
|
107
|
+
"@intlayer/core": "9.5.3",
|
|
108
|
+
"@intlayer/dictionaries-entry": "9.5.3",
|
|
109
|
+
"@intlayer/editor": "9.5.3",
|
|
110
|
+
"@intlayer/types": "9.5.3",
|
|
111
|
+
"@vue/devtools-api": "^6.6.4"
|
|
110
112
|
},
|
|
111
113
|
"devDependencies": {
|
|
112
|
-
"@types/node": "
|
|
114
|
+
"@types/node": "^22",
|
|
113
115
|
"@utils/ts-config": "1.0.4",
|
|
114
116
|
"@utils/ts-config-types": "1.0.4",
|
|
115
117
|
"@utils/tsdown-config": "1.0.4",
|
|
@@ -119,13 +121,13 @@
|
|
|
119
121
|
"rimraf": "6.1.3",
|
|
120
122
|
"tsdown": "0.23.0",
|
|
121
123
|
"typescript": "7.0.2",
|
|
122
|
-
"vite": "8.
|
|
124
|
+
"vite": "8.3.0",
|
|
123
125
|
"vite-plugin-dts": "5.1.0",
|
|
124
126
|
"vitest": "5.0.0",
|
|
125
127
|
"vue-tsc": "3.3.9"
|
|
126
128
|
},
|
|
127
129
|
"peerDependencies": {
|
|
128
|
-
"intlayer": "9.5.
|
|
130
|
+
"intlayer": "9.5.3",
|
|
129
131
|
"vue": ">=3.0.0"
|
|
130
132
|
},
|
|
131
133
|
"peerDependenciesMeta": {
|
|
@@ -134,7 +136,7 @@
|
|
|
134
136
|
}
|
|
135
137
|
},
|
|
136
138
|
"optionalDependencies": {
|
|
137
|
-
"@intlayer/analytics": "9.5.
|
|
139
|
+
"@intlayer/analytics": "9.5.3"
|
|
138
140
|
},
|
|
139
141
|
"engines": {
|
|
140
142
|
"node": ">=14.18"
|
package/dist/esm-BeJJ8BHD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|