@tolgee/core 4.3.0-rc.6d9042d.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.
- package/dist/tolgee.cjs.js +16 -13
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/tolgee.esm.js +1 -1
- package/dist/tolgee.esm.js.map +1 -1
- package/dist/tolgee.umd.js +16 -13
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +1 -1
- package/dist/tolgee.umd.min.js.map +1 -1
- package/lib/Constants/Global.d.ts +0 -0
- package/lib/Constants/ModifierKey.d.ts +0 -0
- package/lib/Errors/ApiHttpError.d.ts +0 -0
- package/lib/Observer.d.ts +0 -0
- package/lib/Properties.d.ts +3 -1
- package/lib/Tolgee.d.ts +0 -0
- package/lib/TolgeeConfig.d.ts +7 -1
- package/lib/helpers/NodeHelper.d.ts +0 -0
- package/lib/helpers/TextHelper.d.ts +0 -0
- package/lib/helpers/commonTypes.d.ts +0 -0
- package/lib/helpers/encoderPolyfill.d.ts +0 -0
- package/lib/helpers/secret.d.ts +0 -0
- package/lib/helpers/sleep.d.ts +0 -0
- package/lib/highlighter/HighlightFunctionsInitializer.d.ts +0 -0
- package/lib/highlighter/MouseEventHandler.d.ts +0 -0
- package/lib/highlighter/TranslationHighlighter.d.ts +0 -0
- package/lib/index.d.ts +0 -0
- package/lib/modules/IcuFormatter.d.ts +0 -0
- package/lib/modules/index.d.ts +0 -0
- package/lib/services/ApiHttpService.d.ts +0 -0
- package/lib/services/CoreService.d.ts +2 -2
- package/lib/services/DependencyService.d.ts +0 -0
- package/lib/services/ElementRegistrar.d.ts +0 -0
- package/lib/services/EventEmitter.d.ts +0 -0
- package/lib/services/EventService.d.ts +0 -0
- package/lib/services/ModuleService.d.ts +0 -0
- package/lib/services/ScreenshotService.d.ts +0 -0
- package/lib/services/Subscription.d.ts +0 -0
- package/lib/services/TextService.d.ts +0 -0
- package/lib/services/TranslationService.d.ts +1 -0
- package/lib/toolsManager/Messages.d.ts +0 -0
- package/lib/toolsManager/PluginManager.d.ts +0 -0
- package/lib/types/DTOs.d.ts +0 -0
- package/lib/types/apiSchema.generated.d.ts +2129 -969
- package/lib/types.d.ts +0 -0
- package/lib/wrappers/AbstractWrapper.d.ts +0 -0
- package/lib/wrappers/NodeHandler.d.ts +0 -0
- package/lib/wrappers/WrappedHandler.d.ts +0 -0
- package/lib/wrappers/invisible/AttributeHandler.d.ts +0 -0
- package/lib/wrappers/invisible/Coder.d.ts +0 -0
- package/lib/wrappers/invisible/ContentHandler.d.ts +0 -0
- package/lib/wrappers/invisible/CoreHandler.d.ts +0 -0
- package/lib/wrappers/invisible/InvisibleWrapper.d.ts +0 -0
- package/lib/wrappers/invisible/ValueMemory.d.ts +0 -0
- package/lib/wrappers/text/AttributeHandler.d.ts +0 -0
- package/lib/wrappers/text/Coder.d.ts +0 -0
- package/lib/wrappers/text/ContentHandler.d.ts +0 -0
- package/lib/wrappers/text/CoreHandler.d.ts +0 -0
- package/lib/wrappers/text/TextWrapper.d.ts +0 -0
- package/package.json +5 -5
package/dist/tolgee.cjs.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
1603
|
+
this.properties.mode = 'production';
|
|
1604
1604
|
return [3 /*break*/, 3];
|
|
1605
1605
|
case 3: return [2 /*return*/];
|
|
1606
1606
|
}
|
|
@@ -1627,6 +1627,7 @@ var CoreService = /** @class */ (function () {
|
|
|
1627
1627
|
details = _a.sent();
|
|
1628
1628
|
this.properties.scopes = details.scopes;
|
|
1629
1629
|
this.properties.projectId = details.projectId;
|
|
1630
|
+
this.properties.permittedLanguageIds = details.permittedLanguageIds;
|
|
1630
1631
|
_a.label = 2;
|
|
1631
1632
|
case 2: return [2 /*return*/];
|
|
1632
1633
|
}
|
|
@@ -1706,10 +1707,9 @@ var TolgeeConfig = /** @class */ (function () {
|
|
|
1706
1707
|
if (this._targetElement === undefined) {
|
|
1707
1708
|
this._targetElement = DEFAULT_TARGET_ELEMENT_SUPPLIER();
|
|
1708
1709
|
}
|
|
1709
|
-
this.mode = this.mode || (this.apiKey ? 'development' : 'production');
|
|
1710
1710
|
this.fallbackLanguage = this.fallbackLanguage || this.defaultLanguage;
|
|
1711
1711
|
if (this.watch === undefined) {
|
|
1712
|
-
this.watch = this.
|
|
1712
|
+
this.watch = Boolean(this.apiKey && this.apiUrl);
|
|
1713
1713
|
}
|
|
1714
1714
|
if (this.availableLanguages === undefined && this.staticData) {
|
|
1715
1715
|
this.availableLanguages = Object.keys(this.staticData);
|
|
@@ -1771,7 +1771,7 @@ var PluginManager = /** @class */ (function () {
|
|
|
1771
1771
|
this.handshake = function () {
|
|
1772
1772
|
var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
|
|
1773
1773
|
//remove properties, which cannot be sent by window.postMessage
|
|
1774
|
-
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.
|
|
1774
|
+
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.5.0" });
|
|
1775
1775
|
var timer = null;
|
|
1776
1776
|
var ping = function () {
|
|
1777
1777
|
_this.messages.send('TOLGEE_READY', sharedConfiguration);
|
|
@@ -3084,6 +3084,9 @@ var Tolgee = /** @class */ (function () {
|
|
|
3084
3084
|
};
|
|
3085
3085
|
Tolgee.prototype.init = function (config) {
|
|
3086
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';
|
|
3087
3090
|
return this;
|
|
3088
3091
|
};
|
|
3089
3092
|
Tolgee.prototype.run = function () {
|
|
@@ -3093,7 +3096,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3093
3096
|
switch (_a.label) {
|
|
3094
3097
|
case 0:
|
|
3095
3098
|
this.dependencyService.run();
|
|
3096
|
-
if (!(this.properties.
|
|
3099
|
+
if (!(this.properties.mode === 'development')) return [3 /*break*/, 4];
|
|
3097
3100
|
_a.label = 1;
|
|
3098
3101
|
case 1:
|
|
3099
3102
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -3104,10 +3107,10 @@ var Tolgee = /** @class */ (function () {
|
|
|
3104
3107
|
case 3:
|
|
3105
3108
|
e_1 = _a.sent();
|
|
3106
3109
|
// eslint-disable-next-line no-console
|
|
3107
|
-
console.error("Couldn't connect to
|
|
3110
|
+
console.error("Couldn't connect to Tolgee");
|
|
3108
3111
|
// eslint-disable-next-line no-console
|
|
3109
3112
|
console.error(e_1);
|
|
3110
|
-
this.properties.
|
|
3113
|
+
this.properties.mode = 'production';
|
|
3111
3114
|
return [3 /*break*/, 4];
|
|
3112
3115
|
case 4: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations()];
|
|
3113
3116
|
case 5:
|
|
@@ -3162,7 +3165,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3162
3165
|
return [4 /*yield*/, this.dependencyService.textService.translate(key, params, undefined, orEmpty, defaultValue)];
|
|
3163
3166
|
case 1:
|
|
3164
3167
|
translation = _a.sent();
|
|
3165
|
-
if (!(this.properties.
|
|
3168
|
+
if (!(this.properties.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
|
|
3166
3169
|
return [4 /*yield*/, this.coreService.loadApiKeyDetails()];
|
|
3167
3170
|
case 2:
|
|
3168
3171
|
_a.sent();
|
|
@@ -3173,7 +3176,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3173
3176
|
});
|
|
3174
3177
|
};
|
|
3175
3178
|
Tolgee.prototype.wrap = function (key, params, defaultValue, translation) {
|
|
3176
|
-
if (this.properties.
|
|
3179
|
+
if (this.properties.mode === 'development') {
|
|
3177
3180
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3178
3181
|
}
|
|
3179
3182
|
else {
|
|
@@ -3195,7 +3198,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3195
3198
|
orEmpty = props.orEmpty !== undefined ? props.orEmpty : orEmpty;
|
|
3196
3199
|
}
|
|
3197
3200
|
var translation = this.dependencyService.textService.instant(key, params, undefined, orEmpty, defaultValue);
|
|
3198
|
-
if (this.properties.
|
|
3201
|
+
if (this.properties.mode === 'development' && !noWrap) {
|
|
3199
3202
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3200
3203
|
}
|
|
3201
3204
|
return translation;
|