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