@tolgee/core 4.4.0 → 4.6.0-rc.6a7caf3.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 +116 -109
- 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 +116 -109
- 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 +2 -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 +1 -0
- package/lib/highlighter/MouseEventHandler.d.ts +7 -12
- package/lib/highlighter/TranslationHighlighter.d.ts +1 -1
- 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 +0 -0
- 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 +0 -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 +0 -0
- package/lib/types.d.ts +1 -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.umd.js
CHANGED
|
@@ -701,7 +701,7 @@
|
|
|
701
701
|
return TranslationService.translationByValue(message, defaultValue);
|
|
702
702
|
};
|
|
703
703
|
TranslationService.prototype.isFetchNeeded = function (lang) {
|
|
704
|
-
var isDevMode = this.properties.
|
|
704
|
+
var isDevMode = this.properties.mode === 'development';
|
|
705
705
|
var dataPresent = this.translationsCache.get(lang) !== undefined;
|
|
706
706
|
var devFetched = Boolean(this.fetchedDev[lang]);
|
|
707
707
|
return (isDevMode && !devFetched) || !dataPresent;
|
|
@@ -712,7 +712,7 @@
|
|
|
712
712
|
return __generator(this, function (_a) {
|
|
713
713
|
switch (_a.label) {
|
|
714
714
|
case 0:
|
|
715
|
-
isDevMode = this.properties.
|
|
715
|
+
isDevMode = this.properties.mode === 'development';
|
|
716
716
|
if (!isDevMode) return [3 /*break*/, 2];
|
|
717
717
|
return [4 /*yield*/, this.fetchTranslationsDevelopment(lang)];
|
|
718
718
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -915,42 +915,35 @@
|
|
|
915
915
|
ModifierKey[ModifierKey["Meta"] = 3] = "Meta";
|
|
916
916
|
})(exports.ModifierKey || (exports.ModifierKey = {}));
|
|
917
917
|
|
|
918
|
+
var eCapture = {
|
|
919
|
+
capture: true,
|
|
920
|
+
};
|
|
918
921
|
var MouseEventHandler = /** @class */ (function () {
|
|
919
|
-
function MouseEventHandler(
|
|
922
|
+
function MouseEventHandler(dependencies) {
|
|
920
923
|
var _this = this;
|
|
921
|
-
this.
|
|
924
|
+
this.dependencies = dependencies;
|
|
922
925
|
this.keysDown = new Set();
|
|
923
|
-
this.mouseOn = new Set();
|
|
924
926
|
this.mouseOnChanged = new EventEmitterImpl();
|
|
925
927
|
this.keysChanged = new EventEmitterImpl();
|
|
926
|
-
this.
|
|
927
|
-
_this.
|
|
928
|
-
|
|
929
|
-
|
|
928
|
+
this.highlight = function (el) {
|
|
929
|
+
if (_this.highlighted !== el) {
|
|
930
|
+
_this.unhighlight();
|
|
931
|
+
if (el) {
|
|
932
|
+
el._tolgee.preventClean = true;
|
|
933
|
+
el._tolgee.highlight();
|
|
934
|
+
_this.highlighted = el;
|
|
935
|
+
_this.mouseOnChanged.emit(el);
|
|
936
|
+
}
|
|
930
937
|
}
|
|
931
938
|
};
|
|
932
|
-
this.highlight = function () {
|
|
933
|
-
_this.getMouseOn()._tolgee.highlight();
|
|
934
|
-
_this.highlighted = _this.getMouseOn();
|
|
935
|
-
};
|
|
936
939
|
this.unhighlight = function () {
|
|
937
940
|
if (_this.highlighted) {
|
|
941
|
+
_this.highlighted._tolgee.preventClean = false;
|
|
938
942
|
_this.highlighted._tolgee.unhighlight();
|
|
939
|
-
_this.highlighted =
|
|
943
|
+
_this.highlighted = undefined;
|
|
944
|
+
_this.mouseOnChanged.emit(_this.highlighted);
|
|
940
945
|
}
|
|
941
946
|
};
|
|
942
|
-
this.onMouseOut = function (element) {
|
|
943
|
-
element._tolgee.preventClean = false;
|
|
944
|
-
_this.mouseOn.delete(element);
|
|
945
|
-
_this.mouseOnChanged.emit(_this.getMouseOn());
|
|
946
|
-
};
|
|
947
|
-
this.onMouseOver = function (element) {
|
|
948
|
-
_this.filterMouseOn();
|
|
949
|
-
element._tolgee.preventClean = true;
|
|
950
|
-
_this.mouseOn.delete(element); //to get in to last place
|
|
951
|
-
_this.mouseOn.add(element);
|
|
952
|
-
_this.mouseOnChanged.emit(_this.getMouseOn());
|
|
953
|
-
};
|
|
954
947
|
}
|
|
955
948
|
MouseEventHandler.prototype.run = function () {
|
|
956
949
|
if (typeof window !== 'undefined') {
|
|
@@ -958,88 +951,81 @@
|
|
|
958
951
|
return;
|
|
959
952
|
}
|
|
960
953
|
};
|
|
961
|
-
MouseEventHandler.prototype.
|
|
962
|
-
var
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
return;
|
|
954
|
+
MouseEventHandler.prototype.updateHighlight = function () {
|
|
955
|
+
var position = this.cursorPosition;
|
|
956
|
+
var newHighlighted;
|
|
957
|
+
if (position && this.areKeysDown()) {
|
|
958
|
+
newHighlighted = this.getClosestTolgeeElement(document.elementFromPoint(position.x, position.y));
|
|
967
959
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
this.keysChanged.subscribe(function () {
|
|
976
|
-
_this.onConditionsChanged();
|
|
977
|
-
});
|
|
960
|
+
this.highlight(newHighlighted);
|
|
961
|
+
};
|
|
962
|
+
MouseEventHandler.prototype.updateCursorPosition = function (position) {
|
|
963
|
+
this.cursorPosition = position;
|
|
964
|
+
this.updateHighlight();
|
|
978
965
|
};
|
|
979
|
-
MouseEventHandler.prototype.
|
|
966
|
+
MouseEventHandler.prototype.initKeyListener = function () {
|
|
980
967
|
var _this = this;
|
|
981
|
-
var
|
|
982
|
-
var onMouseOut = function () { return _this.onMouseOut(element); };
|
|
983
|
-
var onClick = function (e) {
|
|
984
|
-
if (_this.areKeysDown() && _this.highlighted === e.currentTarget) {
|
|
985
|
-
e.stopPropagation();
|
|
986
|
-
e.preventDefault();
|
|
987
|
-
onclick(e);
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
element.addEventListener('mouseover', onMouseOver);
|
|
991
|
-
element.addEventListener('click', onClick, { capture: true });
|
|
992
|
-
var onMouseDownOrUp = function (e) {
|
|
968
|
+
var defaultEventBlock = function (e) {
|
|
993
969
|
if (_this.areKeysDown()) {
|
|
994
970
|
e.stopPropagation();
|
|
995
971
|
e.preventDefault();
|
|
996
972
|
}
|
|
997
973
|
};
|
|
998
|
-
|
|
999
|
-
element.addEventListener('mouseup', onMouseDownOrUp);
|
|
1000
|
-
element.addEventListener('mouseout', onMouseOut);
|
|
1001
|
-
element._tolgee.removeAllEventListeners = function () {
|
|
1002
|
-
element.removeEventListener('mousedown', onMouseDownOrUp);
|
|
1003
|
-
element.removeEventListener('mouseup', onMouseDownOrUp);
|
|
1004
|
-
element.removeEventListener('mouseover', onMouseOver);
|
|
1005
|
-
element.removeEventListener('click', onClick, { capture: true });
|
|
1006
|
-
element.removeEventListener('mouseout', onMouseOut);
|
|
1007
|
-
};
|
|
1008
|
-
};
|
|
1009
|
-
MouseEventHandler.prototype.getMouseOn = function () {
|
|
1010
|
-
var mouseOnArray = Array.from(this.mouseOn);
|
|
1011
|
-
return mouseOnArray.length ? mouseOnArray[0] : undefined;
|
|
1012
|
-
};
|
|
1013
|
-
MouseEventHandler.prototype.initKeyListener = function () {
|
|
1014
|
-
var _this = this;
|
|
1015
|
-
window.addEventListener('blur', function () {
|
|
974
|
+
document.addEventListener('blur', function () {
|
|
1016
975
|
_this.keysDown = new Set();
|
|
1017
976
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1018
|
-
|
|
1019
|
-
|
|
977
|
+
_this.updateHighlight();
|
|
978
|
+
}, eCapture);
|
|
979
|
+
document.addEventListener('keydown', function (e) {
|
|
1020
980
|
var modifierKey = exports.ModifierKey[e.key];
|
|
1021
981
|
if (modifierKey !== undefined) {
|
|
1022
982
|
_this.keysDown.add(modifierKey);
|
|
1023
983
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1024
984
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
985
|
+
_this.updateHighlight();
|
|
986
|
+
}, eCapture);
|
|
987
|
+
document.addEventListener('keyup', function (e) {
|
|
1027
988
|
_this.keysDown.delete(exports.ModifierKey[e.key]);
|
|
1028
989
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
990
|
+
_this.updateHighlight();
|
|
991
|
+
}, eCapture);
|
|
992
|
+
document.addEventListener('mousemove', function (e) {
|
|
993
|
+
_this.updateCursorPosition({ x: e.clientX, y: e.clientY });
|
|
994
|
+
}, { passive: true, capture: true });
|
|
995
|
+
document.addEventListener('mouseenter', defaultEventBlock, eCapture);
|
|
996
|
+
document.addEventListener('mouseover', defaultEventBlock, eCapture);
|
|
997
|
+
document.addEventListener('mouseout', defaultEventBlock, eCapture);
|
|
998
|
+
document.addEventListener('mouseleave', defaultEventBlock, eCapture);
|
|
999
|
+
document.addEventListener('mousedown', defaultEventBlock, eCapture);
|
|
1000
|
+
document.addEventListener('mouseup', defaultEventBlock, eCapture);
|
|
1001
|
+
document.addEventListener('scroll', function () {
|
|
1002
|
+
var _a;
|
|
1003
|
+
(_a = _this.highlighted) === null || _a === void 0 ? void 0 : _a._tolgee.highlight();
|
|
1004
|
+
}, { capture: true, passive: true });
|
|
1005
|
+
document.addEventListener('click', function (e) {
|
|
1006
|
+
defaultEventBlock(e);
|
|
1007
|
+
if (_this.areKeysDown()) {
|
|
1008
|
+
var element = _this.getClosestTolgeeElement(e.target);
|
|
1009
|
+
if (element && element === _this.highlighted) {
|
|
1010
|
+
_this.dependencies.translationHighlighter.translationEdit(e, element);
|
|
1011
|
+
_this.unhighlight();
|
|
1012
|
+
}
|
|
1036
1013
|
}
|
|
1037
|
-
});
|
|
1014
|
+
}, eCapture);
|
|
1015
|
+
};
|
|
1016
|
+
MouseEventHandler.prototype.getClosestTolgeeElement = function (element) {
|
|
1017
|
+
if (element === null || element === void 0 ? void 0 : element._tolgee) {
|
|
1018
|
+
return element;
|
|
1019
|
+
}
|
|
1020
|
+
if (element === null || element === void 0 ? void 0 : element.parentElement) {
|
|
1021
|
+
return this.getClosestTolgeeElement(element.parentElement);
|
|
1022
|
+
}
|
|
1023
|
+
return undefined;
|
|
1038
1024
|
};
|
|
1039
1025
|
MouseEventHandler.prototype.areKeysDown = function () {
|
|
1040
1026
|
var e_1, _a;
|
|
1041
1027
|
try {
|
|
1042
|
-
for (var _b = __values(this.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1028
|
+
for (var _b = __values(this.dependencies.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1043
1029
|
var key = _c.value;
|
|
1044
1030
|
if (!this.keysDown.has(key)) {
|
|
1045
1031
|
return false;
|
|
@@ -1091,14 +1077,11 @@
|
|
|
1091
1077
|
}); })), false); }, []);
|
|
1092
1078
|
};
|
|
1093
1079
|
TranslationHighlighter.prototype.listen = function (element) {
|
|
1094
|
-
var _this = this;
|
|
1095
1080
|
this.dependencies.highlightFunctionInitializer.initFunctions(element);
|
|
1096
|
-
this.dependencies.mouseEventHandler.handle(
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
}
|
|
1101
|
-
}); }); });
|
|
1081
|
+
// this.dependencies.mouseEventHandler.handle(
|
|
1082
|
+
// element,
|
|
1083
|
+
// async (e) => await this.translationEdit(e, element)
|
|
1084
|
+
// );
|
|
1102
1085
|
};
|
|
1103
1086
|
TranslationHighlighter.prototype.getRenderer = function () {
|
|
1104
1087
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1311,7 +1294,7 @@
|
|
|
1311
1294
|
!element._tolgee.wrappedWithElementOnlyKey) {
|
|
1312
1295
|
return;
|
|
1313
1296
|
}
|
|
1314
|
-
if (this.properties.
|
|
1297
|
+
if (this.properties.mode === 'development' &&
|
|
1315
1298
|
!this.registeredElements.has(element)) {
|
|
1316
1299
|
this.translationHighlighter.listen(element);
|
|
1317
1300
|
}
|
|
@@ -1602,7 +1585,7 @@
|
|
|
1602
1585
|
console.error(e_1);
|
|
1603
1586
|
// eslint-disable-next-line no-console
|
|
1604
1587
|
console.error('Error getting scopes. Trying to switch to production mode!');
|
|
1605
|
-
this.properties.
|
|
1588
|
+
this.properties.mode = 'production';
|
|
1606
1589
|
return [3 /*break*/, 3];
|
|
1607
1590
|
case 3: return [2 /*return*/];
|
|
1608
1591
|
}
|
|
@@ -1672,7 +1655,7 @@
|
|
|
1672
1655
|
this.highlightKeys = [exports.ModifierKey.Alt];
|
|
1673
1656
|
this.passToParent = ['option', 'optgroup'];
|
|
1674
1657
|
this.restrictedElements = ['script', 'style'];
|
|
1675
|
-
this.highlightColor = 'rgb(
|
|
1658
|
+
this.highlightColor = 'rgb(255, 0, 0)';
|
|
1676
1659
|
this.wrapperMode = 'text';
|
|
1677
1660
|
/**
|
|
1678
1661
|
* When true, fallback language will be preloaded on Tolgee.run
|
|
@@ -1709,10 +1692,9 @@
|
|
|
1709
1692
|
if (this._targetElement === undefined) {
|
|
1710
1693
|
this._targetElement = DEFAULT_TARGET_ELEMENT_SUPPLIER();
|
|
1711
1694
|
}
|
|
1712
|
-
this.mode = this.mode || (this.apiKey ? 'development' : 'production');
|
|
1713
1695
|
this.fallbackLanguage = this.fallbackLanguage || this.defaultLanguage;
|
|
1714
1696
|
if (this.watch === undefined) {
|
|
1715
|
-
this.watch = this.
|
|
1697
|
+
this.watch = Boolean(this.apiKey && this.apiUrl);
|
|
1716
1698
|
}
|
|
1717
1699
|
if (this.availableLanguages === undefined && this.staticData) {
|
|
1718
1700
|
this.availableLanguages = Object.keys(this.staticData);
|
|
@@ -1774,7 +1756,7 @@
|
|
|
1774
1756
|
this.handshake = function () {
|
|
1775
1757
|
var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
|
|
1776
1758
|
//remove properties, which cannot be sent by window.postMessage
|
|
1777
|
-
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.
|
|
1759
|
+
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.6.0-rc.6a7caf3.0" });
|
|
1778
1760
|
var timer = null;
|
|
1779
1761
|
var ping = function () {
|
|
1780
1762
|
_this.messages.send('TOLGEE_READY', sharedConfiguration);
|
|
@@ -1874,6 +1856,7 @@
|
|
|
1874
1856
|
return Messages;
|
|
1875
1857
|
}());
|
|
1876
1858
|
|
|
1859
|
+
var BORDER_WIDTH = 5;
|
|
1877
1860
|
var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
1878
1861
|
function HighlightFunctionsInitializer(properties) {
|
|
1879
1862
|
this.properties = properties;
|
|
@@ -1885,13 +1868,34 @@
|
|
|
1885
1868
|
HighlightFunctionsInitializer.prototype.initHighlightFunction = function (element) {
|
|
1886
1869
|
var _this = this;
|
|
1887
1870
|
element._tolgee.highlight = function () {
|
|
1888
|
-
element.
|
|
1889
|
-
|
|
1871
|
+
if (!element.isConnected) {
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
var highlightEl = element._tolgee.highlightEl;
|
|
1875
|
+
if (!highlightEl) {
|
|
1876
|
+
highlightEl = document.createElement('div');
|
|
1877
|
+
highlightEl.style.pointerEvents = 'none';
|
|
1878
|
+
highlightEl.style.border = "".concat(BORDER_WIDTH, "px solid ").concat(_this.properties.config.highlightColor);
|
|
1879
|
+
highlightEl.style.position = 'fixed';
|
|
1880
|
+
highlightEl.style.boxSizing = 'border-box';
|
|
1881
|
+
highlightEl.style.zIndex = String(Number.MAX_SAFE_INTEGER);
|
|
1882
|
+
highlightEl.style.contain = 'layout';
|
|
1883
|
+
element._tolgee.highlightEl = highlightEl;
|
|
1884
|
+
document.body.appendChild(highlightEl);
|
|
1885
|
+
}
|
|
1886
|
+
var shape = element.getBoundingClientRect();
|
|
1887
|
+
highlightEl.style.top = shape.top - BORDER_WIDTH + 'px';
|
|
1888
|
+
highlightEl.style.left = shape.left - BORDER_WIDTH + 'px';
|
|
1889
|
+
highlightEl.style.width = shape.width + 2 * BORDER_WIDTH + 'px';
|
|
1890
|
+
highlightEl.style.height = shape.height + 2 * BORDER_WIDTH + 'px';
|
|
1891
|
+
highlightEl.style.display = 'block';
|
|
1890
1892
|
};
|
|
1891
1893
|
};
|
|
1892
1894
|
HighlightFunctionsInitializer.prototype.initUnhighlightFunction = function (element) {
|
|
1893
1895
|
element._tolgee.unhighlight = function () {
|
|
1894
|
-
|
|
1896
|
+
var _a;
|
|
1897
|
+
(_a = element._tolgee.highlightEl) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1898
|
+
element._tolgee.highlightEl = null;
|
|
1895
1899
|
};
|
|
1896
1900
|
};
|
|
1897
1901
|
return HighlightFunctionsInitializer;
|
|
@@ -2915,7 +2919,7 @@
|
|
|
2915
2919
|
this.properties = new Properties();
|
|
2916
2920
|
this.eventService = new EventService();
|
|
2917
2921
|
this.apiHttpService = new ApiHttpService(this.properties);
|
|
2918
|
-
this.mouseEventHandler = new MouseEventHandler(this
|
|
2922
|
+
this.mouseEventHandler = new MouseEventHandler(this);
|
|
2919
2923
|
this.moduleService = new ModuleService();
|
|
2920
2924
|
this.coreService = new CoreService(this.properties, this.apiHttpService);
|
|
2921
2925
|
this.screenshotService = new ScreenshotService(this.coreService, this.apiHttpService);
|
|
@@ -3087,6 +3091,9 @@
|
|
|
3087
3091
|
};
|
|
3088
3092
|
Tolgee.prototype.init = function (config) {
|
|
3089
3093
|
this.dependencyService.init(config);
|
|
3094
|
+
var _a = this.dependencyService.properties.config, apiKey = _a.apiKey, apiUrl = _a.apiUrl;
|
|
3095
|
+
this.dependencyService.properties.mode =
|
|
3096
|
+
apiKey && apiUrl ? 'development' : 'production';
|
|
3090
3097
|
return this;
|
|
3091
3098
|
};
|
|
3092
3099
|
Tolgee.prototype.run = function () {
|
|
@@ -3096,7 +3103,7 @@
|
|
|
3096
3103
|
switch (_a.label) {
|
|
3097
3104
|
case 0:
|
|
3098
3105
|
this.dependencyService.run();
|
|
3099
|
-
if (!(this.properties.
|
|
3106
|
+
if (!(this.properties.mode === 'development')) return [3 /*break*/, 4];
|
|
3100
3107
|
_a.label = 1;
|
|
3101
3108
|
case 1:
|
|
3102
3109
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -3107,10 +3114,10 @@
|
|
|
3107
3114
|
case 3:
|
|
3108
3115
|
e_1 = _a.sent();
|
|
3109
3116
|
// eslint-disable-next-line no-console
|
|
3110
|
-
console.error("Couldn't connect to
|
|
3117
|
+
console.error("Couldn't connect to Tolgee");
|
|
3111
3118
|
// eslint-disable-next-line no-console
|
|
3112
3119
|
console.error(e_1);
|
|
3113
|
-
this.properties.
|
|
3120
|
+
this.properties.mode = 'production';
|
|
3114
3121
|
return [3 /*break*/, 4];
|
|
3115
3122
|
case 4: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations()];
|
|
3116
3123
|
case 5:
|
|
@@ -3165,7 +3172,7 @@
|
|
|
3165
3172
|
return [4 /*yield*/, this.dependencyService.textService.translate(key, params, undefined, orEmpty, defaultValue)];
|
|
3166
3173
|
case 1:
|
|
3167
3174
|
translation = _a.sent();
|
|
3168
|
-
if (!(this.properties.
|
|
3175
|
+
if (!(this.properties.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
|
|
3169
3176
|
return [4 /*yield*/, this.coreService.loadApiKeyDetails()];
|
|
3170
3177
|
case 2:
|
|
3171
3178
|
_a.sent();
|
|
@@ -3176,7 +3183,7 @@
|
|
|
3176
3183
|
});
|
|
3177
3184
|
};
|
|
3178
3185
|
Tolgee.prototype.wrap = function (key, params, defaultValue, translation) {
|
|
3179
|
-
if (this.properties.
|
|
3186
|
+
if (this.properties.mode === 'development') {
|
|
3180
3187
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3181
3188
|
}
|
|
3182
3189
|
else {
|
|
@@ -3198,7 +3205,7 @@
|
|
|
3198
3205
|
orEmpty = props.orEmpty !== undefined ? props.orEmpty : orEmpty;
|
|
3199
3206
|
}
|
|
3200
3207
|
var translation = this.dependencyService.textService.instant(key, params, undefined, orEmpty, defaultValue);
|
|
3201
|
-
if (this.properties.
|
|
3208
|
+
if (this.properties.mode === 'development' && !noWrap) {
|
|
3202
3209
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3203
3210
|
}
|
|
3204
3211
|
return translation;
|