@reforgium/presentia 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, signal, computed, inject, DestroyRef, PLATFORM_ID, afterRenderEffect, Injectable, TemplateRef, ViewContainerRef, effect, Input, Directive, input, ElementRef, Renderer2, Injector, afterNextRender, runInInjectionContext, Pipe, makeEnvironmentProviders, LOCALE_ID } from '@angular/core';
|
|
3
|
-
import { TRANSLATION, SELECTED_LANG, CHANGE_LANG, SELECTED_THEME, CHANGE_THEME, CURRENT_DEVICE, deepEqual } from '@reforgium/internal';
|
|
3
|
+
import { getChainedValue, TRANSLATION, SELECTED_LANG, CHANGE_LANG, SELECTED_THEME, CHANGE_THEME, CURRENT_DEVICE, deepEqual } from '@reforgium/internal';
|
|
4
4
|
import { BreakpointObserver } from '@angular/cdk/layout';
|
|
5
5
|
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -470,7 +470,7 @@ class LangService {
|
|
|
470
470
|
return text.replace(/\{\{(.*?)}}/g, (_, k) => String(params[k.trim()] ?? ''));
|
|
471
471
|
}
|
|
472
472
|
getChainedValue(query = '', source = this.#cache()) {
|
|
473
|
-
if (!query || typeof source !== 'object') {
|
|
473
|
+
if (!query || !source || typeof source !== 'object') {
|
|
474
474
|
return undefined;
|
|
475
475
|
}
|
|
476
476
|
// Prefer the exact (flat) key match first, then attempt deep lookup.
|
|
@@ -478,14 +478,20 @@ class LangService {
|
|
|
478
478
|
return source[query];
|
|
479
479
|
}
|
|
480
480
|
const parts = query.split('.');
|
|
481
|
-
|
|
482
|
-
for (
|
|
483
|
-
|
|
484
|
-
|
|
481
|
+
const record = source;
|
|
482
|
+
for (let i = parts.length - 1; i > 0; i--) {
|
|
483
|
+
const flatPrefix = parts.slice(0, i).join('.');
|
|
484
|
+
if (!(flatPrefix in record)) {
|
|
485
|
+
continue;
|
|
485
486
|
}
|
|
486
|
-
|
|
487
|
+
const nestedPath = parts.slice(i).join('.');
|
|
488
|
+
const prefixed = record[flatPrefix];
|
|
489
|
+
if (!nestedPath) {
|
|
490
|
+
return prefixed;
|
|
491
|
+
}
|
|
492
|
+
return getChainedValue(prefixed, nestedPath);
|
|
487
493
|
}
|
|
488
|
-
return
|
|
494
|
+
return getChainedValue(source, query);
|
|
489
495
|
}
|
|
490
496
|
getStoredLang() {
|
|
491
497
|
const normalize = (value) => this.normalizeLang(value);
|
|
@@ -1408,7 +1414,7 @@ class RouteWatcher {
|
|
|
1408
1414
|
constructor() {
|
|
1409
1415
|
const read = () => {
|
|
1410
1416
|
const snap = this.deepestSnapshot();
|
|
1411
|
-
const url =
|
|
1417
|
+
const url = snapshotFullPath(snap);
|
|
1412
1418
|
!deepEqual(snap.params, this.#params()) && this.#params.set(snap.params);
|
|
1413
1419
|
!deepEqual(snap.queryParams, this.#query()) && this.#query.set(snap.queryParams);
|
|
1414
1420
|
!deepEqual(snap.data, this.#data()) && this.#data.set(snap.data);
|
|
@@ -1443,6 +1449,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
1443
1449
|
function joinUrl(segments) {
|
|
1444
1450
|
return segments.length ? segments.map((s) => s.path).join('/') : '';
|
|
1445
1451
|
}
|
|
1452
|
+
/** Builds a full route path from root to current snapshot */
|
|
1453
|
+
function snapshotFullPath(snap) {
|
|
1454
|
+
return snap.pathFromRoot
|
|
1455
|
+
.map((s) => joinUrl(s.url))
|
|
1456
|
+
.filter(Boolean)
|
|
1457
|
+
.join('/');
|
|
1458
|
+
}
|
|
1446
1459
|
|
|
1447
1460
|
/**
|
|
1448
1461
|
* Generated bundle index. Do not edit.
|
package/package.json
CHANGED
|
@@ -322,7 +322,7 @@ declare class LangService {
|
|
|
322
322
|
* - If `config.kgValue` is not defined, the property will return the default value 'kg'.
|
|
323
323
|
* - For other languages (e.g. `ru`, `en`) returns source language as-is.
|
|
324
324
|
*/
|
|
325
|
-
readonly currentLang: Signal<"ru" | "kg" | "ky">;
|
|
325
|
+
readonly currentLang: Signal<"ru" | "kg" | "en" | (string & {}) | "ky">;
|
|
326
326
|
/**
|
|
327
327
|
* Extracts readonly value from private property `#lang` and assigns it to `innerLangVal`.
|
|
328
328
|
* Expected that property `#lang` has `asReadonly` method that returns immutable representation.
|