@tolgee/core 4.2.1 → 4.3.0-rc.10eeecf.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.
Files changed (158) hide show
  1. package/dist/tolgee.cjs.js +28 -21
  2. package/dist/tolgee.cjs.js.map +1 -1
  3. package/dist/tolgee.cjs.min.js +1 -1
  4. package/dist/tolgee.cjs.min.js.map +1 -1
  5. package/dist/tolgee.esm.js +1 -1
  6. package/dist/tolgee.esm.js.map +1 -1
  7. package/dist/tolgee.umd.js +28 -21
  8. package/dist/tolgee.umd.js.map +1 -1
  9. package/dist/tolgee.umd.min.js +1 -1
  10. package/dist/tolgee.umd.min.js.map +1 -1
  11. package/lib/Constants/Global.d.ts +0 -0
  12. package/lib/Constants/ModifierKey.d.ts +0 -0
  13. package/lib/Errors/ApiHttpError.d.ts +0 -0
  14. package/lib/Observer.d.ts +0 -0
  15. package/lib/Properties.d.ts +0 -0
  16. package/lib/Tolgee.d.ts +0 -0
  17. package/lib/TolgeeConfig.d.ts +7 -1
  18. package/lib/helpers/NodeHelper.d.ts +0 -0
  19. package/lib/helpers/TextHelper.d.ts +0 -0
  20. package/lib/helpers/commonTypes.d.ts +0 -0
  21. package/lib/helpers/encoderPolyfill.d.ts +0 -0
  22. package/lib/helpers/secret.d.ts +0 -0
  23. package/lib/helpers/sleep.d.ts +0 -0
  24. package/lib/highlighter/HighlightFunctionsInitializer.d.ts +0 -0
  25. package/lib/highlighter/MouseEventHandler.d.ts +0 -0
  26. package/lib/highlighter/TranslationHighlighter.d.ts +0 -0
  27. package/lib/index.d.ts +3 -0
  28. package/lib/modules/IcuFormatter.d.ts +0 -0
  29. package/lib/modules/index.d.ts +0 -0
  30. package/lib/services/ApiHttpService.d.ts +0 -0
  31. package/lib/services/CoreService.d.ts +0 -0
  32. package/lib/services/DependencyService.d.ts +0 -0
  33. package/lib/services/ElementRegistrar.d.ts +0 -0
  34. package/lib/services/EventEmitter.d.ts +0 -0
  35. package/lib/services/EventService.d.ts +0 -0
  36. package/lib/services/ModuleService.d.ts +0 -0
  37. package/lib/services/ScreenshotService.d.ts +0 -0
  38. package/lib/services/Subscription.d.ts +0 -0
  39. package/lib/services/TextService.d.ts +0 -0
  40. package/lib/services/TranslationService.d.ts +0 -0
  41. package/lib/toolsManager/Messages.d.ts +0 -0
  42. package/lib/toolsManager/PluginManager.d.ts +0 -0
  43. package/lib/types/DTOs.d.ts +0 -0
  44. package/lib/types/apiSchema.generated.d.ts +0 -0
  45. package/lib/types.d.ts +0 -0
  46. package/lib/wrappers/AbstractWrapper.d.ts +0 -0
  47. package/lib/wrappers/NodeHandler.d.ts +0 -0
  48. package/lib/wrappers/WrappedHandler.d.ts +0 -0
  49. package/lib/wrappers/invisible/AttributeHandler.d.ts +0 -0
  50. package/lib/wrappers/invisible/Coder.d.ts +0 -0
  51. package/lib/wrappers/invisible/ContentHandler.d.ts +0 -0
  52. package/lib/wrappers/invisible/CoreHandler.d.ts +0 -0
  53. package/lib/wrappers/invisible/InvisibleWrapper.d.ts +0 -0
  54. package/lib/wrappers/invisible/ValueMemory.d.ts +0 -0
  55. package/lib/wrappers/text/AttributeHandler.d.ts +0 -0
  56. package/lib/wrappers/text/Coder.d.ts +0 -0
  57. package/lib/wrappers/text/ContentHandler.d.ts +0 -0
  58. package/lib/wrappers/text/CoreHandler.d.ts +0 -0
  59. package/lib/wrappers/text/TextWrapper.d.ts +0 -0
  60. package/package.json +6 -2
  61. package/lib/Constants/Global.js +0 -5
  62. package/lib/Constants/Global.js.map +0 -1
  63. package/lib/Constants/ModifierKey.js +0 -8
  64. package/lib/Constants/ModifierKey.js.map +0 -1
  65. package/lib/Errors/ApiHttpError.js +0 -29
  66. package/lib/Errors/ApiHttpError.js.map +0 -1
  67. package/lib/Observer.js +0 -144
  68. package/lib/Observer.js.map +0 -1
  69. package/lib/Properties.js +0 -86
  70. package/lib/Properties.js.map +0 -1
  71. package/lib/Tolgee.js +0 -308
  72. package/lib/Tolgee.js.map +0 -1
  73. package/lib/TolgeeConfig.js +0 -85
  74. package/lib/TolgeeConfig.js.map +0 -1
  75. package/lib/helpers/NodeHelper.js +0 -140
  76. package/lib/helpers/NodeHelper.js.map +0 -1
  77. package/lib/helpers/TextHelper.js +0 -58
  78. package/lib/helpers/TextHelper.js.map +0 -1
  79. package/lib/helpers/commonTypes.js +0 -2
  80. package/lib/helpers/commonTypes.js.map +0 -1
  81. package/lib/helpers/encoderPolyfill.js +0 -96
  82. package/lib/helpers/encoderPolyfill.js.map +0 -1
  83. package/lib/helpers/secret.js +0 -73
  84. package/lib/helpers/secret.js.map +0 -1
  85. package/lib/helpers/sleep.js +0 -4
  86. package/lib/helpers/sleep.js.map +0 -1
  87. package/lib/highlighter/HighlightFunctionsInitializer.js +0 -24
  88. package/lib/highlighter/HighlightFunctionsInitializer.js.map +0 -1
  89. package/lib/highlighter/MouseEventHandler.js +0 -157
  90. package/lib/highlighter/MouseEventHandler.js.map +0 -1
  91. package/lib/highlighter/TranslationHighlighter.js +0 -220
  92. package/lib/highlighter/TranslationHighlighter.js.map +0 -1
  93. package/lib/index.js +0 -8
  94. package/lib/index.js.map +0 -1
  95. package/lib/modules/IcuFormatter.js +0 -18
  96. package/lib/modules/IcuFormatter.js.map +0 -1
  97. package/lib/modules/index.js +0 -2
  98. package/lib/modules/index.js.map +0 -1
  99. package/lib/services/ApiHttpService.js +0 -171
  100. package/lib/services/ApiHttpService.js.map +0 -1
  101. package/lib/services/CoreService.js +0 -129
  102. package/lib/services/CoreService.js.map +0 -1
  103. package/lib/services/DependencyService.js +0 -64
  104. package/lib/services/DependencyService.js.map +0 -1
  105. package/lib/services/ElementRegistrar.js +0 -193
  106. package/lib/services/ElementRegistrar.js.map +0 -1
  107. package/lib/services/EventEmitter.js +0 -68
  108. package/lib/services/EventEmitter.js.map +0 -1
  109. package/lib/services/EventService.js +0 -12
  110. package/lib/services/EventService.js.map +0 -1
  111. package/lib/services/ModuleService.js +0 -18
  112. package/lib/services/ModuleService.js.map +0 -1
  113. package/lib/services/ScreenshotService.js +0 -67
  114. package/lib/services/ScreenshotService.js.map +0 -1
  115. package/lib/services/Subscription.js +0 -11
  116. package/lib/services/Subscription.js.map +0 -1
  117. package/lib/services/TextService.js +0 -94
  118. package/lib/services/TextService.js.map +0 -1
  119. package/lib/services/TranslationService.js +0 -523
  120. package/lib/services/TranslationService.js.map +0 -1
  121. package/lib/toolsManager/Messages.js +0 -46
  122. package/lib/toolsManager/Messages.js.map +0 -1
  123. package/lib/toolsManager/PluginManager.js +0 -153
  124. package/lib/toolsManager/PluginManager.js.map +0 -1
  125. package/lib/types/DTOs.js +0 -10
  126. package/lib/types/DTOs.js.map +0 -1
  127. package/lib/types/apiSchema.generated.js +0 -6
  128. package/lib/types/apiSchema.generated.js.map +0 -1
  129. package/lib/types.js +0 -2
  130. package/lib/types.js.map +0 -1
  131. package/lib/wrappers/AbstractWrapper.js +0 -2
  132. package/lib/wrappers/AbstractWrapper.js.map +0 -1
  133. package/lib/wrappers/NodeHandler.js +0 -178
  134. package/lib/wrappers/NodeHandler.js.map +0 -1
  135. package/lib/wrappers/WrappedHandler.js +0 -67
  136. package/lib/wrappers/WrappedHandler.js.map +0 -1
  137. package/lib/wrappers/invisible/AttributeHandler.js +0 -134
  138. package/lib/wrappers/invisible/AttributeHandler.js.map +0 -1
  139. package/lib/wrappers/invisible/Coder.js +0 -73
  140. package/lib/wrappers/invisible/Coder.js.map +0 -1
  141. package/lib/wrappers/invisible/ContentHandler.js +0 -63
  142. package/lib/wrappers/invisible/ContentHandler.js.map +0 -1
  143. package/lib/wrappers/invisible/CoreHandler.js +0 -64
  144. package/lib/wrappers/invisible/CoreHandler.js.map +0 -1
  145. package/lib/wrappers/invisible/InvisibleWrapper.js +0 -37
  146. package/lib/wrappers/invisible/InvisibleWrapper.js.map +0 -1
  147. package/lib/wrappers/invisible/ValueMemory.js +0 -19
  148. package/lib/wrappers/invisible/ValueMemory.js.map +0 -1
  149. package/lib/wrappers/text/AttributeHandler.js +0 -137
  150. package/lib/wrappers/text/AttributeHandler.js.map +0 -1
  151. package/lib/wrappers/text/Coder.js +0 -188
  152. package/lib/wrappers/text/Coder.js.map +0 -1
  153. package/lib/wrappers/text/ContentHandler.js +0 -65
  154. package/lib/wrappers/text/ContentHandler.js.map +0 -1
  155. package/lib/wrappers/text/CoreHandler.js +0 -147
  156. package/lib/wrappers/text/CoreHandler.js.map +0 -1
  157. package/lib/wrappers/text/TextWrapper.js +0 -36
  158. package/lib/wrappers/text/TextWrapper.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["../../src/services/EventEmitter.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C;IAAA;QACU,cAAS,GAAG,CAAC,CAAC;QACd,mBAAc,GAAiC,IAAI,GAAG,EAG3D,CAAC;IAsCN,CAAC;IApCC,sBAAY,2CAAa;aAAzB;YACE,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;;;OAAA;IAEM,+BAAI,GAAX,UAAY,IAAQ;;QAClB,IAAM,cAAc,GAAG,EAAE,CAAC;;YAC1B,KAAuB,IAAA,KAAA,SAAA,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAA,gBAAA,4BAAE;gBAA/C,IAAM,QAAQ,WAAA;gBACjB,IAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAChC,IAAI,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,MAAM,CAAC,CAAA,KAAK,UAAU,EAAE;oBAC5C,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC/B;aACF;;;;;;;;;QAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO;SACR;QAED,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;YACzB,OAAA,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC;QAAjD,CAAiD,CAClD,CAAC;IACJ,CAAC;IAEM,oCAAS,GAAhB,UAAiB,QAAyB;QAA1C,iBAKC;QAJC,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,IAAM,YAAY,GAAG,IAAI,YAAY,CAAC,cAAM,OAAA,KAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAvB,CAAuB,CAAC,CAAC;QACrE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACxC,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,sCAAW,GAAnB,UAAoB,EAAU;QAC5B,IAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,EAAE;YACf,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;SACpD;IACH,CAAC;IACH,uBAAC;AAAD,CAAC,AA3CD,IA2CC"}
@@ -1,12 +0,0 @@
1
- import { EventEmitterImpl } from './EventEmitter';
2
- var EventService = /** @class */ (function () {
3
- function EventService() {
4
- this.TRANSLATION_CHANGED = new EventEmitterImpl();
5
- this.LANGUAGE_CHANGED = new EventEmitterImpl();
6
- this.LANGUAGE_LOADED = new EventEmitterImpl();
7
- this.ELEMENT_REGISTERED = new EventEmitterImpl();
8
- }
9
- return EventService;
10
- }());
11
- export { EventService };
12
- //# sourceMappingURL=EventService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventService.js","sourceRoot":"","sources":["../../src/services/EventService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIhE;IAAA;QACkB,wBAAmB,GACjC,IAAI,gBAAgB,EAAmB,CAAC;QAC1B,qBAAgB,GAC9B,IAAI,gBAAgB,EAAU,CAAC;QACjB,oBAAe,GAC7B,IAAI,gBAAgB,EAAU,CAAC;QACjB,uBAAkB,GAChC,IAAI,gBAAgB,EAAmB,CAAC;IAC5C,CAAC;IAAD,mBAAC;AAAD,CAAC,AATD,IASC"}
@@ -1,18 +0,0 @@
1
- var ModuleService = /** @class */ (function () {
2
- function ModuleService() {
3
- var _this = this;
4
- this.formatter = null;
5
- this.addModule = function (module) {
6
- if (module.type === 'formatter') {
7
- var instance = new module();
8
- _this.formatter = instance;
9
- }
10
- else {
11
- throw new Error('Module with unknown type');
12
- }
13
- };
14
- }
15
- return ModuleService;
16
- }());
17
- export { ModuleService };
18
- //# sourceMappingURL=ModuleService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModuleService.js","sourceRoot":"","sources":["../../src/services/ModuleService.ts"],"names":[],"mappings":"AAEA;IAAA;QAAA,iBAWC;QAVC,cAAS,GAAqB,IAAI,CAAC;QAEnC,cAAS,GAAG,UAAC,MAAoB;YAC/B,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE;gBAC/B,IAAM,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAC;gBAC9B,KAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;aAC3B;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;aAC7C;QACH,CAAC,CAAC;IACJ,CAAC;IAAD,oBAAC;AAAD,CAAC,AAXD,IAWC"}
@@ -1,67 +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 ScreenshotService = /** @class */ (function () {
38
- function ScreenshotService(coreService, apiHttpService) {
39
- this.coreService = coreService;
40
- this.apiHttpService = apiHttpService;
41
- }
42
- ScreenshotService.prototype.uploadImage = function (blob) {
43
- return __awaiter(this, void 0, void 0, function () {
44
- var formData;
45
- return __generator(this, function (_a) {
46
- formData = new FormData();
47
- formData.append('image', blob);
48
- return [2 /*return*/, this.apiHttpService.postJson('v2/image-upload', undefined, {
49
- headers: {},
50
- body: formData,
51
- })];
52
- });
53
- });
54
- };
55
- ScreenshotService.prototype.deleteImages = function (ids) {
56
- return __awaiter(this, void 0, void 0, function () {
57
- return __generator(this, function (_a) {
58
- return [2 /*return*/, this.apiHttpService.post("v2/image-upload/".concat(ids.join(',')), undefined, {
59
- method: 'delete',
60
- })];
61
- });
62
- });
63
- };
64
- return ScreenshotService;
65
- }());
66
- export { ScreenshotService };
67
- //# sourceMappingURL=ScreenshotService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScreenshotService.js","sourceRoot":"","sources":["../../src/services/ScreenshotService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;IACE,2BACU,WAAwB,EACxB,cAA8B;QAD9B,gBAAW,GAAX,WAAW,CAAa;QACxB,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAEE,uCAAW,GAAjB,UAAkB,IAAU;;;;gBACpB,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAEhC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAE/B,sBAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,EAAE,SAAS,EAAE;wBAChE,OAAO,EAAE,EAAE;wBACX,IAAI,EAAE,QAAQ;qBACf,CAAgC,EAAC;;;KACnC;IAEK,wCAAY,GAAlB,UAAmB,GAAa;;;gBAC9B,sBAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,0BAAmB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,EAClC,SAAS,EACT;wBACE,MAAM,EAAE,QAAQ;qBACjB,CACmB,EAAC;;;KACxB;IACH,wBAAC;AAAD,CAAC,AA1BD,IA0BC"}
@@ -1,11 +0,0 @@
1
- var Subscription = /** @class */ (function () {
2
- function Subscription(onUnsubscribe) {
3
- this.onUnsubscribe = onUnsubscribe;
4
- }
5
- Subscription.prototype.unsubscribe = function () {
6
- this.onUnsubscribe();
7
- };
8
- return Subscription;
9
- }());
10
- export { Subscription };
11
- //# sourceMappingURL=Subscription.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Subscription.js","sourceRoot":"","sources":["../../src/services/Subscription.ts"],"names":[],"mappings":"AAAA;IACE,sBAAoB,aAAyB;QAAzB,kBAAa,GAAb,aAAa,CAAY;IAAG,CAAC;IAEjD,kCAAW,GAAX;QACE,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IACH,mBAAC;AAAD,CAAC,AAND,IAMC"}
@@ -1,94 +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 TextService = /** @class */ (function () {
38
- function TextService(properties, translationService, moduleService) {
39
- var _this = this;
40
- this.properties = properties;
41
- this.translationService = translationService;
42
- this.moduleService = moduleService;
43
- this.format = function (translation, params, lang) {
44
- try {
45
- // try to format the text
46
- var result = translation;
47
- if (_this.moduleService.formatter) {
48
- result = _this.moduleService.formatter.format({
49
- translation: result,
50
- params: params,
51
- language: lang || _this.properties.currentLanguage,
52
- });
53
- }
54
- return result;
55
- }
56
- catch (e) {
57
- // if string cannot be formatted, throw error
58
- // eslint-disable-next-line no-console
59
- console.error(e);
60
- }
61
- };
62
- }
63
- TextService.prototype.translate = function (key, params, lang, orEmpty, defaultValue) {
64
- if (lang === void 0) { lang = this.properties.currentLanguage; }
65
- return __awaiter(this, void 0, void 0, function () {
66
- var translation;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0: return [4 /*yield*/, this.translationService.getTranslation(key, lang, defaultValue)];
70
- case 1:
71
- translation = _a.sent();
72
- return [2 /*return*/, this.formatTranslation(key, translation, params, lang, orEmpty)];
73
- }
74
- });
75
- });
76
- };
77
- TextService.prototype.instant = function (key, params, lang, orEmpty, defaultValue) {
78
- if (lang === void 0) { lang = this.properties.currentLanguage; }
79
- var translation = this.translationService.getFromCacheOrFallback(key, lang, defaultValue);
80
- return this.formatTranslation(key, translation, params, lang, orEmpty);
81
- };
82
- TextService.prototype.formatTranslation = function (key, translation, params, lang, orEmpty) {
83
- if (translation !== undefined) {
84
- return this.format(translation, params, lang);
85
- }
86
- if (!orEmpty) {
87
- return key;
88
- }
89
- return '';
90
- };
91
- return TextService;
92
- }());
93
- export { TextService };
94
- //# sourceMappingURL=TextService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextService.js","sourceRoot":"","sources":["../../src/services/TextService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;IACE,qBACU,UAAsB,EACtB,kBAAsC,EACtC,aAA4B;QAHtC,iBAII;QAHM,eAAU,GAAV,UAAU,CAAY;QACtB,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,kBAAa,GAAb,aAAa,CAAe;QAkDrB,WAAM,GAAG,UACxB,WAAmB,EACnB,MAAkC,EAClC,IAAwB;YAExB,IAAI;gBACF,yBAAyB;gBACzB,IAAI,MAAM,GAAyB,WAAW,CAAC;gBAC/C,IAAI,KAAI,CAAC,aAAa,CAAC,SAAS,EAAE;oBAChC,MAAM,GAAG,KAAI,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC;wBAC3C,WAAW,EAAE,MAAM;wBACnB,MAAM,QAAA;wBACN,QAAQ,EAAE,IAAI,IAAI,KAAI,CAAC,UAAU,CAAC,eAAe;qBAClD,CAAC,CAAC;iBACJ;gBACD,OAAO,MAA8B,CAAC;aACvC;YAAC,OAAO,CAAC,EAAE;gBACV,6CAA6C;gBAC7C,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aAClB;QACH,CAAC,CAAC;IAtEC,CAAC;IAEE,+BAAS,GAAf,UACE,GAAW,EACX,MAAkC,EAClC,IAAsC,EACtC,OAAiB,EACjB,YAAqB;QAFrB,qBAAA,EAAA,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe;;;;;4BAIlB,qBAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAC9D,GAAG,EACH,IAAI,EACJ,YAAY,CACb,EAAA;;wBAJK,WAAW,GAAG,SAInB;wBACD,sBAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,EAAC;;;;KACxE;IAED,6BAAO,GAAP,UACE,GAAW,EACX,MAAkC,EAClC,IAAsC,EACtC,OAAiB,EACjB,YAAqB;QAFrB,qBAAA,EAAA,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe;QAItC,IAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,sBAAsB,CAChE,GAAG,EACH,IAAI,EACJ,YAAY,CACb,CAAC;QAEF,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAEO,uCAAiB,GAAzB,UACE,GAAW,EACX,WAA+B,EAC/B,MAA8C,EAC9C,IAAwB,EACxB,OAA4B;QAE5B,IAAI,WAAW,KAAK,SAAS,EAAE;YAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC/C;QACD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,CAAC;SACZ;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAwBH,kBAAC;AAAD,CAAC,AA5ED,IA4EC"}