solid-intlayer 9.8.5 → 9.9.1
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/contentProxy.cjs +1 -0
- package/dist/cjs/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/cjs/solidTypes.cjs +1 -0
- package/dist/esm/client/contentProxy.mjs +17 -0
- package/dist/esm/client/useDictionary.mjs +22 -28
- package/dist/esm/client/useDictionaryAsync.mjs +5 -4
- package/dist/esm/client/useDictionaryDynamic.mjs +44 -67
- package/dist/esm/client/useIntlayer.mjs +13 -19
- package/dist/esm/solidTypes.mjs +0 -0
- package/dist/solid/client/contentProxy.js +31 -0
- package/dist/solid/client/useDictionary.js +2 -8
- package/dist/solid/client/useDictionaryAsync.js +2 -1
- package/dist/solid/client/useDictionaryDynamic.js +56 -80
- package/dist/solid/client/useIntlayer.js +2 -8
- package/dist/solid/plugins.jsx +1 -1
- package/dist/solid/solidTypes.js +0 -0
- package/dist/types/IntlayerNode.d.ts +4 -3
- package/dist/types/LoadingBoundary.d.ts +4 -3
- package/dist/types/client/contentProxy.d.ts +15 -0
- package/dist/types/client/useDictionaryDynamic.d.ts +4 -5
- package/dist/types/client/useLocaleStorage.d.ts +4 -8
- package/dist/types/editor/ContentSelector.d.ts +4 -13
- package/dist/types/format/useIntl.d.ts +2 -1
- package/dist/types/html/HTMLRenderer.d.ts +4 -3
- package/dist/types/html/types.d.ts +5 -4
- package/dist/types/markdown/MarkdownProvider.d.ts +4 -3
- package/dist/types/markdown/MarkdownRenderer.d.ts +5 -4
- package/dist/types/markdown/compiler.d.ts +2 -2
- package/dist/types/plugins.d.ts +7 -7
- package/dist/types/solidCompat.d.ts +7 -1
- package/dist/types/solidElement/renderSolidElement.d.ts +2 -2
- package/dist/types/solidTypes.d.ts +15 -0
- package/package.json +11 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>new Proxy(e,{get(e,t){let n=e();if(n==null)return;let r=Reflect.get(Object(n),t);return typeof r==`function`&&!Object.hasOwn(n,t)?r.bind(n):r},has(e,t){let n=e();return typeof n==`object`&&!!n&&t in n},apply(e){return e()}});exports.createContentProxy=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("../plugins.cjs"),n=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("../plugins.cjs"),n=require("./contentProxy.cjs"),r=require("./IntlayerProvider.cjs"),i=require("./useLoadDynamic.cjs");let a=require("@intlayer/core/interpreter"),o=require("solid-js"),s=require("@intlayer/core/dictionaryManipulator");var c=(c,l)=>{let u=(0,o.useContext)(r.IntlayerClientContext)??{},d=new Map,f=e=>{let n=t.getPlugins(e),r=d.get(n);return r||(r=[...n],d.set(n,r)),r},p=()=>{let t=u?.locale?.(),n=i.unwrapLoadable(c)??c;return process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?e.getDictionary(n,l??t,f):e.getDictionary(n,(0,s.resolveDictionaryArgument)({localeOrSelector:l,contextLocale:t,contextVariant:u?.variant?.(),dictionaryKey:c.key}),f)},m=(0,o.createMemo)(()=>{let{result:e,writes:t}=(0,a.collectTransformCacheWrites)(p);return t.length>0&&(0,o.onCleanup)(()=>(0,a.deleteTransformCacheWrites)(t)),e});return n.createContentProxy(m)};exports.useDictionary=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./IntlayerProvider.cjs"),t=require("./useDictionary.cjs");let n=require("@intlayer/core/interpreter"),r=require("solid-js");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./IntlayerProvider.cjs"),t=require("./useDictionary.cjs");let n=require("@intlayer/core/interpreter"),r=require("solid-js"),i=require("@intlayer/core/dictionaryManipulator");var a=async(a,o)=>{let{locale:s}=(0,r.useContext)(e.IntlayerClientContext)??{},c=o??s()??(0,n.resolveInterpreterLocale)(),l=await(0,i.loadDynamicDictionary)(a,c);return t.useDictionary(l,c)};exports.useDictionaryAsync=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("../solidCompat.cjs"),n=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("../solidCompat.cjs"),n=require("./contentProxy.cjs"),r=require("./IntlayerProvider.cjs"),i=require("./useDictionary.cjs"),a=require("./useLoadDynamic.cjs");let o=require("solid-js"),s=require("@intlayer/core/dictionaryManipulator");var c=e=>e,l=(t,n)=>e.getDictionary(t,n),u=(u,d,f)=>{let p=(0,o.useContext)(r.IntlayerClientContext)??{},m=String(d),h=u,{locale:g,selector:_}=process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?{locale:f,selector:void 0}:(0,s.parseDictionarySelector)(f),v=()=>(0,s.resolveDictionaryRead)({localeOrSelector:f,contextLocale:p.locale?.(),contextVariant:p.variant?.(),dictionaryKey:m}),y=()=>{let e=v(),t=process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?``:(0,s.getDictionarySelectorCacheKey)({...e.selector,metadataOnly:void 0});return{...e,cacheKey:t?`${m}.${e.locale}.${t}`:`${m}.${e.locale}`}},b=(e,t)=>(0,s.resolveDynamicContentAsync)({loaderMap:h,key:m,...e,transform:t}),x=(0,s.getDynamicChunkArgument)(g,_);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,s.isQualifiedDynamicLoaderMap)(h)&&h[s.QUALIFIER_DYNAMIC_TYPES_KEY].includes(`item`)&&_?.item===void 0){let r=t.createAsyncValue(v,e=>b(e,_?.metadataOnly?l:c)),i=(0,o.createMemo)(()=>{let t=r();if(!Array.isArray(t))return[];if(_?.metadataOnly)return t;let{locale:n}=v();return t.map(t=>e.getDictionary(t,n))});return t.trackAsyncValue(r),n.createContentProxy(i)}let S=y(),C=(0,s.getPreloadedDictionary)(h,S.locale);C&&a.seedDynamicValue(S,C);let w=a.useLoadDynamic(y,e=>b(e,c).then(t=>{if(t===null)throw Error(`No dynamic dictionary chunk found for key "${m}" and locale "${e.locale}".`);return t}));return i.useDictionary(w,x)};exports.useDictionaryDynamic=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./IntlayerProvider.cjs");let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getIntlayer.cjs"),t=require("./contentProxy.cjs"),n=require("./IntlayerProvider.cjs");let r=require("solid-js"),i=require("@intlayer/core/dictionaryManipulator");var a=(a,o)=>{let s=(0,r.useContext)(n.IntlayerClientContext)??{},c=(0,r.createMemo)(()=>{let t=s?.locale?.();return process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?e.getIntlayer(a,o??t):e.getIntlayer(a,(0,i.resolveDictionaryArgument)({localeOrSelector:o,contextLocale:t,contextVariant:s?.variant?.(),dictionaryKey:a}))});return t.createContentProxy(c)};exports.useIntlayer=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/client/contentProxy.ts
|
|
2
|
+
var e = (e) => new Proxy(e, {
|
|
3
|
+
get(e, t) {
|
|
4
|
+
let n = e();
|
|
5
|
+
if (n == null) return;
|
|
6
|
+
let r = Reflect.get(Object(n), t);
|
|
7
|
+
return typeof r == "function" && !Object.hasOwn(n, t) ? r.bind(n) : r;
|
|
8
|
+
},
|
|
9
|
+
has(e, t) {
|
|
10
|
+
let n = e();
|
|
11
|
+
return typeof n == "object" && !!n && t in n;
|
|
12
|
+
},
|
|
13
|
+
apply(e) {
|
|
14
|
+
return e();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export { e as createContentProxy };
|
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
import { getDictionary as e } from "../getDictionary.mjs";
|
|
2
2
|
import { getPlugins as t } from "../plugins.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { createContentProxy as n } from "./contentProxy.mjs";
|
|
4
|
+
import { IntlayerClientContext as r } from "./IntlayerProvider.mjs";
|
|
5
|
+
import { unwrapLoadable as i } from "./useLoadDynamic.mjs";
|
|
6
|
+
import { collectTransformCacheWrites as a, deleteTransformCacheWrites as o } from "@intlayer/core/interpreter";
|
|
7
|
+
import { createMemo as s, onCleanup as c, useContext as l } from "solid-js";
|
|
8
|
+
import { resolveDictionaryArgument as u } from "@intlayer/core/dictionaryManipulator";
|
|
8
9
|
// src/client/useDictionary.ts
|
|
9
|
-
var
|
|
10
|
-
let
|
|
11
|
-
let n = t(e), r =
|
|
12
|
-
return r || (r = [...n],
|
|
13
|
-
},
|
|
14
|
-
let t =
|
|
15
|
-
return process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? e(n,
|
|
16
|
-
localeOrSelector:
|
|
10
|
+
var d = (d, f) => {
|
|
11
|
+
let p = l(r) ?? {}, m = /* @__PURE__ */ new Map(), h = (e) => {
|
|
12
|
+
let n = t(e), r = m.get(n);
|
|
13
|
+
return r || (r = [...n], m.set(n, r)), r;
|
|
14
|
+
}, g = () => {
|
|
15
|
+
let t = p?.locale?.(), n = i(d) ?? d;
|
|
16
|
+
return process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? e(n, f ?? t, h) : e(n, u({
|
|
17
|
+
localeOrSelector: f,
|
|
17
18
|
contextLocale: t,
|
|
18
|
-
contextVariant:
|
|
19
|
-
dictionaryKey:
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
let { result: e, writes: t } =
|
|
23
|
-
return t.length > 0 &&
|
|
24
|
-
});
|
|
25
|
-
return new Proxy(g, {
|
|
26
|
-
get(e, t) {
|
|
27
|
-
return e()?.[t];
|
|
28
|
-
},
|
|
29
|
-
apply(e, t, n) {
|
|
30
|
-
return Reflect.apply(e, t, n);
|
|
31
|
-
}
|
|
19
|
+
contextVariant: p?.variant?.(),
|
|
20
|
+
dictionaryKey: d.key
|
|
21
|
+
}), h);
|
|
22
|
+
}, _ = s(() => {
|
|
23
|
+
let { result: e, writes: t } = a(g);
|
|
24
|
+
return t.length > 0 && c(() => o(t)), e;
|
|
32
25
|
});
|
|
26
|
+
return n(_);
|
|
33
27
|
};
|
|
34
|
-
export {
|
|
28
|
+
export { d as useDictionary };
|
|
@@ -2,9 +2,10 @@ import { IntlayerClientContext as e } from "./IntlayerProvider.mjs";
|
|
|
2
2
|
import { useDictionary as t } from "./useDictionary.mjs";
|
|
3
3
|
import { resolveInterpreterLocale as n } from "@intlayer/core/interpreter";
|
|
4
4
|
import { useContext as r } from "solid-js";
|
|
5
|
+
import { loadDynamicDictionary as i } from "@intlayer/core/dictionaryManipulator";
|
|
5
6
|
// src/client/useDictionaryAsync.ts
|
|
6
|
-
var
|
|
7
|
-
let { locale:
|
|
8
|
-
return t(
|
|
7
|
+
var a = async (a, o) => {
|
|
8
|
+
let { locale: s } = r(e) ?? {}, c = o ?? s() ?? n(), l = await i(a, c);
|
|
9
|
+
return t(l, c);
|
|
9
10
|
};
|
|
10
|
-
export {
|
|
11
|
+
export { a as useDictionaryAsync };
|
|
@@ -1,75 +1,52 @@
|
|
|
1
1
|
import { getDictionary as e } from "../getDictionary.mjs";
|
|
2
2
|
import { createAsyncValue as t, trackAsyncValue as n } from "../solidCompat.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { createContentProxy as r } from "./contentProxy.mjs";
|
|
4
|
+
import { IntlayerClientContext as i } from "./IntlayerProvider.mjs";
|
|
5
|
+
import { useDictionary as a } from "./useDictionary.mjs";
|
|
6
|
+
import { seedDynamicValue as o, useLoadDynamic as s } from "./useLoadDynamic.mjs";
|
|
7
7
|
import { createMemo as c, useContext as l } from "solid-js";
|
|
8
|
-
import { QUALIFIER_DYNAMIC_TYPES_KEY as u, getDictionarySelectorCacheKey as d,
|
|
8
|
+
import { QUALIFIER_DYNAMIC_TYPES_KEY as u, getDictionarySelectorCacheKey as d, getDynamicChunkArgument as f, getPreloadedDictionary as p, isQualifiedDynamicLoaderMap as m, parseDictionarySelector as h, resolveDictionaryRead as g, resolveDynamicContentAsync as _ } from "@intlayer/core/dictionaryManipulator";
|
|
9
9
|
// src/client/useDictionaryDynamic.ts
|
|
10
|
-
var
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
cacheKey: `${S}.${e}.${d(l())}`,
|
|
24
|
-
locale: e
|
|
25
|
-
};
|
|
26
|
-
}, ({ locale: e }) => g({
|
|
27
|
-
loaderMap: _,
|
|
28
|
-
key: S,
|
|
29
|
-
locale: e,
|
|
30
|
-
selector: l(),
|
|
31
|
-
transform: (e) => e
|
|
32
|
-
}).then((e) => Array.isArray(e) ? e[0] : e));
|
|
33
|
-
return i(e, r);
|
|
34
|
-
}
|
|
35
|
-
let v = t(() => ({
|
|
36
|
-
locale: p(),
|
|
37
|
-
selector: l()
|
|
38
|
-
}), ({ locale: e, selector: t }) => g({
|
|
39
|
-
loaderMap: _,
|
|
40
|
-
key: S,
|
|
41
|
-
locale: e,
|
|
42
|
-
selector: t,
|
|
43
|
-
transform: (e) => e
|
|
44
|
-
})), C = c(() => {
|
|
45
|
-
let t = v(), n = p();
|
|
46
|
-
return Array.isArray(t) ? t.map((t) => e(t, n)) : [];
|
|
10
|
+
var v = (e) => e, y = (t, n) => e(t, n), b = (b, x, S) => {
|
|
11
|
+
let C = l(i) ?? {}, w = String(x), T = b, { locale: E, selector: D } = process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? {
|
|
12
|
+
locale: S,
|
|
13
|
+
selector: void 0
|
|
14
|
+
} : h(S), O = () => g({
|
|
15
|
+
localeOrSelector: S,
|
|
16
|
+
contextLocale: C.locale?.(),
|
|
17
|
+
contextVariant: C.variant?.(),
|
|
18
|
+
dictionaryKey: w
|
|
19
|
+
}), k = () => {
|
|
20
|
+
let e = O(), t = process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? "" : d({
|
|
21
|
+
...e.selector,
|
|
22
|
+
metadataOnly: void 0
|
|
47
23
|
});
|
|
48
|
-
return n(v), new Proxy(C, {
|
|
49
|
-
get(e, t) {
|
|
50
|
-
let n = e(), r = n?.[t];
|
|
51
|
-
return typeof r == "function" ? r.bind(n) : r;
|
|
52
|
-
},
|
|
53
|
-
has(e, t) {
|
|
54
|
-
return t in e();
|
|
55
|
-
},
|
|
56
|
-
apply(e) {
|
|
57
|
-
return e();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
let C = _, w = y, T = () => w ?? x?.() ?? s(), E = () => {
|
|
62
|
-
let e = T();
|
|
63
24
|
return {
|
|
64
|
-
|
|
65
|
-
locale: e
|
|
25
|
+
...e,
|
|
26
|
+
cacheKey: t ? `${w}.${e.locale}.${t}` : `${w}.${e.locale}`
|
|
66
27
|
};
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
28
|
+
}, A = (e, t) => _({
|
|
29
|
+
loaderMap: T,
|
|
30
|
+
key: w,
|
|
31
|
+
...e,
|
|
32
|
+
transform: t
|
|
33
|
+
}), j = f(E, D);
|
|
34
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && m(T) && T[u].includes("item") && D?.item === void 0) {
|
|
35
|
+
let i = t(O, (e) => A(e, D?.metadataOnly ? y : v)), a = c(() => {
|
|
36
|
+
let t = i();
|
|
37
|
+
if (!Array.isArray(t)) return [];
|
|
38
|
+
if (D?.metadataOnly) return t;
|
|
39
|
+
let { locale: n } = O();
|
|
40
|
+
return t.map((t) => e(t, n));
|
|
41
|
+
});
|
|
42
|
+
return n(i), r(a);
|
|
43
|
+
}
|
|
44
|
+
let M = k(), N = p(T, M.locale);
|
|
45
|
+
N && o(M, N);
|
|
46
|
+
let P = s(k, (e) => A(e, v).then((t) => {
|
|
47
|
+
if (t === null) throw Error(`No dynamic dictionary chunk found for key "${w}" and locale "${e.locale}".`);
|
|
48
|
+
return t;
|
|
49
|
+
}));
|
|
50
|
+
return a(P, j);
|
|
74
51
|
};
|
|
75
|
-
export {
|
|
52
|
+
export { b as useDictionaryDynamic };
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { getIntlayer as e } from "../getIntlayer.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { createContentProxy as t } from "./contentProxy.mjs";
|
|
3
|
+
import { IntlayerClientContext as n } from "./IntlayerProvider.mjs";
|
|
4
|
+
import { createMemo as r, useContext as i } from "solid-js";
|
|
5
|
+
import { resolveDictionaryArgument as a } from "@intlayer/core/dictionaryManipulator";
|
|
5
6
|
// src/client/useIntlayer.ts
|
|
6
|
-
var
|
|
7
|
-
let
|
|
8
|
-
let t =
|
|
9
|
-
return process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? e(
|
|
10
|
-
localeOrSelector:
|
|
7
|
+
var o = (o, s) => {
|
|
8
|
+
let c = i(n) ?? {}, l = r(() => {
|
|
9
|
+
let t = c?.locale?.();
|
|
10
|
+
return process.env.INTLAYER_DICTIONARY_SELECTOR === "false" ? e(o, s ?? t) : e(o, a({
|
|
11
|
+
localeOrSelector: s,
|
|
11
12
|
contextLocale: t,
|
|
12
|
-
contextVariant:
|
|
13
|
-
dictionaryKey:
|
|
13
|
+
contextVariant: c?.variant?.(),
|
|
14
|
+
dictionaryKey: o
|
|
14
15
|
}));
|
|
15
16
|
});
|
|
16
|
-
return
|
|
17
|
-
get(e, t) {
|
|
18
|
-
return e()?.[t];
|
|
19
|
-
},
|
|
20
|
-
apply(e, t, n) {
|
|
21
|
-
return Reflect.apply(e, t, n);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
17
|
+
return t(l);
|
|
24
18
|
};
|
|
25
|
-
export {
|
|
19
|
+
export { o as useIntlayer };
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/client/contentProxy.ts
|
|
2
|
+
/**
|
|
3
|
+
* Exposes reactive content through a proxy that reads `accessor` on every
|
|
4
|
+
* access, so each field read stays tracked — shared by `useDictionary`,
|
|
5
|
+
* `useIntlayer` and the dynamic collection read.
|
|
6
|
+
*
|
|
7
|
+
* Collections must behave like real arrays: Solid 2's `<For>` copies its list
|
|
8
|
+
* with `list.slice(0)`, which checks every index with `in`. Answering those
|
|
9
|
+
* checks for the function target would yield holes (`undefined` rows), so `in`
|
|
10
|
+
* is answered for the content, and inherited methods (`slice`, `map`…) run
|
|
11
|
+
* against it. Own fields are returned untouched: content nodes carry their
|
|
12
|
+
* own properties (`.value`, `.raw`) that a bound copy would lose.
|
|
13
|
+
*
|
|
14
|
+
* @param accessor - Returns the current content (a memo).
|
|
15
|
+
*/
|
|
16
|
+
var createContentProxy = (accessor) => new Proxy(accessor, {
|
|
17
|
+
get(target, property) {
|
|
18
|
+
const content = target();
|
|
19
|
+
if (content == null) return void 0;
|
|
20
|
+
const value = Reflect.get(Object(content), property);
|
|
21
|
+
return typeof value === "function" && !Object.hasOwn(content, property) ? value.bind(content) : value;
|
|
22
|
+
},
|
|
23
|
+
has(target, property) {
|
|
24
|
+
const content = target();
|
|
25
|
+
return content != null && typeof content === "object" && property in content;
|
|
26
|
+
},
|
|
27
|
+
apply(target) {
|
|
28
|
+
return target();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export { createContentProxy };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getDictionary as getDictionary$1 } from "../getDictionary.js";
|
|
2
2
|
import { getPlugins } from "../plugins.jsx";
|
|
3
|
+
import { createContentProxy } from "./contentProxy.js";
|
|
3
4
|
import { IntlayerClientContext } from "./IntlayerProvider.jsx";
|
|
4
5
|
import { unwrapLoadable } from "./useLoadDynamic.js";
|
|
5
6
|
import { collectTransformCacheWrites, deleteTransformCacheWrites } from "@intlayer/core/interpreter";
|
|
@@ -44,13 +45,6 @@ var useDictionary = (dictionary, localeOrSelector) => {
|
|
|
44
45
|
if (writes.length > 0) onCleanup(() => deleteTransformCacheWrites(writes));
|
|
45
46
|
return result;
|
|
46
47
|
});
|
|
47
|
-
return
|
|
48
|
-
get(target, prop) {
|
|
49
|
-
return target()?.[prop];
|
|
50
|
-
},
|
|
51
|
-
apply(target, thisArg, args) {
|
|
52
|
-
return Reflect.apply(target, thisArg, args);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
48
|
+
return createContentProxy(accessor);
|
|
55
49
|
};
|
|
56
50
|
export { useDictionary };
|
|
@@ -2,6 +2,7 @@ import { IntlayerClientContext } from "./IntlayerProvider.jsx";
|
|
|
2
2
|
import { useDictionary } from "./useDictionary.js";
|
|
3
3
|
import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
|
|
4
4
|
import { useContext } from "solid-js";
|
|
5
|
+
import { loadDynamicDictionary } from "@intlayer/core/dictionaryManipulator";
|
|
5
6
|
// src/client/useDictionaryAsync.ts
|
|
6
7
|
/**
|
|
7
8
|
* On the server side, Hook that transform a dictionary and return the content
|
|
@@ -11,7 +12,7 @@ import { useContext } from "solid-js";
|
|
|
11
12
|
var useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
12
13
|
const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};
|
|
13
14
|
const localeTarget = locale ?? currentLocale() ?? resolveInterpreterLocale();
|
|
14
|
-
const dictionary = await dictionaryPromise
|
|
15
|
+
const dictionary = await loadDynamicDictionary(dictionaryPromise, localeTarget);
|
|
15
16
|
return useDictionary(dictionary, localeTarget);
|
|
16
17
|
};
|
|
17
18
|
export { useDictionaryAsync };
|
|
@@ -1,105 +1,81 @@
|
|
|
1
|
-
import { getDictionary
|
|
1
|
+
import { getDictionary } from "../getDictionary.js";
|
|
2
2
|
import { createAsyncValue, trackAsyncValue } from "../solidCompat.js";
|
|
3
|
+
import { createContentProxy } from "./contentProxy.js";
|
|
3
4
|
import { IntlayerClientContext } from "./IntlayerProvider.jsx";
|
|
4
5
|
import { useDictionary } from "./useDictionary.js";
|
|
5
6
|
import { seedDynamicValue, useLoadDynamic } from "./useLoadDynamic.js";
|
|
6
|
-
import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
|
|
7
7
|
import { createMemo, useContext } from "solid-js";
|
|
8
|
-
import { QUALIFIER_DYNAMIC_TYPES_KEY, getDictionarySelectorCacheKey, getPreloadedDictionary, isQualifiedDynamicLoaderMap, parseDictionarySelector,
|
|
8
|
+
import { QUALIFIER_DYNAMIC_TYPES_KEY, getDictionarySelectorCacheKey, getDynamicChunkArgument, getPreloadedDictionary, isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryRead, resolveDynamicContentAsync } from "@intlayer/core/dictionaryManipulator";
|
|
9
9
|
// src/client/useDictionaryDynamic.ts
|
|
10
10
|
/**
|
|
11
|
+
* Loaded chunks stay raw (serializable for hydration) and are interpreted
|
|
12
|
+
* inside the component owner. A collection's metadata is plain data, resolved
|
|
13
|
+
* right away — its index holds no dictionary to interpret anyway.
|
|
14
|
+
*/
|
|
15
|
+
var keepRawChunk = (dictionary) => dictionary;
|
|
16
|
+
var readChunkMetadata = (dictionary, argument) => getDictionary(dictionary, argument);
|
|
17
|
+
/**
|
|
11
18
|
* On the client side, Hook that lazily loads a dictionary and returns its
|
|
12
19
|
* reactive content.
|
|
13
20
|
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* targets are loaded; the resolution mirrors static mode.
|
|
21
|
+
* The locale, selector and chunk selection are resolved by the shared
|
|
22
|
+
* `resolveDictionaryRead` / `resolveDynamicContentAsync`; this hook only adds
|
|
23
|
+
* Solid's resources and owner-scoped interpretation.
|
|
18
24
|
*
|
|
19
25
|
* If the locale is not provided (directly or through the selector), it will
|
|
20
26
|
* use the locale from the client context.
|
|
21
27
|
*/
|
|
22
28
|
var useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
23
29
|
const context = useContext(IntlayerClientContext) ?? {};
|
|
24
|
-
const { locale: currentLocale } = context;
|
|
25
30
|
const dictionaryKey = String(key);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}), ({ locale: localeTarget, selector }) => resolveQualifiedDynamicContentAsync({
|
|
58
|
-
loaderMap: dictionaryPromise,
|
|
59
|
-
key: dictionaryKey,
|
|
60
|
-
locale: localeTarget,
|
|
61
|
-
selector,
|
|
62
|
-
transform: (dictionary) => dictionary
|
|
63
|
-
}));
|
|
31
|
+
const loaderMap = dictionaryPromise;
|
|
32
|
+
const { locale: callLocale, selector: callSelector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(localeOrSelector) : {
|
|
33
|
+
locale: localeOrSelector,
|
|
34
|
+
selector: void 0
|
|
35
|
+
};
|
|
36
|
+
const readAccessor = () => resolveDictionaryRead({
|
|
37
|
+
localeOrSelector,
|
|
38
|
+
contextLocale: context.locale?.(),
|
|
39
|
+
contextVariant: context.variant?.(),
|
|
40
|
+
dictionaryKey
|
|
41
|
+
});
|
|
42
|
+
const sourceAccessor = () => {
|
|
43
|
+
const read = readAccessor();
|
|
44
|
+
const chunkSelectorId = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? getDictionarySelectorCacheKey({
|
|
45
|
+
...read.selector,
|
|
46
|
+
metadataOnly: void 0
|
|
47
|
+
}) : "";
|
|
48
|
+
return {
|
|
49
|
+
...read,
|
|
50
|
+
cacheKey: chunkSelectorId ? `${dictionaryKey}.${read.locale}.${chunkSelectorId}` : `${dictionaryKey}.${read.locale}`
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const loadContent = (read, transform) => resolveDynamicContentAsync({
|
|
54
|
+
loaderMap,
|
|
55
|
+
key: dictionaryKey,
|
|
56
|
+
...read,
|
|
57
|
+
transform
|
|
58
|
+
});
|
|
59
|
+
const chunkArgument = getDynamicChunkArgument(callLocale, callSelector);
|
|
60
|
+
if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && isQualifiedDynamicLoaderMap(loaderMap) && loaderMap[QUALIFIER_DYNAMIC_TYPES_KEY].includes("item") && callSelector?.item === void 0) {
|
|
61
|
+
const resolvedEntries = createAsyncValue(readAccessor, (read) => loadContent(read, callSelector?.metadataOnly ? readChunkMetadata : keepRawChunk));
|
|
64
62
|
const accessor = createMemo(() => {
|
|
65
63
|
const resolved = resolvedEntries();
|
|
66
|
-
const localeTarget = localeAccessor();
|
|
67
64
|
if (!Array.isArray(resolved)) return [];
|
|
68
|
-
|
|
65
|
+
if (callSelector?.metadataOnly) return resolved;
|
|
66
|
+
const { locale } = readAccessor();
|
|
67
|
+
return resolved.map((dictionary) => getDictionary(dictionary, locale));
|
|
69
68
|
});
|
|
70
69
|
trackAsyncValue(resolvedEntries);
|
|
71
|
-
return
|
|
72
|
-
get(target, prop) {
|
|
73
|
-
const content = target();
|
|
74
|
-
const value = content?.[prop];
|
|
75
|
-
return typeof value === "function" ? value.bind(content) : value;
|
|
76
|
-
},
|
|
77
|
-
has(target, prop) {
|
|
78
|
-
return prop in target();
|
|
79
|
-
},
|
|
80
|
-
apply(target) {
|
|
81
|
-
return target();
|
|
82
|
-
}
|
|
83
|
-
});
|
|
70
|
+
return createContentProxy(accessor);
|
|
84
71
|
}
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
const loadDictionary = ({ locale: localeTarget }) => {
|
|
96
|
-
const dictionaryLoader = dictionaryLoaders[localeTarget];
|
|
97
|
-
if (!dictionaryLoader) return Promise.reject(/* @__PURE__ */ new Error(`No dynamic dictionary loader found for key "${dictionaryKey}" and locale "${localeTarget}".`));
|
|
98
|
-
return dictionaryLoader();
|
|
99
|
-
};
|
|
100
|
-
const preloadedDictionary = getPreloadedDictionary(dictionaryLoaders, localeAccessor());
|
|
101
|
-
if (preloadedDictionary) seedDynamicValue(dictionarySourceAccessor(), preloadedDictionary);
|
|
102
|
-
const dictionary = useLoadDynamic(dictionarySourceAccessor, loadDictionary);
|
|
103
|
-
return useDictionary(dictionary, locale);
|
|
72
|
+
const initialSource = sourceAccessor();
|
|
73
|
+
const preloadedDictionary = getPreloadedDictionary(loaderMap, initialSource.locale);
|
|
74
|
+
if (preloadedDictionary) seedDynamicValue(initialSource, preloadedDictionary);
|
|
75
|
+
const dictionary = useLoadDynamic(sourceAccessor, (source) => loadContent(source, keepRawChunk).then((resolved) => {
|
|
76
|
+
if (resolved === null) throw new Error(`No dynamic dictionary chunk found for key "${dictionaryKey}" and locale "${source.locale}".`);
|
|
77
|
+
return resolved;
|
|
78
|
+
}));
|
|
79
|
+
return useDictionary(dictionary, chunkArgument);
|
|
104
80
|
};
|
|
105
81
|
export { useDictionaryDynamic };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getIntlayer } from "../getIntlayer.js";
|
|
2
|
+
import { createContentProxy } from "./contentProxy.js";
|
|
2
3
|
import { IntlayerClientContext } from "./IntlayerProvider.jsx";
|
|
3
4
|
import { createMemo, useContext } from "solid-js";
|
|
4
5
|
import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
@@ -43,13 +44,6 @@ var useIntlayer = (key, localeOrSelector) => {
|
|
|
43
44
|
}));
|
|
44
45
|
return getIntlayer(key, localeOrSelector ?? currentLocale);
|
|
45
46
|
});
|
|
46
|
-
return
|
|
47
|
-
get(target, prop) {
|
|
48
|
-
return target()?.[prop];
|
|
49
|
-
},
|
|
50
|
-
apply(target, thisArg, args) {
|
|
51
|
-
return Reflect.apply(target, thisArg, args);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
47
|
+
return createContentProxy(accessor);
|
|
54
48
|
};
|
|
55
49
|
export { useIntlayer };
|
package/dist/solid/plugins.jsx
CHANGED
|
@@ -180,7 +180,7 @@ var markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallb
|
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
var HTMLSuspenseRenderer = lazyComponent(() => htmlRendererModulePromise.then((HTMLRenderer) => ({ default: HTMLRenderer })));
|
|
183
|
-
/** HTML plugin. Replaces node with a function that takes components =>
|
|
183
|
+
/** HTML plugin. Replaces node with a function that takes components => SolidElement. */
|
|
184
184
|
var htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlugin : {
|
|
185
185
|
id: "html-plugin",
|
|
186
186
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeProps } from '@intlayer/core/interpreter';
|
|
2
2
|
import { ResolvedEditor } from '@intlayer/types/module_augmentation';
|
|
3
|
-
import {
|
|
3
|
+
import { ParentProps } from 'solid-js';
|
|
4
|
+
import { SolidElement } from './solidTypes';
|
|
4
5
|
/**
|
|
5
6
|
* Content node returned by `useIntlayer`.
|
|
6
7
|
*
|
|
@@ -11,12 +12,12 @@ import { JSX, ParentProps } from 'solid-js';
|
|
|
11
12
|
*/
|
|
12
13
|
export type IntlayerNode<T = NodeProps['children'], AdditionalProps = unknown> = ResolvedEditor<T & {
|
|
13
14
|
value: T;
|
|
14
|
-
} & AdditionalProps,
|
|
15
|
+
} & AdditionalProps, SolidElement & {
|
|
15
16
|
value: T;
|
|
16
17
|
} & AdditionalProps>;
|
|
17
18
|
type RenderIntlayerNodeProps<T> = ParentProps<{
|
|
18
19
|
value: T;
|
|
19
|
-
children:
|
|
20
|
+
children: SolidElement;
|
|
20
21
|
additionalProps?: Record<string, unknown>;
|
|
21
22
|
}>;
|
|
22
23
|
export declare const renderIntlayerNode: <T>({ children, value, additionalProps, }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Component
|
|
1
|
+
import { Component } from 'solid-js';
|
|
2
|
+
import { SolidElement } from './solidTypes';
|
|
2
3
|
export type LoadingBoundaryProps = {
|
|
3
|
-
fallback?:
|
|
4
|
-
children:
|
|
4
|
+
fallback?: SolidElement;
|
|
5
|
+
children: SolidElement;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* Shows `fallback` while async reads below it are pending: `Suspense` in
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exposes reactive content through a proxy that reads `accessor` on every
|
|
3
|
+
* access, so each field read stays tracked — shared by `useDictionary`,
|
|
4
|
+
* `useIntlayer` and the dynamic collection read.
|
|
5
|
+
*
|
|
6
|
+
* Collections must behave like real arrays: Solid 2's `<For>` copies its list
|
|
7
|
+
* with `list.slice(0)`, which checks every index with `in`. Answering those
|
|
8
|
+
* checks for the function target would yield holes (`undefined` rows), so `in`
|
|
9
|
+
* is answered for the content, and inherited methods (`slice`, `map`…) run
|
|
10
|
+
* against it. Own fields are returned untouched: content nodes carry their
|
|
11
|
+
* own properties (`.value`, `.raw`) that a bound copy would lose.
|
|
12
|
+
*
|
|
13
|
+
* @param accessor - Returns the current content (a memo).
|
|
14
|
+
*/
|
|
15
|
+
export declare const createContentProxy: <Content>(accessor: () => Content) => Content;
|
|
@@ -6,12 +6,11 @@ import { DeepTransformContent } from '../plugins';
|
|
|
6
6
|
* On the client side, Hook that lazily loads a dictionary and returns its
|
|
7
7
|
* reactive content.
|
|
8
8
|
*
|
|
9
|
-
* The
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* targets are loaded; the resolution mirrors static mode.
|
|
9
|
+
* The locale, selector and chunk selection are resolved by the shared
|
|
10
|
+
* `resolveDictionaryRead` / `resolveDynamicContentAsync`; this hook only adds
|
|
11
|
+
* Solid's resources and owner-scoped interpretation.
|
|
13
12
|
*
|
|
14
13
|
* If the locale is not provided (directly or through the selector), it will
|
|
15
14
|
* use the locale from the client context.
|
|
16
15
|
*/
|
|
17
|
-
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?: A) => DeepTransformContent<T["content"]
|
|
16
|
+
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?: A) => DeepTransformContent<T["content"]>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { LocaleStorageClient } from '@intlayer/core/utils';
|
|
1
2
|
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
+
import { Accessor } from 'solid-js';
|
|
2
4
|
/**
|
|
3
5
|
* Reads the locale persisted in the browser storage (cookie, localStorage…).
|
|
4
6
|
*
|
|
@@ -32,10 +34,7 @@ export declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled?:
|
|
|
32
34
|
/**
|
|
33
35
|
* Hook that provides the locale storage and a function to set it
|
|
34
36
|
*/
|
|
35
|
-
export declare const useLocaleStorage: (isCookieEnabled?: boolean) =>
|
|
36
|
-
getLocale: () => import('@intlayer/types').Locale;
|
|
37
|
-
setLocale: (locale: LocalesValues) => void;
|
|
38
|
-
}>;
|
|
37
|
+
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => Accessor<ReturnType<typeof LocaleStorageClient>>;
|
|
39
38
|
/**
|
|
40
39
|
* @deprecated Use useLocaleStorage instead
|
|
41
40
|
*
|
|
@@ -43,7 +42,4 @@ export declare const useLocaleStorage: (isCookieEnabled?: boolean) => import('so
|
|
|
43
42
|
*
|
|
44
43
|
* Hook that provides the locale cookie and a function to set it
|
|
45
44
|
*/
|
|
46
|
-
export declare const useLocaleCookie: (isCookieEnabled?: boolean) =>
|
|
47
|
-
getLocale: () => import('@intlayer/types').Locale;
|
|
48
|
-
setLocale: (locale: LocalesValues) => void;
|
|
49
|
-
}>;
|
|
45
|
+
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => Accessor<ReturnType<typeof LocaleStorageClient>>;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { NodeProps } from '@intlayer/core/interpreter';
|
|
2
|
-
import { Component
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'intlayer-content-selector-wrapper': JSX.HTMLAttributes<HTMLElement> & {
|
|
7
|
-
'key-path'?: string;
|
|
8
|
-
'dictionary-key'?: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export type ContentSelectorWrapperProps = NodeProps & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
14
|
-
children?: JSX.Element;
|
|
2
|
+
import { Component } from 'solid-js';
|
|
3
|
+
import { IntrinsicElementProps, SolidElement } from '../solidTypes';
|
|
4
|
+
export type ContentSelectorWrapperProps = NodeProps & Omit<IntrinsicElementProps<'div'>, 'children'> & {
|
|
5
|
+
children?: SolidElement;
|
|
15
6
|
};
|
|
16
7
|
export declare const ContentSelector: Component<ContentSelectorWrapperProps>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WrappedIntl } from '@intlayer/core/formatters';
|
|
2
2
|
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
+
import { Accessor } from 'solid-js';
|
|
3
4
|
/**
|
|
4
5
|
* Solid client hook that provides a locale-bound `Intl` object.
|
|
5
6
|
*
|
|
@@ -18,4 +19,4 @@ import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
|
18
19
|
* }).format(123.45);
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
export declare const useIntl: (locale?: LocalesValues) =>
|
|
22
|
+
export declare const useIntl: (locale?: LocalesValues) => Accessor<WrappedIntl>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { KeyPath } from '@intlayer/types/keyPath';
|
|
2
|
-
import { Component
|
|
2
|
+
import { Component } from 'solid-js';
|
|
3
|
+
import { SolidElement } from '../solidTypes';
|
|
3
4
|
import { HTMLComponents } from './types';
|
|
4
5
|
export type RenderHTMLProps = {
|
|
5
6
|
/**
|
|
@@ -14,14 +15,14 @@ export type RenderHTMLProps = {
|
|
|
14
15
|
* This function does not use context from HTMLProvider. Use `useHTMLRenderer`
|
|
15
16
|
* hook if you want to leverage provider context.
|
|
16
17
|
*/
|
|
17
|
-
export declare const renderHTML: (content: string, { components }?: RenderHTMLProps) =>
|
|
18
|
+
export declare const renderHTML: (content: string, { components }?: RenderHTMLProps) => SolidElement;
|
|
18
19
|
/**
|
|
19
20
|
* Hook that returns a function to render HTML content.
|
|
20
21
|
*
|
|
21
22
|
* This hook considers the configuration from the `HTMLProvider` context if available,
|
|
22
23
|
* falling back to the provided components.
|
|
23
24
|
*/
|
|
24
|
-
export declare const useHTMLRenderer: ({ components }?: RenderHTMLProps) => (content: string) =>
|
|
25
|
+
export declare const useHTMLRenderer: ({ components }?: RenderHTMLProps) => ((content: string) => SolidElement);
|
|
25
26
|
export type HTMLRendererProps = RenderHTMLProps & {
|
|
26
27
|
/**
|
|
27
28
|
* The HTML content to render as a string.
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { HTMLTagsType } from '@intlayer/core/transpiler';
|
|
2
|
-
import {
|
|
2
|
+
import { IntrinsicElementProps, SolidElement } from '../solidTypes';
|
|
3
3
|
/**
|
|
4
4
|
* Helper to extract specific props from the configuration value.
|
|
5
5
|
*/
|
|
6
6
|
type PropsFromConfig<Value> = Value extends true ? {} : Value extends object ? Value : {};
|
|
7
7
|
/**
|
|
8
|
-
* Common props for all elements
|
|
8
|
+
* Common props for all elements: `HTMLAttributes<HTMLElement>`, which Solid 1
|
|
9
|
+
* gives `<section>`.
|
|
9
10
|
*/
|
|
10
|
-
type ElementProps =
|
|
11
|
+
type ElementProps = IntrinsicElementProps<'section'>;
|
|
11
12
|
/**
|
|
12
13
|
* Solid Component type
|
|
13
14
|
*/
|
|
14
|
-
type SolidComponentType<P = {}> = (props: P) =>
|
|
15
|
+
type SolidComponentType<P = {}> = (props: P) => SolidElement;
|
|
15
16
|
/**
|
|
16
17
|
* Helper: Defines the mapping for the explicitly listed keys in T.
|
|
17
18
|
* Handles whether they are Required or Optional.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Component,
|
|
1
|
+
import { Component, ParentProps, ValidComponent } from 'solid-js';
|
|
2
2
|
import { HTMLComponents } from '../html/types';
|
|
3
|
+
import { SolidElement } from '../solidTypes';
|
|
3
4
|
import { ParsedMarkdown } from './compiler';
|
|
4
5
|
export type MarkdownProviderOptions = {
|
|
5
6
|
/** Forces the compiler to always output content with a block-level wrapper. */
|
|
@@ -11,7 +12,7 @@ export type MarkdownProviderOptions = {
|
|
|
11
12
|
};
|
|
12
13
|
type MarkdownProviderValue = {
|
|
13
14
|
components?: HTMLComponents<'permissive', {}>;
|
|
14
|
-
renderMarkdown: (content: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ValidComponent) =>
|
|
15
|
+
renderMarkdown: (content: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ValidComponent) => SolidElement | Promise<SolidElement>;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* `null` outside a provider. An explicit default keeps `useContext` from
|
|
@@ -24,7 +25,7 @@ export type MarkdownProviderProps = ParentProps<{
|
|
|
24
25
|
forceBlock?: boolean;
|
|
25
26
|
preserveFrontmatter?: boolean;
|
|
26
27
|
tagfilter?: boolean;
|
|
27
|
-
renderMarkdown?: (content: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ValidComponent) =>
|
|
28
|
+
renderMarkdown?: (content: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: ValidComponent) => SolidElement | Promise<SolidElement>;
|
|
28
29
|
}>;
|
|
29
30
|
export declare const MarkdownProvider: Component<MarkdownProviderProps>;
|
|
30
31
|
export declare const useMarkdown: () => MarkdownProviderValue;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { KeyPath } from '@intlayer/types/keyPath';
|
|
2
2
|
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
-
import { Component,
|
|
3
|
+
import { Component, ValidComponent } from 'solid-js';
|
|
4
4
|
import { HTMLComponents } from '../html/types';
|
|
5
|
+
import { SolidElement } from '../solidTypes';
|
|
5
6
|
import { ParsedMarkdown } from './compiler';
|
|
6
7
|
export type RenderMarkdownOptions = {
|
|
7
8
|
components?: HTMLComponents<'permissive', {}>;
|
|
@@ -10,15 +11,15 @@ export type RenderMarkdownOptions = {
|
|
|
10
11
|
preserveFrontmatter?: boolean;
|
|
11
12
|
tagfilter?: boolean;
|
|
12
13
|
};
|
|
13
|
-
export declare const renderMarkdown: (content: string | ParsedMarkdown, options?: RenderMarkdownOptions) => Promise<
|
|
14
|
-
export declare const useMarkdownRenderer: (options?: RenderMarkdownOptions) => (content: string | ParsedMarkdown) => Promise<
|
|
14
|
+
export declare const renderMarkdown: (content: string | ParsedMarkdown, options?: RenderMarkdownOptions) => Promise<SolidElement>;
|
|
15
|
+
export declare const useMarkdownRenderer: (options?: RenderMarkdownOptions) => (content: string | ParsedMarkdown) => Promise<SolidElement>;
|
|
15
16
|
export type MarkdownRendererProps = RenderMarkdownOptions & {
|
|
16
17
|
dictionaryKey: string;
|
|
17
18
|
keyPath: KeyPath[];
|
|
18
19
|
locale?: LocalesValues;
|
|
19
20
|
children: string | ParsedMarkdown;
|
|
20
21
|
};
|
|
21
|
-
export declare const MarkdownRenderer: (props: MarkdownRendererProps) =>
|
|
22
|
+
export declare const MarkdownRenderer: (props: MarkdownRendererProps) => SolidElement;
|
|
22
23
|
export type MarkdownMetadataRendererProps = MarkdownRendererProps & {
|
|
23
24
|
metadataKeyPath: KeyPath[];
|
|
24
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompileOptions, ParsedMarkdown } from '@intlayer/core/markdown';
|
|
2
|
-
import {
|
|
2
|
+
import { SolidElement } from '../solidTypes';
|
|
3
3
|
/**
|
|
4
4
|
* Intermediate AST produced by `parseMarkdown`.
|
|
5
5
|
* Pass this to `compileMarkdown` to skip re-parsing when the same content is
|
|
@@ -40,4 +40,4 @@ export declare const parseMarkdown: (markdown?: string, options?: CompileOptions
|
|
|
40
40
|
* const element = await compileMarkdown('# Hello **world**');
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
export declare const compileMarkdown: (input?: string | ParsedMarkdown, options?: CompileOptions) => Promise<
|
|
43
|
+
export declare const compileMarkdown: (input?: string | ParsedMarkdown, options?: CompileOptions) => Promise<SolidElement>;
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DeepTransformContent as DeepTransformContentCore, IInterpreterPluginState as IInterpreterPluginStateCore, Plugins } from '@intlayer/core/interpreter';
|
|
2
2
|
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
3
|
import { NodeType } from '@intlayer/types/nodeType';
|
|
4
|
-
import { JSX } from 'solid-js';
|
|
5
4
|
import { HTMLComponents } from './html/types';
|
|
6
5
|
import { IntlayerNode } from './IntlayerNode';
|
|
6
|
+
import { SolidElement } from './solidTypes';
|
|
7
7
|
import * as NodeTypes from '@intlayer/types/nodeType';
|
|
8
8
|
/** ---------------------------------------------
|
|
9
9
|
* INTLAYER NODE PLUGIN
|
|
@@ -17,7 +17,7 @@ export declare const intlayerNodePlugins: Plugins;
|
|
|
17
17
|
export type SolidNodeCond<T> = T extends {
|
|
18
18
|
props: any;
|
|
19
19
|
key?: any;
|
|
20
|
-
} ?
|
|
20
|
+
} ? SolidElement : never;
|
|
21
21
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
22
22
|
export declare const solidNodePlugins: Plugins;
|
|
23
23
|
/** ---------------------------------------------
|
|
@@ -28,8 +28,8 @@ export type InsertionCond<T, _S, L extends LocalesValues> = T extends {
|
|
|
28
28
|
[NodeTypes.INSERTION]: infer I;
|
|
29
29
|
fields: readonly (infer F)[];
|
|
30
30
|
} ? <V extends {
|
|
31
|
-
[K in Extract<F, string>]: string | number |
|
|
32
|
-
}>(values: V) => I extends string ? V[keyof V] extends string | number ? IntlayerNode<string> : IntlayerNode<
|
|
31
|
+
[K in Extract<F, string>]: string | number | SolidElement;
|
|
32
|
+
}>(values: V) => I extends string ? V[keyof V] extends string | number ? IntlayerNode<string> : IntlayerNode<SolidElement> : DeepTransformContent<I, L> : never;
|
|
33
33
|
/** Insertion plugin for Solid. Handles component/element insertion. */
|
|
34
34
|
export declare const insertionPlugin: Plugins;
|
|
35
35
|
/**
|
|
@@ -37,7 +37,7 @@ export declare const insertionPlugin: Plugins;
|
|
|
37
37
|
*/
|
|
38
38
|
export type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
|
|
39
39
|
metadata: DeepTransformContent<string>;
|
|
40
|
-
use: (components?: HTMLComponents<'permissive', {}>) =>
|
|
40
|
+
use: (components?: HTMLComponents<'permissive', {}>) => SolidElement;
|
|
41
41
|
}> : never;
|
|
42
42
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
43
43
|
export declare const markdownStringPlugin: Plugins;
|
|
@@ -47,7 +47,7 @@ export type MarkdownCond<T> = T extends {
|
|
|
47
47
|
metadata?: infer U;
|
|
48
48
|
tags?: infer U;
|
|
49
49
|
} ? IntlayerNode<M, {
|
|
50
|
-
use: (components?: HTMLComponents<'permissive', U>) =>
|
|
50
|
+
use: (components?: HTMLComponents<'permissive', U>) => SolidElement;
|
|
51
51
|
metadata: DeepTransformContent<U>;
|
|
52
52
|
}> : never;
|
|
53
53
|
export declare const markdownPlugin: Plugins;
|
|
@@ -61,7 +61,7 @@ export type HTMLPluginCond<T> = T extends {
|
|
|
61
61
|
} ? IntlayerNode<I, {
|
|
62
62
|
use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;
|
|
63
63
|
}> : never;
|
|
64
|
-
/** HTML plugin. Replaces node with a function that takes components =>
|
|
64
|
+
/** HTML plugin. Replaces node with a function that takes components => SolidElement. */
|
|
65
65
|
export declare const htmlPlugin: Plugins;
|
|
66
66
|
/** ---------------------------------------------
|
|
67
67
|
* PLUGINS RESULT
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Accessor, Component, Context } from 'solid-js';
|
|
2
|
+
import { SolidElement } from './solidTypes';
|
|
2
3
|
/** Cleanup returned by an effect callback. */
|
|
3
4
|
type EffectCleanup = void | (() => void);
|
|
4
5
|
/**
|
|
@@ -84,9 +85,14 @@ export declare const lazyComponent: <T extends Component<any>>(load: () => Promi
|
|
|
84
85
|
default: T;
|
|
85
86
|
}>;
|
|
86
87
|
};
|
|
88
|
+
/** Provider component of a context, in a shape valid for both majors. */
|
|
89
|
+
export type ContextProvider<T> = Component<{
|
|
90
|
+
value: T;
|
|
91
|
+
children?: SolidElement;
|
|
92
|
+
}>;
|
|
87
93
|
/**
|
|
88
94
|
* Provider component of a context: `Context.Provider` in Solid 1, the context
|
|
89
95
|
* object itself in Solid 2.
|
|
90
96
|
*/
|
|
91
|
-
export declare const getContextProvider: <T>(context: Context<T>) =>
|
|
97
|
+
export declare const getContextProvider: <T>(context: Context<T>) => ContextProvider<T>;
|
|
92
98
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const renderSolidElement: (element:
|
|
1
|
+
import { SolidElement } from '../solidTypes';
|
|
2
|
+
export declare const renderSolidElement: (element: SolidElement) => any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, ComponentProps, ValidComponent } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
* Anything a component can render: `JSX.Element` in Solid 1, `Element` in
|
|
4
|
+
* Solid 2.
|
|
5
|
+
*/
|
|
6
|
+
export type SolidElement = ReturnType<Component>;
|
|
7
|
+
/**
|
|
8
|
+
* Props of the intrinsic element `Tag`. Solid 1 types them in `solid-js`;
|
|
9
|
+
* Solid 2 keeps DOM attribute types in its web runtime, which this package
|
|
10
|
+
* cannot import, so they stay open there.
|
|
11
|
+
*/
|
|
12
|
+
export type IntrinsicElementProps<Tag extends string> = Tag extends ValidComponent ? ComponentProps<Tag> : {
|
|
13
|
+
[attribute: string]: any;
|
|
14
|
+
children?: SolidElement;
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -114,14 +114,16 @@
|
|
|
114
114
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"@intlayer/api": "9.
|
|
118
|
-
"@intlayer/config": "9.
|
|
119
|
-
"@intlayer/core": "9.
|
|
120
|
-
"@intlayer/editor": "9.
|
|
121
|
-
"@intlayer/types": "9.
|
|
117
|
+
"@intlayer/api": "9.9.1",
|
|
118
|
+
"@intlayer/config": "9.9.1",
|
|
119
|
+
"@intlayer/core": "9.9.1",
|
|
120
|
+
"@intlayer/editor": "9.9.1",
|
|
121
|
+
"@intlayer/types": "9.9.1"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@solidjs/testing-library": "0.8.10",
|
|
125
|
+
"@solidjs/vite-plugin": "3.0.1",
|
|
126
|
+
"@solidjs/web": "2.0.4",
|
|
125
127
|
"@testing-library/jest-dom": "8.0.0",
|
|
126
128
|
"@testing-library/user-event": "14.6.13",
|
|
127
129
|
"@types/node": "^26",
|
|
@@ -131,13 +133,13 @@
|
|
|
131
133
|
"@utils/tsdown-config": "1.0.4",
|
|
132
134
|
"jsdom": "31.0.1",
|
|
133
135
|
"rimraf": "6.1.4",
|
|
134
|
-
"solid-js": "2.0.
|
|
136
|
+
"solid-js": "2.0.4",
|
|
135
137
|
"tsdown": "0.23.7",
|
|
136
138
|
"typescript": "7.0.2",
|
|
137
139
|
"vite": "8.3.8",
|
|
138
140
|
"vite-plugin-dts": "5.1.2",
|
|
139
141
|
"vite-plugin-solid": "2.11.17",
|
|
140
|
-
"vitest": "5.1.
|
|
142
|
+
"vitest": "5.1.2"
|
|
141
143
|
},
|
|
142
144
|
"peerDependencies": {
|
|
143
145
|
"@solidjs/web": ">=2.0.0",
|
|
@@ -149,7 +151,7 @@
|
|
|
149
151
|
}
|
|
150
152
|
},
|
|
151
153
|
"optionalDependencies": {
|
|
152
|
-
"@intlayer/analytics": "9.
|
|
154
|
+
"@intlayer/analytics": "9.9.1"
|
|
153
155
|
},
|
|
154
156
|
"engines": {
|
|
155
157
|
"node": ">=14.18"
|