solid-intlayer 8.12.4 → 9.0.0-canary.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/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -1
- package/dist/cjs/getDictionary.cjs +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -1
- package/dist/cjs/server/index.cjs +1 -0
- package/dist/cjs/server/useDictionary.cjs +1 -0
- package/dist/esm/client/useDictionary.mjs +7 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +52 -13
- package/dist/esm/client/useIntlayer.mjs +5 -2
- package/dist/esm/client/useLoadDynamic.mjs +31 -26
- package/dist/esm/getDictionary.mjs +1 -1
- package/dist/esm/getIntlayer.mjs +1 -1
- package/dist/esm/server/index.mjs +2 -0
- package/dist/esm/server/useDictionary.mjs +9 -0
- package/dist/plugins-vvwP0Yi4.js +1 -0
- package/dist/types/client/useContent.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts +10 -5
- package/dist/types/client/useDictionaryAsync.d.ts +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +13 -4
- package/dist/types/client/useIntlayer.d.ts +10 -3
- package/dist/types/client/useLoadDynamic.d.ts +7 -6
- package/dist/types/client/useLocaleStorage.d.ts +4 -4
- package/dist/types/getDictionary.d.ts +8 -3
- package/dist/types/getIntlayer.d.ts +7 -2
- package/dist/types/server/index.d.ts +1 -0
- package/dist/types/server/useDictionary.d.ts +20 -0
- package/package.json +16 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./IntlayerProvider.cjs");let n=require("solid-js");var r=(r,i)=>{let a=(0,n.useContext)(t.IntlayerClientContext)??{},o=(0,n.createMemo)(()=>e.getDictionary(r,i??
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./IntlayerProvider.cjs");let n=require("solid-js");var r=(r,i)=>{let a=(0,n.useContext)(t.IntlayerClientContext)??{},o=(0,n.createMemo)(()=>{let t=a?.locale?.();return typeof i==`object`&&i?e.getDictionary(r,{...i,locale:i.locale??t}):e.getDictionary(r,i??t)});return new Proxy(o,{get(e,t){return e()?.[t]},apply(e,t,n){return Reflect.apply(e,t,n)}})};exports.useDictionary=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useLoadDynamic.cjs"),t=require("./IntlayerProvider.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useLoadDynamic.cjs"),t=require("../getDictionary.cjs"),n=require("./IntlayerProvider.cjs"),r=require("./useDictionary.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)(n.IntlayerClientContext)??{},d=i.internationalization.defaultLocale,f=String(c);if((0,o.isQualifiedDynamicLoaderMap)(s)){let{locale:n,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=()=>n??u?.()??d;if(!p)return r.useDictionary(e.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)),n);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 e=h(),n=m();return Array.isArray(e)?e.map(e=>t.getDictionary(e,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 r.useDictionary(e.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("../getIntlayer.cjs"),t=require("./IntlayerProvider.cjs");let n=require("solid-js");var r=(r,i)=>{let a=(0,n.useContext)(t.IntlayerClientContext)??{},o=(0,n.createMemo)(()=>{let t=a?.locale();return e.getIntlayer(r,i??t)});return new Proxy(o,{get(e,t){return e()?.[t]},apply(e,t,n){return Reflect.apply(e,t,n)}})};exports.useIntlayer=r;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./IntlayerProvider.cjs");let n=require("solid-js");var r=(r,i)=>{let a=(0,n.useContext)(t.IntlayerClientContext)??{},o=(0,n.createMemo)(()=>{let t=a?.locale?.();return typeof i==`object`&&i?e.getIntlayer(r,{...i,locale:i.locale??t}):e.getIntlayer(r,i??t)});return new Proxy(o,{get(e,t){return e()?.[t]},apply(e,t,n){return Reflect.apply(e,t,n)}})};exports.useIntlayer=r;
|
|
@@ -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
|
|
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=t=>{let r=i=>new Proxy(()=>void 0,{get(o,s){if(s===e.PROXY_RESERVED_KEYS.promiseThen)return;let u=a(t(),i);if(u!=null)return s===Symbol.toPrimitive?()=>u:c(u,Reflect.get(Object(u),s));let d=l(s);return d===n?r([...i,s]):d},apply(e,n,o){let s=a(t(),i);return typeof s==`function`?Reflect.apply(s,n,o):o.length===0?s??``:r(i)}});return r([])},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("../plugins-B7eHFnAa.js");let t=require("@intlayer/core/interpreter");var n=(n,r)=>(0,t.getDictionary)(n,r,e.t(r));exports.getDictionary=n;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../plugins-B7eHFnAa.js");let t=require("@intlayer/core/interpreter");var n=(n,r)=>(0,t.getDictionary)(n,r,e.t(typeof r==`object`&&r?r.locale:r));exports.getDictionary=n;
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../plugins-B7eHFnAa.js");let t=require("@intlayer/core/interpreter");var n=(n,r)=>(0,t.getIntlayer)(n,r,e.t(r));exports.getIntlayer=n;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../plugins-B7eHFnAa.js");let t=require("@intlayer/core/interpreter");var n=(n,r)=>(0,t.getIntlayer)(n,r,e.t(typeof r==`object`&&r?r.locale:r));exports.getIntlayer=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDictionary.cjs");exports.useDictionary=e.useDictionary;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../client/useDictionary.cjs");let t=require("solid-js");var n=(n,r)=>((0,t.createResource)(()=>n,{initialValue:n,ssrLoadFrom:`initial`}),e.useDictionary(n,r));exports.useDictionary=n;
|
|
@@ -3,7 +3,13 @@ import { IntlayerClientContext as t } from "./IntlayerProvider.mjs";
|
|
|
3
3
|
import { createMemo as n, useContext as r } from "solid-js";
|
|
4
4
|
//#region src/client/useDictionary.ts
|
|
5
5
|
var i = (i, a) => {
|
|
6
|
-
let o = r(t) ?? {}, s = n(() =>
|
|
6
|
+
let o = r(t) ?? {}, s = n(() => {
|
|
7
|
+
let t = o?.locale?.();
|
|
8
|
+
return typeof a == "object" && a ? e(i, {
|
|
9
|
+
...a,
|
|
10
|
+
locale: a.locale ?? t
|
|
11
|
+
}) : e(i, a ?? t);
|
|
12
|
+
});
|
|
7
13
|
return new Proxy(s, {
|
|
8
14
|
get(e, t) {
|
|
9
15
|
return e()?.[t];
|
|
@@ -1,21 +1,60 @@
|
|
|
1
1
|
import { useLoadDynamic as e } from "./useLoadDynamic.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { getDictionary as t } from "../getDictionary.mjs";
|
|
3
|
+
import { IntlayerClientContext as n } from "./IntlayerProvider.mjs";
|
|
4
|
+
import { useDictionary as r } from "./useDictionary.mjs";
|
|
5
|
+
import { internationalization as i } from "@intlayer/config/built";
|
|
6
|
+
import { createMemo as a, createRenderEffect as o, createResource as s, useContext as c } from "solid-js";
|
|
7
|
+
import { QUALIFIER_DYNAMIC_TYPES_KEY as l, getDictionarySelectorCacheKey as u, isQualifiedDynamicLoaderMap as d, parseDictionarySelector as f, resolveQualifiedDynamicContentAsync as p } from "@intlayer/core/dictionaryManipulator";
|
|
6
8
|
//#region src/client/useDictionaryDynamic.ts
|
|
7
|
-
var
|
|
8
|
-
let { locale:
|
|
9
|
-
|
|
10
|
-
let
|
|
9
|
+
var m = (m, h, g) => {
|
|
10
|
+
let { locale: _ } = c(n) ?? {}, v = i.defaultLocale, y = String(h);
|
|
11
|
+
if (d(m)) {
|
|
12
|
+
let { locale: n, selector: i } = f(g), c = u(i), d = m[l].includes("item") && i?.item === void 0, h = () => n ?? _?.() ?? v;
|
|
13
|
+
if (!d) return r(e(() => {
|
|
14
|
+
let e = h();
|
|
15
|
+
return {
|
|
16
|
+
cacheKey: `${y}.${e}.${c}`,
|
|
17
|
+
locale: e
|
|
18
|
+
};
|
|
19
|
+
}, ({ locale: e }) => p({
|
|
20
|
+
loaderMap: m,
|
|
21
|
+
key: y,
|
|
22
|
+
locale: e,
|
|
23
|
+
selector: i,
|
|
24
|
+
transform: (e) => e
|
|
25
|
+
}).then((e) => Array.isArray(e) ? e[0] : e)), n);
|
|
26
|
+
let [b] = s(h, (e) => p({
|
|
27
|
+
loaderMap: m,
|
|
28
|
+
key: y,
|
|
29
|
+
locale: e,
|
|
30
|
+
selector: i,
|
|
31
|
+
transform: (e) => e
|
|
32
|
+
})), x = a(() => {
|
|
33
|
+
let e = b(), n = h();
|
|
34
|
+
return Array.isArray(e) ? e.map((e) => t(e, n)) : [];
|
|
35
|
+
});
|
|
36
|
+
return o(() => {
|
|
37
|
+
b();
|
|
38
|
+
}), new Proxy(x, {
|
|
39
|
+
get(e, t) {
|
|
40
|
+
return e()?.[t];
|
|
41
|
+
},
|
|
42
|
+
apply(e) {
|
|
43
|
+
return e();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
let b = m, x = g, S = () => x ?? _?.() ?? v;
|
|
48
|
+
return r(e(() => {
|
|
49
|
+
let e = S();
|
|
11
50
|
return {
|
|
12
|
-
cacheKey: `${
|
|
51
|
+
cacheKey: `${y}.${e}`,
|
|
13
52
|
locale: e
|
|
14
53
|
};
|
|
15
54
|
}, ({ locale: e }) => {
|
|
16
|
-
let t =
|
|
17
|
-
return t ? t() : Promise.reject(/* @__PURE__ */ Error(`No dynamic dictionary loader found for key "${
|
|
18
|
-
}),
|
|
55
|
+
let t = b[e];
|
|
56
|
+
return t ? t() : Promise.reject(/* @__PURE__ */ Error(`No dynamic dictionary loader found for key "${y}" and locale "${e}".`));
|
|
57
|
+
}), x);
|
|
19
58
|
};
|
|
20
59
|
//#endregion
|
|
21
|
-
export {
|
|
60
|
+
export { m as useDictionaryDynamic };
|
|
@@ -4,8 +4,11 @@ import { createMemo as n, useContext as r } from "solid-js";
|
|
|
4
4
|
//#region src/client/useIntlayer.ts
|
|
5
5
|
var i = (i, a) => {
|
|
6
6
|
let o = r(t) ?? {}, s = n(() => {
|
|
7
|
-
let t = o?.locale();
|
|
8
|
-
return e(i,
|
|
7
|
+
let t = o?.locale?.();
|
|
8
|
+
return typeof a == "object" && a ? e(i, {
|
|
9
|
+
...a,
|
|
10
|
+
locale: a.locale ?? t
|
|
11
|
+
}) : e(i, a ?? t);
|
|
9
12
|
});
|
|
10
13
|
return new Proxy(s, {
|
|
11
14
|
get(e, t) {
|
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
import { PROXY_RESERVED_KEYS as e } from "../proxyKeys.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { createRenderEffect as t, createResource as n } from "solid-js";
|
|
3
3
|
//#region src/client/useLoadDynamic.ts
|
|
4
|
-
var
|
|
4
|
+
var r = Symbol("NO_PENDING_PRIMITIVE_FALLBACK"), i = /* @__PURE__ */ new Map(), a = (e) => typeof e == "string" ? e : e.cacheKey, o = (e, t) => t.reduce((e, t) => {
|
|
5
5
|
if (e != null) return Reflect.get(Object(e), t);
|
|
6
|
-
}, e),
|
|
7
|
-
let n =
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
let
|
|
6
|
+
}, e), s = (e, t) => typeof e == "function" ? e(t) : e, c = (e, t) => {
|
|
7
|
+
let n = a(e), r = i.get(n);
|
|
8
|
+
if (r?.status === "success") return r.value;
|
|
9
|
+
if (r?.status === "pending") return r.promise;
|
|
10
|
+
let o = s(t, e).then((e) => (i.set(n, {
|
|
11
11
|
status: "success",
|
|
12
12
|
value: e
|
|
13
13
|
}), e), (e) => {
|
|
14
|
-
throw
|
|
14
|
+
throw i.delete(n), e;
|
|
15
15
|
});
|
|
16
|
-
return
|
|
16
|
+
return i.set(n, {
|
|
17
17
|
status: "pending",
|
|
18
|
-
promise:
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
promise: o
|
|
19
|
+
}), o;
|
|
20
|
+
}, l = (e, t) => typeof t == "function" ? t.bind(e) : t, u = (t) => t === Symbol.toPrimitive ? () => "" : t === Symbol.iterator ? () => ({ next: () => ({
|
|
21
|
+
done: !0,
|
|
22
|
+
value: void 0
|
|
23
|
+
}) }) : t === "length" ? 0 : t === e.toString ? () => "" : t === e.valueOf ? () => void 0 : t === e.value ? "" : r, d = (t) => {
|
|
24
|
+
let n = (i) => new Proxy(() => void 0, {
|
|
25
|
+
get(a, s) {
|
|
23
26
|
if (s === e.promiseThen) return;
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
26
|
-
let d =
|
|
27
|
-
return d ===
|
|
27
|
+
let c = o(t(), i);
|
|
28
|
+
if (c != null) return s === Symbol.toPrimitive ? () => c : l(c, Reflect.get(Object(c), s));
|
|
29
|
+
let d = u(s);
|
|
30
|
+
return d === r ? n([...i, s]) : d;
|
|
28
31
|
},
|
|
29
|
-
apply(e,
|
|
30
|
-
let s =
|
|
31
|
-
return typeof s == "function" ? Reflect.apply(s,
|
|
32
|
+
apply(e, r, a) {
|
|
33
|
+
let s = o(t(), i);
|
|
34
|
+
return typeof s == "function" ? Reflect.apply(s, r, a) : a.length === 0 ? s ?? "" : n(i);
|
|
32
35
|
}
|
|
33
36
|
});
|
|
34
|
-
return
|
|
35
|
-
},
|
|
36
|
-
let [
|
|
37
|
-
return
|
|
37
|
+
return n([]);
|
|
38
|
+
}, f = (e, r) => {
|
|
39
|
+
let [i] = n(() => typeof e == "function" ? e() : e, (e) => c(e, r));
|
|
40
|
+
return t(() => {
|
|
41
|
+
i();
|
|
42
|
+
}), d(() => i());
|
|
38
43
|
};
|
|
39
44
|
//#endregion
|
|
40
|
-
export { d as useLoadDynamic };
|
|
45
|
+
export { d as createLoadableProxy, a as getDynamicSourceCacheKey, c as loadDynamicValue, f as useLoadDynamic };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getPlugins as e } from "./plugins.mjs";
|
|
2
2
|
import { getDictionary as t } from "@intlayer/core/interpreter";
|
|
3
3
|
//#region src/getDictionary.ts
|
|
4
|
-
var n = (n, r) => t(n, r, e(r));
|
|
4
|
+
var n = (n, r) => t(n, r, e(typeof r == "object" && r ? r.locale : r));
|
|
5
5
|
//#endregion
|
|
6
6
|
export { n as getDictionary };
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getPlugins as e } from "./plugins.mjs";
|
|
2
2
|
import { getIntlayer as t } from "@intlayer/core/interpreter";
|
|
3
3
|
//#region src/getIntlayer.ts
|
|
4
|
-
var n = (n, r) => t(n, r, e(r));
|
|
4
|
+
var n = (n, r) => t(n, r, e(typeof r == "object" && r ? r.locale : r));
|
|
5
5
|
//#endregion
|
|
6
6
|
export { n as getIntlayer };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useDictionary as e } from "../client/useDictionary.mjs";
|
|
2
|
+
import { createResource as t } from "solid-js";
|
|
3
|
+
//#region src/server/useDictionary.ts
|
|
4
|
+
var n = (n, r) => (t(() => n, {
|
|
5
|
+
initialValue: n,
|
|
6
|
+
ssrLoadFrom: "initial"
|
|
7
|
+
}), e(n, r));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as useDictionary };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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("./cjs/IntlayerNode.cjs"),l=require("./cjs/client/useLoadDynamic.cjs"),u=require("./cjs/solidElement/renderSolidElement.cjs");let d=require("@intlayer/core/interpreter"),f=require("solid-js/web"),p=require("@intlayer/config/built"),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("./cjs/editor/ContentSelector.cjs")).then(e=>({default:e.ContentSelector}))),v=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?null:Promise.resolve().then(()=>require("./cjs/markdown/MarkdownRenderer.cjs")).then(e=>({MarkdownRenderer:e.MarkdownRenderer,MarkdownMetadataRenderer:e.MarkdownMetadataRenderer})),y=process.env.INTLAYER_NODE_TYPE_HTML===`false`?null:Promise.resolve().then(()=>require("./cjs/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})=>c.renderIntlayerNode({...n,value:n.children,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(g.Suspense,{get fallback(){return n.children},get children(){return(0,f.createComponent)(_,(0,f.mergeProps)(n,{get children(){return n.children}}))}}):n.children})},x=process.env.INTLAYER_NODE_TYPE_SOLID_NODE===`false`?d.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})=>c.renderIntlayerNode({...n,value:`[[solid-element]]`,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(g.Suspense,{get fallback(){return typeof Node<`u`&&e instanceof Node?e:u.renderSolidElement(e)},get children(){return(0,f.createComponent)(_,(0,f.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,d.splitInsertionTemplate)(e,t);return n.isSimple,n.parts},C=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?d.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`,transform:(n,r,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=e=>{let{MarkdownRenderer:t}=l.useLoadDynamic(`solid-markdown-renderer`,v);return(0,f.createComponent)(t,e)},T=e=>{let{MarkdownMetadataRenderer:t}=l.useLoadDynamic(`solid-markdown-renderer`,v);return(0,f.createComponent)(t,e)},E=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?d.fallbackPlugin:{id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,t,n)=>{let{plugins:r,...i}=t,a=n((0,m.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>c.renderIntlayerNode({...n,value:t,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(g.Suspense,{get children(){return(0,f.createComponent)(_,(0,f.mergeProps)(i,{get children(){return(0,f.createComponent)(T,(0,f.mergeProps)(i,{get metadataKeyPath(){return n.keyPath},children:e}))}}))}}):(0,f.createComponent)(T,(0,f.mergeProps)(i,{get metadataKeyPath(){return n.keyPath},children:e}))})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=n=>c.renderIntlayerNode({...t,value:e,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(g.Suspense,{get children(){return(0,f.createComponent)(_,(0,f.mergeProps)(i,{get children(){return(0,f.createComponent)(w,(0,f.mergeProps)(i,{components:n,children:e}))}}))}}):(0,f.createComponent)(w,(0,f.mergeProps)(i,{components:n,children:e})),additionalProps:{metadata:a}}),s=o();return new Proxy(s,{get(t,n,r){if(n===`value`)return e;if(n===Symbol.toPrimitive||n===`toString`||n===`valueOf`)return()=>e;if(typeof n==`string`&&n!==`constructor`){let t=String.prototype[n];if(typeof t==`function`)return t.bind(e)}return n===`metadata`?a:n===`use`?e=>o(e):Reflect.get(t,n,r)}})}},D=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?d.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=e=>(0,f.createComponent)(l.useLoadDynamic(`solid-html-renderer`,y),e),k=process.env.INTLAYER_NODE_TYPE_HTML===`false`?d.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.HTML,transform:(e,t)=>{let n=e[h.HTML],{plugins:r,...i}=t,a=e=>c.renderIntlayerNode({...i,value:n,children:process.env.INTLAYER_EDITOR_ENABLED!==`false`&&p.editor.enabled?(0,f.createComponent)(g.Suspense,{get children(){return(0,f.createComponent)(_,(0,f.mergeProps)(i,{get children(){return(0,f.createComponent)(O,(0,f.mergeProps)(i,{html:n,components:e}))}}))}}):(0,f.createComponent)(O,(0,f.mergeProps)(i,{html:n,components:e}))}),o=[a()];return new Proxy(o,{get(e,t,r){if(t===`value`)return n;if(t===Symbol.toPrimitive||t===`toString`||t===`valueOf`)return()=>n;if(typeof t==`string`&&t!==`constructor`){let e=String.prototype[t];if(typeof e==`function`)return e.bind(n)}return t===`use`?e=>a(e):Reflect.get(e,t,r)}})}},A=new Map,j=(e,t=!0)=>{let n=`${e??p.internationalization.defaultLocale}_${t}`;if(A.has(n))return A.get(n);let r=[(0,d.translationPlugin)(e??p.internationalization.defaultLocale,t?p.internationalization.defaultLocale:void 0),d.enumerationPlugin,(0,d.pluralPlugin)(e??p.internationalization.defaultLocale),d.conditionPlugin,(0,d.nestedPlugin)(e??p.internationalization.defaultLocale),d.filePlugin,d.genderPlugin,b,x,C,D,k];return A.set(n,r),r};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return j}});
|
|
@@ -3,7 +3,7 @@ import { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';
|
|
|
3
3
|
* On the client side, hook to get the translation content based on the locale
|
|
4
4
|
*/
|
|
5
5
|
export declare const useContent: <Content>(languageContent: StrictModeLocaleMap<Content>) => {
|
|
6
|
-
locale: import('
|
|
6
|
+
locale: import('intlayer').Locale;
|
|
7
7
|
content: Content;
|
|
8
8
|
t: <Content_1 = string>(languageContent: StrictModeLocaleMap<Content_1>) => Content_1;
|
|
9
9
|
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
-
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
1
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from '@intlayer/types/dictionary';
|
|
2
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
3
|
import { DeepTransformContent } from '../plugins';
|
|
4
4
|
/**
|
|
5
|
-
* On the client side, Hook that
|
|
5
|
+
* On the client side, Hook that transforms a dictionary (or qualified
|
|
6
|
+
* dictionary group) and returns its reactive content.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* The second argument is either a locale or a selector object
|
|
9
|
+
* (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`).
|
|
10
|
+
*
|
|
11
|
+
* If the locale is not provided (directly or through the selector), it will
|
|
12
|
+
* use the locale from the client context.
|
|
8
13
|
*/
|
|
9
|
-
export declare const useDictionary: <const T extends Dictionary, const
|
|
14
|
+
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
|
|
@@ -5,4 +5,4 @@ import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from '@intlayer/t
|
|
|
5
5
|
*
|
|
6
6
|
* If the locale is not provided, it will use the locale from the client context
|
|
7
7
|
*/
|
|
8
|
-
export declare const useDictionaryAsync: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: L) => Promise<import('@intlayer/core/interpreter').DeepTransformContent<T
|
|
8
|
+
export declare const useDictionaryAsync: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: L) => Promise<import('@intlayer/core/interpreter').DeepTransformContent<import('@intlayer/types').ResolveQualifiedDictionaryContent<T, L>, import('../plugins').IInterpreterPluginState, import('@intlayer/types').ExtractSelectorLocale<L>>>;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { QualifiedDynamicLoaderMap } from '@intlayer/core/dictionaryManipulator';
|
|
1
2
|
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
-
import { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';
|
|
3
|
+
import { DictionaryKeys, DictionarySelectorForKey, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';
|
|
4
|
+
import { DeepTransformContent } from '../plugins';
|
|
3
5
|
/**
|
|
4
|
-
* On the client side, Hook that
|
|
6
|
+
* On the client side, Hook that lazily loads a dictionary and returns its
|
|
7
|
+
* reactive content.
|
|
5
8
|
*
|
|
6
|
-
*
|
|
9
|
+
* The dictionary entry is either a plain dynamic loader map
|
|
10
|
+
* (`locale → loader`) or a qualified one (collection / variant / meta record,
|
|
11
|
+
* possibly combined). For a qualified map, only the chunk(s) the selector
|
|
12
|
+
* targets are loaded; the resolution mirrors static mode.
|
|
13
|
+
*
|
|
14
|
+
* If the locale is not provided (directly or through the selector), it will
|
|
15
|
+
* use the locale from the client context.
|
|
7
16
|
*/
|
|
8
|
-
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T
|
|
17
|
+
export declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<K> = LocalesValues>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>> | QualifiedDynamicLoaderMap, key: K, localeOrSelector?: A) => DeepTransformContent<T["content"]> | import('@intlayer/core/interpreter').DeepTransformContent<import('@intlayer/types').ResolveQualifiedDictionaryContent<T, (string & {}) | "tr" | "th" | "hr" | "mi" | "mn" | "ms" | "is" | "id" | "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is-IS" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi-NZ" | "mr" | "mr-IN" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA">, import('../plugins').IInterpreterPluginState, (string & {}) | "tr" | "th" | "hr" | "mi" | "mn" | "ms" | "is" | "id" | "af" | "af-ZA" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-TD" | "ar-KM" | "ar-DJ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MR" | "ar-MA" | "ar-OM" | "ar-PS" | "ar-QA" | "ar-SA" | "ar-SO" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-YE" | "hy" | "hy-AM" | "az" | "az-AZ" | "eu" | "eu-ES" | "be" | "be-BY" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "bs" | "bs-BA" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "zh" | "zh-HK" | "zh-MO" | "zh-Hans" | "zh-CN" | "zh-SG" | "zh-TW" | "zh-Hant" | "hr-BA" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dv" | "dv-MV" | "nl" | "nl-BE" | "nl-NL" | "en" | "en-AU" | "en-BZ" | "en-BW" | "en-CA" | "en-CB" | "en-GH" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-KE" | "en-MY" | "en-NZ" | "en-NG" | "en-PK" | "en-PH" | "en-SG" | "en-ZA" | "en-TZ" | "en-TT" | "en-UG" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "fo" | "fo-FO" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-CA" | "fr-FR" | "fr-LU" | "fr-MC" | "fr-CH" | "mk" | "mk-MK" | "gl" | "gl-ES" | "ka" | "ka-GE" | "de" | "de-AT" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-GR" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is-IS" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "kn" | "kn-IN" | "kk" | "kk-KZ" | "km" | "km-KH" | "kok" | "kok-IN" | "ko" | "ko-KR" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lo" | "lo-LA" | "lv" | "lv-LV" | "lt" | "lt-LT" | "dsb" | "dsb-DE" | "mg-MG" | "ml" | "ml-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "mi-NZ" | "mr" | "mr-IN" | "mn-MN" | "ne" | "ne-NP" | "ns" | "ns-ZA" | "no" | "nb" | "nb-NO" | "nn" | "nn-NO" | "ps" | "ps-AR" | "pl" | "pl-PL" | "pt" | "pt-BR" | "pt-CV" | "pt-GW" | "pt-MO" | "pt-MZ" | "pt-PT" | "pt-ST" | "pt-TL" | "pa" | "pa-IN" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "ru" | "ru-MD" | "ru-RU" | "se" | "se-FI" | "se-NO" | "se-SE" | "sa" | "sa-IN" | "gd" | "gd-GB" | "sr-Cyrl" | "sr-BA" | "sr-RS" | "sr" | "sr-SP" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-CU" | "es-DO" | "es-EC" | "es-SV" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sv" | "sv-FI" | "sv-SE" | "syr" | "syr-SY" | "tl" | "tl-PH" | "ta" | "ta-IN" | "tt" | "tt-RU" | "te" | "te-IN" | "th-TH" | "ts" | "tn" | "tn-ZA" | "tr-TR" | "uk" | "uk-UA" | "hsb" | "hsb-DE" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "ve" | "ve-ZA" | "vi" | "vi-VN" | "cy" | "cy-GB" | "xh" | "xh-ZA" | "yi" | "yi-001" | "yo" | "yo-NG" | "zu" | "zu-ZA">;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { DeclaredLocales, DictionaryKeys,
|
|
1
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
2
|
import { DeepTransformContent } from '../plugins';
|
|
3
3
|
/**
|
|
4
4
|
* Solid hook that picks one dictionary by its key and returns its reactive content.
|
|
5
5
|
*
|
|
6
|
+
* The second argument is either a locale or a selector object:
|
|
7
|
+
* - `{ item: 2 }` — collection item (omit `item` to get every item as array)
|
|
8
|
+
* - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
|
|
9
|
+
* - `{ id: 'prod_abc', ...metaFields }` — meta record
|
|
10
|
+
* - `locale` composes with any selector and overrides the context locale
|
|
11
|
+
*
|
|
6
12
|
* Supports both direct property access and the accessor call form:
|
|
7
13
|
* - `content.myField.value` — reactive when used inside JSX or other Solid reactive contexts
|
|
8
14
|
* - `content()` — backward-compatible accessor form
|
|
9
15
|
*
|
|
10
16
|
* @param key - The unique key of the dictionary to retrieve.
|
|
11
|
-
* @param
|
|
17
|
+
* @param localeOrSelector - Optional locale or selector.
|
|
12
18
|
* @returns Reactive content accessible via property access or function call.
|
|
13
19
|
*
|
|
14
20
|
* @example
|
|
@@ -17,9 +23,10 @@ import { DeepTransformContent } from '../plugins';
|
|
|
17
23
|
*
|
|
18
24
|
* const MyComponent = () => {
|
|
19
25
|
* const content = useIntlayer('my-dictionary-key');
|
|
26
|
+
* const faq2 = useIntlayer('faq', { item: 2 });
|
|
20
27
|
*
|
|
21
28
|
* return <div>{content.myField.value}</div>;
|
|
22
29
|
* };
|
|
23
30
|
* ```
|
|
24
31
|
*/
|
|
25
|
-
export declare const useIntlayer: <const T extends DictionaryKeys, const
|
|
32
|
+
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
|
|
@@ -2,13 +2,14 @@ type DynamicSource = string | {
|
|
|
2
2
|
cacheKey: string;
|
|
3
3
|
};
|
|
4
4
|
type DynamicKey<T extends DynamicSource> = T | (() => T);
|
|
5
|
-
type DynamicLoader<T, Source extends DynamicSource> = Promise<T> | ((source: Source) => Promise<T>);
|
|
5
|
+
export type DynamicLoader<T, Source extends DynamicSource> = Promise<T> | ((source: Source) => Promise<T>);
|
|
6
|
+
export declare const getDynamicSourceCacheKey: (source: DynamicSource) => string;
|
|
7
|
+
export declare const loadDynamicValue: <T, Source extends DynamicSource>(source: Source, loader: DynamicLoader<T, Source>) => T | Promise<T>;
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* proxy-backed (not a plain accessor) because Intlayer content is read
|
|
11
|
-
* synchronously.
|
|
9
|
+
* Creates a stable callable proxy that re-reads the Solid resource on each
|
|
10
|
+
* property access. This keeps synchronous Intlayer access (`content.x.value`)
|
|
11
|
+
* safe while Solid Suspense owns the actual pending state.
|
|
12
12
|
*/
|
|
13
|
+
export declare const createLoadableProxy: <T>(read: () => T | undefined) => T;
|
|
13
14
|
export declare const useLoadDynamic: <T, Source extends DynamicSource = string>(key: DynamicKey<Source>, loader: DynamicLoader<T, Source>) => T;
|
|
14
15
|
export {};
|
|
@@ -2,13 +2,13 @@ import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the locale cookie
|
|
4
4
|
*/
|
|
5
|
-
export declare const localeInStorage: import('
|
|
5
|
+
export declare const localeInStorage: import('intlayer').Locale | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Use localeInStorage instead
|
|
8
8
|
*
|
|
9
9
|
* Get the locale cookie
|
|
10
10
|
*/
|
|
11
|
-
export declare const localeCookie: import('
|
|
11
|
+
export declare const localeCookie: import('intlayer').Locale | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Set the locale cookie
|
|
14
14
|
*/
|
|
@@ -23,7 +23,7 @@ export declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled?:
|
|
|
23
23
|
* Hook that provides the locale storage and a function to set it
|
|
24
24
|
*/
|
|
25
25
|
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => import('solid-js').Accessor<{
|
|
26
|
-
getLocale: () => import('
|
|
26
|
+
getLocale: () => import('intlayer').Locale;
|
|
27
27
|
setLocale: (locale: LocalesValues) => void;
|
|
28
28
|
}>;
|
|
29
29
|
/**
|
|
@@ -34,6 +34,6 @@ export declare const useLocaleStorage: (isCookieEnabled?: boolean) => import('so
|
|
|
34
34
|
* Hook that provides the locale cookie and a function to set it
|
|
35
35
|
*/
|
|
36
36
|
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => import('solid-js').Accessor<{
|
|
37
|
-
getLocale: () => import('
|
|
37
|
+
getLocale: () => import('intlayer').Locale;
|
|
38
38
|
setLocale: (locale: LocalesValues) => void;
|
|
39
39
|
}>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
-
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
1
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from '@intlayer/types/dictionary';
|
|
2
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
3
|
import { DeepTransformContent } from './plugins';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Transforms a dictionary (or qualified dictionary group) and returns its
|
|
6
|
+
* content for the given locale or selector (`{ item }`, `{ variant }`,
|
|
7
|
+
* `{ id, ...meta }`, optionally combined with `locale`).
|
|
8
|
+
*/
|
|
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,3 +1,8 @@
|
|
|
1
|
-
import { DeclaredLocales, DictionaryKeys,
|
|
1
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
2
|
import { DeepTransformContent } from './plugins';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Picks one dictionary by its key and returns its content for the given
|
|
5
|
+
* locale or selector (`{ item }`, `{ variant }`, `{ id, ...meta }`,
|
|
6
|
+
* optionally combined with `locale`).
|
|
7
|
+
*/
|
|
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>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useDictionary } from './useDictionary';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from '@intlayer/types/dictionary';
|
|
2
|
+
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
+
/**
|
|
4
|
+
* Server-rendering counterpart of `useDictionaryDynamic`, emitted by the
|
|
5
|
+
* optimizer in the server bundle so dynamic-mode dictionaries render
|
|
6
|
+
* synchronously from static JSON.
|
|
7
|
+
*
|
|
8
|
+
* The second argument is either a locale or a selector object
|
|
9
|
+
* (`{ item }`, `{ variant }`, `{ id, ...meta }`, optionally with `locale`),
|
|
10
|
+
* forwarded to the client `useDictionary`.
|
|
11
|
+
*
|
|
12
|
+
* The discarded `createResource` is load-bearing: Solid assigns hydration
|
|
13
|
+
* ids from a positional counter shared by resources and element `data-hk`
|
|
14
|
+
* keys, and the client bundle consumes one resource slot per call (see
|
|
15
|
+
* `useLoadDynamic`) — without the matching slot here, every subsequent
|
|
16
|
+
* hydration key shifts and event bindings are silently lost.
|
|
17
|
+
* `ssrLoadFrom: 'initial'` keeps the dictionary out of the SSR serialization
|
|
18
|
+
* payload, so it is not shipped twice in the HTML.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => import('@intlayer/core/interpreter').DeepTransformContent<import('@intlayer/types').ResolveQualifiedDictionaryContent<T, A>, import('../plugins').IInterpreterPluginState, import('@intlayer/types').ExtractSelectorLocale<A>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-intlayer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -58,6 +58,12 @@
|
|
|
58
58
|
"require": "./dist/cjs/format/index.cjs",
|
|
59
59
|
"import": "./dist/esm/format/index.mjs"
|
|
60
60
|
},
|
|
61
|
+
"./server": {
|
|
62
|
+
"types": "./dist/types/server/index.d.ts",
|
|
63
|
+
"solid": "./dist/esm/server/index.mjs",
|
|
64
|
+
"require": "./dist/cjs/server/index.cjs",
|
|
65
|
+
"import": "./dist/esm/server/index.mjs"
|
|
66
|
+
},
|
|
61
67
|
"./package.json": "./package.json"
|
|
62
68
|
},
|
|
63
69
|
"main": "dist/cjs/index.cjs",
|
|
@@ -77,6 +83,9 @@
|
|
|
77
83
|
"format": [
|
|
78
84
|
"./dist/types/format/index.d.ts"
|
|
79
85
|
],
|
|
86
|
+
"server": [
|
|
87
|
+
"./dist/types/server/index.d.ts"
|
|
88
|
+
],
|
|
80
89
|
"package.json": [
|
|
81
90
|
"./package.json"
|
|
82
91
|
]
|
|
@@ -104,17 +113,17 @@
|
|
|
104
113
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
105
114
|
},
|
|
106
115
|
"dependencies": {
|
|
107
|
-
"@intlayer/api": "
|
|
108
|
-
"@intlayer/config": "
|
|
109
|
-
"@intlayer/core": "
|
|
110
|
-
"@intlayer/editor": "
|
|
111
|
-
"@intlayer/types": "
|
|
116
|
+
"@intlayer/api": "9.0.0-canary.0",
|
|
117
|
+
"@intlayer/config": "9.0.0-canary.0",
|
|
118
|
+
"@intlayer/core": "9.0.0-canary.0",
|
|
119
|
+
"@intlayer/editor": "9.0.0-canary.0",
|
|
120
|
+
"@intlayer/types": "9.0.0-canary.0"
|
|
112
121
|
},
|
|
113
122
|
"devDependencies": {
|
|
114
123
|
"@solidjs/testing-library": "0.8.10",
|
|
115
124
|
"@testing-library/jest-dom": "6.9.1",
|
|
116
125
|
"@testing-library/user-event": "14.6.1",
|
|
117
|
-
"@types/node": "25.9.
|
|
126
|
+
"@types/node": "25.9.3",
|
|
118
127
|
"@utils/ts-config": "1.0.4",
|
|
119
128
|
"@utils/ts-config-types": "1.0.4",
|
|
120
129
|
"@utils/tsdown-config": "1.0.4",
|