vue-intlayer 9.1.1 → 9.1.2

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.
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@intlayer/config/built"),n=require("@intlayer/config/client");var r=Symbol(`intlayer`),i=null,a=(r,a=!0)=>{if(i)return i;(0,n.setIntlayerIdentifier)();let{defaultLocale:o}=t.internationalization??{},s=(0,e.ref)(r??o);return i={locale:(0,e.readonly)(s),setLocale:e=>{s.value=e},isCookieEnabled:a},i},o=(e,t)=>{let{locale:n,isCookieEnabled:i}=t??{},o=a(n,i);return e.provide(r,o),process.env.INTLAYER_EDITOR_ENABLED!==`false`&&Promise.resolve().then(()=>require("../editor/useEditor.cjs")).then(({useEditor:t})=>{t(e)}),process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&Promise.resolve().then(()=>require("../analytics/useAnalytics.cjs")).then(({useAnalytics:t})=>{t(e)}),e},s={install:o};exports.INTLAYER_SYMBOL=r,exports.createIntlayerClient=a,exports.installIntlayer=o,exports.intlayer=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue"),t=require("@intlayer/config/built"),n=require("@intlayer/config/client");var r=Symbol(`intlayer`),i=null,a=(r,a=!0,o)=>{if(i)return i;(0,n.setIntlayerIdentifier)();let{defaultLocale:s}=t.internationalization??{},c=(0,e.ref)(r??s),l=e=>{c.value=e},u=(0,e.ref)(o);return i={locale:(0,e.readonly)(c),setLocale:l,variant:(0,e.readonly)(u),setVariant:e=>{u.value=e},isCookieEnabled:a},i},o=(e,t)=>{let{locale:n,isCookieEnabled:i,variant:o}=t??{},s=a(n,i,o);return e.provide(r,s),process.env.INTLAYER_EDITOR_ENABLED!==`false`&&Promise.resolve().then(()=>require("../editor/useEditor.cjs")).then(({useEditor:t})=>{t(e)}),process.env.INTLAYER_ANALYTICS_ENABLED!==`false`&&Promise.resolve().then(()=>require("../analytics/useAnalytics.cjs")).then(({useAnalytics:t})=>{t(e)}),e},s={install:o};exports.INTLAYER_SYMBOL=r,exports.createIntlayerClient=a,exports.installIntlayer=o,exports.intlayer=s;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./installIntlayer.cjs");let n=require("vue"),r=require("@intlayer/config/built");var i=(e,t)=>t.reduce((e,t)=>e?.[t],e),a=e=>typeof e==`object`&&!!e,o=e=>typeof e==`function`||a(e)&&(`render`in e||`setup`in e),s=e=>e!=null&&(typeof e==`object`||typeof e==`function`)&&`__update`in e&&`render`in e&&`raw`in e,c=e=>(0,n.markRaw)((0,n.defineComponent)({name:`IntlayerLeaf`,setup(){return()=>{let t=e();return t==null?null:o(t)?(0,n.h)(t):Array.isArray(t)?(0,n.h)(`span`,t):t}}})),l=e=>new Proxy({},{get(t,n){let r=e.value;if(n===`__v_isRef`)return!0;if(n===`value`)return r??``;if(n===`$raw`)return e;if(n===`__v_skip`)return!0;if(n===`c`||n===`asComponent`)return c(()=>e.value);if(r==null)return n===Symbol.toPrimitive||n===`toString`?()=>``:void 0;let i=r[n];return typeof i==`function`?i.bind(r):i},ownKeys(){let t=e.value;return typeof t==`object`&&t?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}}),u=(u,d)=>{let f=(0,n.getCurrentInstance)()?(0,n.inject)(t.INTLAYER_SYMBOL):void 0,p=(0,n.isRef)(f?.locale)?f.locale:(0,n.ref)(f?.locale??r.internationalization.defaultLocale),m=(0,n.computed)(()=>{let e=d===void 0?void 0:(0,n.toValue)(d);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&typeof e==`object`&&e){let t=e;return{selector:t,locale:t.locale}}return{selector:void 0,locale:e}}),h=(0,n.computed)(()=>m.value.locale??p.value),g=(0,n.shallowRef)({});(0,n.watch)([()=>(0,n.toValue)(u),()=>h.value,()=>m.value.selector],([t,n,r])=>{g.value=r?e.getDictionary(t,{...r,locale:n}):e.getDictionary(t,n)},{immediate:!0,flush:`sync`});let _=e=>new Proxy({},{get(t,r,u){if(r===`__v_isRef`)return!0;let d=(0,n.computed)(()=>i(g.value,e));if(r===`value`)return d.value??``;if(r===`then`)return;if(r===`c`||r===`asComponent`)return c(()=>d.value);if(r===`$raw`)return d;if(r===Symbol.toPrimitive)return()=>d.value;let f=e.concat(r),p=i(g.value,f);if(p===void 0||a(p)&&!o(p))return _(f);if(s(p))return l((0,n.computed)(()=>i(g.value,f)));if(typeof p==`function`){let t=i(g.value,e);return t!=null&&!Object.hasOwn(t,r)?p.bind(t):(...e)=>i(g.value,f)?.(...e)}let m=(0,n.computed)(()=>i(g.value,f));return new Proxy(m,{get(e,t,n){return t===`value`?e.value??``:Reflect.get(e,t,n)}})},ownKeys(){let t=i(g.value,e);return a(t)?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return _([])};exports.atPath=i,exports.createIntlayerLeafProxy=l,exports.isComponentLike=o,exports.isIntlayerNode=s,exports.isObjectLike=a,exports.toComponent=c,exports.useDictionary=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./installIntlayer.cjs");let n=require("vue"),r=require("@intlayer/config/built"),i=require("@intlayer/core/dictionaryManipulator");var a=(e,t)=>t.reduce((e,t)=>e?.[t],e),o=e=>typeof e==`object`&&!!e,s=e=>typeof e==`function`||o(e)&&(`render`in e||`setup`in e),c=e=>e!=null&&(typeof e==`object`||typeof e==`function`)&&`__update`in e&&`render`in e&&`raw`in e,l=e=>(0,n.markRaw)((0,n.defineComponent)({name:`IntlayerLeaf`,setup(){return()=>{let t=e();return t==null?null:s(t)?(0,n.h)(t):Array.isArray(t)?(0,n.h)(`span`,t):t}}})),u=e=>new Proxy({},{get(t,n){let r=e.value;if(n===`__v_isRef`)return!0;if(n===`value`)return r??``;if(n===`$raw`)return e;if(n===`__v_skip`)return!0;if(n===`c`||n===`asComponent`)return l(()=>e.value);if(r==null)return n===Symbol.toPrimitive||n===`toString`?()=>``:void 0;let i=r[n];return typeof i==`function`?i.bind(r):i},ownKeys(){let t=e.value;return typeof t==`object`&&t?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}}),d=(d,f)=>{let p=(0,n.getCurrentInstance)()?(0,n.inject)(t.INTLAYER_SYMBOL):void 0,m=(0,n.isRef)(p?.locale)?p.locale:(0,n.ref)(p?.locale??r.internationalization.defaultLocale),h=(0,n.computed)(()=>{let e=f===void 0?void 0:(0,n.toValue)(f);return process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?{selector:void 0,locale:e}:(0,i.parseDictionarySelector)((0,i.resolveDictionaryArgument)({localeOrSelector:e,contextLocale:m.value,contextVariant:p?.variant?.value,dictionaryKey:(0,n.toValue)(d).key}))}),g=(0,n.computed)(()=>h.value.locale??m.value),_=(0,n.shallowRef)({});(0,n.watch)([()=>(0,n.toValue)(d),()=>g.value,()=>h.value.selector],([t,n,r])=>{_.value=r?e.getDictionary(t,{...r,locale:n}):e.getDictionary(t,n)},{immediate:!0,flush:`sync`});let v=e=>new Proxy({},{get(t,r,i){if(r===`__v_isRef`)return!0;let d=(0,n.computed)(()=>a(_.value,e));if(r===`value`)return d.value??``;if(r===`then`)return;if(r===`c`||r===`asComponent`)return l(()=>d.value);if(r===`$raw`)return d;if(r===Symbol.toPrimitive)return()=>d.value;let f=e.concat(r),p=a(_.value,f);if(p===void 0||o(p)&&!s(p))return v(f);if(c(p))return u((0,n.computed)(()=>a(_.value,f)));if(typeof p==`function`){let t=a(_.value,e);return t!=null&&!Object.hasOwn(t,r)?p.bind(t):(...e)=>a(_.value,f)?.(...e)}let m=(0,n.computed)(()=>a(_.value,f));return new Proxy(m,{get(e,t,n){return t===`value`?e.value??``:Reflect.get(e,t,n)}})},ownKeys(){let t=a(_.value,e);return o(t)?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return v([])};exports.atPath=a,exports.createIntlayerLeafProxy=u,exports.isComponentLike=s,exports.isIntlayerNode=c,exports.isObjectLike=o,exports.toComponent=l,exports.useDictionary=d;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./installIntlayer.cjs"),n=require("./useDictionaryAsync.cjs");let r=require("vue"),i=require("@intlayer/config/built"),a=require("@intlayer/core/dictionaryManipulator");var o=async(o,s,c)=>{if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,a.isQualifiedDynamicLoaderMap)(o)){let n=(0,r.inject)(t.INTLAYER_SYMBOL),{locale:l,selector:u}=(0,a.parseDictionarySelector)((c===void 0?void 0:(0,r.toValue)(c))??void 0),d=l??n?.locale?.value??i.internationalization.defaultLocale;return(0,a.resolveQualifiedDynamicContentAsync)({loaderMap:o,key:String(s),locale:d,selector:u,transform:t=>e.getDictionary(t,d)})}return n.useDictionaryAsync(o,c)};exports.useDictionaryDynamic=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./installIntlayer.cjs"),n=require("./useDictionaryAsync.cjs");let r=require("vue"),i=require("@intlayer/config/built"),a=require("@intlayer/core/dictionaryManipulator");var o=async(o,s,c)=>{if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,a.isQualifiedDynamicLoaderMap)(o)){let n=(0,r.inject)(t.INTLAYER_SYMBOL),{locale:l,selector:u}=(0,a.parseDictionarySelector)((0,a.resolveDictionaryArgument)({localeOrSelector:(c===void 0?void 0:(0,r.toValue)(c))??void 0,contextLocale:n?.locale?.value,contextVariant:n?.variant?.value,dictionaryKey:String(s)})),d=l??n?.locale?.value??i.internationalization.defaultLocale;return(0,a.resolveQualifiedDynamicContentAsync)({loaderMap:o,key:String(s),locale:d,selector:u,transform:t=>e.getDictionary(t,d)})}return n.useDictionaryAsync(o,c)};exports.useDictionaryDynamic=o;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./installIntlayer.cjs"),n=require("./useDictionary.cjs");let r=require("vue"),i=require("@intlayer/config/built");var a=(a,o)=>{let s=(0,r.inject)(t.INTLAYER_SYMBOL),c=(0,r.isRef)(s?.locale)?s.locale:(0,r.ref)(s?.locale??i.internationalization.defaultLocale),l=(0,r.computed)(()=>{let e=o===void 0?void 0:(0,r.toValue)(o);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&typeof e==`object`&&e){let t=e;return{selector:t,locale:t.locale}}return{selector:void 0,locale:e}}),u=(0,r.computed)(()=>l.value.locale??c.value),d=(0,r.shallowRef)({});(0,r.watch)([()=>(0,r.toValue)(a),()=>u.value,()=>l.value.selector],([t,n,r])=>{d.value=r?e.getIntlayer(t,{...r,locale:n}):e.getIntlayer(t,n)},{immediate:!0,flush:`sync`});let f=new Map,p=e=>{let t=e.join(`.`);if(f.has(t))return f.get(t);let i=(0,r.computed)(()=>n.atPath(d.value,e)),a=new Proxy({},{get(t,a,o){if(typeof a==`symbol`||typeof a==`string`&&(a.startsWith(`__`)||a.startsWith(`$`)))return a===`__v_isRef`?!0:a===`then`?void 0:Reflect.get(t,a,o);if(a===`value`)return i.value??``;if(a===`c`||a===`asComponent`)return n.toComponent(()=>i.value);if(a===`$raw`)return i;if(a===Symbol.toPrimitive)return()=>String(i.value??``);let s=e.concat(a),c=n.atPath(d.value,s);if(c===void 0||n.isObjectLike(c)&&!n.isComponentLike(c))return p(s);if(n.isIntlayerNode(c))return n.createIntlayerLeafProxy((0,r.computed)(()=>n.atPath(d.value,s)));if(typeof c==`function`){let t=n.atPath(d.value,e);return t!=null&&!Object.hasOwn(t,a)?c.bind(t):(...e)=>n.atPath(d.value,s)?.(...e)}let l=(0,r.computed)(()=>n.atPath(d.value,s));return new Proxy(l,{get(e,t,n){return t===`value`?e.value??``:t===`__v_isRef`||Reflect.get(e,t,n)}})},ownKeys(){let t=n.atPath(d.value,e);return n.isObjectLike(t)?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return f.set(t,a),a};return p([])};exports.useIntlayer=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./installIntlayer.cjs"),n=require("./useDictionary.cjs");let r=require("vue"),i=require("@intlayer/config/built"),a=require("@intlayer/core/dictionaryManipulator");var o=(o,s)=>{let c=(0,r.inject)(t.INTLAYER_SYMBOL),l=(0,r.isRef)(c?.locale)?c.locale:(0,r.ref)(c?.locale??i.internationalization.defaultLocale),u=(0,r.computed)(()=>{let e=s===void 0?void 0:(0,r.toValue)(s);return process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?{selector:void 0,locale:e}:(0,a.parseDictionarySelector)((0,a.resolveDictionaryArgument)({localeOrSelector:e,contextLocale:l.value,contextVariant:c?.variant?.value,dictionaryKey:(0,r.toValue)(o)}))}),d=(0,r.computed)(()=>u.value.locale??l.value),f=(0,r.shallowRef)({});(0,r.watch)([()=>(0,r.toValue)(o),()=>d.value,()=>u.value.selector],([t,n,r])=>{f.value=r?e.getIntlayer(t,{...r,locale:n}):e.getIntlayer(t,n)},{immediate:!0,flush:`sync`});let p=new Map,m=e=>{let t=e.join(`.`);if(p.has(t))return p.get(t);let i=(0,r.computed)(()=>n.atPath(f.value,e)),a=new Proxy({},{get(t,a,o){if(typeof a==`symbol`||typeof a==`string`&&(a.startsWith(`__`)||a.startsWith(`$`)))return a===`__v_isRef`?!0:a===`then`?void 0:Reflect.get(t,a,o);if(a===`value`)return i.value??``;if(a===`c`||a===`asComponent`)return n.toComponent(()=>i.value);if(a===`$raw`)return i;if(a===Symbol.toPrimitive)return()=>String(i.value??``);let s=e.concat(a),c=n.atPath(f.value,s);if(c===void 0||n.isObjectLike(c)&&!n.isComponentLike(c))return m(s);if(n.isIntlayerNode(c))return n.createIntlayerLeafProxy((0,r.computed)(()=>n.atPath(f.value,s)));if(typeof c==`function`){let t=n.atPath(f.value,e);return t!=null&&!Object.hasOwn(t,a)?c.bind(t):(...e)=>n.atPath(f.value,s)?.(...e)}let l=(0,r.computed)(()=>n.atPath(f.value,s));return new Proxy(l,{get(e,t,n){return t===`value`?e.value??``:t===`__v_isRef`||Reflect.get(e,t,n)}})},ownKeys(){let t=n.atPath(f.value,e);return n.isObjectLike(t)?Reflect.ownKeys(t):[]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return p.set(t,a),a};return m([])};exports.useIntlayer=o;
@@ -2,20 +2,24 @@ import { readonly as e, ref as t } from "vue";
2
2
  import { internationalization as n } from "@intlayer/config/built";
3
3
  import { setIntlayerIdentifier as r } from "@intlayer/config/client";
4
4
  //#region src/client/installIntlayer.ts
5
- var i = Symbol("intlayer"), a = null, o = (i, o = !0) => {
5
+ var i = Symbol("intlayer"), a = null, o = (i, o = !0, s) => {
6
6
  if (a) return a;
7
7
  r();
8
- let { defaultLocale: s } = n ?? {}, c = t(i ?? s);
8
+ let { defaultLocale: c } = n ?? {}, l = t(i ?? c), u = (e) => {
9
+ l.value = e;
10
+ }, d = t(s);
9
11
  return a = {
10
- locale: e(c),
11
- setLocale: (e) => {
12
- c.value = e;
12
+ locale: e(l),
13
+ setLocale: u,
14
+ variant: e(d),
15
+ setVariant: (e) => {
16
+ d.value = e;
13
17
  },
14
18
  isCookieEnabled: o
15
19
  }, a;
16
20
  }, s = (e, t) => {
17
- let { locale: n, isCookieEnabled: r } = t ?? {}, a = o(n, r);
18
- return e.provide(i, a), process.env.INTLAYER_EDITOR_ENABLED !== "false" && import("../editor/useEditor.mjs").then(({ useEditor: t }) => {
21
+ let { locale: n, isCookieEnabled: r, variant: a } = t ?? {}, s = o(n, r, a);
22
+ return e.provide(i, s), process.env.INTLAYER_EDITOR_ENABLED !== "false" && import("../editor/useEditor.mjs").then(({ useEditor: t }) => {
19
23
  t(e);
20
24
  }), process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && import("../analytics/useAnalytics.mjs").then(({ useAnalytics: t }) => {
21
25
  t(e);
@@ -2,23 +2,24 @@ import { getDictionary as e } from "../getDictionary.mjs";
2
2
  import { INTLAYER_SYMBOL as t } from "./installIntlayer.mjs";
3
3
  import { computed as n, defineComponent as r, getCurrentInstance as i, h as a, inject as o, isRef as s, markRaw as c, ref as l, shallowRef as u, toValue as d, watch as f } from "vue";
4
4
  import { internationalization as p } from "@intlayer/config/built";
5
+ import { parseDictionarySelector as m, resolveDictionaryArgument as h } from "@intlayer/core/dictionaryManipulator";
5
6
  //#region src/client/useDictionary.ts
6
- var m = (e, t) => t.reduce((e, t) => e?.[t], e), h = (e) => typeof e == "object" && !!e, g = (e) => typeof e == "function" || h(e) && ("render" in e || "setup" in e), _ = (e) => e != null && (typeof e == "object" || typeof e == "function") && "__update" in e && "render" in e && "raw" in e, v = (e) => c(r({
7
+ var g = (e, t) => t.reduce((e, t) => e?.[t], e), _ = (e) => typeof e == "object" && !!e, v = (e) => typeof e == "function" || _(e) && ("render" in e || "setup" in e), y = (e) => e != null && (typeof e == "object" || typeof e == "function") && "__update" in e && "render" in e && "raw" in e, b = (e) => c(r({
7
8
  name: "IntlayerLeaf",
8
9
  setup() {
9
10
  return () => {
10
11
  let t = e();
11
- return t == null ? null : g(t) ? a(t) : Array.isArray(t) ? a("span", t) : t;
12
+ return t == null ? null : v(t) ? a(t) : Array.isArray(t) ? a("span", t) : t;
12
13
  };
13
14
  }
14
- })), y = (e) => new Proxy({}, {
15
+ })), x = (e) => new Proxy({}, {
15
16
  get(t, n) {
16
17
  let r = e.value;
17
18
  if (n === "__v_isRef") return !0;
18
19
  if (n === "value") return r ?? "";
19
20
  if (n === "$raw") return e;
20
21
  if (n === "__v_skip") return !0;
21
- if (n === "c" || n === "asComponent") return v(() => e.value);
22
+ if (n === "c" || n === "asComponent") return b(() => e.value);
22
23
  if (r == null) return n === Symbol.toPrimitive || n === "toString" ? () => "" : void 0;
23
24
  let i = r[n];
24
25
  return typeof i == "function" ? i.bind(r) : i;
@@ -33,27 +34,25 @@ var m = (e, t) => t.reduce((e, t) => e?.[t], e), h = (e) => typeof e == "object"
33
34
  configurable: !0
34
35
  };
35
36
  }
36
- }), b = (r, a) => {
37
- let c = i() ? o(t) : void 0, b = s(c?.locale) ? c.locale : l(c?.locale ?? p.defaultLocale), x = n(() => {
37
+ }), S = (r, a) => {
38
+ let c = i() ? o(t) : void 0, S = s(c?.locale) ? c.locale : l(c?.locale ?? p.defaultLocale), C = n(() => {
38
39
  let e = a === void 0 ? void 0 : d(a);
39
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof e == "object" && e) {
40
- let t = e;
41
- return {
42
- selector: t,
43
- locale: t.locale
44
- };
45
- }
46
- return {
40
+ return process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? {
47
41
  selector: void 0,
48
42
  locale: e
49
- };
50
- }), S = n(() => x.value.locale ?? b.value), C = u({});
43
+ } : m(h({
44
+ localeOrSelector: e,
45
+ contextLocale: S.value,
46
+ contextVariant: c?.variant?.value,
47
+ dictionaryKey: d(r).key
48
+ }));
49
+ }), w = n(() => C.value.locale ?? S.value), T = u({});
51
50
  f([
52
51
  () => d(r),
53
- () => S.value,
54
- () => x.value.selector
52
+ () => w.value,
53
+ () => C.value.selector
55
54
  ], ([t, n, r]) => {
56
- C.value = r ? e(t, {
55
+ T.value = r ? e(t, {
57
56
  ...r,
58
57
  locale: n
59
58
  }) : e(t, n);
@@ -61,30 +60,30 @@ var m = (e, t) => t.reduce((e, t) => e?.[t], e), h = (e) => typeof e == "object"
61
60
  immediate: !0,
62
61
  flush: "sync"
63
62
  });
64
- let w = (e) => new Proxy({}, {
63
+ let E = (e) => new Proxy({}, {
65
64
  get(t, r, i) {
66
65
  if (r === "__v_isRef") return !0;
67
- let a = n(() => m(C.value, e));
66
+ let a = n(() => g(T.value, e));
68
67
  if (r === "value") return a.value ?? "";
69
68
  if (r === "then") return;
70
- if (r === "c" || r === "asComponent") return v(() => a.value);
69
+ if (r === "c" || r === "asComponent") return b(() => a.value);
71
70
  if (r === "$raw") return a;
72
71
  if (r === Symbol.toPrimitive) return () => a.value;
73
- let o = e.concat(r), s = m(C.value, o);
74
- if (s === void 0 || h(s) && !g(s)) return w(o);
75
- if (_(s)) return y(n(() => m(C.value, o)));
72
+ let o = e.concat(r), s = g(T.value, o);
73
+ if (s === void 0 || _(s) && !v(s)) return E(o);
74
+ if (y(s)) return x(n(() => g(T.value, o)));
76
75
  if (typeof s == "function") {
77
- let t = m(C.value, e);
78
- return t != null && !Object.hasOwn(t, r) ? s.bind(t) : (...e) => m(C.value, o)?.(...e);
76
+ let t = g(T.value, e);
77
+ return t != null && !Object.hasOwn(t, r) ? s.bind(t) : (...e) => g(T.value, o)?.(...e);
79
78
  }
80
- let c = n(() => m(C.value, o));
79
+ let c = n(() => g(T.value, o));
81
80
  return new Proxy(c, { get(e, t, n) {
82
81
  return t === "value" ? e.value ?? "" : Reflect.get(e, t, n);
83
82
  } });
84
83
  },
85
84
  ownKeys() {
86
- let t = m(C.value, e);
87
- return h(t) ? Reflect.ownKeys(t) : [];
85
+ let t = g(T.value, e);
86
+ return _(t) ? Reflect.ownKeys(t) : [];
88
87
  },
89
88
  getOwnPropertyDescriptor() {
90
89
  return {
@@ -93,7 +92,7 @@ var m = (e, t) => t.reduce((e, t) => e?.[t], e), h = (e) => typeof e == "object"
93
92
  };
94
93
  }
95
94
  });
96
- return w([]);
95
+ return E([]);
97
96
  };
98
97
  //#endregion
99
- export { m as atPath, y as createIntlayerLeafProxy, g as isComponentLike, _ as isIntlayerNode, h as isObjectLike, v as toComponent, b as useDictionary };
98
+ export { g as atPath, x as createIntlayerLeafProxy, v as isComponentLike, y as isIntlayerNode, _ as isObjectLike, b as toComponent, S as useDictionary };
@@ -3,20 +3,25 @@ import { INTLAYER_SYMBOL as t } from "./installIntlayer.mjs";
3
3
  import { useDictionaryAsync as n } from "./useDictionaryAsync.mjs";
4
4
  import { inject as r, toValue as i } from "vue";
5
5
  import { internationalization as a } from "@intlayer/config/built";
6
- import { isQualifiedDynamicLoaderMap as o, parseDictionarySelector as s, resolveQualifiedDynamicContentAsync as c } from "@intlayer/core/dictionaryManipulator";
6
+ import { isQualifiedDynamicLoaderMap as o, parseDictionarySelector as s, resolveDictionaryArgument as c, resolveQualifiedDynamicContentAsync as l } from "@intlayer/core/dictionaryManipulator";
7
7
  //#region src/client/useDictionaryDynamic.ts
8
- var l = async (l, u, d) => {
9
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && o(l)) {
10
- let n = r(t), { locale: o, selector: f } = s((d === void 0 ? void 0 : i(d)) ?? void 0), p = o ?? n?.locale?.value ?? a.defaultLocale;
11
- return c({
12
- loaderMap: l,
13
- key: String(u),
14
- locale: p,
15
- selector: f,
16
- transform: (t) => e(t, p)
8
+ var u = async (u, d, f) => {
9
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && o(u)) {
10
+ let n = r(t), { locale: o, selector: p } = s(c({
11
+ localeOrSelector: (f === void 0 ? void 0 : i(f)) ?? void 0,
12
+ contextLocale: n?.locale?.value,
13
+ contextVariant: n?.variant?.value,
14
+ dictionaryKey: String(d)
15
+ })), m = o ?? n?.locale?.value ?? a.defaultLocale;
16
+ return l({
17
+ loaderMap: u,
18
+ key: String(d),
19
+ locale: m,
20
+ selector: p,
21
+ transform: (t) => e(t, m)
17
22
  });
18
23
  }
19
- return n(l, d);
24
+ return n(u, f);
20
25
  };
21
26
  //#endregion
22
- export { l as useDictionaryDynamic };
27
+ export { u as useDictionaryDynamic };
@@ -3,28 +3,27 @@ import { INTLAYER_SYMBOL as t } from "./installIntlayer.mjs";
3
3
  import { atPath as n, createIntlayerLeafProxy as r, isComponentLike as i, isIntlayerNode as a, isObjectLike as o, toComponent as s } from "./useDictionary.mjs";
4
4
  import { computed as c, inject as l, isRef as u, ref as d, shallowRef as f, toValue as p, watch as m } from "vue";
5
5
  import { internationalization as h } from "@intlayer/config/built";
6
+ import { parseDictionarySelector as g, resolveDictionaryArgument as _ } from "@intlayer/core/dictionaryManipulator";
6
7
  //#region src/client/useIntlayer.ts
7
- var g = (g, _) => {
8
- let v = l(t), y = u(v?.locale) ? v.locale : d(v?.locale ?? h.defaultLocale), b = c(() => {
9
- let e = _ === void 0 ? void 0 : p(_);
10
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof e == "object" && e) {
11
- let t = e;
12
- return {
13
- selector: t,
14
- locale: t.locale
15
- };
16
- }
17
- return {
8
+ var v = (v, y) => {
9
+ let b = l(t), x = u(b?.locale) ? b.locale : d(b?.locale ?? h.defaultLocale), S = c(() => {
10
+ let e = y === void 0 ? void 0 : p(y);
11
+ return process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? {
18
12
  selector: void 0,
19
13
  locale: e
20
- };
21
- }), x = c(() => b.value.locale ?? y.value), S = f({});
14
+ } : g(_({
15
+ localeOrSelector: e,
16
+ contextLocale: x.value,
17
+ contextVariant: b?.variant?.value,
18
+ dictionaryKey: p(v)
19
+ }));
20
+ }), C = c(() => S.value.locale ?? x.value), w = f({});
22
21
  m([
23
- () => p(g),
24
- () => x.value,
25
- () => b.value.selector
22
+ () => p(v),
23
+ () => C.value,
24
+ () => S.value.selector
26
25
  ], ([t, n, r]) => {
27
- S.value = r ? e(t, {
26
+ w.value = r ? e(t, {
28
27
  ...r,
29
28
  locale: n
30
29
  }) : e(t, n);
@@ -32,30 +31,30 @@ var g = (g, _) => {
32
31
  immediate: !0,
33
32
  flush: "sync"
34
33
  });
35
- let C = /* @__PURE__ */ new Map(), w = (e) => {
34
+ let T = /* @__PURE__ */ new Map(), E = (e) => {
36
35
  let t = e.join(".");
37
- if (C.has(t)) return C.get(t);
38
- let l = c(() => n(S.value, e)), u = new Proxy({}, {
36
+ if (T.has(t)) return T.get(t);
37
+ let l = c(() => n(w.value, e)), u = new Proxy({}, {
39
38
  get(t, u, d) {
40
39
  if (typeof u == "symbol" || typeof u == "string" && (u.startsWith("__") || u.startsWith("$"))) return u === "__v_isRef" ? !0 : u === "then" ? void 0 : Reflect.get(t, u, d);
41
40
  if (u === "value") return l.value ?? "";
42
41
  if (u === "c" || u === "asComponent") return s(() => l.value);
43
42
  if (u === "$raw") return l;
44
43
  if (u === Symbol.toPrimitive) return () => String(l.value ?? "");
45
- let f = e.concat(u), p = n(S.value, f);
46
- if (p === void 0 || o(p) && !i(p)) return w(f);
47
- if (a(p)) return r(c(() => n(S.value, f)));
44
+ let f = e.concat(u), p = n(w.value, f);
45
+ if (p === void 0 || o(p) && !i(p)) return E(f);
46
+ if (a(p)) return r(c(() => n(w.value, f)));
48
47
  if (typeof p == "function") {
49
- let t = n(S.value, e);
50
- return t != null && !Object.hasOwn(t, u) ? p.bind(t) : (...e) => n(S.value, f)?.(...e);
48
+ let t = n(w.value, e);
49
+ return t != null && !Object.hasOwn(t, u) ? p.bind(t) : (...e) => n(w.value, f)?.(...e);
51
50
  }
52
- let m = c(() => n(S.value, f));
51
+ let m = c(() => n(w.value, f));
53
52
  return new Proxy(m, { get(e, t, n) {
54
53
  return t === "value" ? e.value ?? "" : t === "__v_isRef" || Reflect.get(e, t, n);
55
54
  } });
56
55
  },
57
56
  ownKeys() {
58
- let t = n(S.value, e);
57
+ let t = n(w.value, e);
59
58
  return o(t) ? Reflect.ownKeys(t) : [];
60
59
  },
61
60
  getOwnPropertyDescriptor() {
@@ -65,9 +64,9 @@ var g = (g, _) => {
65
64
  };
66
65
  }
67
66
  });
68
- return C.set(t, u), u;
67
+ return T.set(t, u), u;
69
68
  };
70
- return w([]);
69
+ return E([]);
71
70
  };
72
71
  //#endregion
73
- export { g as useIntlayer };
72
+ export { v as useIntlayer };
@@ -1,16 +1,22 @@
1
1
  import { Locale } from '@intlayer/types/allLocales';
2
- import { LocalesValues } from '@intlayer/types/module_augmentation';
2
+ import { LocalesValues, ProviderVariant } from '@intlayer/types/module_augmentation';
3
3
  import { App, Ref } from 'vue';
4
4
  export declare const INTLAYER_SYMBOL: unique symbol;
5
5
  export type IntlayerProvider = {
6
6
  locale: Ref<Locale>;
7
7
  setLocale: (locale: LocalesValues) => void;
8
+ /**
9
+ * Ambient variant applied to every dictionary read in the app, the same way
10
+ * `locale` is. Overridden per call by an explicit selector.
11
+ */
12
+ variant: Ref<ProviderVariant | undefined>;
13
+ setVariant: (variant: ProviderVariant | undefined) => void;
8
14
  isCookieEnabled?: boolean;
9
15
  };
10
16
  /**
11
17
  * Create and return a single IntlayerProvider instance
12
18
  */
13
- export declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerProvider;
19
+ export declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: boolean, variant?: ProviderVariant) => IntlayerProvider;
14
20
  /**
15
21
  * Vue plugin to install Intlayer in your application.
16
22
  *
@@ -18,8 +24,15 @@ export declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnab
18
24
  * like `useIntlayer` and `useLocale`.
19
25
  *
20
26
  * @param app - The Vue application instance.
21
- * @param locale - Initial locale to use.
22
- * @param isCookieEnabled - Whether to store the locale in cookies.
27
+ * @param options.locale - Initial locale to use.
28
+ * @param options.isCookieEnabled - Whether to store the locale in cookies.
29
+ * @param options.variant - Ambient variant applied to every dictionary read in
30
+ * the app — for a dimension fixed for the whole session (tenant, school type,
31
+ * plan tier…) that no component should have to pass by hand. Accepts a name
32
+ * (`'school1'`), an ordered preference chain (`['school1', 'default']`), or a
33
+ * per-key map (`{ key1: 'school1', default: 'base' }`). A plain object is
34
+ * always the per-key map; nest a structured variant as
35
+ * `{ default: { id: 'prod_abc' } }`. A call-site selector always wins.
23
36
  * @returns The Vue application instance.
24
37
  *
25
38
  * @example
@@ -38,6 +51,7 @@ export declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnab
38
51
  export declare const installIntlayer: (app: App, options?: {
39
52
  locale?: LocalesValues;
40
53
  isCookieEnabled?: boolean;
54
+ variant?: ProviderVariant;
41
55
  }) => App<any>;
42
56
  /**
43
57
  * Vue plugin object for Intlayer. Can be used with `app.use(intlayer)`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-intlayer",
3
- "version": "9.1.1",
3
+ "version": "9.1.2",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -102,11 +102,11 @@
102
102
  "typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
103
103
  },
104
104
  "dependencies": {
105
- "@intlayer/api": "9.1.1",
106
- "@intlayer/config": "9.1.1",
107
- "@intlayer/core": "9.1.1",
108
- "@intlayer/editor": "9.1.1",
109
- "@intlayer/types": "9.1.1"
105
+ "@intlayer/api": "9.1.2",
106
+ "@intlayer/config": "9.1.2",
107
+ "@intlayer/core": "9.1.2",
108
+ "@intlayer/editor": "9.1.2",
109
+ "@intlayer/types": "9.1.2"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@types/node": "26.1.2",
@@ -125,7 +125,7 @@
125
125
  "vue-tsc": "3.3.7"
126
126
  },
127
127
  "peerDependencies": {
128
- "intlayer": "9.1.1",
128
+ "intlayer": "9.1.2",
129
129
  "vue": ">=3.0.0"
130
130
  },
131
131
  "peerDependenciesMeta": {
@@ -134,7 +134,7 @@
134
134
  }
135
135
  },
136
136
  "optionalDependencies": {
137
- "@intlayer/analytics": "9.1.1"
137
+ "@intlayer/analytics": "9.1.2"
138
138
  },
139
139
  "engines": {
140
140
  "node": ">=14.18"