solid-intlayer 9.3.2 → 9.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./IntlayerProvider.cjs"),n=require("./useDictionary.cjs"),r=require("./useLoadDynamic.cjs");let i=require("@intlayer/config/built"),a=require("solid-js"),o=require("@intlayer/core/dictionaryManipulator");var s=(s,c,l)=>{let u=(0,a.useContext)(t.IntlayerClientContext)??{},{locale:d}=u,f=i.internationalization.defaultLocale,p=String(c);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,o.isQualifiedDynamicLoaderMap)(s)){let{locale:t,selector:i}=(0,o.parseDictionarySelector)(l),c=()=>(0,o.parseDictionarySelector)((0,o.resolveDictionaryArgument)({localeOrSelector:l,contextLocale:d?.(),contextVariant:u.variant?.(),dictionaryKey:p})).selector,m=s[o.QUALIFIER_DYNAMIC_TYPES_KEY].includes(`item`)&&i?.item===void 0,h=()=>t??d?.()??f;if(!m){let e=r.useLoadDynamic(()=>{let e=h();return{cacheKey:`${p}.${e}.${(0,o.getDictionarySelectorCacheKey)(c())}`,locale:e}},({locale:e})=>(0,o.resolveQualifiedDynamicContentAsync)({loaderMap:s,key:p,locale:e,selector:c(),transform:e=>e}).then(e=>Array.isArray(e)?e[0]:e));return n.useDictionary(e,t)}let[g]=(0,a.createResource)(()=>({locale:h(),selector:c()}),({locale:e,selector:t})=>(0,o.resolveQualifiedDynamicContentAsync)({loaderMap:s,key:p,locale:e,selector:t,transform:e=>e})),_=(0,a.createMemo)(()=>{let t=g(),n=h();return Array.isArray(t)?t.map(t=>e.getDictionary(t,n)):[]});return(0,a.createRenderEffect)(()=>{g()}),new Proxy(_,{get(e,t){return e()?.[t]},apply(e){return e()}})}let m=s,h=l,g=()=>h??d?.()??f,_=r.useLoadDynamic(()=>{let e=g();return{cacheKey:`${p}.${e}`,locale:e}},({locale:e})=>{let t=m[e];return t?t():Promise.reject(Error(`No dynamic dictionary loader found for key "${p}" and locale "${e}".`))});return n.useDictionary(_,h)};exports.useDictionaryDynamic=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../getDictionary.cjs"),t=require("./IntlayerProvider.cjs"),n=require("./useDictionary.cjs"),r=require("./useLoadDynamic.cjs");let i=require("@intlayer/config/built"),a=require("solid-js"),o=require("@intlayer/core/dictionaryManipulator");var s=(s,c,l)=>{let u=(0,a.useContext)(t.IntlayerClientContext)??{},{locale:d}=u,f=i.internationalization.defaultLocale,p=String(c);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,o.isQualifiedDynamicLoaderMap)(s)){let{locale:t,selector:i}=(0,o.parseDictionarySelector)(l),c=()=>(0,o.parseDictionarySelector)((0,o.resolveDictionaryArgument)({localeOrSelector:l,contextLocale:d?.(),contextVariant:u.variant?.(),dictionaryKey:p})).selector,m=s[o.QUALIFIER_DYNAMIC_TYPES_KEY].includes(`item`)&&i?.item===void 0,h=()=>t??d?.()??f;if(!m){let e=r.useLoadDynamic(()=>{let e=h();return{cacheKey:`${p}.${e}.${(0,o.getDictionarySelectorCacheKey)(c())}`,locale:e}},({locale:e})=>(0,o.resolveQualifiedDynamicContentAsync)({loaderMap:s,key:p,locale:e,selector:c(),transform:e=>e}).then(e=>Array.isArray(e)?e[0]:e));return n.useDictionary(e,t)}let[g]=(0,a.createResource)(()=>({locale:h(),selector:c()}),({locale:e,selector:t})=>(0,o.resolveQualifiedDynamicContentAsync)({loaderMap:s,key:p,locale:e,selector:t,transform:e=>e})),_=(0,a.createMemo)(()=>{let t=g(),n=h();return Array.isArray(t)?t.map(t=>e.getDictionary(t,n)):[]});return(0,a.createRenderEffect)(()=>{g()}),new Proxy(_,{get(e,t){return e()?.[t]},apply(e){return e()}})}let m=s,h=l,g=()=>h??d?.()??f,_=()=>{let e=g();return{cacheKey:`${p}.${e}`,locale:e}},v=({locale:e})=>{let t=m[e];return t?t():Promise.reject(Error(`No dynamic dictionary loader found for key "${p}" and locale "${e}".`))},y=(0,o.getPreloadedDictionary)(m,g());y&&r.seedDynamicValue(_(),y);let b=r.useLoadDynamic(_,v);return n.useDictionary(b,h)};exports.useDictionaryDynamic=s;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../proxyKeys.cjs");let t=require("solid-js");var n=Symbol(`NO_PENDING_PRIMITIVE_FALLBACK`),r=new Map,i=e=>typeof e==`string`?e:e.cacheKey,a=(e,t)=>t.reduce((e,t)=>{if(e!=null)return Reflect.get(Object(e),t)},e),o=(e,t)=>typeof e==`function`?e(t):e,s=(e,t)=>{let n=i(e),a=r.get(n);if(a?.status===`success`)return a.value;if(a?.status===`pending`)return a.promise;let s=o(t,e).then(e=>(r.set(n,{status:`success`,value:e}),e),e=>{throw r.delete(n),e});return r.set(n,{status:`pending`,promise:s}),s},c=(e,t)=>typeof t==`function`?t.bind(e):t,l=t=>t===Symbol.toPrimitive?()=>``:t===Symbol.iterator?()=>({next:()=>({done:!0,value:void 0})}):t===`length`?0:t===e.PROXY_RESERVED_KEYS.toString?()=>``:t===e.PROXY_RESERVED_KEYS.valueOf?()=>void 0:t===e.PROXY_RESERVED_KEYS.value?``:n,u=r=>{let i=o=>new Proxy(()=>void 0,{get(t,s){if(s===e.PROXY_RESERVED_KEYS.promiseThen)return;let u=a(r(),o);if(u!=null)return s===Symbol.toPrimitive?()=>u:c(u,Reflect.get(Object(u),s));let d=l(s);return d===n?i([...o,s]):d},apply(e,n,i){let s=a(r(),o);return typeof s==`function`?Reflect.apply(s,n,i):i.length===0?s??``:u(()=>{let e=a(r(),o);if(typeof e==`function`)return(0,t.untrack)(()=>Reflect.apply(e,n,i))})}});return i([])},d=(e,n)=>{let[r]=(0,t.createResource)(()=>typeof e==`function`?e():e,e=>s(e,n));return(0,t.createRenderEffect)(()=>{r()}),u(()=>r())};exports.createLoadableProxy=u,exports.getDynamicSourceCacheKey=i,exports.loadDynamicValue=s,exports.useLoadDynamic=d;
1
+ 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)=>{let n=i(e);r.has(n)||r.set(n,{status:`success`,value:t})},l=(e,t)=>typeof t==`function`?t.bind(e):t,u=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,d=r=>{let i=o=>new Proxy(()=>void 0,{get(t,s){if(s===e.PROXY_RESERVED_KEYS.promiseThen)return;let c=a(r(),o);if(c!=null)return s===Symbol.toPrimitive?()=>c:l(c,Reflect.get(Object(c),s));let d=u(s);return d===n?i([...o,s]):d},apply(e,n,i){let s=a(r(),o);return typeof s==`function`?Reflect.apply(s,n,i):i.length===0?s??``:d(()=>{let e=a(r(),o);if(typeof e==`function`)return(0,t.untrack)(()=>Reflect.apply(e,n,i))})}});return i([])},f=(e,n)=>{let[r]=(0,t.createResource)(()=>typeof e==`function`?e():e,e=>s(e,n));return(0,t.createRenderEffect)(()=>{r()}),d(()=>r())};exports.createLoadableProxy=d,exports.getDynamicSourceCacheKey=i,exports.loadDynamicValue=s,exports.seedDynamicValue=c,exports.useLoadDynamic=f;
@@ -1,52 +1,52 @@
1
1
  import { getDictionary as e } from "../getDictionary.mjs";
2
2
  import { IntlayerClientContext as t } from "./IntlayerProvider.mjs";
3
3
  import { useDictionary as n } from "./useDictionary.mjs";
4
- import { useLoadDynamic as r } from "./useLoadDynamic.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, resolveDictionaryArgument as p, resolveQualifiedDynamicContentAsync as m } from "@intlayer/core/dictionaryManipulator";
4
+ import { seedDynamicValue as r, useLoadDynamic as i } from "./useLoadDynamic.mjs";
5
+ import { internationalization as a } from "@intlayer/config/built";
6
+ import { createMemo as o, createRenderEffect as s, createResource as c, useContext as l } from "solid-js";
7
+ import { QUALIFIER_DYNAMIC_TYPES_KEY as u, getDictionarySelectorCacheKey as d, getPreloadedDictionary as f, isQualifiedDynamicLoaderMap as p, parseDictionarySelector as m, resolveDictionaryArgument as h, resolveQualifiedDynamicContentAsync as g } from "@intlayer/core/dictionaryManipulator";
8
8
  //#region src/client/useDictionaryDynamic.ts
9
- var h = (h, g, _) => {
10
- let v = c(t) ?? {}, { locale: y } = v, b = i.defaultLocale, x = String(g);
11
- if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && d(h)) {
12
- let { locale: t, selector: i } = f(_), c = () => f(p({
13
- localeOrSelector: _,
14
- contextLocale: y?.(),
15
- contextVariant: v.variant?.(),
16
- dictionaryKey: x
17
- })).selector, d = h[l].includes("item") && i?.item === void 0, g = () => t ?? y?.() ?? b;
18
- if (!d) {
19
- let e = r(() => {
20
- let e = g();
9
+ var _ = (_, v, y) => {
10
+ let b = l(t) ?? {}, { locale: x } = b, S = a.defaultLocale, C = String(v);
11
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && p(_)) {
12
+ let { locale: t, selector: r } = m(y), a = () => m(h({
13
+ localeOrSelector: y,
14
+ contextLocale: x?.(),
15
+ contextVariant: b.variant?.(),
16
+ dictionaryKey: C
17
+ })).selector, l = _[u].includes("item") && r?.item === void 0, f = () => t ?? x?.() ?? S;
18
+ if (!l) {
19
+ let e = i(() => {
20
+ let e = f();
21
21
  return {
22
- cacheKey: `${x}.${e}.${u(c())}`,
22
+ cacheKey: `${C}.${e}.${d(a())}`,
23
23
  locale: e
24
24
  };
25
- }, ({ locale: e }) => m({
26
- loaderMap: h,
27
- key: x,
25
+ }, ({ locale: e }) => g({
26
+ loaderMap: _,
27
+ key: C,
28
28
  locale: e,
29
- selector: c(),
29
+ selector: a(),
30
30
  transform: (e) => e
31
31
  }).then((e) => Array.isArray(e) ? e[0] : e));
32
32
  return n(e, t);
33
33
  }
34
- let [S] = s(() => ({
35
- locale: g(),
36
- selector: c()
37
- }), ({ locale: e, selector: t }) => m({
38
- loaderMap: h,
39
- key: x,
34
+ let [p] = c(() => ({
35
+ locale: f(),
36
+ selector: a()
37
+ }), ({ locale: e, selector: t }) => g({
38
+ loaderMap: _,
39
+ key: C,
40
40
  locale: e,
41
41
  selector: t,
42
42
  transform: (e) => e
43
- })), C = a(() => {
44
- let t = S(), n = g();
43
+ })), v = o(() => {
44
+ let t = p(), n = f();
45
45
  return Array.isArray(t) ? t.map((t) => e(t, n)) : [];
46
46
  });
47
- return o(() => {
48
- S();
49
- }), new Proxy(C, {
47
+ return s(() => {
48
+ p();
49
+ }), new Proxy(v, {
50
50
  get(e, t) {
51
51
  return e()?.[t];
52
52
  },
@@ -55,17 +55,19 @@ var h = (h, g, _) => {
55
55
  }
56
56
  });
57
57
  }
58
- let S = h, C = _, w = () => C ?? y?.() ?? b, T = r(() => {
59
- let e = w();
58
+ let w = _, T = y, E = () => T ?? x?.() ?? S, D = () => {
59
+ let e = E();
60
60
  return {
61
- cacheKey: `${x}.${e}`,
61
+ cacheKey: `${C}.${e}`,
62
62
  locale: e
63
63
  };
64
- }, ({ locale: e }) => {
65
- let t = S[e];
66
- return t ? t() : Promise.reject(/* @__PURE__ */ Error(`No dynamic dictionary loader found for key "${x}" and locale "${e}".`));
67
- });
68
- return n(T, C);
64
+ }, O = ({ locale: e }) => {
65
+ let t = w[e];
66
+ return t ? t() : Promise.reject(/* @__PURE__ */ Error(`No dynamic dictionary loader found for key "${C}" and locale "${e}".`));
67
+ }, k = f(w, E());
68
+ k && r(D(), k);
69
+ let A = i(D, O);
70
+ return n(A, T);
69
71
  };
70
72
  //#endregion
71
- export { h as useDictionaryDynamic };
73
+ export { _ as useDictionaryDynamic };
@@ -17,32 +17,38 @@ var i = Symbol("NO_PENDING_PRIMITIVE_FALLBACK"), a = /* @__PURE__ */ new Map(),
17
17
  status: "pending",
18
18
  promise: i
19
19
  }), i;
20
- }, u = (e, t) => typeof t == "function" ? t.bind(e) : t, d = (t) => t === Symbol.toPrimitive ? () => "" : t === Symbol.iterator ? () => ({ next: () => ({
20
+ }, u = (e, t) => {
21
+ let n = o(e);
22
+ a.has(n) || a.set(n, {
23
+ status: "success",
24
+ value: t
25
+ });
26
+ }, d = (e, t) => typeof t == "function" ? t.bind(e) : t, f = (t) => t === Symbol.toPrimitive ? () => "" : t === Symbol.iterator ? () => ({ next: () => ({
21
27
  done: !0,
22
28
  value: void 0
23
- }) }) : t === "length" ? 0 : t === e.toString ? () => "" : t === e.valueOf ? () => void 0 : t === e.value ? "" : i, f = (t) => {
29
+ }) }) : t === "length" ? 0 : t === e.toString ? () => "" : t === e.valueOf ? () => void 0 : t === e.value ? "" : i, p = (t) => {
24
30
  let n = (a) => new Proxy(() => void 0, {
25
31
  get(r, o) {
26
32
  if (o === e.promiseThen) return;
27
33
  let c = s(t(), a);
28
- if (c != null) return o === Symbol.toPrimitive ? () => c : u(c, Reflect.get(Object(c), o));
29
- let l = d(o);
34
+ if (c != null) return o === Symbol.toPrimitive ? () => c : d(c, Reflect.get(Object(c), o));
35
+ let l = f(o);
30
36
  return l === i ? n([...a, o]) : l;
31
37
  },
32
38
  apply(e, n, i) {
33
39
  let o = s(t(), a);
34
- return typeof o == "function" ? Reflect.apply(o, n, i) : i.length === 0 ? o ?? "" : f(() => {
40
+ return typeof o == "function" ? Reflect.apply(o, n, i) : i.length === 0 ? o ?? "" : p(() => {
35
41
  let e = s(t(), a);
36
42
  if (typeof e == "function") return r(() => Reflect.apply(e, n, i));
37
43
  });
38
44
  }
39
45
  });
40
46
  return n([]);
41
- }, p = (e, r) => {
47
+ }, m = (e, r) => {
42
48
  let [i] = n(() => typeof e == "function" ? e() : e, (e) => l(e, r));
43
49
  return t(() => {
44
50
  i();
45
- }), f(() => i());
51
+ }), p(() => i());
46
52
  };
47
53
  //#endregion
48
- export { f as createLoadableProxy, o as getDynamicSourceCacheKey, l as loadDynamicValue, p as useLoadDynamic };
54
+ export { p as createLoadableProxy, o as getDynamicSourceCacheKey, l as loadDynamicValue, u as seedDynamicValue, m as useLoadDynamic };
@@ -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('@intlayer/types').Locale;
6
+ locale: import('intlayer').Locale;
7
7
  content: Content;
8
8
  t: <Content_1 = string>(languageContent: StrictModeLocaleMap<Content_1>) => Content_1;
9
9
  };
@@ -5,6 +5,17 @@ type DynamicKey<T extends DynamicSource> = T | (() => T);
5
5
  export type DynamicLoader<T, Source extends DynamicSource> = Promise<T> | ((source: Source) => Promise<T>);
6
6
  export declare const getDynamicSourceCacheKey: (source: DynamicSource) => string;
7
7
  export declare const loadDynamicValue: <T, Source extends DynamicSource>(source: Source, loader: DynamicLoader<T, Source>) => T | Promise<T>;
8
+ /**
9
+ * Records a value that is already available, so the next
10
+ * {@link loadDynamicValue} for this key returns it synchronously.
11
+ *
12
+ * Used for dictionaries a build-tool plugin awaited while their entry point
13
+ * evaluated: `createResource` resolves without ever entering a pending state,
14
+ * so Suspense is not triggered and the first render already has the content.
15
+ *
16
+ * An existing entry is never replaced — an in-flight load owns its key.
17
+ */
18
+ export declare const seedDynamicValue: <T>(source: DynamicSource, value: T) => void;
8
19
  /**
9
20
  * Creates a stable callable proxy that re-reads the Solid resource on each
10
21
  * property access. This keeps synchronous Intlayer access (`content.x.value`)
@@ -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('@intlayer/types').Locale | undefined;
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('@intlayer/types').Locale | undefined;
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('@intlayer/types').Locale;
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('@intlayer/types').Locale;
37
+ getLocale: () => import('intlayer').Locale;
38
38
  setLocale: (locale: LocalesValues) => void;
39
39
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-intlayer",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -114,10 +114,10 @@
114
114
  },
115
115
  "dependencies": {
116
116
  "@intlayer/api": "9.3.2",
117
- "@intlayer/config": "9.3.2",
118
- "@intlayer/core": "9.3.2",
119
- "@intlayer/editor": "9.3.2",
120
- "@intlayer/types": "9.3.2"
117
+ "@intlayer/config": "9.3.3",
118
+ "@intlayer/core": "9.3.3",
119
+ "@intlayer/editor": "9.3.3",
120
+ "@intlayer/types": "9.3.3"
121
121
  },
122
122
  "devDependencies": {
123
123
  "@solidjs/testing-library": "0.8.10",
@@ -135,13 +135,13 @@
135
135
  "vite": "8.2.1",
136
136
  "vite-plugin-dts": "5.0.3",
137
137
  "vite-plugin-solid": "2.11.14",
138
- "vitest": "4.1.10"
138
+ "vitest": "4.1.11"
139
139
  },
140
140
  "peerDependencies": {
141
141
  "solid-js": ">=1.0.0"
142
142
  },
143
143
  "optionalDependencies": {
144
- "@intlayer/analytics": "9.3.2"
144
+ "@intlayer/analytics": "9.3.3"
145
145
  },
146
146
  "engines": {
147
147
  "node": ">=14.18"