solid-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.
- 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/client/index.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useLoadDynamic.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/client/index.mjs +8 -8
- package/dist/esm/client/useDictionaryDynamic.mjs +11 -11
- package/dist/esm/client/useLoadDynamic.mjs +28 -25
- package/dist/esm/editor/useEditor.mjs +2 -1
- package/dist/esm/index.mjs +15 -10
- package/dist/esm/plugins.mjs +79 -74
- 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 +18 -14
|
@@ -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("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./getBrowserLocale.cjs"),t=require("./useLocaleStorage.cjs"),n=require("./IntlayerProvider.cjs"),r=require("./t.cjs"),i=require("./useDictionary.cjs"),a=require("./useDictionaryAsync.cjs"),o=require("./useLoadDynamic.cjs"),s=require("./useDictionaryDynamic.cjs"),c=require("./useIntlayer.cjs"),l=require("./useLocale.cjs"),u=require("./useLocaleBase.cjs"),d=require("./usePathname.cjs"),f=require("./useRewriteURL.cjs");exports.IntlayerClientContext=n.IntlayerClientContext,exports.IntlayerProvider=n.IntlayerProvider,exports.IntlayerProviderContent=n.IntlayerProviderContent,exports.getBrowserLocale=e.getBrowserLocale,exports.localeCookie=t.localeCookie,exports.localeInStorage=t.localeInStorage,exports.setLocaleCookie=t.setLocaleCookie,exports.setLocaleInStorage=t.setLocaleInStorage,exports.t=r.t,exports.useDictionary=i.useDictionary,exports.useDictionaryAsync=a.useDictionaryAsync,exports.useDictionaryDynamic=s.useDictionaryDynamic,exports.useIntlayer=c.useIntlayer,exports.useIntlayerContext=n.useIntlayerContext,exports.useLoadDynamic=o.useLoadDynamic,exports.useLocale=l.useLocale,exports.useLocaleBase=u.useLocaleBase,exports.useLocaleCookie=t.useLocaleCookie,exports.useLocaleStorage=t.useLocaleStorage,exports.usePathname=d.usePathname,exports.useRewriteURL=f.useRewriteURL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./IntlayerProvider.cjs"),n=require("./useDictionary.cjs"),r=require("./useLoadDynamic.cjs");let i=require("@intlayer/config/built"),a=require("solid-js"),o=require("@intlayer/core/dictionaryManipulator");var s=(s,c,l)=>{let{locale:u}=(0,a.useContext)(t.IntlayerClientContext)??{},d=i.internationalization.defaultLocale,f=String(c);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,o.isQualifiedDynamicLoaderMap)(s)){let{locale:t,selector:i}=(0,o.parseDictionarySelector)(l),c=(0,o.getDictionarySelectorCacheKey)(i),p=s[o.QUALIFIER_DYNAMIC_TYPES_KEY].includes(`item`)&&i?.item===void 0,m=()=>t??u?.()??d;if(!p)return n.useDictionary(r.useLoadDynamic(()=>{let e=m();return{cacheKey:`${f}.${e}.${c}`,locale:e}},({locale:e})=>(0,o.resolveQualifiedDynamicContentAsync)({loaderMap:s,key:f,locale:e,selector:i,transform:e=>e}).then(e=>Array.isArray(e)?e[0]:e)),t);let[h]=(0,a.createResource)(m,e=>(0,o.resolveQualifiedDynamicContentAsync)({loaderMap:s,key:f,locale:e,selector:i,transform:e=>e})),g=(0,a.createMemo)(()=>{let t=h(),n=m();return Array.isArray(t)?t.map(t=>e.getDictionary(t,n)):[]});return(0,a.createRenderEffect)(()=>{h()}),new Proxy(g,{get(e,t){return e()?.[t]},apply(e){return e()}})}let p=s,m=l,h=()=>m??u?.()??d;return n.useDictionary(r.useLoadDynamic(()=>{let e=h();return{cacheKey:`${f}.${e}`,locale:e}},({locale:e})=>{let t=p[e];return t?t():Promise.reject(Error(`No dynamic dictionary loader found for key "${f}" and locale "${e}".`))}),m)};exports.useDictionaryDynamic=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../proxyKeys.cjs");let t=require("solid-js");var n=Symbol(`NO_PENDING_PRIMITIVE_FALLBACK`),r=new Map,i=e=>typeof e==`string`?e:e.cacheKey,a=(e,t)=>t.reduce((e,t)=>{if(e!=null)return Reflect.get(Object(e),t)},e),o=(e,t)=>typeof e==`function`?e(t):e,s=(e,t)=>{let n=i(e),a=r.get(n);if(a?.status===`success`)return a.value;if(a?.status===`pending`)return a.promise;let s=o(t,e).then(e=>(r.set(n,{status:`success`,value:e}),e),e=>{throw r.delete(n),e});return r.set(n,{status:`pending`,promise:s}),s},c=(e,t)=>typeof t==`function`?t.bind(e):t,l=t=>t===Symbol.toPrimitive?()=>``:t===Symbol.iterator?()=>({next:()=>({done:!0,value:void 0})}):t===`length`?0:t===e.PROXY_RESERVED_KEYS.toString?()=>``:t===e.PROXY_RESERVED_KEYS.valueOf?()=>void 0:t===e.PROXY_RESERVED_KEYS.value?``:n,u=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../proxyKeys.cjs");let t=require("solid-js");var n=Symbol(`NO_PENDING_PRIMITIVE_FALLBACK`),r=new Map,i=e=>typeof e==`string`?e:e.cacheKey,a=(e,t)=>t.reduce((e,t)=>{if(e!=null)return Reflect.get(Object(e),t)},e),o=(e,t)=>typeof e==`function`?e(t):e,s=(e,t)=>{let n=i(e),a=r.get(n);if(a?.status===`success`)return a.value;if(a?.status===`pending`)return a.promise;let s=o(t,e).then(e=>(r.set(n,{status:`success`,value:e}),e),e=>{throw r.delete(n),e});return r.set(n,{status:`pending`,promise:s}),s},c=(e,t)=>typeof t==`function`?t.bind(e):t,l=t=>t===Symbol.toPrimitive?()=>``:t===Symbol.iterator?()=>({next:()=>({done:!0,value:void 0})}):t===`length`?0:t===e.PROXY_RESERVED_KEYS.toString?()=>``:t===e.PROXY_RESERVED_KEYS.valueOf?()=>void 0:t===e.PROXY_RESERVED_KEYS.value?``:n,u=r=>{let i=o=>new Proxy(()=>void 0,{get(t,s){if(s===e.PROXY_RESERVED_KEYS.promiseThen)return;let u=a(r(),o);if(u!=null)return s===Symbol.toPrimitive?()=>u:c(u,Reflect.get(Object(u),s));let d=l(s);return d===n?i([...o,s]):d},apply(e,n,i){let s=a(r(),o);return typeof s==`function`?Reflect.apply(s,n,i):i.length===0?s??``:u(()=>{let e=a(r(),o);if(typeof e==`function`)return(0,t.untrack)(()=>Reflect.apply(e,n,i))})}});return i([])},d=(e,n)=>{let[r]=(0,t.createResource)(()=>typeof e==`function`?e():e,e=>s(e,n));return(0,t.createRenderEffect)(()=>{r()}),u(()=>r())};exports.createLoadableProxy=u,exports.getDynamicSourceCacheKey=i,exports.loadDynamicValue=s,exports.useLoadDynamic=d;
|
|
@@ -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("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./getIntlayer.cjs"),t=require("./getDictionary.cjs"),n=require("./client/getBrowserLocale.cjs"),r=require("./client/useLocaleStorage.cjs"),i=require("./client/IntlayerProvider.cjs"),a=require("./client/t.cjs"),o=require("./client/useDictionary.cjs"),s=require("./client/useDictionaryAsync.cjs"),c=require("./client/useLoadDynamic.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=i.IntlayerClientContext,exports.IntlayerProvider=i.IntlayerProvider,exports.IntlayerProviderContent=i.IntlayerProviderContent,exports.getBrowserLocale=n.getBrowserLocale,exports.getDictionary=t.getDictionary,exports.getIntlayer=e.getIntlayer,exports.localeCookie=r.localeCookie,exports.localeInStorage=r.localeInStorage,exports.setLocaleCookie=r.setLocaleCookie,exports.setLocaleInStorage=r.setLocaleInStorage,exports.t=a.t,exports.useAnalytics=m.useAnalytics,exports.useConversion=g.useConversion,exports.useDictionary=o.useDictionary,exports.useDictionaryAsync=s.useDictionaryAsync,exports.useDictionaryDynamic=l.useDictionaryDynamic,exports.useExperiment=_.useExperiment,exports.useIntlayer=u.useIntlayer,exports.useIntlayerContext=i.useIntlayerContext,exports.useLoadDynamic=c.useLoadDynamic,exports.useLocale=d.useLocale,exports.useLocaleBase=f.useLocaleBase,exports.useLocaleCookie=r.useLocaleCookie,exports.useLocaleStorage=r.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("./
|
|
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("./IntlayerNode.cjs"),u=require("./solidElement/renderSolidElement.cjs");let d=require("solid-js/web"),f=require("@intlayer/config/built"),p=require("@intlayer/core/interpreter"),m=require("@intlayer/core/markdown"),h=require("@intlayer/types/nodeType");h=s(h);let g=require("solid-js");var _=process.env.INTLAYER_EDITOR_ENABLED===`false`?null:(0,g.lazy)(()=>Promise.resolve().then(()=>require("./editor/ContentSelector.cjs")).then(e=>({default:e.ContentSelector}))),v=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?null:Promise.resolve().then(()=>require("./markdown/MarkdownRenderer.cjs")).then(e=>({MarkdownRenderer:e.MarkdownRenderer,MarkdownMetadataRenderer:e.MarkdownMetadataRenderer})),y=process.env.INTLAYER_NODE_TYPE_HTML===`false`?null:Promise.resolve().then(()=>require("./html/HTMLRenderer.cjs")).then(e=>e.HTMLRenderer),b={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`}),l.renderIntlayerNode({...n,value:n.children,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?(0,d.createComponent)(g.Suspense,{get fallback(){return n.children},get children(){return(0,d.createComponent)(_,(0,d.mergeProps)(n,{get children(){return n.children}}))}}):n.children}))},x=process.env.INTLAYER_NODE_TYPE_SOLID_NODE===`false`?p.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`}),l.renderIntlayerNode({...n,value:`[[solid-element]]`,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?(0,d.createComponent)(g.Suspense,{get fallback(){return typeof Node<`u`&&e instanceof Node?e:u.renderSolidElement(e)},get children(){return(0,d.createComponent)(_,(0,d.mergeProps)(n,{get children(){return typeof Node<`u`&&e instanceof Node?e:u.renderSolidElement(e)}}))}}):typeof Node<`u`&&e instanceof Node?e:u.renderSolidElement(e)}))},S=(e,t)=>{let n=(0,p.splitInsertionTemplate)(e,t);return n.isSimple,n.parts},C=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?p.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];return e=>{let a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`||(0,p.isInterpolableWrapperNode)(e),transform:(n,r,i)=>{if((0,p.isInterpolableWrapperNode)(n))return(0,p.transformInterpolableNode)(n,e,r,t.plugins,i);let a=S(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??[]]})}}},w=(0,g.lazy)(()=>v.then(e=>({default:e.MarkdownRenderer}))),T=(0,g.lazy)(()=>v.then(e=>({default:e.MarkdownMetadataRenderer}))),E=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,m.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>l.renderIntlayerNode({...n,value:t,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?(0,d.createComponent)(g.Suspense,{get children(){return(0,d.createComponent)(_,(0,d.mergeProps)(i,{get children(){return(0,d.createComponent)(T,(0,d.mergeProps)(i,{get metadataKeyPath(){return n.keyPath},children:e}))}}))}}):(0,d.createComponent)(T,(0,d.mergeProps)(i,{get metadataKeyPath(){return n.keyPath},children:e}))})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>l.renderIntlayerNode({...t,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?(0,d.createComponent)(g.Suspense,{get children(){return(0,d.createComponent)(_,(0,d.mergeProps)(i,{get children(){return(0,d.createComponent)(w,(0,d.mergeProps)(i,{components:n,children:e}))}}))}}):(0,d.createComponent)(w,(0,d.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)}})}},D=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?p.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:[E,...t.plugins??[]]})}},O=(0,g.lazy)(()=>y.then(e=>({default:e}))),k=process.env.INTLAYER_NODE_TYPE_HTML===`false`?p.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.HTML,transform:(e,t)=>{let n=e[h.HTML],{plugins:r,children:i,...a}=t,o=e=>l.renderIntlayerNode({...a,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&f.editor.enabled?(0,d.createComponent)(g.Suspense,{get children(){return(0,d.createComponent)(_,(0,d.mergeProps)(a,{get children(){return(0,d.createComponent)(O,(0,d.mergeProps)(a,{html:n,components:e}))}}))}}):(0,d.createComponent)(O,(0,d.mergeProps)(a,{html:n,components:e}))}),s=[o()];return new Proxy(s,{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=>o(e):Reflect.get(e,t,r)}})}},A=new Map,j=(e,t=!0)=>{let n=`${e??f.internationalization.defaultLocale}_${t}`;if(A.has(n))return A.get(n);let r=[(0,p.translationPlugin)(e??f.internationalization.defaultLocale,t?f.internationalization.defaultLocale:void 0),p.enumerationPlugin,(0,p.pluralPlugin)(e??f.internationalization.defaultLocale),p.conditionPlugin,(0,p.nestedPlugin)(e??f.internationalization.defaultLocale),p.filePlugin,p.genderPlugin,b,x,C,D,k];return A.set(n,r),r};exports.getPlugins=j,exports.htmlPlugin=k,exports.insertionPlugin=C,exports.intlayerNodePlugins=b,exports.markdownPlugin=D,exports.markdownStringPlugin=E,exports.solidNodePlugins=x;
|
|
@@ -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
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { getBrowserLocale as e } from "./getBrowserLocale.mjs";
|
|
2
|
+
import { localeCookie as t, localeInStorage as n, setLocaleCookie as r, setLocaleInStorage as i, useLocaleCookie as a, useLocaleStorage as o } from "./useLocaleStorage.mjs";
|
|
3
|
+
import { IntlayerClientContext as s, IntlayerProvider as c, IntlayerProviderContent as l, useIntlayerContext as u } from "./IntlayerProvider.mjs";
|
|
4
|
+
import { t as d } from "./t.mjs";
|
|
5
|
+
import { useDictionary as f } from "./useDictionary.mjs";
|
|
6
|
+
import { useDictionaryAsync as p } from "./useDictionaryAsync.mjs";
|
|
7
|
+
import { useLoadDynamic as m } from "./useLoadDynamic.mjs";
|
|
8
8
|
import { useDictionaryDynamic as h } from "./useDictionaryDynamic.mjs";
|
|
9
9
|
import { useIntlayer as g } from "./useIntlayer.mjs";
|
|
10
10
|
import { useLocale as _ } from "./useLocale.mjs";
|
|
11
11
|
import { useLocaleBase as v } from "./useLocaleBase.mjs";
|
|
12
12
|
import { usePathname as y } from "./usePathname.mjs";
|
|
13
13
|
import { useRewriteURL as b } from "./useRewriteURL.mjs";
|
|
14
|
-
export {
|
|
14
|
+
export { s as IntlayerClientContext, c as IntlayerProvider, l as IntlayerProviderContent, e as getBrowserLocale, t as localeCookie, n as localeInStorage, r as setLocaleCookie, i as setLocaleInStorage, d as t, f as useDictionary, p as useDictionaryAsync, h as useDictionaryDynamic, g as useIntlayer, u as useIntlayerContext, m as useLoadDynamic, _ as useLocale, v as useLocaleBase, a as useLocaleCookie, o as useLocaleStorage, y as usePathname, b as useRewriteURL };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { getDictionary as e } from "../getDictionary.mjs";
|
|
2
|
+
import { IntlayerClientContext as t } from "./IntlayerProvider.mjs";
|
|
3
|
+
import { useDictionary as n } from "./useDictionary.mjs";
|
|
4
|
+
import { useLoadDynamic as r } from "./useLoadDynamic.mjs";
|
|
5
5
|
import { internationalization as i } from "@intlayer/config/built";
|
|
6
6
|
import { createMemo as a, createRenderEffect as o, createResource as s, useContext as c } from "solid-js";
|
|
7
7
|
import { QUALIFIER_DYNAMIC_TYPES_KEY as l, getDictionarySelectorCacheKey as u, isQualifiedDynamicLoaderMap as d, parseDictionarySelector as f, resolveQualifiedDynamicContentAsync as p } from "@intlayer/core/dictionaryManipulator";
|
|
8
8
|
//#region src/client/useDictionaryDynamic.ts
|
|
9
9
|
var m = (m, h, g) => {
|
|
10
|
-
let { locale: _ } = c(
|
|
10
|
+
let { locale: _ } = c(t) ?? {}, v = i.defaultLocale, y = String(h);
|
|
11
11
|
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && d(m)) {
|
|
12
|
-
let { locale:
|
|
13
|
-
if (!d) return r(
|
|
12
|
+
let { locale: t, selector: i } = f(g), c = u(i), d = m[l].includes("item") && i?.item === void 0, h = () => t ?? _?.() ?? v;
|
|
13
|
+
if (!d) return n(r(() => {
|
|
14
14
|
let e = h();
|
|
15
15
|
return {
|
|
16
16
|
cacheKey: `${y}.${e}.${c}`,
|
|
@@ -22,7 +22,7 @@ var m = (m, h, g) => {
|
|
|
22
22
|
locale: e,
|
|
23
23
|
selector: i,
|
|
24
24
|
transform: (e) => e
|
|
25
|
-
}).then((e) => Array.isArray(e) ? e[0] : e)),
|
|
25
|
+
}).then((e) => Array.isArray(e) ? e[0] : e)), t);
|
|
26
26
|
let [b] = s(h, (e) => p({
|
|
27
27
|
loaderMap: m,
|
|
28
28
|
key: y,
|
|
@@ -30,8 +30,8 @@ var m = (m, h, g) => {
|
|
|
30
30
|
selector: i,
|
|
31
31
|
transform: (e) => e
|
|
32
32
|
})), x = a(() => {
|
|
33
|
-
let
|
|
34
|
-
return Array.isArray(
|
|
33
|
+
let t = b(), n = h();
|
|
34
|
+
return Array.isArray(t) ? t.map((t) => e(t, n)) : [];
|
|
35
35
|
});
|
|
36
36
|
return o(() => {
|
|
37
37
|
b();
|
|
@@ -45,7 +45,7 @@ var m = (m, h, g) => {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
let b = m, x = g, S = () => x ?? _?.() ?? v;
|
|
48
|
-
return r(
|
|
48
|
+
return n(r(() => {
|
|
49
49
|
let e = S();
|
|
50
50
|
return {
|
|
51
51
|
cacheKey: `${y}.${e}`,
|
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
import { PROXY_RESERVED_KEYS as e } from "../proxyKeys.mjs";
|
|
2
|
-
import { createRenderEffect as t, createResource as n } from "solid-js";
|
|
2
|
+
import { createRenderEffect as t, createResource as n, untrack as r } from "solid-js";
|
|
3
3
|
//#region src/client/useLoadDynamic.ts
|
|
4
|
-
var
|
|
4
|
+
var i = Symbol("NO_PENDING_PRIMITIVE_FALLBACK"), a = /* @__PURE__ */ new Map(), o = (e) => typeof e == "string" ? e : e.cacheKey, s = (e, t) => t.reduce((e, t) => {
|
|
5
5
|
if (e != null) return Reflect.get(Object(e), t);
|
|
6
|
-
}, e),
|
|
7
|
-
let n =
|
|
6
|
+
}, e), c = (e, t) => typeof e == "function" ? e(t) : e, l = (e, t) => {
|
|
7
|
+
let n = o(e), r = a.get(n);
|
|
8
8
|
if (r?.status === "success") return r.value;
|
|
9
9
|
if (r?.status === "pending") return r.promise;
|
|
10
|
-
let
|
|
10
|
+
let i = c(t, e).then((e) => (a.set(n, {
|
|
11
11
|
status: "success",
|
|
12
12
|
value: e
|
|
13
13
|
}), e), (e) => {
|
|
14
|
-
throw
|
|
14
|
+
throw a.delete(n), e;
|
|
15
15
|
});
|
|
16
|
-
return
|
|
16
|
+
return a.set(n, {
|
|
17
17
|
status: "pending",
|
|
18
|
-
promise:
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
18
|
+
promise: i
|
|
19
|
+
}), i;
|
|
20
|
+
}, u = (e, t) => typeof t == "function" ? t.bind(e) : t, d = (t) => t === Symbol.toPrimitive ? () => "" : t === Symbol.iterator ? () => ({ next: () => ({
|
|
21
21
|
done: !0,
|
|
22
22
|
value: void 0
|
|
23
|
-
}) }) : t === "length" ? 0 : t === e.toString ? () => "" : t === e.valueOf ? () => void 0 : t === e.value ? "" :
|
|
24
|
-
let n = (
|
|
25
|
-
get(
|
|
26
|
-
if (
|
|
27
|
-
let c =
|
|
28
|
-
if (c != null) return
|
|
29
|
-
let
|
|
30
|
-
return
|
|
23
|
+
}) }) : t === "length" ? 0 : t === e.toString ? () => "" : t === e.valueOf ? () => void 0 : t === e.value ? "" : i, f = (t) => {
|
|
24
|
+
let n = (a) => new Proxy(() => void 0, {
|
|
25
|
+
get(r, o) {
|
|
26
|
+
if (o === e.promiseThen) return;
|
|
27
|
+
let c = s(t(), a);
|
|
28
|
+
if (c != null) return o === Symbol.toPrimitive ? () => c : u(c, Reflect.get(Object(c), o));
|
|
29
|
+
let l = d(o);
|
|
30
|
+
return l === i ? n([...a, o]) : l;
|
|
31
31
|
},
|
|
32
|
-
apply(e,
|
|
33
|
-
let
|
|
34
|
-
return typeof
|
|
32
|
+
apply(e, n, i) {
|
|
33
|
+
let o = s(t(), a);
|
|
34
|
+
return typeof o == "function" ? Reflect.apply(o, n, i) : i.length === 0 ? o ?? "" : f(() => {
|
|
35
|
+
let e = s(t(), a);
|
|
36
|
+
if (typeof e == "function") return r(() => Reflect.apply(e, n, i));
|
|
37
|
+
});
|
|
35
38
|
}
|
|
36
39
|
});
|
|
37
40
|
return n([]);
|
|
38
|
-
},
|
|
39
|
-
let [i] = n(() => typeof e == "function" ? e() : e, (e) =>
|
|
41
|
+
}, p = (e, r) => {
|
|
42
|
+
let [i] = n(() => typeof e == "function" ? e() : e, (e) => l(e, r));
|
|
40
43
|
return t(() => {
|
|
41
44
|
i();
|
|
42
|
-
}),
|
|
45
|
+
}), f(() => i());
|
|
43
46
|
};
|
|
44
47
|
//#endregion
|
|
45
|
-
export {
|
|
48
|
+
export { f as createLoadableProxy, o as getDynamicSourceCacheKey, l as loadDynamicValue, p as useLoadDynamic };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { getIntlayer as e } from "./getIntlayer.mjs";
|
|
2
|
+
import { getDictionary as t } from "./getDictionary.mjs";
|
|
3
|
+
import { getBrowserLocale as n } from "./client/getBrowserLocale.mjs";
|
|
4
|
+
import { localeCookie as r, localeInStorage as i, setLocaleCookie as a, setLocaleInStorage as o, useLocaleCookie as s, useLocaleStorage as c } from "./client/useLocaleStorage.mjs";
|
|
5
|
+
import { IntlayerClientContext as l, IntlayerProvider as u, IntlayerProviderContent as d, useIntlayerContext as f } from "./client/IntlayerProvider.mjs";
|
|
6
|
+
import { t as p } from "./client/t.mjs";
|
|
7
|
+
import { useDictionary as m } from "./client/useDictionary.mjs";
|
|
8
|
+
import { useDictionaryAsync as h } from "./client/useDictionaryAsync.mjs";
|
|
9
|
+
import { useLoadDynamic as g } from "./client/useLoadDynamic.mjs";
|
|
10
10
|
import { useDictionaryDynamic as _ } from "./client/useDictionaryDynamic.mjs";
|
|
11
11
|
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, l as IntlayerClientContext, u as IntlayerProvider, d as IntlayerProviderContent, n as getBrowserLocale, t as getDictionary, e as getIntlayer, r as localeCookie, i as localeInStorage, a as setLocaleCookie, o as setLocaleInStorage, p as t, S as useAnalytics, w as useConversion, m as useDictionary, h as useDictionaryAsync, _ as useDictionaryDynamic, T as useExperiment, v as useIntlayer, f as useIntlayerContext, g as useLoadDynamic, y as useLocale, b as useLocaleBase, s as useLocaleCookie, c as useLocaleStorage, x as useRewriteURL };
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,64 +1,75 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reportExposure as e } from "./analytics/exposureSink.mjs";
|
|
2
2
|
import { renderIntlayerNode as t } from "./IntlayerNode.mjs";
|
|
3
3
|
import { renderSolidElement as n } from "./solidElement/renderSolidElement.mjs";
|
|
4
4
|
import { createComponent as r, mergeProps as i } from "solid-js/web";
|
|
5
5
|
import { editor as a, internationalization as o } from "@intlayer/config/built";
|
|
6
|
-
import { conditionPlugin as s, enumerationPlugin as c, fallbackPlugin as l, filePlugin as u, genderPlugin as d,
|
|
7
|
-
import { getMarkdownMetadata as
|
|
8
|
-
import * as
|
|
9
|
-
import { Suspense as
|
|
6
|
+
import { conditionPlugin as s, enumerationPlugin as c, fallbackPlugin as l, filePlugin as u, genderPlugin as d, isInterpolableWrapperNode as f, nestedPlugin as p, pluralPlugin as m, splitInsertionTemplate as h, transformInterpolableNode as g, translationPlugin as _ } from "@intlayer/core/interpreter";
|
|
7
|
+
import { getMarkdownMetadata as v } from "@intlayer/core/markdown";
|
|
8
|
+
import * as y from "@intlayer/types/nodeType";
|
|
9
|
+
import { Suspense as b, lazy as x } from "solid-js";
|
|
10
10
|
//#region src/plugins.tsx
|
|
11
|
-
var
|
|
11
|
+
var S = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : x(() => import("./editor/ContentSelector.mjs").then((e) => ({ default: e.ContentSelector }))), C = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? null : import("./markdown/MarkdownRenderer.mjs").then((e) => ({
|
|
12
12
|
MarkdownRenderer: e.MarkdownRenderer,
|
|
13
13
|
MarkdownMetadataRenderer: e.MarkdownMetadataRenderer
|
|
14
|
-
})),
|
|
14
|
+
})), w = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? null : import("./html/HTMLRenderer.mjs").then((e) => e.HTMLRenderer), T = {
|
|
15
15
|
id: "intlayer-node-plugin",
|
|
16
16
|
canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
|
|
17
|
-
transform: (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
transform: (n, { plugins: o, ...s }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
|
|
18
|
+
dictionaryKey: s.dictionaryKey,
|
|
19
|
+
keyPath: s.keyPath,
|
|
20
|
+
locale: s.locale,
|
|
21
|
+
nodeType: "text"
|
|
22
|
+
}), t({
|
|
23
|
+
...s,
|
|
24
|
+
value: s.children,
|
|
25
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(b, {
|
|
21
26
|
get fallback() {
|
|
22
|
-
return
|
|
27
|
+
return s.children;
|
|
23
28
|
},
|
|
24
29
|
get children() {
|
|
25
|
-
return r(
|
|
26
|
-
return
|
|
30
|
+
return r(S, i(s, { get children() {
|
|
31
|
+
return s.children;
|
|
27
32
|
} }));
|
|
28
33
|
}
|
|
29
|
-
}) :
|
|
30
|
-
})
|
|
31
|
-
},
|
|
34
|
+
}) : s.children
|
|
35
|
+
}))
|
|
36
|
+
}, E = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? l : {
|
|
32
37
|
id: "solid-node-plugin",
|
|
33
38
|
canHandle: (e) => typeof e == "object" && e?.props !== void 0 || typeof Node < "u" && e instanceof Node,
|
|
34
|
-
transform: (
|
|
35
|
-
|
|
39
|
+
transform: (o, { plugins: s, ...c }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
|
|
40
|
+
dictionaryKey: c.dictionaryKey,
|
|
41
|
+
keyPath: c.keyPath,
|
|
42
|
+
locale: c.locale,
|
|
43
|
+
nodeType: "solid-node"
|
|
44
|
+
}), t({
|
|
45
|
+
...c,
|
|
36
46
|
value: "[[solid-element]]",
|
|
37
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(
|
|
47
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(b, {
|
|
38
48
|
get fallback() {
|
|
39
|
-
return typeof Node < "u" &&
|
|
49
|
+
return typeof Node < "u" && o instanceof Node ? o : n(o);
|
|
40
50
|
},
|
|
41
51
|
get children() {
|
|
42
|
-
return r(
|
|
43
|
-
return typeof Node < "u" &&
|
|
52
|
+
return r(S, i(c, { get children() {
|
|
53
|
+
return typeof Node < "u" && o instanceof Node ? o : n(o);
|
|
44
54
|
} }));
|
|
45
55
|
}
|
|
46
|
-
}) : typeof Node < "u" &&
|
|
47
|
-
})
|
|
48
|
-
},
|
|
49
|
-
let n =
|
|
56
|
+
}) : typeof Node < "u" && o instanceof Node ? o : n(o)
|
|
57
|
+
}))
|
|
58
|
+
}, D = (e, t) => {
|
|
59
|
+
let n = h(e, t);
|
|
50
60
|
return n.isSimple, n.parts;
|
|
51
|
-
},
|
|
61
|
+
}, O = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? l : {
|
|
52
62
|
id: "insertion-plugin",
|
|
53
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
63
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === y.INSERTION,
|
|
54
64
|
transform: (e, t, n) => {
|
|
55
|
-
let r = [...t.keyPath, { type:
|
|
65
|
+
let r = [...t.keyPath, { type: y.INSERTION }], i = e[y.INSERTION];
|
|
56
66
|
return (e) => {
|
|
57
67
|
let a = {
|
|
58
68
|
id: "insertion-string-plugin",
|
|
59
|
-
canHandle: (e) => typeof e == "string",
|
|
69
|
+
canHandle: (e) => typeof e == "string" || f(e),
|
|
60
70
|
transform: (n, r, i) => {
|
|
61
|
-
|
|
71
|
+
if (f(n)) return g(n, e, r, t.plugins, i);
|
|
72
|
+
let a = D(i(n, {
|
|
62
73
|
...r,
|
|
63
74
|
children: n,
|
|
64
75
|
plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
|
|
@@ -78,33 +89,27 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : y(() => import(
|
|
|
78
89
|
});
|
|
79
90
|
};
|
|
80
91
|
}
|
|
81
|
-
},
|
|
82
|
-
let { MarkdownRenderer: n } = e("solid-markdown-renderer", x);
|
|
83
|
-
return r(n, t);
|
|
84
|
-
}, O = (t) => {
|
|
85
|
-
let { MarkdownMetadataRenderer: n } = e("solid-markdown-renderer", x);
|
|
86
|
-
return r(n, t);
|
|
87
|
-
}, k = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
|
|
92
|
+
}, k = x(() => C.then((e) => ({ default: e.MarkdownRenderer }))), A = x(() => C.then((e) => ({ default: e.MarkdownMetadataRenderer }))), j = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
|
|
88
93
|
id: "markdown-string-plugin",
|
|
89
94
|
canHandle: (e) => typeof e == "string",
|
|
90
95
|
transform: (e, n, o) => {
|
|
91
|
-
let { plugins: s, ...c } = n, l = o(
|
|
96
|
+
let { plugins: s, ...c } = n, l = o(v(e) ?? {}, {
|
|
92
97
|
plugins: [{
|
|
93
98
|
id: "markdown-metadata-plugin",
|
|
94
99
|
canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
|
|
95
100
|
transform: (n, o) => t({
|
|
96
101
|
...o,
|
|
97
102
|
value: n,
|
|
98
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(
|
|
99
|
-
return r(
|
|
100
|
-
return r(
|
|
103
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(b, { get children() {
|
|
104
|
+
return r(S, i(c, { get children() {
|
|
105
|
+
return r(A, i(c, {
|
|
101
106
|
get metadataKeyPath() {
|
|
102
107
|
return o.keyPath;
|
|
103
108
|
},
|
|
104
109
|
children: e
|
|
105
110
|
}));
|
|
106
111
|
} }));
|
|
107
|
-
} }) : r(
|
|
112
|
+
} }) : r(A, i(c, {
|
|
108
113
|
get metadataKeyPath() {
|
|
109
114
|
return o.keyPath;
|
|
110
115
|
},
|
|
@@ -117,14 +122,14 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : y(() => import(
|
|
|
117
122
|
}), u = (o) => t({
|
|
118
123
|
...n,
|
|
119
124
|
value: e,
|
|
120
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(
|
|
121
|
-
return r(
|
|
122
|
-
return r(
|
|
125
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(b, { get children() {
|
|
126
|
+
return r(S, i(c, { get children() {
|
|
127
|
+
return r(k, i(c, {
|
|
123
128
|
components: o,
|
|
124
129
|
children: e
|
|
125
130
|
}));
|
|
126
131
|
} }));
|
|
127
|
-
} }) : r(
|
|
132
|
+
} }) : r(k, i(c, {
|
|
128
133
|
components: o,
|
|
129
134
|
children: e
|
|
130
135
|
})),
|
|
@@ -140,65 +145,65 @@ var b = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : y(() => import(
|
|
|
140
145
|
return n === "metadata" ? l : n === "use" ? (e) => u(e) : Reflect.get(t, n, r);
|
|
141
146
|
} });
|
|
142
147
|
}
|
|
143
|
-
},
|
|
148
|
+
}, M = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
|
|
144
149
|
id: "markdown-plugin",
|
|
145
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
150
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === y.MARKDOWN,
|
|
146
151
|
transform: (e, t, n) => {
|
|
147
|
-
let r = [...t.keyPath, { type:
|
|
152
|
+
let r = [...t.keyPath, { type: y.MARKDOWN }], i = e[y.MARKDOWN];
|
|
148
153
|
return n(i, {
|
|
149
154
|
...t,
|
|
150
155
|
children: i,
|
|
151
156
|
keyPath: r,
|
|
152
|
-
plugins: [
|
|
157
|
+
plugins: [j, ...t.plugins ?? []]
|
|
153
158
|
});
|
|
154
159
|
}
|
|
155
|
-
},
|
|
160
|
+
}, N = x(() => w.then((e) => ({ default: e }))), P = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? l : {
|
|
156
161
|
id: "html-plugin",
|
|
157
|
-
canHandle: (e) => typeof e == "object" && e?.nodeType ===
|
|
162
|
+
canHandle: (e) => typeof e == "object" && e?.nodeType === y.HTML,
|
|
158
163
|
transform: (e, n) => {
|
|
159
|
-
let o = e[
|
|
160
|
-
...
|
|
164
|
+
let o = e[y.HTML], { plugins: s, children: c, ...l } = n, u = (e) => t({
|
|
165
|
+
...l,
|
|
161
166
|
value: o,
|
|
162
|
-
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(
|
|
163
|
-
return r(
|
|
164
|
-
return r(
|
|
167
|
+
children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(b, { get children() {
|
|
168
|
+
return r(S, i(l, { get children() {
|
|
169
|
+
return r(N, i(l, {
|
|
165
170
|
html: o,
|
|
166
171
|
components: e
|
|
167
172
|
}));
|
|
168
173
|
} }));
|
|
169
|
-
} }) : r(
|
|
174
|
+
} }) : r(N, i(l, {
|
|
170
175
|
html: o,
|
|
171
176
|
components: e
|
|
172
177
|
}))
|
|
173
|
-
}),
|
|
174
|
-
return new Proxy(
|
|
178
|
+
}), d = [u()];
|
|
179
|
+
return new Proxy(d, { get(e, t, n) {
|
|
175
180
|
if (t === "value") return o;
|
|
176
181
|
if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") return () => o;
|
|
177
182
|
if (typeof t == "string" && t !== "constructor") {
|
|
178
183
|
let e = String.prototype[t];
|
|
179
184
|
if (typeof e == "function") return e.bind(o);
|
|
180
185
|
}
|
|
181
|
-
return t === "use" ? (e) =>
|
|
186
|
+
return t === "use" ? (e) => u(e) : Reflect.get(e, t, n);
|
|
182
187
|
} });
|
|
183
188
|
}
|
|
184
|
-
},
|
|
189
|
+
}, F = /* @__PURE__ */ new Map(), I = (e, t = !0) => {
|
|
185
190
|
let n = `${e ?? o.defaultLocale}_${t}`;
|
|
186
|
-
if (
|
|
191
|
+
if (F.has(n)) return F.get(n);
|
|
187
192
|
let r = [
|
|
188
|
-
|
|
193
|
+
_(e ?? o.defaultLocale, t ? o.defaultLocale : void 0),
|
|
189
194
|
c,
|
|
190
|
-
|
|
195
|
+
m(e ?? o.defaultLocale),
|
|
191
196
|
s,
|
|
192
|
-
|
|
197
|
+
p(e ?? o.defaultLocale),
|
|
193
198
|
u,
|
|
194
199
|
d,
|
|
195
|
-
|
|
196
|
-
w,
|
|
200
|
+
T,
|
|
197
201
|
E,
|
|
198
|
-
|
|
199
|
-
M
|
|
202
|
+
O,
|
|
203
|
+
M,
|
|
204
|
+
P
|
|
200
205
|
];
|
|
201
|
-
return
|
|
206
|
+
return F.set(n, r), r;
|
|
202
207
|
};
|
|
203
208
|
//#endregion
|
|
204
|
-
export {
|
|
209
|
+
export { I as getPlugins, P as htmlPlugin, O as insertionPlugin, T as intlayerNodePlugins, M as markdownPlugin, j as markdownStringPlugin, E 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
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -113,32 +113,36 @@
|
|
|
113
113
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@intlayer/api": "9.0.0
|
|
117
|
-
"@intlayer/config": "9.0.0
|
|
118
|
-
"@intlayer/core": "9.0.0
|
|
119
|
-
"@intlayer/editor": "9.0.0
|
|
120
|
-
"@intlayer/types": "9.0.0
|
|
116
|
+
"@intlayer/api": "9.0.0",
|
|
117
|
+
"@intlayer/config": "9.0.0",
|
|
118
|
+
"@intlayer/core": "9.0.0",
|
|
119
|
+
"@intlayer/editor": "9.0.0",
|
|
120
|
+
"@intlayer/types": "9.0.0"
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
123
|
"@solidjs/testing-library": "0.8.10",
|
|
124
|
-
"@testing-library/jest-dom": "
|
|
124
|
+
"@testing-library/jest-dom": "7.0.0",
|
|
125
125
|
"@testing-library/user-event": "14.6.1",
|
|
126
|
-
"@types/node": "
|
|
126
|
+
"@types/node": "26.1.1",
|
|
127
|
+
"@typescript/typescript6": "^6.0.2",
|
|
127
128
|
"@utils/ts-config": "1.0.4",
|
|
128
129
|
"@utils/ts-config-types": "1.0.4",
|
|
129
130
|
"@utils/tsdown-config": "1.0.4",
|
|
130
131
|
"jsdom": "29.1.1",
|
|
131
132
|
"rimraf": "6.1.3",
|
|
132
|
-
"tsdown": "0.
|
|
133
|
-
"typescript": "
|
|
134
|
-
"vite": "8.1.
|
|
135
|
-
"vite-plugin-dts": "5.0.
|
|
136
|
-
"vite-plugin-solid": "2.11.
|
|
137
|
-
"vitest": "4.1.
|
|
133
|
+
"tsdown": "0.22.13",
|
|
134
|
+
"typescript": "7.0.2",
|
|
135
|
+
"vite": "8.1.5",
|
|
136
|
+
"vite-plugin-dts": "5.0.3",
|
|
137
|
+
"vite-plugin-solid": "2.11.13",
|
|
138
|
+
"vitest": "4.1.10"
|
|
138
139
|
},
|
|
139
140
|
"peerDependencies": {
|
|
140
141
|
"solid-js": ">=1.0.0"
|
|
141
142
|
},
|
|
143
|
+
"optionalDependencies": {
|
|
144
|
+
"@intlayer/analytics": "9.0.0"
|
|
145
|
+
},
|
|
142
146
|
"engines": {
|
|
143
147
|
"node": ">=14.18"
|
|
144
148
|
},
|