@sambath999/localize-token 12.4.3 → 12.4.4
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/bundles/sambath999-localize-token.umd.js +44 -41
- package/bundles/sambath999-localize-token.umd.js.map +1 -1
- package/esm2015/localize-token/helpers/interfaces.js +8 -1
- package/esm2015/localize-token/helpers/loccalize.api.helper.js +15 -19
- package/fesm2015/sambath999-localize-token.js +23 -19
- package/fesm2015/sambath999-localize-token.js.map +1 -1
- package/localize-token/helpers/interfaces.d.ts +3 -9
- package/localize-token/helpers/loccalize.api.helper.d.ts +4 -5
- package/package.json +1 -1
- package/sambath999-localize-token.metadata.json +1 -1
|
@@ -932,7 +932,14 @@
|
|
|
932
932
|
EMethod["PUT"] = "put";
|
|
933
933
|
EMethod["DELETE"] = "delete";
|
|
934
934
|
EMethod["PATCH"] = "patch";
|
|
935
|
-
})(exports.EMethod || (exports.EMethod = {}));
|
|
935
|
+
})(exports.EMethod || (exports.EMethod = {}));
|
|
936
|
+
// export interface INormalizedError {
|
|
937
|
+
// error: any;
|
|
938
|
+
// code: string;
|
|
939
|
+
// message: string;
|
|
940
|
+
// details?: any;
|
|
941
|
+
// status: number;
|
|
942
|
+
// }
|
|
936
943
|
|
|
937
944
|
var LocalizeApiHelper = /** @class */ (function () {
|
|
938
945
|
function LocalizeApiHelper() {
|
|
@@ -947,26 +954,26 @@
|
|
|
947
954
|
LocalizeApiHelper.prototype.performRetry = function (options) {
|
|
948
955
|
return __awaiter(this, void 0, void 0, function () {
|
|
949
956
|
var attempts, lastError, consoleCount, styleElement, result, error_1;
|
|
950
|
-
return __generator(this, function (
|
|
951
|
-
switch (
|
|
957
|
+
return __generator(this, function (_f) {
|
|
958
|
+
switch (_f.label) {
|
|
952
959
|
case 0:
|
|
953
960
|
attempts = 0;
|
|
954
961
|
consoleCount = 0;
|
|
955
962
|
// Merge default retry options with provided options
|
|
956
963
|
options = Object.assign(Object.assign({}, this.defaultRetryOptions), options);
|
|
957
|
-
|
|
964
|
+
_f.label = 1;
|
|
958
965
|
case 1:
|
|
959
966
|
if (!(attempts < options.maxRetries())) return [3 /*break*/, 10];
|
|
960
|
-
|
|
967
|
+
_f.label = 2;
|
|
961
968
|
case 2:
|
|
962
|
-
|
|
969
|
+
_f.trys.push([2, 4, , 9]);
|
|
963
970
|
return [4 /*yield*/, options.callback()];
|
|
964
971
|
case 3:
|
|
965
|
-
result =
|
|
972
|
+
result = _f.sent();
|
|
966
973
|
this.removeBlocker(styleElement);
|
|
967
974
|
return [2 /*return*/, result];
|
|
968
975
|
case 4:
|
|
969
|
-
error_1 =
|
|
976
|
+
error_1 = _f.sent();
|
|
970
977
|
lastError = error_1;
|
|
971
978
|
if (consoleCount >= 7) {
|
|
972
979
|
console.clear();
|
|
@@ -977,12 +984,12 @@
|
|
|
977
984
|
return [4 /*yield*/, this.onConnectionError(options, error_1)];
|
|
978
985
|
case 5:
|
|
979
986
|
// Handle connection error
|
|
980
|
-
styleElement =
|
|
987
|
+
styleElement = _f.sent();
|
|
981
988
|
if (!options.onError) return [3 /*break*/, 7];
|
|
982
989
|
return [4 /*yield*/, this.invokeHook(options.onError.bind(this, error_1))];
|
|
983
990
|
case 6:
|
|
984
|
-
|
|
985
|
-
|
|
991
|
+
_f.sent();
|
|
992
|
+
_f.label = 7;
|
|
986
993
|
case 7:
|
|
987
994
|
if (attempts >= options.maxRetries() - 1)
|
|
988
995
|
throw error_1;
|
|
@@ -991,7 +998,7 @@
|
|
|
991
998
|
console.warn("Attempt " + attempts + " failed. Retrying...", error_1);
|
|
992
999
|
return [4 /*yield*/, waitFor(options.delay)];
|
|
993
1000
|
case 8:
|
|
994
|
-
|
|
1001
|
+
_f.sent();
|
|
995
1002
|
return [3 /*break*/, 9];
|
|
996
1003
|
case 9: return [3 /*break*/, 1];
|
|
997
1004
|
case 10:
|
|
@@ -1005,8 +1012,8 @@
|
|
|
1005
1012
|
var _a, _b, _c, _d;
|
|
1006
1013
|
return __awaiter(this, void 0, void 0, function () {
|
|
1007
1014
|
var retryUnless;
|
|
1008
|
-
return __generator(this, function (
|
|
1009
|
-
switch (
|
|
1015
|
+
return __generator(this, function (_f) {
|
|
1016
|
+
switch (_f.label) {
|
|
1010
1017
|
case 0:
|
|
1011
1018
|
retryUnless = ((_a = config.retryOptions) === null || _a === void 0 ? void 0 : _a.retryFunction)
|
|
1012
1019
|
|| this.isConnectionError;
|
|
@@ -1017,7 +1024,7 @@
|
|
|
1017
1024
|
callback: function () { return performRequest(options); },
|
|
1018
1025
|
retryUnless: retryUnless,
|
|
1019
1026
|
})];
|
|
1020
|
-
case 1: return [2 /*return*/,
|
|
1027
|
+
case 1: return [2 /*return*/, _f.sent()];
|
|
1021
1028
|
}
|
|
1022
1029
|
});
|
|
1023
1030
|
});
|
|
@@ -1028,21 +1035,20 @@
|
|
|
1028
1035
|
? normalizedUrl.slice(0, -1)
|
|
1029
1036
|
: normalizedUrl;
|
|
1030
1037
|
};
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
};
|
|
1038
|
+
// normalizeError(error: HttpErrorResponse): INormalizedError {
|
|
1039
|
+
// return {
|
|
1040
|
+
// error: error.error || {},
|
|
1041
|
+
// code: error.error?.code || `HTTP_${error.status}`,
|
|
1042
|
+
// message: error.error?.message || error.message,
|
|
1043
|
+
// details: error.error?.details,
|
|
1044
|
+
// status: error.status
|
|
1045
|
+
// };
|
|
1046
|
+
// }
|
|
1041
1047
|
LocalizeApiHelper.prototype.invokeHook = function (callback) {
|
|
1042
1048
|
return __awaiter(this, void 0, void 0, function () {
|
|
1043
1049
|
var result;
|
|
1044
|
-
return __generator(this, function (
|
|
1045
|
-
switch (
|
|
1050
|
+
return __generator(this, function (_f) {
|
|
1051
|
+
switch (_f.label) {
|
|
1046
1052
|
case 0:
|
|
1047
1053
|
if (!callback)
|
|
1048
1054
|
return [2 /*return*/];
|
|
@@ -1050,18 +1056,17 @@
|
|
|
1050
1056
|
if (!(result instanceof Promise)) return [3 /*break*/, 2];
|
|
1051
1057
|
return [4 /*yield*/, result];
|
|
1052
1058
|
case 1:
|
|
1053
|
-
|
|
1054
|
-
|
|
1059
|
+
_f.sent();
|
|
1060
|
+
_f.label = 2;
|
|
1055
1061
|
case 2: return [2 /*return*/];
|
|
1056
1062
|
}
|
|
1057
1063
|
});
|
|
1058
1064
|
});
|
|
1059
1065
|
};
|
|
1060
1066
|
LocalizeApiHelper.prototype.createRequest = function (instance, method, url, body, options) {
|
|
1061
|
-
var _this = this;
|
|
1062
1067
|
var request$ = instance.client.request(method, url, Object.assign(Object.assign({}, options), { body: body, observe: 'response' })).pipe(rxjs.takeUntil(instance.destroy$()), rxjs.catchError(function (error) {
|
|
1063
1068
|
// Convert to a non-observable error to handle in the promise
|
|
1064
|
-
return rxjs.throwError(function () { return
|
|
1069
|
+
return rxjs.throwError(function () { return error; });
|
|
1065
1070
|
}));
|
|
1066
1071
|
return request$;
|
|
1067
1072
|
};
|
|
@@ -1080,8 +1085,8 @@
|
|
|
1080
1085
|
var _a;
|
|
1081
1086
|
return __awaiter(this, void 0, void 0, function () {
|
|
1082
1087
|
var styleElement;
|
|
1083
|
-
return __generator(this, function (
|
|
1084
|
-
switch (
|
|
1088
|
+
return __generator(this, function (_f) {
|
|
1089
|
+
switch (_f.label) {
|
|
1085
1090
|
case 0:
|
|
1086
1091
|
if (!options.connectionError)
|
|
1087
1092
|
return [2 /*return*/];
|
|
@@ -1089,12 +1094,12 @@
|
|
|
1089
1094
|
styleElement = this.screenBlocker(options, error, true);
|
|
1090
1095
|
return [4 /*yield*/, this.invokeHook((_a = options.connectionError.callback) === null || _a === void 0 ? void 0 : _a.bind(this, error))];
|
|
1091
1096
|
case 1:
|
|
1092
|
-
|
|
1097
|
+
_f.sent();
|
|
1093
1098
|
return [2 /*return*/, styleElement];
|
|
1094
1099
|
case 2:
|
|
1095
1100
|
this.screenBlocker(options, error, false);
|
|
1096
1101
|
styleElement === null || styleElement === void 0 ? void 0 : styleElement.remove();
|
|
1097
|
-
|
|
1102
|
+
_f.label = 3;
|
|
1098
1103
|
case 3: return [2 /*return*/];
|
|
1099
1104
|
}
|
|
1100
1105
|
});
|
|
@@ -1102,17 +1107,15 @@
|
|
|
1102
1107
|
};
|
|
1103
1108
|
LocalizeApiHelper.prototype.screenBlocker = function (optons, error, add) {
|
|
1104
1109
|
if (add === void 0) { add = true; }
|
|
1105
|
-
var _a, _b, _c, _d;
|
|
1110
|
+
var _a, _b, _c, _d, _e;
|
|
1106
1111
|
if (!((_a = optons.connectionError) === null || _a === void 0 ? void 0 : _a.blockScreen))
|
|
1107
1112
|
return;
|
|
1108
|
-
if (error instanceof i1.HttpErrorResponse)
|
|
1109
|
-
error = this.normalizeError(error);
|
|
1110
1113
|
var message = ((_b = optons.connectionError) === null || _b === void 0 ? void 0 : _b.message)
|
|
1111
1114
|
|| 'Connection error occurred. Please wait';
|
|
1112
|
-
var errorMessage = (error === null || error === void 0 ? void 0 : error.message) || 'An error occurred';
|
|
1113
|
-
var suggestinMessage = ((
|
|
1115
|
+
var errorMessage = ((_c = error === null || error === void 0 ? void 0 : error.error) === null || _c === void 0 ? void 0 : _c.message) || 'An error occurred';
|
|
1116
|
+
var suggestinMessage = ((_d = optons.connectionError) === null || _d === void 0 ? void 0 : _d.suggestionMessage)
|
|
1114
1117
|
|| 'Please check your internet connection or the server status.';
|
|
1115
|
-
var zIndex = ((
|
|
1118
|
+
var zIndex = ((_e = optons.connectionError) === null || _e === void 0 ? void 0 : _e.blockScreenZIndex) || 10000;
|
|
1116
1119
|
var body = document.body;
|
|
1117
1120
|
var blcokerHtml = "\n <div class=\"lze-blocker\">\n " + LOCALIZE_API_ASSETS.network.noConnection + "\n <div class=\"lze-blocker__message\">\n " + message + "\n <span class=\"lze-blocker__dotting\">\n <span class=\"lze-blocker__dot\"></span>\n <span class=\"lze-blocker__dot\"></span>\n <span class=\"lze-blocker__dot\"></span>\n </span>\n </div>\n <div class=\"lze-blocker__error\">" + errorMessage + "</div>\n <div class=\"lze-blocker__error_suggestion\">" + suggestinMessage + "</div>\n </div>\n ";
|
|
1118
1121
|
var style = "\n div.lze-blocker {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.85) !important;\n z-index: " + zIndex + ";\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n color: #fff !important;\n font-family: Arial, sans-serif;\n text-align: center;\n padding: 20px;\n box-sizing: border-box;\n overflow: hidden;\n user-select: none;\n }\n\n svg#lze-no-connection {\n width: 75px;\n height: 75px;\n margin-bottom: 20px;\n }\n \n div.lze-blocker__message {\n color: #fff !important;\n font-size: 18px !important;\n margin-bottom: 10px;\n }\n \n .lze-blocker__dotting {\n display: inline-block;\n vertical-align: middle;\n }\n span.lze-blocker__dot {\n display: inline-block;\n width: 7px;\n height: 7px;\n background-color: #ffffff !important;\n border-radius: 50%;\n margin-left: 3px;\n opacity: 0.3;\n animation: dotting 1s infinite;\n }\n .lze-blocker__dot:nth-child(1) {\n animation-delay: 0s;\n opacity: 1;\n }\n .lze-blocker__dot:nth-child(2) {\n animation-delay: 0.2s;\n }\n .lze-blocker__dot:nth-child(3) {\n animation-delay: 0.4s;\n }\n\n @keyframes dotting {\n 0%, 80%, 100% { opacity: 0.3; }\n 40% { opacity: 1; }\n }\n\n div.lze-blocker__error {\n color: #f00;\n font-size: 14px !important;\n margin-bottom: 10px;\n text-shadow: 0 0 1px #ff5f5f !important;\n }\n\n div.lze-blocker__error_suggestion {\n color: #ccc !important;\n font-size: 14px !important;\n margin-top: 10px;\n }\n \n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ";
|