solid-intlayer 9.0.0-canary.15 → 9.0.0-canary.17
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/AnalyticsProvider.cjs +1 -0
- package/dist/cjs/analytics/exposureSink.cjs +1 -0
- package/dist/cjs/analytics/index.cjs +1 -0
- package/dist/cjs/analytics/useAnalytics.cjs +1 -0
- package/dist/cjs/analytics/useConversion.cjs +1 -0
- package/dist/cjs/analytics/useExperiment.cjs +1 -0
- package/dist/cjs/client/IntlayerProvider.cjs +1 -1
- package/dist/cjs/client/getBrowserLocale.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/esm/analytics/AnalyticsProvider.mjs +5 -0
- package/dist/esm/analytics/exposureSink.mjs +8 -0
- package/dist/esm/analytics/index.mjs +5 -0
- package/dist/esm/analytics/useAnalytics.mjs +35 -0
- package/dist/esm/analytics/useConversion.mjs +9 -0
- package/dist/esm/analytics/useExperiment.mjs +30 -0
- package/dist/esm/client/IntlayerProvider.mjs +14 -8
- package/dist/esm/client/getBrowserLocale.mjs +4 -1
- package/dist/esm/editor/useEditor.mjs +2 -1
- package/dist/esm/index.mjs +6 -1
- package/dist/esm/plugins.mjs +104 -93
- package/dist/esm-JsFWnEiY.mjs +202 -0
- package/dist/esm-kl1nXjmn.js +1 -0
- package/dist/isEnabled-B9hPiyif.js +1 -0
- package/dist/isEnabled-C5NavXyG.mjs +5 -0
- package/dist/types/analytics/AnalyticsProvider.d.ts +6 -0
- package/dist/types/analytics/exposureSink.d.ts +28 -0
- package/dist/types/analytics/index.d.ts +4 -0
- package/dist/types/analytics/useAnalytics.d.ts +11 -0
- package/dist/types/analytics/useConversion.d.ts +27 -0
- package/dist/types/analytics/useExperiment.d.ts +38 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +11 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useAnalytics.cjs");var t=({children:t})=>(e.useAnalytics(),t);exports.AnalyticsProvider=t;
|
|
@@ -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("./AnalyticsProvider.cjs"),n=require("./useConversion.cjs"),r=require("./useExperiment.cjs");exports.AnalyticsProvider=t.AnalyticsProvider,exports.useAnalytics=e.useAnalytics,exports.useConversion=n.useConversion,exports.useExperiment=r.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/IntlayerProvider.cjs");let r=require("solid-js");var i=()=>{if(process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!t.t)return;let{locale:i}=n.useIntlayerContext(),[a,o]=(0,r.createSignal)(null),s=!1,c=!1;(0,r.onMount)(()=>{Promise.resolve().then(()=>require("../../esm-kl1nXjmn.js")).then(({initAnalyticsClient:t,buildContentExposure:n})=>{if(s)return;let r=t();c=!0;let a=i?.();a&&r.setLocale(a),r.trackPageView({reason:`initial`}),e.setExposureSink(e=>r.trackContentExposure(n(e))),o(r)}).catch(()=>{})});let l;(0,r.createEffect)(()=>{let e=a(),t=i?.();if(!(!e||!t)){if(l===void 0){l=t;return}l!==t&&(l=t,e.setLocale(t),e.trackPageView({reason:`locale_change`}))}}),(0,r.onCleanup)(()=>{s=!0,e.setExposureSink(null),Promise.resolve().then(()=>require("../../esm-kl1nXjmn.js")).then(({stopAnalyticsClient:e})=>{c&&e()}).catch(()=>{})})};exports.useAnalytics=i;
|
|
@@ -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("solid-js");var n=(n,r,i)=>{let[a,o]=(0,t.createSignal)(r[0]??``),[s,c]=(0,t.createSignal)(!1),l=!1,u=!1;return(0,t.onMount)(()=>{process.env.INTLAYER_ANALYTICS_ENABLED===`false`||!e.t||Promise.resolve().then(()=>require("../../esm-kl1nXjmn.js")).then(({initAnalyticsClient:e})=>{if(l)return;let t=e();u=!0;let a=t.getVariant(n,r,i);o(a),c(!0),t.trackContentExposure({dictionaryKey:n,keyPath:``,nodeType:`experiment`,experimentKey:n,variant:a})}).catch(()=>{})}),(0,t.onCleanup)(()=>{l=!0,Promise.resolve().then(()=>require("../../esm-kl1nXjmn.js")).then(({stopAnalyticsClient:e})=>{u&&e()}).catch(()=>{})}),{variant:a,isAssigned:s}};exports.useExperiment=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useLocaleStorage.cjs");let t=require("solid-js/web"),n=require("@intlayer/config/built"),r=require("solid-js"),i=require("@intlayer/core/localization"),a=require("@intlayer/config/client");var o=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,r.lazy)(()=>Promise.resolve().then(()=>require("../editor/EditorProvider.cjs")).then(e=>({default:e.EditorProvider}))),s=(0,r.createContext)({locale:()=>e.localeInStorage??n.internationalization?.defaultLocale,setLocale:()=>null}),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useLocaleStorage.cjs");let t=require("solid-js/web"),n=require("@intlayer/config/built"),r=require("solid-js"),i=require("@intlayer/core/localization"),a=require("@intlayer/config/client");var o=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,r.lazy)(()=>Promise.resolve().then(()=>require("../editor/EditorProvider.cjs")).then(e=>({default:e.EditorProvider}))),s=process.env.INTLAYER_ANALYTICS_ENABLED===`false`?null:(0,r.lazy)(()=>Promise.resolve().then(()=>require("../analytics/AnalyticsProvider.cjs")).then(e=>({default:e.AnalyticsProvider}))),c=(0,r.createContext)({locale:()=>e.localeInStorage??n.internationalization?.defaultLocale,setLocale:()=>null}),l=()=>(0,r.useContext)(c)??{},u=o=>{let{defaultLocale:s,locales:l}=n.internationalization??{},[u,d]=(0,r.createSignal)(o.locale??e.localeInStorage??o.defaultLocale??s),f=o.setLocale??(t=>{if(u().toString()!==t.toString()){if(!l?.map(String).includes(t)){console.error(`Locale ${t} is not available`);return}d(t),e.setLocaleInStorage(t,o.isCookieEnabled)}}),p=(0,r.createMemo)(()=>(0,i.localeResolver)(u()));return(0,r.createEffect)((0,r.on)(()=>o.locale,e=>{e&&e!==(0,r.untrack)(u)&&d(e)},{defer:!0})),(0,r.onMount)(()=>{(0,a.setIntlayerIdentifier)()}),(0,t.createComponent)(c.Provider,{value:{locale:p,setLocale:f},get children(){return o.children}})},d=e=>(0,t.createComponent)(u,(0,t.mergeProps)(e,{get children(){return[(0,t.memo)(()=>(0,t.memo)(()=>!!(process.env.INTLAYER_EDITOR_ENABLED!==`false`&&o))()&&(0,t.createComponent)(r.Suspense,{get children(){return(0,t.createComponent)(o,{})}})),(0,t.memo)(()=>(0,t.memo)(()=>!!(process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&s))()&&(0,t.createComponent)(r.Suspense,{get children(){return(0,t.createComponent)(s,{})}})),(0,t.memo)(()=>e.children)]}}));exports.IntlayerClientContext=c,exports.IntlayerProvider=d,exports.IntlayerProviderContent=u,exports.useIntlayerContext=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("@intlayer/config/defaultValues"),n=require("@intlayer/core/localization"),r=require("@intlayer/core/utils");var i=function(e){return e.Querystring=`querystring`,e.Storage=`storage`,e.Navigator=`navigator`,e.HtmlTag=`htmlTag`,e}({}),a=()=>({order:[`querystring`,`storage`,`navigator`,`htmlTag`],lookupQuerystring:`locale`,htmlTag:typeof document<`u`?document.documentElement:null}),o=(t,i)=>{let a={},o={querystring:()=>{if(typeof window>`u`)return;let e=window.location.search||``,t=new URLSearchParams(e).get(i.lookupQuerystring??``);t&&(a.querystring=t)},storage:()=>{if(typeof window>`u`)return;let e=(0,r.getLocaleFromStorageClient)({getCookie:e=>{try{let t=document.cookie.split(`;`),n=`${e}=`,r=t.find(e=>e.trim().startsWith(n));if(r)return r.split(`=`)[1].trim()}catch{}},getSessionStorage:e=>{try{return window.sessionStorage.getItem(e)??void 0}catch{}},getLocaleStorage:e=>{try{return window.localStorage.getItem(e)??void 0}catch{}}});e&&(a.storage=e)},navigator:()=>{if(typeof navigator>`u`)return;let t=(0,n.localeDetector)({"accept-language":(navigator.languages??[navigator.language]).join(`,`)},e.internationalization.locales,e.internationalization.defaultLocale);t&&(a.navigator=t)},htmlTag:()=>{let t=i.htmlTag;if(t&&typeof t.getAttribute==`function`){let r=t.getAttribute(`lang`);r
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("@intlayer/config/defaultValues"),n=require("@intlayer/core/localization"),r=require("@intlayer/core/utils");var i=function(e){return e.Querystring=`querystring`,e.Storage=`storage`,e.Navigator=`navigator`,e.HtmlTag=`htmlTag`,e}({}),a=()=>({order:[`querystring`,`storage`,`navigator`,`htmlTag`],lookupQuerystring:`locale`,htmlTag:typeof document<`u`?document.documentElement:null}),o=(t,i)=>{let a={},o={querystring:()=>{if(typeof window>`u`)return;let e=window.location.search||``,t=new URLSearchParams(e).get(i.lookupQuerystring??``);t&&(a.querystring=t)},storage:()=>{if(typeof window>`u`)return;let e=(0,r.getLocaleFromStorageClient)({getCookie:e=>{try{let t=document.cookie.split(`;`),n=`${e}=`,r=t.find(e=>e.trim().startsWith(n));if(r)return r.split(`=`)[1].trim()}catch{}},getSessionStorage:e=>{try{return window.sessionStorage.getItem(e)??void 0}catch{}},getLocaleStorage:e=>{try{return window.localStorage.getItem(e)??void 0}catch{}}});e&&(a.storage=e)},navigator:()=>{if(typeof navigator>`u`)return;let t=(0,n.localeDetector)({"accept-language":(navigator.languages??[navigator.language]).join(`,`)},e.internationalization.locales,e.internationalization.defaultLocale);t&&(a.navigator=t)},htmlTag:()=>{let t=i.htmlTag;if(t&&typeof t.getAttribute==`function`){let r=t.getAttribute(`lang`);if(r){let t=(0,n.localeDetector)({"accept-language":r},e.internationalization.locales,e.internationalization.defaultLocale);a.htmlTag=t}}}};return t.forEach(e=>{o[e]?.()}),a},s=(n,r)=>{for(let t of r){let r=n[t];if(r&&e.internationalization.locales.includes(r))return r}return e.internationalization?.defaultLocale??t.DEFAULT_LOCALE},c=(e={})=>{let t={...a(),...e};return s(o(t.order??[],t),t.order??[])};exports.LanguageDetector=i,exports.getBrowserLocale=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../client/IntlayerProvider.cjs");let t=require("solid-js"),n=require("@intlayer/editor/isEnabled");var r=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled)return;let{locale:r}=e.useIntlayerContext(),[i,a]=(0,t.createSignal)(null);(0,t.onMount)(()=>{import(`@intlayer/editor`).then(({initEditorClient:e})=>{
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../client/IntlayerProvider.cjs");let t=require("solid-js"),n=require("@intlayer/editor/isEnabled");var r=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled)return;let{locale:r}=e.useIntlayerContext(),[i,a]=(0,t.createSignal)(null);(0,t.onMount)(()=>{import(`@intlayer/editor`).then(({initEditorClient:e})=>{let t=e();a(t)})}),(0,t.createEffect)(()=>{let e=i(),t=r();e&&t&&e.currentLocale.set(t)}),(0,t.onCleanup)(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};exports.useEditor=r;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./client/useLoadDynamic.cjs"),t=require("./getIntlayer.cjs"),n=require("./getDictionary.cjs"),r=require("./client/getBrowserLocale.cjs"),i=require("./client/useLocaleStorage.cjs"),a=require("./client/IntlayerProvider.cjs"),o=require("./client/t.cjs"),s=require("./client/useDictionary.cjs"),c=require("./client/useDictionaryAsync.cjs"),l=require("./client/useDictionaryDynamic.cjs"),u=require("./client/useIntlayer.cjs"),d=require("./client/useLocale.cjs"),f=require("./client/useLocaleBase.cjs"),p=require("./client/useRewriteURL.cjs");exports.IntlayerClientContext=a.IntlayerClientContext,exports.IntlayerProvider=a.IntlayerProvider,exports.IntlayerProviderContent=a.IntlayerProviderContent,exports.getBrowserLocale=r.getBrowserLocale,exports.getDictionary=n.getDictionary,exports.getIntlayer=t.getIntlayer,exports.localeCookie=i.localeCookie,exports.localeInStorage=i.localeInStorage,exports.setLocaleCookie=i.setLocaleCookie,exports.setLocaleInStorage=i.setLocaleInStorage,exports.t=o.t,exports.useDictionary=s.useDictionary,exports.useDictionaryAsync=c.useDictionaryAsync,exports.useDictionaryDynamic=l.useDictionaryDynamic,exports.useIntlayer=u.useIntlayer,exports.useIntlayerContext=a.useIntlayerContext,exports.useLoadDynamic=e.useLoadDynamic,exports.useLocale=d.useLocale,exports.useLocaleBase=f.useLocaleBase,exports.useLocaleCookie=i.useLocaleCookie,exports.useLocaleStorage=i.useLocaleStorage,exports.useRewriteURL=p.useRewriteURL;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./client/useLoadDynamic.cjs"),t=require("./getIntlayer.cjs"),n=require("./getDictionary.cjs"),r=require("./client/getBrowserLocale.cjs"),i=require("./client/useLocaleStorage.cjs"),a=require("./client/IntlayerProvider.cjs"),o=require("./client/t.cjs"),s=require("./client/useDictionary.cjs"),c=require("./client/useDictionaryAsync.cjs"),l=require("./client/useDictionaryDynamic.cjs"),u=require("./client/useIntlayer.cjs"),d=require("./client/useLocale.cjs"),f=require("./client/useLocaleBase.cjs"),p=require("./client/useRewriteURL.cjs"),m=require("./analytics/useAnalytics.cjs"),h=require("./analytics/AnalyticsProvider.cjs"),g=require("./analytics/useConversion.cjs"),_=require("./analytics/useExperiment.cjs");require("./analytics/index.cjs"),exports.AnalyticsProvider=h.AnalyticsProvider,exports.IntlayerClientContext=a.IntlayerClientContext,exports.IntlayerProvider=a.IntlayerProvider,exports.IntlayerProviderContent=a.IntlayerProviderContent,exports.getBrowserLocale=r.getBrowserLocale,exports.getDictionary=n.getDictionary,exports.getIntlayer=t.getIntlayer,exports.localeCookie=i.localeCookie,exports.localeInStorage=i.localeInStorage,exports.setLocaleCookie=i.setLocaleCookie,exports.setLocaleInStorage=i.setLocaleInStorage,exports.t=o.t,exports.useAnalytics=m.useAnalytics,exports.useConversion=g.useConversion,exports.useDictionary=s.useDictionary,exports.useDictionaryAsync=c.useDictionaryAsync,exports.useDictionaryDynamic=l.useDictionaryDynamic,exports.useExperiment=_.useExperiment,exports.useIntlayer=u.useIntlayer,exports.useIntlayerContext=a.useIntlayerContext,exports.useLoadDynamic=e.useLoadDynamic,exports.useLocale=d.useLocale,exports.useLocaleBase=f.useLocaleBase,exports.useLocaleCookie=i.useLocaleCookie,exports.useLocaleStorage=i.useLocaleStorage,exports.useRewriteURL=p.useRewriteURL;
|
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,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./client/useLoadDynamic.cjs"),
|
|
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("./analytics/exposureSink.cjs"),l=require("./client/useLoadDynamic.cjs"),u=require("./IntlayerNode.cjs"),d=require("./solidElement/renderSolidElement.cjs");let f=require("solid-js/web"),p=require("@intlayer/config/built"),m=require("@intlayer/core/interpreter"),h=require("@intlayer/core/markdown"),g=require("@intlayer/types/nodeType");g=s(g);let _=require("solid-js");var v=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,_.lazy)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs")).then(e=>({default:e.ContentSelector}))),y=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?null:Promise.resolve().then(()=>require("./markdown/MarkdownRenderer.cjs")).then(e=>({MarkdownRenderer:e.MarkdownRenderer,MarkdownMetadataRenderer:e.MarkdownMetadataRenderer})),b=process.env.INTLAYER_NODE_TYPE_HTML===`false`?null:Promise.resolve().then(()=>require("./html/HTMLRenderer.cjs")).then(e=>e.HTMLRenderer),x={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:t,...n})=>(process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&c.reportExposure({dictionaryKey:n.dictionaryKey,keyPath:n.keyPath,locale:n.locale,nodeType:`text`}),u.renderIntlayerNode({...n,value:n.children,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(_.Suspense,{get fallback(){return n.children},get children(){return(0,f.createComponent)(v,(0,f.mergeProps)(n,{get children(){return n.children}}))}}):n.children}))},S=process.env.INTLAYER_NODE_TYPE_SOLID_NODE===`false`?m.fallbackPlugin:{id:`solid-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0||typeof Node<`u`&&e instanceof Node,transform:(e,{plugins:t,...n})=>(process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&c.reportExposure({dictionaryKey:n.dictionaryKey,keyPath:n.keyPath,locale:n.locale,nodeType:`solid-node`}),u.renderIntlayerNode({...n,value:`[[solid-element]]`,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(_.Suspense,{get fallback(){return typeof Node<`u`&&e instanceof Node?e:d.renderSolidElement(e)},get children(){return(0,f.createComponent)(v,(0,f.mergeProps)(n,{get children(){return typeof Node<`u`&&e instanceof Node?e:d.renderSolidElement(e)}}))}}):typeof Node<`u`&&e instanceof Node?e:d.renderSolidElement(e)}))},C=(e,t)=>{let n=(0,m.splitInsertionTemplate)(e,t);return n.isSimple,n.parts},w=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?m.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];return e=>{let a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(n,r,i)=>{let a=C(i(n,{...r,children:n,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]}),e);return i(a,{...r,plugins:t.plugins,children:a})}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}}},T=e=>{let{MarkdownRenderer:t}=l.useLoadDynamic(`solid-markdown-renderer`,y);return(0,f.createComponent)(t,e)},E=e=>{let{MarkdownMetadataRenderer:t}=l.useLoadDynamic(`solid-markdown-renderer`,y);return(0,f.createComponent)(t,e)},D=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?m.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)=>u.renderIntlayerNode({...n,value:t,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(_.Suspense,{get children(){return(0,f.createComponent)(v,(0,f.mergeProps)(i,{get children(){return(0,f.createComponent)(E,(0,f.mergeProps)(i,{get metadataKeyPath(){return n.keyPath},children:e}))}}))}}):(0,f.createComponent)(E,(0,f.mergeProps)(i,{get metadataKeyPath(){return n.keyPath},children:e}))})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>u.renderIntlayerNode({...t,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(_.Suspense,{get children(){return(0,f.createComponent)(v,(0,f.mergeProps)(i,{get children(){return(0,f.createComponent)(T,(0,f.mergeProps)(i,{components:n,children:e}))}}))}}):(0,f.createComponent)(T,(0,f.mergeProps)(i,{components:n,children:e})),additionalProps:{metadata:a}}),s=o();return new Proxy(s,{get(t,n,r){if(n===`value`)return e;if(n===Symbol.toPrimitive||n===`toString`||n===`valueOf`)return()=>e;if(typeof n==`string`&&n!==`constructor`){let t=String.prototype[n];if(typeof t==`function`)return t.bind(e)}return n===`metadata`?a:n===`use`?e=>o(e):Reflect.get(t,n,r)}})}},O=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?m.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:[D,...t.plugins??[]]})}},k=e=>(0,f.createComponent)(l.useLoadDynamic(`solid-html-renderer`,b),e),A=process.env.INTLAYER_NODE_TYPE_HTML===`false`?m.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===g.HTML,transform:(e,t)=>{let n=e[g.HTML],{plugins:r,...i}=t,a=e=>u.renderIntlayerNode({...i,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(_.Suspense,{get children(){return(0,f.createComponent)(v,(0,f.mergeProps)(i,{get children(){return(0,f.createComponent)(k,(0,f.mergeProps)(i,{html:n,components:e}))}}))}}):(0,f.createComponent)(k,(0,f.mergeProps)(i,{html:n,components:e}))}),o=[a()];return new Proxy(o,{get(e,t,r){if(t===`value`)return n;if(t===Symbol.toPrimitive||t===`toString`||t===`valueOf`)return()=>n;if(typeof t==`string`&&t!==`constructor`){let e=String.prototype[t];if(typeof e==`function`)return e.bind(n)}return t===`use`?e=>a(e):Reflect.get(e,t,r)}})}},j=new Map,M=(e,t=!0)=>{let n=`${e??p.internationalization.defaultLocale}_${t}`;if(j.has(n))return j.get(n);let r=[(0,m.translationPlugin)(e??p.internationalization.defaultLocale,t?p.internationalization.defaultLocale:void 0),m.enumerationPlugin,(0,m.pluralPlugin)(e??p.internationalization.defaultLocale),m.conditionPlugin,(0,m.nestedPlugin)(e??p.internationalization.defaultLocale),m.filePlugin,m.genderPlugin,x,S,w,O,A];return j.set(n,r),r};exports.getPlugins=M,exports.htmlPlugin=A,exports.insertionPlugin=w,exports.intlayerNodePlugins=x,exports.markdownPlugin=O,exports.markdownStringPlugin=D,exports.solidNodePlugins=S;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useAnalytics as e } from "./useAnalytics.mjs";
|
|
2
|
+
import { AnalyticsProvider as t } from "./AnalyticsProvider.mjs";
|
|
3
|
+
import { useConversion as n } from "./useConversion.mjs";
|
|
4
|
+
import { useExperiment as r } from "./useExperiment.mjs";
|
|
5
|
+
export { t as AnalyticsProvider, e as useAnalytics, n as useConversion, r as useExperiment };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { setExposureSink as e } from "./exposureSink.mjs";
|
|
2
|
+
import { t } from "../../isEnabled-C5NavXyG.mjs";
|
|
3
|
+
import { useIntlayerContext as n } from "../client/IntlayerProvider.mjs";
|
|
4
|
+
import { createEffect as r, createSignal as i, onCleanup as a, onMount as o } from "solid-js";
|
|
5
|
+
//#region src/analytics/useAnalytics.tsx
|
|
6
|
+
var s = () => {
|
|
7
|
+
if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !t) return;
|
|
8
|
+
let { locale: s } = n(), [c, l] = i(null), u = !1, d = !1;
|
|
9
|
+
o(() => {
|
|
10
|
+
import("../../esm-JsFWnEiY.mjs").then(({ initAnalyticsClient: t, buildContentExposure: n }) => {
|
|
11
|
+
if (u) return;
|
|
12
|
+
let r = t();
|
|
13
|
+
d = !0;
|
|
14
|
+
let i = s?.();
|
|
15
|
+
i && r.setLocale(i), r.trackPageView({ reason: "initial" }), e((e) => r.trackContentExposure(n(e))), l(r);
|
|
16
|
+
}).catch(() => {});
|
|
17
|
+
});
|
|
18
|
+
let f;
|
|
19
|
+
r(() => {
|
|
20
|
+
let e = c(), t = s?.();
|
|
21
|
+
if (!(!e || !t)) {
|
|
22
|
+
if (f === void 0) {
|
|
23
|
+
f = t;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
f !== t && (f = t, e.setLocale(t), e.trackPageView({ reason: "locale_change" }));
|
|
27
|
+
}
|
|
28
|
+
}), a(() => {
|
|
29
|
+
u = !0, e(null), import("../../esm-JsFWnEiY.mjs").then(({ stopAnalyticsClient: e }) => {
|
|
30
|
+
d && e();
|
|
31
|
+
}).catch(() => {});
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { s 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 { createSignal as t, onCleanup as n, onMount as r } from "solid-js";
|
|
3
|
+
//#region src/analytics/useExperiment.ts
|
|
4
|
+
var i = (i, a, o) => {
|
|
5
|
+
let [s, c] = t(a[0] ?? ""), [l, u] = t(!1), d = !1, f = !1;
|
|
6
|
+
return r(() => {
|
|
7
|
+
process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !e || import("../../esm-JsFWnEiY.mjs").then(({ initAnalyticsClient: e }) => {
|
|
8
|
+
if (d) return;
|
|
9
|
+
let t = e();
|
|
10
|
+
f = !0;
|
|
11
|
+
let n = t.getVariant(i, a, o);
|
|
12
|
+
c(n), u(!0), t.trackContentExposure({
|
|
13
|
+
dictionaryKey: i,
|
|
14
|
+
keyPath: "",
|
|
15
|
+
nodeType: "experiment",
|
|
16
|
+
experimentKey: i,
|
|
17
|
+
variant: n
|
|
18
|
+
});
|
|
19
|
+
}).catch(() => {});
|
|
20
|
+
}), n(() => {
|
|
21
|
+
d = !0, import("../../esm-JsFWnEiY.mjs").then(({ stopAnalyticsClient: e }) => {
|
|
22
|
+
f && e();
|
|
23
|
+
}).catch(() => {});
|
|
24
|
+
}), {
|
|
25
|
+
variant: s,
|
|
26
|
+
isAssigned: l
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { i as useExperiment };
|
|
@@ -5,10 +5,10 @@ import { Suspense as o, createContext as s, createEffect as c, createMemo as l,
|
|
|
5
5
|
import { localeResolver as g } from "@intlayer/core/localization";
|
|
6
6
|
import { setIntlayerIdentifier as _ } from "@intlayer/config/client";
|
|
7
7
|
//#region src/client/IntlayerProvider.tsx
|
|
8
|
-
var v = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : d(() => import("../editor/EditorProvider.mjs").then((e) => ({ default: e.EditorProvider }))), y = s({
|
|
8
|
+
var v = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : d(() => import("../editor/EditorProvider.mjs").then((e) => ({ default: e.EditorProvider }))), y = process.env.INTLAYER_ANALYTICS_ENABLED === "false" ? null : d(() => import("../analytics/AnalyticsProvider.mjs").then((e) => ({ default: e.AnalyticsProvider }))), b = s({
|
|
9
9
|
locale: () => e ?? a?.defaultLocale,
|
|
10
10
|
setLocale: () => null
|
|
11
|
-
}),
|
|
11
|
+
}), x = () => h(b) ?? {}, S = (r) => {
|
|
12
12
|
let { defaultLocale: i, locales: o } = a ?? {}, [s, d] = u(r.locale ?? e ?? r.defaultLocale ?? i), h = r.setLocale ?? ((e) => {
|
|
13
13
|
if (s().toString() !== e.toString()) {
|
|
14
14
|
if (!o?.map(String).includes(e)) {
|
|
@@ -22,7 +22,7 @@ var v = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : d(() => import(
|
|
|
22
22
|
e && e !== m(s) && d(e);
|
|
23
23
|
}, { defer: !0 })), p(() => {
|
|
24
24
|
_();
|
|
25
|
-
}), n(
|
|
25
|
+
}), n(b.Provider, {
|
|
26
26
|
value: {
|
|
27
27
|
locale: v,
|
|
28
28
|
setLocale: h
|
|
@@ -31,10 +31,16 @@ var v = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : d(() => import(
|
|
|
31
31
|
return r.children;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
},
|
|
35
|
-
return [
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
}, C = (e) => n(S, i(e, { get children() {
|
|
35
|
+
return [
|
|
36
|
+
r(() => r(() => !!(process.env.INTLAYER_EDITOR_ENABLED !== "false" && v))() && n(o, { get children() {
|
|
37
|
+
return n(v, {});
|
|
38
|
+
} })),
|
|
39
|
+
r(() => r(() => !!(process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && y))() && n(o, { get children() {
|
|
40
|
+
return n(y, {});
|
|
41
|
+
} })),
|
|
42
|
+
r(() => e.children)
|
|
43
|
+
];
|
|
38
44
|
} }));
|
|
39
45
|
//#endregion
|
|
40
|
-
export {
|
|
46
|
+
export { b as IntlayerClientContext, C as IntlayerProvider, S as IntlayerProviderContent, x as useIntlayerContext };
|
|
@@ -52,7 +52,10 @@ var i = /* @__PURE__ */ function(e) {
|
|
|
52
52
|
let t = i.htmlTag;
|
|
53
53
|
if (t && typeof t.getAttribute == "function") {
|
|
54
54
|
let r = t.getAttribute("lang");
|
|
55
|
-
|
|
55
|
+
if (r) {
|
|
56
|
+
let t = n({ "accept-language": r }, e.locales, e.defaultLocale);
|
|
57
|
+
a.htmlTag = t;
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -12,4 +12,9 @@ import { useIntlayer as v } from "./client/useIntlayer.mjs";
|
|
|
12
12
|
import { useLocale as y } from "./client/useLocale.mjs";
|
|
13
13
|
import { useLocaleBase as b } from "./client/useLocaleBase.mjs";
|
|
14
14
|
import { useRewriteURL as x } from "./client/useRewriteURL.mjs";
|
|
15
|
-
|
|
15
|
+
import { useAnalytics as S } from "./analytics/useAnalytics.mjs";
|
|
16
|
+
import { AnalyticsProvider as C } from "./analytics/AnalyticsProvider.mjs";
|
|
17
|
+
import { useConversion as w } from "./analytics/useConversion.mjs";
|
|
18
|
+
import { useExperiment as T } from "./analytics/useExperiment.mjs";
|
|
19
|
+
import "./analytics/index.mjs";
|
|
20
|
+
export { C as AnalyticsProvider, u as IntlayerClientContext, d as IntlayerProvider, f as IntlayerProviderContent, r as getBrowserLocale, n as getDictionary, t as getIntlayer, i as localeCookie, a as localeInStorage, o as setLocaleCookie, s as setLocaleInStorage, m as t, S as useAnalytics, w as useConversion, h as useDictionary, g as useDictionaryAsync, _ as useDictionaryDynamic, T as useExperiment, v as useIntlayer, p as useIntlayerContext, e as useLoadDynamic, y as useLocale, b as useLocaleBase, c as useLocaleCookie, l as useLocaleStorage, x as useRewriteURL };
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,64 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { reportExposure as e } from "./analytics/exposureSink.mjs";
|
|
2
|
+
import { useLoadDynamic as t } from "./client/useLoadDynamic.mjs";
|
|
3
|
+
import { renderIntlayerNode as n } from "./IntlayerNode.mjs";
|
|
4
|
+
import { renderSolidElement as r } from "./solidElement/renderSolidElement.mjs";
|
|
5
|
+
import { createComponent as i, mergeProps as a } from "solid-js/web";
|
|
6
|
+
import { editor as o, internationalization as s } from "@intlayer/config/built";
|
|
7
|
+
import { conditionPlugin as c, enumerationPlugin as l, fallbackPlugin as u, filePlugin as d, genderPlugin as f, nestedPlugin as p, pluralPlugin as m, splitInsertionTemplate as h, translationPlugin as g } from "@intlayer/core/interpreter";
|
|
8
|
+
import { getMarkdownMetadata as _ } from "@intlayer/core/markdown";
|
|
9
|
+
import * as v from "@intlayer/types/nodeType";
|
|
10
|
+
import { Suspense as y, lazy as b } from "solid-js";
|
|
10
11
|
//#region src/plugins.tsx
|
|
11
|
-
var
|
|
12
|
+
var x = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : b(() => import("./editor/ContentSelector.mjs").then((e) => ({ default: e.ContentSelector }))), S = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? null : import("./markdown/MarkdownRenderer.mjs").then((e) => ({
|
|
12
13
|
MarkdownRenderer: e.MarkdownRenderer,
|
|
13
14
|
MarkdownMetadataRenderer: e.MarkdownMetadataRenderer
|
|
14
|
-
})),
|
|
15
|
+
})), C = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? null : import("./html/HTMLRenderer.mjs").then((e) => e.HTMLRenderer), w = {
|
|
15
16
|
id: "intlayer-node-plugin",
|
|
16
17
|
canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
|
|
17
|
-
transform: (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
transform: (t, { plugins: r, ...s }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
|
|
19
|
+
dictionaryKey: s.dictionaryKey,
|
|
20
|
+
keyPath: s.keyPath,
|
|
21
|
+
locale: s.locale,
|
|
22
|
+
nodeType: "text"
|
|
23
|
+
}), n({
|
|
24
|
+
...s,
|
|
25
|
+
value: s.children,
|
|
26
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && o.enabled ? i(y, {
|
|
21
27
|
get fallback() {
|
|
22
|
-
return
|
|
28
|
+
return s.children;
|
|
23
29
|
},
|
|
24
30
|
get children() {
|
|
25
|
-
return
|
|
26
|
-
return
|
|
31
|
+
return i(x, a(s, { get children() {
|
|
32
|
+
return s.children;
|
|
27
33
|
} }));
|
|
28
34
|
}
|
|
29
|
-
}) :
|
|
30
|
-
})
|
|
31
|
-
},
|
|
35
|
+
}) : s.children
|
|
36
|
+
}))
|
|
37
|
+
}, T = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? u : {
|
|
32
38
|
id: "solid-node-plugin",
|
|
33
39
|
canHandle: (e) => typeof e == "object" && e?.props !== void 0 || typeof Node < "u" && e instanceof Node,
|
|
34
|
-
transform: (
|
|
35
|
-
|
|
40
|
+
transform: (t, { plugins: s, ...c }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
|
|
41
|
+
dictionaryKey: c.dictionaryKey,
|
|
42
|
+
keyPath: c.keyPath,
|
|
43
|
+
locale: c.locale,
|
|
44
|
+
nodeType: "solid-node"
|
|
45
|
+
}), n({
|
|
46
|
+
...c,
|
|
36
47
|
value: "[[solid-element]]",
|
|
37
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
48
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && o.enabled ? i(y, {
|
|
38
49
|
get fallback() {
|
|
39
|
-
return typeof Node < "u" &&
|
|
50
|
+
return typeof Node < "u" && t instanceof Node ? t : r(t);
|
|
40
51
|
},
|
|
41
52
|
get children() {
|
|
42
|
-
return
|
|
43
|
-
return typeof Node < "u" &&
|
|
53
|
+
return i(x, a(c, { get children() {
|
|
54
|
+
return typeof Node < "u" && t instanceof Node ? t : r(t);
|
|
44
55
|
} }));
|
|
45
56
|
}
|
|
46
|
-
}) : typeof Node < "u" &&
|
|
47
|
-
})
|
|
48
|
-
},
|
|
49
|
-
let n =
|
|
57
|
+
}) : typeof Node < "u" && t instanceof Node ? t : r(t)
|
|
58
|
+
}))
|
|
59
|
+
}, E = (e, t) => {
|
|
60
|
+
let n = h(e, t);
|
|
50
61
|
return n.isSimple, n.parts;
|
|
51
|
-
},
|
|
62
|
+
}, D = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? u : {
|
|
52
63
|
id: "insertion-plugin",
|
|
53
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
64
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === v.INSERTION,
|
|
54
65
|
transform: (e, t, n) => {
|
|
55
|
-
let r = [...t.keyPath, { type:
|
|
66
|
+
let r = [...t.keyPath, { type: v.INSERTION }], i = e[v.INSERTION];
|
|
56
67
|
return (e) => {
|
|
57
68
|
let a = {
|
|
58
69
|
id: "insertion-string-plugin",
|
|
59
70
|
canHandle: (e) => typeof e == "string",
|
|
60
71
|
transform: (n, r, i) => {
|
|
61
|
-
let a =
|
|
72
|
+
let a = E(i(n, {
|
|
62
73
|
...r,
|
|
63
74
|
children: n,
|
|
64
75
|
plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
|
|
@@ -78,35 +89,35 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : y(() => import(
|
|
|
78
89
|
});
|
|
79
90
|
};
|
|
80
91
|
}
|
|
81
|
-
},
|
|
82
|
-
let { MarkdownRenderer: n } =
|
|
83
|
-
return
|
|
84
|
-
},
|
|
85
|
-
let { MarkdownMetadataRenderer: n } =
|
|
86
|
-
return
|
|
87
|
-
},
|
|
92
|
+
}, O = (e) => {
|
|
93
|
+
let { MarkdownRenderer: n } = t("solid-markdown-renderer", S);
|
|
94
|
+
return i(n, e);
|
|
95
|
+
}, k = (e) => {
|
|
96
|
+
let { MarkdownMetadataRenderer: n } = t("solid-markdown-renderer", S);
|
|
97
|
+
return i(n, e);
|
|
98
|
+
}, A = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? u : {
|
|
88
99
|
id: "markdown-string-plugin",
|
|
89
100
|
canHandle: (e) => typeof e == "string",
|
|
90
|
-
transform: (e,
|
|
91
|
-
let { plugins: s, ...c } =
|
|
101
|
+
transform: (e, t, r) => {
|
|
102
|
+
let { plugins: s, ...c } = t, l = r(_(e) ?? {}, {
|
|
92
103
|
plugins: [{
|
|
93
104
|
id: "markdown-metadata-plugin",
|
|
94
105
|
canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
|
|
95
|
-
transform: (
|
|
96
|
-
...
|
|
97
|
-
value:
|
|
98
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
99
|
-
return
|
|
100
|
-
return
|
|
106
|
+
transform: (t, r) => n({
|
|
107
|
+
...r,
|
|
108
|
+
value: t,
|
|
109
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && o.enabled ? i(y, { get children() {
|
|
110
|
+
return i(x, a(c, { get children() {
|
|
111
|
+
return i(k, a(c, {
|
|
101
112
|
get metadataKeyPath() {
|
|
102
|
-
return
|
|
113
|
+
return r.keyPath;
|
|
103
114
|
},
|
|
104
115
|
children: e
|
|
105
116
|
}));
|
|
106
117
|
} }));
|
|
107
|
-
} }) :
|
|
118
|
+
} }) : i(k, a(c, {
|
|
108
119
|
get metadataKeyPath() {
|
|
109
|
-
return
|
|
120
|
+
return r.keyPath;
|
|
110
121
|
},
|
|
111
122
|
children: e
|
|
112
123
|
}))
|
|
@@ -114,18 +125,18 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : y(() => import(
|
|
|
114
125
|
}],
|
|
115
126
|
dictionaryKey: c.dictionaryKey,
|
|
116
127
|
keyPath: []
|
|
117
|
-
}), u = (
|
|
118
|
-
...
|
|
128
|
+
}), u = (r) => n({
|
|
129
|
+
...t,
|
|
119
130
|
value: e,
|
|
120
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
121
|
-
return
|
|
122
|
-
return
|
|
123
|
-
components:
|
|
131
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && o.enabled ? i(y, { get children() {
|
|
132
|
+
return i(x, a(c, { get children() {
|
|
133
|
+
return i(O, a(c, {
|
|
134
|
+
components: r,
|
|
124
135
|
children: e
|
|
125
136
|
}));
|
|
126
137
|
} }));
|
|
127
|
-
} }) :
|
|
128
|
-
components:
|
|
138
|
+
} }) : i(O, a(c, {
|
|
139
|
+
components: r,
|
|
129
140
|
children: e
|
|
130
141
|
})),
|
|
131
142
|
additionalProps: { metadata: l }
|
|
@@ -140,65 +151,65 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : y(() => import(
|
|
|
140
151
|
return n === "metadata" ? l : n === "use" ? (e) => u(e) : Reflect.get(t, n, r);
|
|
141
152
|
} });
|
|
142
153
|
}
|
|
143
|
-
},
|
|
154
|
+
}, j = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? u : {
|
|
144
155
|
id: "markdown-plugin",
|
|
145
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
156
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === v.MARKDOWN,
|
|
146
157
|
transform: (e, t, n) => {
|
|
147
|
-
let r = [...t.keyPath, { type:
|
|
158
|
+
let r = [...t.keyPath, { type: v.MARKDOWN }], i = e[v.MARKDOWN];
|
|
148
159
|
return n(i, {
|
|
149
160
|
...t,
|
|
150
161
|
children: i,
|
|
151
162
|
keyPath: r,
|
|
152
|
-
plugins: [
|
|
163
|
+
plugins: [A, ...t.plugins ?? []]
|
|
153
164
|
});
|
|
154
165
|
}
|
|
155
|
-
},
|
|
166
|
+
}, M = (e) => i(t("solid-html-renderer", C), e), N = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? u : {
|
|
156
167
|
id: "html-plugin",
|
|
157
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
158
|
-
transform: (e,
|
|
159
|
-
let
|
|
168
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === v.HTML,
|
|
169
|
+
transform: (e, t) => {
|
|
170
|
+
let r = e[v.HTML], { plugins: s, ...c } = t, l = (e) => n({
|
|
160
171
|
...c,
|
|
161
|
-
value:
|
|
162
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" &&
|
|
163
|
-
return
|
|
164
|
-
return
|
|
165
|
-
html:
|
|
172
|
+
value: r,
|
|
173
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && o.enabled ? i(y, { get children() {
|
|
174
|
+
return i(x, a(c, { get children() {
|
|
175
|
+
return i(M, a(c, {
|
|
176
|
+
html: r,
|
|
166
177
|
components: e
|
|
167
178
|
}));
|
|
168
179
|
} }));
|
|
169
|
-
} }) :
|
|
170
|
-
html:
|
|
180
|
+
} }) : i(M, a(c, {
|
|
181
|
+
html: r,
|
|
171
182
|
components: e
|
|
172
183
|
}))
|
|
173
184
|
}), u = [l()];
|
|
174
185
|
return new Proxy(u, { get(e, t, n) {
|
|
175
|
-
if (t === "value") return
|
|
176
|
-
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") return () =>
|
|
186
|
+
if (t === "value") return r;
|
|
187
|
+
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") return () => r;
|
|
177
188
|
if (typeof t == "string" && t !== "constructor") {
|
|
178
189
|
let e = String.prototype[t];
|
|
179
|
-
if (typeof e == "function") return e.bind(
|
|
190
|
+
if (typeof e == "function") return e.bind(r);
|
|
180
191
|
}
|
|
181
192
|
return t === "use" ? (e) => l(e) : Reflect.get(e, t, n);
|
|
182
193
|
} });
|
|
183
194
|
}
|
|
184
|
-
},
|
|
185
|
-
let n = `${e ??
|
|
186
|
-
if (
|
|
195
|
+
}, P = /* @__PURE__ */ new Map(), F = (e, t = !0) => {
|
|
196
|
+
let n = `${e ?? s.defaultLocale}_${t}`;
|
|
197
|
+
if (P.has(n)) return P.get(n);
|
|
187
198
|
let r = [
|
|
188
|
-
|
|
199
|
+
g(e ?? s.defaultLocale, t ? s.defaultLocale : void 0),
|
|
200
|
+
l,
|
|
201
|
+
m(e ?? s.defaultLocale),
|
|
189
202
|
c,
|
|
190
|
-
p(e ??
|
|
191
|
-
s,
|
|
192
|
-
f(e ?? o.defaultLocale),
|
|
193
|
-
u,
|
|
203
|
+
p(e ?? s.defaultLocale),
|
|
194
204
|
d,
|
|
195
|
-
|
|
205
|
+
f,
|
|
196
206
|
w,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
T,
|
|
208
|
+
D,
|
|
209
|
+
j,
|
|
210
|
+
N
|
|
200
211
|
];
|
|
201
|
-
return
|
|
212
|
+
return P.set(n, r), r;
|
|
202
213
|
};
|
|
203
214
|
//#endregion
|
|
204
|
-
export {
|
|
215
|
+
export { F as getPlugins, N as htmlPlugin, D as insertionPlugin, w as intlayerNodePlugins, j as markdownPlugin, A as markdownStringPlugin, T as solidNodePlugins };
|
|
@@ -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.tsx` 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 unmount.
|
|
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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initializes the Intlayer analytics client singleton when analytics is enabled
|
|
3
|
+
* and keeps it aware of the current locale.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
|
|
6
|
+
* ships as its own async chunk, off the critical rendering path. Apps that
|
|
7
|
+
* don't opt in (`analytics.enabled !== true`) pay nothing — the whole body is
|
|
8
|
+
* guarded by `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build
|
|
9
|
+
* time.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useAnalytics: () => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
* ```tsx
|
|
21
|
+
* const trackConversion = useConversion();
|
|
22
|
+
* <button onClick={() => trackConversion({
|
|
23
|
+
* experimentKey: 'homepage-hero', variant: 'b', goal: 'cta_click',
|
|
24
|
+
* })}>Get started</button>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const useConversion: () => (params: ConversionParams) => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
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: Accessor<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: Accessor<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
|
+
* ```tsx
|
|
34
|
+
* const { variant } = useExperiment('homepage-hero', ['a', 'b']);
|
|
35
|
+
* const content = useIntlayer(variant() === 'b' ? 'hero-b' : 'hero');
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare module '@intlayer/core/interpreter' {
|
|
|
4
4
|
interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginSolid<T, S, L> {
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
export { AnalyticsProvider, type ConversionParams, type ExperimentState, useAnalytics, useConversion, useExperiment, } from './analytics/index';
|
|
7
8
|
export { getBrowserLocale, IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, type IntlayerProviderProps, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage, useRewriteURL, } from './client/index';
|
|
8
9
|
export { getDictionary } from './getDictionary';
|
|
9
10
|
export { getIntlayer } from './getIntlayer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-intlayer",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@intlayer/api": "9.0.0-canary.
|
|
117
|
-
"@intlayer/config": "9.0.0-canary.
|
|
118
|
-
"@intlayer/core": "9.0.0-canary.
|
|
119
|
-
"@intlayer/editor": "9.0.0-canary.
|
|
120
|
-
"@intlayer/types": "9.0.0-canary.
|
|
116
|
+
"@intlayer/api": "9.0.0-canary.17",
|
|
117
|
+
"@intlayer/config": "9.0.0-canary.17",
|
|
118
|
+
"@intlayer/core": "9.0.0-canary.17",
|
|
119
|
+
"@intlayer/editor": "9.0.0-canary.17",
|
|
120
|
+
"@intlayer/types": "9.0.0-canary.17"
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
123
|
"@solidjs/testing-library": "0.8.10",
|
|
@@ -131,14 +131,17 @@
|
|
|
131
131
|
"rimraf": "6.1.3",
|
|
132
132
|
"tsdown": "0.21.10",
|
|
133
133
|
"typescript": "6.0.3",
|
|
134
|
-
"vite": "8.1.
|
|
134
|
+
"vite": "8.1.4",
|
|
135
135
|
"vite-plugin-dts": "5.0.3",
|
|
136
136
|
"vite-plugin-solid": "2.11.12",
|
|
137
|
-
"vitest": "4.1.
|
|
137
|
+
"vitest": "4.1.10"
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
140
|
"solid-js": ">=1.0.0"
|
|
141
141
|
},
|
|
142
|
+
"optionalDependencies": {
|
|
143
|
+
"@intlayer/analytics": "9.0.0-canary.17"
|
|
144
|
+
},
|
|
142
145
|
"engines": {
|
|
143
146
|
"node": ">=14.18"
|
|
144
147
|
},
|