@hakistack/i18n 0.0.0-stage → 0.2.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.
@@ -0,0 +1,394 @@
1
+ /**
2
+ * The single deep-merge used to assemble every tree built from several
3
+ * translation modules: the runtime keys tree (`buildKeysTree`), the generated
4
+ * `TK` literal (`mergeKeys`) and the per-language trees (`buildLanguageTree`).
5
+ *
6
+ * One implementation means the three can never disagree about which keys exist
7
+ * when modules share a scope or nest under each other. A key defined twice, or
8
+ * a key that is both a translation and a group, is an authoring error and throws
9
+ * instead of letting one module silently win.
10
+ */
11
+ function isTree(value) {
12
+ return typeof value === 'object' && value !== null;
13
+ }
14
+ function cloneTree(tree) {
15
+ const out = {};
16
+ for (const [key, value] of Object.entries(tree))
17
+ out[key] = isTree(value) ? cloneTree(value) : value;
18
+ return out;
19
+ }
20
+ /**
21
+ * Deep-merge `source` into `target` (never mutating `source`). `path` is the
22
+ * dotted location of `target`, used in error messages. With `keysTree`, string
23
+ * leaves are full translation keys and are quoted as-is in errors.
24
+ */
25
+ function mergeInto(target, source, path = '', keysTree = false) {
26
+ for (const [key, value] of Object.entries(source)) {
27
+ const at = path ? `${path}.${key}` : key;
28
+ const existing = target[key];
29
+ if (existing === undefined) {
30
+ target[key] = isTree(value) ? cloneTree(value) : value;
31
+ }
32
+ else if (isTree(existing) && isTree(value)) {
33
+ mergeInto(existing, value, at, keysTree);
34
+ }
35
+ else if (!isTree(existing) && !isTree(value)) {
36
+ throw new Error(`i18n: duplicate translation key '${keysTree ? String(existing) : at}' — it is defined by more than one module.`);
37
+ }
38
+ else {
39
+ throw new Error(`i18n: '${at}' is both a translation and a group of translations (check modules sharing or nesting this scope).`);
40
+ }
41
+ }
42
+ }
43
+ /** Wrap `subtree` in nested objects following a dotted `scope` (`'a.b'` → `{ a: { b: subtree } }`). */
44
+ function nestAtScope(scope, subtree) {
45
+ return scope
46
+ .split('.')
47
+ .reverse()
48
+ .reduce((inner, part) => ({ [part]: inner }), subtree);
49
+ }
50
+ /**
51
+ * Deep-merge several keys objects into one. Emitted by `hakistack-i18n scan`
52
+ * wherever several modules contribute to the same `TK` branch (modules sharing
53
+ * a scope, or a module plus deeper scopes nested under it). The intersection
54
+ * type exposes every contributed key, matching the runtime value exactly.
55
+ *
56
+ * @example
57
+ * mergeKeys(COMMON_A.keys, COMMON_B.keys, { users: ADMIN_USERS.keys })
58
+ */
59
+ function mergeKeys(...parts) {
60
+ const out = {};
61
+ for (const part of parts)
62
+ mergeInto(out, part, '', true);
63
+ return out;
64
+ }
65
+
66
+ /**
67
+ * Type-safe translation definitions — the authoring heart of `@hakistack/i18n`.
68
+ *
69
+ * Consumers author translations in `.ts` files (`*.i18n.ts`) using
70
+ * `defineTranslations()` + `t()`. English is the required source locale; every
71
+ * other locale is optional. The companion `keys` object gives type-safe
72
+ * dot-path access at the value level, and the scanner derives a merged `TK`
73
+ * literal from these modules.
74
+ *
75
+ * Unlike the original app-local engine, locales here are **not hardcoded**.
76
+ * Consumers declare their locale union by augmenting the {@link I18nLocales}
77
+ * interface (the scanner / schematic can emit this augmentation), so `t()` gets
78
+ * autocomplete on exactly the locales the project supports.
79
+ */
80
+ /**
81
+ * The source locale. `t()` stores its first argument here, every other locale
82
+ * is optional, and build-time + runtime fallbacks end here. This is fixed by
83
+ * the engine's types (`TranslationValue.en`), so it is not configurable.
84
+ */
85
+ const SOURCE_LANG = 'en';
86
+ /**
87
+ * Runtime brand stamped (non-enumerably) on every `TranslationValue` produced
88
+ * by `t()` or by bare-string normalization.
89
+ *
90
+ * Without a brand, a *group* whose child happens to be named `en` — e.g.
91
+ * `languages: { en: 'English', es: 'Español' }` in a language picker — is
92
+ * indistinguishable from a leaf. `Symbol.for` (global registry) is used so the
93
+ * codegen CLI (which bundles its own copy of the engine) recognizes values
94
+ * created by the consumer's installed copy.
95
+ */
96
+ const TRANSLATION_BRAND = Symbol.for('@hakistack/i18n:translation-value');
97
+ /**
98
+ * Define a single translation value.
99
+ *
100
+ * @param en - English (source) translation — required.
101
+ * @param translations - Other-locale translations — optional, autocompletes the
102
+ * consumer's declared locales.
103
+ * @param options.comment - Translator-facing context. Emitted as a sibling
104
+ * `<key>.comment` entry in the JSON for translator review; stripped at runtime
105
+ * by the comment interceptor so it never renders.
106
+ *
107
+ * @example
108
+ * t('Hello', { es: 'Hola' })
109
+ * t('Save') // English only — other locales fall back to English
110
+ * t('Welcome', { es: '¡Bienvenido!' }, { comment: 'Greeting on home dashboard' })
111
+ */
112
+ function t(en, translations, options) {
113
+ const value = brand({ en, ...translations });
114
+ if (options?.comment) {
115
+ value.__comment = options.comment;
116
+ }
117
+ return value;
118
+ }
119
+ /** Stamp the non-enumerable brand on a plain `{ en, … }` record. */
120
+ function brand(value) {
121
+ Object.defineProperty(value, TRANSLATION_BRAND, { value: true, enumerable: false, writable: false, configurable: false });
122
+ return value;
123
+ }
124
+ /**
125
+ * Define a translation module with auto-generated keys.
126
+ *
127
+ * @param scope - The scope/prefix for these translations.
128
+ * @param translations - The translation definitions (full `t()` form or
129
+ * bare-string shorthand, nested freely).
130
+ * @param options.scoped - Emit to a per-scope JSON file (see {@link TranslationModule.scoped}).
131
+ *
132
+ * @example
133
+ * export const COMMON = defineTranslations('common', {
134
+ * buttons: {
135
+ * save: t('Save', { es: 'Guardar' }),
136
+ * cancel: t('Cancel', { es: 'Cancelar' }),
137
+ * reset: 'Reset', // shorthand
138
+ * },
139
+ * });
140
+ * // COMMON.keys.buttons.save === 'common.buttons.save'
141
+ */
142
+ function defineTranslations(scope, translations, options) {
143
+ const normalized = normalizeTree(translations);
144
+ const keys = buildKeys(normalized, scope);
145
+ return {
146
+ scope,
147
+ translations: normalized,
148
+ keys,
149
+ scoped: options?.scoped ?? false,
150
+ };
151
+ }
152
+ // =============================================================================
153
+ // Internal Utilities
154
+ // =============================================================================
155
+ /**
156
+ * Normalize an authored tree by replacing every bare-string leaf with
157
+ * `{ en: value }`. The output contains only `TranslationValue` leaves and
158
+ * nested records — the canonical shape consumed by the generator/validator.
159
+ */
160
+ function normalizeTree(node) {
161
+ if (typeof node === 'string') {
162
+ return brand({ en: node });
163
+ }
164
+ if (isTranslationValue(node)) {
165
+ return node;
166
+ }
167
+ const result = {};
168
+ for (const [key, value] of Object.entries(node)) {
169
+ result[key] = normalizeTree(value);
170
+ }
171
+ return result;
172
+ }
173
+ /** Recursively builds the dot-path keys object from a normalized tree. */
174
+ function buildKeys(obj, prefix) {
175
+ const result = {};
176
+ for (const [key, value] of Object.entries(obj)) {
177
+ const fullKey = prefix ? `${prefix}.${key}` : key;
178
+ if (isTranslationValue(value)) {
179
+ result[key] = fullKey;
180
+ }
181
+ else if (typeof value === 'object' && value !== null) {
182
+ result[key] = buildKeys(value, fullKey);
183
+ }
184
+ }
185
+ return result;
186
+ }
187
+ /** Type guard: is this value a branded `TranslationValue` (created by `t()` or normalization)? */
188
+ function isTranslationValue(value) {
189
+ return value !== null && typeof value === 'object' && value[TRANSLATION_BRAND] === true;
190
+ }
191
+ // =============================================================================
192
+ // Auto-derive a merged keys tree from module scopes (value-level)
193
+ // =============================================================================
194
+ /**
195
+ * Build a merged keys tree from a list of translation modules by placing each
196
+ * module's `keys` object at its scope path and deep-merging.
197
+ *
198
+ * This is the **runtime** value used by the directive (via the `I18N_KEYS`
199
+ * token). It uses the same deep merge as the scanner-emitted `TK` literal
200
+ * (`mergeKeys`) and the language trees, so all three agree on which keys exist.
201
+ * Throws when a key is defined twice or is both a translation and a group.
202
+ */
203
+ function buildKeysTree(modules) {
204
+ const tree = {};
205
+ for (const mod of modules) {
206
+ mergeInto(tree, nestAtScope(mod.scope, mod.keys), '', true);
207
+ }
208
+ return tree;
209
+ }
210
+ /**
211
+ * Find every key collision across the registry, including the ones a deep
212
+ * merge cannot see: a dotted key name (`'a.b'`) colliding with a nested group
213
+ * (`a: { b }`) produces the same Transloco key.
214
+ */
215
+ function findKeyConflicts(modules) {
216
+ const leaves = [];
217
+ const walk = (node, prefix, scope) => {
218
+ for (const [key, value] of Object.entries(node)) {
219
+ const full = `${prefix}.${key}`;
220
+ if (isTranslationValue(value))
221
+ leaves.push({ key: full, scope });
222
+ else if (typeof value === 'object' && value !== null)
223
+ walk(value, full, scope);
224
+ }
225
+ };
226
+ for (const mod of modules)
227
+ walk(mod.translations, mod.scope, mod.scope);
228
+ return conflictsFromLeaves(leaves);
229
+ }
230
+ /**
231
+ * Conflict detection over a flat list of full keys (one entry per definition).
232
+ * Shared by {@link findKeyConflicts} (runtime registry) and the CLI scanner
233
+ * (keys read statically from source).
234
+ */
235
+ function conflictsFromLeaves(leaves) {
236
+ const byKey = new Map();
237
+ const groups = new Map();
238
+ const add = (map, key, scope) => map.set(key, [...(map.get(key) ?? []), scope]);
239
+ for (const { key, scope } of leaves) {
240
+ add(byKey, key, scope);
241
+ const parts = key.split('.');
242
+ for (let i = 1; i < parts.length; i++)
243
+ add(groups, parts.slice(0, i).join('.'), scope);
244
+ }
245
+ const conflicts = [];
246
+ for (const [key, scopes] of byKey) {
247
+ if (scopes.length > 1)
248
+ conflicts.push({ key, kind: 'duplicate', scopes });
249
+ const groupScopes = groups.get(key);
250
+ if (groupScopes)
251
+ conflicts.push({ key, kind: 'translation-and-group', scopes: [...new Set([...scopes, ...groupScopes])] });
252
+ }
253
+ return conflicts.sort((a, b) => a.key.localeCompare(b.key));
254
+ }
255
+
256
+ /**
257
+ * Build a per-language translation tree from the in-memory module registry.
258
+ *
259
+ * Shared by:
260
+ * - the generator CLI — writes the tree as JSON to `<outputDir>/<lang>.json`
261
+ * for translator-facing tooling (build artifacts, not a runtime dependency).
262
+ * - the runtime `TranslocoRegistryLoader` — returns the tree synchronously to
263
+ * Transloco, eliminating the HTTP fetch.
264
+ *
265
+ * Producing the tree from the registry guarantees the runtime sees the exact
266
+ * shape the generator emits — there's no "JSON drifted from TS" failure mode.
267
+ *
268
+ * Locale handling is parameterized: every function takes the `defaultLang`
269
+ * (source/fallback locale) explicitly rather than reading a hardcoded constant,
270
+ * so the engine is reusable across consumers with different locale sets.
271
+ */
272
+ /**
273
+ * Resolve a single `TranslationValue` for a given language.
274
+ * Falls back to `defaultLang` for any locale that didn't supply a translation —
275
+ * mirrors `useFallbackTranslation: true` in the runtime Transloco config.
276
+ */
277
+ function getTranslation(value, lang, defaultLang) {
278
+ const byLang = value;
279
+ if (lang === defaultLang) {
280
+ return byLang[defaultLang] ?? value.en;
281
+ }
282
+ return byLang[lang] ?? byLang[defaultLang] ?? value.en;
283
+ }
284
+ /**
285
+ * Walk a normalized translation subtree (all leaves are `TranslationValue`s) and
286
+ * emit a string-only tree for the given language.
287
+ *
288
+ * If a leaf carries a `__comment` (set via `t(en, others, { comment })`) and
289
+ * `options.comments` is not `false`, a sibling entry `<key>.comment` is added at
290
+ * the same level for translators.
291
+ */
292
+ function extractLanguage(translations, lang, defaultLang, options = {}) {
293
+ const comments = options.comments ?? true;
294
+ const result = {};
295
+ for (const [key, value] of Object.entries(translations)) {
296
+ if (isTranslationValue(value)) {
297
+ result[key] = getTranslation(value, lang, defaultLang);
298
+ if (comments && value.__comment) {
299
+ result[`${key}.comment`] = value.__comment;
300
+ }
301
+ }
302
+ else if (typeof value === 'object' && value !== null) {
303
+ result[key] = extractLanguage(value, lang, defaultLang, options);
304
+ }
305
+ }
306
+ return result;
307
+ }
308
+ /**
309
+ * Deep-merge a subtree into the target at a dot-delimited scope path, creating
310
+ * intermediate objects as needed. Throws when a key would be defined twice or
311
+ * when a translation and a group collide (see `mergeInto`).
312
+ */
313
+ function setAtScope(target, scope, subtree) {
314
+ mergeInto(target, nestAtScope(scope, subtree));
315
+ }
316
+ /**
317
+ * Build the complete translation tree for a single language from the registry.
318
+ * The returned tree matches the JSON file layout exactly — same keys, nesting,
319
+ * and fallbacks — so a consumer cannot tell whether the data came from the
320
+ * registry or from disk.
321
+ */
322
+ function buildLanguageTree(registry, lang, defaultLang, options) {
323
+ const tree = {};
324
+ for (const mod of registry) {
325
+ setAtScope(tree, mod.scope, extractLanguage(mod.translations, lang, defaultLang, options));
326
+ }
327
+ return tree;
328
+ }
329
+ /**
330
+ * Build the eager (root) tree — only modules declared without `{ scoped: true }`.
331
+ * Used by the generator when route-level scope providers are adopted.
332
+ */
333
+ function buildEagerTree(registry, lang, defaultLang, options) {
334
+ return buildLanguageTree(registry.filter((mod) => !mod.scoped), lang, defaultLang, options);
335
+ }
336
+ /**
337
+ * Build the per-scope tree for a scope — returned unwrapped (no scope key
338
+ * around it), matching the layout `provideTranslocoScope` expects to load from
339
+ * `<scope-with-slashes>/<lang>.json`. Every scoped module declaring that scope
340
+ * is merged in.
341
+ *
342
+ * `scope` may be given in dotted (`administration.users`) or slash form
343
+ * (`administration/users` — what Transloco hands a loader); both match.
344
+ *
345
+ * Returns `null` if no scoped module declares the scope.
346
+ */
347
+ function buildScopedTree(registry, lang, defaultLang, scope, options) {
348
+ const wanted = normalizeScope(scope);
349
+ const modules = registry.filter((mod) => mod.scoped && normalizeScope(mod.scope) === wanted);
350
+ if (modules.length === 0)
351
+ return null;
352
+ const tree = {};
353
+ for (const mod of modules)
354
+ mergeInto(tree, extractLanguage(mod.translations, lang, defaultLang, options), wanted);
355
+ return tree;
356
+ }
357
+ /**
358
+ * Convert a dot-separated scope to its filesystem path.
359
+ * 'administration.users' → 'administration/users'
360
+ */
361
+ function scopeToFilesystemPath(scope) {
362
+ return scope.replace(/\./g, '/');
363
+ }
364
+ /**
365
+ * Canonical dotted form of a scope, accepting either separator.
366
+ * 'administration/users' → 'administration.users'
367
+ */
368
+ function normalizeScope(scope) {
369
+ return scope.replace(/\//g, '.');
370
+ }
371
+
372
+ /*
373
+ * @hakistack/i18n/engine
374
+ *
375
+ * The Angular-free authoring + tree-building engine. This entry point has NO
376
+ * Angular dependency, so it loads in a plain Node context — which is what lets
377
+ * the codegen CLI execute your `*.i18n.ts` modules via a TS loader.
378
+ *
379
+ * Author your translation modules against THIS entry point:
380
+ *
381
+ * ```ts
382
+ * import { defineTranslations, t } from '@hakistack/i18n/engine';
383
+ * ```
384
+ *
385
+ * Runtime APIs (`provideI18n`, `translateSignal`, the directive base) live on
386
+ * the main `@hakistack/i18n` entry point.
387
+ */
388
+
389
+ /**
390
+ * Generated bundle index. Do not edit.
391
+ */
392
+
393
+ export { SOURCE_LANG, TRANSLATION_BRAND, buildEagerTree, buildKeysTree, buildLanguageTree, buildScopedTree, defineTranslations, extractLanguage, findKeyConflicts, getTranslation, isTranslationValue, mergeKeys, normalizeScope, scopeToFilesystemPath, setAtScope, t };
394
+ //# sourceMappingURL=hakistack-i18n-engine.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hakistack-i18n-engine.mjs","sources":["../../../../projects/hakistack/i18n/engine/merge.ts","../../../../projects/hakistack/i18n/engine/define-translations.ts","../../../../projects/hakistack/i18n/engine/build-tree.ts","../../../../projects/hakistack/i18n/engine/public-api.ts","../../../../projects/hakistack/i18n/engine/hakistack-i18n-engine.ts"],"sourcesContent":["/**\n * The single deep-merge used to assemble every tree built from several\n * translation modules: the runtime keys tree (`buildKeysTree`), the generated\n * `TK` literal (`mergeKeys`) and the per-language trees (`buildLanguageTree`).\n *\n * One implementation means the three can never disagree about which keys exist\n * when modules share a scope or nest under each other. A key defined twice, or\n * a key that is both a translation and a group, is an authoring error and throws\n * instead of letting one module silently win.\n */\n\ntype Tree = Record<string, unknown>;\n\nfunction isTree(value: unknown): value is Tree {\n return typeof value === 'object' && value !== null;\n}\n\nfunction cloneTree(tree: Tree): Tree {\n const out: Tree = {};\n for (const [key, value] of Object.entries(tree)) out[key] = isTree(value) ? cloneTree(value) : value;\n return out;\n}\n\n/**\n * Deep-merge `source` into `target` (never mutating `source`). `path` is the\n * dotted location of `target`, used in error messages. With `keysTree`, string\n * leaves are full translation keys and are quoted as-is in errors.\n */\nexport function mergeInto(target: Tree, source: Tree, path = '', keysTree = false): void {\n for (const [key, value] of Object.entries(source)) {\n const at = path ? `${path}.${key}` : key;\n const existing = target[key];\n if (existing === undefined) {\n target[key] = isTree(value) ? cloneTree(value) : value;\n } else if (isTree(existing) && isTree(value)) {\n mergeInto(existing, value, at, keysTree);\n } else if (!isTree(existing) && !isTree(value)) {\n throw new Error(`i18n: duplicate translation key '${keysTree ? String(existing) : at}' — it is defined by more than one module.`);\n } else {\n throw new Error(`i18n: '${at}' is both a translation and a group of translations (check modules sharing or nesting this scope).`);\n }\n }\n}\n\n/** Wrap `subtree` in nested objects following a dotted `scope` (`'a.b'` → `{ a: { b: subtree } }`). */\nexport function nestAtScope(scope: string, subtree: Tree): Tree {\n return scope\n .split('.')\n .reverse()\n .reduce<Tree>((inner, part) => ({ [part]: inner }), subtree);\n}\n\ntype Intersect<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Rest] ? Head & Intersect<Rest> : unknown;\n\n/**\n * Deep-merge several keys objects into one. Emitted by `hakistack-i18n scan`\n * wherever several modules contribute to the same `TK` branch (modules sharing\n * a scope, or a module plus deeper scopes nested under it). The intersection\n * type exposes every contributed key, matching the runtime value exactly.\n *\n * @example\n * mergeKeys(COMMON_A.keys, COMMON_B.keys, { users: ADMIN_USERS.keys })\n */\nexport function mergeKeys<const T extends readonly object[]>(...parts: T): Intersect<T> {\n const out: Tree = {};\n for (const part of parts) mergeInto(out, part as Tree, '', true);\n return out as Intersect<T>;\n}\n","/**\n * Type-safe translation definitions — the authoring heart of `@hakistack/i18n`.\n *\n * Consumers author translations in `.ts` files (`*.i18n.ts`) using\n * `defineTranslations()` + `t()`. English is the required source locale; every\n * other locale is optional. The companion `keys` object gives type-safe\n * dot-path access at the value level, and the scanner derives a merged `TK`\n * literal from these modules.\n *\n * Unlike the original app-local engine, locales here are **not hardcoded**.\n * Consumers declare their locale union by augmenting the {@link I18nLocales}\n * interface (the scanner / schematic can emit this augmentation), so `t()` gets\n * autocomplete on exactly the locales the project supports.\n */\n\nimport { mergeInto, nestAtScope } from './merge';\n\n// =============================================================================\n// Locale configuration (consumer-augmented)\n// =============================================================================\n\n/**\n * The set of locales a project supports, as a type.\n *\n * `en` is the always-present source locale (English is the source of truth).\n * Consumers add their other locales by declaration-merging this interface:\n *\n * ```ts\n * declare module '@hakistack/i18n/engine' {\n * interface I18nLocales {\n * es: string;\n * fr: string;\n * }\n * }\n * ```\n *\n * After augmentation, `t('Hello', { es: '…', fr: '…' })` autocompletes `es`/`fr`\n * and `Language` resolves to `'en' | 'es' | 'fr'`.\n */\nexport interface I18nLocales {\n /** Source locale — always required on every translation value. */\n en: string;\n}\n\n/** Union of every declared locale id (e.g. `'en' | 'es'`). */\nexport type LocaleId = keyof I18nLocales & string;\n\n/**\n * The source locale. `t()` stores its first argument here, every other locale\n * is optional, and build-time + runtime fallbacks end here. This is fixed by\n * the engine's types (`TranslationValue.en`), so it is not configurable.\n */\nexport const SOURCE_LANG = 'en';\nexport type SourceLang = typeof SOURCE_LANG;\n\n/**\n * Runtime brand stamped (non-enumerably) on every `TranslationValue` produced\n * by `t()` or by bare-string normalization.\n *\n * Without a brand, a *group* whose child happens to be named `en` — e.g.\n * `languages: { en: 'English', es: 'Español' }` in a language picker — is\n * indistinguishable from a leaf. `Symbol.for` (global registry) is used so the\n * codegen CLI (which bundles its own copy of the engine) recognizes values\n * created by the consumer's installed copy.\n */\nexport const TRANSLATION_BRAND: unique symbol = Symbol.for('@hakistack/i18n:translation-value');\n\n/** Alias kept for ergonomics — the active/target language id. */\nexport type Language = LocaleId;\n\n// =============================================================================\n// Type Definitions\n// =============================================================================\n\n/**\n * A single translation value across all declared locales.\n *\n * English (`en`) is required; every other declared locale is optional and falls\n * back to English at build time and runtime. The optional `__comment` field\n * stores translator-facing context — it is emitted as a sibling `<key>.comment`\n * entry in the JSON and stripped by the runtime interceptor so it never renders.\n */\nexport type TranslationValue = OtherLocales & {\n en: string;\n /** Internal — translator-context comment, attached via `t(en, others, { comment })`. */\n __comment?: string;\n /** Internal — runtime brand; only `t()` / normalization create branded values. */\n readonly [TRANSLATION_BRAND]: true;\n};\n\n/** Optional non-source locale fields, derived from the augmented locale set. */\nexport type OtherLocales = {\n [K in Exclude<LocaleId, 'en'>]?: string;\n};\n\n/**\n * Define a single translation value.\n *\n * @param en - English (source) translation — required.\n * @param translations - Other-locale translations — optional, autocompletes the\n * consumer's declared locales.\n * @param options.comment - Translator-facing context. Emitted as a sibling\n * `<key>.comment` entry in the JSON for translator review; stripped at runtime\n * by the comment interceptor so it never renders.\n *\n * @example\n * t('Hello', { es: 'Hola' })\n * t('Save') // English only — other locales fall back to English\n * t('Welcome', { es: '¡Bienvenido!' }, { comment: 'Greeting on home dashboard' })\n */\nexport function t(en: string, translations?: OtherLocales, options?: { comment?: string }): TranslationValue {\n const value = brand({ en, ...translations });\n if (options?.comment) {\n value.__comment = options.comment;\n }\n return value;\n}\n\n/** Stamp the non-enumerable brand on a plain `{ en, … }` record. */\nfunction brand(value: OtherLocales & { en: string; __comment?: string }): TranslationValue {\n Object.defineProperty(value, TRANSLATION_BRAND, { value: true, enumerable: false, writable: false, configurable: false });\n return value as TranslationValue;\n}\n\n/**\n * Authored translation node — what callers write inside `defineTranslations()`.\n * Accepts:\n * - `TranslationValue` (full form, from `t()`)\n * - `string` (shorthand for English-only — equivalent to `t(value)`)\n * - nested object of either\n *\n * Only `t()` produces a leaf. A hand-written `{ en: '…', es: '…' }` object is a\n * *group* with children named `en`/`es` — which is what a language picker wants.\n *\n * Strings are normalized to `TranslationValue` at module construction so the\n * rest of the pipeline (generator, validator, keys builder) only ever sees the\n * canonical `{ en, … }` shape.\n *\n * Note: any leaf string containing `{{…}}` placeholders MUST use `t()` — the\n * validator rejects bare placeholder strings because parity across locales\n * cannot be expressed with the shorthand.\n */\nexport type AuthoredTranslationNode = TranslationValue | string | { [key: string]: AuthoredTranslationNode };\n\n/** Canonical (post-normalization) translation node — internal use only. */\ntype TranslationNode = TranslationValue | { [key: string]: TranslationNode };\n\n/**\n * Recursively builds dot-notation key strings from the authored object shape.\n * Treats both `TranslationValue` and `string` as leaves (string is shorthand).\n */\ntype BuildKeyObject<T, Prefix extends string = ''> = {\n readonly [K in keyof T]: K extends string\n ? T[K] extends TranslationValue | string\n ? Join<Prefix, K>\n : T[K] extends Record<string, unknown>\n ? BuildKeyObject<T[K], Join<Prefix, K>>\n : never\n : never;\n};\n\ntype Join<Prefix extends string, K extends string> = Prefix extends '' ? K : `${Prefix}.${K}`;\n\n/**\n * Translation module returned by {@link defineTranslations}.\n *\n * `translations` stores the normalized form (every bare string promoted to\n * `{ en: value }`); `keys` is the type-derived companion of dot-paths.\n */\nexport interface TranslationModule<\n T extends Record<string, AuthoredTranslationNode> = Record<string, AuthoredTranslationNode>,\n S extends string = string,\n> {\n /** Scope/prefix for these translations (e.g. `'common'`, `'administration.users'`). */\n scope: S;\n /** Normalized translation definitions (strings promoted to `{ en: value }`). */\n translations: T;\n /** Auto-generated keys object for type-safe usage (full keys, scope included: `'common.buttons.save'`). */\n keys: BuildKeyObject<T, S>;\n /**\n * If `true`, the generator emits this module's data to a subdirectory matching\n * its scope path (`administration.users` → `administration/users/<lang>.json`)\n * rather than merging into the root `<lang>.json`. Future-proofs\n * `provideTranslocoScope`-based lazy loading. Default: `false` (eager).\n */\n scoped: boolean;\n}\n\n/**\n * Define a translation module with auto-generated keys.\n *\n * @param scope - The scope/prefix for these translations.\n * @param translations - The translation definitions (full `t()` form or\n * bare-string shorthand, nested freely).\n * @param options.scoped - Emit to a per-scope JSON file (see {@link TranslationModule.scoped}).\n *\n * @example\n * export const COMMON = defineTranslations('common', {\n * buttons: {\n * save: t('Save', { es: 'Guardar' }),\n * cancel: t('Cancel', { es: 'Cancelar' }),\n * reset: 'Reset', // shorthand\n * },\n * });\n * // COMMON.keys.buttons.save === 'common.buttons.save'\n */\nexport function defineTranslations<T extends Record<string, AuthoredTranslationNode>, const S extends string = string>(\n scope: S,\n translations: T,\n options?: { scoped?: boolean },\n): TranslationModule<T, S> {\n const normalized = normalizeTree(translations) as Record<string, TranslationNode>;\n const keys = buildKeys(normalized, scope) as BuildKeyObject<T, S>;\n return {\n scope,\n translations: normalized as unknown as T,\n keys,\n scoped: options?.scoped ?? false,\n };\n}\n\n// =============================================================================\n// Internal Utilities\n// =============================================================================\n\n/**\n * Normalize an authored tree by replacing every bare-string leaf with\n * `{ en: value }`. The output contains only `TranslationValue` leaves and\n * nested records — the canonical shape consumed by the generator/validator.\n */\nfunction normalizeTree(node: AuthoredTranslationNode): TranslationNode {\n if (typeof node === 'string') {\n return brand({ en: node });\n }\n if (isTranslationValue(node)) {\n return node;\n }\n const result: Record<string, TranslationNode> = {};\n for (const [key, value] of Object.entries(node)) {\n result[key] = normalizeTree(value as AuthoredTranslationNode);\n }\n return result;\n}\n\n/** Recursively builds the dot-path keys object from a normalized tree. */\nfunction buildKeys(obj: Record<string, unknown>, prefix: string): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n const fullKey = prefix ? `${prefix}.${key}` : key;\n if (isTranslationValue(value)) {\n result[key] = fullKey;\n } else if (typeof value === 'object' && value !== null) {\n result[key] = buildKeys(value as Record<string, unknown>, fullKey);\n }\n }\n return result;\n}\n\n/** Type guard: is this value a branded `TranslationValue` (created by `t()` or normalization)? */\nexport function isTranslationValue(value: unknown): value is TranslationValue {\n return value !== null && typeof value === 'object' && (value as Record<symbol, unknown>)[TRANSLATION_BRAND] === true;\n}\n\n// =============================================================================\n// Auto-derive a merged keys tree from module scopes (value-level)\n// =============================================================================\n\n/**\n * Build a merged keys tree from a list of translation modules by placing each\n * module's `keys` object at its scope path and deep-merging.\n *\n * This is the **runtime** value used by the directive (via the `I18N_KEYS`\n * token). It uses the same deep merge as the scanner-emitted `TK` literal\n * (`mergeKeys`) and the language trees, so all three agree on which keys exist.\n * Throws when a key is defined twice or is both a translation and a group.\n */\nexport function buildKeysTree(modules: readonly TranslationModule[]): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n for (const mod of modules) {\n mergeInto(tree, nestAtScope(mod.scope, mod.keys as Record<string, unknown>), '', true);\n }\n return tree;\n}\n\n// =============================================================================\n// Key conflicts (reported by the CLI before anything is generated)\n// =============================================================================\n\n/** A key defined by more than one module, or used both as a translation and as a group. */\nexport interface KeyConflict {\n /** Full dotted key, e.g. `'common.buttons.save'`. */\n key: string;\n kind: 'duplicate' | 'translation-and-group';\n /** Scopes of the modules involved (one entry per contributing module). */\n scopes: string[];\n}\n\n/**\n * Find every key collision across the registry, including the ones a deep\n * merge cannot see: a dotted key name (`'a.b'`) colliding with a nested group\n * (`a: { b }`) produces the same Transloco key.\n */\nexport function findKeyConflicts(modules: readonly TranslationModule[]): KeyConflict[] {\n const leaves: { key: string; scope: string }[] = [];\n const walk = (node: Record<string, unknown>, prefix: string, scope: string): void => {\n for (const [key, value] of Object.entries(node)) {\n const full = `${prefix}.${key}`;\n if (isTranslationValue(value)) leaves.push({ key: full, scope });\n else if (typeof value === 'object' && value !== null) walk(value as Record<string, unknown>, full, scope);\n }\n };\n for (const mod of modules) walk(mod.translations as Record<string, unknown>, mod.scope, mod.scope);\n return conflictsFromLeaves(leaves);\n}\n\n/**\n * Conflict detection over a flat list of full keys (one entry per definition).\n * Shared by {@link findKeyConflicts} (runtime registry) and the CLI scanner\n * (keys read statically from source).\n */\nexport function conflictsFromLeaves(leaves: Iterable<{ key: string; scope: string }>): KeyConflict[] {\n const byKey = new Map<string, string[]>();\n const groups = new Map<string, string[]>();\n const add = (map: Map<string, string[]>, key: string, scope: string) => map.set(key, [...(map.get(key) ?? []), scope]);\n for (const { key, scope } of leaves) {\n add(byKey, key, scope);\n const parts = key.split('.');\n for (let i = 1; i < parts.length; i++) add(groups, parts.slice(0, i).join('.'), scope);\n }\n\n const conflicts: KeyConflict[] = [];\n for (const [key, scopes] of byKey) {\n if (scopes.length > 1) conflicts.push({ key, kind: 'duplicate', scopes });\n const groupScopes = groups.get(key);\n if (groupScopes) conflicts.push({ key, kind: 'translation-and-group', scopes: [...new Set([...scopes, ...groupScopes])] });\n }\n return conflicts.sort((a, b) => a.key.localeCompare(b.key));\n}\n","/**\n * Build a per-language translation tree from the in-memory module registry.\n *\n * Shared by:\n * - the generator CLI — writes the tree as JSON to `<outputDir>/<lang>.json`\n * for translator-facing tooling (build artifacts, not a runtime dependency).\n * - the runtime `TranslocoRegistryLoader` — returns the tree synchronously to\n * Transloco, eliminating the HTTP fetch.\n *\n * Producing the tree from the registry guarantees the runtime sees the exact\n * shape the generator emits — there's no \"JSON drifted from TS\" failure mode.\n *\n * Locale handling is parameterized: every function takes the `defaultLang`\n * (source/fallback locale) explicitly rather than reading a hardcoded constant,\n * so the engine is reusable across consumers with different locale sets.\n */\n\nimport { AuthoredTranslationNode, isTranslationValue, TranslationModule, TranslationValue } from './define-translations';\nimport { mergeInto, nestAtScope } from './merge';\n\n/** A nested string-tree as Transloco / the JSON files consume it. */\nexport interface LanguageTree {\n [key: string]: string | LanguageTree;\n}\n\n/** Options for building string trees from the registry. */\nexport interface LanguageTreeOptions {\n /**\n * Emit translator comments as `<key>.comment` siblings. Default `true` (the\n * translator-facing JSON). The runtime registry loader passes `false` so\n * comments never reach Transloco's store.\n */\n comments?: boolean;\n}\n\n/**\n * Resolve a single `TranslationValue` for a given language.\n * Falls back to `defaultLang` for any locale that didn't supply a translation —\n * mirrors `useFallbackTranslation: true` in the runtime Transloco config.\n */\nexport function getTranslation(value: TranslationValue, lang: string, defaultLang: string): string {\n const byLang = value as Record<string, string | undefined>;\n if (lang === defaultLang) {\n return byLang[defaultLang] ?? value.en;\n }\n return byLang[lang] ?? byLang[defaultLang] ?? value.en;\n}\n\n/**\n * Walk a normalized translation subtree (all leaves are `TranslationValue`s) and\n * emit a string-only tree for the given language.\n *\n * If a leaf carries a `__comment` (set via `t(en, others, { comment })`) and\n * `options.comments` is not `false`, a sibling entry `<key>.comment` is added at\n * the same level for translators.\n */\nexport function extractLanguage(\n translations: Record<string, unknown>,\n lang: string,\n defaultLang: string,\n options: LanguageTreeOptions = {},\n): LanguageTree {\n const comments = options.comments ?? true;\n const result: LanguageTree = {};\n for (const [key, value] of Object.entries(translations)) {\n if (isTranslationValue(value)) {\n result[key] = getTranslation(value, lang, defaultLang);\n if (comments && value.__comment) {\n result[`${key}.comment`] = value.__comment;\n }\n } else if (typeof value === 'object' && value !== null) {\n result[key] = extractLanguage(value as Record<string, unknown>, lang, defaultLang, options);\n }\n }\n return result;\n}\n\n/**\n * Deep-merge a subtree into the target at a dot-delimited scope path, creating\n * intermediate objects as needed. Throws when a key would be defined twice or\n * when a translation and a group collide (see `mergeInto`).\n */\nexport function setAtScope(target: LanguageTree, scope: string, subtree: LanguageTree): void {\n mergeInto(target, nestAtScope(scope, subtree));\n}\n\ntype Registry = readonly TranslationModule<Record<string, AuthoredTranslationNode>>[];\n\n/**\n * Build the complete translation tree for a single language from the registry.\n * The returned tree matches the JSON file layout exactly — same keys, nesting,\n * and fallbacks — so a consumer cannot tell whether the data came from the\n * registry or from disk.\n */\nexport function buildLanguageTree(registry: Registry, lang: string, defaultLang: string, options?: LanguageTreeOptions): LanguageTree {\n const tree: LanguageTree = {};\n for (const mod of registry) {\n setAtScope(tree, mod.scope, extractLanguage(mod.translations, lang, defaultLang, options));\n }\n return tree;\n}\n\n/**\n * Build the eager (root) tree — only modules declared without `{ scoped: true }`.\n * Used by the generator when route-level scope providers are adopted.\n */\nexport function buildEagerTree(registry: Registry, lang: string, defaultLang: string, options?: LanguageTreeOptions): LanguageTree {\n return buildLanguageTree(\n registry.filter((mod) => !mod.scoped),\n lang,\n defaultLang,\n options,\n );\n}\n\n/**\n * Build the per-scope tree for a scope — returned unwrapped (no scope key\n * around it), matching the layout `provideTranslocoScope` expects to load from\n * `<scope-with-slashes>/<lang>.json`. Every scoped module declaring that scope\n * is merged in.\n *\n * `scope` may be given in dotted (`administration.users`) or slash form\n * (`administration/users` — what Transloco hands a loader); both match.\n *\n * Returns `null` if no scoped module declares the scope.\n */\nexport function buildScopedTree(\n registry: Registry,\n lang: string,\n defaultLang: string,\n scope: string,\n options?: LanguageTreeOptions,\n): LanguageTree | null {\n const wanted = normalizeScope(scope);\n const modules = registry.filter((mod) => mod.scoped && normalizeScope(mod.scope) === wanted);\n if (modules.length === 0) return null;\n const tree: LanguageTree = {};\n for (const mod of modules) mergeInto(tree, extractLanguage(mod.translations, lang, defaultLang, options), wanted);\n return tree;\n}\n\n/**\n * Convert a dot-separated scope to its filesystem path.\n * 'administration.users' → 'administration/users'\n */\nexport function scopeToFilesystemPath(scope: string): string {\n return scope.replace(/\\./g, '/');\n}\n\n/**\n * Canonical dotted form of a scope, accepting either separator.\n * 'administration/users' → 'administration.users'\n */\nexport function normalizeScope(scope: string): string {\n return scope.replace(/\\//g, '.');\n}\n","/*\n * @hakistack/i18n/engine\n *\n * The Angular-free authoring + tree-building engine. This entry point has NO\n * Angular dependency, so it loads in a plain Node context — which is what lets\n * the codegen CLI execute your `*.i18n.ts` modules via a TS loader.\n *\n * Author your translation modules against THIS entry point:\n *\n * ```ts\n * import { defineTranslations, t } from '@hakistack/i18n/engine';\n * ```\n *\n * Runtime APIs (`provideI18n`, `translateSignal`, the directive base) live on\n * the main `@hakistack/i18n` entry point.\n */\n\nexport {\n buildKeysTree,\n defineTranslations,\n findKeyConflicts,\n isTranslationValue,\n SOURCE_LANG,\n t,\n TRANSLATION_BRAND,\n} from './define-translations';\nexport type {\n AuthoredTranslationNode,\n I18nLocales,\n KeyConflict,\n Language,\n LocaleId,\n OtherLocales,\n SourceLang,\n TranslationModule,\n TranslationValue,\n} from './define-translations';\n\nexport {\n buildEagerTree,\n buildLanguageTree,\n buildScopedTree,\n extractLanguage,\n getTranslation,\n normalizeScope,\n scopeToFilesystemPath,\n setAtScope,\n} from './build-tree';\nexport type { LanguageTree, LanguageTreeOptions } from './build-tree';\n\nexport { mergeKeys } from './merge';\nexport type { I18nKey, KeyParams, ParamsOf } from './key-types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AAIH,SAAS,MAAM,CAAC,KAAc,EAAA;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;AACpD;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