@asteby/metacore-i18n 5.0.1 → 6.0.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/addon-i18n.d.ts +39 -0
- package/dist/addon-i18n.d.ts.map +1 -0
- package/dist/addon-i18n.js +235 -0
- package/dist/addon-i18n.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type UseAddonI18nOptions = {
|
|
2
|
+
/** Override the Hub base URL. Defaults to globalThis or VITE_HUB_URL or hub.asteby.com. */
|
|
3
|
+
hubURL?: string;
|
|
4
|
+
/** Disable the localStorage layer (memory + network only). */
|
|
5
|
+
disablePersistence?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type UseAddonI18nResult = {
|
|
8
|
+
/** Translation map for the current language. Empty when not yet fetched or not provided by the addon. */
|
|
9
|
+
labels: Record<string, string>;
|
|
10
|
+
/** Convenience: labels.name (or empty string) — the addon's display name. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** True after the first network/cached resolution for the current (key, lang) pair. */
|
|
13
|
+
ready: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the i18n bundle published by an addon's manifest from the Hub.
|
|
17
|
+
*
|
|
18
|
+
* Reactive to `useLocale()` — switching language refetches without a page
|
|
19
|
+
* reload. Memory + localStorage cached. Returns `{}` for addons that don't
|
|
20
|
+
* ship a bundle for the active language so callers fall back gracefully.
|
|
21
|
+
*
|
|
22
|
+
* const { name, labels } = useAddonI18n('assets')
|
|
23
|
+
* // sidebar.tsx
|
|
24
|
+
* <SidebarItem title={name || addon.name || addon.key} />
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAddonI18n(addonKey: string | undefined | null, options?: UseAddonI18nOptions): UseAddonI18nResult;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve display names for many addons at once. Built for the sidebar /
|
|
29
|
+
* dashboard which iterate over an installed-addons list and need the
|
|
30
|
+
* localised name without spawning one component per row.
|
|
31
|
+
*
|
|
32
|
+
* const names = useAddonNames(installs.map(i => i.addon_key))
|
|
33
|
+
* // names['assets'] -> 'Activos Fijos' (es) or 'Fixed Assets' (en)
|
|
34
|
+
*
|
|
35
|
+
* Empty string for entries without a Hub-published bundle so callers can
|
|
36
|
+
* fall back to the install-time row.name or the raw key.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useAddonNames(keys: ReadonlyArray<string>, options?: UseAddonI18nOptions): Record<string, string>;
|
|
39
|
+
//# sourceMappingURL=addon-i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addon-i18n.d.ts","sourceRoot":"","sources":["../src/addon-i18n.ts"],"names":[],"mappings":"AA+EA,MAAM,MAAM,mBAAmB,GAAG;IAChC,2FAA2F;IAC3F,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yGAAyG;IACzG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAA;IACZ,uFAAuF;IACvF,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACnC,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CAmEpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,OAAO,GAAE,mBAAwB,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwExB"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useLocale } from './hooks';
|
|
3
|
+
const DEFAULT_HUB_URL = 'https://hub.asteby.com';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the Hub base URL the SDK should hit for addon i18n bundles.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order:
|
|
8
|
+
* 1. explicit `hubURL` argument
|
|
9
|
+
* 2. `globalThis.__METACORE_HUB_URL__` (apps can set this once on boot)
|
|
10
|
+
* 3. `import.meta.env.VITE_HUB_URL` (Vite apps)
|
|
11
|
+
* 4. `https://hub.asteby.com`
|
|
12
|
+
*/
|
|
13
|
+
function resolveHubURL(override) {
|
|
14
|
+
if (override)
|
|
15
|
+
return override.replace(/\/$/, '');
|
|
16
|
+
const g = globalThis;
|
|
17
|
+
if (g.__METACORE_HUB_URL__)
|
|
18
|
+
return g.__METACORE_HUB_URL__.replace(/\/$/, '');
|
|
19
|
+
try {
|
|
20
|
+
const envURL = import.meta?.env?.VITE_HUB_URL;
|
|
21
|
+
if (envURL)
|
|
22
|
+
return envURL.replace(/\/$/, '');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* SSR / non-Vite */
|
|
26
|
+
}
|
|
27
|
+
return DEFAULT_HUB_URL;
|
|
28
|
+
}
|
|
29
|
+
const STORAGE_PREFIX = 'metacore.addon-i18n';
|
|
30
|
+
const TTL_MS = 1000 * 60 * 60 * 6; // 6h — addon i18n is near-immutable per version
|
|
31
|
+
const memoryCache = new Map();
|
|
32
|
+
function readLocalStorage(cacheKey) {
|
|
33
|
+
if (typeof localStorage === 'undefined')
|
|
34
|
+
return null;
|
|
35
|
+
try {
|
|
36
|
+
const raw = localStorage.getItem(`${STORAGE_PREFIX}:${cacheKey}`);
|
|
37
|
+
if (!raw)
|
|
38
|
+
return null;
|
|
39
|
+
const entry = JSON.parse(raw);
|
|
40
|
+
if (!entry || typeof entry.storedAt !== 'number')
|
|
41
|
+
return null;
|
|
42
|
+
if (Date.now() - entry.storedAt > TTL_MS) {
|
|
43
|
+
localStorage.removeItem(`${STORAGE_PREFIX}:${cacheKey}`);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return entry.labels ?? null;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function writeLocalStorage(cacheKey, labels) {
|
|
53
|
+
if (typeof localStorage === 'undefined')
|
|
54
|
+
return;
|
|
55
|
+
try {
|
|
56
|
+
const payload = { labels, storedAt: Date.now() };
|
|
57
|
+
localStorage.setItem(`${STORAGE_PREFIX}:${cacheKey}`, JSON.stringify(payload));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
/* storage full / disabled */
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function fetchAddonI18n(hubURL, addonKey, lang) {
|
|
64
|
+
const url = `${hubURL}/v1/addons/${encodeURIComponent(addonKey)}/i18n/${encodeURIComponent(lang)}.json`;
|
|
65
|
+
const res = await fetch(url, { credentials: 'omit' });
|
|
66
|
+
if (!res.ok) {
|
|
67
|
+
if (res.status === 404)
|
|
68
|
+
return {};
|
|
69
|
+
throw new Error(`addon i18n fetch failed: ${res.status}`);
|
|
70
|
+
}
|
|
71
|
+
const data = (await res.json());
|
|
72
|
+
return data && typeof data === 'object' ? data : {};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the i18n bundle published by an addon's manifest from the Hub.
|
|
76
|
+
*
|
|
77
|
+
* Reactive to `useLocale()` — switching language refetches without a page
|
|
78
|
+
* reload. Memory + localStorage cached. Returns `{}` for addons that don't
|
|
79
|
+
* ship a bundle for the active language so callers fall back gracefully.
|
|
80
|
+
*
|
|
81
|
+
* const { name, labels } = useAddonI18n('assets')
|
|
82
|
+
* // sidebar.tsx
|
|
83
|
+
* <SidebarItem title={name || addon.name || addon.key} />
|
|
84
|
+
*/
|
|
85
|
+
export function useAddonI18n(addonKey, options = {}) {
|
|
86
|
+
const { locale } = useLocale();
|
|
87
|
+
const lang = locale.split('-')[0] || locale || 'en';
|
|
88
|
+
const hubURL = resolveHubURL(options.hubURL);
|
|
89
|
+
const cacheKey = `${hubURL}|${addonKey ?? ''}|${lang}`;
|
|
90
|
+
// Synchronous initial state from localStorage so the first render already
|
|
91
|
+
// has the right label and the sidebar doesn't flash with the raw key.
|
|
92
|
+
const initial = !addonKey || options.disablePersistence ? null : readLocalStorage(cacheKey);
|
|
93
|
+
const [labels, setLabels] = useState(initial ?? {});
|
|
94
|
+
const [ready, setReady] = useState(initial !== null);
|
|
95
|
+
const lastKeyRef = useRef('');
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!addonKey) {
|
|
98
|
+
setLabels({});
|
|
99
|
+
setReady(true);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (lastKeyRef.current === cacheKey)
|
|
103
|
+
return;
|
|
104
|
+
lastKeyRef.current = cacheKey;
|
|
105
|
+
const cached = options.disablePersistence ? null : readLocalStorage(cacheKey);
|
|
106
|
+
if (cached) {
|
|
107
|
+
setLabels(cached);
|
|
108
|
+
setReady(true);
|
|
109
|
+
// Re-validate in the background — addon publishers may push a new
|
|
110
|
+
// version with updated copy. We don't await so the UI stays snappy.
|
|
111
|
+
}
|
|
112
|
+
let cancelled = false;
|
|
113
|
+
let inflight = memoryCache.get(cacheKey);
|
|
114
|
+
if (!inflight) {
|
|
115
|
+
inflight = fetchAddonI18n(hubURL, addonKey, lang);
|
|
116
|
+
memoryCache.set(cacheKey, inflight);
|
|
117
|
+
}
|
|
118
|
+
inflight
|
|
119
|
+
.then((data) => {
|
|
120
|
+
if (cancelled)
|
|
121
|
+
return;
|
|
122
|
+
setLabels(data);
|
|
123
|
+
setReady(true);
|
|
124
|
+
if (!options.disablePersistence)
|
|
125
|
+
writeLocalStorage(cacheKey, data);
|
|
126
|
+
})
|
|
127
|
+
.catch(() => {
|
|
128
|
+
if (cancelled)
|
|
129
|
+
return;
|
|
130
|
+
// Network failure — keep whatever we had, mark ready so the caller
|
|
131
|
+
// stops showing a loading state.
|
|
132
|
+
setReady(true);
|
|
133
|
+
})
|
|
134
|
+
.finally(() => {
|
|
135
|
+
// Drop the inflight promise so a future remount can refetch on
|
|
136
|
+
// demand. The data lives in localStorage for the next call anyway.
|
|
137
|
+
if (memoryCache.get(cacheKey) === inflight) {
|
|
138
|
+
memoryCache.delete(cacheKey);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return () => {
|
|
142
|
+
cancelled = true;
|
|
143
|
+
};
|
|
144
|
+
}, [addonKey, lang, hubURL, cacheKey, options.disablePersistence]);
|
|
145
|
+
return {
|
|
146
|
+
labels,
|
|
147
|
+
name: labels.name ?? '',
|
|
148
|
+
ready,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolve display names for many addons at once. Built for the sidebar /
|
|
153
|
+
* dashboard which iterate over an installed-addons list and need the
|
|
154
|
+
* localised name without spawning one component per row.
|
|
155
|
+
*
|
|
156
|
+
* const names = useAddonNames(installs.map(i => i.addon_key))
|
|
157
|
+
* // names['assets'] -> 'Activos Fijos' (es) or 'Fixed Assets' (en)
|
|
158
|
+
*
|
|
159
|
+
* Empty string for entries without a Hub-published bundle so callers can
|
|
160
|
+
* fall back to the install-time row.name or the raw key.
|
|
161
|
+
*/
|
|
162
|
+
export function useAddonNames(keys, options = {}) {
|
|
163
|
+
const { locale } = useLocale();
|
|
164
|
+
const lang = locale.split('-')[0] || locale || 'en';
|
|
165
|
+
const hubURL = resolveHubURL(options.hubURL);
|
|
166
|
+
// Stable cache key so a re-render with the same key list doesn't refetch.
|
|
167
|
+
const keysSig = keys.join(',');
|
|
168
|
+
const [names, setNames] = useState(() => {
|
|
169
|
+
if (options.disablePersistence)
|
|
170
|
+
return {};
|
|
171
|
+
const seed = {};
|
|
172
|
+
for (const k of keys) {
|
|
173
|
+
const cached = readLocalStorage(`${hubURL}|${k}|${lang}`);
|
|
174
|
+
if (cached?.name)
|
|
175
|
+
seed[k] = cached.name;
|
|
176
|
+
}
|
|
177
|
+
return seed;
|
|
178
|
+
});
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (keys.length === 0) {
|
|
181
|
+
setNames({});
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
let cancelled = false;
|
|
185
|
+
const out = {};
|
|
186
|
+
// Hydrate synchronously from localStorage first so the UI never flashes
|
|
187
|
+
// with raw keys, then revalidate over the network.
|
|
188
|
+
if (!options.disablePersistence) {
|
|
189
|
+
for (const k of keys) {
|
|
190
|
+
const cached = readLocalStorage(`${hubURL}|${k}|${lang}`);
|
|
191
|
+
if (cached?.name)
|
|
192
|
+
out[k] = cached.name;
|
|
193
|
+
}
|
|
194
|
+
if (Object.keys(out).length > 0)
|
|
195
|
+
setNames({ ...out });
|
|
196
|
+
}
|
|
197
|
+
Promise.all(keys.map(async (k) => {
|
|
198
|
+
const cacheKey = `${hubURL}|${k}|${lang}`;
|
|
199
|
+
let inflight = memoryCache.get(cacheKey);
|
|
200
|
+
if (!inflight) {
|
|
201
|
+
inflight = fetchAddonI18n(hubURL, k, lang);
|
|
202
|
+
memoryCache.set(cacheKey, inflight);
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const data = await inflight;
|
|
206
|
+
if (!options.disablePersistence)
|
|
207
|
+
writeLocalStorage(cacheKey, data);
|
|
208
|
+
return [k, data.name ?? ''];
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return [k, ''];
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
if (memoryCache.get(cacheKey) === inflight) {
|
|
215
|
+
memoryCache.delete(cacheKey);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
})).then((entries) => {
|
|
219
|
+
if (cancelled)
|
|
220
|
+
return;
|
|
221
|
+
const next = {};
|
|
222
|
+
for (const [k, n] of entries) {
|
|
223
|
+
if (n)
|
|
224
|
+
next[k] = n;
|
|
225
|
+
}
|
|
226
|
+
setNames(next);
|
|
227
|
+
});
|
|
228
|
+
return () => {
|
|
229
|
+
cancelled = true;
|
|
230
|
+
};
|
|
231
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
232
|
+
}, [keysSig, lang, hubURL, options.disablePersistence]);
|
|
233
|
+
return names;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=addon-i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addon-i18n.js","sourceRoot":"","sources":["../src/addon-i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,eAAe,GAAG,wBAAwB,CAAA;AAEhD;;;;;;;;GAQG;AACH,SAAS,aAAa,CAAC,QAAiB;IACtC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAChD,MAAM,CAAC,GAAG,UAA+C,CAAA;IACzD,IAAI,CAAC,CAAC,oBAAoB;QAAE,OAAO,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC5E,IAAI,CAAC;QACH,MAAM,MAAM,GAAI,MAAM,CAAC,IAAY,EAAE,GAAG,EAAE,YAAkC,CAAA;QAC5E,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,oBAAoB;IACtB,CAAC;IACD,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,MAAM,cAAc,GAAG,qBAAqB,CAAA;AAC5C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,CAAC,gDAAgD;AAOlF,MA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 +3,5 @@ export { baseResources, en, es, type BaseLanguage, } from './locales/index';
|
|
|
3
3
|
export { LanguageSwitcher, type LanguageOption, type LanguageSwitcherProps, } from './language-switcher';
|
|
4
4
|
export { DirectionProvider, useDirection, type Direction, type DirectionContextValue, type DirectionProviderProps, } from './direction-provider';
|
|
5
5
|
export { useLocale, directionFor, DEFAULT_RTL_LANGUAGES, type UseLocaleResult, } from './hooks';
|
|
6
|
+
export { useAddonI18n, useAddonNames, type UseAddonI18nOptions, type UseAddonI18nResult, } from './addon-i18n';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,aAAa,EACb,EAAE,EACF,EAAE,EACF,KAAK,YAAY,GAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,aAAa,EACb,EAAE,EACF,EAAE,EACF,KAAK,YAAY,GAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { baseResources, en, es, } from './locales/index';
|
|
|
3
3
|
export { LanguageSwitcher, } from './language-switcher';
|
|
4
4
|
export { DirectionProvider, useDirection, } from './direction-provider';
|
|
5
5
|
export { useLocale, directionFor, DEFAULT_RTL_LANGUAGES, } from './hooks';
|
|
6
|
+
export { useAddonI18n, useAddonNames, } from './addon-i18n';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,aAAa,EACb,EAAE,EACF,EAAE,GAEH,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,gBAAgB,GAGjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iBAAiB,EACjB,YAAY,GAIb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,GAEtB,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,aAAa,EACb,EAAE,EACF,EAAE,GAEH,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,gBAAgB,GAGjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iBAAiB,EACjB,YAAY,GAIb,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,GAEtB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-i18n",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Metacore i18n — i18next factory, base ES/EN bundles, language switcher, RTL provider",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"types": "./dist/hooks.d.ts",
|
|
37
37
|
"import": "./dist/hooks.js"
|
|
38
38
|
},
|
|
39
|
+
"./addon-i18n": {
|
|
40
|
+
"types": "./dist/addon-i18n.d.ts",
|
|
41
|
+
"import": "./dist/addon-i18n.js"
|
|
42
|
+
},
|
|
39
43
|
"./locales/en": "./dist/locales/en.json",
|
|
40
44
|
"./locales/es": "./dist/locales/es.json"
|
|
41
45
|
},
|
|
@@ -45,7 +49,7 @@
|
|
|
45
49
|
"i18next": ">=23",
|
|
46
50
|
"lucide-react": ">=0.460",
|
|
47
51
|
"react-i18next": ">=13",
|
|
48
|
-
"@asteby/metacore-ui": "^0.
|
|
52
|
+
"@asteby/metacore-ui": "^2.0.0"
|
|
49
53
|
},
|
|
50
54
|
"peerDependenciesMeta": {
|
|
51
55
|
"@asteby/metacore-ui": {
|
|
@@ -58,14 +62,14 @@
|
|
|
58
62
|
"devDependencies": {
|
|
59
63
|
"@types/react": "^19.0.0",
|
|
60
64
|
"@types/react-dom": "^19.0.0",
|
|
61
|
-
"i18next": "^
|
|
62
|
-
"lucide-react": "^0.
|
|
65
|
+
"i18next": "^26.0.0",
|
|
66
|
+
"lucide-react": "^1.0.0",
|
|
63
67
|
"react": "^19.2.4",
|
|
64
68
|
"react-dom": "^19.2.4",
|
|
65
|
-
"react-i18next": "^
|
|
69
|
+
"react-i18next": "^17.0.0",
|
|
66
70
|
"tsc-alias": "^1.8.10",
|
|
67
71
|
"typescript": "^5.6.0",
|
|
68
|
-
"@asteby/metacore-ui": "0.
|
|
72
|
+
"@asteby/metacore-ui": "2.0.0"
|
|
69
73
|
},
|
|
70
74
|
"publishConfig": {
|
|
71
75
|
"access": "public"
|