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