@tolgee/core 4.3.0 → 4.6.0-rc.03177a3.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 +154 -121
- 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 +154 -121
- 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 +1 -0
- package/lib/highlighter/MouseEventHandler.d.ts +17 -13
- 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 +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 +1 -3
- 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 +7 -7
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,131 +913,144 @@ 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
|
+
};
|
|
919
|
+
var ePassive = {
|
|
920
|
+
capture: true,
|
|
921
|
+
passive: true,
|
|
922
|
+
};
|
|
916
923
|
var MouseEventHandler = /** @class */ (function () {
|
|
917
|
-
function MouseEventHandler(
|
|
924
|
+
function MouseEventHandler(dependencies) {
|
|
918
925
|
var _this = this;
|
|
919
|
-
this.
|
|
926
|
+
this.dependencies = dependencies;
|
|
920
927
|
this.keysDown = new Set();
|
|
921
|
-
this.mouseOn = new Set();
|
|
922
928
|
this.mouseOnChanged = new EventEmitterImpl();
|
|
923
929
|
this.keysChanged = new EventEmitterImpl();
|
|
924
|
-
this.
|
|
925
|
-
_this.
|
|
926
|
-
|
|
927
|
-
|
|
930
|
+
this.highlight = function (el) {
|
|
931
|
+
if (_this.highlighted !== el) {
|
|
932
|
+
_this.unhighlight();
|
|
933
|
+
if (el) {
|
|
934
|
+
el._tolgee.preventClean = true;
|
|
935
|
+
el._tolgee.highlight();
|
|
936
|
+
_this.highlighted = el;
|
|
937
|
+
_this.mouseOnChanged.emit(el);
|
|
938
|
+
}
|
|
928
939
|
}
|
|
929
940
|
};
|
|
930
|
-
this.highlight = function () {
|
|
931
|
-
_this.getMouseOn()._tolgee.highlight();
|
|
932
|
-
_this.highlighted = _this.getMouseOn();
|
|
933
|
-
};
|
|
934
941
|
this.unhighlight = function () {
|
|
935
942
|
if (_this.highlighted) {
|
|
943
|
+
_this.highlighted._tolgee.preventClean = false;
|
|
936
944
|
_this.highlighted._tolgee.unhighlight();
|
|
937
|
-
_this.highlighted =
|
|
938
|
-
|
|
939
|
-
};
|
|
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
|
-
}
|
|
953
|
-
MouseEventHandler.prototype.run = function () {
|
|
954
|
-
if (typeof window !== 'undefined') {
|
|
955
|
-
this.initKeyListener();
|
|
956
|
-
return;
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
MouseEventHandler.prototype.handle = function (element, onclick) {
|
|
960
|
-
var _this = this;
|
|
961
|
-
if (element._tolgee.listeningForHighlighting) {
|
|
962
|
-
// eslint-disable-next-line no-console
|
|
963
|
-
console.error('Element is already listening mouse events! This is probably bug in tolgee');
|
|
964
|
-
return;
|
|
965
|
-
}
|
|
966
|
-
element._tolgee.listeningForHighlighting = true;
|
|
967
|
-
this.initEventListeners(element, onclick);
|
|
968
|
-
this.mouseOnChanged.subscribe(function () {
|
|
969
|
-
if (_this.highlighted !== _this.getMouseOn()) {
|
|
970
|
-
_this.onConditionsChanged();
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
this.keysChanged.subscribe(function () {
|
|
974
|
-
_this.onConditionsChanged();
|
|
975
|
-
});
|
|
976
|
-
};
|
|
977
|
-
MouseEventHandler.prototype.initEventListeners = function (element, onclick) {
|
|
978
|
-
var _this = this;
|
|
979
|
-
var onMouseOver = function () { return _this.onMouseOver(element); };
|
|
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);
|
|
945
|
+
_this.highlighted = undefined;
|
|
946
|
+
_this.mouseOnChanged.emit(_this.highlighted);
|
|
986
947
|
}
|
|
987
948
|
};
|
|
988
|
-
|
|
989
|
-
element.addEventListener('click', onClick, { capture: true });
|
|
990
|
-
var onMouseDownOrUp = function (e) {
|
|
949
|
+
this.blockEvents = function (e) {
|
|
991
950
|
if (_this.areKeysDown()) {
|
|
992
951
|
e.stopPropagation();
|
|
993
952
|
e.preventDefault();
|
|
994
953
|
}
|
|
995
954
|
};
|
|
996
|
-
|
|
997
|
-
|
|
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);
|
|
955
|
+
this.onMouseMove = function (e) {
|
|
956
|
+
_this.updateCursorPosition({ x: e.clientX, y: e.clientY });
|
|
1005
957
|
};
|
|
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 () {
|
|
958
|
+
this.onBlur = function () {
|
|
1014
959
|
_this.keysDown = new Set();
|
|
1015
960
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1016
|
-
|
|
1017
|
-
|
|
961
|
+
_this.updateHighlight();
|
|
962
|
+
};
|
|
963
|
+
this.onKeyDown = function (e) {
|
|
1018
964
|
var modifierKey = exports.ModifierKey[e.key];
|
|
1019
965
|
if (modifierKey !== undefined) {
|
|
1020
966
|
_this.keysDown.add(modifierKey);
|
|
1021
967
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1022
968
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
969
|
+
_this.updateHighlight();
|
|
970
|
+
};
|
|
971
|
+
this.onKeyUp = function (e) {
|
|
1025
972
|
_this.keysDown.delete(exports.ModifierKey[e.key]);
|
|
1026
973
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
974
|
+
_this.updateHighlight();
|
|
975
|
+
};
|
|
976
|
+
this.onScroll = function () {
|
|
977
|
+
var _a;
|
|
978
|
+
(_a = _this.highlighted) === null || _a === void 0 ? void 0 : _a._tolgee.highlight();
|
|
979
|
+
};
|
|
980
|
+
this.onClick = function (e) {
|
|
981
|
+
_this.blockEvents(e);
|
|
982
|
+
if (_this.areKeysDown()) {
|
|
983
|
+
var element = _this.getClosestTolgeeElement(e.target);
|
|
984
|
+
if (element && element === _this.highlighted) {
|
|
985
|
+
_this.dependencies.translationHighlighter.translationEdit(e, element);
|
|
986
|
+
_this.unhighlight();
|
|
987
|
+
}
|
|
1034
988
|
}
|
|
1035
|
-
}
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
MouseEventHandler.prototype.run = function () {
|
|
992
|
+
if (typeof window !== 'undefined') {
|
|
993
|
+
this.initEventListeners();
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
MouseEventHandler.prototype.stop = function () {
|
|
997
|
+
if (typeof window !== 'undefined') {
|
|
998
|
+
this.removeEventListeners();
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
MouseEventHandler.prototype.updateHighlight = function () {
|
|
1002
|
+
var position = this.cursorPosition;
|
|
1003
|
+
var newHighlighted;
|
|
1004
|
+
if (position && this.areKeysDown()) {
|
|
1005
|
+
newHighlighted = this.getClosestTolgeeElement(document.elementFromPoint(position.x, position.y));
|
|
1006
|
+
}
|
|
1007
|
+
this.highlight(newHighlighted);
|
|
1008
|
+
};
|
|
1009
|
+
MouseEventHandler.prototype.updateCursorPosition = function (position) {
|
|
1010
|
+
this.cursorPosition = position;
|
|
1011
|
+
this.updateHighlight();
|
|
1012
|
+
};
|
|
1013
|
+
MouseEventHandler.prototype.initEventListeners = function () {
|
|
1014
|
+
window.addEventListener('blur', this.onBlur, eCapture);
|
|
1015
|
+
window.addEventListener('keydown', this.onKeyDown, eCapture);
|
|
1016
|
+
window.addEventListener('keyup', this.onKeyUp, eCapture);
|
|
1017
|
+
window.addEventListener('mousemove', this.onMouseMove, ePassive);
|
|
1018
|
+
window.addEventListener('scroll', this.onScroll, ePassive);
|
|
1019
|
+
window.addEventListener('click', this.onClick, eCapture);
|
|
1020
|
+
window.addEventListener('mouseenter', this.blockEvents, eCapture);
|
|
1021
|
+
window.addEventListener('mouseover', this.blockEvents, eCapture);
|
|
1022
|
+
window.addEventListener('mouseout', this.blockEvents, eCapture);
|
|
1023
|
+
window.addEventListener('mouseleave', this.blockEvents, eCapture);
|
|
1024
|
+
window.addEventListener('mousedown', this.blockEvents, eCapture);
|
|
1025
|
+
window.addEventListener('mouseup', this.blockEvents, eCapture);
|
|
1026
|
+
};
|
|
1027
|
+
MouseEventHandler.prototype.removeEventListeners = function () {
|
|
1028
|
+
window.removeEventListener('blur', this.onBlur, eCapture);
|
|
1029
|
+
window.removeEventListener('keydown', this.onKeyDown, eCapture);
|
|
1030
|
+
window.removeEventListener('keyup', this.onKeyUp, eCapture);
|
|
1031
|
+
window.removeEventListener('mousemove', this.onMouseMove, ePassive);
|
|
1032
|
+
window.removeEventListener('scroll', this.onScroll, ePassive);
|
|
1033
|
+
window.removeEventListener('click', this.onClick, eCapture);
|
|
1034
|
+
window.removeEventListener('mouseenter', this.blockEvents, eCapture);
|
|
1035
|
+
window.removeEventListener('mouseover', this.blockEvents, eCapture);
|
|
1036
|
+
window.removeEventListener('mouseout', this.blockEvents, eCapture);
|
|
1037
|
+
window.removeEventListener('mouseleave', this.blockEvents, eCapture);
|
|
1038
|
+
window.removeEventListener('mousedown', this.blockEvents, eCapture);
|
|
1039
|
+
window.removeEventListener('mouseup', this.blockEvents, eCapture);
|
|
1040
|
+
};
|
|
1041
|
+
MouseEventHandler.prototype.getClosestTolgeeElement = function (element) {
|
|
1042
|
+
if (element === null || element === void 0 ? void 0 : element._tolgee) {
|
|
1043
|
+
return element;
|
|
1044
|
+
}
|
|
1045
|
+
if (element === null || element === void 0 ? void 0 : element.parentElement) {
|
|
1046
|
+
return this.getClosestTolgeeElement(element.parentElement);
|
|
1047
|
+
}
|
|
1048
|
+
return undefined;
|
|
1036
1049
|
};
|
|
1037
1050
|
MouseEventHandler.prototype.areKeysDown = function () {
|
|
1038
1051
|
var e_1, _a;
|
|
1039
1052
|
try {
|
|
1040
|
-
for (var _b = __values(this.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1053
|
+
for (var _b = __values(this.dependencies.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1041
1054
|
var key = _c.value;
|
|
1042
1055
|
if (!this.keysDown.has(key)) {
|
|
1043
1056
|
return false;
|
|
@@ -1089,14 +1102,11 @@ var TranslationHighlighter = /** @class */ (function () {
|
|
|
1089
1102
|
}); })), false); }, []);
|
|
1090
1103
|
};
|
|
1091
1104
|
TranslationHighlighter.prototype.listen = function (element) {
|
|
1092
|
-
var _this = this;
|
|
1093
1105
|
this.dependencies.highlightFunctionInitializer.initFunctions(element);
|
|
1094
|
-
this.dependencies.mouseEventHandler.handle(
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
}); }); });
|
|
1106
|
+
// this.dependencies.mouseEventHandler.handle(
|
|
1107
|
+
// element,
|
|
1108
|
+
// async (e) => await this.translationEdit(e, element)
|
|
1109
|
+
// );
|
|
1100
1110
|
};
|
|
1101
1111
|
TranslationHighlighter.prototype.getRenderer = function () {
|
|
1102
1112
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1309,7 +1319,7 @@ var ElementRegistrar = /** @class */ (function () {
|
|
|
1309
1319
|
!element._tolgee.wrappedWithElementOnlyKey) {
|
|
1310
1320
|
return;
|
|
1311
1321
|
}
|
|
1312
|
-
if (this.properties.
|
|
1322
|
+
if (this.properties.mode === 'development' &&
|
|
1313
1323
|
!this.registeredElements.has(element)) {
|
|
1314
1324
|
this.translationHighlighter.listen(element);
|
|
1315
1325
|
}
|
|
@@ -1399,9 +1409,6 @@ var ElementRegistrar = /** @class */ (function () {
|
|
|
1399
1409
|
};
|
|
1400
1410
|
ElementRegistrar.prototype.cleanElement = function (element) {
|
|
1401
1411
|
if (!element._tolgee.preventClean) {
|
|
1402
|
-
if (typeof element._tolgee.removeAllEventListeners === 'function') {
|
|
1403
|
-
element._tolgee.removeAllEventListeners();
|
|
1404
|
-
}
|
|
1405
1412
|
element.removeAttribute(TOLGEE_ATTRIBUTE_NAME);
|
|
1406
1413
|
delete element._tolgee;
|
|
1407
1414
|
this.registeredElements.delete(element);
|
|
@@ -1600,7 +1607,7 @@ var CoreService = /** @class */ (function () {
|
|
|
1600
1607
|
console.error(e_1);
|
|
1601
1608
|
// eslint-disable-next-line no-console
|
|
1602
1609
|
console.error('Error getting scopes. Trying to switch to production mode!');
|
|
1603
|
-
this.properties.
|
|
1610
|
+
this.properties.mode = 'production';
|
|
1604
1611
|
return [3 /*break*/, 3];
|
|
1605
1612
|
case 3: return [2 /*return*/];
|
|
1606
1613
|
}
|
|
@@ -1627,6 +1634,7 @@ var CoreService = /** @class */ (function () {
|
|
|
1627
1634
|
details = _a.sent();
|
|
1628
1635
|
this.properties.scopes = details.scopes;
|
|
1629
1636
|
this.properties.projectId = details.projectId;
|
|
1637
|
+
this.properties.permittedLanguageIds = details.permittedLanguageIds;
|
|
1630
1638
|
_a.label = 2;
|
|
1631
1639
|
case 2: return [2 /*return*/];
|
|
1632
1640
|
}
|
|
@@ -1669,7 +1677,7 @@ var TolgeeConfig = /** @class */ (function () {
|
|
|
1669
1677
|
this.highlightKeys = [exports.ModifierKey.Alt];
|
|
1670
1678
|
this.passToParent = ['option', 'optgroup'];
|
|
1671
1679
|
this.restrictedElements = ['script', 'style'];
|
|
1672
|
-
this.highlightColor = 'rgb(
|
|
1680
|
+
this.highlightColor = 'rgb(255, 0, 0)';
|
|
1673
1681
|
this.wrapperMode = 'text';
|
|
1674
1682
|
/**
|
|
1675
1683
|
* When true, fallback language will be preloaded on Tolgee.run
|
|
@@ -1706,10 +1714,9 @@ var TolgeeConfig = /** @class */ (function () {
|
|
|
1706
1714
|
if (this._targetElement === undefined) {
|
|
1707
1715
|
this._targetElement = DEFAULT_TARGET_ELEMENT_SUPPLIER();
|
|
1708
1716
|
}
|
|
1709
|
-
this.mode = this.mode || (this.apiKey ? 'development' : 'production');
|
|
1710
1717
|
this.fallbackLanguage = this.fallbackLanguage || this.defaultLanguage;
|
|
1711
1718
|
if (this.watch === undefined) {
|
|
1712
|
-
this.watch = this.
|
|
1719
|
+
this.watch = Boolean(this.apiKey && this.apiUrl);
|
|
1713
1720
|
}
|
|
1714
1721
|
if (this.availableLanguages === undefined && this.staticData) {
|
|
1715
1722
|
this.availableLanguages = Object.keys(this.staticData);
|
|
@@ -1771,7 +1778,7 @@ var PluginManager = /** @class */ (function () {
|
|
|
1771
1778
|
this.handshake = function () {
|
|
1772
1779
|
var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
|
|
1773
1780
|
//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.
|
|
1781
|
+
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.6.0-rc.03177a3.0" });
|
|
1775
1782
|
var timer = null;
|
|
1776
1783
|
var ping = function () {
|
|
1777
1784
|
_this.messages.send('TOLGEE_READY', sharedConfiguration);
|
|
@@ -1871,6 +1878,7 @@ var Messages = /** @class */ (function () {
|
|
|
1871
1878
|
return Messages;
|
|
1872
1879
|
}());
|
|
1873
1880
|
|
|
1881
|
+
var BORDER_WIDTH = 5;
|
|
1874
1882
|
var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
1875
1883
|
function HighlightFunctionsInitializer(properties) {
|
|
1876
1884
|
this.properties = properties;
|
|
@@ -1882,13 +1890,34 @@ var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
|
1882
1890
|
HighlightFunctionsInitializer.prototype.initHighlightFunction = function (element) {
|
|
1883
1891
|
var _this = this;
|
|
1884
1892
|
element._tolgee.highlight = function () {
|
|
1885
|
-
element.
|
|
1886
|
-
|
|
1893
|
+
if (!element.isConnected) {
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
var highlightEl = element._tolgee.highlightEl;
|
|
1897
|
+
if (!highlightEl) {
|
|
1898
|
+
highlightEl = document.createElement('div');
|
|
1899
|
+
highlightEl.style.pointerEvents = 'none';
|
|
1900
|
+
highlightEl.style.border = "".concat(BORDER_WIDTH, "px solid ").concat(_this.properties.config.highlightColor);
|
|
1901
|
+
highlightEl.style.position = 'fixed';
|
|
1902
|
+
highlightEl.style.boxSizing = 'border-box';
|
|
1903
|
+
highlightEl.style.zIndex = String(Number.MAX_SAFE_INTEGER);
|
|
1904
|
+
highlightEl.style.contain = 'layout';
|
|
1905
|
+
element._tolgee.highlightEl = highlightEl;
|
|
1906
|
+
document.body.appendChild(highlightEl);
|
|
1907
|
+
}
|
|
1908
|
+
var shape = element.getBoundingClientRect();
|
|
1909
|
+
highlightEl.style.top = shape.top - BORDER_WIDTH + 'px';
|
|
1910
|
+
highlightEl.style.left = shape.left - BORDER_WIDTH + 'px';
|
|
1911
|
+
highlightEl.style.width = shape.width + 2 * BORDER_WIDTH + 'px';
|
|
1912
|
+
highlightEl.style.height = shape.height + 2 * BORDER_WIDTH + 'px';
|
|
1913
|
+
highlightEl.style.display = 'block';
|
|
1887
1914
|
};
|
|
1888
1915
|
};
|
|
1889
1916
|
HighlightFunctionsInitializer.prototype.initUnhighlightFunction = function (element) {
|
|
1890
1917
|
element._tolgee.unhighlight = function () {
|
|
1891
|
-
|
|
1918
|
+
var _a;
|
|
1919
|
+
(_a = element._tolgee.highlightEl) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1920
|
+
element._tolgee.highlightEl = null;
|
|
1892
1921
|
};
|
|
1893
1922
|
};
|
|
1894
1923
|
return HighlightFunctionsInitializer;
|
|
@@ -2912,7 +2941,7 @@ var DependencyService = /** @class */ (function () {
|
|
|
2912
2941
|
this.properties = new Properties();
|
|
2913
2942
|
this.eventService = new EventService();
|
|
2914
2943
|
this.apiHttpService = new ApiHttpService(this.properties);
|
|
2915
|
-
this.mouseEventHandler = new MouseEventHandler(this
|
|
2944
|
+
this.mouseEventHandler = new MouseEventHandler(this);
|
|
2916
2945
|
this.moduleService = new ModuleService();
|
|
2917
2946
|
this.coreService = new CoreService(this.properties, this.apiHttpService);
|
|
2918
2947
|
this.screenshotService = new ScreenshotService(this.coreService, this.apiHttpService);
|
|
@@ -2929,6 +2958,7 @@ var DependencyService = /** @class */ (function () {
|
|
|
2929
2958
|
this.stop = function () {
|
|
2930
2959
|
_this.observer.stopObserving();
|
|
2931
2960
|
_this.elementRegistrar.cleanAll();
|
|
2961
|
+
_this.mouseEventHandler.stop();
|
|
2932
2962
|
NodeHelper.unmarkElementAsTargetElement(_this.properties.config.targetElement);
|
|
2933
2963
|
};
|
|
2934
2964
|
this.translationHighlighter.pluginManager = this.pluginManager;
|
|
@@ -3084,6 +3114,9 @@ var Tolgee = /** @class */ (function () {
|
|
|
3084
3114
|
};
|
|
3085
3115
|
Tolgee.prototype.init = function (config) {
|
|
3086
3116
|
this.dependencyService.init(config);
|
|
3117
|
+
var _a = this.dependencyService.properties.config, apiKey = _a.apiKey, apiUrl = _a.apiUrl;
|
|
3118
|
+
this.dependencyService.properties.mode =
|
|
3119
|
+
apiKey && apiUrl ? 'development' : 'production';
|
|
3087
3120
|
return this;
|
|
3088
3121
|
};
|
|
3089
3122
|
Tolgee.prototype.run = function () {
|
|
@@ -3093,7 +3126,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3093
3126
|
switch (_a.label) {
|
|
3094
3127
|
case 0:
|
|
3095
3128
|
this.dependencyService.run();
|
|
3096
|
-
if (!(this.properties.
|
|
3129
|
+
if (!(this.properties.mode === 'development')) return [3 /*break*/, 4];
|
|
3097
3130
|
_a.label = 1;
|
|
3098
3131
|
case 1:
|
|
3099
3132
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -3104,10 +3137,10 @@ var Tolgee = /** @class */ (function () {
|
|
|
3104
3137
|
case 3:
|
|
3105
3138
|
e_1 = _a.sent();
|
|
3106
3139
|
// eslint-disable-next-line no-console
|
|
3107
|
-
console.error("Couldn't connect to
|
|
3140
|
+
console.error("Couldn't connect to Tolgee");
|
|
3108
3141
|
// eslint-disable-next-line no-console
|
|
3109
3142
|
console.error(e_1);
|
|
3110
|
-
this.properties.
|
|
3143
|
+
this.properties.mode = 'production';
|
|
3111
3144
|
return [3 /*break*/, 4];
|
|
3112
3145
|
case 4: return [4 /*yield*/, this.dependencyService.translationService.loadTranslations()];
|
|
3113
3146
|
case 5:
|
|
@@ -3162,7 +3195,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3162
3195
|
return [4 /*yield*/, this.dependencyService.textService.translate(key, params, undefined, orEmpty, defaultValue)];
|
|
3163
3196
|
case 1:
|
|
3164
3197
|
translation = _a.sent();
|
|
3165
|
-
if (!(this.properties.
|
|
3198
|
+
if (!(this.properties.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
|
|
3166
3199
|
return [4 /*yield*/, this.coreService.loadApiKeyDetails()];
|
|
3167
3200
|
case 2:
|
|
3168
3201
|
_a.sent();
|
|
@@ -3173,7 +3206,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3173
3206
|
});
|
|
3174
3207
|
};
|
|
3175
3208
|
Tolgee.prototype.wrap = function (key, params, defaultValue, translation) {
|
|
3176
|
-
if (this.properties.
|
|
3209
|
+
if (this.properties.mode === 'development') {
|
|
3177
3210
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3178
3211
|
}
|
|
3179
3212
|
else {
|
|
@@ -3195,7 +3228,7 @@ var Tolgee = /** @class */ (function () {
|
|
|
3195
3228
|
orEmpty = props.orEmpty !== undefined ? props.orEmpty : orEmpty;
|
|
3196
3229
|
}
|
|
3197
3230
|
var translation = this.dependencyService.textService.instant(key, params, undefined, orEmpty, defaultValue);
|
|
3198
|
-
if (this.properties.
|
|
3231
|
+
if (this.properties.mode === 'development' && !noWrap) {
|
|
3199
3232
|
return this.dependencyService.wrapper.wrap(key, params, defaultValue, translation);
|
|
3200
3233
|
}
|
|
3201
3234
|
return translation;
|