ngwr 9.1.0 → 10.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.
Files changed (106) hide show
  1. package/README.md +14 -0
  2. package/badge/styles/_index.scss +16 -6
  3. package/badge/styles/_tag.scss +10 -1
  4. package/button/styles/_index.scss +48 -1
  5. package/dialog/styles/_index.scss +65 -0
  6. package/drawer/styles/_index.scss +61 -1
  7. package/fesm2022/ngwr-action-sheet.mjs +1 -1
  8. package/fesm2022/ngwr-action-sheet.mjs.map +1 -1
  9. package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
  10. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  11. package/fesm2022/ngwr-card.mjs +2 -2
  12. package/fesm2022/ngwr-card.mjs.map +1 -1
  13. package/fesm2022/ngwr-cascader.mjs +6 -5
  14. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  15. package/fesm2022/ngwr-color-picker.mjs +6 -5
  16. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  17. package/fesm2022/ngwr-context-menu.mjs +7 -7
  18. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  19. package/fesm2022/ngwr-date-picker.mjs +14 -9
  20. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  21. package/fesm2022/ngwr-density.mjs +10 -2
  22. package/fesm2022/ngwr-density.mjs.map +1 -1
  23. package/fesm2022/ngwr-dialog.mjs +10 -1
  24. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  25. package/fesm2022/ngwr-drag-drop.mjs +2 -2
  26. package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
  27. package/fesm2022/ngwr-drawer.mjs +37 -16
  28. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  29. package/fesm2022/ngwr-dropdown.mjs +4 -3
  30. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  31. package/fesm2022/ngwr-i18n-en.mjs +16 -0
  32. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  33. package/fesm2022/ngwr-i18n-ru.mjs +17 -0
  34. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  35. package/fesm2022/ngwr-i18n.mjs +74 -1
  36. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  37. package/fesm2022/ngwr-icon.mjs +74 -35
  38. package/fesm2022/ngwr-icon.mjs.map +1 -1
  39. package/fesm2022/ngwr-lightbox.mjs +2 -2
  40. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  41. package/fesm2022/ngwr-list.mjs +2 -2
  42. package/fesm2022/ngwr-list.mjs.map +1 -1
  43. package/fesm2022/ngwr-mention.mjs +166 -10
  44. package/fesm2022/ngwr-mention.mjs.map +1 -1
  45. package/fesm2022/ngwr-overlay.mjs +173 -3
  46. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  47. package/fesm2022/ngwr-pagination.mjs +17 -4
  48. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  49. package/fesm2022/ngwr-popconfirm.mjs +4 -3
  50. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  51. package/fesm2022/ngwr-popover.mjs +10 -3
  52. package/fesm2022/ngwr-popover.mjs.map +1 -1
  53. package/fesm2022/ngwr-select.mjs +12 -5
  54. package/fesm2022/ngwr-select.mjs.map +1 -1
  55. package/fesm2022/ngwr-table.mjs +1 -1
  56. package/fesm2022/ngwr-table.mjs.map +1 -1
  57. package/fesm2022/ngwr-theme.mjs +13 -3
  58. package/fesm2022/ngwr-theme.mjs.map +1 -1
  59. package/fesm2022/ngwr-tree.mjs +4 -3
  60. package/fesm2022/ngwr-tree.mjs.map +1 -1
  61. package/fesm2022/ngwr-version.mjs +1 -1
  62. package/fesm2022/ngwr-version.mjs.map +1 -1
  63. package/fesm2022/ngwr-waves.mjs +25 -3
  64. package/fesm2022/ngwr-waves.mjs.map +1 -1
  65. package/i18n/en.json +165 -0
  66. package/i18n/ru.json +165 -0
  67. package/icon/styles/_index.scss +10 -1
  68. package/input/styles/_index.scss +16 -0
  69. package/input-number/styles/_index.scss +8 -1
  70. package/keyboard/styles/_index.scss +10 -3
  71. package/llms-full.txt +3 -3
  72. package/mention/styles/_index.scss +23 -0
  73. package/package.json +3 -1
  74. package/pagination/styles/_index.scss +12 -0
  75. package/popover/styles/_index.scss +129 -45
  76. package/schematics/ng-add/index.js +18 -4
  77. package/schematics/package.json +3 -0
  78. package/schematics/use/symbol-map.json +2 -0
  79. package/select/styles/_index.scss +13 -0
  80. package/splitter/styles/_index.scss +7 -1
  81. package/table/styles/_index.scss +28 -10
  82. package/theme/styles/_box-model.scss +29 -0
  83. package/theme/styles/_colors.scss +74 -15
  84. package/theme/styles/_dark.scss +52 -6
  85. package/theme/styles/_index.scss +1 -0
  86. package/types/ngwr-cascader.d.ts +1 -0
  87. package/types/ngwr-color-picker.d.ts +1 -0
  88. package/types/ngwr-context-menu.d.ts +1 -0
  89. package/types/ngwr-date-picker.d.ts +5 -3
  90. package/types/ngwr-density.d.ts +8 -1
  91. package/types/ngwr-dialog.d.ts +9 -0
  92. package/types/ngwr-drawer.d.ts +20 -4
  93. package/types/ngwr-dropdown.d.ts +1 -0
  94. package/types/ngwr-i18n.d.ts +65 -2
  95. package/types/ngwr-icon.d.ts +11 -19
  96. package/types/ngwr-mention.d.ts +45 -1
  97. package/types/ngwr-overlay.d.ts +80 -2
  98. package/types/ngwr-pagination.d.ts +14 -1
  99. package/types/ngwr-popconfirm.d.ts +1 -0
  100. package/types/ngwr-popover.d.ts +1 -0
  101. package/types/ngwr-select.d.ts +6 -0
  102. package/types/ngwr-theme.d.ts +8 -1
  103. package/types/ngwr-tree.d.ts +1 -0
  104. package/types/ngwr-version.d.ts +1 -1
  105. package/types/ngwr-waves.d.ts +10 -0
  106. package/waves/styles/_index.scss +21 -0
@@ -4,6 +4,32 @@ import { firstValueFrom, of, catchError } from 'rxjs';
4
4
  import { WrStorage } from 'ngwr/storage';
5
5
  import { HttpClient } from '@angular/common/http';
6
6
 
7
+ /**
8
+ * @license
9
+ *
10
+ * Use of this source code is governed by an MIT-style license that can be
11
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
12
+ */
13
+ /**
14
+ * Catalogs consulted *underneath* whatever the loader returned — the place for
15
+ * ngwr's own built-in strings.
16
+ *
17
+ * A loader **replaces** the catalog for a locale rather than extending it, so an
18
+ * app whose JSON holds only its own keys used to lose every built-in label to
19
+ * its hardcoded English fallback, silently. Registering `wrRu` / `wrEn` here
20
+ * puts them back without the app having to merge anything itself.
21
+ *
22
+ * `multi`, so several features can each contribute; later contributions win on
23
+ * a key collision, and anything the loader returned still wins over all of them.
24
+ *
25
+ * It has to be handed in by the consumer rather than wired up inside
26
+ * `provideWrI18n()`: the catalogs are their own entry points (`ngwr/i18n/ru`)
27
+ * and they already import from `ngwr/i18n`, so importing them back here is a
28
+ * circular entry-point dependency that ng-packagr rejects outright. Passing
29
+ * them in also keeps the locales you don't ship out of your bundle.
30
+ */
31
+ const WR_I18N_BASE_CATALOGS = new InjectionToken('WR_I18N_BASE_CATALOGS');
32
+
7
33
  /**
8
34
  * @license
9
35
  *
@@ -104,6 +130,12 @@ class WrI18n {
104
130
  config = inject(WR_I18N_CONFIG);
105
131
  loader = inject(WR_I18N_LOADER);
106
132
  storage = inject(WrStorage);
133
+ /**
134
+ * Catalogs registered via `provideWrI18nBaseCatalogs()` — the floor under the
135
+ * loader's own catalogs, so ngwr's built-in strings survive an app that only
136
+ * ships its own keys. @internal
137
+ */
138
+ baseCatalogs = inject(WR_I18N_BASE_CATALOGS, { optional: true }) ?? [];
107
139
  /** Per-(locale,scope) catalogs, populated by `loadCatalog`. @internal */
108
140
  catalogs = new Map();
109
141
  /** Bumped after each catalog write so reactive translates recompute. @internal */
@@ -162,6 +194,10 @@ class WrI18n {
162
194
  const lc = this._locale();
163
195
  let hit = scope ? walk(this.catalogs.get(cacheKey(lc, scope)) ?? null, key) : null;
164
196
  hit ??= walk(this.catalogs.get(cacheKey(lc, null)) ?? null, key);
197
+ // Base catalogs are the floor: consulted only once the loader's own catalogs
198
+ // have missed, so an app's keys always win, but ngwr's built-in strings are
199
+ // still there when the app's catalog doesn't carry them.
200
+ hit ??= this.walkBase(lc, key);
165
201
  if (hit === null) {
166
202
  // Fire a background load so a future read can resolve it.
167
203
  void this.loadCatalog(lc, scope ?? null);
@@ -174,6 +210,18 @@ class WrI18n {
174
210
  return computed(() => this.t(key, params, scope));
175
211
  }
176
212
  // Internals
213
+ /**
214
+ * Look a key up in the registered base catalogs, later contributions first so
215
+ * a feature can shadow an earlier one.
216
+ */
217
+ walkBase(locale, key) {
218
+ for (let i = this.baseCatalogs.length - 1; i >= 0; i--) {
219
+ const hit = walk(this.baseCatalogs[i][locale] ?? null, key);
220
+ if (hit !== null)
221
+ return hit;
222
+ }
223
+ return null;
224
+ }
177
225
  initialLocale() {
178
226
  if (this.config.storageKey) {
179
227
  const saved = this.storage.get(this.config.storageKey);
@@ -371,6 +419,31 @@ function provideWrI18n(options = {}) {
371
419
  function provideWrI18nStaticLoader(catalogs, scopes) {
372
420
  return { provide: WR_I18N_LOADER, useValue: new WrI18nStaticLoader(catalogs, scopes) };
373
421
  }
422
+ /**
423
+ * Register catalogs consulted *underneath* the loader — this is how ngwr's own
424
+ * built-in strings survive when you supply your own catalogs.
425
+ *
426
+ * A loader replaces the catalog for a locale instead of extending it, so a JSON
427
+ * file holding only your keys leaves every built-in label on its hardcoded
428
+ * English fallback, with nothing logged. One line fixes it, on either loader:
429
+ *
430
+ * @example
431
+ * ```ts
432
+ * import { wrRu } from 'ngwr/i18n/ru';
433
+ *
434
+ * providers: [
435
+ * provideWrI18n({ defaultLocale: 'ru', availableLocales: ['ru'] }),
436
+ * provideWrI18nBaseCatalogs({ ru: wrRu }),
437
+ * provideWrI18nHttpLoader({ path: '/assets/i18n/{locale}.json' }),
438
+ * ]
439
+ * ```
440
+ *
441
+ * Pass only the locales you ship — the ones you leave out stay out of the
442
+ * bundle. Your own keys always win; this is a floor, not an override.
443
+ */
444
+ function provideWrI18nBaseCatalogs(catalogs) {
445
+ return { provide: WR_I18N_BASE_CATALOGS, useValue: catalogs, multi: true };
446
+ }
374
447
  /** Provide an HTTP loader — catalogs fetched from URLs. Requires `provideHttpClient`. */
375
448
  function provideWrI18nHttpLoader(config) {
376
449
  return { provide: WR_I18N_LOADER, useFactory: () => new WrI18nHttpLoader(config) };
@@ -474,5 +547,5 @@ function useI18nFormatter(key, fallback) {
474
547
  * Generated bundle index. Do not edit.
475
548
  */
476
549
 
477
- export { DEFAULT_WR_I18N_CONFIG, WR_I18N_CONFIG, WR_I18N_LOADER, WrI18n, WrI18nHttpLoader, WrI18nStaticLoader, WrTDirective, WrTPipe, provideWrI18n, provideWrI18nHttpLoader, provideWrI18nStaticLoader, readI18nText, useI18nFormatter, useI18nText };
550
+ export { DEFAULT_WR_I18N_CONFIG, WR_I18N_BASE_CATALOGS, WR_I18N_CONFIG, WR_I18N_LOADER, WrI18n, WrI18nHttpLoader, WrI18nStaticLoader, WrTDirective, WrTPipe, provideWrI18n, provideWrI18nBaseCatalogs, provideWrI18nHttpLoader, provideWrI18nStaticLoader, readI18nText, useI18nFormatter, useI18nText };
478
551
  //# sourceMappingURL=ngwr-i18n.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-i18n.mjs","sources":["../../../projects/lib/i18n/i18n-config.ts","../../../projects/lib/i18n/i18n-loader.ts","../../../projects/lib/i18n/i18n.ts","../../../projects/lib/i18n/t.pipe.ts","../../../projects/lib/i18n/t.directive.ts","../../../projects/lib/i18n/loaders/static-loader.ts","../../../projects/lib/i18n/loaders/http-loader.ts","../../../projects/lib/i18n/provide-wr-i18n.ts","../../../projects/lib/i18n/util.ts","../../../projects/lib/i18n/ngwr-i18n.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\n/** Translation catalog — flat or nested record of strings. */\nexport interface WrI18nCatalog {\n readonly [key: string]: string | WrI18nCatalog;\n}\n\n/** Parameters passed to interpolation — coerced to strings via `String(v)`. */\nexport type WrI18nParams = Readonly<Record<string, unknown>>;\n\n/** Hook called once on every key that resolves to nothing. */\nexport type WrI18nMissingHandler = (key: string, locale: string) => string;\n\n/** User-facing config for {@link provideWrI18n}. */\nexport interface WrI18nConfig {\n /** BCP-47 tag used until the user calls `setLocale`. @default 'en' */\n readonly defaultLocale?: string;\n\n /** Whitelisted locales — `setLocale` ignores anything outside this list. */\n readonly availableLocales?: readonly string[];\n\n /**\n * Storage key for persisting the active locale (via `WrStorage`).\n * Set to `null` to disable persistence. @default 'wr:i18n:locale'\n */\n readonly storageKey?: string | null;\n\n /** Called when a key is missing. Default returns the key itself. */\n readonly missingHandler?: WrI18nMissingHandler;\n}\n\n/** Resolved config — every field non-optional. @internal */\nexport interface WrI18nConfigResolved {\n readonly defaultLocale: string;\n readonly availableLocales: readonly string[];\n readonly storageKey: string | null;\n readonly missingHandler: WrI18nMissingHandler;\n}\n\nexport const DEFAULT_WR_I18N_CONFIG: WrI18nConfigResolved = {\n defaultLocale: 'en',\n availableLocales: ['en'],\n storageKey: 'wr:i18n:locale',\n missingHandler: key => key,\n};\n\nexport const WR_I18N_CONFIG = new InjectionToken<WrI18nConfigResolved>('WR_I18N_CONFIG', {\n factory: () => DEFAULT_WR_I18N_CONFIG,\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { type Observable } from 'rxjs';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/**\n * Loads a catalog for a `(locale, scope)` pair. `scope` is `null` for the\n * root catalog. Implementations may return the catalog synchronously\n * (via `of(...)`) for static catalogs or asynchronously (via HTTP) for\n * lazy fetches.\n */\nexport interface WrI18nLoader {\n load(locale: string, scope: string | null): Observable<WrI18nCatalog>;\n}\n\nexport const WR_I18N_LOADER = new InjectionToken<WrI18nLoader>('WR_I18N_LOADER');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Service, type Signal, computed, effect, inject, signal } from '@angular/core';\n\nimport { type Observable, firstValueFrom } from 'rxjs';\n\nimport { WrStorage } from 'ngwr/storage';\n\nimport { WR_I18N_CONFIG, type WrI18nCatalog, type WrI18nParams } from './i18n-config';\nimport { WR_I18N_LOADER } from './i18n-loader';\n\n/** Cache key shape: `<locale>::<scope|''>`. @internal */\nfunction cacheKey(locale: string, scope: string | null): string {\n return `${locale}::${scope ?? ''}`;\n}\n\n/** Walk a dotted path through a catalog tree. Returns string | null. @internal */\nfunction walk(cat: WrI18nCatalog | null, key: string): string | null {\n if (!cat) return null;\n let node: string | WrI18nCatalog | undefined = cat;\n for (const part of key.split('.')) {\n if (node === undefined || typeof node === 'string') return null;\n node = node[part];\n }\n return typeof node === 'string' ? node : null;\n}\n\n/**\n * `{{name}}` interpolation. Missing params resolve to `''`. Exported so\n * helpers in `util.ts` can interpolate the fallback template when no\n * `WrI18n` provider is wired up.\n *\n * @internal\n */\nexport function wrInterpolate(template: string, params: WrI18nParams | undefined): string {\n if (!params) return template;\n return template.replace(/\\{\\{\\s*([\\w.-]+)\\s*\\}\\}/g, (_match, name: string) => {\n const v = params[name];\n if (v === undefined || v === null) return '';\n if (typeof v === 'string') return v;\n if (typeof v === 'number' || typeof v === 'boolean') return String(v);\n try {\n return JSON.stringify(v);\n } catch {\n return '';\n }\n });\n}\n\n/**\n * Reactive i18n service. Holds:\n *\n * - the active locale as a `Signal<string>`\n * - per-`(locale, scope)` catalogs in a `Map` (loaded once, then cached)\n * - a per-locale signal counter so every `translate()` reading the signal\n * re-evaluates the moment a new catalog finishes loading\n *\n * Translations are looked up scope-first, then root. `t('forms.save', { ... })`\n * with `scope: 'forms'` will try the scoped catalog before falling back to\n * `forms.save` in the root catalog — useful for per-feature overrides.\n *\n * @example\n * ```ts\n * const i18n = inject(WrI18n);\n * i18n.use('ru'); // switch locale\n * i18n.t('cart.checkout'); // → 'Оформить заказ'\n * i18n.t('greeting', { name: 'Ada' }); // → 'Hello, Ada!'\n *\n * effect(() => console.log(i18n.translate('hi')())); // re-runs on locale change\n * ```\n *\n * @see https://ngwr.dev/reference/services/i18n\n */\n@Service()\nexport class WrI18n {\n private readonly config = inject(WR_I18N_CONFIG);\n private readonly loader = inject(WR_I18N_LOADER);\n private readonly storage = inject(WrStorage);\n\n /** Per-(locale,scope) catalogs, populated by `loadCatalog`. @internal */\n private readonly catalogs = new Map<string, WrI18nCatalog>();\n\n /** Bumped after each catalog write so reactive translates recompute. @internal */\n private readonly revision = signal(0);\n\n /** In-flight load promises — dedupes parallel `t()` callers. @internal */\n private readonly inflight = new Map<string, Promise<WrI18nCatalog>>();\n\n /** Registered scopes — auto-loaded whenever the locale changes. @internal */\n private readonly scopes = new Set<string>();\n\n /** Active locale. Writes go through `use()` so storage stays in sync. */\n private readonly _locale = signal<string>(this.initialLocale());\n readonly locale: Signal<string> = this._locale.asReadonly();\n\n constructor() {\n // Eagerly load the root catalog + every registered scope for the\n // current locale. Subsequent locale changes refire the same effect.\n effect(() => {\n const lc = this._locale();\n void this.loadCatalog(lc, null);\n for (const sc of this.scopes) void this.loadCatalog(lc, sc);\n });\n }\n\n // Locale\n\n /** Switch active locale. Ignored when not whitelisted. */\n use(locale: string): void {\n if (!this.config.availableLocales.includes(locale)) return;\n this._locale.set(locale);\n if (this.config.storageKey) this.storage.set(this.config.storageKey, locale);\n }\n\n /** Available locales — pass-through from config. */\n available(): readonly string[] {\n return this.config.availableLocales;\n }\n\n // Scopes\n\n /**\n * Register a scope so its catalog loads alongside the root one. Idempotent.\n * Returns a promise resolving once the current locale's scope catalog is in\n * the cache — handy for feature `canActivate` guards.\n */\n registerScope(scope: string): Promise<WrI18nCatalog> {\n this.scopes.add(scope);\n return this.loadCatalog(this._locale(), scope);\n }\n\n // Translate\n\n /**\n * Eager translate — returns the current value or the missing-handler\n * fallback. Does NOT auto-load missing catalogs; combine with the\n * reactive `translate(...)` if you want load-on-demand.\n */\n t(key: string, params?: WrI18nParams, scope?: string): string {\n // Read revision so callers inside computed/effect re-run on updates.\n this.revision();\n const lc = this._locale();\n\n let hit = scope ? walk(this.catalogs.get(cacheKey(lc, scope)) ?? null, key) : null;\n hit ??= walk(this.catalogs.get(cacheKey(lc, null)) ?? null, key);\n\n if (hit === null) {\n // Fire a background load so a future read can resolve it.\n void this.loadCatalog(lc, scope ?? null);\n return this.config.missingHandler(key, lc);\n }\n return wrInterpolate(hit, params);\n }\n\n /** Reactive translate — re-evaluates on locale or catalog updates. */\n translate(key: string, params?: WrI18nParams, scope?: string): Signal<string> {\n return computed(() => this.t(key, params, scope));\n }\n\n // Internals\n\n private initialLocale(): string {\n if (this.config.storageKey) {\n const saved = this.storage.get<string>(this.config.storageKey);\n if (saved && this.config.availableLocales.includes(saved)) return saved;\n }\n return this.config.defaultLocale;\n }\n\n private loadCatalog(locale: string, scope: string | null): Promise<WrI18nCatalog> {\n const ck = cacheKey(locale, scope);\n const cached = this.catalogs.get(ck);\n if (cached) return Promise.resolve(cached);\n\n const pending = this.inflight.get(ck);\n if (pending) return pending;\n\n const stream: Observable<WrI18nCatalog> = this.loader.load(locale, scope);\n const promise = firstValueFrom(stream)\n .then(catalog => {\n this.catalogs.set(ck, catalog);\n this.revision.update(v => v + 1);\n return catalog;\n })\n .catch((err: unknown) => {\n // eslint-disable-next-line no-console -- intentional diagnostic for missing catalog\n console.warn(`[ngwr/i18n] failed to load (${locale}, ${scope ?? 'root'})`, err);\n const empty: WrI18nCatalog = {};\n this.catalogs.set(ck, empty);\n return empty;\n })\n .finally(() => {\n this.inflight.delete(ck);\n });\n\n this.inflight.set(ck, promise);\n return promise;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Pipe, type PipeTransform, inject } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams } from './i18n-config';\n\n/**\n * Translate a key. Impure — re-evaluates on every CD so locale switches\n * and catalog loads propagate without a manual refresh.\n *\n * @example\n * ```html\n * <h1>{{ 'home.title' | wrT }}</h1>\n * <p>{{ 'greeting' | wrT: { name: user().name } }}</p>\n * <button>{{ 'forms.save' | wrT: null : 'checkout' }}</button>\n * ```\n */\n// eslint-disable-next-line @angular-eslint/no-pipe-impure -- intentional: locale + catalog updates must propagate even when args are stable\n@Pipe({ name: 'wrT', pure: false })\nexport class WrTPipe implements PipeTransform {\n private readonly i18n = inject(WrI18n);\n\n transform(key: string, params?: WrI18nParams | null, scope?: string): string {\n return this.i18n.t(key, params ?? undefined, scope);\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, computed, effect, inject, input } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams } from './i18n-config';\n\n/**\n * Attribute directive that sets `textContent` of its host to the translation\n * of the bound key. Reactive — re-renders on locale + catalog changes.\n *\n * @example\n * ```html\n * <span [wrT]=\"'home.title'\"></span>\n * <span [wrT]=\"'greeting'\" [wrTParams]=\"{ name: user().name }\"></span>\n * <span [wrT]=\"'forms.save'\" wrTScope=\"checkout\"></span>\n * ```\n */\n@Directive({\n selector: '[wrT]',\n})\nexport class WrTDirective {\n /** Translation key. Required. */\n readonly wrT = input.required<string>();\n\n /** Interpolation params for `{{name}}` tokens. */\n readonly wrTParams = input<WrI18nParams | null>(null);\n\n /** Optional scope — scoped lookup first, then root fallback. */\n readonly wrTScope = input<string | null>(null);\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly i18n = inject(WrI18n);\n\n private readonly text = computed(() =>\n this.i18n.t(this.wrT(), this.wrTParams() ?? undefined, this.wrTScope() ?? undefined)\n );\n\n constructor() {\n effect(() => {\n this.host.nativeElement.textContent = this.text();\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Observable, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Root catalogs keyed by locale: `{ en: catalog, ru: catalog, … }`. */\nexport type WrI18nStaticCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/** Per-scope catalogs: `{ checkout: { en: catalog, ru: catalog }, … }`. */\nexport type WrI18nStaticScopedCatalogs = Readonly<Record<string, WrI18nStaticCatalogs>>;\n\n/**\n * Loader for catalogs already in memory (imported from JSON or generated).\n *\n * - Pass `catalogs` for the root catalog of every locale.\n * - Pass `scopes` if you ship per-feature catalogs the loader should serve\n * to `WrI18n.registerScope(name)` calls.\n *\n * Missing locale or scope resolves to `{}` — the missing-key handler then\n * decides what to render.\n */\nexport class WrI18nStaticLoader implements WrI18nLoader {\n constructor(\n private readonly catalogs: WrI18nStaticCatalogs,\n private readonly scopes: WrI18nStaticScopedCatalogs = {}\n ) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n if (scope === null) return of(this.catalogs[locale] ?? {});\n return of(this.scopes[scope]?.[locale] ?? {});\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { HttpClient } from '@angular/common/http';\nimport { inject } from '@angular/core';\n\nimport { type Observable, catchError, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Configuration for {@link WrI18nHttpLoader}. */\nexport interface WrI18nHttpLoaderConfig {\n /**\n * URL template. Tokens:\n * - `{locale}` — required, BCP-47 tag (e.g. `en`).\n * - `{scope}` — optional, scope name. Use the `rootPath` if you need a\n * different path entirely for the root catalog.\n *\n * @example\n * ```ts\n * { path: '/assets/i18n/{locale}.json' } // root only\n * { path: '/assets/i18n/{scope}/{locale}.json',\n * rootPath: '/assets/i18n/{locale}.json' } // root + scopes\n * ```\n */\n readonly path: string;\n /** Path template for the root catalog. Defaults to `path`. */\n readonly rootPath?: string;\n}\n\n/**\n * Loader that fetches catalogs via `HttpClient`. Failures resolve to `{}`\n * (logged once at the service layer) so a missing file never throws into\n * user code.\n */\nexport class WrI18nHttpLoader implements WrI18nLoader {\n private readonly http = inject(HttpClient);\n\n constructor(private readonly config: WrI18nHttpLoaderConfig) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n const template = scope === null ? (this.config.rootPath ?? this.config.path) : this.config.path;\n const url = template.replace('{locale}', locale).replace('{scope}', scope ?? '');\n return this.http.get<WrI18nCatalog>(url).pipe(catchError(() => of<WrI18nCatalog>({})));\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type EnvironmentProviders, type Provider, makeEnvironmentProviders } from '@angular/core';\n\nimport { DEFAULT_WR_I18N_CONFIG, WR_I18N_CONFIG, type WrI18nConfig, type WrI18nConfigResolved } from './i18n-config';\nimport { WR_I18N_LOADER, type WrI18nLoader } from './i18n-loader';\nimport { WrI18nHttpLoader, type WrI18nHttpLoaderConfig } from './loaders/http-loader';\nimport {\n WrI18nStaticLoader,\n type WrI18nStaticCatalogs,\n type WrI18nStaticScopedCatalogs,\n} from './loaders/static-loader';\n\n/**\n * Configure {@link WrI18n}. Either pass a `loader` directly, or use the\n * `provideWrI18nHttpLoader` / `provideWrI18nStaticLoader` helpers in the\n * same providers array.\n */\nexport interface ProvideWrI18nOptions extends WrI18nConfig {\n readonly loader?: WrI18nLoader;\n}\n\nexport function provideWrI18n(options: ProvideWrI18nOptions = {}): EnvironmentProviders {\n const { loader, ...config } = options;\n const merged: WrI18nConfigResolved = { ...DEFAULT_WR_I18N_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_I18N_CONFIG, useValue: merged }];\n if (loader) providers.push({ provide: WR_I18N_LOADER, useValue: loader });\n\n return makeEnvironmentProviders(providers);\n}\n\n/**\n * Provide a static loader — catalogs already in memory.\n *\n * @param catalogs Root catalogs keyed by locale.\n * @param scopes Optional per-scope catalogs served to `registerScope(name)`.\n */\nexport function provideWrI18nStaticLoader(\n catalogs: WrI18nStaticCatalogs,\n scopes?: WrI18nStaticScopedCatalogs\n): Provider {\n return { provide: WR_I18N_LOADER, useValue: new WrI18nStaticLoader(catalogs, scopes) };\n}\n\n/** Provide an HTTP loader — catalogs fetched from URLs. Requires `provideHttpClient`. */\nexport function provideWrI18nHttpLoader(config: WrI18nHttpLoaderConfig): Provider {\n return { provide: WR_I18N_LOADER, useFactory: () => new WrI18nHttpLoader(config) };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Signal, computed, inject, signal } from '@angular/core';\n\nimport { WrI18n, wrInterpolate } from './i18n';\nimport type { WrI18nParams } from './i18n-config';\n\n/**\n * Helper for component default text. Returns a reactive string that:\n *\n * 1. Prefers the consumer's override (an `input<string | null>()` value).\n * 2. Falls back to the i18n catalog under `key` — re-renders on locale\n * change so a switcher updates the DOM live.\n * 3. Falls back to `fallback` when no `WrI18n` is provided OR the catalog\n * is missing the key.\n *\n * Components don't need a hard dependency on `provideWrI18n` — without it,\n * the fallback is returned and everything still works.\n *\n * @example\n * ```ts\n * readonly emptyText = input<string | null>(null);\n * protected readonly empty = useI18nText(this.emptyText, 'table.empty', 'No data');\n *\n * // In template: <div>{{ empty() }}</div>\n * ```\n */\nexport function useI18nText(binding: Signal<string | null | undefined>, key: string, fallback: string): Signal<string> {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return computed(() => {\n const v = binding();\n return v ?? fallback;\n });\n }\n\n return computed(() => {\n const v = binding();\n if (v !== null && v !== undefined && v !== '') return v;\n const translated = i18n.t(key);\n // Default missing handler returns the key itself — treat that as \"missing\"\n // and use our explicit fallback.\n return translated === key ? fallback : translated;\n });\n}\n\n/**\n * Like {@link useI18nText} but takes a literal value (not a Signal) — for\n * computed `aria-label`s that already mix a static piece with a dynamic\n * value. Returns the resolved string once, at injection time.\n */\nexport function readI18nText(key: string, fallback: string): string {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) return fallback;\n const v = i18n.t(key);\n return v === key ? fallback : v;\n}\n\n/** Tiny shim — useful when the caller doesn't have an `input` to forward. */\nexport function nullSignal(): Signal<null> {\n return signal(null).asReadonly();\n}\n\n/**\n * Build a per-call formatter for parametrized labels (e.g. ARIA labels\n * that interpolate a per-row value: `\"Remove {{label}}\"`). Returns a\n * function the template calls with the params for the current item.\n *\n * The returned function:\n * - Re-resolves the i18n catalog on every call (live locale switches just\n * work — re-rendered templates pick up new strings).\n * - Falls back to the literal `fallback` template with the same\n * `{{name}}` syntax when no `WrI18n` provider is present, or when the\n * key is missing.\n *\n * Use this for labels that vary per row. For static labels, prefer\n * {@link useI18nText} or {@link readI18nText}.\n *\n * @example\n * ```ts\n * protected readonly removeChipLabel = useI18nFormatter('select.removeItem', 'Remove {{label}}');\n *\n * // In template:\n * // [attr.aria-label]=\"removeChipLabel({ label: chip.label })\"\n * ```\n */\nexport function useI18nFormatter(key: string, fallback: string): (params?: WrI18nParams) => string {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return (params?: WrI18nParams) => wrInterpolate(fallback, params);\n }\n return (params?: WrI18nParams) => {\n const v = i18n.t(key, params);\n return v === key ? wrInterpolate(fallback, params) : v;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAyCI,MAAM,sBAAsB,GAAyB;AAC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AC/C,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,MAAqB,KAAK,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC;IACnE;IACA,OAAO,CAAC,MAAqB,KAAI;QAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC;AAC7B,QAAA,OAAO,CAAC,KAAK,GAAG,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC;AACxD,IAAA,CAAC;AACH;;ACpGA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngwr-i18n.mjs","sources":["../../../projects/lib/i18n/i18n-base-catalogs.ts","../../../projects/lib/i18n/i18n-config.ts","../../../projects/lib/i18n/i18n-loader.ts","../../../projects/lib/i18n/i18n.ts","../../../projects/lib/i18n/t.pipe.ts","../../../projects/lib/i18n/t.directive.ts","../../../projects/lib/i18n/loaders/static-loader.ts","../../../projects/lib/i18n/loaders/http-loader.ts","../../../projects/lib/i18n/provide-wr-i18n.ts","../../../projects/lib/i18n/util.ts","../../../projects/lib/i18n/ngwr-i18n.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/** Base catalogs keyed by locale, contributed by {@link provideWrI18nBaseCatalogs}. */\nexport type WrI18nBaseCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/**\n * Catalogs consulted *underneath* whatever the loader returned — the place for\n * ngwr's own built-in strings.\n *\n * A loader **replaces** the catalog for a locale rather than extending it, so an\n * app whose JSON holds only its own keys used to lose every built-in label to\n * its hardcoded English fallback, silently. Registering `wrRu` / `wrEn` here\n * puts them back without the app having to merge anything itself.\n *\n * `multi`, so several features can each contribute; later contributions win on\n * a key collision, and anything the loader returned still wins over all of them.\n *\n * It has to be handed in by the consumer rather than wired up inside\n * `provideWrI18n()`: the catalogs are their own entry points (`ngwr/i18n/ru`)\n * and they already import from `ngwr/i18n`, so importing them back here is a\n * circular entry-point dependency that ng-packagr rejects outright. Passing\n * them in also keeps the locales you don't ship out of your bundle.\n */\nexport const WR_I18N_BASE_CATALOGS = new InjectionToken<readonly WrI18nBaseCatalogs[]>('WR_I18N_BASE_CATALOGS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\n/** Translation catalog — flat or nested record of strings. */\nexport interface WrI18nCatalog {\n readonly [key: string]: string | WrI18nCatalog;\n}\n\n/** Parameters passed to interpolation — coerced to strings via `String(v)`. */\nexport type WrI18nParams = Readonly<Record<string, unknown>>;\n\n/** Hook called once on every key that resolves to nothing. */\nexport type WrI18nMissingHandler = (key: string, locale: string) => string;\n\n/** User-facing config for {@link provideWrI18n}. */\nexport interface WrI18nConfig {\n /** BCP-47 tag used until the user calls `setLocale`. @default 'en' */\n readonly defaultLocale?: string;\n\n /** Whitelisted locales — `setLocale` ignores anything outside this list. */\n readonly availableLocales?: readonly string[];\n\n /**\n * Storage key for persisting the active locale (via `WrStorage`).\n * Set to `null` to disable persistence. @default 'wr:i18n:locale'\n */\n readonly storageKey?: string | null;\n\n /** Called when a key is missing. Default returns the key itself. */\n readonly missingHandler?: WrI18nMissingHandler;\n}\n\n/** Resolved config — every field non-optional. @internal */\nexport interface WrI18nConfigResolved {\n readonly defaultLocale: string;\n readonly availableLocales: readonly string[];\n readonly storageKey: string | null;\n readonly missingHandler: WrI18nMissingHandler;\n}\n\nexport const DEFAULT_WR_I18N_CONFIG: WrI18nConfigResolved = {\n defaultLocale: 'en',\n availableLocales: ['en'],\n storageKey: 'wr:i18n:locale',\n missingHandler: key => key,\n};\n\nexport const WR_I18N_CONFIG = new InjectionToken<WrI18nConfigResolved>('WR_I18N_CONFIG', {\n factory: () => DEFAULT_WR_I18N_CONFIG,\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport { type Observable } from 'rxjs';\n\nimport { type WrI18nCatalog } from './i18n-config';\n\n/**\n * Loads a catalog for a `(locale, scope)` pair. `scope` is `null` for the\n * root catalog. Implementations may return the catalog synchronously\n * (via `of(...)`) for static catalogs or asynchronously (via HTTP) for\n * lazy fetches.\n */\nexport interface WrI18nLoader {\n load(locale: string, scope: string | null): Observable<WrI18nCatalog>;\n}\n\nexport const WR_I18N_LOADER = new InjectionToken<WrI18nLoader>('WR_I18N_LOADER');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Service, type Signal, computed, effect, inject, signal } from '@angular/core';\n\nimport { type Observable, firstValueFrom } from 'rxjs';\n\nimport { WrStorage } from 'ngwr/storage';\n\nimport { WR_I18N_BASE_CATALOGS } from './i18n-base-catalogs';\nimport { WR_I18N_CONFIG, type WrI18nCatalog, type WrI18nParams } from './i18n-config';\nimport { WR_I18N_LOADER } from './i18n-loader';\n\n/** Cache key shape: `<locale>::<scope|''>`. @internal */\nfunction cacheKey(locale: string, scope: string | null): string {\n return `${locale}::${scope ?? ''}`;\n}\n\n/** Walk a dotted path through a catalog tree. Returns string | null. @internal */\nfunction walk(cat: WrI18nCatalog | null, key: string): string | null {\n if (!cat) return null;\n let node: string | WrI18nCatalog | undefined = cat;\n for (const part of key.split('.')) {\n if (node === undefined || typeof node === 'string') return null;\n node = node[part];\n }\n return typeof node === 'string' ? node : null;\n}\n\n/**\n * `{{name}}` interpolation. Missing params resolve to `''`. Exported so\n * helpers in `util.ts` can interpolate the fallback template when no\n * `WrI18n` provider is wired up.\n *\n * @internal\n */\nexport function wrInterpolate(template: string, params: WrI18nParams | undefined): string {\n if (!params) return template;\n return template.replace(/\\{\\{\\s*([\\w.-]+)\\s*\\}\\}/g, (_match, name: string) => {\n const v = params[name];\n if (v === undefined || v === null) return '';\n if (typeof v === 'string') return v;\n if (typeof v === 'number' || typeof v === 'boolean') return String(v);\n try {\n return JSON.stringify(v);\n } catch {\n return '';\n }\n });\n}\n\n/**\n * Reactive i18n service. Holds:\n *\n * - the active locale as a `Signal<string>`\n * - per-`(locale, scope)` catalogs in a `Map` (loaded once, then cached)\n * - a per-locale signal counter so every `translate()` reading the signal\n * re-evaluates the moment a new catalog finishes loading\n *\n * Translations are looked up scope-first, then root. `t('forms.save', { ... })`\n * with `scope: 'forms'` will try the scoped catalog before falling back to\n * `forms.save` in the root catalog — useful for per-feature overrides.\n *\n * @example\n * ```ts\n * const i18n = inject(WrI18n);\n * i18n.use('ru'); // switch locale\n * i18n.t('cart.checkout'); // → 'Оформить заказ'\n * i18n.t('greeting', { name: 'Ada' }); // → 'Hello, Ada!'\n *\n * effect(() => console.log(i18n.translate('hi')())); // re-runs on locale change\n * ```\n *\n * @see https://ngwr.dev/reference/services/i18n\n */\n@Service()\nexport class WrI18n {\n private readonly config = inject(WR_I18N_CONFIG);\n private readonly loader = inject(WR_I18N_LOADER);\n private readonly storage = inject(WrStorage);\n\n /**\n * Catalogs registered via `provideWrI18nBaseCatalogs()` — the floor under the\n * loader's own catalogs, so ngwr's built-in strings survive an app that only\n * ships its own keys. @internal\n */\n private readonly baseCatalogs = inject(WR_I18N_BASE_CATALOGS, { optional: true }) ?? [];\n\n /** Per-(locale,scope) catalogs, populated by `loadCatalog`. @internal */\n private readonly catalogs = new Map<string, WrI18nCatalog>();\n\n /** Bumped after each catalog write so reactive translates recompute. @internal */\n private readonly revision = signal(0);\n\n /** In-flight load promises — dedupes parallel `t()` callers. @internal */\n private readonly inflight = new Map<string, Promise<WrI18nCatalog>>();\n\n /** Registered scopes — auto-loaded whenever the locale changes. @internal */\n private readonly scopes = new Set<string>();\n\n /** Active locale. Writes go through `use()` so storage stays in sync. */\n private readonly _locale = signal<string>(this.initialLocale());\n readonly locale: Signal<string> = this._locale.asReadonly();\n\n constructor() {\n // Eagerly load the root catalog + every registered scope for the\n // current locale. Subsequent locale changes refire the same effect.\n effect(() => {\n const lc = this._locale();\n void this.loadCatalog(lc, null);\n for (const sc of this.scopes) void this.loadCatalog(lc, sc);\n });\n }\n\n // Locale\n\n /** Switch active locale. Ignored when not whitelisted. */\n use(locale: string): void {\n if (!this.config.availableLocales.includes(locale)) return;\n this._locale.set(locale);\n if (this.config.storageKey) this.storage.set(this.config.storageKey, locale);\n }\n\n /** Available locales — pass-through from config. */\n available(): readonly string[] {\n return this.config.availableLocales;\n }\n\n // Scopes\n\n /**\n * Register a scope so its catalog loads alongside the root one. Idempotent.\n * Returns a promise resolving once the current locale's scope catalog is in\n * the cache — handy for feature `canActivate` guards.\n */\n registerScope(scope: string): Promise<WrI18nCatalog> {\n this.scopes.add(scope);\n return this.loadCatalog(this._locale(), scope);\n }\n\n // Translate\n\n /**\n * Eager translate — returns the current value or the missing-handler\n * fallback. Does NOT auto-load missing catalogs; combine with the\n * reactive `translate(...)` if you want load-on-demand.\n */\n t(key: string, params?: WrI18nParams, scope?: string): string {\n // Read revision so callers inside computed/effect re-run on updates.\n this.revision();\n const lc = this._locale();\n\n let hit = scope ? walk(this.catalogs.get(cacheKey(lc, scope)) ?? null, key) : null;\n hit ??= walk(this.catalogs.get(cacheKey(lc, null)) ?? null, key);\n // Base catalogs are the floor: consulted only once the loader's own catalogs\n // have missed, so an app's keys always win, but ngwr's built-in strings are\n // still there when the app's catalog doesn't carry them.\n hit ??= this.walkBase(lc, key);\n\n if (hit === null) {\n // Fire a background load so a future read can resolve it.\n void this.loadCatalog(lc, scope ?? null);\n return this.config.missingHandler(key, lc);\n }\n return wrInterpolate(hit, params);\n }\n\n /** Reactive translate — re-evaluates on locale or catalog updates. */\n translate(key: string, params?: WrI18nParams, scope?: string): Signal<string> {\n return computed(() => this.t(key, params, scope));\n }\n\n // Internals\n\n /**\n * Look a key up in the registered base catalogs, later contributions first so\n * a feature can shadow an earlier one.\n */\n private walkBase(locale: string, key: string): string | null {\n for (let i = this.baseCatalogs.length - 1; i >= 0; i--) {\n const hit = walk(this.baseCatalogs[i][locale] ?? null, key);\n if (hit !== null) return hit;\n }\n return null;\n }\n\n private initialLocale(): string {\n if (this.config.storageKey) {\n const saved = this.storage.get<string>(this.config.storageKey);\n if (saved && this.config.availableLocales.includes(saved)) return saved;\n }\n return this.config.defaultLocale;\n }\n\n private loadCatalog(locale: string, scope: string | null): Promise<WrI18nCatalog> {\n const ck = cacheKey(locale, scope);\n const cached = this.catalogs.get(ck);\n if (cached) return Promise.resolve(cached);\n\n const pending = this.inflight.get(ck);\n if (pending) return pending;\n\n const stream: Observable<WrI18nCatalog> = this.loader.load(locale, scope);\n const promise = firstValueFrom(stream)\n .then(catalog => {\n this.catalogs.set(ck, catalog);\n this.revision.update(v => v + 1);\n return catalog;\n })\n .catch((err: unknown) => {\n // eslint-disable-next-line no-console -- intentional diagnostic for missing catalog\n console.warn(`[ngwr/i18n] failed to load (${locale}, ${scope ?? 'root'})`, err);\n const empty: WrI18nCatalog = {};\n this.catalogs.set(ck, empty);\n return empty;\n })\n .finally(() => {\n this.inflight.delete(ck);\n });\n\n this.inflight.set(ck, promise);\n return promise;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Pipe, type PipeTransform, inject } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams } from './i18n-config';\n\n/**\n * Translate a key. Impure — re-evaluates on every CD so locale switches\n * and catalog loads propagate without a manual refresh.\n *\n * @example\n * ```html\n * <h1>{{ 'home.title' | wrT }}</h1>\n * <p>{{ 'greeting' | wrT: { name: user().name } }}</p>\n * <button>{{ 'forms.save' | wrT: null : 'checkout' }}</button>\n * ```\n */\n// eslint-disable-next-line @angular-eslint/no-pipe-impure -- intentional: locale + catalog updates must propagate even when args are stable\n@Pipe({ name: 'wrT', pure: false })\nexport class WrTPipe implements PipeTransform {\n private readonly i18n = inject(WrI18n);\n\n transform(key: string, params?: WrI18nParams | null, scope?: string): string {\n return this.i18n.t(key, params ?? undefined, scope);\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, computed, effect, inject, input } from '@angular/core';\n\nimport { WrI18n } from './i18n';\nimport { type WrI18nParams } from './i18n-config';\n\n/**\n * Attribute directive that sets `textContent` of its host to the translation\n * of the bound key. Reactive — re-renders on locale + catalog changes.\n *\n * @example\n * ```html\n * <span [wrT]=\"'home.title'\"></span>\n * <span [wrT]=\"'greeting'\" [wrTParams]=\"{ name: user().name }\"></span>\n * <span [wrT]=\"'forms.save'\" wrTScope=\"checkout\"></span>\n * ```\n */\n@Directive({\n selector: '[wrT]',\n})\nexport class WrTDirective {\n /** Translation key. Required. */\n readonly wrT = input.required<string>();\n\n /** Interpolation params for `{{name}}` tokens. */\n readonly wrTParams = input<WrI18nParams | null>(null);\n\n /** Optional scope — scoped lookup first, then root fallback. */\n readonly wrTScope = input<string | null>(null);\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly i18n = inject(WrI18n);\n\n private readonly text = computed(() =>\n this.i18n.t(this.wrT(), this.wrTParams() ?? undefined, this.wrTScope() ?? undefined)\n );\n\n constructor() {\n effect(() => {\n this.host.nativeElement.textContent = this.text();\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Observable, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Root catalogs keyed by locale: `{ en: catalog, ru: catalog, … }`. */\nexport type WrI18nStaticCatalogs = Readonly<Record<string, WrI18nCatalog>>;\n\n/** Per-scope catalogs: `{ checkout: { en: catalog, ru: catalog }, … }`. */\nexport type WrI18nStaticScopedCatalogs = Readonly<Record<string, WrI18nStaticCatalogs>>;\n\n/**\n * Loader for catalogs already in memory (imported from JSON or generated).\n *\n * - Pass `catalogs` for the root catalog of every locale.\n * - Pass `scopes` if you ship per-feature catalogs the loader should serve\n * to `WrI18n.registerScope(name)` calls.\n *\n * Missing locale or scope resolves to `{}` — the missing-key handler then\n * decides what to render.\n */\nexport class WrI18nStaticLoader implements WrI18nLoader {\n constructor(\n private readonly catalogs: WrI18nStaticCatalogs,\n private readonly scopes: WrI18nStaticScopedCatalogs = {}\n ) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n if (scope === null) return of(this.catalogs[locale] ?? {});\n return of(this.scopes[scope]?.[locale] ?? {});\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { HttpClient } from '@angular/common/http';\nimport { inject } from '@angular/core';\n\nimport { type Observable, catchError, of } from 'rxjs';\n\nimport { type WrI18nCatalog } from '../i18n-config';\nimport { type WrI18nLoader } from '../i18n-loader';\n\n/** Configuration for {@link WrI18nHttpLoader}. */\nexport interface WrI18nHttpLoaderConfig {\n /**\n * URL template. Tokens:\n * - `{locale}` — required, BCP-47 tag (e.g. `en`).\n * - `{scope}` — optional, scope name. Use the `rootPath` if you need a\n * different path entirely for the root catalog.\n *\n * @example\n * ```ts\n * { path: '/assets/i18n/{locale}.json' } // root only\n * { path: '/assets/i18n/{scope}/{locale}.json',\n * rootPath: '/assets/i18n/{locale}.json' } // root + scopes\n * ```\n */\n readonly path: string;\n /** Path template for the root catalog. Defaults to `path`. */\n readonly rootPath?: string;\n}\n\n/**\n * Loader that fetches catalogs via `HttpClient`. Failures resolve to `{}`\n * (logged once at the service layer) so a missing file never throws into\n * user code.\n */\nexport class WrI18nHttpLoader implements WrI18nLoader {\n private readonly http = inject(HttpClient);\n\n constructor(private readonly config: WrI18nHttpLoaderConfig) {}\n\n load(locale: string, scope: string | null): Observable<WrI18nCatalog> {\n const template = scope === null ? (this.config.rootPath ?? this.config.path) : this.config.path;\n const url = template.replace('{locale}', locale).replace('{scope}', scope ?? '');\n return this.http.get<WrI18nCatalog>(url).pipe(catchError(() => of<WrI18nCatalog>({})));\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type EnvironmentProviders, type Provider, makeEnvironmentProviders } from '@angular/core';\n\nimport { WR_I18N_BASE_CATALOGS, type WrI18nBaseCatalogs } from './i18n-base-catalogs';\nimport { DEFAULT_WR_I18N_CONFIG, WR_I18N_CONFIG, type WrI18nConfig, type WrI18nConfigResolved } from './i18n-config';\nimport { WR_I18N_LOADER, type WrI18nLoader } from './i18n-loader';\nimport { WrI18nHttpLoader, type WrI18nHttpLoaderConfig } from './loaders/http-loader';\nimport {\n WrI18nStaticLoader,\n type WrI18nStaticCatalogs,\n type WrI18nStaticScopedCatalogs,\n} from './loaders/static-loader';\n\n/**\n * Configure {@link WrI18n}. Either pass a `loader` directly, or use the\n * `provideWrI18nHttpLoader` / `provideWrI18nStaticLoader` helpers in the\n * same providers array.\n */\nexport interface ProvideWrI18nOptions extends WrI18nConfig {\n readonly loader?: WrI18nLoader;\n}\n\nexport function provideWrI18n(options: ProvideWrI18nOptions = {}): EnvironmentProviders {\n const { loader, ...config } = options;\n const merged: WrI18nConfigResolved = { ...DEFAULT_WR_I18N_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_I18N_CONFIG, useValue: merged }];\n if (loader) providers.push({ provide: WR_I18N_LOADER, useValue: loader });\n\n return makeEnvironmentProviders(providers);\n}\n\n/**\n * Provide a static loader — catalogs already in memory.\n *\n * @param catalogs Root catalogs keyed by locale.\n * @param scopes Optional per-scope catalogs served to `registerScope(name)`.\n */\nexport function provideWrI18nStaticLoader(\n catalogs: WrI18nStaticCatalogs,\n scopes?: WrI18nStaticScopedCatalogs\n): Provider {\n return { provide: WR_I18N_LOADER, useValue: new WrI18nStaticLoader(catalogs, scopes) };\n}\n\n/**\n * Register catalogs consulted *underneath* the loader — this is how ngwr's own\n * built-in strings survive when you supply your own catalogs.\n *\n * A loader replaces the catalog for a locale instead of extending it, so a JSON\n * file holding only your keys leaves every built-in label on its hardcoded\n * English fallback, with nothing logged. One line fixes it, on either loader:\n *\n * @example\n * ```ts\n * import { wrRu } from 'ngwr/i18n/ru';\n *\n * providers: [\n * provideWrI18n({ defaultLocale: 'ru', availableLocales: ['ru'] }),\n * provideWrI18nBaseCatalogs({ ru: wrRu }),\n * provideWrI18nHttpLoader({ path: '/assets/i18n/{locale}.json' }),\n * ]\n * ```\n *\n * Pass only the locales you ship — the ones you leave out stay out of the\n * bundle. Your own keys always win; this is a floor, not an override.\n */\nexport function provideWrI18nBaseCatalogs(catalogs: WrI18nBaseCatalogs): Provider {\n return { provide: WR_I18N_BASE_CATALOGS, useValue: catalogs, multi: true };\n}\n\n/** Provide an HTTP loader — catalogs fetched from URLs. Requires `provideHttpClient`. */\nexport function provideWrI18nHttpLoader(config: WrI18nHttpLoaderConfig): Provider {\n return { provide: WR_I18N_LOADER, useFactory: () => new WrI18nHttpLoader(config) };\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Signal, computed, inject, signal } from '@angular/core';\n\nimport { WrI18n, wrInterpolate } from './i18n';\nimport type { WrI18nParams } from './i18n-config';\n\n/**\n * Helper for component default text. Returns a reactive string that:\n *\n * 1. Prefers the consumer's override (an `input<string | null>()` value).\n * 2. Falls back to the i18n catalog under `key` — re-renders on locale\n * change so a switcher updates the DOM live.\n * 3. Falls back to `fallback` when no `WrI18n` is provided OR the catalog\n * is missing the key.\n *\n * Components don't need a hard dependency on `provideWrI18n` — without it,\n * the fallback is returned and everything still works.\n *\n * @example\n * ```ts\n * readonly emptyText = input<string | null>(null);\n * protected readonly empty = useI18nText(this.emptyText, 'table.empty', 'No data');\n *\n * // In template: <div>{{ empty() }}</div>\n * ```\n */\nexport function useI18nText(binding: Signal<string | null | undefined>, key: string, fallback: string): Signal<string> {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return computed(() => {\n const v = binding();\n return v ?? fallback;\n });\n }\n\n return computed(() => {\n const v = binding();\n if (v !== null && v !== undefined && v !== '') return v;\n const translated = i18n.t(key);\n // Default missing handler returns the key itself — treat that as \"missing\"\n // and use our explicit fallback.\n return translated === key ? fallback : translated;\n });\n}\n\n/**\n * Like {@link useI18nText} but takes a literal value (not a Signal) — for\n * computed `aria-label`s that already mix a static piece with a dynamic\n * value. Returns the resolved string once, at injection time.\n */\nexport function readI18nText(key: string, fallback: string): string {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) return fallback;\n const v = i18n.t(key);\n return v === key ? fallback : v;\n}\n\n/** Tiny shim — useful when the caller doesn't have an `input` to forward. */\nexport function nullSignal(): Signal<null> {\n return signal(null).asReadonly();\n}\n\n/**\n * Build a per-call formatter for parametrized labels (e.g. ARIA labels\n * that interpolate a per-row value: `\"Remove {{label}}\"`). Returns a\n * function the template calls with the params for the current item.\n *\n * The returned function:\n * - Re-resolves the i18n catalog on every call (live locale switches just\n * work — re-rendered templates pick up new strings).\n * - Falls back to the literal `fallback` template with the same\n * `{{name}}` syntax when no `WrI18n` provider is present, or when the\n * key is missing.\n *\n * Use this for labels that vary per row. For static labels, prefer\n * {@link useI18nText} or {@link readI18nText}.\n *\n * @example\n * ```ts\n * protected readonly removeChipLabel = useI18nFormatter('select.removeItem', 'Remove {{label}}');\n *\n * // In template:\n * // [attr.aria-label]=\"removeChipLabel({ label: chip.label })\"\n * ```\n */\nexport function useI18nFormatter(key: string, fallback: string): (params?: WrI18nParams) => string {\n const i18n = inject(WrI18n, { optional: true });\n if (!i18n) {\n return (params?: WrI18nParams) => wrInterpolate(fallback, params);\n }\n return (params?: WrI18nParams) => {\n const v = i18n.t(key, params);\n return v === key ? wrInterpolate(fallback, params) : v;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AASH;;;;;;;;;;;;;;;;;AAiBG;MACU,qBAAqB,GAAG,IAAI,cAAc,CAAgC,uBAAuB;;AChC9G;;;;;AAKG;AAyCI,MAAM,sBAAsB,GAAyB;AAC1D,IAAA,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,CAAC,IAAI,CAAC;AACxB,IAAA,UAAU,EAAE,gBAAgB;AAC5B,IAAA,cAAc,EAAE,GAAG,IAAI,GAAG;;MAGf,cAAc,GAAG,IAAI,cAAc,CAAuB,gBAAgB,EAAE;AACvF,IAAA,OAAO,EAAE,MAAM,sBAAsB;AACtC,CAAA;;ACvDD;;;;;AAKG;MAkBU,cAAc,GAAG,IAAI,cAAc,CAAe,gBAAgB;;ACvB/E;;;;;AAKG;AAYH;AACA,SAAS,QAAQ,CAAC,MAAc,EAAE,KAAoB,EAAA;AACpD,IAAA,OAAO,GAAG,MAAM,CAAA,EAAA,EAAK,KAAK,IAAI,EAAE,EAAE;AACpC;AAEA;AACA,SAAS,IAAI,CAAC,GAAyB,EAAE,GAAW,EAAA;AAClD,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,IAAI;IACrB,IAAI,IAAI,GAAuC,GAAG;IAClD,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;AACjC,QAAA,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,YAAA,OAAO,IAAI;AAC/D,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACnB;AACA,IAAA,OAAO,OAAO,IAAI,KAAK,QAAQ,G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AC;IACnE;IACA,OAAO,CAAC,MAAqB,KAAI;QAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC;AAC7B,QAAA,OAAO,CAAC,KAAK,GAAG,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC;AACxD,IAAA,CAAC;AACH;;ACpGA;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, input, inject, ElementRef, EnvironmentInjector, computed, effect, isDevMode, ViewEncapsulation, Component } from '@angular/core';
2
+ import { InjectionToken, inject, Injectable, input, ElementRef, computed, effect, isDevMode, ViewEncapsulation, Component } from '@angular/core';
3
3
 
4
4
  /**
5
5
  * @license
@@ -16,6 +16,50 @@ import { InjectionToken, input, inject, ElementRef, EnvironmentInjector, compute
16
16
  */
17
17
  const WR_ICONS = new InjectionToken('WR_ICONS');
18
18
 
19
+ /**
20
+ * @license
21
+ *
22
+ * Use of this source code is governed by an MIT-style license that can be
23
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
24
+ */
25
+ /**
26
+ * One link in the icon-registry chain. {@link provideWrIcons} provides an
27
+ * instance alongside its icons, so every injector level that registers icons
28
+ * gets its own link whose parent is the next registering level above it.
29
+ *
30
+ * This exists because Angular does not merge `multi: true` providers across
31
+ * injector levels — an element-level `provideWrIcons()` *replaces* the visible
32
+ * `WR_ICONS` collection rather than adding to it. Reading only the closest
33
+ * contribution silently hid every icon registered further up, which contradicts
34
+ * the "each call adds to the registry" contract. Walking the chain restores it
35
+ * for any number of levels.
36
+ *
37
+ * @internal
38
+ */
39
+ class WrIconRegistry {
40
+ /** The next registering level up, if any. */
41
+ parent = inject(WrIconRegistry, { skipSelf: true, optional: true });
42
+ /** Icons registered at *this* level only. */
43
+ own = inject(WR_ICONS, { self: true, optional: true }) ?? [];
44
+ /**
45
+ * Every icon visible from this level, nearest last so a local registration
46
+ * wins over an identically named one further up.
47
+ */
48
+ resolve() {
49
+ const map = this.parent?.resolve() ?? new Map();
50
+ for (const set of this.own) {
51
+ for (const icon of set)
52
+ map.set(icon.name, icon);
53
+ }
54
+ return map;
55
+ }
56
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrIconRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
57
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrIconRegistry });
58
+ }
59
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrIconRegistry, decorators: [{
60
+ type: Injectable
61
+ }] });
62
+
19
63
  /**
20
64
  * @license
21
65
  *
@@ -40,41 +84,21 @@ class WrIcon {
40
84
  ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
41
85
  host = inject(ElementRef);
42
86
  /**
43
- * Merged view of every `WR_ICONS` multi-provider visible from this
44
- * injector position — element-level first overlay, environment-level
45
- * (app/lazy-route bootstrap) as the base.
46
- *
47
- * Angular's default `inject(WR_ICONS)` only returns the **closest**
48
- * injector's contribution; if a component declares its own
49
- * `provideWrIcons(...)`, the root registration is **shadowed**, not
50
- * appended. That contradicts the docstring's "each call adds to the
51
- * registry" promise and silently breaks any page that overrides while
52
- * still relying on root-registered icons.
87
+ * Every icon visible from this position, walked up the whole chain of
88
+ * registering injector levels.
53
89
  *
54
- * We work around it by also asking the environment injector directly
55
- * (`envInjector.get(WR_ICONS, null, …)`). When no element-level
56
- * provider exists both calls return the same array reference and we
57
- * skip the redundant pass. Otherwise we lay element on top of env so
58
- * a page's local icons can override a root-registered name.
90
+ * Angular's `inject(WR_ICONS)` returns only the **closest** injector's
91
+ * contribution — `multi` providers are not merged across levels — so a
92
+ * component that registers its own icons used to shadow, not extend, what an
93
+ * ancestor registered. {@link WrIconRegistry} is provided once per
94
+ * registering level and links to its parent, so nesting any number of levels
95
+ * now adds up, with the nearest registration winning a name collision.
59
96
  *
60
- * One known limitation: multiple element-injector levels in between
61
- * still shadow each other — but the showcase doesn't nest providers
62
- * that deep, and the env+local merge fixes the dominant case.
97
+ * Optional: with no `provideWrIcons()` anywhere the map is simply empty and
98
+ * every name reports as unregistered.
63
99
  */
64
- iconSets = (() => {
65
- const local = inject(WR_ICONS, { optional: true }) ?? [];
66
- const env = inject(EnvironmentInjector).get(WR_ICONS, null, { optional: true }) ?? [];
67
- return local === env ? local : [...env, ...local];
68
- })();
69
- registry = computed(() => {
70
- const map = new Map();
71
- for (const set of this.iconSets) {
72
- for (const icon of set) {
73
- map.set(icon.name, icon);
74
- }
75
- }
76
- return map;
77
- }, /* @ts-ignore */
100
+ iconRegistry = inject(WrIconRegistry, { optional: true });
101
+ registry = computed(() => (this.iconRegistry?.resolve() ?? new Map()), /* @ts-ignore */
78
102
  ...(ngDevMode ? [{ debugName: "registry" }] : /* istanbul ignore next */ []));
79
103
  icon = computed(() => this.registry().get(this.name()), /* @ts-ignore */
80
104
  ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
@@ -84,7 +108,15 @@ class WrIcon {
84
108
  const name = this.name();
85
109
  if (!icon) {
86
110
  if (isDevMode()) {
87
- throw new Error(`[NGWR] No icon named "${name}" is registered. Did you forget to call provideWrIcons()?`);
111
+ // Reported, never thrown. An exception here escapes into
112
+ // `runEffectsInView`, which abandons the remaining effects of the
113
+ // whole view — one unknown name would blank every `<wr-icon>` after
114
+ // it while the console blamed only the first. Error level (not
115
+ // `badgeLog`) so it survives a console filtered to errors.
116
+ // eslint-disable-next-line no-console -- misconfiguration must be visible, but must not throw
117
+ console.error(`[NGWR] No icon named "${name}" is registered. Did you forget to call provideWrIcons()? ` +
118
+ `If the name IS registered, check the injector level: a component-level provideWrIcons() ` +
119
+ `shadows icons registered on an ancestor component.`);
88
120
  }
89
121
  this.host.nativeElement.innerHTML = '';
90
122
  return;
@@ -190,7 +222,14 @@ function provideWrIcons(icons) {
190
222
  for (const icon of icons)
191
223
  validateIcon(icon);
192
224
  }
193
- return [{ provide: WR_ICONS, useValue: icons, multi: true }];
225
+ return [
226
+ { provide: WR_ICONS, useValue: icons, multi: true },
227
+ // A registry link per registering level. Angular does not merge `multi`
228
+ // providers across injectors, so without this chain an element-level
229
+ // registration would shadow everything registered above it instead of
230
+ // adding to it.
231
+ WrIconRegistry,
232
+ ];
194
233
  }
195
234
 
196
235
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-icon.mjs","sources":["../../../projects/lib/icon/tokens/icon.token.ts","../../../projects/lib/icon/icon.ts","../../../projects/lib/icon/utils/validate-icon.ts","../../../projects/lib/icon/providers/provide-wr-icons.ts","../../../projects/lib/icon/svg-icon.ts","../../../projects/lib/icon/ngwr-icon.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrIconDef } from '../interfaces';\n\n/**\n * Multi-provider token for registering icons with the icon registry.\n *\n * Use {@link provideWrIcons} instead of providing this token directly.\n *\n * @internal\n */\nexport const WR_ICONS = new InjectionToken<readonly WrIconDef[][]>('WR_ICONS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport {\n Component,\n ElementRef,\n EnvironmentInjector,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n isDevMode,\n} from '@angular/core';\n\nimport type { WrIconDef, WrIconName } from './interfaces';\nimport { WR_ICONS } from './tokens';\n\n/**\n * Renders a registered SVG icon.\n *\n * Icons must be registered via {@link provideWrIcons} before use —\n * either at the application root or on any ancestor component.\n *\n * @example\n * ```html\n * <wr-icon name=\"home\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/icon\n */\n@Component({\n selector: 'wr-icon',\n template: '',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-icon',\n '[attr.data-icon]': 'name()',\n },\n})\nexport class WrIcon {\n readonly name = input.required<WrIconName>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Merged view of every `WR_ICONS` multi-provider visible from this\n * injector position — element-level first overlay, environment-level\n * (app/lazy-route bootstrap) as the base.\n *\n * Angular's default `inject(WR_ICONS)` only returns the **closest**\n * injector's contribution; if a component declares its own\n * `provideWrIcons(...)`, the root registration is **shadowed**, not\n * appended. That contradicts the docstring's \"each call adds to the\n * registry\" promise and silently breaks any page that overrides while\n * still relying on root-registered icons.\n *\n * We work around it by also asking the environment injector directly\n * (`envInjector.get(WR_ICONS, null, …)`). When no element-level\n * provider exists both calls return the same array reference and we\n * skip the redundant pass. Otherwise we lay element on top of env so\n * a page's local icons can override a root-registered name.\n *\n * One known limitation: multiple element-injector levels in between\n * still shadow each other — but the showcase doesn't nest providers\n * that deep, and the env+local merge fixes the dominant case.\n */\n private readonly iconSets: readonly (readonly WrIconDef[])[] = (() => {\n const local = inject(WR_ICONS, { optional: true }) ?? [];\n const env = inject(EnvironmentInjector).get(WR_ICONS, null, { optional: true }) ?? [];\n return local === env ? local : [...env, ...local];\n })();\n\n private readonly registry = computed(() => {\n const map = new Map<WrIconName, WrIconDef>();\n for (const set of this.iconSets) {\n for (const icon of set) {\n map.set(icon.name, icon);\n }\n }\n return map;\n });\n\n private readonly icon = computed(() => this.registry().get(this.name()));\n\n constructor() {\n effect(() => {\n const icon = this.icon();\n const name = this.name();\n\n if (!icon) {\n if (isDevMode()) {\n throw new Error(`[NGWR] No icon named \"${name}\" is registered. Did you forget to call provideWrIcons()?`);\n }\n this.host.nativeElement.innerHTML = '';\n return;\n }\n\n this.host.nativeElement.innerHTML = icon.data;\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from '../interfaces';\n\nconst VIEW_BOX_RE = /<svg\\b[^>]*\\bviewBox\\s*=/i;\nconst SVG_ROOT_RE = /<svg\\b/i;\n\n/**\n * Dev-mode sanity check for a registered icon.\n *\n * Warns about issues that prevent correct rendering — most importantly,\n * a missing `viewBox`, which causes the SVG not to scale to the icon\n * host's size.\n *\n * Production builds drop the call entirely via `isDevMode()` tree-shaking.\n *\n * @internal\n */\nexport function validateIcon(icon: WrIconDef): void {\n if (!SVG_ROOT_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" data does not contain an <svg> root element. ` +\n `Custom icons must be valid SVG markup.`\n );\n return;\n }\n\n if (!VIEW_BOX_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" has no viewBox attribute — it won't scale ` +\n `to the host size. Add viewBox=\"0 0 W H\" to the <svg> root.`\n );\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Provider, isDevMode } from '@angular/core';\n\nimport type { WrIconDef } from '../interfaces';\nimport { WR_ICONS } from '../tokens';\nimport { validateIcon } from '../utils';\n\n/**\n * Registers a set of icons for use by `<wr-icon>`.\n *\n * Can be called multiple times — each call adds to the registry.\n * Works at both the application root and at the component level,\n * so a feature module or a single component can bring its own icons\n * without polluting the global config.\n *\n * In dev mode, each icon is validated for common issues (missing\n * `viewBox`, malformed root). Validation is dropped from production\n * builds via `isDevMode()` tree-shaking.\n *\n * @example\n * ```ts\n * // App-level registration\n * import { home, user, cog, provideWrIcons } from 'ngwr/icon';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideWrIcons([home, user, cog]),\n * ],\n * };\n * ```\n *\n * @example\n * ```ts\n * // Component-level registration\n * import { logoGithub, logoNpm, provideWrIcons, WrIconDef } from 'ngwr/icon';\n *\n * @Component({\n * selector: 'ngwr-header',\n * imports: [WrIcon],\n * providers: [provideWrIcons([logoGithub, logoNpm])],\n * template: `<wr-icon name=\"logo-github\" />`,\n * })\n * export class HeaderComponent {}\n * ```\n */\nexport function provideWrIcons(icons: WrIconDef[]): Provider[] {\n if (isDevMode()) {\n for (const icon of icons) validateIcon(icon);\n }\n return [{ provide: WR_ICONS, useValue: icons, multi: true }];\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from './interfaces';\n\n/**\n * Wrap a raw SVG string in the {@link WrIconDef} envelope. Use this when\n * importing icons from sources that ship full `<svg>` files — Tabler,\n * Phosphor, Heroicons, Iconoir, Radix, Bootstrap Icons, your designer.\n *\n * Pair with a bundler's raw-SVG import (Vite's `?raw`, Webpack's\n * `raw-loader`, esbuild's `--loader:.svg=text`) so the SVG file becomes\n * a string at build time.\n *\n * For sets with a non-SVG shape (Lucide's IconNode tuples, Feather's\n * inner-only SVG), use the dedicated adapter under\n * `ngwr/icon/adapters/<set>` instead.\n *\n * @example\n * ```ts\n * import { svgIcon, provideWrIcons } from 'ngwr/icon';\n * // Vite: the `?raw` suffix returns the file as a string.\n * import plusSvg from '@tabler/icons/icons/plus.svg?raw';\n * import phosphorPlusSvg from '@phosphor-icons/core/assets/regular/plus.svg?raw';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideWrIcons([\n * svgIcon('plus', plusSvg),\n * svgIcon('plus-phosphor', phosphorPlusSvg),\n * ]),\n * ],\n * });\n * ```\n */\nexport function svgIcon(name: string, svg: string): WrIconDef {\n return { name, data: svg };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAMH;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAyB,UAAU,CAAC;;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AAA,CAAwC,CAC3C;QACD;IACF;IAEA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;;AAEhC,QAAA,OAAO,CAAC,IAAI,CACV,gBAAgB,IAAI,CAAC,IAAI,CAAA,4CAAA,CAA8C;AACrE,YAAA,CAAA,0DAAA,CAA4D,CAC/D;IACH;AACF;;ACxCA;;;;;AAKG;AAQH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACG,SAAU,cAAc,CAAC,KAAkB,EAAA;IAC/C,IAAI,SAAS,EAAE,EAAE;QACf,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,YAAY,CAAC,IAAI,CAAC;IAC9C;AACA,IAAA,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC9D;;ACxDA;;;;;AAKG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACG,SAAU,OAAO,CAAC,IAAY,EAAE,GAAW,EAAA;AAC/C,IAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;AAC5B;;ACzCA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngwr-icon.mjs","sources":["../../../projects/lib/icon/tokens/icon.token.ts","../../../projects/lib/icon/icon-registry.ts","../../../projects/lib/icon/icon.ts","../../../projects/lib/icon/utils/validate-icon.ts","../../../projects/lib/icon/providers/provide-wr-icons.ts","../../../projects/lib/icon/svg-icon.ts","../../../projects/lib/icon/ngwr-icon.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrIconDef } from '../interfaces';\n\n/**\n * Multi-provider token for registering icons with the icon registry.\n *\n * Use {@link provideWrIcons} instead of providing this token directly.\n *\n * @internal\n */\nexport const WR_ICONS = new InjectionToken<readonly WrIconDef[][]>('WR_ICONS');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Injectable, inject } from '@angular/core';\n\nimport type { WrIconDef } from './interfaces';\nimport { WR_ICONS } from './tokens';\n\n/**\n * One link in the icon-registry chain. {@link provideWrIcons} provides an\n * instance alongside its icons, so every injector level that registers icons\n * gets its own link whose parent is the next registering level above it.\n *\n * This exists because Angular does not merge `multi: true` providers across\n * injector levels — an element-level `provideWrIcons()` *replaces* the visible\n * `WR_ICONS` collection rather than adding to it. Reading only the closest\n * contribution silently hid every icon registered further up, which contradicts\n * the \"each call adds to the registry\" contract. Walking the chain restores it\n * for any number of levels.\n *\n * @internal\n */\n@Injectable()\nexport class WrIconRegistry {\n /** The next registering level up, if any. */\n private readonly parent = inject(WrIconRegistry, { skipSelf: true, optional: true });\n\n /** Icons registered at *this* level only. */\n private readonly own = inject(WR_ICONS, { self: true, optional: true }) ?? [];\n\n /**\n * Every icon visible from this level, nearest last so a local registration\n * wins over an identically named one further up.\n */\n resolve(): Map<string, WrIconDef> {\n const map = this.parent?.resolve() ?? new Map<string, WrIconDef>();\n for (const set of this.own) {\n for (const icon of set) map.set(icon.name, icon);\n }\n return map;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ElementRef, ViewEncapsulation, computed, effect, inject, input, isDevMode } from '@angular/core';\n\nimport { WrIconRegistry } from './icon-registry';\nimport type { WrIconDef, WrIconName } from './interfaces';\n\n/**\n * Renders a registered SVG icon.\n *\n * Icons must be registered via {@link provideWrIcons} before use —\n * either at the application root or on any ancestor component.\n *\n * @example\n * ```html\n * <wr-icon name=\"home\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/icon\n */\n@Component({\n selector: 'wr-icon',\n template: '',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-icon',\n '[attr.data-icon]': 'name()',\n },\n})\nexport class WrIcon {\n readonly name = input.required<WrIconName>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Every icon visible from this position, walked up the whole chain of\n * registering injector levels.\n *\n * Angular's `inject(WR_ICONS)` returns only the **closest** injector's\n * contribution — `multi` providers are not merged across levels — so a\n * component that registers its own icons used to shadow, not extend, what an\n * ancestor registered. {@link WrIconRegistry} is provided once per\n * registering level and links to its parent, so nesting any number of levels\n * now adds up, with the nearest registration winning a name collision.\n *\n * Optional: with no `provideWrIcons()` anywhere the map is simply empty and\n * every name reports as unregistered.\n */\n private readonly iconRegistry = inject(WrIconRegistry, { optional: true });\n\n private readonly registry = computed<ReadonlyMap<WrIconName, WrIconDef>>(\n () => (this.iconRegistry?.resolve() ?? new Map()) as ReadonlyMap<WrIconName, WrIconDef>\n );\n\n private readonly icon = computed(() => this.registry().get(this.name()));\n\n constructor() {\n effect(() => {\n const icon = this.icon();\n const name = this.name();\n\n if (!icon) {\n if (isDevMode()) {\n // Reported, never thrown. An exception here escapes into\n // `runEffectsInView`, which abandons the remaining effects of the\n // whole view — one unknown name would blank every `<wr-icon>` after\n // it while the console blamed only the first. Error level (not\n // `badgeLog`) so it survives a console filtered to errors.\n // eslint-disable-next-line no-console -- misconfiguration must be visible, but must not throw\n console.error(\n `[NGWR] No icon named \"${name}\" is registered. Did you forget to call provideWrIcons()? ` +\n `If the name IS registered, check the injector level: a component-level provideWrIcons() ` +\n `shadows icons registered on an ancestor component.`\n );\n }\n this.host.nativeElement.innerHTML = '';\n return;\n }\n\n this.host.nativeElement.innerHTML = icon.data;\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from '../interfaces';\n\nconst VIEW_BOX_RE = /<svg\\b[^>]*\\bviewBox\\s*=/i;\nconst SVG_ROOT_RE = /<svg\\b/i;\n\n/**\n * Dev-mode sanity check for a registered icon.\n *\n * Warns about issues that prevent correct rendering — most importantly,\n * a missing `viewBox`, which causes the SVG not to scale to the icon\n * host's size.\n *\n * Production builds drop the call entirely via `isDevMode()` tree-shaking.\n *\n * @internal\n */\nexport function validateIcon(icon: WrIconDef): void {\n if (!SVG_ROOT_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" data does not contain an <svg> root element. ` +\n `Custom icons must be valid SVG markup.`\n );\n return;\n }\n\n if (!VIEW_BOX_RE.test(icon.data)) {\n // eslint-disable-next-line no-console -- dev-mode validation\n console.warn(\n `[NGWR] Icon \"${icon.name}\" has no viewBox attribute — it won't scale ` +\n `to the host size. Add viewBox=\"0 0 W H\" to the <svg> root.`\n );\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type Provider, isDevMode } from '@angular/core';\n\nimport { WrIconRegistry } from '../icon-registry';\nimport type { WrIconDef } from '../interfaces';\nimport { WR_ICONS } from '../tokens';\nimport { validateIcon } from '../utils';\n\n/**\n * Registers a set of icons for use by `<wr-icon>`.\n *\n * Can be called multiple times — each call adds to the registry.\n * Works at both the application root and at the component level,\n * so a feature module or a single component can bring its own icons\n * without polluting the global config.\n *\n * In dev mode, each icon is validated for common issues (missing\n * `viewBox`, malformed root). Validation is dropped from production\n * builds via `isDevMode()` tree-shaking.\n *\n * @example\n * ```ts\n * // App-level registration\n * import { home, user, cog, provideWrIcons } from 'ngwr/icon';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideWrIcons([home, user, cog]),\n * ],\n * };\n * ```\n *\n * @example\n * ```ts\n * // Component-level registration\n * import { logoGithub, logoNpm, provideWrIcons, WrIconDef } from 'ngwr/icon';\n *\n * @Component({\n * selector: 'ngwr-header',\n * imports: [WrIcon],\n * providers: [provideWrIcons([logoGithub, logoNpm])],\n * template: `<wr-icon name=\"logo-github\" />`,\n * })\n * export class HeaderComponent {}\n * ```\n */\nexport function provideWrIcons(icons: WrIconDef[]): Provider[] {\n if (isDevMode()) {\n for (const icon of icons) validateIcon(icon);\n }\n return [\n { provide: WR_ICONS, useValue: icons, multi: true },\n // A registry link per registering level. Angular does not merge `multi`\n // providers across injectors, so without this chain an element-level\n // registration would shadow everything registered above it instead of\n // adding to it.\n WrIconRegistry,\n ];\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport type { WrIconDef } from './interfaces';\n\n/**\n * Wrap a raw SVG string in the {@link WrIconDef} envelope. Use this when\n * importing icons from sources that ship full `<svg>` files — Tabler,\n * Phosphor, Heroicons, Iconoir, Radix, Bootstrap Icons, your designer.\n *\n * Pair with a bundler's raw-SVG import (Vite's `?raw`, Webpack's\n * `raw-loader`, esbuild's `--loader:.svg=text`) so the SVG file becomes\n * a string at build time.\n *\n * For sets with a non-SVG shape (Lucide's IconNode tuples, Feather's\n * inner-only SVG), use the dedicated adapter under\n * `ngwr/icon/adapters/<set>` instead.\n *\n * @example\n * ```ts\n * import { svgIcon, provideWrIcons } from 'ngwr/icon';\n * // Vite: the `?raw` suffix returns the file as a string.\n * import plusSvg from '@tabler/icons/icons/plus.svg?raw';\n * import phosphorPlusSvg from '@phosphor-icons/core/assets/regular/plus.svg?raw';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideWrIcons([\n * svgIcon('plus', plusSvg),\n * svgIcon('plus-phosphor', phosphorPlusSvg),\n * ]),\n * ],\n * });\n * ```\n */\nexport function svgIcon(name: string, svg: string): WrIconDef {\n return { name, data: svg };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AA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