@tolgee/core 2.8.0 → 2.8.1
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 +45 -38
- 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 +45 -38
- 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/helpers/NodeHelper.d.ts +1 -1
- package/lib/helpers/NodeHelper.js +19 -18
- package/lib/helpers/NodeHelper.js.map +1 -1
- package/lib/highlighter/MouseEventHandler.js +2 -0
- package/lib/highlighter/MouseEventHandler.js.map +1 -1
- package/lib/services/ElementRegistrar.js +13 -9
- package/lib/services/ElementRegistrar.js.map +1 -1
- package/lib/types.d.ts +11 -0
- package/package.json +2 -2
package/dist/tolgee.cjs.js
CHANGED
|
@@ -129,23 +129,6 @@ var TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE = 'data-tolgee-key-only';
|
|
|
129
129
|
var NodeHelper = /** @class */ (function () {
|
|
130
130
|
function NodeHelper() {
|
|
131
131
|
}
|
|
132
|
-
NodeHelper.evaluateGenerator = function (expression, targetNode) {
|
|
133
|
-
var node, evaluated;
|
|
134
|
-
return __generator(this, function (_a) {
|
|
135
|
-
switch (_a.label) {
|
|
136
|
-
case 0:
|
|
137
|
-
evaluated = document.evaluate(expression, targetNode, undefined, XPathResult.ANY_TYPE);
|
|
138
|
-
_a.label = 1;
|
|
139
|
-
case 1:
|
|
140
|
-
if (!((node = evaluated.iterateNext()) !== null)) return [3 /*break*/, 3];
|
|
141
|
-
return [4 /*yield*/, node];
|
|
142
|
-
case 2:
|
|
143
|
-
_a.sent();
|
|
144
|
-
return [3 /*break*/, 1];
|
|
145
|
-
case 3: return [2 /*return*/];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
132
|
NodeHelper.evaluate = function () {
|
|
150
133
|
var args = [];
|
|
151
134
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -195,13 +178,31 @@ var NodeHelper = /** @class */ (function () {
|
|
|
195
178
|
return true;
|
|
196
179
|
}
|
|
197
180
|
if (node instanceof Attr) {
|
|
198
|
-
var ownerContainsAttr =
|
|
181
|
+
var ownerContainsAttr = node.ownerElement &&
|
|
182
|
+
Object.values(node.ownerElement.attributes).indexOf(node) > -1;
|
|
199
183
|
if (descendant.contains(node.ownerElement) && ownerContainsAttr) {
|
|
200
184
|
return true;
|
|
201
185
|
}
|
|
202
186
|
}
|
|
203
187
|
return false;
|
|
204
188
|
};
|
|
189
|
+
NodeHelper.evaluateGenerator = function (expression, targetNode) {
|
|
190
|
+
var node, evaluated;
|
|
191
|
+
return __generator(this, function (_a) {
|
|
192
|
+
switch (_a.label) {
|
|
193
|
+
case 0:
|
|
194
|
+
evaluated = document.evaluate(expression, targetNode, undefined, XPathResult.ANY_TYPE);
|
|
195
|
+
_a.label = 1;
|
|
196
|
+
case 1:
|
|
197
|
+
if (!((node = evaluated.iterateNext()) !== null)) return [3 /*break*/, 3];
|
|
198
|
+
return [4 /*yield*/, node];
|
|
199
|
+
case 2:
|
|
200
|
+
_a.sent();
|
|
201
|
+
return [3 /*break*/, 1];
|
|
202
|
+
case 3: return [2 /*return*/];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
};
|
|
205
206
|
return NodeHelper;
|
|
206
207
|
}());
|
|
207
208
|
|
|
@@ -1595,8 +1596,8 @@ function parseNumberSkeleton(tokens) {
|
|
|
1595
1596
|
}
|
|
1596
1597
|
|
|
1597
1598
|
var _a;
|
|
1598
|
-
var SPACE_SEPARATOR_START_REGEX = new RegExp("^"
|
|
1599
|
-
var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source
|
|
1599
|
+
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
|
|
1600
|
+
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
|
|
1600
1601
|
function createLocation(start, end) {
|
|
1601
1602
|
return { start: start, end: end };
|
|
1602
1603
|
}
|
|
@@ -1843,7 +1844,7 @@ var Parser = /** @class */ (function () {
|
|
|
1843
1844
|
return {
|
|
1844
1845
|
val: {
|
|
1845
1846
|
type: TYPE.literal,
|
|
1846
|
-
value: "<"
|
|
1847
|
+
value: "<".concat(tagName, "/>"),
|
|
1847
1848
|
location: createLocation(startPosition, this.clonePosition()),
|
|
1848
1849
|
},
|
|
1849
1850
|
err: null,
|
|
@@ -2448,7 +2449,7 @@ var Parser = /** @class */ (function () {
|
|
|
2448
2449
|
}
|
|
2449
2450
|
var code = codePointAt(this.message, offset);
|
|
2450
2451
|
if (code === undefined) {
|
|
2451
|
-
throw Error("Offset "
|
|
2452
|
+
throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
|
|
2452
2453
|
}
|
|
2453
2454
|
return code;
|
|
2454
2455
|
};
|
|
@@ -2516,7 +2517,7 @@ var Parser = /** @class */ (function () {
|
|
|
2516
2517
|
*/
|
|
2517
2518
|
Parser.prototype.bumpTo = function (targetOffset) {
|
|
2518
2519
|
if (this.offset() > targetOffset) {
|
|
2519
|
-
throw Error("targetOffset "
|
|
2520
|
+
throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
|
|
2520
2521
|
}
|
|
2521
2522
|
targetOffset = Math.min(targetOffset, this.message.length);
|
|
2522
2523
|
while (true) {
|
|
@@ -2525,7 +2526,7 @@ var Parser = /** @class */ (function () {
|
|
|
2525
2526
|
break;
|
|
2526
2527
|
}
|
|
2527
2528
|
if (offset > targetOffset) {
|
|
2528
|
-
throw Error("targetOffset "
|
|
2529
|
+
throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
|
|
2529
2530
|
}
|
|
2530
2531
|
this.bump();
|
|
2531
2532
|
if (this.isEOF()) {
|
|
@@ -2991,28 +2992,28 @@ var FormatError = /** @class */ (function (_super) {
|
|
|
2991
2992
|
return _this;
|
|
2992
2993
|
}
|
|
2993
2994
|
FormatError.prototype.toString = function () {
|
|
2994
|
-
return "[formatjs Error: "
|
|
2995
|
+
return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
|
|
2995
2996
|
};
|
|
2996
2997
|
return FormatError;
|
|
2997
2998
|
}(Error));
|
|
2998
2999
|
var InvalidValueError = /** @class */ (function (_super) {
|
|
2999
3000
|
__extends(InvalidValueError, _super);
|
|
3000
3001
|
function InvalidValueError(variableId, value, options, originalMessage) {
|
|
3001
|
-
return _super.call(this, "Invalid values for \""
|
|
3002
|
+
return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
|
|
3002
3003
|
}
|
|
3003
3004
|
return InvalidValueError;
|
|
3004
3005
|
}(FormatError));
|
|
3005
3006
|
var InvalidValueTypeError = /** @class */ (function (_super) {
|
|
3006
3007
|
__extends(InvalidValueTypeError, _super);
|
|
3007
3008
|
function InvalidValueTypeError(value, type, originalMessage) {
|
|
3008
|
-
return _super.call(this, "Value for \""
|
|
3009
|
+
return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
|
|
3009
3010
|
}
|
|
3010
3011
|
return InvalidValueTypeError;
|
|
3011
3012
|
}(FormatError));
|
|
3012
3013
|
var MissingValueError = /** @class */ (function (_super) {
|
|
3013
3014
|
__extends(MissingValueError, _super);
|
|
3014
3015
|
function MissingValueError(variableId, originalMessage) {
|
|
3015
|
-
return _super.call(this, "The intl string context variable \""
|
|
3016
|
+
return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
|
|
3016
3017
|
}
|
|
3017
3018
|
return MissingValueError;
|
|
3018
3019
|
}(FormatError));
|
|
@@ -3173,7 +3174,7 @@ originalMessage) {
|
|
|
3173
3174
|
continue;
|
|
3174
3175
|
}
|
|
3175
3176
|
if (isPluralElement(el)) {
|
|
3176
|
-
var opt = el.options["="
|
|
3177
|
+
var opt = el.options["=".concat(value)];
|
|
3177
3178
|
if (!opt) {
|
|
3178
3179
|
if (!Intl.PluralRules) {
|
|
3179
3180
|
throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
|
|
@@ -3719,11 +3720,13 @@ var MouseEventHandler = /** @class */ (function () {
|
|
|
3719
3720
|
}
|
|
3720
3721
|
};
|
|
3721
3722
|
MouseEventHandler.prototype.onMouseOut = function (element) {
|
|
3723
|
+
element._tolgee.preventClean = false;
|
|
3722
3724
|
this.mouseOn.delete(element);
|
|
3723
3725
|
this.mouseOnChanged.emit(this.getMouseOn());
|
|
3724
3726
|
};
|
|
3725
3727
|
MouseEventHandler.prototype.onMouseOver = function (element) {
|
|
3726
3728
|
this.filterMouseOn();
|
|
3729
|
+
element._tolgee.preventClean = true;
|
|
3727
3730
|
this.mouseOn.delete(element); //to get in to last place
|
|
3728
3731
|
this.mouseOn.add(element);
|
|
3729
3732
|
this.mouseOnChanged.emit(this.getMouseOn());
|
|
@@ -3951,10 +3954,12 @@ var ElementRegistrar = /** @class */ (function () {
|
|
|
3951
3954
|
try {
|
|
3952
3955
|
for (var _b = __values(this.registeredElements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3953
3956
|
var element = _c.value;
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3957
|
+
if (!element._tolgee.preventClean) {
|
|
3958
|
+
this.cleanElementInactiveNodes(element);
|
|
3959
|
+
if (element._tolgee.nodes.size === 0 &&
|
|
3960
|
+
!element._tolgee.wrappedWithElementOnlyKey) {
|
|
3961
|
+
this.cleanElement(element);
|
|
3962
|
+
}
|
|
3958
3963
|
}
|
|
3959
3964
|
}
|
|
3960
3965
|
}
|
|
@@ -4026,12 +4031,14 @@ var ElementRegistrar = /** @class */ (function () {
|
|
|
4026
4031
|
}
|
|
4027
4032
|
};
|
|
4028
4033
|
ElementRegistrar.prototype.cleanElement = function (element) {
|
|
4029
|
-
if (
|
|
4030
|
-
element._tolgee.removeAllEventListeners
|
|
4034
|
+
if (!element._tolgee.preventClean) {
|
|
4035
|
+
if (typeof element._tolgee.removeAllEventListeners === 'function') {
|
|
4036
|
+
element._tolgee.removeAllEventListeners();
|
|
4037
|
+
}
|
|
4038
|
+
element.removeAttribute(TOLGEE_ATTRIBUTE_NAME);
|
|
4039
|
+
delete element._tolgee;
|
|
4040
|
+
this.registeredElements.delete(element);
|
|
4031
4041
|
}
|
|
4032
|
-
element.removeAttribute(TOLGEE_ATTRIBUTE_NAME);
|
|
4033
|
-
delete element._tolgee;
|
|
4034
|
-
this.registeredElements.delete(element);
|
|
4035
4042
|
};
|
|
4036
4043
|
ElementRegistrar.prototype.getActiveNodes = function (element) {
|
|
4037
4044
|
var _a, _b, node, e_5_1;
|