@alfadocs/ui-kit-debug 0.41.1 → 0.41.2
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/agent-catalog.json +1 -1
- package/dist/i18n/config.d.ts.map +1 -1
- package/dist/i18n/config.js +39 -24
- package/dist/i18n/config.js.map +1 -1
- package/package.json +1 -1
package/dist/agent-catalog.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/i18n/config.ts"],"names":[],"mappings":"AAAA,OAAO,OAAsC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/i18n/config.ts"],"names":[],"mappings":"AAAA,OAAO,OAAsC,MAAM,SAAS,CAAC;AAgH7D;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB5D;AAED,2EAA2E;AAC3E,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3D;AAED;;+DAE+D;AAC/D,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAeD,eAAe,OAAO,CAAC;AAiBvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/i18n/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import i from "i18next";
|
|
2
2
|
import { default as v } from "i18next";
|
|
3
|
-
import { initReactI18next as
|
|
4
|
-
import { enUi as
|
|
3
|
+
import { initReactI18next as p } from "react-i18next";
|
|
4
|
+
import { enUi as o } from "./locales/en.js";
|
|
5
5
|
const c = [
|
|
6
6
|
"en",
|
|
7
7
|
"it",
|
|
@@ -22,18 +22,18 @@ const c = [
|
|
|
22
22
|
"zh",
|
|
23
23
|
"hi"
|
|
24
24
|
];
|
|
25
|
-
function
|
|
26
|
-
|
|
25
|
+
function U(e, t) {
|
|
26
|
+
i.addResourceBundle(
|
|
27
27
|
e,
|
|
28
28
|
"ui",
|
|
29
|
-
|
|
29
|
+
t,
|
|
30
30
|
/* deep */
|
|
31
31
|
!0,
|
|
32
32
|
/* overwrite */
|
|
33
33
|
!1
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
36
|
+
const m = {}, r = typeof import.meta < "u" && typeof m < "u" && !1, s = {
|
|
37
37
|
it: () => import("./locales/it.js").then((e) => e.itUi),
|
|
38
38
|
de: () => import("./locales/de.js").then((e) => e.deUi),
|
|
39
39
|
ar: () => import("./locales/ar.js").then((e) => e.arUi),
|
|
@@ -52,11 +52,25 @@ const l = {}, r = typeof import.meta < "u" && typeof l < "u" && !1, o = {
|
|
|
52
52
|
zh: () => import("./locales/zh.js").then((e) => e.zhUi),
|
|
53
53
|
hi: () => import("./locales/hi.js").then((e) => e.hiUi)
|
|
54
54
|
};
|
|
55
|
-
|
|
55
|
+
function u() {
|
|
56
|
+
i.addResourceBundle(
|
|
57
|
+
"en",
|
|
58
|
+
"ui",
|
|
59
|
+
o,
|
|
60
|
+
/* deep */
|
|
61
|
+
!0,
|
|
62
|
+
/* overwrite */
|
|
63
|
+
!1
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
i.isInitialized ? u() : i.use(p).init({
|
|
56
67
|
lng: "en",
|
|
57
68
|
fallbackLng: "en",
|
|
58
69
|
ns: ["ui"],
|
|
59
70
|
defaultNS: "ui",
|
|
71
|
+
// The kit bundles only `en` eagerly and lazy-loads the rest, so the store
|
|
72
|
+
// is partially bundled — let a later consumer `init()` / backend coexist.
|
|
73
|
+
partialBundledLanguages: !0,
|
|
60
74
|
debug: r,
|
|
61
75
|
saveMissing: r,
|
|
62
76
|
missingKeyHandler: void 0,
|
|
@@ -67,39 +81,40 @@ t.use(u).init({
|
|
|
67
81
|
// changeLanguage wrapper below (or the explicit `loadLocale` /
|
|
68
82
|
// `setLocale` / `loadAllLocales` helpers).
|
|
69
83
|
resources: {
|
|
70
|
-
en: { ui:
|
|
84
|
+
en: { ui: o }
|
|
71
85
|
}
|
|
72
86
|
});
|
|
87
|
+
i.on("initialized", u);
|
|
73
88
|
async function n(e) {
|
|
74
|
-
if (e === "en" ||
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
89
|
+
if (e === "en" || i.hasResourceBundle(e, "ui")) return;
|
|
90
|
+
const t = s[e];
|
|
91
|
+
if (!t)
|
|
77
92
|
return;
|
|
78
|
-
const
|
|
79
|
-
|
|
93
|
+
const l = await t();
|
|
94
|
+
i.addResourceBundle(
|
|
80
95
|
e,
|
|
81
96
|
"ui",
|
|
82
|
-
|
|
97
|
+
l,
|
|
83
98
|
/* deep */
|
|
84
99
|
!0,
|
|
85
100
|
/* overwrite */
|
|
86
101
|
!1
|
|
87
102
|
);
|
|
88
103
|
}
|
|
89
|
-
async function
|
|
90
|
-
await n(e), await
|
|
104
|
+
async function g(e) {
|
|
105
|
+
await n(e), await i.changeLanguage(e);
|
|
91
106
|
}
|
|
92
|
-
async function
|
|
93
|
-
await Promise.all(Object.keys(
|
|
107
|
+
async function L() {
|
|
108
|
+
await Promise.all(Object.keys(s).map((e) => n(e)));
|
|
94
109
|
}
|
|
95
|
-
const a =
|
|
96
|
-
|
|
110
|
+
const a = i.changeLanguage.bind(i);
|
|
111
|
+
i.changeLanguage = ((e, t) => e ? n(e).then(() => a(e, t)) : a(e, t));
|
|
97
112
|
export {
|
|
98
113
|
c as LOCALES_WITH_BUNDLES,
|
|
99
114
|
v as default,
|
|
100
|
-
|
|
115
|
+
L as loadAllLocales,
|
|
101
116
|
n as loadLocale,
|
|
102
|
-
|
|
103
|
-
|
|
117
|
+
U as registerUiBundle,
|
|
118
|
+
g as setLocale
|
|
104
119
|
};
|
|
105
120
|
//# sourceMappingURL=config.js.map
|
package/dist/i18n/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/i18n/resources.ts","../../src/i18n/registerUiBundle.ts","../../src/i18n/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* DS i18n resources — aggregate re-exports across all 18 locales. */\n/* */\n/* Every locale lives in its own `./locales/<code>.ts` module so the */\n/* runtime can dynamic-import them (one chunk per locale, see config.ts */\n/* LOADERS map). This file is the eager entry point — used by */\n/* scripts/build-locales.mjs (emits dist/locales/<code>.json) and by */\n/* consumers who want to inline every locale at import time. */\n/* */\n/* 0.30.5: en + it extracted from inline blocks into per-locale files */\n/* (./locales/en.ts, ./locales/it.ts) so the lazy-load story is */\n/* uniform across the 18 locales — no locale lives in this file anymore. */\n/* -------------------------------------------------------------------- */\n\nexport { enUi } from './locales/en.ts';\nexport { itUi } from './locales/it.ts';\nexport { arUi } from './locales/ar.ts';\nexport { deUi } from './locales/de.ts';\nexport { elUi } from './locales/el.ts';\nexport { esUi } from './locales/es.ts';\nexport { frUi } from './locales/fr.ts';\nexport { hiUi } from './locales/hi.ts';\nexport { jaUi } from './locales/ja.ts';\nexport { nlUi } from './locales/nl.ts';\nexport { plUi } from './locales/pl.ts';\nexport { ptUi } from './locales/pt.ts';\nexport { roUi } from './locales/ro.ts';\nexport { ruUi } from './locales/ru.ts';\nexport { sqUi } from './locales/sq.ts';\nexport { svUi } from './locales/sv.ts';\nexport { trUi } from './locales/tr.ts';\nexport { zhUi } from './locales/zh.ts';\n\nimport { enUi } from './locales/en.ts';\nimport { itUi } from './locales/it.ts';\nimport { arUi } from './locales/ar.ts';\nimport { deUi } from './locales/de.ts';\nimport { elUi } from './locales/el.ts';\nimport { esUi } from './locales/es.ts';\nimport { frUi } from './locales/fr.ts';\nimport { hiUi } from './locales/hi.ts';\nimport { jaUi } from './locales/ja.ts';\nimport { nlUi } from './locales/nl.ts';\nimport { plUi } from './locales/pl.ts';\nimport { ptUi } from './locales/pt.ts';\nimport { roUi } from './locales/ro.ts';\nimport { ruUi } from './locales/ru.ts';\nimport { sqUi } from './locales/sq.ts';\nimport { svUi } from './locales/sv.ts';\nimport { trUi } from './locales/tr.ts';\nimport { zhUi } from './locales/zh.ts';\n\n/**\n * Locales that ship a JSON bundle. Consumer apps register these via\n * `i18n.addResourceBundle(locale, 'ui', bundle)` — see docs/06-i18n.mdx.\n * Locales not listed here fall back to English through i18next's own\n * `fallbackLng` resolution.\n */\nexport const LOCALES_WITH_BUNDLES = [\n 'en',\n 'it',\n 'de',\n 'ar',\n 'fr',\n 'es',\n 'pt',\n 'nl',\n 'ro',\n 'sq',\n 'tr',\n 'pl',\n 'sv',\n 'ru',\n 'el',\n 'ja',\n 'zh',\n 'hi',\n] as const;\n\n/** Per-locale `ui` resources keyed by IETF locale tag. */\nexport const uiResources: Record<\n (typeof LOCALES_WITH_BUNDLES)[number],\n Record<string, unknown>\n> = {\n en: enUi,\n it: itUi,\n de: deUi,\n ar: arUi,\n fr: frUi,\n es: esUi,\n pt: ptUi,\n nl: nlUi,\n ro: roUi,\n sq: sqUi,\n tr: trUi,\n pl: plUi,\n sv: svUi,\n ru: ruUi,\n el: elUi,\n ja: jaUi,\n zh: zhUi,\n hi: hiUi,\n};\n","import i18next from 'i18next';\n\n/**\n * Register or extend the `ui` namespace bundle for a locale.\n *\n * Use this only when:\n * - You're shipping a locale the kit doesn't bundle yet (currently\n * en / it / de / ar are auto-registered; ask the DS team before\n * adding more)\n * - You're overriding individual kit strings for a specific consumer\n *\n * Calling `i18next.addResourceBundle` directly is considered private\n * API — go through this helper so that the deep-merge / overwrite\n * semantics stay consistent across consumers.\n */\nexport function registerUiBundle(\n locale: string,\n bundle: Record<string, unknown>,\n): void {\n i18next.addResourceBundle(\n locale,\n 'ui',\n bundle,\n /* deep */ true,\n /* overwrite */ false,\n );\n}\n","import i18next, { type i18n as I18nInstance } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\nimport { enUi } from './locales/en.ts';\n\n/* -------------------------------------------------------------------- */\n/* DS i18n runtime — eager-init English, lazy-load the other 17 locales. */\n/* */\n/* 0.30.5: only English is bundled into the entry chunk. The other 17 */\n/* locales are dynamic imports — Vite emits each as its own ~30-60 KB */\n/* chunk, fetched on demand when a consumer calls `setLocale(code)` or */\n/* `i18next.changeLanguage(code)`. Resolves the Babel deopt warning on */\n/* consumer builds (`dist/i18n/config.js` previously >800 KB) and cuts */\n/* the initial paint cost for consumers who only ever use English. */\n/* */\n/* Consumers that need all locales up-front can call `loadAllLocales()` */\n/* on app boot — emits 17 parallel `import()` calls. */\n/* -------------------------------------------------------------------- */\n\n// In DEV we warn on missing keys so typos surface immediately. In\n// production the handlers tree-shake to no-ops via the import.meta.env\n// guard.\nconst IS_DEV =\n typeof import.meta !== 'undefined' &&\n typeof import.meta.env !== 'undefined' &&\n import.meta.env.DEV === true;\n\n// Per-locale dynamic-import loaders. Each entry produces its own chunk\n// when bundled (Vite / esbuild's static-`import()`-call detection).\n// English is omitted because it ships eagerly in the entry chunk.\nconst LOADERS: Record<string, () => Promise<Record<string, unknown>>> = {\n it: () => import('./locales/it.ts').then((m) => m.itUi),\n de: () => import('./locales/de.ts').then((m) => m.deUi),\n ar: () => import('./locales/ar.ts').then((m) => m.arUi),\n fr: () => import('./locales/fr.ts').then((m) => m.frUi),\n es: () => import('./locales/es.ts').then((m) => m.esUi),\n pt: () => import('./locales/pt.ts').then((m) => m.ptUi),\n nl: () => import('./locales/nl.ts').then((m) => m.nlUi),\n ro: () => import('./locales/ro.ts').then((m) => m.roUi),\n sq: () => import('./locales/sq.ts').then((m) => m.sqUi),\n tr: () => import('./locales/tr.ts').then((m) => m.trUi),\n pl: () => import('./locales/pl.ts').then((m) => m.plUi),\n sv: () => import('./locales/sv.ts').then((m) => m.svUi),\n ru: () => import('./locales/ru.ts').then((m) => m.ruUi),\n el: () => import('./locales/el.ts').then((m) => m.elUi),\n ja: () => import('./locales/ja.ts').then((m) => m.jaUi),\n zh: () => import('./locales/zh.ts').then((m) => m.zhUi),\n hi: () => import('./locales/hi.ts').then((m) => m.hiUi),\n};\n\ni18next.use(initReactI18next).init({\n lng: 'en',\n fallbackLng: 'en',\n ns: ['ui'],\n defaultNS: 'ui',\n debug: IS_DEV,\n saveMissing: IS_DEV,\n missingKeyHandler: IS_DEV\n ? (lngs, ns, key) => {\n console.warn(\n `[i18n] Missing key \"${key}\" in namespace \"${ns}\" for locales [${lngs.join(', ')}].`,\n );\n }\n : undefined,\n interpolation: {\n escapeValue: false,\n },\n // English-only at init — the other 17 locales load on demand via the\n // changeLanguage wrapper below (or the explicit `loadLocale` /\n // `setLocale` / `loadAllLocales` helpers).\n resources: {\n en: { ui: enUi },\n },\n});\n\n/**\n * Lazy-load a locale's `ui` bundle and register it with i18next. No-op\n * for `en` (already in the entry chunk) and for locales already\n * registered. Unknown locales resolve without registering — i18next's\n * `fallbackLng` handles the lookup.\n */\nexport async function loadLocale(code: string): Promise<void> {\n if (code === 'en') return;\n if (i18next.hasResourceBundle(code, 'ui')) return;\n const loader = LOADERS[code];\n if (!loader) {\n if (IS_DEV) {\n console.warn(\n `[i18n] loadLocale: no bundle for \"${code}\"; falling back to \"en\".`,\n );\n }\n return;\n }\n const bundle = await loader();\n i18next.addResourceBundle(\n code,\n 'ui',\n bundle,\n /* deep */ true,\n /* overwrite */ false,\n );\n}\n\n/** Convenience: `loadLocale(code)` then `i18next.changeLanguage(code)`. */\nexport async function setLocale(code: string): Promise<void> {\n await loadLocale(code);\n await i18next.changeLanguage(code);\n}\n\n/** Eager-load every locale bundle in parallel. Useful at app boot when\n * the consumer can afford the up-front cost (offline-first apps,\n * marketing pages that switch locales without a re-fetch). */\nexport async function loadAllLocales(): Promise<void> {\n await Promise.all(Object.keys(LOADERS).map((code) => loadLocale(code)));\n}\n\n// Transparent `changeLanguage` wrapping — consumers keep calling\n// `i18next.changeLanguage('it')` and the kit auto-loads the bundle\n// first. Preserves the 0.30.x API surface; the wrapped method still\n// returns a Promise<TFunction>.\nconst originalChangeLanguage = i18next.changeLanguage.bind(i18next);\ntype ChangeLanguageFn = I18nInstance['changeLanguage'];\ni18next.changeLanguage = ((lng, callback) => {\n if (lng) {\n return loadLocale(lng).then(() => originalChangeLanguage(lng, callback));\n }\n return originalChangeLanguage(lng, callback);\n}) as ChangeLanguageFn;\n\nexport default i18next;\n// 0.30.5: per-locale named re-exports (`itUi`, `deUi`, ...) and the\n// aggregate `uiResources` are no longer re-exported here — they pulled\n// every locale into the consumer's bundle even when only English was\n// referenced (re-exports defeat tree-shaking through this entry point).\n//\n// Consumers that need a specific locale's bundle directly should import\n// from the per-locale subpath:\n//\n// import { itUi } from '@alfadocs/ui-kit/i18n/locales/it';\n//\n// Or, more commonly, just call `i18next.changeLanguage('it')` and let\n// the kit lazy-load it for you (transparent via the `changeLanguage`\n// wrapping above).\n//\n// `LOCALES_WITH_BUNDLES` is a small const array (no locale data) and\n// stays re-exported.\nexport { LOCALES_WITH_BUNDLES } from './resources';\nexport { registerUiBundle } from './registerUiBundle';\n"],"names":["LOCALES_WITH_BUNDLES","registerUiBundle","locale","bundle","i18next","IS_DEV","__vite_import_meta_env__","LOADERS","m","initReactI18next","enUi","loadLocale","code","loader","setLocale","loadAllLocales","originalChangeLanguage","lng","callback"],"mappings":";;;;AA0DO,MAAMA,IAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AC9DO,SAASC,EACdC,GACAC,GACM;AACN,EAAAC,EAAQ;AAAA,IACNF;AAAA,IACA;AAAA,IACAC;AAAA;AAAA,IACW;AAAA;AAAA,IACK;AAAA,EAAA;AAEpB;cCLME,IACJ,OAAO,cAAgB,OACvB,OAAOC,IAAoB,OAC3B,IAKIC,IAAkE;AAAA,EACtE,IAAI,MAAM,OAAO,iBAAi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,MAAMA,EAAE,IAAI;AACxD;AAEAJ,EAAQ,IAAIK,CAAgB,EAAE,KAAK;AAAA,EACjC,KAAK;AAAA,EACL,aAAa;AAAA,EACb,IAAI,CAAC,IAAI;AAAA,EACT,WAAW;AAAA,EACX,OAAOJ;AAAA,EACP,aAAaA;AAAA,EACb,mBAMI;AAAA,EACJ,eAAe;AAAA,IACb,aAAa;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAKf,WAAW;AAAA,IACT,IAAI,EAAE,IAAIK,EAAA;AAAA,EAAK;AAEnB,CAAC;AAQD,eAAsBC,EAAWC,GAA6B;AAE5D,MADIA,MAAS,QACTR,EAAQ,kBAAkBQ,GAAM,IAAI,EAAG;AAC3C,QAAMC,IAASN,EAAQK,CAAI;AAC3B,MAAI,CAACC;AAMH;AAEF,QAAMV,IAAS,MAAMU,EAAA;AACrB,EAAAT,EAAQ;AAAA,IACNQ;AAAA,IACA;AAAA,IACAT;AAAA;AAAA,IACW;AAAA;AAAA,IACK;AAAA,EAAA;AAEpB;AAGA,eAAsBW,EAAUF,GAA6B;AAC3D,QAAMD,EAAWC,CAAI,GACrB,MAAMR,EAAQ,eAAeQ,CAAI;AACnC;AAKA,eAAsBG,IAAgC;AACpD,QAAM,QAAQ,IAAI,OAAO,KAAKR,CAAO,EAAE,IAAI,CAACK,MAASD,EAAWC,CAAI,CAAC,CAAC;AACxE;AAMA,MAAMI,IAAyBZ,EAAQ,eAAe,KAAKA,CAAO;AAElEA,EAAQ,kBAAkB,CAACa,GAAKC,MAC1BD,IACKN,EAAWM,CAAG,EAAE,KAAK,MAAMD,EAAuBC,GAAKC,CAAQ,CAAC,IAElEF,EAAuBC,GAAKC,CAAQ;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/i18n/resources.ts","../../src/i18n/registerUiBundle.ts","../../src/i18n/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* DS i18n resources — aggregate re-exports across all 18 locales. */\n/* */\n/* Every locale lives in its own `./locales/<code>.ts` module so the */\n/* runtime can dynamic-import them (one chunk per locale, see config.ts */\n/* LOADERS map). This file is the eager entry point — used by */\n/* scripts/build-locales.mjs (emits dist/locales/<code>.json) and by */\n/* consumers who want to inline every locale at import time. */\n/* */\n/* 0.30.5: en + it extracted from inline blocks into per-locale files */\n/* (./locales/en.ts, ./locales/it.ts) so the lazy-load story is */\n/* uniform across the 18 locales — no locale lives in this file anymore. */\n/* -------------------------------------------------------------------- */\n\nexport { enUi } from './locales/en.ts';\nexport { itUi } from './locales/it.ts';\nexport { arUi } from './locales/ar.ts';\nexport { deUi } from './locales/de.ts';\nexport { elUi } from './locales/el.ts';\nexport { esUi } from './locales/es.ts';\nexport { frUi } from './locales/fr.ts';\nexport { hiUi } from './locales/hi.ts';\nexport { jaUi } from './locales/ja.ts';\nexport { nlUi } from './locales/nl.ts';\nexport { plUi } from './locales/pl.ts';\nexport { ptUi } from './locales/pt.ts';\nexport { roUi } from './locales/ro.ts';\nexport { ruUi } from './locales/ru.ts';\nexport { sqUi } from './locales/sq.ts';\nexport { svUi } from './locales/sv.ts';\nexport { trUi } from './locales/tr.ts';\nexport { zhUi } from './locales/zh.ts';\n\nimport { enUi } from './locales/en.ts';\nimport { itUi } from './locales/it.ts';\nimport { arUi } from './locales/ar.ts';\nimport { deUi } from './locales/de.ts';\nimport { elUi } from './locales/el.ts';\nimport { esUi } from './locales/es.ts';\nimport { frUi } from './locales/fr.ts';\nimport { hiUi } from './locales/hi.ts';\nimport { jaUi } from './locales/ja.ts';\nimport { nlUi } from './locales/nl.ts';\nimport { plUi } from './locales/pl.ts';\nimport { ptUi } from './locales/pt.ts';\nimport { roUi } from './locales/ro.ts';\nimport { ruUi } from './locales/ru.ts';\nimport { sqUi } from './locales/sq.ts';\nimport { svUi } from './locales/sv.ts';\nimport { trUi } from './locales/tr.ts';\nimport { zhUi } from './locales/zh.ts';\n\n/**\n * Locales that ship a JSON bundle. Consumer apps register these via\n * `i18n.addResourceBundle(locale, 'ui', bundle)` — see docs/06-i18n.mdx.\n * Locales not listed here fall back to English through i18next's own\n * `fallbackLng` resolution.\n */\nexport const LOCALES_WITH_BUNDLES = [\n 'en',\n 'it',\n 'de',\n 'ar',\n 'fr',\n 'es',\n 'pt',\n 'nl',\n 'ro',\n 'sq',\n 'tr',\n 'pl',\n 'sv',\n 'ru',\n 'el',\n 'ja',\n 'zh',\n 'hi',\n] as const;\n\n/** Per-locale `ui` resources keyed by IETF locale tag. */\nexport const uiResources: Record<\n (typeof LOCALES_WITH_BUNDLES)[number],\n Record<string, unknown>\n> = {\n en: enUi,\n it: itUi,\n de: deUi,\n ar: arUi,\n fr: frUi,\n es: esUi,\n pt: ptUi,\n nl: nlUi,\n ro: roUi,\n sq: sqUi,\n tr: trUi,\n pl: plUi,\n sv: svUi,\n ru: ruUi,\n el: elUi,\n ja: jaUi,\n zh: zhUi,\n hi: hiUi,\n};\n","import i18next from 'i18next';\n\n/**\n * Register or extend the `ui` namespace bundle for a locale.\n *\n * Use this only when:\n * - You're shipping a locale the kit doesn't bundle yet (currently\n * en / it / de / ar are auto-registered; ask the DS team before\n * adding more)\n * - You're overriding individual kit strings for a specific consumer\n *\n * Calling `i18next.addResourceBundle` directly is considered private\n * API — go through this helper so that the deep-merge / overwrite\n * semantics stay consistent across consumers.\n */\nexport function registerUiBundle(\n locale: string,\n bundle: Record<string, unknown>,\n): void {\n i18next.addResourceBundle(\n locale,\n 'ui',\n bundle,\n /* deep */ true,\n /* overwrite */ false,\n );\n}\n","import i18next, { type i18n as I18nInstance } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\nimport { enUi } from './locales/en.ts';\n\n/* -------------------------------------------------------------------- */\n/* DS i18n runtime — eager-init English, lazy-load the other 17 locales. */\n/* */\n/* 0.30.5: only English is bundled into the entry chunk. The other 17 */\n/* locales are dynamic imports — Vite emits each as its own ~30-60 KB */\n/* chunk, fetched on demand when a consumer calls `setLocale(code)` or */\n/* `i18next.changeLanguage(code)`. Resolves the Babel deopt warning on */\n/* consumer builds (`dist/i18n/config.js` previously >800 KB) and cuts */\n/* the initial paint cost for consumers who only ever use English. */\n/* */\n/* Consumers that need all locales up-front can call `loadAllLocales()` */\n/* on app boot — emits 17 parallel `import()` calls. */\n/* -------------------------------------------------------------------- */\n\n// In DEV we warn on missing keys so typos surface immediately. In\n// production the handlers tree-shake to no-ops via the import.meta.env\n// guard.\nconst IS_DEV =\n typeof import.meta !== 'undefined' &&\n typeof import.meta.env !== 'undefined' &&\n import.meta.env.DEV === true;\n\n// Per-locale dynamic-import loaders. Each entry produces its own chunk\n// when bundled (Vite / esbuild's static-`import()`-call detection).\n// English is omitted because it ships eagerly in the entry chunk.\nconst LOADERS: Record<string, () => Promise<Record<string, unknown>>> = {\n it: () => import('./locales/it.ts').then((m) => m.itUi),\n de: () => import('./locales/de.ts').then((m) => m.deUi),\n ar: () => import('./locales/ar.ts').then((m) => m.arUi),\n fr: () => import('./locales/fr.ts').then((m) => m.frUi),\n es: () => import('./locales/es.ts').then((m) => m.esUi),\n pt: () => import('./locales/pt.ts').then((m) => m.ptUi),\n nl: () => import('./locales/nl.ts').then((m) => m.nlUi),\n ro: () => import('./locales/ro.ts').then((m) => m.roUi),\n sq: () => import('./locales/sq.ts').then((m) => m.sqUi),\n tr: () => import('./locales/tr.ts').then((m) => m.trUi),\n pl: () => import('./locales/pl.ts').then((m) => m.plUi),\n sv: () => import('./locales/sv.ts').then((m) => m.svUi),\n ru: () => import('./locales/ru.ts').then((m) => m.ruUi),\n el: () => import('./locales/el.ts').then((m) => m.elUi),\n ja: () => import('./locales/ja.ts').then((m) => m.jaUi),\n zh: () => import('./locales/zh.ts').then((m) => m.zhUi),\n hi: () => import('./locales/hi.ts').then((m) => m.hiUi),\n};\n\n/**\n * Register the kit's `ui` namespace bundles onto whatever i18next instance the\n * consumer is running — deep-merged, NEVER overwriting existing keys. Only\n * English is registered here (the eagerly-bundled locale); the other 17\n * self-register on demand through `loadLocale` / the `changeLanguage` wrapper.\n * Safe to call repeatedly: it re-runs after a consumer `init()` replaces the\n * resource store (see the `initialized` listener below).\n */\nfunction registerUiBundles(): void {\n i18next.addResourceBundle(\n 'en',\n 'ui',\n enUi,\n /* deep */ true,\n /* overwrite */ false,\n );\n}\n\n// A library must NEVER re-`init()` the host's global i18next singleton. If the\n// consumer has already initialised it, we only add our `ui` bundles and leave\n// their language / defaultNS / resources untouched — re-`init` would wipe the\n// app's resources, reset its language to `en`, and hijack `defaultNS` to `ui`\n// (the 0.39.0 alfacare-tools clash). We bootstrap a minimal init ONLY when the\n// kit is genuinely the first/only initialiser (Storybook, tests, a consumer\n// that doesn't own i18next).\nif (i18next.isInitialized) {\n registerUiBundles();\n} else {\n i18next.use(initReactI18next).init({\n lng: 'en',\n fallbackLng: 'en',\n ns: ['ui'],\n defaultNS: 'ui',\n // The kit bundles only `en` eagerly and lazy-loads the rest, so the store\n // is partially bundled — let a later consumer `init()` / backend coexist.\n partialBundledLanguages: true,\n debug: IS_DEV,\n saveMissing: IS_DEV,\n missingKeyHandler: IS_DEV\n ? (lngs, ns, key) => {\n console.warn(\n `[i18n] Missing key \"${key}\" in namespace \"${ns}\" for locales [${lngs.join(', ')}].`,\n );\n }\n : undefined,\n interpolation: {\n escapeValue: false,\n },\n // English-only at init — the other 17 locales load on demand via the\n // changeLanguage wrapper below (or the explicit `loadLocale` /\n // `setLocale` / `loadAllLocales` helpers).\n resources: {\n en: { ui: enUi },\n },\n });\n}\n\n// If the consumer's `init()` runs AFTER this module is imported, its\n// `resources` option replaces the whole store and drops our `ui` bundles —\n// re-add them on every `initialized` event so kit strings survive. Harmless\n// when the kit was the initialiser (the bundle is already present, no-overwrite).\ni18next.on('initialized', registerUiBundles);\n\n/**\n * Lazy-load a locale's `ui` bundle and register it with i18next. No-op\n * for `en` (already in the entry chunk) and for locales already\n * registered. Unknown locales resolve without registering — i18next's\n * `fallbackLng` handles the lookup.\n */\nexport async function loadLocale(code: string): Promise<void> {\n if (code === 'en') return;\n if (i18next.hasResourceBundle(code, 'ui')) return;\n const loader = LOADERS[code];\n if (!loader) {\n if (IS_DEV) {\n console.warn(\n `[i18n] loadLocale: no bundle for \"${code}\"; falling back to \"en\".`,\n );\n }\n return;\n }\n const bundle = await loader();\n i18next.addResourceBundle(\n code,\n 'ui',\n bundle,\n /* deep */ true,\n /* overwrite */ false,\n );\n}\n\n/** Convenience: `loadLocale(code)` then `i18next.changeLanguage(code)`. */\nexport async function setLocale(code: string): Promise<void> {\n await loadLocale(code);\n await i18next.changeLanguage(code);\n}\n\n/** Eager-load every locale bundle in parallel. Useful at app boot when\n * the consumer can afford the up-front cost (offline-first apps,\n * marketing pages that switch locales without a re-fetch). */\nexport async function loadAllLocales(): Promise<void> {\n await Promise.all(Object.keys(LOADERS).map((code) => loadLocale(code)));\n}\n\n// Transparent `changeLanguage` wrapping — consumers keep calling\n// `i18next.changeLanguage('it')` and the kit auto-loads the bundle\n// first. Preserves the 0.30.x API surface; the wrapped method still\n// returns a Promise<TFunction>.\nconst originalChangeLanguage = i18next.changeLanguage.bind(i18next);\ntype ChangeLanguageFn = I18nInstance['changeLanguage'];\ni18next.changeLanguage = ((lng, callback) => {\n if (lng) {\n return loadLocale(lng).then(() => originalChangeLanguage(lng, callback));\n }\n return originalChangeLanguage(lng, callback);\n}) as ChangeLanguageFn;\n\nexport default i18next;\n// 0.30.5: per-locale named re-exports (`itUi`, `deUi`, ...) and the\n// aggregate `uiResources` are no longer re-exported here — they pulled\n// every locale into the consumer's bundle even when only English was\n// referenced (re-exports defeat tree-shaking through this entry point).\n//\n// Consumers that need a specific locale's bundle directly should import\n// from the per-locale subpath:\n//\n// import { itUi } from '@alfadocs/ui-kit/i18n/locales/it';\n//\n// Or, more commonly, just call `i18next.changeLanguage('it')` and let\n// the kit lazy-load it for you (transparent via the `changeLanguage`\n// wrapping above).\n//\n// `LOCALES_WITH_BUNDLES` is a small const array (no locale data) and\n// stays re-exported.\nexport { LOCALES_WITH_BUNDLES } from './resources';\nexport { registerUiBundle } from './registerUiBundle';\n"],"names":["LOCALES_WITH_BUNDLES","registerUiBundle","locale","bundle","i18next","IS_DEV","__vite_import_meta_env__","LOADERS","m","registerUiBundles","enUi","initReactI18next","loadLocale","code","loader","setLocale","loadAllLocales","originalChangeLanguage","lng","callback"],"mappings":";;;;AA0DO,MAAMA,IAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AC9DO,SAASC,EACdC,GACAC,GACM;AACN,EAAAC,EAAQ;AAAA,IACNF;AAAA,IACA;AAAA,IACAC;AAAA;AAAA,IACW;AAAA;AAAA,IACK;AAAA,EAAA;AAEpB;cCLME,IACJ,OAAO,cAAgB,OACvB,OAAOC,IAAoB,OAC3B,IAKIC,IAAkE;AAAA,EACtE,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACC,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,iBAAiB,EAAE,KAAK,CAACA,MAAMA,EAAE,IAAI;AAAA,EACtD,IAAI,MAAM,OAAO,i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,MADIA,MAAS,QACTT,EAAQ,kBAAkBS,GAAM,IAAI,EAAG;AAC3C,QAAMC,IAASP,EAAQM,CAAI;AAC3B,MAAI,CAACC;AAMH;AAEF,QAAMX,IAAS,MAAMW,EAAA;AACrB,EAAAV,EAAQ;AAAA,IACNS;AAAA,IACA;AAAA,IACAV;AAAA;AAAA,IACW;AAAA;AAAA,IACK;AAAA,EAAA;AAEpB;AAGA,eAAsBY,EAAUF,GAA6B;AAC3D,QAAMD,EAAWC,CAAI,GACrB,MAAMT,EAAQ,eAAeS,CAAI;AACnC;AAKA,eAAsBG,IAAgC;AACpD,QAAM,QAAQ,IAAI,OAAO,KAAKT,CAAO,EAAE,IAAI,CAACM,MAASD,EAAWC,CAAI,CAAC,CAAC;AACxE;AAMA,MAAMI,IAAyBb,EAAQ,eAAe,KAAKA,CAAO;AAElEA,EAAQ,kBAAkB,CAACc,GAAKC,MAC1BD,IACKN,EAAWM,CAAG,EAAE,KAAK,MAAMD,EAAuBC,GAAKC,CAAQ,CAAC,IAElEF,EAAuBC,GAAKC,CAAQ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfadocs/ui-kit-debug",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AlfaDocs shared design system — tokens, components, patterns, and translations for platform, booking, and alfascribe. (debug build — identical runtime to @alfadocs/ui-kit, ships source maps for symbolication).",
|
|
6
6
|
"license": "BUSL-1.1",
|