@monkvision/common 4.0.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/LICENSE +32 -0
- package/README/APP_UTILS.md +52 -0
- package/README/HOOKS.md +242 -0
- package/README/INTERNATIONALIZATION.md +89 -0
- package/README/STATE_MANAGEMENT.md +125 -0
- package/README/THEMING.md +70 -0
- package/README/UTILITIES.md +254 -0
- package/README.md +23 -0
- package/lib/PreventExit/hooks.d.ts +15 -0
- package/lib/PreventExit/hooks.js +27 -0
- package/lib/PreventExit/hooks.js.map +1 -0
- package/lib/PreventExit/index.d.ts +1 -0
- package/lib/PreventExit/index.js +18 -0
- package/lib/PreventExit/index.js.map +1 -0
- package/lib/PreventExit/store.d.ts +23 -0
- package/lib/PreventExit/store.js +41 -0
- package/lib/PreventExit/store.js.map +1 -0
- package/lib/apps/analytics.d.ts +2 -0
- package/lib/apps/analytics.js +16 -0
- package/lib/apps/analytics.js.map +1 -0
- package/lib/apps/appState.d.ts +61 -0
- package/lib/apps/appState.js +11 -0
- package/lib/apps/appState.js.map +1 -0
- package/lib/apps/appStateProvider.d.ts +64 -0
- package/lib/apps/appStateProvider.js +116 -0
- package/lib/apps/appStateProvider.js.map +1 -0
- package/lib/apps/index.d.ts +3 -0
- package/lib/apps/index.js +20 -0
- package/lib/apps/index.js.map +1 -0
- package/lib/apps/monitoring.d.ts +2 -0
- package/lib/apps/monitoring.js +25 -0
- package/lib/apps/monitoring.js.map +1 -0
- package/lib/apps/searchParams.d.ts +60 -0
- package/lib/apps/searchParams.js +81 -0
- package/lib/apps/searchParams.js.map +1 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/index.js +29 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useAsyncEffect.d.ts +7 -0
- package/lib/hooks/useAsyncEffect.js +37 -0
- package/lib/hooks/useAsyncEffect.js.map +1 -0
- package/lib/hooks/useAsyncInterval.d.ts +7 -0
- package/lib/hooks/useAsyncInterval.js +54 -0
- package/lib/hooks/useAsyncInterval.js.map +1 -0
- package/lib/hooks/useInteractiveStatus.d.ts +52 -0
- package/lib/hooks/useInteractiveStatus.js +70 -0
- package/lib/hooks/useInteractiveStatus.js.map +1 -0
- package/lib/hooks/useInterval.d.ts +5 -0
- package/lib/hooks/useInterval.js +27 -0
- package/lib/hooks/useInterval.js.map +1 -0
- package/lib/hooks/useLoadingState.d.ts +33 -0
- package/lib/hooks/useLoadingState.js +36 -0
- package/lib/hooks/useLoadingState.js.map +1 -0
- package/lib/hooks/useObjectMemo.d.ts +12 -0
- package/lib/hooks/useObjectMemo.js +20 -0
- package/lib/hooks/useObjectMemo.js.map +1 -0
- package/lib/hooks/useObjectTranslation.d.ts +15 -0
- package/lib/hooks/useObjectTranslation.js +19 -0
- package/lib/hooks/useObjectTranslation.js.map +1 -0
- package/lib/hooks/useQueue.d.ts +152 -0
- package/lib/hooks/useQueue.js +194 -0
- package/lib/hooks/useQueue.js.map +1 -0
- package/lib/hooks/useResponsiveStyle.d.ts +28 -0
- package/lib/hooks/useResponsiveStyle.js +64 -0
- package/lib/hooks/useResponsiveStyle.js.map +1 -0
- package/lib/hooks/useSearchParams.d.ts +4 -0
- package/lib/hooks/useSearchParams.js +12 -0
- package/lib/hooks/useSearchParams.js.map +1 -0
- package/lib/hooks/useSightLabel.d.ts +21 -0
- package/lib/hooks/useSightLabel.js +19 -0
- package/lib/hooks/useSightLabel.js.map +1 -0
- package/lib/hooks/useWindowDimensions.d.ts +15 -0
- package/lib/hooks/useWindowDimensions.js +27 -0
- package/lib/hooks/useWindowDimensions.js.map +1 -0
- package/lib/i18n/index.d.ts +2 -0
- package/lib/i18n/index.js +19 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/i18n/translations/image.d.ts +22 -0
- package/lib/i18n/translations/image.js +408 -0
- package/lib/i18n/translations/image.js.map +1 -0
- package/lib/i18n/translations/index.d.ts +2 -0
- package/lib/i18n/translations/index.js +19 -0
- package/lib/i18n/translations/index.js.map +1 -0
- package/lib/i18n/translations/vehicleParts.d.ts +5 -0
- package/lib/i18n/translations/vehicleParts.js +461 -0
- package/lib/i18n/translations/vehicleParts.js.map +1 -0
- package/lib/i18n/utils.d.ts +45 -0
- package/lib/i18n/utils.js +86 -0
- package/lib/i18n/utils.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/state/actions/createdOneImage.d.ts +44 -0
- package/lib/state/actions/createdOneImage.js +52 -0
- package/lib/state/actions/createdOneImage.js.map +1 -0
- package/lib/state/actions/gotOneInspection.d.ts +24 -0
- package/lib/state/actions/gotOneInspection.js +55 -0
- package/lib/state/actions/gotOneInspection.js.map +1 -0
- package/lib/state/actions/index.d.ts +6 -0
- package/lib/state/actions/index.js +23 -0
- package/lib/state/actions/index.js.map +1 -0
- package/lib/state/actions/monkAction.d.ts +34 -0
- package/lib/state/actions/monkAction.js +30 -0
- package/lib/state/actions/monkAction.js.map +1 -0
- package/lib/state/actions/resetState.d.ts +20 -0
- package/lib/state/actions/resetState.js +21 -0
- package/lib/state/actions/resetState.js.map +1 -0
- package/lib/state/actions/updatedManyTasks.d.ts +32 -0
- package/lib/state/actions/updatedManyTasks.js +47 -0
- package/lib/state/actions/updatedManyTasks.js.map +1 -0
- package/lib/state/actions/updatedVehicle.d.ts +38 -0
- package/lib/state/actions/updatedVehicle.js +50 -0
- package/lib/state/actions/updatedVehicle.js.map +1 -0
- package/lib/state/context.d.ts +21 -0
- package/lib/state/context.js +10 -0
- package/lib/state/context.js.map +1 -0
- package/lib/state/hooks.d.ts +8 -0
- package/lib/state/hooks.js +20 -0
- package/lib/state/hooks.js.map +1 -0
- package/lib/state/index.d.ts +6 -0
- package/lib/state/index.js +23 -0
- package/lib/state/index.js.map +1 -0
- package/lib/state/provider.d.ts +19 -0
- package/lib/state/provider.js +40 -0
- package/lib/state/provider.js.map +1 -0
- package/lib/state/reducer.d.ts +6 -0
- package/lib/state/reducer.js +24 -0
- package/lib/state/reducer.js.map +1 -0
- package/lib/state/state.d.ts +50 -0
- package/lib/state/state.js +22 -0
- package/lib/state/state.js.map +1 -0
- package/lib/theme/context.d.ts +5 -0
- package/lib/theme/context.js +10 -0
- package/lib/theme/context.js.map +1 -0
- package/lib/theme/default/index.d.ts +1 -0
- package/lib/theme/default/index.js +18 -0
- package/lib/theme/default/index.js.map +1 -0
- package/lib/theme/default/palette.d.ts +2 -0
- package/lib/theme/default/palette.js +69 -0
- package/lib/theme/default/palette.js.map +1 -0
- package/lib/theme/hooks.d.ts +5 -0
- package/lib/theme/hooks.js +13 -0
- package/lib/theme/hooks.js.map +1 -0
- package/lib/theme/index.d.ts +5 -0
- package/lib/theme/index.js +22 -0
- package/lib/theme/index.js.map +1 -0
- package/lib/theme/provider.d.ts +16 -0
- package/lib/theme/provider.js +29 -0
- package/lib/theme/provider.js.map +1 -0
- package/lib/theme/theme.d.ts +17 -0
- package/lib/theme/theme.js +54 -0
- package/lib/theme/theme.js.map +1 -0
- package/lib/utils/array.utils.d.ts +26 -0
- package/lib/utils/array.utils.js +75 -0
- package/lib/utils/array.utils.js.map +1 -0
- package/lib/utils/browser.utils.d.ts +4 -0
- package/lib/utils/browser.utils.js +16 -0
- package/lib/utils/browser.utils.js.map +1 -0
- package/lib/utils/color.utils.d.ts +51 -0
- package/lib/utils/color.utils.js +155 -0
- package/lib/utils/color.utils.js.map +1 -0
- package/lib/utils/env.utils.d.ts +5 -0
- package/lib/utils/env.utils.js +16 -0
- package/lib/utils/env.utils.js.map +1 -0
- package/lib/utils/index.d.ts +9 -0
- package/lib/utils/index.js +26 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/mimetype.utils.d.ts +14 -0
- package/lib/utils/mimetype.utils.js +69 -0
- package/lib/utils/mimetype.utils.js.map +1 -0
- package/lib/utils/promise.utils.d.ts +4 -0
- package/lib/utils/promise.utils.js +13 -0
- package/lib/utils/promise.utils.js.map +1 -0
- package/lib/utils/state.utils.d.ts +9 -0
- package/lib/utils/state.utils.js +35 -0
- package/lib/utils/state.utils.js.map +1 -0
- package/lib/utils/string.utils.d.ts +22 -0
- package/lib/utils/string.utils.js +48 -0
- package/lib/utils/string.utils.js.map +1 -0
- package/lib/utils/zlib.utils.d.ts +8 -0
- package/lib/utils/zlib.utils.js +30 -0
- package/lib/utils/zlib.utils.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { InteractiveStatus, RGBA } from '@monkvision/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the RGBA values of the given color. The accepted formats are :
|
|
4
|
+
* - RGB : rgb(167, 224, 146)
|
|
5
|
+
* - RGBA : rgb(167, 224, 146, 0.03)
|
|
6
|
+
* - HEX : #A7E092
|
|
7
|
+
* - HEX (alpha) : #A7E09208
|
|
8
|
+
* - HEX (short) : #AE9
|
|
9
|
+
* - HEX (short + alpha) : #AE98
|
|
10
|
+
*
|
|
11
|
+
* This function is case-insensitive and ignores white spaces.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getRGBAFromString(str: string): RGBA;
|
|
14
|
+
/**
|
|
15
|
+
* Converts RGBA values to their hexadecimal representation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getHexFromRGBA(rgba: RGBA): string;
|
|
18
|
+
/**
|
|
19
|
+
* Apply a shade of black or white over the given color.
|
|
20
|
+
*
|
|
21
|
+
* @param color A color using the same format accepted by the `getRGBAFromString` function.
|
|
22
|
+
* @param amount The amount of shade to apply, as a ratio :
|
|
23
|
+
* - positive values like 0.08 to lighten the color by 8%
|
|
24
|
+
* - negative values like -0.08 to darken the color by 8%
|
|
25
|
+
* @see getRGBAFromString
|
|
26
|
+
*/
|
|
27
|
+
export declare function shadeColor(color: string, amount: number): string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a new color equal to the given color but with a different alpha value.
|
|
30
|
+
*
|
|
31
|
+
* @param color The color to change the alpha value of.
|
|
32
|
+
* @param amount The alpha value (from 0 to 1).
|
|
33
|
+
*/
|
|
34
|
+
export declare function changeAlpha(color: string, amount: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* The different ways an interactive element's style is altered when the user interacts with it.
|
|
37
|
+
*/
|
|
38
|
+
export declare enum InteractiveVariation {
|
|
39
|
+
/**
|
|
40
|
+
* The element will darken when the user interacts with it (used for light elements).
|
|
41
|
+
*/
|
|
42
|
+
DARKEN = "darken",
|
|
43
|
+
/**
|
|
44
|
+
* The element will lighten when the user interacts with it (used for dark elements).
|
|
45
|
+
*/
|
|
46
|
+
LIGHTEN = "lighten"
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create interactive variants (hovered, active...) for the given color.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getInteractiveVariants(color: string, variant?: InteractiveVariation): Record<InteractiveStatus, string>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.getInteractiveVariants = exports.InteractiveVariation = exports.changeAlpha = exports.shadeColor = exports.getHexFromRGBA = exports.getRGBAFromString = void 0;
|
|
26
|
+
var types_1 = require("@monkvision/types");
|
|
27
|
+
var RGBA_REGEXP = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/i;
|
|
28
|
+
var HEX_REGEXP = /^#(?:(?:[0-9a-f]{3}){1,2}|(?:[0-9a-f]{4}){1,2})$/i;
|
|
29
|
+
function getRGBAFromRGBAString(str) {
|
|
30
|
+
var result = str.match(RGBA_REGEXP);
|
|
31
|
+
if (!result) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
r: Number(result[1]),
|
|
36
|
+
g: Number(result[2]),
|
|
37
|
+
b: Number(result[3]),
|
|
38
|
+
a: result[4] ? Number(result[4]) : 1,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function getRGBAFromHexString(str) {
|
|
42
|
+
var _a;
|
|
43
|
+
if (!HEX_REGEXP.test(str)) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
var colors = [];
|
|
47
|
+
var increment = str.length > 5 ? 2 : 1;
|
|
48
|
+
for (var i = 1; i < str.length; i += increment) {
|
|
49
|
+
colors.push(str.substring(i, i + increment));
|
|
50
|
+
}
|
|
51
|
+
colors = colors.map(function (hex) { return parseInt(hex.length > 1 ? hex : "".concat(hex).concat(hex), 16); });
|
|
52
|
+
return {
|
|
53
|
+
r: colors[0],
|
|
54
|
+
g: colors[1],
|
|
55
|
+
b: colors[2],
|
|
56
|
+
a: ((_a = colors[3]) !== null && _a !== void 0 ? _a : 255) / 255,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function convertColorToHexCode(value) {
|
|
60
|
+
var rounded = Math.round(value);
|
|
61
|
+
rounded = rounded > 255 ? 255 : rounded;
|
|
62
|
+
var hex = rounded.toString(16);
|
|
63
|
+
return hex.length > 1 ? hex : "0".concat(hex);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the RGBA values of the given color. The accepted formats are :
|
|
67
|
+
* - RGB : rgb(167, 224, 146)
|
|
68
|
+
* - RGBA : rgb(167, 224, 146, 0.03)
|
|
69
|
+
* - HEX : #A7E092
|
|
70
|
+
* - HEX (alpha) : #A7E09208
|
|
71
|
+
* - HEX (short) : #AE9
|
|
72
|
+
* - HEX (short + alpha) : #AE98
|
|
73
|
+
*
|
|
74
|
+
* This function is case-insensitive and ignores white spaces.
|
|
75
|
+
*/
|
|
76
|
+
function getRGBAFromString(str) {
|
|
77
|
+
var trimmed = str.trim();
|
|
78
|
+
var result = trimmed.length > 9 ? getRGBAFromRGBAString(trimmed) : getRGBAFromHexString(trimmed);
|
|
79
|
+
if (!result) {
|
|
80
|
+
throw new Error("Invalid color format : ".concat(trimmed));
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
exports.getRGBAFromString = getRGBAFromString;
|
|
85
|
+
/**
|
|
86
|
+
* Converts RGBA values to their hexadecimal representation.
|
|
87
|
+
*/
|
|
88
|
+
function getHexFromRGBA(rgba) {
|
|
89
|
+
var r = convertColorToHexCode(rgba.r);
|
|
90
|
+
var g = convertColorToHexCode(rgba.g);
|
|
91
|
+
var b = convertColorToHexCode(rgba.b);
|
|
92
|
+
var a = convertColorToHexCode(rgba.a * 255);
|
|
93
|
+
return "#".concat(r).concat(g).concat(b).concat(a);
|
|
94
|
+
}
|
|
95
|
+
exports.getHexFromRGBA = getHexFromRGBA;
|
|
96
|
+
/**
|
|
97
|
+
* Apply a shade of black or white over the given color.
|
|
98
|
+
*
|
|
99
|
+
* @param color A color using the same format accepted by the `getRGBAFromString` function.
|
|
100
|
+
* @param amount The amount of shade to apply, as a ratio :
|
|
101
|
+
* - positive values like 0.08 to lighten the color by 8%
|
|
102
|
+
* - negative values like -0.08 to darken the color by 8%
|
|
103
|
+
* @see getRGBAFromString
|
|
104
|
+
*/
|
|
105
|
+
function shadeColor(color, amount) {
|
|
106
|
+
var _a = getRGBAFromString(color), a = _a.a, rgb = __rest(_a, ["a"]);
|
|
107
|
+
Object.entries(rgb).forEach(function (_a) {
|
|
108
|
+
var key = _a[0], value = _a[1];
|
|
109
|
+
var shaded = value * (1 + amount);
|
|
110
|
+
rgb[key] = shaded > 255 ? 255 : shaded;
|
|
111
|
+
});
|
|
112
|
+
return getHexFromRGBA(__assign({ a: a }, rgb));
|
|
113
|
+
}
|
|
114
|
+
exports.shadeColor = shadeColor;
|
|
115
|
+
/**
|
|
116
|
+
* Returns a new color equal to the given color but with a different alpha value.
|
|
117
|
+
*
|
|
118
|
+
* @param color The color to change the alpha value of.
|
|
119
|
+
* @param amount The alpha value (from 0 to 1).
|
|
120
|
+
*/
|
|
121
|
+
function changeAlpha(color, amount) {
|
|
122
|
+
var _a = getRGBAFromString(color), _ = _a.a, rgb = __rest(_a, ["a"]);
|
|
123
|
+
return getHexFromRGBA(__assign({ a: amount }, rgb));
|
|
124
|
+
}
|
|
125
|
+
exports.changeAlpha = changeAlpha;
|
|
126
|
+
/**
|
|
127
|
+
* The different ways an interactive element's style is altered when the user interacts with it.
|
|
128
|
+
*/
|
|
129
|
+
var InteractiveVariation;
|
|
130
|
+
(function (InteractiveVariation) {
|
|
131
|
+
/**
|
|
132
|
+
* The element will darken when the user interacts with it (used for light elements).
|
|
133
|
+
*/
|
|
134
|
+
InteractiveVariation["DARKEN"] = "darken";
|
|
135
|
+
/**
|
|
136
|
+
* The element will lighten when the user interacts with it (used for dark elements).
|
|
137
|
+
*/
|
|
138
|
+
InteractiveVariation["LIGHTEN"] = "lighten";
|
|
139
|
+
})(InteractiveVariation = exports.InteractiveVariation || (exports.InteractiveVariation = {}));
|
|
140
|
+
/**
|
|
141
|
+
* Create interactive variants (hovered, active...) for the given color.
|
|
142
|
+
*/
|
|
143
|
+
function getInteractiveVariants(color, variant) {
|
|
144
|
+
var _a;
|
|
145
|
+
if (variant === void 0) { variant = InteractiveVariation.LIGHTEN; }
|
|
146
|
+
var factor = variant === InteractiveVariation.LIGHTEN ? 1 : -1;
|
|
147
|
+
return _a = {},
|
|
148
|
+
_a[types_1.InteractiveStatus.DEFAULT] = color,
|
|
149
|
+
_a[types_1.InteractiveStatus.HOVERED] = shadeColor(color, factor * 0.08),
|
|
150
|
+
_a[types_1.InteractiveStatus.ACTIVE] = shadeColor(color, factor * 0.12),
|
|
151
|
+
_a[types_1.InteractiveStatus.DISABLED] = color,
|
|
152
|
+
_a;
|
|
153
|
+
}
|
|
154
|
+
exports.getInteractiveVariants = getInteractiveVariants;
|
|
155
|
+
//# sourceMappingURL=color.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.utils.js","sourceRoot":"","sources":["../../src/utils/color.utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAE5D,IAAM,WAAW,GAAG,4EAA4E,CAAC;AACjG,IAAM,UAAU,GAAG,mDAAmD,CAAC;AAEvE,SAAS,qBAAqB,CAAC,GAAW;IACxC,IAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IACD,OAAO;QACL,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC,CAAC;AACJ,CAAC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1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvOrThrow = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Utility function that returns the value of a given environment variable. If the value does not exist, it throws an
|
|
6
|
+
* error.
|
|
7
|
+
*/
|
|
8
|
+
function getEnvOrThrow(name) {
|
|
9
|
+
var value = process.env[name];
|
|
10
|
+
if (!value) {
|
|
11
|
+
throw new Error("Required environment variable ".concat(name, " is not defined."));
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
exports.getEnvOrThrow = getEnvOrThrow;
|
|
16
|
+
//# sourceMappingURL=env.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.utils.js","sourceRoot":"","sources":["../../src/utils/env.utils.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,SAAgB,aAAa,CAAC,IAAY;IACxC,IAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,wCAAiC,IAAI,qBAAkB,CAAC,CAAC;KAC1E;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAND,sCAMC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './string.utils';
|
|
2
|
+
export * from './array.utils';
|
|
3
|
+
export * from './color.utils';
|
|
4
|
+
export * from './mimetype.utils';
|
|
5
|
+
export * from './promise.utils';
|
|
6
|
+
export * from './zlib.utils';
|
|
7
|
+
export * from './browser.utils';
|
|
8
|
+
export * from './env.utils';
|
|
9
|
+
export * from './state.utils';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./string.utils"), exports);
|
|
18
|
+
__exportStar(require("./array.utils"), exports);
|
|
19
|
+
__exportStar(require("./color.utils"), exports);
|
|
20
|
+
__exportStar(require("./mimetype.utils"), exports);
|
|
21
|
+
__exportStar(require("./promise.utils"), exports);
|
|
22
|
+
__exportStar(require("./zlib.utils"), exports);
|
|
23
|
+
__exportStar(require("./browser.utils"), exports);
|
|
24
|
+
__exportStar(require("./env.utils"), exports);
|
|
25
|
+
__exportStar(require("./state.utils"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,gDAA8B;AAC9B,gDAA8B;AAC9B,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,kDAAgC;AAChC,8CAA4B;AAC5B,gDAA8B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datamap that associates mimetypes to known file extensions corresponding to this mimetype.
|
|
3
|
+
*/
|
|
4
|
+
export declare const MIMETYPE_FILE_EXTENSIONS: Record<string, string[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a list of file extensions known to be corresponding to the given mimetype. If no file extension is known for
|
|
7
|
+
* this mimetype, this function will throw an error.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFileExtensions(mimetype: string): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Returns the mimetype associated with the given file extension. If the file extension is unknown, this function will
|
|
12
|
+
* throw an error.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getMimetype(fileExtension: string): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMimetype = exports.getFileExtensions = exports.MIMETYPE_FILE_EXTENSIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Datamap that associates mimetypes to known file extensions corresponding to this mimetype.
|
|
6
|
+
*/
|
|
7
|
+
exports.MIMETYPE_FILE_EXTENSIONS = {
|
|
8
|
+
'text/plain': ['txt'],
|
|
9
|
+
'text/html': ['html', 'htm', 'shtml'],
|
|
10
|
+
'text/css': ['css'],
|
|
11
|
+
'text/xml': ['xml'],
|
|
12
|
+
'image/gif': ['gif'],
|
|
13
|
+
'image/jpeg': ['jpeg', 'jpg'],
|
|
14
|
+
'image/png': ['png'],
|
|
15
|
+
'image/tiff': ['tif', 'tiff'],
|
|
16
|
+
'image/vnd.wap.wbmp': ['wbmp'],
|
|
17
|
+
'image/x-icon': ['ico'],
|
|
18
|
+
'image/x-jng': ['jng'],
|
|
19
|
+
'image/x-ms-bmp': ['bmp'],
|
|
20
|
+
'image/svg+xml': ['svg'],
|
|
21
|
+
'image/webp': ['webp'],
|
|
22
|
+
'application/octet-stream': ['bin', 'exe', 'dll', 'eot', 'iso', 'img', 'msi', 'msp', 'msm'],
|
|
23
|
+
'application/x-javascript': ['js'],
|
|
24
|
+
'application/pdf': ['pdf'],
|
|
25
|
+
'application/xhtml+xml': ['xhtml'],
|
|
26
|
+
'application/zip': ['zip'],
|
|
27
|
+
'audio/midi': ['mid', 'midi', 'kar'],
|
|
28
|
+
'audio/mpeg': ['mp3'],
|
|
29
|
+
'audio/ogg': ['ogg'],
|
|
30
|
+
'audio/x-realaudio': ['ra'],
|
|
31
|
+
'video/3gpp': ['3gpp', '3gp'],
|
|
32
|
+
'video/mpeg': ['mpeg', 'mpg'],
|
|
33
|
+
'video/quicktime': ['mov'],
|
|
34
|
+
'video/x-flv': ['flv'],
|
|
35
|
+
'video/x-mng': ['mng'],
|
|
36
|
+
'video/x-ms-asf': ['asx', 'asf'],
|
|
37
|
+
'video/x-ms-wmv': ['wmv'],
|
|
38
|
+
'video/x-msvideo': ['avi'],
|
|
39
|
+
'video/mp4': ['m4v', 'mp4'],
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Returns a list of file extensions known to be corresponding to the given mimetype. If no file extension is known for
|
|
43
|
+
* this mimetype, this function will throw an error.
|
|
44
|
+
*/
|
|
45
|
+
function getFileExtensions(mimetype) {
|
|
46
|
+
var extensions = exports.MIMETYPE_FILE_EXTENSIONS[mimetype];
|
|
47
|
+
if (!extensions) {
|
|
48
|
+
throw new Error("Unknown mimetype : ".concat(mimetype));
|
|
49
|
+
}
|
|
50
|
+
return extensions;
|
|
51
|
+
}
|
|
52
|
+
exports.getFileExtensions = getFileExtensions;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the mimetype associated with the given file extension. If the file extension is unknown, this function will
|
|
55
|
+
* throw an error.
|
|
56
|
+
*/
|
|
57
|
+
function getMimetype(fileExtension) {
|
|
58
|
+
var _a;
|
|
59
|
+
var mimetype = (_a = Object.entries(exports.MIMETYPE_FILE_EXTENSIONS).find(function (_a) {
|
|
60
|
+
var extensions = _a[1];
|
|
61
|
+
return extensions.includes(fileExtension);
|
|
62
|
+
})) === null || _a === void 0 ? void 0 : _a[0];
|
|
63
|
+
if (!mimetype) {
|
|
64
|
+
throw new Error("Unknown file extension : ".concat(fileExtension));
|
|
65
|
+
}
|
|
66
|
+
return mimetype;
|
|
67
|
+
}
|
|
68
|
+
exports.getMimetype = getMimetype;
|
|
69
|
+
//# sourceMappingURL=mimetype.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mimetype.utils.js","sourceRoot":"","sources":["../../src/utils/mimetype.utils.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,wBAAwB,GAA6B;IAChE,YAAY,EAAE,CAAC,KAAK,CAAC;IACrB,WAAW,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;IACrC,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,UAAU,EAAE,CAAC,KAAK,CAAC;IAEnB,WAAW,EAAE,CAAC,KAAK,CAAC;IACpB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IAC7B,WAAW,EAAE,CAAC,KAAK,CAAC;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,CAAC,MAAM,CAAC;IAC9B,cAAc,EAAE,CAAC,KAAK,CAAC;IACvB,aAAa,EAAE,CAAC,KAAK,CAAC;IACtB,gBAAgB,EAAE,CAAC,KAAK,CAAC;IACzB,eAAe,EAAE,CAAC,KAAK,CAAC;IACxB,YAAY,EAAE,CAAC,MAAM,CAAC;IAEtB,0BAA0B,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;IAC3F,0BAA0B,EAAE,CAAC,IAAI,CAAC;IAClC,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,uBAAuB,EAAE,CAAC,OAAO,CAAC;IAClC,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAE1B,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;IACpC,YAAY,EAAE,CAAC,KAAK,CAAC;IACrB,WAAW,EAAE,CAAC,KAAK,CAAC;IACpB,mBAAmB,EAA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function creates and returns a new Promise that will resolve to void after the given amount of milliseconds.
|
|
6
|
+
*/
|
|
7
|
+
function timeoutPromise(delayMs) {
|
|
8
|
+
return new Promise(function (resolve) {
|
|
9
|
+
setTimeout(function () { return resolve(); }, delayMs);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.timeoutPromise = timeoutPromise;
|
|
13
|
+
//# sourceMappingURL=promise.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.utils.js","sourceRoot":"","sources":["../../src/utils/promise.utils.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;QACzB,UAAU,CAAC,cAAM,OAAA,OAAO,EAAE,EAAT,CAAS,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,wCAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Image } from '@monkvision/types';
|
|
2
|
+
/**
|
|
3
|
+
* Utility function that extracts the images of the given inspection.
|
|
4
|
+
*
|
|
5
|
+
* @param inspectionId The ID of the inspection to get the images of.
|
|
6
|
+
* @param images Array containing every image existing in the current local state.
|
|
7
|
+
* @param filterRetakes Boolean indicating if retaken pictures should be filtered out or not (default: false).
|
|
8
|
+
*/
|
|
9
|
+
export declare function getInspectionImages(inspectionId: string, images: Image[], filterRetakes?: boolean): Image[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInspectionImages = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Utility function that extracts the images of the given inspection.
|
|
6
|
+
*
|
|
7
|
+
* @param inspectionId The ID of the inspection to get the images of.
|
|
8
|
+
* @param images Array containing every image existing in the current local state.
|
|
9
|
+
* @param filterRetakes Boolean indicating if retaken pictures should be filtered out or not (default: false).
|
|
10
|
+
*/
|
|
11
|
+
function getInspectionImages(inspectionId, images, filterRetakes) {
|
|
12
|
+
if (filterRetakes === void 0) { filterRetakes = false; }
|
|
13
|
+
var inspectionImages = images.filter(function (image) { return image.inspectionId === inspectionId; });
|
|
14
|
+
if (!filterRetakes) {
|
|
15
|
+
return inspectionImages;
|
|
16
|
+
}
|
|
17
|
+
var filteredRetakes = [];
|
|
18
|
+
inspectionImages.forEach(function (image) {
|
|
19
|
+
if (image.sightId) {
|
|
20
|
+
var index = filteredRetakes.findIndex(function (i) { return i.sightId === image.sightId; });
|
|
21
|
+
if (index >= 0) {
|
|
22
|
+
if (image.createdAt &&
|
|
23
|
+
filteredRetakes[index].createdAt &&
|
|
24
|
+
image.createdAt > filteredRetakes[index].createdAt) {
|
|
25
|
+
filteredRetakes[index] = image;
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
filteredRetakes.push(image);
|
|
31
|
+
});
|
|
32
|
+
return filteredRetakes;
|
|
33
|
+
}
|
|
34
|
+
exports.getInspectionImages = getInspectionImages;
|
|
35
|
+
//# sourceMappingURL=state.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.utils.js","sourceRoot":"","sources":["../../src/utils/state.utils.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,YAAoB,EACpB,MAAe,EACf,aAAqB;IAArB,8BAAA,EAAA,qBAAqB;IAErB,IAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,YAAY,KAAK,YAAY,EAAnC,CAAmC,CAAC,CAAC;IACvF,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,gBAAgB,CAAC;KACzB;IACD,IAAM,eAAe,GAAY,EAAE,CAAC;IACpC,gBAAgB,CAAC,OAAO,CAAC,UAAC,KAAK;QAC7B,IAAI,KAAK,CAAC,OAAO,EAAE;YACjB,IAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EAA3B,CAA2B,CAAC,CAAC;YAC5E,IAAI,KAAK,IAAI,CAAC,EAAE;gBACd,IACE,KAAK,CAAC,SAAS;oBACf,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS;oBAChC,KAAK,CAAC,SAAS,GAAI,eAAe,CAAC,KAAK,CAAC,CAAC,SAAoB,EAC9D;oBACA,eAAe,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;iBAChC;gBACD,OAAO;aACR;SACF;QACD,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,OAAO,eAAe,CAAC;AACzB,CAAC;AA3BD,kDA2BC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suffixes a string with the given suffixes, only if their value is `true` in the suffixes object param.
|
|
3
|
+
*
|
|
4
|
+
* Note : The order of the suffixes is not guaranteed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function suffix(str: string, suffixes?: Record<string, boolean | undefined | null>, separator?: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Split the given string into its composing words.
|
|
9
|
+
*/
|
|
10
|
+
export declare function words(str: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Capitalizes (transforms the first character to upper case) the given string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function capitalize(str: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Uncapitalizes (transforms the first character to lower case) the given string.
|
|
17
|
+
*/
|
|
18
|
+
export declare function uncapitalize(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a string to camel case.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toCamelCase(str: string): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCamelCase = exports.uncapitalize = exports.capitalize = exports.words = exports.suffix = void 0;
|
|
4
|
+
var WORD_PATTERN = /[A-Z][a-z]+|[A-Z]+(?=[A-Z][a-z])|[A-Z]+|[a-z]+|\d+/g;
|
|
5
|
+
/**
|
|
6
|
+
* Suffixes a string with the given suffixes, only if their value is `true` in the suffixes object param.
|
|
7
|
+
*
|
|
8
|
+
* Note : The order of the suffixes is not guaranteed.
|
|
9
|
+
*/
|
|
10
|
+
function suffix(str, suffixes, separator) {
|
|
11
|
+
if (separator === void 0) { separator = ' '; }
|
|
12
|
+
return suffixes
|
|
13
|
+
? Object.keys(suffixes).reduce(function (prev, curr) { return "".concat(prev).concat(suffixes[curr] ? separator + curr : ''); }, str)
|
|
14
|
+
: str;
|
|
15
|
+
}
|
|
16
|
+
exports.suffix = suffix;
|
|
17
|
+
/**
|
|
18
|
+
* Split the given string into its composing words.
|
|
19
|
+
*/
|
|
20
|
+
function words(str) {
|
|
21
|
+
var _a;
|
|
22
|
+
return (_a = str.match(WORD_PATTERN)) !== null && _a !== void 0 ? _a : [];
|
|
23
|
+
}
|
|
24
|
+
exports.words = words;
|
|
25
|
+
/**
|
|
26
|
+
* Capitalizes (transforms the first character to upper case) the given string.
|
|
27
|
+
*/
|
|
28
|
+
function capitalize(str) {
|
|
29
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
30
|
+
}
|
|
31
|
+
exports.capitalize = capitalize;
|
|
32
|
+
/**
|
|
33
|
+
* Uncapitalizes (transforms the first character to lower case) the given string.
|
|
34
|
+
*/
|
|
35
|
+
function uncapitalize(str) {
|
|
36
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
37
|
+
}
|
|
38
|
+
exports.uncapitalize = uncapitalize;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a string to camel case.
|
|
41
|
+
*/
|
|
42
|
+
function toCamelCase(str) {
|
|
43
|
+
return words(str)
|
|
44
|
+
.map(function (word, index) { return (index === 0 ? word.toLowerCase() : capitalize(word.toLowerCase())); })
|
|
45
|
+
.join('');
|
|
46
|
+
}
|
|
47
|
+
exports.toCamelCase = toCamelCase;
|
|
48
|
+
//# sourceMappingURL=string.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.utils.js","sourceRoot":"","sources":["../../src/utils/string.utils.ts"],"names":[],"mappings":";;;AAAA,IAAM,YAAY,GAAG,qDAAqD,CAAC;AAE3E;;;;GAIG;AACH,SAAgB,MAAM,CACpB,GAAW,EACX,QAAqD,EACrD,SAAe;IAAf,0BAAA,EAAA,eAAe;IAEf,OAAO,QAAQ;QACb,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC1B,UAAC,IAAI,EAAE,IAAI,IAAK,OAAA,UAAG,IAAI,SAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAE,EAAlD,CAAkD,EAClE,GAAG,CACJ;QACH,CAAC,CAAC,GAAG,CAAC;AACV,CAAC;AAXD,wBAWC;AAED;;GAEG;AACH,SAAgB,KAAK,CAAC,GAAW;;IAC/B,OAAO,MAAA,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,mCAAI,EAAE,CAAC;AACvC,CAAC;AAFD,sBAEC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAFD,oCAEC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,KAAK,CAAC,GAAG,CAAC;SACd,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK,IAAK,OAAA,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,EAAnE,CAAmE,CAAC;SACzF,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAJD,kCAIC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compresses and encodes a string in base64 using the ZLib algorithm.
|
|
3
|
+
*/
|
|
4
|
+
export declare function zlibCompress(str: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Decompresses a string that has been encoded in base64 and compressed using the Zlib algorithm.
|
|
7
|
+
*/
|
|
8
|
+
export declare function zlibDecompress(str: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.zlibDecompress = exports.zlibCompress = void 0;
|
|
7
|
+
var pako_1 = __importDefault(require("pako"));
|
|
8
|
+
/**
|
|
9
|
+
* Compresses and encodes a string in base64 using the ZLib algorithm.
|
|
10
|
+
*/
|
|
11
|
+
function zlibCompress(str) {
|
|
12
|
+
var binaryConverter = new TextEncoder();
|
|
13
|
+
var binary = binaryConverter.encode(str);
|
|
14
|
+
var compressed = pako_1.default.deflate(binary);
|
|
15
|
+
return btoa(String.fromCharCode.apply(null, Array.from(compressed)));
|
|
16
|
+
}
|
|
17
|
+
exports.zlibCompress = zlibCompress;
|
|
18
|
+
/**
|
|
19
|
+
* Decompresses a string that has been encoded in base64 and compressed using the Zlib algorithm.
|
|
20
|
+
*/
|
|
21
|
+
function zlibDecompress(str) {
|
|
22
|
+
var compressed = new Uint8Array(atob(str)
|
|
23
|
+
.split('')
|
|
24
|
+
.map(function (c) { return c.charCodeAt(0); }));
|
|
25
|
+
var binary = pako_1.default.inflate(compressed);
|
|
26
|
+
var binaryConverter = new TextDecoder('utf-8');
|
|
27
|
+
return binaryConverter.decode(binary);
|
|
28
|
+
}
|
|
29
|
+
exports.zlibDecompress = zlibDecompress;
|
|
30
|
+
//# sourceMappingURL=zlib.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zlib.utils.js","sourceRoot":"","sources":["../../src/utils/zlib.utils.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AAExB;;GAEG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,IAAM,eAAe,GAAG,IAAI,WAAW,EAAE,CAAC;IAC1C,IAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AALD,oCAKC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,IAAM,UAAU,GAAG,IAAI,UAAU,CAC/B,IAAI,CAAC,GAAG,CAAC;SACN,KAAK,CAAC,EAAE,CAAC;SACT,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAf,CAAe,CAAC,CAC/B,CAAC;IACF,IAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,IAAM,eAAe,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AATD,wCASC"}
|