monkey-front-core 0.0.439 → 0.0.440

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.
@@ -3307,6 +3307,56 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3307
3307
  this.translateService.setDefaultLang('pt-BR');
3308
3308
  this.translateService.use('pt-BR');
3309
3309
  }
3310
+ async applyWithSync(params, environment, change = false, call) {
3311
+ const { monkeyecxService, monkeyecxCookieStorageService, monkeyecxErrorConfigService } = this;
3312
+ let { i18n } = params;
3313
+ const currentExternali18n = params?.externali18n?.[`${i18n?.lang || 'pt-BR'}`];
3314
+ const cookie = monkeyecxCookieStorageService.getCookie('monkey-app-locale');
3315
+ if (cookie && !change) {
3316
+ i18n = JSON.parse(atob(cookie));
3317
+ }
3318
+ else {
3319
+ monkeyecxCookieStorageService.setCookie('monkey-app-locale', btoa(JSON.stringify(i18n)), environment);
3320
+ }
3321
+ try {
3322
+ const externali18nPaths = params?.i18n?.paths || [];
3323
+ const services = externali18nPaths?.map((url) => {
3324
+ return monkeyecxService?.get(`${url}/${i18n?.lang}.json`).pipe(take(1)).toPromise();
3325
+ });
3326
+ if (!services?.length)
3327
+ return;
3328
+ const externali18nData = await Promise.all(services);
3329
+ externali18nData?.forEach((config) => {
3330
+ const { lang } = config;
3331
+ const { data } = config;
3332
+ this.translateService.setTranslation('pt-BR', data, true);
3333
+ this.translateService.setTranslation(lang, data, true);
3334
+ });
3335
+ }
3336
+ catch (err) {
3337
+ // not to do
3338
+ }
3339
+ try {
3340
+ const currenti18n = await monkeyecxService?.get(`${environment.localAssets}/i18n/${i18n?.lang}.json`).pipe(take(1)).toPromise();
3341
+ const { lang } = currenti18n;
3342
+ let { data } = currenti18n;
3343
+ if (currentExternali18n) {
3344
+ data = {
3345
+ ...data,
3346
+ EXTERNAL: currentExternali18n
3347
+ };
3348
+ }
3349
+ this.translateService.setTranslation('pt-BR', data, true);
3350
+ this.translateService.setTranslation(lang, data, true);
3351
+ this.translateService.use(lang);
3352
+ }
3353
+ catch (err) {
3354
+ console.error(`i18n ${i18n?.lang} not found!`);
3355
+ monkeyecxErrorConfigService.apply('i18n');
3356
+ throwError(err);
3357
+ }
3358
+ call?.();
3359
+ }
3310
3360
  async apply(params, environment, change = false) {
3311
3361
  const { monkeyecxService, monkeyecxCookieStorageService, monkeyecxErrorConfigService } = this;
3312
3362
  let { i18n } = params;
@@ -3359,6 +3409,16 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3359
3409
  }
3360
3410
  MonkeyEcxi18nConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, deps: [{ token: MonkeyEcxService }, { token: i1$1.TranslateService }, { token: MonkeyEcxCookieStorageService }, { token: MonkeyEcxErrorConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
3361
3411
  MonkeyEcxi18nConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, providedIn: 'root' });
3412
+ __decorate([
3413
+ MonkeyEcxCoreService({
3414
+ httpResponse: {
3415
+ httpCodeIgnore: [404]
3416
+ },
3417
+ requestInProgress: {
3418
+ showProgress: false
3419
+ }
3420
+ })
3421
+ ], MonkeyEcxi18nConfigService.prototype, "applyWithSync", null);
3362
3422
  __decorate([
3363
3423
  MonkeyEcxCoreService({
3364
3424
  httpResponse: {
@@ -3374,7 +3434,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
3374
3434
  args: [{
3375
3435
  providedIn: 'root'
3376
3436
  }]
3377
- }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: { apply: [] } });
3437
+ }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: { applyWithSync: [], apply: [] } });
3378
3438
 
3379
3439
  class MonkeyEcxLogsConfigService {
3380
3440
  apply(params, configBootstrap, environment, identifyCode) {
@@ -3702,11 +3762,13 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
3702
3762
  const callback = args[1];
3703
3763
  const environment = args[2];
3704
3764
  const config = args[3];
3705
- await monkeyecxi18nConfigService.apply(config, environment);
3706
- monkeyecxSecurityConsoleConfigService.apply();
3707
- monkeyecxServiceWorkerConfigService.apply(configBootstrap);
3708
- monkeyecxMaintenanceConfigService.apply(configBootstrap);
3709
- callback(configBootstrap);
3765
+ const call = () => {
3766
+ monkeyecxSecurityConsoleConfigService.apply();
3767
+ monkeyecxServiceWorkerConfigService.apply(configBootstrap);
3768
+ monkeyecxMaintenanceConfigService.apply(configBootstrap);
3769
+ callback(configBootstrap);
3770
+ };
3771
+ await monkeyecxi18nConfigService.applyWithSync(config, environment, false, call);
3710
3772
  }
3711
3773
  getWhiteLabelSettings(monkeyecxCode, configBootstrap, callback, environment, identifyCode) {
3712
3774
  const { monkeyecxService, configSubject$, monkeyStyleGuideSettingsService, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyGTMConfigService, monkeyEcxAlertsConfigService, internalValidations } = this;