@tolgee/core 4.5.0 → 4.6.0-rc.2e9d3c7.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 +103 -97
- 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 +103 -97
- 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 +0 -0
- package/lib/Tolgee.d.ts +0 -0
- package/lib/TolgeeConfig.d.ts +0 -0
- 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 +4 -4
package/dist/tolgee.cjs.js
CHANGED
|
@@ -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,82 @@ 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
|
+
defaultEventBlock(e);
|
|
992
|
+
_this.updateCursorPosition({ x: e.clientX, y: e.clientY });
|
|
993
|
+
}, { passive: true, capture: true });
|
|
994
|
+
document.addEventListener('mouseenter', defaultEventBlock, eCapture);
|
|
995
|
+
document.addEventListener('mouseover', defaultEventBlock, eCapture);
|
|
996
|
+
document.addEventListener('mouseout', defaultEventBlock, eCapture);
|
|
997
|
+
document.addEventListener('mouseleave', defaultEventBlock, eCapture);
|
|
998
|
+
document.addEventListener('mousedown', defaultEventBlock, eCapture);
|
|
999
|
+
document.addEventListener('mouseup', defaultEventBlock, eCapture);
|
|
1000
|
+
document.addEventListener('scroll', function () {
|
|
1001
|
+
var _a;
|
|
1002
|
+
(_a = _this.highlighted) === null || _a === void 0 ? void 0 : _a._tolgee.highlight();
|
|
1003
|
+
}, { capture: true, passive: true });
|
|
1004
|
+
document.addEventListener('click', function (e) {
|
|
1005
|
+
defaultEventBlock(e);
|
|
1006
|
+
if (_this.areKeysDown()) {
|
|
1007
|
+
var element = _this.getClosestTolgeeElement(e.target);
|
|
1008
|
+
if (element && element === _this.highlighted) {
|
|
1009
|
+
_this.dependencies.translationHighlighter.translationEdit(e, element);
|
|
1010
|
+
_this.unhighlight();
|
|
1011
|
+
}
|
|
1034
1012
|
}
|
|
1035
|
-
});
|
|
1013
|
+
}, eCapture);
|
|
1014
|
+
};
|
|
1015
|
+
MouseEventHandler.prototype.getClosestTolgeeElement = function (element) {
|
|
1016
|
+
if (element === null || element === void 0 ? void 0 : element._tolgee) {
|
|
1017
|
+
return element;
|
|
1018
|
+
}
|
|
1019
|
+
if (element === null || element === void 0 ? void 0 : element.parentElement) {
|
|
1020
|
+
return this.getClosestTolgeeElement(element.parentElement);
|
|
1021
|
+
}
|
|
1022
|
+
return undefined;
|
|
1036
1023
|
};
|
|
1037
1024
|
MouseEventHandler.prototype.areKeysDown = function () {
|
|
1038
1025
|
var e_1, _a;
|
|
1039
1026
|
try {
|
|
1040
|
-
for (var _b = __values(this.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1027
|
+
for (var _b = __values(this.dependencies.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1041
1028
|
var key = _c.value;
|
|
1042
1029
|
if (!this.keysDown.has(key)) {
|
|
1043
1030
|
return false;
|
|
@@ -1089,14 +1076,11 @@ var TranslationHighlighter = /** @class */ (function () {
|
|
|
1089
1076
|
}); })), false); }, []);
|
|
1090
1077
|
};
|
|
1091
1078
|
TranslationHighlighter.prototype.listen = function (element) {
|
|
1092
|
-
var _this = this;
|
|
1093
1079
|
this.dependencies.highlightFunctionInitializer.initFunctions(element);
|
|
1094
|
-
this.dependencies.mouseEventHandler.handle(
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
}); }); });
|
|
1080
|
+
// this.dependencies.mouseEventHandler.handle(
|
|
1081
|
+
// element,
|
|
1082
|
+
// async (e) => await this.translationEdit(e, element)
|
|
1083
|
+
// );
|
|
1100
1084
|
};
|
|
1101
1085
|
TranslationHighlighter.prototype.getRenderer = function () {
|
|
1102
1086
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1670,7 +1654,7 @@ var TolgeeConfig = /** @class */ (function () {
|
|
|
1670
1654
|
this.highlightKeys = [exports.ModifierKey.Alt];
|
|
1671
1655
|
this.passToParent = ['option', 'optgroup'];
|
|
1672
1656
|
this.restrictedElements = ['script', 'style'];
|
|
1673
|
-
this.highlightColor = 'rgb(
|
|
1657
|
+
this.highlightColor = 'rgb(255, 0, 0)';
|
|
1674
1658
|
this.wrapperMode = 'text';
|
|
1675
1659
|
/**
|
|
1676
1660
|
* When true, fallback language will be preloaded on Tolgee.run
|
|
@@ -1771,7 +1755,7 @@ var PluginManager = /** @class */ (function () {
|
|
|
1771
1755
|
this.handshake = function () {
|
|
1772
1756
|
var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
|
|
1773
1757
|
//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.
|
|
1758
|
+
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.6.0-rc.2e9d3c7.0" });
|
|
1775
1759
|
var timer = null;
|
|
1776
1760
|
var ping = function () {
|
|
1777
1761
|
_this.messages.send('TOLGEE_READY', sharedConfiguration);
|
|
@@ -1871,6 +1855,7 @@ var Messages = /** @class */ (function () {
|
|
|
1871
1855
|
return Messages;
|
|
1872
1856
|
}());
|
|
1873
1857
|
|
|
1858
|
+
var BORDER_WIDTH = 5;
|
|
1874
1859
|
var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
1875
1860
|
function HighlightFunctionsInitializer(properties) {
|
|
1876
1861
|
this.properties = properties;
|
|
@@ -1882,13 +1867,34 @@ var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
|
1882
1867
|
HighlightFunctionsInitializer.prototype.initHighlightFunction = function (element) {
|
|
1883
1868
|
var _this = this;
|
|
1884
1869
|
element._tolgee.highlight = function () {
|
|
1885
|
-
element.
|
|
1886
|
-
|
|
1870
|
+
if (!element.isConnected) {
|
|
1871
|
+
return;
|
|
1872
|
+
}
|
|
1873
|
+
var highlightEl = element._tolgee.highlightEl;
|
|
1874
|
+
if (!highlightEl) {
|
|
1875
|
+
highlightEl = document.createElement('div');
|
|
1876
|
+
highlightEl.style.pointerEvents = 'none';
|
|
1877
|
+
highlightEl.style.border = "".concat(BORDER_WIDTH, "px solid ").concat(_this.properties.config.highlightColor);
|
|
1878
|
+
highlightEl.style.position = 'fixed';
|
|
1879
|
+
highlightEl.style.boxSizing = 'border-box';
|
|
1880
|
+
highlightEl.style.zIndex = String(Number.MAX_SAFE_INTEGER);
|
|
1881
|
+
highlightEl.style.contain = 'layout';
|
|
1882
|
+
element._tolgee.highlightEl = highlightEl;
|
|
1883
|
+
document.body.appendChild(highlightEl);
|
|
1884
|
+
}
|
|
1885
|
+
var shape = element.getBoundingClientRect();
|
|
1886
|
+
highlightEl.style.top = shape.top - BORDER_WIDTH + 'px';
|
|
1887
|
+
highlightEl.style.left = shape.left - BORDER_WIDTH + 'px';
|
|
1888
|
+
highlightEl.style.width = shape.width + 2 * BORDER_WIDTH + 'px';
|
|
1889
|
+
highlightEl.style.height = shape.height + 2 * BORDER_WIDTH + 'px';
|
|
1890
|
+
highlightEl.style.display = 'block';
|
|
1887
1891
|
};
|
|
1888
1892
|
};
|
|
1889
1893
|
HighlightFunctionsInitializer.prototype.initUnhighlightFunction = function (element) {
|
|
1890
1894
|
element._tolgee.unhighlight = function () {
|
|
1891
|
-
|
|
1895
|
+
var _a;
|
|
1896
|
+
(_a = element._tolgee.highlightEl) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1897
|
+
element._tolgee.highlightEl = null;
|
|
1892
1898
|
};
|
|
1893
1899
|
};
|
|
1894
1900
|
return HighlightFunctionsInitializer;
|
|
@@ -2912,7 +2918,7 @@ var DependencyService = /** @class */ (function () {
|
|
|
2912
2918
|
this.properties = new Properties();
|
|
2913
2919
|
this.eventService = new EventService();
|
|
2914
2920
|
this.apiHttpService = new ApiHttpService(this.properties);
|
|
2915
|
-
this.mouseEventHandler = new MouseEventHandler(this
|
|
2921
|
+
this.mouseEventHandler = new MouseEventHandler(this);
|
|
2916
2922
|
this.moduleService = new ModuleService();
|
|
2917
2923
|
this.coreService = new CoreService(this.properties, this.apiHttpService);
|
|
2918
2924
|
this.screenshotService = new ScreenshotService(this.coreService, this.apiHttpService);
|