@tolgee/core 4.4.0 → 4.5.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.
@@ -699,7 +699,7 @@ var TranslationService = /** @class */ (function () {
699
699
  return TranslationService.translationByValue(message, defaultValue);
700
700
  };
701
701
  TranslationService.prototype.isFetchNeeded = function (lang) {
702
- var isDevMode = this.properties.config.mode === 'development';
702
+ var isDevMode = this.properties.mode === 'development';
703
703
  var dataPresent = this.translationsCache.get(lang) !== undefined;
704
704
  var devFetched = Boolean(this.fetchedDev[lang]);
705
705
  return (isDevMode && !devFetched) || !dataPresent;
@@ -710,7 +710,7 @@ var TranslationService = /** @class */ (function () {
710
710
  return __generator(this, function (_a) {
711
711
  switch (_a.label) {
712
712
  case 0:
713
- isDevMode = this.properties.config.mode === 'development';
713
+ isDevMode = this.properties.mode === 'development';
714
714
  if (!isDevMode) return [3 /*break*/, 2];
715
715
  return [4 /*yield*/, this.fetchTranslationsDevelopment(lang)];
716
716
  case 1: return [2 /*return*/, _a.sent()];
@@ -1309,7 +1309,7 @@ var ElementRegistrar = /** @class */ (function () {
1309
1309
  !element._tolgee.wrappedWithElementOnlyKey) {
1310
1310
  return;
1311
1311
  }
1312
- if (this.properties.config.mode === 'development' &&
1312
+ if (this.properties.mode === 'development' &&
1313
1313
  !this.registeredElements.has(element)) {
1314
1314
  this.translationHighlighter.listen(element);
1315
1315
  }
@@ -1600,7 +1600,7 @@ var CoreService = /** @class */ (function () {
1600
1600
  console.error(e_1);
1601
1601
  // eslint-disable-next-line no-console
1602
1602
  console.error('Error getting scopes. Trying to switch to production mode!');
1603
- this.properties.config.mode = 'production';
1603
+ this.properties.mode = 'production';
1604
1604
  return [3 /*break*/, 3];
1605
1605
  case 3: return [2 /*return*/];
1606
1606
  }
@@ -1707,10 +1707,9 @@ var TolgeeConfig = /** @class */ (function () {
1707
1707
  if (this._targetElement === undefined) {
1708
1708
  this._targetElement = DEFAULT_TARGET_ELEMENT_SUPPLIER();
1709
1709
  }
1710
- this.mode = this.mode || (this.apiKey ? 'development' : 'production');
1711
1710
  this.fallbackLanguage = this.fallbackLanguage || this.defaultLanguage;
1712
1711
  if (this.watch === undefined) {
1713
- this.watch = this.mode === 'development';
1712
+ this.watch = Boolean(this.apiKey && this.apiUrl);
1714
1713
  }
1715
1714
  if (this.availableLanguages === undefined && this.staticData) {
1716
1715
  this.availableLanguages = Object.keys(this.staticData);
@@ -1772,7 +1771,7 @@ var PluginManager = /** @class */ (function () {
1772
1771
  this.handshake = function () {
1773
1772
  var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
1774
1773
  //remove properties, which cannot be sent by window.postMessage
1775
- staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.4.0" });
1774
+ staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.5.0" });
1776
1775
  var timer = null;
1777
1776
  var ping = function () {
1778
1777
  _this.messages.send('TOLGEE_READY', sharedConfiguration);
@@ -3085,6 +3084,9 @@ var Tolgee = /** @class */ (function () {
3085
3084
  };
3086
3085
  Tolgee.prototype.init = function (config) {
3087
3086
  this.dependencyService.init(config);
3087
+ var _a = this.dependencyService.properties.config, apiKey = _a.apiKey, apiUrl = _a.apiUrl;
3088
+ this.dependencyService.properties.mode =
3089
+ apiKey && apiUrl ? 'development' : 'production';
3088
3090
  return this;
3089
3091
  };
3090
3092
  Tolgee.prototype.run = function () {
@@ -3094,7 +3096,7 @@ var Tolgee = /** @class */ (function () {
3094
3096
  switch (_a.label) {
3095
3097
  case 0:
3096
3098
  this.dependencyService.run();
3097
- if (!(this.properties.config.mode === 'development')) return [3 /*break*/, 4];
3099
+ if (!(this.properties.mode === 'development')) return [3 /*break*/, 4];
3098
3100
  _a.label = 1;
3099
3101
  case 1:
3100
3102
  _a.trys.push([1, 3, , 4]);
@@ -3105,10 +3107,10 @@ var Tolgee = /** @class */ (function () {
3105
3107
  case 3:
3106
3108
  e_1 = _a.sent();
3107
3109
  // eslint-disable-next-line no-console
3108
- console.error("Couldn't connect to tolgee");
3110
+ console.error("Couldn't connect to Tolgee");
3109
3111
  // eslint-disable-next-line no-console
3110
3112
  console.error(e_1);
3111
- this.properties.config.mode = 'production';
3113
+ this.properties.mode = 'production';
3112
3114
  return [3 /*break*/, 4];
3113
3115
  case 4: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations()];
3114
3116
  case 5:
@@ -3163,7 +3165,7 @@ var Tolgee = /** @class */ (function () {
3163
3165
  return [4 /*yield*/, this.dependencyService.textService.translate(key, params, undefined, orEmpty, defaultValue)];
3164
3166
  case 1:
3165
3167
  translation = _a.sent();
3166
- if (!(this.properties.config.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
3168
+ if (!(this.properties.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
3167
3169
  return [4 /*yield*/, this.coreService.loadApiKeyDetails()];
3168
3170
  case 2:
3169
3171
  _a.sent();
@@ -3174,7 +3176,7 @@ var Tolgee = /** @class */ (function () {
3174
3176
  });
3175
3177
  };
3176
3178
  Tolgee.prototype.wrap = function (key, params, defaultValue, translation) {
3177
- if (this.properties.config.mode === 'development') {
3179
+ if (this.properties.mode === 'development') {
3178
3180
  return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
3179
3181
  }
3180
3182
  else {
@@ -3196,7 +3198,7 @@ var Tolgee = /** @class */ (function () {
3196
3198
  orEmpty = props.orEmpty !== undefined ? props.orEmpty : orEmpty;
3197
3199
  }
3198
3200
  var translation = this.dependencyService.textService.instant(key, params, undefined, orEmpty, defaultValue);
3199
- if (this.properties.config.mode === 'development' && !noWrap) {
3201
+ if (this.properties.mode === 'development' && !noWrap) {
3200
3202
  return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
3201
3203
  }
3202
3204
  return translation;