@tolgee/core 4.2.1 → 4.3.0-rc.5103942.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 +28 -21
- 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 +28 -21
- 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 +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 +0 -0
- package/lib/highlighter/MouseEventHandler.d.ts +0 -0
- package/lib/highlighter/TranslationHighlighter.d.ts +0 -0
- package/lib/index.d.ts +3 -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 +0 -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 +6 -2
- package/lib/Constants/Global.js +0 -5
- package/lib/Constants/Global.js.map +0 -1
- package/lib/Constants/ModifierKey.js +0 -8
- package/lib/Constants/ModifierKey.js.map +0 -1
- package/lib/Errors/ApiHttpError.js +0 -29
- package/lib/Errors/ApiHttpError.js.map +0 -1
- package/lib/Observer.js +0 -144
- package/lib/Observer.js.map +0 -1
- package/lib/Properties.js +0 -86
- package/lib/Properties.js.map +0 -1
- package/lib/Tolgee.js +0 -308
- package/lib/Tolgee.js.map +0 -1
- package/lib/TolgeeConfig.js +0 -85
- package/lib/TolgeeConfig.js.map +0 -1
- package/lib/helpers/NodeHelper.js +0 -140
- package/lib/helpers/NodeHelper.js.map +0 -1
- package/lib/helpers/TextHelper.js +0 -58
- package/lib/helpers/TextHelper.js.map +0 -1
- package/lib/helpers/commonTypes.js +0 -2
- package/lib/helpers/commonTypes.js.map +0 -1
- package/lib/helpers/encoderPolyfill.js +0 -96
- package/lib/helpers/encoderPolyfill.js.map +0 -1
- package/lib/helpers/secret.js +0 -73
- package/lib/helpers/secret.js.map +0 -1
- package/lib/helpers/sleep.js +0 -4
- package/lib/helpers/sleep.js.map +0 -1
- package/lib/highlighter/HighlightFunctionsInitializer.js +0 -24
- package/lib/highlighter/HighlightFunctionsInitializer.js.map +0 -1
- package/lib/highlighter/MouseEventHandler.js +0 -157
- package/lib/highlighter/MouseEventHandler.js.map +0 -1
- package/lib/highlighter/TranslationHighlighter.js +0 -220
- package/lib/highlighter/TranslationHighlighter.js.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
- package/lib/modules/IcuFormatter.js +0 -18
- package/lib/modules/IcuFormatter.js.map +0 -1
- package/lib/modules/index.js +0 -2
- package/lib/modules/index.js.map +0 -1
- package/lib/services/ApiHttpService.js +0 -171
- package/lib/services/ApiHttpService.js.map +0 -1
- package/lib/services/CoreService.js +0 -129
- package/lib/services/CoreService.js.map +0 -1
- package/lib/services/DependencyService.js +0 -64
- package/lib/services/DependencyService.js.map +0 -1
- package/lib/services/ElementRegistrar.js +0 -193
- package/lib/services/ElementRegistrar.js.map +0 -1
- package/lib/services/EventEmitter.js +0 -68
- package/lib/services/EventEmitter.js.map +0 -1
- package/lib/services/EventService.js +0 -12
- package/lib/services/EventService.js.map +0 -1
- package/lib/services/ModuleService.js +0 -18
- package/lib/services/ModuleService.js.map +0 -1
- package/lib/services/ScreenshotService.js +0 -67
- package/lib/services/ScreenshotService.js.map +0 -1
- package/lib/services/Subscription.js +0 -11
- package/lib/services/Subscription.js.map +0 -1
- package/lib/services/TextService.js +0 -94
- package/lib/services/TextService.js.map +0 -1
- package/lib/services/TranslationService.js +0 -523
- package/lib/services/TranslationService.js.map +0 -1
- package/lib/toolsManager/Messages.js +0 -46
- package/lib/toolsManager/Messages.js.map +0 -1
- package/lib/toolsManager/PluginManager.js +0 -153
- package/lib/toolsManager/PluginManager.js.map +0 -1
- package/lib/types/DTOs.js +0 -10
- package/lib/types/DTOs.js.map +0 -1
- package/lib/types/apiSchema.generated.js +0 -6
- package/lib/types/apiSchema.generated.js.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/wrappers/AbstractWrapper.js +0 -2
- package/lib/wrappers/AbstractWrapper.js.map +0 -1
- package/lib/wrappers/NodeHandler.js +0 -178
- package/lib/wrappers/NodeHandler.js.map +0 -1
- package/lib/wrappers/WrappedHandler.js +0 -67
- package/lib/wrappers/WrappedHandler.js.map +0 -1
- package/lib/wrappers/invisible/AttributeHandler.js +0 -134
- package/lib/wrappers/invisible/AttributeHandler.js.map +0 -1
- package/lib/wrappers/invisible/Coder.js +0 -73
- package/lib/wrappers/invisible/Coder.js.map +0 -1
- package/lib/wrappers/invisible/ContentHandler.js +0 -63
- package/lib/wrappers/invisible/ContentHandler.js.map +0 -1
- package/lib/wrappers/invisible/CoreHandler.js +0 -64
- package/lib/wrappers/invisible/CoreHandler.js.map +0 -1
- package/lib/wrappers/invisible/InvisibleWrapper.js +0 -37
- package/lib/wrappers/invisible/InvisibleWrapper.js.map +0 -1
- package/lib/wrappers/invisible/ValueMemory.js +0 -19
- package/lib/wrappers/invisible/ValueMemory.js.map +0 -1
- package/lib/wrappers/text/AttributeHandler.js +0 -137
- package/lib/wrappers/text/AttributeHandler.js.map +0 -1
- package/lib/wrappers/text/Coder.js +0 -188
- package/lib/wrappers/text/Coder.js.map +0 -1
- package/lib/wrappers/text/ContentHandler.js +0 -65
- package/lib/wrappers/text/ContentHandler.js.map +0 -1
- package/lib/wrappers/text/CoreHandler.js +0 -147
- package/lib/wrappers/text/CoreHandler.js.map +0 -1
- package/lib/wrappers/text/TextWrapper.js +0 -36
- package/lib/wrappers/text/TextWrapper.js.map +0 -1
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
|
-
import { decodeFromText, encodeMessage, removeSecrets, stringToCodePoints, } from '../../helpers/secret';
|
|
27
|
-
import { ValueMemory } from './ValueMemory';
|
|
28
|
-
var Coder = /** @class */ (function () {
|
|
29
|
-
function Coder() {
|
|
30
|
-
this.keyMemory = new ValueMemory();
|
|
31
|
-
this.defaultMemory = new ValueMemory();
|
|
32
|
-
}
|
|
33
|
-
Coder.prototype.unwrap = function (text) {
|
|
34
|
-
var _this = this;
|
|
35
|
-
var keysAndParams = [];
|
|
36
|
-
var messages = decodeFromText(text);
|
|
37
|
-
messages.forEach(function (msg) {
|
|
38
|
-
var _a = __read(stringToCodePoints(msg), 2), keyCode = _a[0], defaultCode = _a[1];
|
|
39
|
-
var key = _this.keyMemory.numberToValue(keyCode);
|
|
40
|
-
var defaultValue = defaultCode !== undefined
|
|
41
|
-
? _this.defaultMemory.numberToValue(defaultCode)
|
|
42
|
-
: undefined;
|
|
43
|
-
keysAndParams.push({
|
|
44
|
-
key: key,
|
|
45
|
-
params: undefined,
|
|
46
|
-
defaultValue: defaultValue,
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
var result = removeSecrets(text);
|
|
50
|
-
if (keysAndParams.length) {
|
|
51
|
-
return { text: result, keys: keysAndParams };
|
|
52
|
-
}
|
|
53
|
-
return undefined;
|
|
54
|
-
};
|
|
55
|
-
Coder.prototype.wrap = function (key, _params, defaultValue, translation) {
|
|
56
|
-
if (_params === void 0) { _params = {}; }
|
|
57
|
-
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
58
|
-
if (translation === void 0) { translation = undefined; }
|
|
59
|
-
var codes = [this.keyMemory.valueToNumber(key)];
|
|
60
|
-
if (defaultValue) {
|
|
61
|
-
codes.push(this.defaultMemory.valueToNumber(defaultValue));
|
|
62
|
-
}
|
|
63
|
-
var value = translation || '';
|
|
64
|
-
var invisibleMark = encodeMessage(String.fromCodePoint.apply(String, __spreadArray([], __read(codes), false)));
|
|
65
|
-
return typeof value === 'string'
|
|
66
|
-
? value + invisibleMark
|
|
67
|
-
: Array.isArray(value)
|
|
68
|
-
? __spreadArray(__spreadArray([], __read(value), false), [invisibleMark], false) : [value, invisibleMark];
|
|
69
|
-
};
|
|
70
|
-
return Coder;
|
|
71
|
-
}());
|
|
72
|
-
export { Coder };
|
|
73
|
-
//# sourceMappingURL=Coder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Coder.js","sourceRoot":"","sources":["../../../src/wrappers/invisible/Coder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;IAAA;QACU,cAAS,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,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a,CAAC,YAAY,CAAC,CAAC,CAAC;SAC5D;QAED,IAAM,KAAK,GAAG,WAAW,IAAI,EAAE,CAAC;QAChC,IAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,aAAa,OAApB,MAAM,2BAAkB,KAAK,WAAE,CAAC;QAEpE,OAAO,OAAO,KAAK,KAAK,QAAQ;YAC9B,CAAC,CAAC,KAAK,GAAG,aAAa;YACvB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACtB,CAAC,wCAAK,KAAK,YAAE,aAAa,UAC1B,CAAC,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC7B,CAAC;IACH,YAAC;AAAD,CAAC,AAlDD,IAkDC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { NodeHelper } from '../../helpers/NodeHelper';
|
|
38
|
-
import { INVISIBLE_CHARACTERS } from '../../helpers/secret';
|
|
39
|
-
var ContentHandler = /** @class */ (function () {
|
|
40
|
-
function ContentHandler(nodeHandler) {
|
|
41
|
-
this.nodeHandler = nodeHandler;
|
|
42
|
-
}
|
|
43
|
-
ContentHandler.prototype.handle = function (node) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var xPath, nodes, filtered;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
xPath = "./descendant-or-self::text()[contains(., '".concat(INVISIBLE_CHARACTERS[0], "')]");
|
|
50
|
-
nodes = NodeHelper.evaluate(xPath, node);
|
|
51
|
-
filtered = this.nodeHandler.filterRestricted(nodes);
|
|
52
|
-
return [4 /*yield*/, this.nodeHandler.handleNodes(filtered)];
|
|
53
|
-
case 1:
|
|
54
|
-
_a.sent();
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
return ContentHandler;
|
|
61
|
-
}());
|
|
62
|
-
export { ContentHandler };
|
|
63
|
-
//# sourceMappingURL=ContentHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentHandler.js","sourceRoot":"","sources":["../../../src/wrappers/invisible/ContentHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D;IACE,wBAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAE1C,+BAAM,GAAZ,UAAa,IAAU;;;;;;wBACf,KAAK,GAAG,oDAA6C,oBAAoB,CAAC,CAAC,CAAC,QAAK,CAAC;wBAClF,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;wBACzC,QAAQ,GAAW,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAe,CAAC,CAAC;wBAE5E,qBAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAA;;wBAA5C,SAA4C,CAAC;;;;;KAC9C;IACH,qBAAC;AAAD,CAAC,AAVD,IAUC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var CoreHandler = /** @class */ (function () {
|
|
38
|
-
function CoreHandler(textHandler, attributeHandler, wrappedHandler) {
|
|
39
|
-
this.textHandler = textHandler;
|
|
40
|
-
this.attributeHandler = attributeHandler;
|
|
41
|
-
this.wrappedHandler = wrappedHandler;
|
|
42
|
-
}
|
|
43
|
-
CoreHandler.prototype.handleSubtree = function (target) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, this.attributeHandler.handle(target)];
|
|
48
|
-
case 1:
|
|
49
|
-
_a.sent();
|
|
50
|
-
return [4 /*yield*/, this.textHandler.handle(target)];
|
|
51
|
-
case 2:
|
|
52
|
-
_a.sent();
|
|
53
|
-
return [4 /*yield*/, this.wrappedHandler.handle(target)];
|
|
54
|
-
case 3:
|
|
55
|
-
_a.sent();
|
|
56
|
-
return [2 /*return*/];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
return CoreHandler;
|
|
62
|
-
}());
|
|
63
|
-
export { CoreHandler };
|
|
64
|
-
//# sourceMappingURL=CoreHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreHandler.js","sourceRoot":"","sources":["../../../src/wrappers/invisible/CoreHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;IACE,qBACU,WAA2B,EAC3B,gBAAkC,EAClC,cAA8B;QAF9B,gBAAW,GAAX,WAAW,CAAgB;QAC3B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAES,mCAAa,GAA1B,UAA2B,MAAe;;;;4BACxC,qBAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAA;;wBAA1C,SAA0C,CAAC;wBAC3C,qBAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAA;;wBAArC,SAAqC,CAAC;wBACtC,qBAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,EAAA;;wBAAxC,SAAwC,CAAC;;;;;KAC1C;IACH,kBAAC;AAAD,CAAC,AAZD,IAYC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { NodeHandler } from '../NodeHandler';
|
|
2
|
-
import { AttributeHandler } from './AttributeHandler';
|
|
3
|
-
import { Coder } from './Coder';
|
|
4
|
-
import { CoreHandler } from './CoreHandler';
|
|
5
|
-
import { ContentHandler } from './ContentHandler';
|
|
6
|
-
import { WrappedHandler } from '../WrappedHandler';
|
|
7
|
-
var InvisibleWrapper = /** @class */ (function () {
|
|
8
|
-
function InvisibleWrapper(properties, elementRegistrar) {
|
|
9
|
-
this.coder = new Coder();
|
|
10
|
-
this.nodeHandler = new NodeHandler(properties, elementRegistrar, this);
|
|
11
|
-
this.textHandler = new ContentHandler(this.nodeHandler);
|
|
12
|
-
this.attributeHandler = new AttributeHandler(properties, this.nodeHandler);
|
|
13
|
-
this.wrappedHandler = new WrappedHandler(elementRegistrar, this.nodeHandler);
|
|
14
|
-
this.coreHandler = new CoreHandler(this.textHandler, this.attributeHandler, this.wrappedHandler);
|
|
15
|
-
}
|
|
16
|
-
InvisibleWrapper.prototype.handleText = function (node) {
|
|
17
|
-
return this.textHandler.handle(node);
|
|
18
|
-
};
|
|
19
|
-
InvisibleWrapper.prototype.handleSubtree = function (node) {
|
|
20
|
-
return this.coreHandler.handleSubtree(node);
|
|
21
|
-
};
|
|
22
|
-
InvisibleWrapper.prototype.handleAttribute = function (node) {
|
|
23
|
-
return this.attributeHandler.handle(node);
|
|
24
|
-
};
|
|
25
|
-
InvisibleWrapper.prototype.wrap = function (key, params, defaultValue, translation) {
|
|
26
|
-
if (params === void 0) { params = {}; }
|
|
27
|
-
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
28
|
-
if (translation === void 0) { translation = ''; }
|
|
29
|
-
return this.coder.wrap(key, params, defaultValue, translation);
|
|
30
|
-
};
|
|
31
|
-
InvisibleWrapper.prototype.unwrap = function (text) {
|
|
32
|
-
return this.coder.unwrap(text);
|
|
33
|
-
};
|
|
34
|
-
return InvisibleWrapper;
|
|
35
|
-
}());
|
|
36
|
-
export { InvisibleWrapper };
|
|
37
|
-
//# sourceMappingURL=InvisibleWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvisibleWrapper.js","sourceRoot":"","sources":["../../../src/wrappers/invisible/InvisibleWrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;IAOE,0BAAY,UAAsB,EAAE,gBAAkC;QACpE,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,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0 @@
|
|
|
1
|
-
var ValueMemory = /** @class */ (function () {
|
|
2
|
-
function ValueMemory() {
|
|
3
|
-
this.values = [];
|
|
4
|
-
}
|
|
5
|
-
ValueMemory.prototype.valueToNumber = function (key) {
|
|
6
|
-
var index = this.values.indexOf(key);
|
|
7
|
-
if (index === -1) {
|
|
8
|
-
index = this.values.length;
|
|
9
|
-
this.values.push(key);
|
|
10
|
-
}
|
|
11
|
-
return index;
|
|
12
|
-
};
|
|
13
|
-
ValueMemory.prototype.numberToValue = function (num) {
|
|
14
|
-
return this.values[num];
|
|
15
|
-
};
|
|
16
|
-
return ValueMemory;
|
|
17
|
-
}());
|
|
18
|
-
export { ValueMemory };
|
|
19
|
-
//# sourceMappingURL=ValueMemory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValueMemory.js","sourceRoot":"","sources":["../../../src/wrappers/invisible/ValueMemory.ts"],"names":[],"mappings":"AAAA;IAAA;QACU,WAAM,GAAa,EAAE,CAAC;IAchC,CAAC;IAZQ,mCAAa,GAApB,UAAqB,GAAW;QAC9B,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACvB;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,mCAAa,GAApB,UAAqB,GAAW;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACH,kBAAC;AAAD,CAAC,AAfD,IAeC"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __values = (this && this.__values) || function(o) {
|
|
38
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
-
if (m) return m.call(o);
|
|
40
|
-
if (o && typeof o.length === "number") return {
|
|
41
|
-
next: function () {
|
|
42
|
-
if (o && i >= o.length) o = void 0;
|
|
43
|
-
return { value: o && o[i++], done: !o };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
-
};
|
|
48
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
-
if (!m) return o;
|
|
51
|
-
var i = m.call(o), r, ar = [], e;
|
|
52
|
-
try {
|
|
53
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
-
}
|
|
55
|
-
catch (error) { e = { error: error }; }
|
|
56
|
-
finally {
|
|
57
|
-
try {
|
|
58
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
-
}
|
|
60
|
-
finally { if (e) throw e.error; }
|
|
61
|
-
}
|
|
62
|
-
return ar;
|
|
63
|
-
};
|
|
64
|
-
import { NodeHelper } from '../../helpers/NodeHelper';
|
|
65
|
-
var AttributeHandler = /** @class */ (function () {
|
|
66
|
-
function AttributeHandler(properties, nodeHandler) {
|
|
67
|
-
this.properties = properties;
|
|
68
|
-
this.nodeHandler = nodeHandler;
|
|
69
|
-
}
|
|
70
|
-
AttributeHandler.prototype.handle = function (node) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var inputPrefix, inputSuffix, _a, _b, _c, tag, attributes, attributes_1, attributes_1_1, attribute, expression, nodes, e_1_1, e_2_1;
|
|
73
|
-
var e_2, _d, e_1, _e;
|
|
74
|
-
return __generator(this, function (_f) {
|
|
75
|
-
switch (_f.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
inputPrefix = this.properties.config.inputPrefix;
|
|
78
|
-
inputSuffix = this.properties.config.inputSuffix;
|
|
79
|
-
_f.label = 1;
|
|
80
|
-
case 1:
|
|
81
|
-
_f.trys.push([1, 12, 13, 14]);
|
|
82
|
-
_a = __values(Object.entries(this.properties.config.tagAttributes)), _b = _a.next();
|
|
83
|
-
_f.label = 2;
|
|
84
|
-
case 2:
|
|
85
|
-
if (!!_b.done) return [3 /*break*/, 11];
|
|
86
|
-
_c = __read(_b.value, 2), tag = _c[0], attributes = _c[1];
|
|
87
|
-
_f.label = 3;
|
|
88
|
-
case 3:
|
|
89
|
-
_f.trys.push([3, 8, 9, 10]);
|
|
90
|
-
attributes_1 = (e_1 = void 0, __values(attributes)), attributes_1_1 = attributes_1.next();
|
|
91
|
-
_f.label = 4;
|
|
92
|
-
case 4:
|
|
93
|
-
if (!!attributes_1_1.done) return [3 /*break*/, 7];
|
|
94
|
-
attribute = attributes_1_1.value;
|
|
95
|
-
expression = "descendant-or-self::".concat(tag, "/@").concat(attribute, "[contains(., '").concat(inputPrefix, "') and contains(., '").concat(inputSuffix, "')]");
|
|
96
|
-
nodes = NodeHelper.evaluate(expression, node);
|
|
97
|
-
return [4 /*yield*/, this.nodeHandler.handleNodes(nodes)];
|
|
98
|
-
case 5:
|
|
99
|
-
_f.sent();
|
|
100
|
-
_f.label = 6;
|
|
101
|
-
case 6:
|
|
102
|
-
attributes_1_1 = attributes_1.next();
|
|
103
|
-
return [3 /*break*/, 4];
|
|
104
|
-
case 7: return [3 /*break*/, 10];
|
|
105
|
-
case 8:
|
|
106
|
-
e_1_1 = _f.sent();
|
|
107
|
-
e_1 = { error: e_1_1 };
|
|
108
|
-
return [3 /*break*/, 10];
|
|
109
|
-
case 9:
|
|
110
|
-
try {
|
|
111
|
-
if (attributes_1_1 && !attributes_1_1.done && (_e = attributes_1.return)) _e.call(attributes_1);
|
|
112
|
-
}
|
|
113
|
-
finally { if (e_1) throw e_1.error; }
|
|
114
|
-
return [7 /*endfinally*/];
|
|
115
|
-
case 10:
|
|
116
|
-
_b = _a.next();
|
|
117
|
-
return [3 /*break*/, 2];
|
|
118
|
-
case 11: return [3 /*break*/, 14];
|
|
119
|
-
case 12:
|
|
120
|
-
e_2_1 = _f.sent();
|
|
121
|
-
e_2 = { error: e_2_1 };
|
|
122
|
-
return [3 /*break*/, 14];
|
|
123
|
-
case 13:
|
|
124
|
-
try {
|
|
125
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
126
|
-
}
|
|
127
|
-
finally { if (e_2) throw e_2.error; }
|
|
128
|
-
return [7 /*endfinally*/];
|
|
129
|
-
case 14: return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
return AttributeHandler;
|
|
135
|
-
}());
|
|
136
|
-
export { AttributeHandler };
|
|
137
|
-
//# sourceMappingURL=AttributeHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeHandler.js","sourceRoot":"","sources":["../../../src/wrappers/text/AttributeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;IACE,0BACU,UAAsB,EACtB,WAAwB;QADxB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAa;IAC/B,CAAC;IAEE,iCAAM,GAAZ,UAAa,IAAa;;;;;;;wBAClB,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC;wBACjD,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC;;;;wBAEvB,KAAA,SAAA,MAAM,CAAC,OAAO,CAC5C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CACrC,CAAA;;;;wBAFU,KAAA,mBAAiB,EAAhB,GAAG,QAAA,EAAE,UAAU,QAAA;;;;wBAGD,8BAAA,SAAA,UAAU,CAAA,CAAA;;;;wBAAvB,SAAS;wBACZ,UAAU,GAAG,8BAAuB,GAAG,eAAK,SAAS,2BAAiB,WAAW,iCAAuB,WAAW,QAAK,CAAC;wBACzH,KAAK,GAAuB,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;wBACxE,qBAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,EAAA;;wBAAzC,SAAyC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAG/C;IACH,uBAAC;AAAD,CAAC,AApBD,IAoBC"}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
var __values = (this && this.__values) || function(o) {
|
|
2
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
-
if (m) return m.call(o);
|
|
4
|
-
if (o && typeof o.length === "number") return {
|
|
5
|
-
next: function () {
|
|
6
|
-
if (o && i >= o.length) o = void 0;
|
|
7
|
-
return { value: o && o[i++], done: !o };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
import { TextHelper } from '../../helpers/TextHelper';
|
|
29
|
-
var Coder = /** @class */ (function () {
|
|
30
|
-
function Coder(properties, textService) {
|
|
31
|
-
this.properties = properties;
|
|
32
|
-
this.textService = textService;
|
|
33
|
-
this.escapeForRegExp = function (string) {
|
|
34
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
35
|
-
};
|
|
36
|
-
this.escapeParam = function (param) {
|
|
37
|
-
if (typeof param === 'string') {
|
|
38
|
-
return param.replace(/[,:\\]/gs, '\\$&');
|
|
39
|
-
}
|
|
40
|
-
if (typeof param === 'number' || typeof param === 'bigint') {
|
|
41
|
-
return param.toString();
|
|
42
|
-
}
|
|
43
|
-
// eslint-disable-next-line no-console
|
|
44
|
-
console.warn("Parameters of type \"".concat(typeof param, "\" are not supported in \"text\" wrapper mode."));
|
|
45
|
-
return param;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
Object.defineProperty(Coder.prototype, "rawUnWrapRegex", {
|
|
49
|
-
get: function () {
|
|
50
|
-
var escapedPrefix = this.escapeForRegExp(this.properties.config.inputPrefix);
|
|
51
|
-
var escapedSuffix = this.escapeForRegExp(this.properties.config.inputSuffix);
|
|
52
|
-
return "(\\\\?)(".concat(escapedPrefix, "(.*?)").concat(escapedSuffix, ")");
|
|
53
|
-
},
|
|
54
|
-
enumerable: false,
|
|
55
|
-
configurable: true
|
|
56
|
-
});
|
|
57
|
-
Coder.parseUnwrapped = function (unwrappedString) {
|
|
58
|
-
var e_1, _a;
|
|
59
|
-
var escaped = false;
|
|
60
|
-
var actual = '';
|
|
61
|
-
var paramName = '';
|
|
62
|
-
var readingState = 'KEY';
|
|
63
|
-
var result = {
|
|
64
|
-
key: '',
|
|
65
|
-
params: {},
|
|
66
|
-
defaultValue: undefined,
|
|
67
|
-
};
|
|
68
|
-
try {
|
|
69
|
-
for (var unwrappedString_1 = __values(unwrappedString), unwrappedString_1_1 = unwrappedString_1.next(); !unwrappedString_1_1.done; unwrappedString_1_1 = unwrappedString_1.next()) {
|
|
70
|
-
var char = unwrappedString_1_1.value;
|
|
71
|
-
if (char === '\\' && !escaped) {
|
|
72
|
-
escaped = true;
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (escaped) {
|
|
76
|
-
escaped = false;
|
|
77
|
-
actual += char;
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (readingState === 'KEY' && char === ',') {
|
|
81
|
-
readingState = 'DEFAULT_VALUE';
|
|
82
|
-
result.key = actual;
|
|
83
|
-
actual = '';
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (readingState === 'KEY' && char === ':') {
|
|
87
|
-
readingState = 'PARAM_NAME';
|
|
88
|
-
result.key = actual;
|
|
89
|
-
actual = '';
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (readingState === 'DEFAULT_VALUE' && char === ':') {
|
|
93
|
-
readingState = 'PARAM_NAME';
|
|
94
|
-
result.defaultValue = actual;
|
|
95
|
-
actual = '';
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (readingState === 'PARAM_NAME' && char === ':') {
|
|
99
|
-
readingState = 'PARAM_VALUE';
|
|
100
|
-
paramName = actual;
|
|
101
|
-
actual = '';
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (readingState === 'PARAM_VALUE' && char === ',') {
|
|
105
|
-
readingState = 'PARAM_NAME';
|
|
106
|
-
result.params[paramName] = actual;
|
|
107
|
-
actual = '';
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
actual += char;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
114
|
-
finally {
|
|
115
|
-
try {
|
|
116
|
-
if (unwrappedString_1_1 && !unwrappedString_1_1.done && (_a = unwrappedString_1.return)) _a.call(unwrappedString_1);
|
|
117
|
-
}
|
|
118
|
-
finally { if (e_1) throw e_1.error; }
|
|
119
|
-
}
|
|
120
|
-
if (readingState === 'KEY') {
|
|
121
|
-
result.key = actual;
|
|
122
|
-
}
|
|
123
|
-
if (readingState === 'DEFAULT_VALUE') {
|
|
124
|
-
result.defaultValue = actual;
|
|
125
|
-
}
|
|
126
|
-
if (readingState === 'PARAM_VALUE') {
|
|
127
|
-
result.params[paramName] = actual;
|
|
128
|
-
}
|
|
129
|
-
return result;
|
|
130
|
-
};
|
|
131
|
-
Coder.prototype.unwrap = function (text) {
|
|
132
|
-
var matchRegexp = new RegExp(this.rawUnWrapRegex, 'gs');
|
|
133
|
-
var keysAndParams = [];
|
|
134
|
-
var matched = false;
|
|
135
|
-
var match;
|
|
136
|
-
var start = 0;
|
|
137
|
-
var result = '';
|
|
138
|
-
while ((match = matchRegexp.exec(text)) !== null) {
|
|
139
|
-
var pre = match[1];
|
|
140
|
-
var _a = __read(match, 4), fullMatch = _a[0], _ = _a[1], wrapped = _a[2], unwrapped = _a[3];
|
|
141
|
-
var index = match.index, input = match.input;
|
|
142
|
-
result += input.substr(start, index - start);
|
|
143
|
-
start = index + fullMatch.length;
|
|
144
|
-
if (pre === '\\') {
|
|
145
|
-
if (!TextHelper.isCharEscaped(index, text)) {
|
|
146
|
-
result += wrapped;
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
pre = '';
|
|
150
|
-
}
|
|
151
|
-
var translated = this.getTranslatedWithMetadata(unwrapped);
|
|
152
|
-
keysAndParams.push({
|
|
153
|
-
key: translated.key,
|
|
154
|
-
params: translated.params,
|
|
155
|
-
defaultValue: translated.defaultValue,
|
|
156
|
-
});
|
|
157
|
-
matched = true;
|
|
158
|
-
result += pre + translated.translated;
|
|
159
|
-
}
|
|
160
|
-
result += text.substring(start);
|
|
161
|
-
if (matched) {
|
|
162
|
-
return { text: result, keys: keysAndParams };
|
|
163
|
-
}
|
|
164
|
-
return undefined;
|
|
165
|
-
};
|
|
166
|
-
Coder.prototype.wrap = function (key, params, defaultValue) {
|
|
167
|
-
var _this = this;
|
|
168
|
-
if (params === void 0) { params = {}; }
|
|
169
|
-
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
170
|
-
var paramString = Object.entries(params)
|
|
171
|
-
.map(function (_a) {
|
|
172
|
-
var _b = __read(_a, 2), name = _b[0], value = _b[1];
|
|
173
|
-
return "".concat(_this.escapeParam(name), ":").concat(_this.escapeParam(value));
|
|
174
|
-
})
|
|
175
|
-
.join(',');
|
|
176
|
-
paramString = paramString.length ? ":".concat(paramString) : '';
|
|
177
|
-
var defaultString = defaultValue !== undefined ? ",".concat(this.escapeParam(defaultValue)) : '';
|
|
178
|
-
return "".concat(this.properties.config.inputPrefix).concat(this.escapeParam(key)).concat(defaultString).concat(paramString).concat(this.properties.config.inputSuffix);
|
|
179
|
-
};
|
|
180
|
-
Coder.prototype.getTranslatedWithMetadata = function (text) {
|
|
181
|
-
var _a = Coder.parseUnwrapped(text), key = _a.key, params = _a.params, defaultValue = _a.defaultValue;
|
|
182
|
-
var translated = this.textService.instant(key, params, undefined, false, defaultValue);
|
|
183
|
-
return { translated: translated, key: key, params: params, defaultValue: defaultValue };
|
|
184
|
-
};
|
|
185
|
-
return Coder;
|
|
186
|
-
}());
|
|
187
|
-
export { Coder };
|
|
188
|
-
//# sourceMappingURL=Coder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Coder.js","sourceRoot":"","sources":["../../../src/wrappers/text/Coder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAA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