vue-intlayer 9.0.0-canary.8 → 9.0.0

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.
Files changed (33) hide show
  1. package/dist/cjs/analytics/exposureSink.cjs +1 -0
  2. package/dist/cjs/analytics/index.cjs +1 -0
  3. package/dist/cjs/analytics/useAnalytics.cjs +1 -0
  4. package/dist/cjs/analytics/useConversion.cjs +1 -0
  5. package/dist/cjs/analytics/useExperiment.cjs +1 -0
  6. package/dist/cjs/client/installIntlayer.cjs +1 -1
  7. package/dist/cjs/client/useIntlayer.cjs +1 -1
  8. package/dist/cjs/index.cjs +1 -1
  9. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -1
  10. package/dist/cjs/plugins.cjs +1 -1
  11. package/dist/esm/analytics/exposureSink.mjs +8 -0
  12. package/dist/esm/analytics/index.mjs +4 -0
  13. package/dist/esm/analytics/useAnalytics.mjs +47 -0
  14. package/dist/esm/analytics/useConversion.mjs +9 -0
  15. package/dist/esm/analytics/useExperiment.mjs +30 -0
  16. package/dist/esm/client/installIntlayer.mjs +2 -0
  17. package/dist/esm/client/useIntlayer.mjs +1 -1
  18. package/dist/esm/index.mjs +14 -10
  19. package/dist/esm/markdown/installIntlayerMarkdown.mjs +34 -27
  20. package/dist/esm/plugins.mjs +91 -80
  21. package/dist/esm-JsFWnEiY.mjs +202 -0
  22. package/dist/esm-kl1nXjmn.js +1 -0
  23. package/dist/isEnabled-B9hPiyif.js +1 -0
  24. package/dist/isEnabled-C5NavXyG.mjs +5 -0
  25. package/dist/types/analytics/exposureSink.d.ts +28 -0
  26. package/dist/types/analytics/index.d.ts +3 -0
  27. package/dist/types/analytics/useAnalytics.d.ts +11 -0
  28. package/dist/types/analytics/useConversion.d.ts +31 -0
  29. package/dist/types/analytics/useExperiment.d.ts +38 -0
  30. package/dist/types/html/HTMLRenderer.d.ts +9 -9
  31. package/dist/types/index.d.ts +1 -0
  32. package/dist/types/markdown/MarkdownRenderer.d.ts +9 -9
  33. package/package.json +19 -16
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=null,t=t=>{e=t},n=t=>{e?.(t)};exports.reportExposure=n,exports.setExposureSink=t;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useAnalytics.cjs"),t=require("./useConversion.cjs"),n=require("./useExperiment.cjs");exports.useAnalytics=e.useAnalytics,exports.useConversion=t.useConversion,exports.useExperiment=n.useExperiment;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exposureSink.cjs"),t=require("../../isEnabled-B9hPiyif.js"),n=require("../client/installIntlayer.cjs");let r=require("vue");var i=t=>{let n=null,i=!1,a=!1;return Promise.resolve().then(()=>require("../../esm-kl1nXjmn.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-kl1nXjmn.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;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../isEnabled-B9hPiyif.js");var t=()=>t=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-kl1nXjmn.js")).then(({getGlobalAnalyticsClient:e})=>{e()?.trackConversion(t)}).catch(()=>{})};exports.useConversion=t;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../isEnabled-B9hPiyif.js");let t=require("vue");var n=(n,r,i)=>{let a=(0,t.ref)(r[0]??``),o=(0,t.ref)(!1),s=!1,c=!1;return(0,t.onMounted)(()=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-kl1nXjmn.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-kl1nXjmn.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)=>{if(i)return i;(0,n.setIntlayerIdentifier)();let{defaultLocale:o}=t.internationalization??{},s=(0,e.ref)(r??o);return i={locale:(0,e.readonly)(s),setLocale:e=>{s.value=e},isCookieEnabled:a},i},o=(e,t)=>{let{locale:n,isCookieEnabled:i}=t??{},o=a(n,i);return e.provide(r,o),process.env.INTLAYER_EDITOR_ENABLED!==`false`&&Promise.resolve().then(()=>require("../editor/useEditor.cjs")).then(({useEditor:t})=>{t(e)}),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)=>{if(i)return i;(0,n.setIntlayerIdentifier)();let{defaultLocale:o}=t.internationalization??{},s=(0,e.ref)(r??o);return i={locale:(0,e.readonly)(s),setLocale:e=>{s.value=e},isCookieEnabled:a},i},o=(e,t)=>{let{locale:n,isCookieEnabled:i}=t??{},o=a(n,i);return e.provide(r,o),process.env.INTLAYER_EDITOR_ENABLED!==`false`&&Promise.resolve().then(()=>require("../editor/useEditor.cjs")).then(({useEditor:t})=>{t(e)}),process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&Promise.resolve().then(()=>require("../analytics/useAnalytics.cjs")).then(({useAnalytics:t})=>{t(e)}),e},s={install:o};exports.INTLAYER_SYMBOL=r,exports.createIntlayerClient=a,exports.installIntlayer=o,exports.intlayer=s;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./installIntlayer.cjs"),n=require("./useDictionary.cjs");let r=require("vue"),i=require("@intlayer/config/built");var a=(a,o)=>{let s=(0,r.inject)(t.INTLAYER_SYMBOL),c=(0,r.isRef)(s?.locale)?s.locale:(0,r.ref)(s?.locale??i.internationalization.defaultLocale),l=(0,r.computed)(()=>{let e=o===void 0?void 0:(0,r.toValue)(o);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&typeof e==`object`&&e){let t=e;return{selector:t,locale:t.locale}}return{selector:void 0,locale:e}}),u=(0,r.computed)(()=>l.value.locale??c.value),d=(0,r.shallowRef)({});(0,r.watch)([()=>(0,r.toValue)(a),()=>u.value,()=>l.value.selector],([t,n,r])=>{d.value=r?e.getIntlayer(t,{...r,locale:n}):e.getIntlayer(t,n)},{immediate:!0,flush:`sync`});let f=new Map,p=e=>{let t=e.join(`.`);if(f.has(t))return f.get(t);let i=(0,r.computed)(()=>n.atPath(d.value,e)),a=new Proxy({},{get(t,a,o){if(typeof a==`symbol`||typeof a==`string`&&(a.startsWith(`__`)||a.startsWith(`$`)))return a===`__v_isRef`?!0:a===`then`?void 0:Reflect.get(t,a,o);if(a===`value`)return i.value??``;if(a===`c`||a===`asComponent`)return n.toComponent(()=>i.value);if(a===`$raw`)return i;if(a===Symbol.toPrimitive)return()=>String(i.value??``);let s=e.concat(a),c=n.atPath(d.value,s);if(c===void 0||n.isObjectLike(c)&&!n.isComponentLike(c))return p(s);if(n.isIntlayerNode(c))return n.createIntlayerLeafProxy((0,r.computed)(()=>n.atPath(d.value,s)));let l=(0,r.computed)(()=>n.atPath(d.value,s));return new Proxy(l,{get(e,t,n){return t===`value`?e.value??``:t===`__v_isRef`?!0:Reflect.get(e,t,n)}})},ownKeys(){let t=n.atPath(d.value,e);return n.isObjectLike(t)?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return f.set(t,a),a};return p([])};exports.useIntlayer=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./installIntlayer.cjs"),n=require("./useDictionary.cjs");let r=require("vue"),i=require("@intlayer/config/built");var a=(a,o)=>{let s=(0,r.inject)(t.INTLAYER_SYMBOL),c=(0,r.isRef)(s?.locale)?s.locale:(0,r.ref)(s?.locale??i.internationalization.defaultLocale),l=(0,r.computed)(()=>{let e=o===void 0?void 0:(0,r.toValue)(o);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&typeof e==`object`&&e){let t=e;return{selector:t,locale:t.locale}}return{selector:void 0,locale:e}}),u=(0,r.computed)(()=>l.value.locale??c.value),d=(0,r.shallowRef)({});(0,r.watch)([()=>(0,r.toValue)(a),()=>u.value,()=>l.value.selector],([t,n,r])=>{d.value=r?e.getIntlayer(t,{...r,locale:n}):e.getIntlayer(t,n)},{immediate:!0,flush:`sync`});let f=new Map,p=e=>{let t=e.join(`.`);if(f.has(t))return f.get(t);let i=(0,r.computed)(()=>n.atPath(d.value,e)),a=new Proxy({},{get(t,a,o){if(typeof a==`symbol`||typeof a==`string`&&(a.startsWith(`__`)||a.startsWith(`$`)))return a===`__v_isRef`?!0:a===`then`?void 0:Reflect.get(t,a,o);if(a===`value`)return i.value??``;if(a===`c`||a===`asComponent`)return n.toComponent(()=>i.value);if(a===`$raw`)return i;if(a===Symbol.toPrimitive)return()=>String(i.value??``);let s=e.concat(a),c=n.atPath(d.value,s);if(c===void 0||n.isObjectLike(c)&&!n.isComponentLike(c))return p(s);if(n.isIntlayerNode(c))return n.createIntlayerLeafProxy((0,r.computed)(()=>n.atPath(d.value,s)));let l=(0,r.computed)(()=>n.atPath(d.value,s));return new Proxy(l,{get(e,t,n){return t===`value`?e.value??``:t===`__v_isRef`||Reflect.get(e,t,n)}})},ownKeys(){let t=n.atPath(d.value,e);return n.isObjectLike(t)?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return f.set(t,a),a};return p([])};exports.useIntlayer=a;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugins.cjs"),t=require("./getIntlayer.cjs"),n=require("./getDictionary.cjs"),r=require("./client/installIntlayer.cjs"),i=require("./client/useDictionary.cjs"),a=require("./client/useDictionaryAsync.cjs"),o=require("./client/useDictionaryDynamic.cjs"),s=require("./client/useIntlayer.cjs"),c=require("./client/useLoadDynamic.cjs"),l=require("./client/useLocale.cjs"),u=require("./client/usePathname.cjs"),d=require("./client/useRewriteURL.cjs");require("./client/index.cjs");const f=require("./editor/useEditor.cjs");exports.INTLAYER_SYMBOL=r.INTLAYER_SYMBOL,exports.atPath=i.atPath,exports.createIntlayerClient=r.createIntlayerClient,exports.createIntlayerLeafProxy=i.createIntlayerLeafProxy,exports.getDictionary=n.getDictionary,exports.getIntlayer=t.getIntlayer,exports.getPlugins=e.getPlugins,exports.htmlPlugin=e.htmlPlugin,exports.insertionPlugin=e.insertionPlugin,exports.installIntlayer=r.installIntlayer,exports.intlayer=r.intlayer,exports.intlayerNodePlugins=e.intlayerNodePlugins,exports.isComponentLike=i.isComponentLike,exports.isIntlayerNode=i.isIntlayerNode,exports.isObjectLike=i.isObjectLike,exports.markdownPlugin=e.markdownPlugin,exports.markdownStringPlugin=e.markdownStringPlugin,exports.toComponent=i.toComponent,exports.useDictionary=i.useDictionary,exports.useDictionaryAsync=a.useDictionaryAsync,exports.useDictionaryDynamic=o.useDictionaryDynamic,exports.useEditor=f.useEditor,exports.useIntlayer=s.useIntlayer,exports.useLoadDynamic=c.useLoadDynamic,exports.useLocale=l.useLocale,exports.usePathname=u.usePathname,exports.useRewriteURL=d.useRewriteURL;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./plugins.cjs"),t=require("./getIntlayer.cjs"),n=require("./getDictionary.cjs"),r=require("./client/installIntlayer.cjs"),i=require("./analytics/useAnalytics.cjs"),a=require("./analytics/useConversion.cjs"),o=require("./analytics/useExperiment.cjs");require("./analytics/index.cjs");const s=require("./client/useDictionary.cjs"),c=require("./client/useDictionaryAsync.cjs"),l=require("./client/useDictionaryDynamic.cjs"),u=require("./client/useIntlayer.cjs"),d=require("./client/useLoadDynamic.cjs"),f=require("./client/useLocale.cjs"),p=require("./client/usePathname.cjs"),m=require("./client/useRewriteURL.cjs");require("./client/index.cjs");const h=require("./editor/useEditor.cjs");exports.INTLAYER_SYMBOL=r.INTLAYER_SYMBOL,exports.atPath=s.atPath,exports.createIntlayerClient=r.createIntlayerClient,exports.createIntlayerLeafProxy=s.createIntlayerLeafProxy,exports.getDictionary=n.getDictionary,exports.getIntlayer=t.getIntlayer,exports.getPlugins=e.getPlugins,exports.htmlPlugin=e.htmlPlugin,exports.insertionPlugin=e.insertionPlugin,exports.installIntlayer=r.installIntlayer,exports.intlayer=r.intlayer,exports.intlayerNodePlugins=e.intlayerNodePlugins,exports.isComponentLike=s.isComponentLike,exports.isIntlayerNode=s.isIntlayerNode,exports.isObjectLike=s.isObjectLike,exports.markdownPlugin=e.markdownPlugin,exports.markdownStringPlugin=e.markdownStringPlugin,exports.toComponent=s.toComponent,exports.useAnalytics=i.useAnalytics,exports.useConversion=a.useConversion,exports.useDictionary=s.useDictionary,exports.useDictionaryAsync=c.useDictionaryAsync,exports.useDictionaryDynamic=l.useDictionaryDynamic,exports.useEditor=h.useEditor,exports.useExperiment=o.useExperiment,exports.useIntlayer=u.useIntlayer,exports.useLoadDynamic=d.useLoadDynamic,exports.useLocale=f.useLocale,exports.usePathname=p.usePathname,exports.useRewriteURL=m.useRewriteURL;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./compiler.cjs");let t=require("vue");var n=Symbol(`intlayerMarkdown`),r=null,i=(e,t)=>r||(r={components:t,renderMarkdown:e},r),a=(r,a)=>{let o,s;if(typeof a==`function`)o=a;else{let{components:t,wrapper:n,forceBlock:r,forceInline:i,preserveFrontmatter:c,tagfilter:l,renderMarkdown:u}=a??{};if(s=t,u)o=u;else{let a={components:t,forceBlock:r,forceInline:i,wrapper:n,forceWrapper:!!n,preserveFrontmatter:c,tagfilter:l};o=(t,n,r,i)=>e.compileMarkdown(t,{...a,forceBlock:n?.forceBlock??a.forceBlock,forceInline:n?.forceInline??a.forceInline,preserveFrontmatter:n?.preserveFrontmatter??a.preserveFrontmatter,tagfilter:n?.tagfilter??a.tagfilter,wrapper:i||a.wrapper,forceWrapper:!!(i||a.wrapper),components:{...a.components,...r??{}}})}}let c=i((e,r,i,s)=>typeof a==`function`||typeof a==`object`&&a?.renderMarkdown?{setup(){return(0,t.provide)(n,{renderMarkdown:void 0}),()=>o(e,r,i,s)}}:o(e,r,i,s),s);r.provide(n,c)},o={install:a},s=()=>{let e=(0,t.inject)(n,{renderMarkdown:e=>e});if(!e)throw Error(`useMarkdown must be used within a MarkdownProvider`);return e};exports.INTLAYER_MARKDOWN_SYMBOL=n,exports.createIntlayerMarkdownClient=i,exports.installIntlayerMarkdown=a,exports.intlayerMarkdown=o,exports.useMarkdown=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./compiler.cjs");let t=require("vue");var n=Symbol(`intlayerMarkdown`),r=e=>typeof e?.then==`function`,i=null,a=(e,t)=>i||(i={components:t,renderMarkdown:e},i),o=(i,o)=>{let s,c;if(typeof o==`function`)s=o;else{let{components:t,wrapper:n,forceBlock:r,forceInline:i,preserveFrontmatter:a,tagfilter:l,renderMarkdown:u}=o??{};if(c=t,u)s=u;else{let o={components:t,forceBlock:r,forceInline:i,wrapper:n,forceWrapper:!!n,preserveFrontmatter:a,tagfilter:l};s=(t,n,r,i)=>e.compileMarkdown(t,{...o,forceBlock:n?.forceBlock??o.forceBlock,forceInline:n?.forceInline??o.forceInline,preserveFrontmatter:n?.preserveFrontmatter??o.preserveFrontmatter,tagfilter:n?.tagfilter??o.tagfilter,wrapper:i||o.wrapper,forceWrapper:!!(i||o.wrapper),components:{...o.components,...r??{}}})}}let l=a((e,i,a,c)=>typeof o==`function`||typeof o==`object`&&o?.renderMarkdown?(0,t.h)({name:`IntlayerCustomMarkdown`,setup:()=>{(0,t.provide)(n,{renderMarkdown:void 0});let o=(0,t.shallowRef)(null),l=s(e,i,a,c);return r(l)?l.then(e=>{o.value=e}):o.value=l,()=>o.value}}):s(e,i,a,c),c);i.provide(n,l)},s={install:o},c=()=>{let e=(0,t.inject)(n,{renderMarkdown:e=>e});if(!e)throw Error(`useMarkdown must be used within a MarkdownProvider`);return e};exports.INTLAYER_MARKDOWN_SYMBOL=n,exports.createIntlayerMarkdownClient=a,exports.installIntlayerMarkdown=o,exports.intlayerMarkdown=s,exports.useMarkdown=c;
@@ -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,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./renderIntlayerNode.cjs"),l=require("./html/HTMLRenderer.cjs"),u=require("./markdown/installIntlayerMarkdown.cjs");let d=require("vue"),f=require("@intlayer/core/interpreter"),p=require("@intlayer/config/built"),m=require("@intlayer/core/markdown"),h=require("@intlayer/types/nodeType");h=s(h);var g=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,d.defineAsyncComponent)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs"))),_={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:t,...n})=>{let r=e=>c.renderIntlayerNode({...n,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?()=>(0,d.h)(g,{dictionaryKey:n.dictionaryKey,keyPath:n.keyPath},{default:()=>typeof e==`function`?e():e}):e}),i=r(t);if(typeof t!=`function`)return i;let a=(...e)=>r(t(...e));Object.setPrototypeOf(a,Object.getPrototypeOf(i));for(let e of Object.getOwnPropertyNames(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}for(let e of Object.getOwnPropertySymbols(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}return(0,d.markRaw)(a)}},v=(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,d.h)(d.Fragment,null,...e)}else 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,d.h)(d.Fragment,null,...e)}return i.isSimple?i.parts:(0,d.h)(d.Fragment,null,i.parts)},y=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`,transform:(e,n,r)=>{let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=v(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},b=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)=>c.renderIntlayerNode({...n,value:t,children:e})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>c.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,d.h)(g,{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},{default:()=>a}):a},additionalProps:{metadata:a,use:e=>o(e)}});return o()}},x=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:[b,...t.plugins??[]]})}},S=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 c.renderIntlayerNode({...t,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?()=>(0,d.h)(g,{dictionaryKey:t.dictionaryKey,keyPath:t.keyPath,...e},{default:()=>i}):i,additionalProps:{use:e=>r(e)}})};return r()}},C=new Map,w=(e,t=!0)=>{let n=`${e??p.internationalization.defaultLocale}_${t}`;if(C.has(n))return C.get(n);let r=[(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,_,y,x,S];return C.set(n,r),r};exports.getPlugins=w,exports.htmlPlugin=S,exports.insertionPlugin=y,exports.intlayerNodePlugins=_,exports.markdownPlugin=x,exports.markdownStringPlugin=b;
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,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./renderIntlayerNode.cjs"),l=require("./analytics/exposureSink.cjs"),u=require("./html/HTMLRenderer.cjs"),d=require("./markdown/installIntlayerMarkdown.cjs");let f=require("vue"),p=require("@intlayer/core/interpreter"),m=require("@intlayer/config/built"),h=require("@intlayer/core/markdown"),g=require("@intlayer/types/nodeType");g=s(g);var _=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,f.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:t,...n})=>{process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&l.reportExposure({dictionaryKey:n.dictionaryKey,keyPath:n.keyPath,locale:n.locale,nodeType:`text`});let r=e=>c.renderIntlayerNode({...n,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&m.editor.enabled?()=>(0,f.h)(_,{dictionaryKey:n.dictionaryKey,keyPath:n.keyPath},{default:()=>typeof e==`function`?e():e}):e}),i=r(t);if(typeof t!=`function`)return i;let a=(...e)=>{let n=t(...e);return r(n)};Object.setPrototypeOf(a,Object.getPrototypeOf(i));for(let e of Object.getOwnPropertyNames(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}for(let e of Object.getOwnPropertySymbols(i)){let t=Object.getOwnPropertyDescriptor(i,e);t&&Object.defineProperty(a,e,t)}return(0,f.markRaw)(a)}},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,p.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,f.h)(f.Fragment,null,...e)}else 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,f.h)(f.Fragment,null,...e)}return i.isSimple?i.parts:(0,f.h)(f.Fragment,null,i.parts)},b=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?p.fallbackPlugin:{id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.INSERTION,transform:(e,t,n)=>{let r=[...t.keyPath,{type:g.INSERTION}],i=e[g.INSERTION],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`||(0,p.isInterpolableWrapperNode)(e),transform:(e,n,r)=>{if((0,p.isInterpolableWrapperNode)(e))return i=>(0,p.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})}}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}},x=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?p.fallbackPlugin:{id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,t,n)=>{let{plugins:r,...i}=t,a=n((0,h.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>c.renderIntlayerNode({...n,value:t,children:e})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>c.renderIntlayerNode({...t,value:e,children:()=>{let{renderMarkdown:t,components:r}=d.useMarkdown(),a=t(e,void 0,{...r??{},...n??{}});return process.env.INTLAYER_EDITOR_ENABLED!==`false`&&m.editor.enabled?(0,f.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`?p.fallbackPlugin:{id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.MARKDOWN,transform:(e,t,n)=>{let r=[...t.keyPath,{type:g.MARKDOWN}],i=e[g.MARKDOWN];return n(i,{...t,children:i,keyPath:r,plugins:[x,...t.plugins??[]]})}},C=process.env.INTLAYER_NODE_TYPE_HTML===`false`?p.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.HTML,transform:(e,t)=>{let n=e[g.HTML];e.tags;let r=(e={})=>{let i=u.renderHTML(n,{components:e});return c.renderIntlayerNode({...t,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&m.editor.enabled?()=>(0,f.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??m.internationalization.defaultLocale}_${t}`;if(w.has(n))return w.get(n);let r=[(0,p.translationPlugin)(e??m.internationalization.defaultLocale,t?m.internationalization.defaultLocale:void 0),p.enumerationPlugin,(0,p.pluralPlugin)(e??m.internationalization.defaultLocale),p.conditionPlugin,(0,p.nestedPlugin)(e??m.internationalization.defaultLocale),p.filePlugin,p.genderPlugin,v,b,S,C];return w.set(n,r),r};exports.getPlugins=T,exports.htmlPlugin=C,exports.insertionPlugin=b,exports.intlayerNodePlugins=v,exports.markdownPlugin=S,exports.markdownStringPlugin=x;
@@ -0,0 +1,8 @@
1
+ //#region src/analytics/exposureSink.ts
2
+ var e = null, t = (t) => {
3
+ e = t;
4
+ }, n = (t) => {
5
+ e?.(t);
6
+ };
7
+ //#endregion
8
+ export { n as reportExposure, t as setExposureSink };
@@ -0,0 +1,4 @@
1
+ import { useAnalytics as e } from "./useAnalytics.mjs";
2
+ import { useConversion as t } from "./useConversion.mjs";
3
+ import { useExperiment as n } from "./useExperiment.mjs";
4
+ export { e as useAnalytics, t as useConversion, n as useExperiment };
@@ -0,0 +1,47 @@
1
+ import { setExposureSink as e } from "./exposureSink.mjs";
2
+ import { t } from "../../isEnabled-C5NavXyG.mjs";
3
+ import { INTLAYER_SYMBOL as n } from "../client/installIntlayer.mjs";
4
+ import { inject as r, onMounted as i, onUnmounted as a, watch as o } from "vue";
5
+ //#region src/analytics/useAnalytics.ts
6
+ var s = (t) => {
7
+ let n = null, r = !1, i = !1;
8
+ return import("../../esm-JsFWnEiY.mjs").then(({ initAnalyticsClient: a, buildContentExposure: s }) => {
9
+ if (r) return;
10
+ let c = a();
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
+ e && (c.setLocale(e), c.trackPageView({ reason: "locale_change" }));
13
+ }));
14
+ }).catch(() => {}), () => {
15
+ r = !0, n?.(), e(null), import("../../esm-JsFWnEiY.mjs").then(({ stopAnalyticsClient: e }) => {
16
+ i && e();
17
+ }).catch(() => {});
18
+ };
19
+ }, c = (e) => {
20
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !t) return;
21
+ if (e) {
22
+ let t = null;
23
+ e.mixin({
24
+ inject: { _intlayerClient: {
25
+ from: n,
26
+ default: null
27
+ } },
28
+ mounted() {
29
+ if (this.$parent !== null) return;
30
+ let e = this._intlayerClient;
31
+ t = s(e?.locale);
32
+ },
33
+ unmounted() {
34
+ this.$parent === null && t?.();
35
+ }
36
+ });
37
+ return;
38
+ }
39
+ let o = r(n), c = null;
40
+ i(() => {
41
+ c = s(o?.locale);
42
+ }), a(() => {
43
+ c?.();
44
+ });
45
+ };
46
+ //#endregion
47
+ export { c as useAnalytics };
@@ -0,0 +1,9 @@
1
+ import { t as e } from "../../isEnabled-C5NavXyG.mjs";
2
+ //#region src/analytics/useConversion.ts
3
+ var t = () => (t) => {
4
+ process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-JsFWnEiY.mjs").then(({ getGlobalAnalyticsClient: e }) => {
5
+ e()?.trackConversion(t);
6
+ }).catch(() => {});
7
+ };
8
+ //#endregion
9
+ export { t as useConversion };
@@ -0,0 +1,30 @@
1
+ import { t as e } from "../../isEnabled-C5NavXyG.mjs";
2
+ import { onMounted as t, onUnmounted as n, ref as r } from "vue";
3
+ //#region src/analytics/useExperiment.ts
4
+ var i = (i, a, o) => {
5
+ let s = r(a[0] ?? ""), c = r(!1), l = !1, u = !1;
6
+ return t(() => {
7
+ process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-JsFWnEiY.mjs").then(({ initAnalyticsClient: e }) => {
8
+ if (l) return;
9
+ let t = e();
10
+ u = !0;
11
+ let n = t.getVariant(i, a, o);
12
+ s.value = n, c.value = !0, t.trackContentExposure({
13
+ dictionaryKey: i,
14
+ keyPath: "",
15
+ nodeType: "experiment",
16
+ experimentKey: i,
17
+ variant: n
18
+ });
19
+ }).catch(() => {});
20
+ }), n(() => {
21
+ l = !0, import("../../esm-JsFWnEiY.mjs").then(({ stopAnalyticsClient: e }) => {
22
+ u && e();
23
+ }).catch(() => {});
24
+ }), {
25
+ variant: s,
26
+ isAssigned: c
27
+ };
28
+ };
29
+ //#endregion
30
+ export { i as useExperiment };
@@ -17,6 +17,8 @@ var i = Symbol("intlayer"), a = null, o = (i, o = !0) => {
17
17
  let { locale: n, isCookieEnabled: r } = t ?? {}, a = o(n, r);
18
18
  return e.provide(i, a), process.env.INTLAYER_EDITOR_ENABLED !== "false" && import("../editor/useEditor.mjs").then(({ useEditor: t }) => {
19
19
  t(e);
20
+ }), process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && import("../analytics/useAnalytics.mjs").then(({ useAnalytics: t }) => {
21
+ t(e);
20
22
  }), e;
21
23
  }, c = { install: s };
22
24
  //#endregion
@@ -47,7 +47,7 @@ var g = (g, _) => {
47
47
  if (a(p)) return r(c(() => n(S.value, f)));
48
48
  let m = c(() => n(S.value, f));
49
49
  return new Proxy(m, { get(e, t, n) {
50
- return t === "value" ? e.value ?? "" : t === "__v_isRef" ? !0 : Reflect.get(e, t, n);
50
+ return t === "value" ? e.value ?? "" : t === "__v_isRef" || Reflect.get(e, t, n);
51
51
  } });
52
52
  },
53
53
  ownKeys() {
@@ -2,14 +2,18 @@ import { getPlugins as e, htmlPlugin as t, insertionPlugin as n, intlayerNodePlu
2
2
  import { getIntlayer as o } from "./getIntlayer.mjs";
3
3
  import { getDictionary as s } from "./getDictionary.mjs";
4
4
  import { INTLAYER_SYMBOL as c, createIntlayerClient as l, installIntlayer as u, intlayer as d } from "./client/installIntlayer.mjs";
5
- import { atPath as f, createIntlayerLeafProxy as p, isComponentLike as m, isIntlayerNode as h, isObjectLike as g, toComponent as _, useDictionary as v } from "./client/useDictionary.mjs";
6
- import { useDictionaryAsync as y } from "./client/useDictionaryAsync.mjs";
7
- import { useDictionaryDynamic as b } from "./client/useDictionaryDynamic.mjs";
8
- import { useIntlayer as x } from "./client/useIntlayer.mjs";
9
- import { useLoadDynamic as S } from "./client/useLoadDynamic.mjs";
10
- import { useLocale as C } from "./client/useLocale.mjs";
11
- import { usePathname as w } from "./client/usePathname.mjs";
12
- import { useRewriteURL as T } from "./client/useRewriteURL.mjs";
5
+ import { useAnalytics as f } from "./analytics/useAnalytics.mjs";
6
+ import { useConversion as p } from "./analytics/useConversion.mjs";
7
+ import { useExperiment as m } from "./analytics/useExperiment.mjs";
8
+ import "./analytics/index.mjs";
9
+ import { atPath as h, createIntlayerLeafProxy as g, isComponentLike as _, isIntlayerNode as v, isObjectLike as y, toComponent as b, useDictionary as x } from "./client/useDictionary.mjs";
10
+ import { useDictionaryAsync as S } from "./client/useDictionaryAsync.mjs";
11
+ import { useDictionaryDynamic as C } from "./client/useDictionaryDynamic.mjs";
12
+ import { useIntlayer as w } from "./client/useIntlayer.mjs";
13
+ import { useLoadDynamic as T } from "./client/useLoadDynamic.mjs";
14
+ import { useLocale as E } from "./client/useLocale.mjs";
15
+ import { usePathname as D } from "./client/usePathname.mjs";
16
+ import { useRewriteURL as O } from "./client/useRewriteURL.mjs";
13
17
  import "./client/index.mjs";
14
- import { useEditor as E } from "./editor/useEditor.mjs";
15
- export { c as INTLAYER_SYMBOL, f as atPath, l as createIntlayerClient, p as createIntlayerLeafProxy, s as getDictionary, o as getIntlayer, e as getPlugins, t as htmlPlugin, n as insertionPlugin, u as installIntlayer, d as intlayer, r as intlayerNodePlugins, m as isComponentLike, h as isIntlayerNode, g as isObjectLike, i as markdownPlugin, a as markdownStringPlugin, _ as toComponent, v as useDictionary, y as useDictionaryAsync, b as useDictionaryDynamic, E as useEditor, x as useIntlayer, S as useLoadDynamic, C as useLocale, w as usePathname, T as useRewriteURL };
18
+ import { useEditor as k } from "./editor/useEditor.mjs";
19
+ export { c as INTLAYER_SYMBOL, h as atPath, l as createIntlayerClient, g as createIntlayerLeafProxy, s as getDictionary, o as getIntlayer, e as getPlugins, t as htmlPlugin, n as insertionPlugin, u as installIntlayer, d as intlayer, r as intlayerNodePlugins, _ as isComponentLike, v as isIntlayerNode, y as isObjectLike, i as markdownPlugin, a as markdownStringPlugin, b as toComponent, f as useAnalytics, p as useConversion, x as useDictionary, S as useDictionaryAsync, C as useDictionaryDynamic, k as useEditor, m as useExperiment, w as useIntlayer, T as useLoadDynamic, E as useLocale, D as usePathname, O as useRewriteURL };
@@ -1,48 +1,55 @@
1
1
  import { compileMarkdown as e } from "./compiler.mjs";
2
- import { inject as t, provide as n } from "vue";
2
+ import { h as t, inject as n, provide as r, shallowRef as i } from "vue";
3
3
  //#region src/markdown/installIntlayerMarkdown.ts
4
- var r = Symbol("intlayerMarkdown"), i = null, a = (e, t) => i || (i = {
4
+ var a = Symbol("intlayerMarkdown"), o = (e) => typeof e?.then == "function", s = null, c = (e, t) => s || (s = {
5
5
  components: t,
6
6
  renderMarkdown: e
7
- }, i), o = (t, i) => {
8
- let o, s;
9
- if (typeof i == "function") o = i;
7
+ }, s), l = (n, s) => {
8
+ let l, u;
9
+ if (typeof s == "function") l = s;
10
10
  else {
11
- let { components: t, wrapper: n, forceBlock: r, forceInline: a, preserveFrontmatter: c, tagfilter: l, renderMarkdown: u } = i ?? {};
12
- if (s = t, u) o = u;
11
+ let { components: t, wrapper: n, forceBlock: r, forceInline: i, preserveFrontmatter: a, tagfilter: o, renderMarkdown: c } = s ?? {};
12
+ if (u = t, c) l = c;
13
13
  else {
14
- let i = {
14
+ let s = {
15
15
  components: t,
16
16
  forceBlock: r,
17
- forceInline: a,
17
+ forceInline: i,
18
18
  wrapper: n,
19
19
  forceWrapper: !!n,
20
- preserveFrontmatter: c,
21
- tagfilter: l
20
+ preserveFrontmatter: a,
21
+ tagfilter: o
22
22
  };
23
- o = (t, n, r, a) => e(t, {
24
- ...i,
25
- forceBlock: n?.forceBlock ?? i.forceBlock,
26
- forceInline: n?.forceInline ?? i.forceInline,
27
- preserveFrontmatter: n?.preserveFrontmatter ?? i.preserveFrontmatter,
28
- tagfilter: n?.tagfilter ?? i.tagfilter,
29
- wrapper: a || i.wrapper,
30
- forceWrapper: !!(a || i.wrapper),
23
+ l = (t, n, r, i) => e(t, {
24
+ ...s,
25
+ forceBlock: n?.forceBlock ?? s.forceBlock,
26
+ forceInline: n?.forceInline ?? s.forceInline,
27
+ preserveFrontmatter: n?.preserveFrontmatter ?? s.preserveFrontmatter,
28
+ tagfilter: n?.tagfilter ?? s.tagfilter,
29
+ wrapper: i || s.wrapper,
30
+ forceWrapper: !!(i || s.wrapper),
31
31
  components: {
32
- ...i.components,
32
+ ...s.components,
33
33
  ...r ?? {}
34
34
  }
35
35
  });
36
36
  }
37
37
  }
38
- let c = a((e, t, a, s) => typeof i == "function" || typeof i == "object" && i?.renderMarkdown ? { setup() {
39
- return n(r, { renderMarkdown: void 0 }), () => o(e, t, a, s);
40
- } } : o(e, t, a, s), s);
41
- t.provide(r, c);
42
- }, s = { install: o }, c = () => {
43
- let e = t(r, { renderMarkdown: (e) => e });
38
+ let d = c((e, n, c, u) => typeof s == "function" || typeof s == "object" && s?.renderMarkdown ? t({
39
+ name: "IntlayerCustomMarkdown",
40
+ setup: () => {
41
+ r(a, { renderMarkdown: void 0 });
42
+ let t = i(null), s = l(e, n, c, u);
43
+ return o(s) ? s.then((e) => {
44
+ t.value = e;
45
+ }) : t.value = s, () => t.value;
46
+ }
47
+ }) : l(e, n, c, u), u);
48
+ n.provide(a, d);
49
+ }, u = { install: l }, d = () => {
50
+ let e = n(a, { renderMarkdown: (e) => e });
44
51
  if (!e) throw Error("useMarkdown must be used within a MarkdownProvider");
45
52
  return e;
46
53
  };
47
54
  //#endregion
48
- export { r as INTLAYER_MARKDOWN_SYMBOL, a as createIntlayerMarkdownClient, o as installIntlayerMarkdown, s as intlayerMarkdown, c as useMarkdown };
55
+ export { a as INTLAYER_MARKDOWN_SYMBOL, c as createIntlayerMarkdownClient, l as installIntlayerMarkdown, u as intlayerMarkdown, d as useMarkdown };
@@ -1,51 +1,61 @@
1
1
  import { renderIntlayerNode as e } from "./renderIntlayerNode.mjs";
2
- import { renderHTML as t } from "./html/HTMLRenderer.mjs";
3
- import { useMarkdown as n } from "./markdown/installIntlayerMarkdown.mjs";
4
- import { Fragment as r, defineAsyncComponent as i, h as a, markRaw as o } from "vue";
5
- import { conditionPlugin as s, enumerationPlugin as c, fallbackPlugin as l, filePlugin as u, genderPlugin as d, nestedPlugin as f, pluralPlugin as p, splitInsertionTemplate as m, translationPlugin as h } from "@intlayer/core/interpreter";
6
- import { editor as g, internationalization as _ } from "@intlayer/config/built";
7
- import { getMarkdownMetadata as v } from "@intlayer/core/markdown";
8
- import * as y from "@intlayer/types/nodeType";
2
+ import { reportExposure as t } from "./analytics/exposureSink.mjs";
3
+ import { renderHTML as n } from "./html/HTMLRenderer.mjs";
4
+ import { useMarkdown as r } from "./markdown/installIntlayerMarkdown.mjs";
5
+ import { Fragment as i, defineAsyncComponent as a, h as o, markRaw as s } from "vue";
6
+ import { conditionPlugin as c, enumerationPlugin as l, fallbackPlugin as u, filePlugin as d, genderPlugin as f, isInterpolableWrapperNode as p, nestedPlugin as m, pluralPlugin as h, splitInsertionTemplate as g, transformInterpolableNode as _, translationPlugin as v } from "@intlayer/core/interpreter";
7
+ import { editor as y, internationalization as b } from "@intlayer/config/built";
8
+ import { getMarkdownMetadata as x } from "@intlayer/core/markdown";
9
+ import * as S from "@intlayer/types/nodeType";
9
10
  //#region src/plugins.ts
10
- var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : i(() => import("./editor/ContentSelector.mjs")), x = {
11
+ var C = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : a(() => import("./editor/ContentSelector.mjs")), w = {
11
12
  id: "intlayer-node-plugin",
12
13
  canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
13
- transform: (t, { children: n, ...r }) => {
14
- let i = (t) => e({
15
- ...r,
14
+ transform: (n, { children: r, ...i }) => {
15
+ process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && t({
16
+ dictionaryKey: i.dictionaryKey,
17
+ keyPath: i.keyPath,
18
+ locale: i.locale,
19
+ nodeType: "text"
20
+ });
21
+ let a = (t) => e({
22
+ ...i,
16
23
  value: t,
17
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && g.enabled ? () => a(b, {
18
- dictionaryKey: r.dictionaryKey,
19
- keyPath: r.keyPath
24
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && y.enabled ? () => o(C, {
25
+ dictionaryKey: i.dictionaryKey,
26
+ keyPath: i.keyPath
20
27
  }, { default: () => typeof t == "function" ? t() : t }) : t
21
- }), s = i(n);
22
- if (typeof n != "function") return s;
23
- let c = (...e) => i(n(...e));
24
- Object.setPrototypeOf(c, Object.getPrototypeOf(s));
25
- for (let e of Object.getOwnPropertyNames(s)) {
26
- let t = Object.getOwnPropertyDescriptor(s, e);
27
- t && Object.defineProperty(c, e, t);
28
+ }), c = a(r);
29
+ if (typeof r != "function") return c;
30
+ let l = (...e) => {
31
+ let t = r(...e);
32
+ return a(t);
33
+ };
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);
28
38
  }
29
- for (let e of Object.getOwnPropertySymbols(s)) {
30
- let t = Object.getOwnPropertyDescriptor(s, e);
31
- t && Object.defineProperty(c, e, t);
39
+ for (let e of Object.getOwnPropertySymbols(c)) {
40
+ let t = Object.getOwnPropertyDescriptor(c, e);
41
+ t && Object.defineProperty(l, e, t);
32
42
  }
33
- return o(c);
43
+ return s(l);
34
44
  }
35
- }, S = (e, t) => {
36
- let n = /* @__PURE__ */ new Map(), i = {};
37
- for (let [e, r] of Object.entries(t)) typeof r == "string" || typeof r == "number" ? i[e] = r : (n.set(e, r), i[e] = `__VNODE_${e}__`);
38
- let o = m(e, i);
45
+ }, T = (e, t) => {
46
+ let n = /* @__PURE__ */ new Map(), r = {};
47
+ 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}__`);
48
+ let a = g(e, r);
39
49
  if (n.size > 0) {
40
50
  let e = [];
41
- if (o.isSimple) {
42
- let t = o.parts, i = 0;
43
- for (let [r] of n) {
44
- let a = `__VNODE_${r}__`, o = t.indexOf(a);
45
- o !== -1 && (o > i && e.push(t.substring(i, o)), e.push(n.get(r)), i = o + a.length);
51
+ if (a.isSimple) {
52
+ let t = a.parts, r = 0;
53
+ for (let [i] of n) {
54
+ let a = `__VNODE_${i}__`, o = t.indexOf(a);
55
+ o !== -1 && (o > r && e.push(t.substring(r, o)), e.push(n.get(i)), r = o + a.length);
46
56
  }
47
- return i < t.length && e.push(t.substring(i)), a(r, null, ...e);
48
- } else return o.parts.forEach((t) => {
57
+ return r < t.length && e.push(t.substring(r)), o(i, null, ...e);
58
+ } else return a.parts.forEach((t) => {
49
59
  if (typeof t == "string") {
50
60
  let r = t;
51
61
  for (let [t] of n) {
@@ -54,24 +64,25 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : i(() => import(
54
64
  }
55
65
  r.length > 0 && e.push(r);
56
66
  } else e.push(t);
57
- }), a(r, null, ...e);
67
+ }), o(i, null, ...e);
58
68
  }
59
- return o.isSimple ? o.parts : a(r, null, o.parts);
60
- }, C = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? l : {
69
+ return a.isSimple ? a.parts : o(i, null, a.parts);
70
+ }, E = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? u : {
61
71
  id: "insertion-plugin",
62
- canHandle: (e) => typeof e == "object" && e?.nodeType === y.INSERTION,
72
+ canHandle: (e) => typeof e == "object" && e?.nodeType === S.INSERTION,
63
73
  transform: (e, t, n) => {
64
- let r = [...t.keyPath, { type: y.INSERTION }], i = e[y.INSERTION], a = {
74
+ let r = [...t.keyPath, { type: S.INSERTION }], i = e[S.INSERTION], a = {
65
75
  id: "insertion-string-plugin",
66
- canHandle: (e) => typeof e == "string",
76
+ canHandle: (e) => typeof e == "string" || p(e),
67
77
  transform: (e, n, r) => {
78
+ if (p(e)) return (i) => _(e, i, n, t.plugins, r);
68
79
  let i = r(e, {
69
80
  ...n,
70
81
  children: e,
71
82
  plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
72
83
  });
73
84
  return (e) => {
74
- let a = S(i, e);
85
+ let a = T(i, e);
75
86
  return r(a, {
76
87
  ...n,
77
88
  plugins: t.plugins,
@@ -87,11 +98,11 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : i(() => import(
87
98
  plugins: [a, ...t.plugins ?? []]
88
99
  });
89
100
  }
90
- }, w = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
101
+ }, D = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? u : {
91
102
  id: "markdown-string-plugin",
92
103
  canHandle: (e) => typeof e == "string",
93
- transform: (t, r, i) => {
94
- let { plugins: o, ...s } = r, c = i(v(t) ?? {}, {
104
+ transform: (t, n, i) => {
105
+ let { plugins: a, ...s } = n, c = i(x(t) ?? {}, {
95
106
  plugins: [{
96
107
  id: "markdown-metadata-plugin",
97
108
  canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
@@ -104,17 +115,17 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : i(() => import(
104
115
  dictionaryKey: s.dictionaryKey,
105
116
  keyPath: []
106
117
  }), l = (i) => e({
107
- ...r,
118
+ ...n,
108
119
  value: t,
109
120
  children: () => {
110
- let { renderMarkdown: e, components: r } = n(), o = e(t, void 0, {
111
- ...r ?? {},
121
+ let { renderMarkdown: e, components: n } = r(), a = e(t, void 0, {
122
+ ...n ?? {},
112
123
  ...i ?? {}
113
124
  });
114
- return process.env.INTLAYER_EDITOR_ENABLED !== "false" && g.enabled ? a(b, {
125
+ return process.env.INTLAYER_EDITOR_ENABLED !== "false" && y.enabled ? o(C, {
115
126
  dictionaryKey: s.dictionaryKey,
116
127
  keyPath: s.keyPath
117
- }, { default: () => o }) : o;
128
+ }, { default: () => a }) : a;
118
129
  },
119
130
  additionalProps: {
120
131
  metadata: c,
@@ -123,56 +134,56 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : i(() => import(
123
134
  });
124
135
  return l();
125
136
  }
126
- }, T = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
137
+ }, O = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? u : {
127
138
  id: "markdown-plugin",
128
- canHandle: (e) => typeof e == "object" && e?.nodeType === y.MARKDOWN,
139
+ canHandle: (e) => typeof e == "object" && e?.nodeType === S.MARKDOWN,
129
140
  transform: (e, t, n) => {
130
- let r = [...t.keyPath, { type: y.MARKDOWN }], i = e[y.MARKDOWN];
141
+ let r = [...t.keyPath, { type: S.MARKDOWN }], i = e[S.MARKDOWN];
131
142
  return n(i, {
132
143
  ...t,
133
144
  children: i,
134
145
  keyPath: r,
135
- plugins: [w, ...t.plugins ?? []]
146
+ plugins: [D, ...t.plugins ?? []]
136
147
  });
137
148
  }
138
- }, E = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? l : {
149
+ }, k = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? u : {
139
150
  id: "html-plugin",
140
- canHandle: (e) => typeof e == "object" && e?.nodeType === y.HTML,
141
- transform: (n, r) => {
142
- let i = n[y.HTML];
143
- n.tags;
144
- let o = (n = {}) => {
145
- let s = t(i, { components: n });
151
+ canHandle: (e) => typeof e == "object" && e?.nodeType === S.HTML,
152
+ transform: (t, r) => {
153
+ let i = t[S.HTML];
154
+ t.tags;
155
+ let a = (t = {}) => {
156
+ let s = n(i, { components: t });
146
157
  return e({
147
158
  ...r,
148
159
  value: i,
149
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && g.enabled ? () => a(b, {
160
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && y.enabled ? () => o(C, {
150
161
  dictionaryKey: r.dictionaryKey,
151
162
  keyPath: r.keyPath,
152
- ...n
163
+ ...t
153
164
  }, { default: () => s }) : s,
154
- additionalProps: { use: (e) => o(e) }
165
+ additionalProps: { use: (e) => a(e) }
155
166
  });
156
167
  };
157
- return o();
168
+ return a();
158
169
  }
159
- }, D = /* @__PURE__ */ new Map(), O = (e, t = !0) => {
160
- let n = `${e ?? _.defaultLocale}_${t}`;
161
- if (D.has(n)) return D.get(n);
170
+ }, A = /* @__PURE__ */ new Map(), j = (e, t = !0) => {
171
+ let n = `${e ?? b.defaultLocale}_${t}`;
172
+ if (A.has(n)) return A.get(n);
162
173
  let r = [
163
- h(e ?? _.defaultLocale, t ? _.defaultLocale : void 0),
174
+ v(e ?? b.defaultLocale, t ? b.defaultLocale : void 0),
175
+ l,
176
+ h(e ?? b.defaultLocale),
164
177
  c,
165
- p(e ?? _.defaultLocale),
166
- s,
167
- f(e ?? _.defaultLocale),
168
- u,
178
+ m(e ?? b.defaultLocale),
169
179
  d,
170
- x,
171
- C,
172
- T,
173
- E
180
+ f,
181
+ w,
182
+ E,
183
+ O,
184
+ k
174
185
  ];
175
- return D.set(n, r), r;
186
+ return A.set(n, r), r;
176
187
  };
177
188
  //#endregion
178
- export { O as getPlugins, E as htmlPlugin, C as insertionPlugin, x as intlayerNodePlugins, T as markdownPlugin, w as markdownStringPlugin };
189
+ export { j as getPlugins, k as htmlPlugin, E as insertionPlugin, w as intlayerNodePlugins, O as markdownPlugin, D as markdownStringPlugin };
@@ -0,0 +1,202 @@
1
+ import { analytics as e, editor as t } from "@intlayer/config/built";
2
+ //#region ../@intlayer/analytics/dist/esm/utils/hash.mjs
3
+ var n = (e) => {
4
+ let t = 2166136261;
5
+ for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
6
+ return t >>> 0;
7
+ }, r = (e, t, r, i) => {
8
+ if (r.length === 0) throw Error("assignVariant requires at least one variant");
9
+ if (r.length === 1) return r[0];
10
+ let a = n(`${e}:${t}`) / 4294967296;
11
+ if (!i || i.length !== r.length) {
12
+ let e = Math.floor(a * r.length);
13
+ return r[Math.min(e, r.length - 1)];
14
+ }
15
+ let o = i.reduce((e, t) => e + t, 0);
16
+ if (o <= 0) return r[Math.floor(a * r.length)];
17
+ let s = 0, c = a * o;
18
+ for (let e = 0; e < r.length; e++) if (s += i[e], c < s) return r[e];
19
+ return r[r.length - 1];
20
+ }, i = "", a = (e) => [
21
+ e.url,
22
+ e.dictionaryKey,
23
+ e.keyPath,
24
+ e.locale,
25
+ e.experimentKey ?? "",
26
+ e.variant ?? ""
27
+ ].join(i), o = ({ max: e }) => {
28
+ let t = [], n = /* @__PURE__ */ new Map(), r = () => t.length + n.size, i = () => {
29
+ for (; r() > e && n.size > 0;) {
30
+ let e = n.keys().next().value;
31
+ n.delete(e);
32
+ }
33
+ r() > e && (t = t.slice(r() - e));
34
+ };
35
+ return {
36
+ push: (e) => {
37
+ if (e.type === "content_exposure") {
38
+ let t = a(e), r = n.get(t);
39
+ r ? (r.count = (r.count ?? 1) + (e.count ?? 1), r.t = e.t) : n.set(t, {
40
+ ...e,
41
+ count: e.count ?? 1
42
+ });
43
+ } else t.push(e);
44
+ return i(), r();
45
+ },
46
+ drain: () => {
47
+ let e = [...t, ...n.values()];
48
+ return t = [], n.clear(), e;
49
+ },
50
+ size: r
51
+ };
52
+ }, s = (e, t) => t >= 1 ? !0 : t <= 0 ? !1 : n(e) / 4294967295 < t, c = "__intlayer_analytics_sid__", l = () => {
53
+ let e = typeof globalThis < "u" ? globalThis.crypto : void 0;
54
+ return e?.randomUUID ? e.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
55
+ }, u = () => {
56
+ if (typeof window > "u" || !window.sessionStorage) return l();
57
+ try {
58
+ let e = window.sessionStorage.getItem(c);
59
+ if (e) return e;
60
+ let t = l();
61
+ return window.sessionStorage.setItem(c, t), t;
62
+ } catch {
63
+ return l();
64
+ }
65
+ }, d = (e, t, { useBeacon: n = !1 } = {}) => {
66
+ try {
67
+ let r = JSON.stringify(t);
68
+ return n && typeof navigator < "u" && typeof navigator.sendBeacon == "function" ? navigator.sendBeacon(e, r) : typeof fetch == "function" ? (fetch(e, {
69
+ method: "POST",
70
+ headers: { "Content-Type": "application/json" },
71
+ body: r,
72
+ keepalive: !0,
73
+ credentials: "omit",
74
+ mode: "cors"
75
+ }).catch(() => {}), !0) : !1;
76
+ } catch {
77
+ return !1;
78
+ }
79
+ }, f = (e) => {
80
+ if (typeof window > "u") return;
81
+ let t = window.requestIdleCallback;
82
+ if (typeof t == "function") {
83
+ t(() => e());
84
+ return;
85
+ }
86
+ setTimeout(e, 1);
87
+ }, p = "intlayer-analytics/1", m = () => typeof window > "u" || !window.location ? "" : window.location.pathname, h = () => {
88
+ if (!(typeof document > "u" || !document.referrer)) try {
89
+ return new URL(document.referrer).host;
90
+ } catch {
91
+ return;
92
+ }
93
+ }, g = (e) => {
94
+ let t = u(), n = s(t, e.sampleRate), i = o({ max: e.maxBufferSize }), a = `${e.backendURL.replace(/\/$/, "")}/api/analytics/events`, c = "", l = null, g = !1, _ = null, v = /* @__PURE__ */ new Set(), y = (n = !1) => {
95
+ let r = i.drain();
96
+ for (let i = 0; i < r.length; i += 200) d(a, {
97
+ clientId: e.clientId,
98
+ sessionId: t,
99
+ sdkVersion: p,
100
+ events: r.slice(i, i + 200)
101
+ }, { useBeacon: n });
102
+ }, b = (t) => {
103
+ i.push(t) >= e.maxBufferSize && y();
104
+ }, x = (e) => {
105
+ c = e;
106
+ }, S = (e = {}) => {
107
+ n && (v = /* @__PURE__ */ new Set(), b({
108
+ type: "page_view",
109
+ t: Date.now(),
110
+ url: e.url ?? m(),
111
+ locale: e.locale ?? c,
112
+ ref: e.ref ?? h(),
113
+ vw: e.vw ?? (typeof window < "u" ? window.innerWidth : void 0),
114
+ vh: e.vh ?? (typeof window < "u" ? window.innerHeight : void 0),
115
+ reason: e.reason ?? "initial"
116
+ }));
117
+ }, C = (e) => {
118
+ if (!n) return;
119
+ let t = e.locale ?? c, r = [
120
+ e.dictionaryKey,
121
+ e.keyPath,
122
+ t,
123
+ e.experimentKey ?? "",
124
+ e.variant ?? ""
125
+ ].join("");
126
+ v.has(r) || (v.add(r), b({
127
+ ...e,
128
+ type: "content_exposure",
129
+ t: Date.now(),
130
+ url: m(),
131
+ locale: t
132
+ }));
133
+ }, w = (e) => {
134
+ b({
135
+ ...e,
136
+ type: "conversion",
137
+ t: Date.now(),
138
+ url: m(),
139
+ locale: e.locale ?? c
140
+ }), y();
141
+ }, T = (e, n, i) => r(t, e, n, i), E = () => {
142
+ if (typeof window > "u") return;
143
+ let e = () => {
144
+ document.visibilityState === "hidden" && y(!0);
145
+ }, t = () => y(!0), n = () => S({ reason: "route_change" });
146
+ document.addEventListener("visibilitychange", e), window.addEventListener("pagehide", t, { capture: !0 }), window.addEventListener("popstate", n);
147
+ let r = window.history, i = r.pushState, a = function(...e) {
148
+ let t = i.apply(this, e);
149
+ return S({ reason: "route_change" }), t;
150
+ };
151
+ r.pushState = a, _ = () => {
152
+ document.removeEventListener("visibilitychange", e), window.removeEventListener("pagehide", t, { capture: !0 }), window.removeEventListener("popstate", n), r.pushState === a && (r.pushState = i);
153
+ };
154
+ };
155
+ return {
156
+ setLocale: x,
157
+ trackPageView: S,
158
+ trackContentExposure: C,
159
+ trackConversion: w,
160
+ getVariant: T,
161
+ flush: y,
162
+ start: () => {
163
+ g || (g = !0, l = setInterval(y, e.flushInterval), l?.unref?.(), f(E));
164
+ },
165
+ stop: () => {
166
+ g && (g = !1, l &&= (clearInterval(l), null), _?.(), _ = null, y(!0));
167
+ }
168
+ };
169
+ }, _ = "__intlayer_analytics_client__", v = "__intlayer_analytics_ref_count__", y = () => typeof window > "u" ? null : window[_] ?? null, b = (e) => {
170
+ typeof window > "u" || (window[_] = e);
171
+ }, x = () => {
172
+ if (typeof window > "u") return 0;
173
+ let e = window;
174
+ return e[v] = (e[v] ?? 0) + 1, e[v];
175
+ }, S = () => {
176
+ if (typeof window > "u") return 0;
177
+ let e = window;
178
+ return e[v] = Math.max(0, (e[v] ?? 0) - 1), e[v];
179
+ }, C = () => {
180
+ x();
181
+ let n = y();
182
+ if (n) return n;
183
+ let r = g({
184
+ backendURL: t?.backendURL ?? "",
185
+ clientId: t?.clientId,
186
+ flushInterval: e?.flushInterval ?? 2e4,
187
+ maxBufferSize: 500,
188
+ sampleRate: e?.sampleRate ?? 1
189
+ });
190
+ return b(r), r.start(), r;
191
+ }, w = () => {
192
+ S() > 0 || (y()?.stop(), b(null));
193
+ }, T = (e) => e.map((e) => e.key === void 0 ? "*" : String(e.key)).join("."), E = (e) => ({
194
+ dictionaryKey: e.dictionaryKey,
195
+ keyPath: T(e.keyPath),
196
+ locale: e.locale,
197
+ nodeType: e.nodeType,
198
+ experimentKey: e.experimentKey,
199
+ variant: e.variant
200
+ });
201
+ //#endregion
202
+ export { E as buildContentExposure, y as getGlobalAnalyticsClient, C as initAnalyticsClient, w as stopAnalyticsClient };
@@ -0,0 +1 @@
1
+ let e=require("@intlayer/config/built");var t=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},n=(e,n,r,i)=>{if(r.length===0)throw Error(`assignVariant requires at least one variant`);if(r.length===1)return r[0];let a=t(`${e}:${n}`)/4294967296;if(!i||i.length!==r.length){let e=Math.floor(a*r.length);return r[Math.min(e,r.length-1)]}let o=i.reduce((e,t)=>e+t,0);if(o<=0)return r[Math.floor(a*r.length)];let s=0,c=a*o;for(let e=0;e<r.length;e++)if(s+=i[e],c<s)return r[e];return r[r.length-1]},r=``,i=e=>[e.url,e.dictionaryKey,e.keyPath,e.locale,e.experimentKey??``,e.variant??``].join(r),a=({max:e})=>{let t=[],n=new Map,r=()=>t.length+n.size,a=()=>{for(;r()>e&&n.size>0;){let e=n.keys().next().value;n.delete(e)}r()>e&&(t=t.slice(r()-e))};return{push:e=>{if(e.type===`content_exposure`){let t=i(e),r=n.get(t);r?(r.count=(r.count??1)+(e.count??1),r.t=e.t):n.set(t,{...e,count:e.count??1})}else t.push(e);return a(),r()},drain:()=>{let e=[...t,...n.values()];return t=[],n.clear(),e},size:r}},o=(e,n)=>n>=1?!0:n<=0?!1:t(e)/4294967295<n,s=`__intlayer_analytics_sid__`,c=()=>{let e=typeof globalThis<`u`?globalThis.crypto:void 0;return e?.randomUUID?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`},l=()=>{if(typeof window>`u`||!window.sessionStorage)return c();try{let e=window.sessionStorage.getItem(s);if(e)return e;let t=c();return window.sessionStorage.setItem(s,t),t}catch{return c()}},u=(e,t,{useBeacon:n=!1}={})=>{try{let r=JSON.stringify(t);return n&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`?navigator.sendBeacon(e,r):typeof fetch==`function`?(fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0,credentials:`omit`,mode:`cors`}).catch(()=>{}),!0):!1}catch{return!1}},d=e=>{if(typeof window>`u`)return;let t=window.requestIdleCallback;if(typeof t==`function`){t(()=>e());return}setTimeout(e,1)},f=`intlayer-analytics/1`,p=()=>typeof window>`u`||!window.location?``:window.location.pathname,m=()=>{if(!(typeof document>`u`||!document.referrer))try{return new URL(document.referrer).host}catch{return}},h=e=>{let t=l(),r=o(t,e.sampleRate),i=a({max:e.maxBufferSize}),s=`${e.backendURL.replace(/\/$/,``)}/api/analytics/events`,c=``,h=null,g=!1,_=null,v=new Set,y=(n=!1)=>{let r=i.drain();for(let i=0;i<r.length;i+=200)u(s,{clientId:e.clientId,sessionId:t,sdkVersion:f,events:r.slice(i,i+200)},{useBeacon:n})},b=t=>{i.push(t)>=e.maxBufferSize&&y()},x=e=>{c=e},S=(e={})=>{r&&(v=new Set,b({type:`page_view`,t:Date.now(),url:e.url??p(),locale:e.locale??c,ref:e.ref??m(),vw:e.vw??(typeof window<`u`?window.innerWidth:void 0),vh:e.vh??(typeof window<`u`?window.innerHeight:void 0),reason:e.reason??`initial`}))},C=e=>{if(!r)return;let t=e.locale??c,n=[e.dictionaryKey,e.keyPath,t,e.experimentKey??``,e.variant??``].join(``);v.has(n)||(v.add(n),b({...e,type:`content_exposure`,t:Date.now(),url:p(),locale:t}))},w=e=>{b({...e,type:`conversion`,t:Date.now(),url:p(),locale:e.locale??c}),y()},T=(e,r,i)=>n(t,e,r,i),E=()=>{if(typeof window>`u`)return;let e=()=>{document.visibilityState===`hidden`&&y(!0)},t=()=>y(!0),n=()=>S({reason:`route_change`});document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t,{capture:!0}),window.addEventListener(`popstate`,n);let r=window.history,i=r.pushState,a=function(...e){let t=i.apply(this,e);return S({reason:`route_change`}),t};r.pushState=a,_=()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t,{capture:!0}),window.removeEventListener(`popstate`,n),r.pushState===a&&(r.pushState=i)}};return{setLocale:x,trackPageView:S,trackContentExposure:C,trackConversion:w,getVariant:T,flush:y,start:()=>{g||(g=!0,h=setInterval(y,e.flushInterval),h?.unref?.(),d(E))},stop:()=>{g&&(g=!1,h&&=(clearInterval(h),null),_?.(),_=null,y(!0))}}},g=`__intlayer_analytics_client__`,_=`__intlayer_analytics_ref_count__`,v=()=>typeof window>`u`?null:window[g]??null,y=e=>{typeof window>`u`||(window[g]=e)},b=()=>{if(typeof window>`u`)return 0;let e=window;return e[_]=(e[_]??0)+1,e[_]},x=()=>{if(typeof window>`u`)return 0;let e=window;return e[_]=Math.max(0,(e[_]??0)-1),e[_]},S=()=>{b();let t=v();if(t)return t;let n=h({backendURL:e.editor?.backendURL??``,clientId:e.editor?.clientId,flushInterval:e.analytics?.flushInterval??2e4,maxBufferSize:500,sampleRate:e.analytics?.sampleRate??1});return y(n),n.start(),n},C=()=>{x()>0||(v()?.stop(),y(null))},w=e=>e.map(e=>e.key===void 0?`*`:String(e.key)).join(`.`),T=e=>({dictionaryKey:e.dictionaryKey,keyPath:w(e.keyPath),locale:e.locale,nodeType:e.nodeType,experimentKey:e.experimentKey,variant:e.variant});exports.buildContentExposure=T,exports.getGlobalAnalyticsClient=v,exports.initAnalyticsClient=S,exports.stopAnalyticsClient=C;
@@ -0,0 +1 @@
1
+ let e=require("@intlayer/config/built");var t=process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&e.analytics?.enabled===!0&&!!e.editor?.clientId&&typeof window<`u`&&window.self===window.top;Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
@@ -0,0 +1,5 @@
1
+ import { analytics as e, editor as t } from "@intlayer/config/built";
2
+ //#region ../@intlayer/analytics/dist/esm/isEnabled.mjs
3
+ var n = process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e?.enabled === !0 && !!t?.clientId && typeof window < "u" && window.self === window.top;
4
+ //#endregion
5
+ export { n as t };
@@ -0,0 +1,28 @@
1
+ import { KeyPath } from '@intlayer/types/keyPath';
2
+ /**
3
+ * Node metadata reported for a content exposure. Kept dependency-free (types
4
+ * only) so the interpreter hot path in `plugins.ts` never statically imports
5
+ * `@intlayer/analytics` — the package stays optional and tree-shakeable.
6
+ */
7
+ export type ExposureInput = {
8
+ dictionaryKey: string;
9
+ keyPath: KeyPath[];
10
+ locale?: string;
11
+ nodeType?: string;
12
+ };
13
+ /** Consumer of exposure reports, installed by `useAnalytics` after init. */
14
+ export type ExposureSink = (input: ExposureInput) => void;
15
+ /**
16
+ * Installs (or clears) the exposure sink. `useAnalytics` sets this once the
17
+ * analytics client has loaded, and clears it on teardown.
18
+ *
19
+ * @param next - The sink to install, or `null` to clear.
20
+ */
21
+ export declare const setExposureSink: (next: ExposureSink | null) => void;
22
+ /**
23
+ * Forwards a content exposure to the installed sink. A cheap null-check when
24
+ * analytics is not running, so it is safe to call from every node resolution.
25
+ *
26
+ * @param input - The node metadata to report.
27
+ */
28
+ export declare const reportExposure: (input: ExposureInput) => void;
@@ -0,0 +1,3 @@
1
+ export * from './useAnalytics';
2
+ export * from './useConversion';
3
+ export * from './useExperiment';
@@ -0,0 +1,11 @@
1
+ import { App } from 'vue';
2
+ /**
3
+ * Initializes the Intlayer analytics client singleton when analytics is
4
+ * enabled (mirrors {@link useEditor}). Records an initial page view, keeps the
5
+ * client aware of the current locale, and wires node-level content exposures.
6
+ *
7
+ * @param app - When provided, hooks into the root component lifecycle via
8
+ * `app.mixin` (use from `installIntlayer`). When omitted, uses Vue composable
9
+ * lifecycle hooks (use from a component's `setup`).
10
+ */
11
+ export declare const useAnalytics: (app?: App) => void;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Parameters describing a conversion to record.
3
+ */
4
+ export type ConversionParams = {
5
+ /** The experiment this conversion is attributed to. */
6
+ experimentKey: string;
7
+ /** The variant the session was assigned. */
8
+ variant: string;
9
+ /** The goal reached (e.g. `"signup"`, `"cta_click"`). */
10
+ goal: string;
11
+ /** Optional numeric value (e.g. revenue). */
12
+ value?: number;
13
+ };
14
+ /**
15
+ * Returns a `trackConversion` callback for content A/B testing. Safe to call
16
+ * from any component: it resolves to a no-op when analytics is disabled or the
17
+ * client has not been initialized yet.
18
+ *
19
+ * @example
20
+ * ```vue
21
+ * <script setup>
22
+ * const trackConversion = useConversion();
23
+ * </script>
24
+ * <template>
25
+ * <button @click="trackConversion({
26
+ * experimentKey: 'homepage-hero', variant: 'b', goal: 'cta_click',
27
+ * })">Get started</button>
28
+ * </template>
29
+ * ```
30
+ */
31
+ export declare const useConversion: () => (params: ConversionParams) => void;
@@ -0,0 +1,38 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * The state of an A/B experiment for the current session.
4
+ */
5
+ export type ExperimentState = {
6
+ /**
7
+ * The variant assigned to this session. Until assignment resolves (and on
8
+ * the server, or when analytics is disabled), this is the first variant —
9
+ * treat the first variant as the control.
10
+ */
11
+ variant: Ref<string>;
12
+ /**
13
+ * `true` once the variant has been deterministically assigned and its
14
+ * exposure recorded. Useful to defer rendering when a flash of the control
15
+ * variant is not acceptable.
16
+ */
17
+ isAssigned: Ref<boolean>;
18
+ };
19
+ /**
20
+ * Assigns this session to a variant of an A/B experiment and records the
21
+ * exposure, scoped to `experimentKey`, so the backend can compute per-variant
22
+ * conversion rates against `useConversion` events.
23
+ *
24
+ * Assignment is deterministic per session (no server round-trip, stable across
25
+ * re-mounts). The exposure is recorded once per mount.
26
+ *
27
+ * @param experimentKey - Unique key identifying the experiment.
28
+ * @param variants - The candidate variant names; the first one is the control.
29
+ * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
30
+ * @returns The {@link ExperimentState} for this session.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const { variant } = useExperiment('homepage-hero', ['a', 'b']);
35
+ * const content = useIntlayer(variant.value === 'b' ? 'hero-b' : 'hero');
36
+ * ```
37
+ */
38
+ export declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
@@ -37,15 +37,6 @@ export declare const HTMLRenderer: import('vue').DefineComponent<import('vue').E
37
37
  object?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
38
38
  children?: any;
39
39
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
40
- small?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
41
- children?: any;
42
- }) => import('vue').VNode | import('vue').VNode[]) | undefined;
43
- sub?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
44
- children?: any;
45
- }) => import('vue').VNode | import('vue').VNode[]) | undefined;
46
- sup?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
47
- children?: any;
48
- }) => import('vue').VNode | import('vue').VNode[]) | undefined;
49
40
  html?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
50
41
  children?: any;
51
42
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
@@ -133,6 +124,15 @@ export declare const HTMLRenderer: import('vue').DefineComponent<import('vue').E
133
124
  mark?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
134
125
  children?: any;
135
126
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
127
+ small?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
128
+ children?: any;
129
+ }) => import('vue').VNode | import('vue').VNode[]) | undefined;
130
+ sub?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
131
+ children?: any;
132
+ }) => import('vue').VNode | import('vue').VNode[]) | undefined;
133
+ sup?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
134
+ children?: any;
135
+ }) => import('vue').VNode | import('vue').VNode[]) | undefined;
136
136
  code?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
137
137
  children?: any;
138
138
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
@@ -4,6 +4,7 @@ declare module '@intlayer/core/interpreter' {
4
4
  interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginVue<T, S, L> {
5
5
  }
6
6
  }
7
+ export * from './analytics';
7
8
  export * from './client';
8
9
  export * from './editor/useEditor';
9
10
  export * from './getDictionary';
@@ -202,15 +202,6 @@ export declare const MarkdownRenderer: import('vue').DefineComponent<import('vue
202
202
  object?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
203
203
  children?: any;
204
204
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
205
- small?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
206
- children?: any;
207
- }) => import('vue').VNode | import('vue').VNode[]) | undefined;
208
- sub?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
209
- children?: any;
210
- }) => import('vue').VNode | import('vue').VNode[]) | undefined;
211
- sup?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
212
- children?: any;
213
- }) => import('vue').VNode | import('vue').VNode[]) | undefined;
214
205
  html?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
215
206
  children?: any;
216
207
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
@@ -298,6 +289,15 @@ export declare const MarkdownRenderer: import('vue').DefineComponent<import('vue
298
289
  mark?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
299
290
  children?: any;
300
291
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
292
+ small?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
293
+ children?: any;
294
+ }) => import('vue').VNode | import('vue').VNode[]) | undefined;
295
+ sub?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
296
+ children?: any;
297
+ }) => import('vue').VNode | import('vue').VNode[]) | undefined;
298
+ sup?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
299
+ children?: any;
300
+ }) => import('vue').VNode | import('vue').VNode[]) | undefined;
301
301
  code?: ((props: import('vue').HTMLAttributes & import('vue').AllowedComponentProps & import('vue').VNodeProps & {
302
302
  children?: any;
303
303
  }) => import('vue').VNode | import('vue').VNode[]) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-intlayer",
3
- "version": "9.0.0-canary.8",
3
+ "version": "9.0.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -102,30 +102,30 @@
102
102
  "typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
103
103
  },
104
104
  "dependencies": {
105
- "@intlayer/api": "9.0.0-canary.8",
106
- "@intlayer/config": "9.0.0-canary.8",
107
- "@intlayer/core": "9.0.0-canary.8",
108
- "@intlayer/editor": "9.0.0-canary.8",
109
- "@intlayer/types": "9.0.0-canary.8"
105
+ "@intlayer/api": "9.0.0",
106
+ "@intlayer/config": "9.0.0",
107
+ "@intlayer/core": "9.0.0",
108
+ "@intlayer/editor": "9.0.0",
109
+ "@intlayer/types": "9.0.0"
110
110
  },
111
111
  "devDependencies": {
112
- "@types/node": "25.9.4",
112
+ "@types/node": "26.1.1",
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",
116
- "@vitejs/plugin-vue": "6.0.5",
117
- "ajv": "8.18.0",
116
+ "@vitejs/plugin-vue": "6.0.8",
117
+ "ajv": "8.20.0",
118
118
  "fast-glob": "3.3.3",
119
119
  "rimraf": "6.1.3",
120
- "tsdown": "0.21.10",
121
- "typescript": "6.0.3",
122
- "vite": "8.1.0",
123
- "vite-plugin-dts": "5.0.2",
124
- "vitest": "4.1.9",
125
- "vue-tsc": "3.1.8"
120
+ "tsdown": "0.22.13",
121
+ "typescript": "7.0.2",
122
+ "vite": "8.1.5",
123
+ "vite-plugin-dts": "5.0.3",
124
+ "vitest": "4.1.10",
125
+ "vue-tsc": "3.3.7"
126
126
  },
127
127
  "peerDependencies": {
128
- "intlayer": "9.0.0-canary.8",
128
+ "intlayer": "9.0.0",
129
129
  "vue": ">=3.0.0"
130
130
  },
131
131
  "peerDependenciesMeta": {
@@ -133,6 +133,9 @@
133
133
  "optional": true
134
134
  }
135
135
  },
136
+ "optionalDependencies": {
137
+ "@intlayer/analytics": "9.0.0"
138
+ },
136
139
  "engines": {
137
140
  "node": ">=14.18"
138
141
  },