vue-intlayer 9.1.1 → 9.1.3
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/client/installIntlayer.cjs +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/esm/client/installIntlayer.mjs +11 -7
- package/dist/esm/client/useDictionary.mjs +31 -32
- package/dist/esm/client/useDictionaryDynamic.mjs +17 -12
- package/dist/esm/client/useIntlayer.mjs +29 -30
- package/dist/types/client/installIntlayer.d.ts +18 -4
- package/dist/types/client/useDictionary.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useIntlayer.d.ts +2 -2
- package/dist/types/getDictionary.d.ts +2 -2
- package/dist/types/getIntlayer.d.ts +2 -2
- package/package.json +8 -8
|
@@ -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:
|
|
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
|
|
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
|
|
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:
|
|
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(
|
|
11
|
-
setLocale:
|
|
12
|
-
|
|
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 ?? {},
|
|
18
|
-
return e.provide(i,
|
|
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
|
|
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 :
|
|
12
|
+
return t == null ? null : v(t) ? a(t) : Array.isArray(t) ? a("span", t) : t;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
})),
|
|
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
|
|
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
|
-
}),
|
|
37
|
-
let c = i() ? o(t) : void 0,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
() =>
|
|
54
|
-
() =>
|
|
52
|
+
() => w.value,
|
|
53
|
+
() => C.value.selector
|
|
55
54
|
], ([t, n, r]) => {
|
|
56
|
-
|
|
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
|
|
63
|
+
let E = (e) => new Proxy({}, {
|
|
65
64
|
get(t, r, i) {
|
|
66
65
|
if (r === "__v_isRef") return !0;
|
|
67
|
-
let a = n(() =>
|
|
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
|
|
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 =
|
|
74
|
-
if (s === void 0 ||
|
|
75
|
-
if (
|
|
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 =
|
|
78
|
-
return t != null && !Object.hasOwn(t, r) ? s.bind(t) : (...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(() =>
|
|
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 =
|
|
87
|
-
return
|
|
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
|
|
95
|
+
return E([]);
|
|
97
96
|
};
|
|
98
97
|
//#endregion
|
|
99
|
-
export {
|
|
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,
|
|
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
|
|
9
|
-
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && o(
|
|
10
|
-
let n = r(t), { locale: o, selector:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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(
|
|
24
|
+
return n(u, f);
|
|
20
25
|
};
|
|
21
26
|
//#endregion
|
|
22
|
-
export {
|
|
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
|
|
8
|
-
let
|
|
9
|
-
let e =
|
|
10
|
-
|
|
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
|
-
|
|
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(
|
|
24
|
-
() =>
|
|
25
|
-
() =>
|
|
22
|
+
() => p(v),
|
|
23
|
+
() => C.value,
|
|
24
|
+
() => S.value.selector
|
|
26
25
|
], ([t, n, r]) => {
|
|
27
|
-
|
|
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
|
|
34
|
+
let T = /* @__PURE__ */ new Map(), E = (e) => {
|
|
36
35
|
let t = e.join(".");
|
|
37
|
-
if (
|
|
38
|
-
let l = c(() => n(
|
|
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(
|
|
46
|
-
if (p === void 0 || o(p) && !i(p)) return
|
|
47
|
-
if (a(p)) return r(c(() => n(
|
|
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(
|
|
50
|
-
return t != null && !Object.hasOwn(t, u) ? p.bind(t) : (...e) => n(
|
|
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(
|
|
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(
|
|
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
|
|
67
|
+
return T.set(t, u), u;
|
|
69
68
|
};
|
|
70
|
-
return
|
|
69
|
+
return E([]);
|
|
71
70
|
};
|
|
72
71
|
//#endregion
|
|
73
|
-
export {
|
|
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)`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from '@intlayer/types/dictionary';
|
|
2
|
-
import { DeclaredLocales, ExtractSelectorLocale } from '@intlayer/types/module_augmentation';
|
|
2
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
3
|
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
4
4
|
import { DeepTransformContent } from '../plugins';
|
|
5
5
|
export declare const atPath: (obj: any, path: (string | number)[]) => any;
|
|
@@ -17,4 +17,4 @@ export declare const toComponent: (getter: () => any) => import('vue').Raw<impor
|
|
|
17
17
|
* - Passes through other IntlayerNode properties (render, toString, etc.)
|
|
18
18
|
*/
|
|
19
19
|
export declare const createIntlayerLeafProxy: (leafRef: ComputedRef<any>) => any;
|
|
20
|
-
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends
|
|
20
|
+
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: MaybeRefOrGetter<T>, localeOrSelector?: MaybeRefOrGetter<A | null | undefined>) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QualifiedDynamicLoaderMap } from '@intlayer/core/dictionaryManipulator';
|
|
2
2
|
import { Dictionary } from '@intlayer/types/dictionary';
|
|
3
|
-
import { DictionaryKeys, DictionarySelectorForKey, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';
|
|
3
|
+
import { DictionaryKeys, DictionarySelectorForKey, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';
|
|
4
4
|
import { MaybeRefOrGetter } from 'vue';
|
|
5
5
|
/**
|
|
6
6
|
* Lazily loads a dictionary (plain or qualified) and returns its content.
|
|
@@ -12,4 +12,4 @@ import { MaybeRefOrGetter } from 'vue';
|
|
|
12
12
|
* If the locale is not provided (directly or through the selector), it will use
|
|
13
13
|
* the locale from the client context.
|
|
14
14
|
*/
|
|
15
|
-
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends
|
|
15
|
+
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: MaybeRefOrGetter<A | null | undefined>) => Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale } from '@intlayer/types/module_augmentation';
|
|
1
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
2
|
import { MaybeRefOrGetter } from 'vue';
|
|
3
3
|
import { DeepTransformContent } from '../plugins';
|
|
4
4
|
/**
|
|
@@ -24,4 +24,4 @@ import { DeepTransformContent } from '../plugins';
|
|
|
24
24
|
* </template>
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends
|
|
27
|
+
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: MaybeRefOrGetter<A | null | undefined>) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from '@intlayer/types/dictionary';
|
|
2
|
-
import { DeclaredLocales, ExtractSelectorLocale } from '@intlayer/types/module_augmentation';
|
|
2
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
3
|
import { DeepTransformContent } from './plugins';
|
|
4
4
|
/**
|
|
5
5
|
* Transforms a dictionary (or qualified dictionary group) and returns its
|
|
6
6
|
* content for the given locale or selector (`{ item }`, `{ variant }`,
|
|
7
7
|
* optionally combined with `locale`).
|
|
8
8
|
*/
|
|
9
|
-
export declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends
|
|
9
|
+
export declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale } from '@intlayer/types/module_augmentation';
|
|
1
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
2
|
import { DeepTransformContent } from './plugins';
|
|
3
3
|
/**
|
|
4
4
|
* Picks one dictionary by its key and returns its content for the given
|
|
5
5
|
* locale or selector (`{ item }`, `{ variant }`,
|
|
6
6
|
* optionally combined with `locale`).
|
|
7
7
|
*/
|
|
8
|
-
export declare const getIntlayer: <const T extends DictionaryKeys, const A extends
|
|
8
|
+
export declare const getIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.3",
|
|
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.
|
|
106
|
-
"@intlayer/config": "9.1.
|
|
107
|
-
"@intlayer/core": "9.1.
|
|
108
|
-
"@intlayer/editor": "9.1.
|
|
109
|
-
"@intlayer/types": "9.1.
|
|
105
|
+
"@intlayer/api": "9.1.3",
|
|
106
|
+
"@intlayer/config": "9.1.3",
|
|
107
|
+
"@intlayer/core": "9.1.3",
|
|
108
|
+
"@intlayer/editor": "9.1.3",
|
|
109
|
+
"@intlayer/types": "9.1.3"
|
|
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.
|
|
128
|
+
"intlayer": "9.1.3",
|
|
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.
|
|
137
|
+
"@intlayer/analytics": "9.1.3"
|
|
138
138
|
},
|
|
139
139
|
"engines": {
|
|
140
140
|
"node": ">=14.18"
|