@firedesktop/react-base 3.0.0 → 3.0.2
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/components/AppIcon.d.ts +20 -20
- package/dist/components/AppIcon.js +53 -64
- package/dist/components/AppIcon.js.map +1 -1
- package/dist/components/AppInput.d.ts +20 -20
- package/dist/components/AppInput.js +7 -18
- package/dist/components/AppInput.js.map +1 -1
- package/dist/components/AppPagination.d.ts +11 -11
- package/dist/components/AppPagination.js +63 -74
- package/dist/components/AppPagination.js.map +1 -1
- package/dist/components/Spin.d.ts +6 -6
- package/dist/components/Spin.js +21 -21
- package/dist/components/Spin.js.map +1 -1
- package/dist/components/Toaster/Toaster.d.ts +7 -7
- package/dist/components/Toaster/Toaster.js +41 -41
- package/dist/components/Toaster/Toaster.js.map +1 -1
- package/dist/components/Toaster/Types.d.ts +6 -6
- package/dist/components/Toaster/Types.js +1 -1
- package/dist/components/index.d.ts +7 -7
- package/dist/components/index.js +7 -7
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/utils/CurrencyUtiles.d.ts +4 -4
- package/dist/utils/CurrencyUtiles.js +35 -35
- package/dist/utils/CurrencyUtiles.js.map +1 -1
- package/dist/utils/DateUtils.d.ts +7 -7
- package/dist/utils/DateUtils.js +111 -111
- package/dist/utils/DateUtils.js.map +1 -1
- package/dist/utils/FileUtils.d.ts +5 -5
- package/dist/utils/FileUtils.js +73 -73
- package/dist/utils/FileUtils.js.map +1 -1
- package/dist/utils/Logger.d.ts +13 -13
- package/dist/utils/Logger.js +43 -43
- package/dist/utils/RegExValidation.d.ts +4 -4
- package/dist/utils/RegExValidation.js +19 -19
- package/dist/utils/UrlUtils.d.ts +4 -4
- package/dist/utils/UrlUtils.js +15 -15
- package/dist/utils/configuration/ConfigurationLoader.d.ts +6 -6
- package/dist/utils/configuration/ConfigurationLoader.js +76 -76
- package/dist/utils/configuration/ConfigurationManager.d.ts +5 -5
- package/dist/utils/configuration/ConfigurationManager.js +96 -96
- package/dist/utils/configuration/ConfigurationManager.js.map +1 -1
- package/dist/utils/configuration/ConfigurationReturner.d.ts +9 -9
- package/dist/utils/configuration/ConfigurationReturner.js +70 -70
- package/dist/utils/configuration/index.d.ts +4 -4
- package/dist/utils/configuration/index.js +4 -4
- package/dist/utils/fetch/Types.d.ts +10 -10
- package/dist/utils/fetch/Types.js +1 -1
- package/dist/utils/fetch/fetchWrapper.d.ts +14 -14
- package/dist/utils/fetch/fetchWrapper.js +268 -239
- package/dist/utils/fetch/fetchWrapper.js.map +1 -1
- package/dist/utils/fetch/index.d.ts +3 -3
- package/dist/utils/fetch/index.js +3 -3
- package/dist/utils/index.d.ts +10 -10
- package/dist/utils/index.js +10 -10
- package/dist/utils/labels/LanguageLoader.d.ts +7 -7
- package/dist/utils/labels/LanguageLoader.js +130 -130
- package/dist/utils/labels/LanguageLoader.js.map +1 -1
- package/dist/utils/labels/LanguageManager.d.ts +6 -6
- package/dist/utils/labels/LanguageManager.js +118 -118
- package/dist/utils/labels/LanguageManager.js.map +1 -1
- package/dist/utils/labels/LanguageReturner.d.ts +10 -10
- package/dist/utils/labels/LanguageReturner.js +70 -70
- package/dist/utils/labels/index.d.ts +4 -4
- package/dist/utils/labels/index.js +4 -4
- package/package.json +9 -9
package/dist/utils/Logger.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
|
-
var PREFIX = '[react-base]';
|
|
11
|
-
var debugEnabled = false;
|
|
12
|
-
function enableDebug(enabled) {
|
|
13
|
-
debugEnabled = enabled;
|
|
14
|
-
}
|
|
15
|
-
function isEnabled() {
|
|
16
|
-
return debugEnabled;
|
|
17
|
-
}
|
|
18
|
-
function debug(message) {
|
|
19
|
-
var args = [];
|
|
20
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
21
|
-
args[_i - 1] = arguments[_i];
|
|
22
|
-
}
|
|
23
|
-
if (debugEnabled)
|
|
24
|
-
console.log.apply(console, __spreadArray(["".concat(PREFIX, " ").concat(message)], args, false));
|
|
25
|
-
}
|
|
26
|
-
function warn(message) {
|
|
27
|
-
var args = [];
|
|
28
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
29
|
-
args[_i - 1] = arguments[_i];
|
|
30
|
-
}
|
|
31
|
-
if (debugEnabled)
|
|
32
|
-
console.warn.apply(console, __spreadArray(["".concat(PREFIX, " ").concat(message)], args, false));
|
|
33
|
-
}
|
|
34
|
-
function error(message) {
|
|
35
|
-
var args = [];
|
|
36
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
37
|
-
args[_i - 1] = arguments[_i];
|
|
38
|
-
}
|
|
39
|
-
if (debugEnabled)
|
|
40
|
-
console.error.apply(console, __spreadArray(["".concat(PREFIX, " ").concat(message)], args, false));
|
|
41
|
-
}
|
|
42
|
-
var Logger = { enableDebug: enableDebug, isEnabled: isEnabled, debug: debug, warn: warn, error: error };
|
|
43
|
-
export default Logger;
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
var PREFIX = '[react-base]';
|
|
11
|
+
var debugEnabled = false;
|
|
12
|
+
function enableDebug(enabled) {
|
|
13
|
+
debugEnabled = enabled;
|
|
14
|
+
}
|
|
15
|
+
function isEnabled() {
|
|
16
|
+
return debugEnabled;
|
|
17
|
+
}
|
|
18
|
+
function debug(message) {
|
|
19
|
+
var args = [];
|
|
20
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
21
|
+
args[_i - 1] = arguments[_i];
|
|
22
|
+
}
|
|
23
|
+
if (debugEnabled)
|
|
24
|
+
console.log.apply(console, __spreadArray(["".concat(PREFIX, " ").concat(message)], args, false));
|
|
25
|
+
}
|
|
26
|
+
function warn(message) {
|
|
27
|
+
var args = [];
|
|
28
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
29
|
+
args[_i - 1] = arguments[_i];
|
|
30
|
+
}
|
|
31
|
+
if (debugEnabled)
|
|
32
|
+
console.warn.apply(console, __spreadArray(["".concat(PREFIX, " ").concat(message)], args, false));
|
|
33
|
+
}
|
|
34
|
+
function error(message) {
|
|
35
|
+
var args = [];
|
|
36
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
37
|
+
args[_i - 1] = arguments[_i];
|
|
38
|
+
}
|
|
39
|
+
if (debugEnabled)
|
|
40
|
+
console.error.apply(console, __spreadArray(["".concat(PREFIX, " ").concat(message)], args, false));
|
|
41
|
+
}
|
|
42
|
+
var Logger = { enableDebug: enableDebug, isEnabled: isEnabled, debug: debug, warn: warn, error: error };
|
|
43
|
+
export default Logger;
|
|
44
44
|
//# sourceMappingURL=Logger.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function RegExValidation(): {
|
|
2
|
-
isAValid_CSharpName: (value?: string) => boolean;
|
|
3
|
-
isAValid_EmailAddress: (value?: string) => boolean;
|
|
4
|
-
};
|
|
1
|
+
export default function RegExValidation(): {
|
|
2
|
+
isAValid_CSharpName: (value?: string) => boolean;
|
|
3
|
+
isAValid_EmailAddress: (value?: string) => boolean;
|
|
4
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export default function RegExValidation() {
|
|
2
|
-
var isAValid_CSharpName = function (value) {
|
|
3
|
-
var regex = /^(?![0-9])\w+$/;
|
|
4
|
-
if (!value)
|
|
5
|
-
return false;
|
|
6
|
-
return regex.test(value);
|
|
7
|
-
};
|
|
8
|
-
var isAValid_EmailAddress = function (value) {
|
|
9
|
-
var regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
10
|
-
if (!value)
|
|
11
|
-
return false;
|
|
12
|
-
return regex.test(value);
|
|
13
|
-
};
|
|
14
|
-
return {
|
|
15
|
-
isAValid_CSharpName: isAValid_CSharpName,
|
|
16
|
-
isAValid_EmailAddress: isAValid_EmailAddress
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
;
|
|
1
|
+
export default function RegExValidation() {
|
|
2
|
+
var isAValid_CSharpName = function (value) {
|
|
3
|
+
var regex = /^(?![0-9])\w+$/;
|
|
4
|
+
if (!value)
|
|
5
|
+
return false;
|
|
6
|
+
return regex.test(value);
|
|
7
|
+
};
|
|
8
|
+
var isAValid_EmailAddress = function (value) {
|
|
9
|
+
var regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
10
|
+
if (!value)
|
|
11
|
+
return false;
|
|
12
|
+
return regex.test(value);
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
isAValid_CSharpName: isAValid_CSharpName,
|
|
16
|
+
isAValid_EmailAddress: isAValid_EmailAddress
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
20
|
//# sourceMappingURL=RegExValidation.js.map
|
package/dist/utils/UrlUtils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare function UrlUtils(): {
|
|
2
|
-
validate: (url?: string) => boolean;
|
|
3
|
-
};
|
|
4
|
-
export default UrlUtils;
|
|
1
|
+
declare function UrlUtils(): {
|
|
2
|
+
validate: (url?: string) => boolean;
|
|
3
|
+
};
|
|
4
|
+
export default UrlUtils;
|
package/dist/utils/UrlUtils.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
function UrlUtils() {
|
|
2
|
-
var validate = function (url) {
|
|
3
|
-
var pattern = new RegExp('^(https?:\\/\\/)?' +
|
|
4
|
-
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
|
|
5
|
-
'((\\d{1,3}\\.){3}\\d{1,3}))' +
|
|
6
|
-
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
|
|
7
|
-
'(\\?[;&a-z\\d%_.~+=-]*)?' +
|
|
8
|
-
'(\\#[-a-z\\d_]*)?$', 'i');
|
|
9
|
-
return !!pattern.test(url !== null && url !== void 0 ? url : '');
|
|
10
|
-
};
|
|
11
|
-
return {
|
|
12
|
-
validate: validate
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export default UrlUtils;
|
|
1
|
+
function UrlUtils() {
|
|
2
|
+
var validate = function (url) {
|
|
3
|
+
var pattern = new RegExp('^(https?:\\/\\/)?' +
|
|
4
|
+
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
|
|
5
|
+
'((\\d{1,3}\\.){3}\\d{1,3}))' +
|
|
6
|
+
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
|
|
7
|
+
'(\\?[;&a-z\\d%_.~+=-]*)?' +
|
|
8
|
+
'(\\#[-a-z\\d_]*)?$', 'i');
|
|
9
|
+
return !!pattern.test(url !== null && url !== void 0 ? url : '');
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
validate: validate
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default UrlUtils;
|
|
16
16
|
//# sourceMappingURL=UrlUtils.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type configurationLoaderParamsType = {
|
|
2
|
-
updateAppState: (name: string, value: object) => any;
|
|
3
|
-
path?: string;
|
|
4
|
-
};
|
|
5
|
-
declare function ConfigurationLoader({ updateAppState, path }: configurationLoaderParamsType): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export default ConfigurationLoader;
|
|
1
|
+
export type configurationLoaderParamsType = {
|
|
2
|
+
updateAppState: (name: string, value: object) => any;
|
|
3
|
+
path?: string;
|
|
4
|
+
};
|
|
5
|
+
declare function ConfigurationLoader({ updateAppState, path }: configurationLoaderParamsType): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default ConfigurationLoader;
|
|
@@ -1,77 +1,77 @@
|
|
|
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 =
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
-
import React, { useEffect } from 'react';
|
|
39
|
-
import { useDispatch, useSelector } from 'react-redux';
|
|
40
|
-
import Logger from '../Logger';
|
|
41
|
-
import ConfigurationManager from './ConfigurationManager';
|
|
42
|
-
function ConfigurationLoader(_a) {
|
|
43
|
-
var updateAppState = _a.updateAppState, path = _a.path;
|
|
44
|
-
var dispatch = useDispatch();
|
|
45
|
-
var configuration = useSelector(function (state) { return state.configuration; });
|
|
46
|
-
var loadConfiguration = ConfigurationManager().loadConfiguration;
|
|
47
|
-
var fullPath = '/configuration/config.json';
|
|
48
|
-
if (path)
|
|
49
|
-
fullPath = path;
|
|
50
|
-
useEffect(function () {
|
|
51
|
-
function justAsync() {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0:
|
|
56
|
-
if (!(!configuration || !configuration.loaded)) return [3, 2];
|
|
57
|
-
Logger.debug("Loading Configuration for this Site in this path: ".concat(fullPath));
|
|
58
|
-
return [4, loadConfiguration(fullPath).then(function (response) {
|
|
59
|
-
Logger.debug("Loaded Configuration for this Site in this path: ".concat(fullPath), response);
|
|
60
|
-
dispatch(updateAppState('configuration', response));
|
|
61
|
-
}).catch(function (err) {
|
|
62
|
-
Logger.error("Problem loading the Site Configuration in this path: ".concat(fullPath));
|
|
63
|
-
})];
|
|
64
|
-
case 1:
|
|
65
|
-
_a.sent();
|
|
66
|
-
_a.label = 2;
|
|
67
|
-
case 2: return [2];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
justAsync();
|
|
73
|
-
}, []);
|
|
74
|
-
return (_jsx(React.Fragment, {}));
|
|
75
|
-
}
|
|
76
|
-
export default ConfigurationLoader;
|
|
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
+
import React, { useEffect } from 'react';
|
|
39
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
40
|
+
import Logger from '../Logger';
|
|
41
|
+
import ConfigurationManager from './ConfigurationManager';
|
|
42
|
+
function ConfigurationLoader(_a) {
|
|
43
|
+
var updateAppState = _a.updateAppState, path = _a.path;
|
|
44
|
+
var dispatch = useDispatch();
|
|
45
|
+
var configuration = useSelector(function (state) { return state.configuration; });
|
|
46
|
+
var loadConfiguration = ConfigurationManager().loadConfiguration;
|
|
47
|
+
var fullPath = '/configuration/config.json';
|
|
48
|
+
if (path)
|
|
49
|
+
fullPath = path;
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
function justAsync() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
if (!(!configuration || !configuration.loaded)) return [3, 2];
|
|
57
|
+
Logger.debug("Loading Configuration for this Site in this path: ".concat(fullPath));
|
|
58
|
+
return [4, loadConfiguration(fullPath).then(function (response) {
|
|
59
|
+
Logger.debug("Loaded Configuration for this Site in this path: ".concat(fullPath), response);
|
|
60
|
+
dispatch(updateAppState('configuration', response));
|
|
61
|
+
}).catch(function (err) {
|
|
62
|
+
Logger.error("Problem loading the Site Configuration in this path: ".concat(fullPath));
|
|
63
|
+
})];
|
|
64
|
+
case 1:
|
|
65
|
+
_a.sent();
|
|
66
|
+
_a.label = 2;
|
|
67
|
+
case 2: return [2];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
justAsync();
|
|
73
|
+
}, []);
|
|
74
|
+
return (_jsx(React.Fragment, {}));
|
|
75
|
+
}
|
|
76
|
+
export default ConfigurationLoader;
|
|
77
77
|
//# sourceMappingURL=ConfigurationLoader.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare function ConfigurationManager(): {
|
|
2
|
-
loadConfiguration: (fullPath: string) => Promise<any>;
|
|
3
|
-
loadConfigurationWithDispatch: (dispatch: any, updateAppState: any, configuration: any) => Promise<void>;
|
|
4
|
-
};
|
|
5
|
-
export default ConfigurationManager;
|
|
1
|
+
declare function ConfigurationManager(): {
|
|
2
|
+
loadConfiguration: (fullPath: string) => Promise<any>;
|
|
3
|
+
loadConfigurationWithDispatch: (dispatch: any, updateAppState: any, configuration: any) => Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
export default ConfigurationManager;
|
|
@@ -1,97 +1,97 @@
|
|
|
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 =
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 Logger from '../Logger';
|
|
38
|
-
function ConfigurationManager() {
|
|
39
|
-
function loadConfiguration(fullPath) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
-
var res, data, err_1;
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
switch (_a.label) {
|
|
44
|
-
case 0:
|
|
45
|
-
_a.trys.push([0, 3, , 4]);
|
|
46
|
-
return [4, fetch(fullPath, {
|
|
47
|
-
headers: {
|
|
48
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
49
|
-
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
50
|
-
'Expires': '0',
|
|
51
|
-
'pragma': 'no-cache',
|
|
52
|
-
'X-Content-Type-Options': 'nosniff'
|
|
53
|
-
}
|
|
54
|
-
})];
|
|
55
|
-
case 1:
|
|
56
|
-
res = _a.sent();
|
|
57
|
-
if (!res.ok)
|
|
58
|
-
throw new Error("Configuration load failed: HTTP ".concat(res.status));
|
|
59
|
-
return [4, res.json()];
|
|
60
|
-
case 2:
|
|
61
|
-
data = _a.sent();
|
|
62
|
-
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
63
|
-
throw new Error('Configuration response is not a valid JSON object');
|
|
64
|
-
return [2, data];
|
|
65
|
-
case 3:
|
|
66
|
-
err_1 = _a.sent();
|
|
67
|
-
Logger.error('Problem loading the Site Configuration', err_1);
|
|
68
|
-
return [3, 4];
|
|
69
|
-
case 4: return [2];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
;
|
|
75
|
-
function loadConfigurationWithDispatch(dispatch, updateAppState, configuration) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
-
var avoidCache, fullPath_1;
|
|
78
|
-
return __generator(this, function (_a) {
|
|
79
|
-
if (!configuration || !configuration.loaded) {
|
|
80
|
-
avoidCache = new Date().getTime();
|
|
81
|
-
fullPath_1 = "/configuration/config.json?".concat(avoidCache);
|
|
82
|
-
Logger.debug("Loading Configuration for this Site from this path: ".concat(fullPath_1));
|
|
83
|
-
loadConfiguration(fullPath_1).then(function (response) {
|
|
84
|
-
Logger.debug("Loaded Configuration for this Site in this path: ".concat(fullPath_1), response);
|
|
85
|
-
dispatch(updateAppState('configuration', response));
|
|
86
|
-
}).catch(function (err) {
|
|
87
|
-
Logger.error("Problem loading the Site Configuration in this path: ".concat(fullPath_1));
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return [2];
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return { loadConfiguration: loadConfiguration, loadConfigurationWithDispatch: loadConfigurationWithDispatch };
|
|
95
|
-
}
|
|
96
|
-
export default ConfigurationManager;
|
|
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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 (g && (g = 0, op[0] && (_ = 0)), _) 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 Logger from '../Logger';
|
|
38
|
+
function ConfigurationManager() {
|
|
39
|
+
function loadConfiguration(fullPath) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
+
var res, data, err_1;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
_a.trys.push([0, 3, , 4]);
|
|
46
|
+
return [4, fetch(fullPath, {
|
|
47
|
+
headers: {
|
|
48
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
49
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
50
|
+
'Expires': '0',
|
|
51
|
+
'pragma': 'no-cache',
|
|
52
|
+
'X-Content-Type-Options': 'nosniff'
|
|
53
|
+
}
|
|
54
|
+
})];
|
|
55
|
+
case 1:
|
|
56
|
+
res = _a.sent();
|
|
57
|
+
if (!res.ok)
|
|
58
|
+
throw new Error("Configuration load failed: HTTP ".concat(res.status));
|
|
59
|
+
return [4, res.json()];
|
|
60
|
+
case 2:
|
|
61
|
+
data = _a.sent();
|
|
62
|
+
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
63
|
+
throw new Error('Configuration response is not a valid JSON object');
|
|
64
|
+
return [2, data];
|
|
65
|
+
case 3:
|
|
66
|
+
err_1 = _a.sent();
|
|
67
|
+
Logger.error('Problem loading the Site Configuration', err_1);
|
|
68
|
+
return [3, 4];
|
|
69
|
+
case 4: return [2];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
;
|
|
75
|
+
function loadConfigurationWithDispatch(dispatch, updateAppState, configuration) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var avoidCache, fullPath_1;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
if (!configuration || !configuration.loaded) {
|
|
80
|
+
avoidCache = new Date().getTime();
|
|
81
|
+
fullPath_1 = "/configuration/config.json?".concat(avoidCache);
|
|
82
|
+
Logger.debug("Loading Configuration for this Site from this path: ".concat(fullPath_1));
|
|
83
|
+
loadConfiguration(fullPath_1).then(function (response) {
|
|
84
|
+
Logger.debug("Loaded Configuration for this Site in this path: ".concat(fullPath_1), response);
|
|
85
|
+
dispatch(updateAppState('configuration', response));
|
|
86
|
+
}).catch(function (err) {
|
|
87
|
+
Logger.error("Problem loading the Site Configuration in this path: ".concat(fullPath_1));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return [2];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return { loadConfiguration: loadConfiguration, loadConfigurationWithDispatch: loadConfigurationWithDispatch };
|
|
95
|
+
}
|
|
96
|
+
export default ConfigurationManager;
|
|
97
97
|
//# sourceMappingURL=ConfigurationManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationManager.js","sourceRoot":"","sources":["../../../src/lib/utils/configuration/ConfigurationManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,SAAS,oBAAoB;IAEzB,SAAe,iBAAiB,CAAC,QAAgB;;;;;;;wBAE7B,WAAM,KAAK,CAAC,QAAQ,EAAE;gCAC9B,OAAO,EAAE;oCACL,cAAc,EAAE,iCAAiC;oCACjD,eAAe,EAAE,qCAAqC;oCACtD,SAAS,EAAE,GAAG;oCACd,QAAQ,EAAE,UAAU;o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
|
|
4
|
-
export type configurationLoaderParamsType = {
|
|
5
|
-
configuration?: Configuration_Type;
|
|
6
|
-
onConfigurationLoad: (condifiguration?: Configuration_Type) => void;
|
|
7
|
-
path: string;
|
|
8
|
-
};
|
|
9
|
-
export default function ConfigurationReturner({ configuration, onConfigurationLoad, path }: configurationLoaderParamsType): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export type Configuration_Type = {
|
|
2
|
+
loaded: boolean;
|
|
3
|
+
};
|
|
4
|
+
export type configurationLoaderParamsType = {
|
|
5
|
+
configuration?: Configuration_Type;
|
|
6
|
+
onConfigurationLoad: (condifiguration?: Configuration_Type) => void;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
export default function ConfigurationReturner({ configuration, onConfigurationLoad, path }: configurationLoaderParamsType): import("react/jsx-runtime").JSX.Element;
|