@jsverse/transloco 7.2.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/esm2022/index.mjs +3 -3
- package/esm2022/lib/transloco-missing-handler.mjs +5 -5
- package/esm2022/lib/transloco.directive.mjs +6 -11
- package/esm2022/lib/transloco.providers.mjs +3 -3
- package/esm2022/lib/transloco.service.mjs +7 -10
- package/fesm2022/jsverse-transloco.mjs +16 -25
- package/fesm2022/jsverse-transloco.mjs.map +1 -1
- package/index.d.ts +2 -2
- package/lib/transloco-missing-handler.d.ts +3 -3
- package/lib/transloco.directive.d.ts +1 -2
- package/lib/transloco.service.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, Injectable, Injector, Inject, Optional, Component, Input, TemplateRef, ChangeDetectorRef, ElementRef, ViewContainerRef, Renderer2, Directive, Pipe, NgModule, makeEnvironmentProviders, APP_INITIALIZER } from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, Injectable, Injector, Inject, Optional, Component, Input, TemplateRef, DestroyRef, ChangeDetectorRef, ElementRef, ViewContainerRef, Renderer2, Directive, Pipe, NgModule, makeEnvironmentProviders, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import { of, take, from, map, Subject, BehaviorSubject, forkJoin, retry, tap, catchError, shareReplay, switchMap, combineLatest, EMPTY } from 'rxjs';
|
|
4
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
5
|
import { unflatten as unflatten$1, flatten as flatten$1 } from 'flat';
|
|
5
6
|
|
|
6
7
|
class DefaultLoader {
|
|
@@ -295,7 +296,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImpor
|
|
|
295
296
|
}] });
|
|
296
297
|
|
|
297
298
|
const TRANSLOCO_MISSING_HANDLER = new InjectionToken('TRANSLOCO_MISSING_HANDLER');
|
|
298
|
-
class
|
|
299
|
+
class DefaultMissingHandler {
|
|
299
300
|
handle(key, config) {
|
|
300
301
|
if (config.missingHandler.logMissingKey && !config.prodMode) {
|
|
301
302
|
const msg = `Missing translation for '${key}'`;
|
|
@@ -303,10 +304,10 @@ class DefaultHandler {
|
|
|
303
304
|
}
|
|
304
305
|
return key;
|
|
305
306
|
}
|
|
306
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type:
|
|
307
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type:
|
|
307
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultMissingHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
308
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultMissingHandler });
|
|
308
309
|
}
|
|
309
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type:
|
|
310
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultMissingHandler, decorators: [{
|
|
310
311
|
type: Injectable
|
|
311
312
|
}] });
|
|
312
313
|
|
|
@@ -456,7 +457,6 @@ class TranslocoService {
|
|
|
456
457
|
interceptor;
|
|
457
458
|
fallbackStrategy;
|
|
458
459
|
langChanges$;
|
|
459
|
-
subscription = null;
|
|
460
460
|
translations = new Map();
|
|
461
461
|
cache = new Map();
|
|
462
462
|
firstFallbackLang;
|
|
@@ -489,7 +489,7 @@ class TranslocoService {
|
|
|
489
489
|
/**
|
|
490
490
|
* When we have a failure, we want to define the next language that succeeded as the active
|
|
491
491
|
*/
|
|
492
|
-
this.
|
|
492
|
+
this.events$.pipe(takeUntilDestroyed()).subscribe((e) => {
|
|
493
493
|
if (e.type === 'translationLoadSuccess' && e.wasFailure) {
|
|
494
494
|
this.setActiveLang(e.payload.langName);
|
|
495
495
|
}
|
|
@@ -604,7 +604,10 @@ class TranslocoService {
|
|
|
604
604
|
return this._handleMissingKey(key, value, params);
|
|
605
605
|
}
|
|
606
606
|
return this.parser.transpile({
|
|
607
|
-
value,
|
|
607
|
+
value,
|
|
608
|
+
params,
|
|
609
|
+
translation,
|
|
610
|
+
key,
|
|
608
611
|
});
|
|
609
612
|
}
|
|
610
613
|
/**
|
|
@@ -854,12 +857,6 @@ class TranslocoService {
|
|
|
854
857
|
this.config.scopeMapping[scope] = alias;
|
|
855
858
|
}
|
|
856
859
|
ngOnDestroy() {
|
|
857
|
-
if (this.subscription) {
|
|
858
|
-
this.subscription.unsubscribe();
|
|
859
|
-
// Caretaker note: it's important to clean up references to subscriptions since they save the `next`
|
|
860
|
-
// callback within its `destination` property, preventing classes from being GC'd.
|
|
861
|
-
this.subscription = null;
|
|
862
|
-
}
|
|
863
860
|
// Caretaker note: since this is the root provider, it'll be destroyed when the `NgModuleRef.destroy()` is run.
|
|
864
861
|
// Cached values capture `this`, thus leading to a circular reference and preventing the `TranslocoService` from
|
|
865
862
|
// being GC'd. This would lead to a memory leak when server-side rendering is used since the service is created
|
|
@@ -1135,6 +1132,7 @@ class ScopeResolver {
|
|
|
1135
1132
|
}
|
|
1136
1133
|
|
|
1137
1134
|
class TranslocoDirective {
|
|
1135
|
+
destroyRef = inject(DestroyRef);
|
|
1138
1136
|
service = inject(TranslocoService);
|
|
1139
1137
|
tpl = inject(TemplateRef, {
|
|
1140
1138
|
optional: true,
|
|
@@ -1148,7 +1146,6 @@ class TranslocoDirective {
|
|
|
1148
1146
|
host = inject(ElementRef);
|
|
1149
1147
|
vcr = inject(ViewContainerRef);
|
|
1150
1148
|
renderer = inject(Renderer2);
|
|
1151
|
-
subscription = null;
|
|
1152
1149
|
view;
|
|
1153
1150
|
memo = new Map();
|
|
1154
1151
|
key;
|
|
@@ -1172,7 +1169,7 @@ class TranslocoDirective {
|
|
|
1172
1169
|
}
|
|
1173
1170
|
ngOnInit() {
|
|
1174
1171
|
const listenToLangChange = shouldListenToLangChanges(this.service, this.providerLang || this.inlineLang);
|
|
1175
|
-
this.
|
|
1172
|
+
this.service.langChanges$
|
|
1176
1173
|
.pipe(switchMap((activeLang) => {
|
|
1177
1174
|
const lang = this.langResolver.resolve({
|
|
1178
1175
|
inline: this.inlineLang,
|
|
@@ -1182,7 +1179,7 @@ class TranslocoDirective {
|
|
|
1182
1179
|
return Array.isArray(this.providerScope)
|
|
1183
1180
|
? forkJoin(this.providerScope.map((providerScope) => this.resolveScope(lang, providerScope)))
|
|
1184
1181
|
: this.resolveScope(lang, this.providerScope);
|
|
1185
|
-
}), listenOrNotOperator(listenToLangChange))
|
|
1182
|
+
}), listenOrNotOperator(listenToLangChange), takeUntilDestroyed(this.destroyRef))
|
|
1186
1183
|
.subscribe(() => {
|
|
1187
1184
|
this.currentLang = this.langResolver.resolveLangBasedOnScope(this.path);
|
|
1188
1185
|
this.strategy === 'attribute'
|
|
@@ -1244,12 +1241,6 @@ class TranslocoDirective {
|
|
|
1244
1241
|
}
|
|
1245
1242
|
ngOnDestroy() {
|
|
1246
1243
|
this.memo.clear();
|
|
1247
|
-
if (this.subscription) {
|
|
1248
|
-
this.subscription.unsubscribe();
|
|
1249
|
-
// Caretaker note: it's important to clean up references to subscriptions since they save the `next`
|
|
1250
|
-
// callback within its `destination` property, preventing classes from being GC'd.
|
|
1251
|
-
this.subscription = null;
|
|
1252
|
-
}
|
|
1253
1244
|
}
|
|
1254
1245
|
detachLoader() {
|
|
1255
1246
|
this.loaderTplHandler?.detachView();
|
|
@@ -1399,7 +1390,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImpor
|
|
|
1399
1390
|
function provideTransloco(options) {
|
|
1400
1391
|
const providers = [
|
|
1401
1392
|
provideTranslocoTranspiler(DefaultTranspiler),
|
|
1402
|
-
provideTranslocoMissingHandler(
|
|
1393
|
+
provideTranslocoMissingHandler(DefaultMissingHandler),
|
|
1403
1394
|
provideTranslocoInterceptor(DefaultInterceptor),
|
|
1404
1395
|
provideTranslocoFallbackStrategy(DefaultFallbackStrategy),
|
|
1405
1396
|
];
|
|
@@ -1579,5 +1570,5 @@ function getBrowserCultureLang() {
|
|
|
1579
1570
|
* Generated bundle index. Do not edit.
|
|
1580
1571
|
*/
|
|
1581
1572
|
|
|
1582
|
-
export { DefaultFallbackStrategy, DefaultTranspiler, FunctionalTranspiler, TRANSLOCO_CONFIG, TRANSLOCO_FALLBACK_STRATEGY, TRANSLOCO_INTERCEPTOR, TRANSLOCO_LANG, TRANSLOCO_LOADER, TRANSLOCO_LOADING_TEMPLATE, TRANSLOCO_MISSING_HANDLER, TRANSLOCO_SCOPE, TRANSLOCO_TRANSPILER, TestingLoader, TranslocoDirective, TranslocoModule, TranslocoPipe, TranslocoService, TranslocoTestingModule, coerceArray, defaultConfig, flatten, getBrowserCultureLang, getBrowserLang, getFunctionArgs, getLangFromScope, getPipeValue, getScopeFromLang, getValue, hasInlineLoader, isBrowser, isDefined, isEmpty, isFunction, isNil, isNumber, isObject, isScopeArray, isScopeObject, isString, provideTransloco, provideTranslocoConfig, provideTranslocoFallbackStrategy, provideTranslocoInterceptor, provideTranslocoLang, provideTranslocoLoader, provideTranslocoLoadingTpl, provideTranslocoMissingHandler, provideTranslocoScope, provideTranslocoTranspiler, setValue, size, toCamelCase, toNumber, translate, translateObject, translocoConfig, unflatten };
|
|
1573
|
+
export { DefaultFallbackStrategy, DefaultInterceptor, DefaultMissingHandler, DefaultTranspiler, FunctionalTranspiler, TRANSLOCO_CONFIG, TRANSLOCO_FALLBACK_STRATEGY, TRANSLOCO_INTERCEPTOR, TRANSLOCO_LANG, TRANSLOCO_LOADER, TRANSLOCO_LOADING_TEMPLATE, TRANSLOCO_MISSING_HANDLER, TRANSLOCO_SCOPE, TRANSLOCO_TRANSPILER, TestingLoader, TranslocoDirective, TranslocoModule, TranslocoPipe, TranslocoService, TranslocoTestingModule, coerceArray, defaultConfig, flatten, getBrowserCultureLang, getBrowserLang, getFunctionArgs, getLangFromScope, getPipeValue, getScopeFromLang, getValue, hasInlineLoader, isBrowser, isDefined, isEmpty, isFunction, isNil, isNumber, isObject, isScopeArray, isScopeObject, isString, provideTransloco, provideTranslocoConfig, provideTranslocoFallbackStrategy, provideTranslocoInterceptor, provideTranslocoLang, provideTranslocoLoader, provideTranslocoLoadingTpl, provideTranslocoMissingHandler, provideTranslocoScope, provideTranslocoTranspiler, setValue, size, toCamelCase, toNumber, translate, translateObject, translocoConfig, unflatten };
|
|
1583
1574
|
//# sourceMappingURL=jsverse-transloco.mjs.map
|