vue-intlayer 9.5.9 → 9.5.10
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/installIntlayer.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -1
- package/dist/cjs/devtools/index.cjs +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/cjs/renderIntlayerNode.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/installIntlayer.mjs +22 -21
- package/dist/esm/client/useLocale.mjs +7 -7
- package/dist/esm/client/useLocaleStorage.mjs +10 -10
- package/dist/esm/devtools/index.mjs +22 -22
- package/dist/esm/plugins.mjs +23 -23
- package/dist/esm/renderIntlayerNode.mjs +20 -31
- package/dist/{esm-DXg1m_y3.js → esm-CXlI80Tk.js} +1 -1
- package/dist/{esm-DZ1bEPA6.mjs → esm-CtrrRmRn.mjs} +2 -2
- package/dist/types/client/useLocaleStorage.d.ts +14 -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/dist/types/index.d.ts +0 -2
- package/package.json +11 -11
|
@@ -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-CXlI80Tk.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-CXlI80Tk.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!==`false`&&e.t&&Promise.resolve().then(()=>require("../../esm-
|
|
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-CXlI80Tk.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!==`false`&&e.t&&Promise.resolve().then(()=>require("../../esm-
|
|
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-CXlI80Tk.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-CXlI80Tk.js")).then(({stopAnalyticsClient:e})=>{c&&e()}).catch(()=>{})}),{variant:a,isAssigned:o}};exports.useExperiment=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useLocaleStorage.cjs");let t=require("@intlayer/config/built"),n=require("vue"),r=require("@intlayer/config/client");var i=Symbol(`intlayer`),a=null,o=(i,o=!0,s)=>{if(a)return a;(0,r.setIntlayerIdentifier)();let{defaultLocale:c}=t.internationalization??{},l=(0,n.ref)(i??e.getLocaleInStorage()??c),u=e=>{l.value=e},d=(0,n.ref)(s);return a={locale:(0,n.readonly)(l),setLocale:u,variant:(0,n.readonly)(d),setVariant:e=>{d.value=e},isCookieEnabled:o},a},s=(e,t)=>{let{locale:n,isCookieEnabled:r,variant:a}=t??{},s=o(n,r,a);return e.provide(i,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},c={install:s};exports.INTLAYER_SYMBOL=i,exports.createIntlayerClient=o,exports.installIntlayer=s,exports.intlayer=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useLocaleStorage.cjs"),t=require("./installIntlayer.cjs");let n=require("@intlayer/config/built"),r=require("vue");var{defaultLocale:i,locales:a}=n.internationalization??{},o=({isCookieEnabled:n,onLocaleChange:o}={})=>{let s=(0,r.inject)(t.INTLAYER_SYMBOL);return{locale:(0,r.computed)(()=>s?.locale?.value??i),defaultLocale:i,availableLocales:a,setLocale:t=>{if(!a?.map(String).includes(t)){console.error(`Locale ${t} is not available`);return}s&&s.setLocale(t),e.setLocaleInStorage(t,n??s?.isCookieEnabled??!0),o?.(t)}}};exports.useLocale=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@intlayer/core/utils");var n=(0,t.getLocaleFromStorageClient)(t.localeStorageOptions),r
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@intlayer/core/utils");var n=t.getCachedLocaleFromStorageClient,r=(0,t.getLocaleFromStorageClient)(t.localeStorageOptions),i=r,a=(e,n)=>(0,t.setLocaleInStorageClient)(e,{...t.localeStorageOptions,isCookieEnabled:n}),o=a,s=n=>{let r=(0,t.LocaleStorageClient)({...t.localeStorageOptions,isCookieEnabled:n});return{localeStorage:(0,e.computed)(()=>r.getLocale()),setLocaleStorage:r.setLocale}},c=s;exports.getLocaleInStorage=n,exports.localeCookie=i,exports.localeInStorage=r,exports.setLocaleCookie=o,exports.setLocaleInStorage=a,exports.useLocaleCookie=c,exports.useLocaleStorage=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../client/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../client/useLocaleStorage.cjs"),t=require("../client/installIntlayer.cjs"),n=require("./formatDictionaryForInspector.cjs"),r=require("./buildLocalesInspectorNode.cjs");let i=require("@intlayer/config/built"),a=require("vue"),o=require("@intlayer/dictionaries-entry"),s=require("@vue/devtools-api");var c=`intlayer`,l=`intlayer-dictionaries-inspector`,{defaultLocale:u,locales:d}=i.internationalization??{},f=s.setupDevtoolsPlugin,p=i=>{f({id:c,label:`Intlayer`,packageName:`vue-intlayer`,homepage:`https://intlayer.org`,componentStateTypes:[c],app:i},i=>{i.addInspector({id:l,label:`Intlayer`,icon:`language`,treeFilterPlaceholder:`Search dictionaries`,nodeActions:[{icon:`check`,tooltip:`Set as current locale`,action:n=>{if(!r.isLocaleNodeId(n))return;let a=r.getLocaleFromNodeId(n);if(!d?.map(String).includes(a)){console.error(`Locale ${a} is not available`);return}let o=t.createIntlayerClient();o.setLocale(a),e.setLocaleInStorage(a,o.isCookieEnabled??!0),i.sendInspectorTree(l),i.sendInspectorState(l)}}]}),(0,a.watch)(()=>t.createIntlayerClient().locale.value,()=>{i.sendInspectorTree(l),i.sendInspectorState(l)}),i.on.getInspectorTree(e=>{if(e.inspectorId!==`intlayer-dictionaries-inspector`)return;let n=(0,o.getDictionaries)(),i=Object.keys(n),a=t.createIntlayerClient().locale.value??u;e.rootNodes=[...i.length===0?[{id:`intlayer-no-dictionaries`,label:`No dictionaries loaded. Add an Intlayer build plugin (e.g. vite-intlayer) to generate them.`}]:i.map(e=>({id:e,label:e})),r.buildLocalesInspectorNode(a)]}),i.on.getInspectorState(e=>{if(e.inspectorId!==`intlayer-dictionaries-inspector`)return;let i=t.createIntlayerClient().locale.value??u;if(e.nodeId===`intlayer-locales`){e.state={Locales:(d??[]).map(e=>({key:e,value:e===i?`current`:``,editable:!1}))};return}if(r.isLocaleNodeId(e.nodeId)){let t=r.getLocaleFromNodeId(e.nodeId);e.state={Locale:[{key:`locale`,value:t,editable:!1},{key:`current`,value:t===i,editable:!1}]};return}let a=(0,o.getDictionaries)()[e.nodeId];if(!a){e.state={};return}let s=n.formatDictionaryForInspector(a);e.state={Translations:Object.entries(s).map(([e,t])=>({key:e,value:t,editable:!1})),Metadata:[{key:`key`,value:a.key,editable:!1},{key:`title`,value:a.title??``,editable:!1},{key:`description`,value:a.description??``,editable:!1}]}})})};exports.INTLAYER_DEVTOOLS_PLUGIN_ID=c,exports.INTLAYER_DICTIONARIES_INSPECTOR_ID=l,exports.enableIntlayerDevtools=p;
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./analytics/exposureSink.cjs"),l=require("./html/HTMLRenderer.cjs"),u=require("./markdown/installIntlayerMarkdown.cjs"),d=require("./renderIntlayerNode.cjs");let f=require("@intlayer/core/interpreter"),p=require("@intlayer/config/built"),m=require("@intlayer/core/markdown"),h=require("@intlayer/types/nodeType");h=s(h);let g=require("vue");var _=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,g.defineAsyncComponent)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs"))),v={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./analytics/exposureSink.cjs"),l=require("./html/HTMLRenderer.cjs"),u=require("./markdown/installIntlayerMarkdown.cjs"),d=require("./renderIntlayerNode.cjs");let f=require("@intlayer/core/interpreter"),p=require("@intlayer/config/built"),m=require("@intlayer/core/markdown"),h=require("@intlayer/types/nodeType");h=s(h);let g=require("vue");var _=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,g.defineAsyncComponent)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs"))),v={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,t)=>{let{children:n,dictionaryKey:r,keyPath:i}=t;process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&c.reportExposure({dictionaryKey:r,keyPath:i,locale:t.locale,nodeType:`text`});let a=e=>d.renderIntlayerNode({value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?()=>(0,g.h)(_,{dictionaryKey:r,keyPath:i},{default:()=>typeof e==`function`?e():e}):e}),o=a(n);if(typeof n!=`function`)return o;let s=(...e)=>{let t=n(...e);return a(t)};Object.setPrototypeOf(s,Object.getPrototypeOf(o));for(let e of Object.getOwnPropertyNames(o)){let t=Object.getOwnPropertyDescriptor(o,e);t&&Object.defineProperty(s,e,t)}for(let e of Object.getOwnPropertySymbols(o)){let t=Object.getOwnPropertyDescriptor(o,e);t&&Object.defineProperty(s,e,t)}return(0,g.markRaw)(s)}},y=(e,t)=>{let n=new Map,r={};for(let[e,i]of Object.entries(t))typeof i==`string`||typeof i==`number`?r[e]=i:(n.set(e,i),r[e]=`__VNODE_${e}__`);let i=(0,f.splitInsertionTemplate)(e,r);if(n.size>0){let e=[];if(i.isSimple){let t=i.parts,r=0;for(let[i]of n){let a=`__VNODE_${i}__`,o=t.indexOf(a);o!==-1&&(o>r&&e.push(t.substring(r,o)),e.push(n.get(i)),r=o+a.length)}return r<t.length&&e.push(t.substring(r)),(0,g.h)(g.Fragment,null,...e)}return i.parts.forEach(t=>{if(typeof t==`string`){let r=t;for(let[t]of n){let i=`__VNODE_${t}__`,a=r.indexOf(i);a!==-1&&(a>0&&e.push(r.substring(0,a)),e.push(n.get(t)),r=r.substring(a+i.length))}r.length>0&&e.push(r)}else e.push(t)}),(0,g.h)(g.Fragment,null,...e)}return i.isSimple?i.parts:(0,g.h)(g.Fragment,null,i.parts)},b=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?f.fallbackPlugin:{id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.INSERTION,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.INSERTION}],i=e[h.INSERTION],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`||(0,f.isInterpolableWrapperNode)(e),transform:(e,n,r)=>{if((0,f.isInterpolableWrapperNode)(e))return i=>(0,f.transformInterpolableNode)(e,i,n,t.plugins,r);let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=y(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return(0,f.resolveInsertedSelector)(i,o)}},x=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?f.fallbackPlugin:{id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,t,n)=>{let{plugins:r,...i}=t,a=n((0,m.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>d.renderIntlayerNode({...n,value:t,children:e})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>d.renderIntlayerNode({...t,value:e,children:()=>{let{renderMarkdown:t,components:r}=u.useMarkdown(),a=t(e,void 0,{...r??{},...n??{}});return process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,g.h)(_,{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},{default:()=>a}):a},additionalProps:{metadata:a,use:e=>o(e)}});return o()}},S=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?f.fallbackPlugin:{id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.MARKDOWN,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.MARKDOWN}],i=e[h.MARKDOWN];return n(i,{...t,children:i,keyPath:r,plugins:[x,...t.plugins??[]]})}},C=process.env.INTLAYER_NODE_TYPE_HTML===`false`?f.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.HTML,transform:(e,t)=>{let n=e[h.HTML];e.tags;let r=(e={})=>{let i=l.renderHTML(n,{components:e});return d.renderIntlayerNode({...t,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?()=>(0,g.h)(_,{dictionaryKey:t.dictionaryKey,keyPath:t.keyPath,...e},{default:()=>i}):i,additionalProps:{use:e=>r(e)}})};return r()}},w=new Map,T=(e,t=!0)=>{let n=`${e??p.internationalization.defaultLocale}_${t}`;if(w.has(n))return w.get(n);let r=[v,(0,f.translationPlugin)(e??p.internationalization.defaultLocale,t?p.internationalization.defaultLocale:void 0),f.enumerationPlugin,(0,f.pluralPlugin)(e??p.internationalization.defaultLocale),f.conditionPlugin,(0,f.nestedPlugin)(e??p.internationalization.defaultLocale),f.filePlugin,f.genderPlugin,f.selectPlugin,b,S,C].filter(e=>e!==f.fallbackPlugin);return w.set(n,r),r};exports.getPlugins=T,exports.htmlPlugin=C,exports.insertionPlugin=b,exports.intlayerNodePlugins=v,exports.markdownPlugin=S,exports.markdownStringPlugin=x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@intlayer/core/utils");var n=({value:r,children:i,additionalProps:a={}})=>{let o=(0,e.ref)(r),s=typeof i==`function`?e=>i(e):()=>i,c=e=>(o.value,s(e)),l=(e=>c(e));return Object.assign(l,{render:c,toString:()=>String(o.value??``),valueOf:()=>o.value,[Symbol.toPrimitive]:()=>o.value,toJSON:()=>o.value,get raw(){return o.value},set raw(e){o.value=e},get value(){return o.value},use(e){return n({value:o.value,children:()=>s(e),additionalProps:a})},__update(e){s=e.render,this.raw=e.raw},...a}),Object.setPrototypeOf(l,(0,t.getIntlayerNodePrototype)(r,Function.prototype)),(0,e.markRaw)(l)};exports.renderIntlayerNode=n;
|
|
@@ -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-CtrrRmRn.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-CtrrRmRn.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 !== "false" && e && import("../../esm-
|
|
4
|
+
process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e && import("../../esm-CtrrRmRn.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 !== "false" && e && import("../../esm-
|
|
7
|
+
process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e && import("../../esm-CtrrRmRn.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-CtrrRmRn.mjs").then(({ stopAnalyticsClient: e }) => {
|
|
22
22
|
u && e();
|
|
23
23
|
}).catch(() => {});
|
|
24
24
|
}), {
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getLocaleInStorage as e } from "./useLocaleStorage.mjs";
|
|
2
|
+
import { internationalization as t } from "@intlayer/config/built";
|
|
3
|
+
import { readonly as n, ref as r } from "vue";
|
|
4
|
+
import { setIntlayerIdentifier as i } from "@intlayer/config/client";
|
|
4
5
|
//#region src/client/installIntlayer.ts
|
|
5
|
-
var
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
let { defaultLocale:
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
return
|
|
12
|
-
locale:
|
|
13
|
-
setLocale:
|
|
14
|
-
variant:
|
|
6
|
+
var a = Symbol("intlayer"), o = null, s = (a, s = !0, c) => {
|
|
7
|
+
if (o) return o;
|
|
8
|
+
i();
|
|
9
|
+
let { defaultLocale: l } = t ?? {}, u = r(a ?? e() ?? l), d = (e) => {
|
|
10
|
+
u.value = e;
|
|
11
|
+
}, f = r(c);
|
|
12
|
+
return o = {
|
|
13
|
+
locale: n(u),
|
|
14
|
+
setLocale: d,
|
|
15
|
+
variant: n(f),
|
|
15
16
|
setVariant: (e) => {
|
|
16
|
-
|
|
17
|
+
f.value = e;
|
|
17
18
|
},
|
|
18
|
-
isCookieEnabled:
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
let { locale: n, isCookieEnabled: r, variant:
|
|
22
|
-
return e.provide(
|
|
19
|
+
isCookieEnabled: s
|
|
20
|
+
}, o;
|
|
21
|
+
}, c = (e, t) => {
|
|
22
|
+
let { locale: n, isCookieEnabled: r, variant: i } = t ?? {}, o = s(n, r, i);
|
|
23
|
+
return e.provide(a, o), process.env.INTLAYER_EDITOR_ENABLED !== "false" && import("../editor/useEditor.mjs").then(({ useEditor: t }) => {
|
|
23
24
|
t(e);
|
|
24
25
|
}).catch(() => {}), process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && import("../analytics/useAnalytics.mjs").then(({ useAnalytics: t }) => {
|
|
25
26
|
t(e);
|
|
26
27
|
}).catch(() => {}), process.env.INTLAYER_DEVTOOLS_ENABLED !== "false" && import("../devtools/index.mjs").then(({ enableIntlayerDevtools: t }) => {
|
|
27
28
|
t(e);
|
|
28
29
|
}).catch(() => {}), e;
|
|
29
|
-
},
|
|
30
|
+
}, l = { install: c };
|
|
30
31
|
//#endregion
|
|
31
|
-
export {
|
|
32
|
+
export { a as INTLAYER_SYMBOL, s as createIntlayerClient, c as installIntlayer, l as intlayer };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { setLocaleInStorage as e } from "./useLocaleStorage.mjs";
|
|
2
|
+
import { INTLAYER_SYMBOL as t } from "./installIntlayer.mjs";
|
|
3
3
|
import { internationalization as n } from "@intlayer/config/built";
|
|
4
4
|
import { computed as r, inject as i } from "vue";
|
|
5
5
|
//#region src/client/useLocale.ts
|
|
6
6
|
var { defaultLocale: a, locales: o } = n ?? {}, s = ({ isCookieEnabled: n, onLocaleChange: s } = {}) => {
|
|
7
|
-
let c = i(
|
|
7
|
+
let c = i(t);
|
|
8
8
|
return {
|
|
9
9
|
locale: r(() => c?.locale?.value ?? a),
|
|
10
10
|
defaultLocale: a,
|
|
11
11
|
availableLocales: o,
|
|
12
|
-
setLocale: (
|
|
13
|
-
if (!o?.map(String).includes(
|
|
14
|
-
console.error(`Locale ${
|
|
12
|
+
setLocale: (t) => {
|
|
13
|
+
if (!o?.map(String).includes(t)) {
|
|
14
|
+
console.error(`Locale ${t} is not available`);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
c && c.setLocale(
|
|
17
|
+
c && c.setLocale(t), e(t, n ?? c?.isCookieEnabled ?? !0), s?.(t);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { computed as e } from "vue";
|
|
2
|
-
import { LocaleStorageClient as t,
|
|
2
|
+
import { LocaleStorageClient as t, getCachedLocaleFromStorageClient as n, getLocaleFromStorageClient as r, localeStorageOptions as i, setLocaleInStorageClient as a } from "@intlayer/core/utils";
|
|
3
3
|
//#region src/client/useLocaleStorage.ts
|
|
4
|
-
var
|
|
5
|
-
...
|
|
4
|
+
var o = n, s = /* @__PURE__ */ r(i), c = s, l = (e, t) => a(e, {
|
|
5
|
+
...i,
|
|
6
6
|
isCookieEnabled: t
|
|
7
|
-
}),
|
|
8
|
-
let
|
|
9
|
-
...
|
|
7
|
+
}), u = l, d = (n) => {
|
|
8
|
+
let r = t({
|
|
9
|
+
...i,
|
|
10
10
|
isCookieEnabled: n
|
|
11
11
|
});
|
|
12
12
|
return {
|
|
13
|
-
localeStorage: e(() =>
|
|
14
|
-
setLocaleStorage:
|
|
13
|
+
localeStorage: e(() => r.getLocale()),
|
|
14
|
+
setLocaleStorage: r.setLocale
|
|
15
15
|
};
|
|
16
|
-
},
|
|
16
|
+
}, f = d;
|
|
17
17
|
//#endregion
|
|
18
|
-
export { o as localeCookie,
|
|
18
|
+
export { o as getLocaleInStorage, c as localeCookie, s as localeInStorage, u as setLocaleCookie, l as setLocaleInStorage, f as useLocaleCookie, d as useLocaleStorage };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { setLocaleInStorage as e } from "../client/useLocaleStorage.mjs";
|
|
2
|
+
import { createIntlayerClient as t } from "../client/installIntlayer.mjs";
|
|
3
3
|
import { formatDictionaryForInspector as n } from "./formatDictionaryForInspector.mjs";
|
|
4
4
|
import { buildLocalesInspectorNode as r, getLocaleFromNodeId as i, isLocaleNodeId as a } from "./buildLocalesInspectorNode.mjs";
|
|
5
5
|
import { internationalization as o } from "@intlayer/config/built";
|
|
@@ -31,53 +31,53 @@ var u = "intlayer", d = "intlayer-dictionaries-inspector", { defaultLocale: f, l
|
|
|
31
31
|
console.error(`Locale ${r} is not available`);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
let s =
|
|
35
|
-
s.setLocale(r),
|
|
34
|
+
let s = t();
|
|
35
|
+
s.setLocale(r), e(r, s.isCookieEnabled ?? !0), o.sendInspectorTree(d), o.sendInspectorState(d);
|
|
36
36
|
}
|
|
37
37
|
}]
|
|
38
|
-
}), s(() =>
|
|
38
|
+
}), s(() => t().locale.value, () => {
|
|
39
39
|
o.sendInspectorTree(d), o.sendInspectorState(d);
|
|
40
|
-
}), o.on.getInspectorTree((
|
|
41
|
-
if (
|
|
42
|
-
let n = c(), i = Object.keys(n), a =
|
|
43
|
-
|
|
40
|
+
}), o.on.getInspectorTree((e) => {
|
|
41
|
+
if (e.inspectorId !== "intlayer-dictionaries-inspector") return;
|
|
42
|
+
let n = c(), i = Object.keys(n), a = t().locale.value ?? f;
|
|
43
|
+
e.rootNodes = [...i.length === 0 ? [{
|
|
44
44
|
id: "intlayer-no-dictionaries",
|
|
45
45
|
label: "No dictionaries loaded. Add an Intlayer build plugin (e.g. vite-intlayer) to generate them."
|
|
46
46
|
}] : i.map((e) => ({
|
|
47
47
|
id: e,
|
|
48
48
|
label: e
|
|
49
49
|
})), r(a)];
|
|
50
|
-
}), o.on.getInspectorState((
|
|
51
|
-
if (
|
|
52
|
-
let r =
|
|
53
|
-
if (
|
|
54
|
-
|
|
50
|
+
}), o.on.getInspectorState((e) => {
|
|
51
|
+
if (e.inspectorId !== "intlayer-dictionaries-inspector") return;
|
|
52
|
+
let r = t().locale.value ?? f;
|
|
53
|
+
if (e.nodeId === "intlayer-locales") {
|
|
54
|
+
e.state = { Locales: (p ?? []).map((e) => ({
|
|
55
55
|
key: e,
|
|
56
56
|
value: e === r ? "current" : "",
|
|
57
57
|
editable: !1
|
|
58
58
|
})) };
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
if (a(
|
|
62
|
-
let
|
|
63
|
-
|
|
61
|
+
if (a(e.nodeId)) {
|
|
62
|
+
let t = i(e.nodeId);
|
|
63
|
+
e.state = { Locale: [{
|
|
64
64
|
key: "locale",
|
|
65
|
-
value:
|
|
65
|
+
value: t,
|
|
66
66
|
editable: !1
|
|
67
67
|
}, {
|
|
68
68
|
key: "current",
|
|
69
|
-
value:
|
|
69
|
+
value: t === r,
|
|
70
70
|
editable: !1
|
|
71
71
|
}] };
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
let o = c()[
|
|
74
|
+
let o = c()[e.nodeId];
|
|
75
75
|
if (!o) {
|
|
76
|
-
|
|
76
|
+
e.state = {};
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
let s = n(o);
|
|
80
|
-
|
|
80
|
+
e.state = {
|
|
81
81
|
Translations: Object.entries(s).map(([e, t]) => ({
|
|
82
82
|
key: e,
|
|
83
83
|
value: t,
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -11,36 +11,36 @@ import { Fragment as x, defineAsyncComponent as S, h as C, markRaw as w } from "
|
|
|
11
11
|
var T = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : S(() => import("./editor/ContentSelector.mjs")), E = {
|
|
12
12
|
id: "intlayer-node-plugin",
|
|
13
13
|
canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
|
|
14
|
-
transform: (t,
|
|
14
|
+
transform: (t, n) => {
|
|
15
|
+
let { children: i, dictionaryKey: a, keyPath: o } = n;
|
|
15
16
|
process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
|
|
16
|
-
dictionaryKey:
|
|
17
|
-
keyPath:
|
|
18
|
-
locale:
|
|
17
|
+
dictionaryKey: a,
|
|
18
|
+
keyPath: o,
|
|
19
|
+
locale: n.locale,
|
|
19
20
|
nodeType: "text"
|
|
20
21
|
});
|
|
21
|
-
let
|
|
22
|
-
...i,
|
|
22
|
+
let s = (e) => r({
|
|
23
23
|
value: e,
|
|
24
24
|
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && _.enabled ? () => C(T, {
|
|
25
|
-
dictionaryKey:
|
|
26
|
-
keyPath:
|
|
25
|
+
dictionaryKey: a,
|
|
26
|
+
keyPath: o
|
|
27
27
|
}, { default: () => typeof e == "function" ? e() : e }) : e
|
|
28
|
-
}),
|
|
29
|
-
if (typeof
|
|
30
|
-
let
|
|
31
|
-
let t =
|
|
32
|
-
return
|
|
28
|
+
}), c = s(i);
|
|
29
|
+
if (typeof i != "function") return c;
|
|
30
|
+
let l = (...e) => {
|
|
31
|
+
let t = i(...e);
|
|
32
|
+
return s(t);
|
|
33
33
|
};
|
|
34
|
-
Object.setPrototypeOf(
|
|
35
|
-
for (let e of Object.getOwnPropertyNames(
|
|
36
|
-
let t = Object.getOwnPropertyDescriptor(
|
|
37
|
-
t && Object.defineProperty(
|
|
34
|
+
Object.setPrototypeOf(l, Object.getPrototypeOf(c));
|
|
35
|
+
for (let e of Object.getOwnPropertyNames(c)) {
|
|
36
|
+
let t = Object.getOwnPropertyDescriptor(c, e);
|
|
37
|
+
t && Object.defineProperty(l, e, t);
|
|
38
38
|
}
|
|
39
|
-
for (let e of Object.getOwnPropertySymbols(
|
|
40
|
-
let t = Object.getOwnPropertyDescriptor(
|
|
41
|
-
t && Object.defineProperty(
|
|
39
|
+
for (let e of Object.getOwnPropertySymbols(c)) {
|
|
40
|
+
let t = Object.getOwnPropertyDescriptor(c, e);
|
|
41
|
+
t && Object.defineProperty(l, e, t);
|
|
42
42
|
}
|
|
43
|
-
return w(
|
|
43
|
+
return w(l);
|
|
44
44
|
}
|
|
45
45
|
}, D = (e, t) => {
|
|
46
46
|
let n = /* @__PURE__ */ new Map(), r = {};
|
|
@@ -172,6 +172,7 @@ var T = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : S(() => import(
|
|
|
172
172
|
let n = `${e ?? v.defaultLocale}_${t}`;
|
|
173
173
|
if (M.has(n)) return M.get(n);
|
|
174
174
|
let r = [
|
|
175
|
+
E,
|
|
175
176
|
g(e ?? v.defaultLocale, t ? v.defaultLocale : void 0),
|
|
176
177
|
a,
|
|
177
178
|
d(e ?? v.defaultLocale),
|
|
@@ -180,11 +181,10 @@ var T = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : S(() => import(
|
|
|
180
181
|
s,
|
|
181
182
|
c,
|
|
182
183
|
p,
|
|
183
|
-
E,
|
|
184
184
|
O,
|
|
185
185
|
A,
|
|
186
186
|
j
|
|
187
|
-
];
|
|
187
|
+
].filter((e) => e !== o);
|
|
188
188
|
return M.set(n, r), r;
|
|
189
189
|
};
|
|
190
190
|
//#endregion
|
|
@@ -1,46 +1,35 @@
|
|
|
1
1
|
import { markRaw as e, ref as t } from "vue";
|
|
2
|
+
import { getIntlayerNodePrototype as n } from "@intlayer/core/utils";
|
|
2
3
|
//#region src/renderIntlayerNode.ts
|
|
3
|
-
var
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
render:
|
|
7
|
-
toString: () => String(
|
|
8
|
-
valueOf: () =>
|
|
9
|
-
[Symbol.toPrimitive]: () =>
|
|
10
|
-
toJSON: () =>
|
|
4
|
+
var r = ({ value: i, children: a, additionalProps: o = {} }) => {
|
|
5
|
+
let s = t(i), c = typeof a == "function" ? (e) => a(e) : () => a, l = (e) => (s.value, c(e)), u = ((e) => l(e));
|
|
6
|
+
return Object.assign(u, {
|
|
7
|
+
render: l,
|
|
8
|
+
toString: () => String(s.value ?? ""),
|
|
9
|
+
valueOf: () => s.value,
|
|
10
|
+
[Symbol.toPrimitive]: () => s.value,
|
|
11
|
+
toJSON: () => s.value,
|
|
11
12
|
get raw() {
|
|
12
|
-
return
|
|
13
|
+
return s.value;
|
|
13
14
|
},
|
|
14
15
|
set raw(e) {
|
|
15
|
-
|
|
16
|
+
s.value = e;
|
|
16
17
|
},
|
|
17
18
|
get value() {
|
|
18
|
-
return
|
|
19
|
+
return s.value;
|
|
19
20
|
},
|
|
20
21
|
use(e) {
|
|
21
|
-
return
|
|
22
|
-
value:
|
|
23
|
-
children: () =>
|
|
24
|
-
additionalProps:
|
|
22
|
+
return r({
|
|
23
|
+
value: s.value,
|
|
24
|
+
children: () => c(e),
|
|
25
|
+
additionalProps: o
|
|
25
26
|
});
|
|
26
27
|
},
|
|
27
28
|
__update(e) {
|
|
28
|
-
|
|
29
|
+
c = e.render, this.raw = e.raw;
|
|
29
30
|
},
|
|
30
|
-
...
|
|
31
|
-
}),
|
|
32
|
-
let e = Object(r), t = Object.getPrototypeOf(e);
|
|
33
|
-
for (let n of Object.getOwnPropertyNames(t)) {
|
|
34
|
-
if (n === "constructor" || n in l) continue;
|
|
35
|
-
let t = e[n];
|
|
36
|
-
typeof t == "function" && Object.defineProperty(l, n, {
|
|
37
|
-
value: t.bind(r),
|
|
38
|
-
writable: !0,
|
|
39
|
-
configurable: !0
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return e(l);
|
|
31
|
+
...o
|
|
32
|
+
}), Object.setPrototypeOf(u, n(i, Function.prototype)), e(u);
|
|
44
33
|
};
|
|
45
34
|
//#endregion
|
|
46
|
-
export {
|
|
35
|
+
export { r as renderIntlayerNode };
|
|
@@ -1 +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(
|
|
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;
|
|
@@ -135,7 +135,7 @@ var r = (e) => {
|
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
}, y = "intlayer-analytics/1", b = () => typeof window > "u" || !window.location ? "" : window.location.pathname, x = () => {
|
|
138
|
-
if (
|
|
138
|
+
if (typeof document < "u" && document.referrer) try {
|
|
139
139
|
return new URL(document.referrer).host;
|
|
140
140
|
} catch {
|
|
141
141
|
return;
|
|
@@ -226,7 +226,7 @@ var r = (e) => {
|
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
}, C = "__intlayer_analytics_client__", w = "__intlayer_analytics_ref_count__", T = () => typeof window > "u" ? null : window[C] ?? null, E = (e) => {
|
|
229
|
-
typeof window
|
|
229
|
+
typeof window < "u" && (window[C] = e);
|
|
230
230
|
}, D = () => {
|
|
231
231
|
if (typeof window > "u") return 0;
|
|
232
232
|
let e = window;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the locale persisted in the browser storage (cookie, localStorage…).
|
|
4
|
+
*
|
|
5
|
+
* Unlike `localeInStorage`, read on first call rather than at import, then
|
|
6
|
+
* cached until the next `setLocaleInStorage`. Never cached on the server.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getLocaleInStorage: () => import('@intlayer/types').Locale | undefined;
|
|
2
9
|
/**
|
|
3
10
|
* Get the locale cookie
|
|
11
|
+
*
|
|
12
|
+
* Read once at import time; marked pure so bundlers drop the read when nothing
|
|
13
|
+
* imports it.
|
|
4
14
|
*/
|
|
5
|
-
export declare const localeInStorage: import('intlayer').Locale | undefined;
|
|
15
|
+
export declare const localeInStorage: import('@intlayer/types').Locale | undefined;
|
|
6
16
|
/**
|
|
7
17
|
* @deprecated Use localeInStorage instead
|
|
8
18
|
*
|
|
9
19
|
* Get the locale cookie
|
|
10
20
|
*/
|
|
11
|
-
export declare const localeCookie: import('intlayer').Locale | undefined;
|
|
21
|
+
export declare const localeCookie: import('@intlayer/types').Locale | undefined;
|
|
12
22
|
/**
|
|
13
23
|
* Set the locale cookie
|
|
14
24
|
*/
|
|
@@ -23,7 +33,7 @@ export declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: b
|
|
|
23
33
|
* Composable that provides the locale storage and a function to set it
|
|
24
34
|
*/
|
|
25
35
|
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
26
|
-
localeStorage: import('vue').ComputedRef<import('intlayer').Locale>;
|
|
36
|
+
localeStorage: import('vue').ComputedRef<import('@intlayer/types').Locale>;
|
|
27
37
|
setLocaleStorage: (locale: LocalesValues) => void;
|
|
28
38
|
};
|
|
29
39
|
/**
|
|
@@ -34,6 +44,6 @@ export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
34
44
|
* Composable that provides the locale cookie and a function to set it
|
|
35
45
|
*/
|
|
36
46
|
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
37
|
-
localeStorage: import('vue').ComputedRef<import('intlayer').Locale>;
|
|
47
|
+
localeStorage: import('vue').ComputedRef<import('@intlayer/types').Locale>;
|
|
38
48
|
setLocaleStorage: (locale: LocalesValues) => void;
|
|
39
49
|
};
|
|
@@ -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('intlayer').LocalesValues;
|
|
12
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
23
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
21
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
20
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
21
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
15
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
18
|
+
locale?: import('@intlayer/types').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('intlayer').LocalesValues;
|
|
17
|
+
locale?: import('@intlayer/types').LocalesValues;
|
|
18
18
|
}) | undefined) => string>;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -103,12 +103,12 @@
|
|
|
103
103
|
"typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@intlayer/api": "9.5.
|
|
107
|
-
"@intlayer/config": "9.5.
|
|
108
|
-
"@intlayer/core": "9.5.
|
|
109
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
110
|
-
"@intlayer/editor": "9.5.
|
|
111
|
-
"@intlayer/types": "9.5.
|
|
106
|
+
"@intlayer/api": "9.5.10",
|
|
107
|
+
"@intlayer/config": "9.5.10",
|
|
108
|
+
"@intlayer/core": "9.5.10",
|
|
109
|
+
"@intlayer/dictionaries-entry": "9.5.10",
|
|
110
|
+
"@intlayer/editor": "9.5.10",
|
|
111
|
+
"@intlayer/types": "9.5.10",
|
|
112
112
|
"@vue/devtools-api": "^6.6.4"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
@@ -122,13 +122,13 @@
|
|
|
122
122
|
"rimraf": "6.1.3",
|
|
123
123
|
"tsdown": "0.23.0",
|
|
124
124
|
"typescript": "7.0.2",
|
|
125
|
-
"vite": "8.3.
|
|
125
|
+
"vite": "8.3.1",
|
|
126
126
|
"vite-plugin-dts": "5.1.1",
|
|
127
|
-
"vitest": "5.0.
|
|
127
|
+
"vitest": "5.0.2",
|
|
128
128
|
"vue-tsc": "3.3.9"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
|
-
"intlayer": "9.5.
|
|
131
|
+
"intlayer": "9.5.10",
|
|
132
132
|
"vue": ">=3.0.0"
|
|
133
133
|
},
|
|
134
134
|
"peerDependenciesMeta": {
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
"optionalDependencies": {
|
|
140
|
-
"@intlayer/analytics": "9.5.
|
|
140
|
+
"@intlayer/analytics": "9.5.10"
|
|
141
141
|
},
|
|
142
142
|
"engines": {
|
|
143
143
|
"node": ">=14.18"
|