@monkvision/common 4.0.20 → 4.0.21
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/README/UTILITIES.md +10 -0
- package/lib/apps/appStateProvider.js +2 -6
- package/lib/utils/config.utils.d.ts +5 -0
- package/lib/utils/config.utils.js +22 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +13 -13
package/README/UTILITIES.md
CHANGED
|
@@ -111,6 +111,16 @@ type of variation to use for the interactive colors (lighten or darken the color
|
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
114
|
+
# Config Utils
|
|
115
|
+
### getAvailableVehicleTypes
|
|
116
|
+
```typescript
|
|
117
|
+
import { getAvailableVehicleTypes } from '@monkvision/common';
|
|
118
|
+
|
|
119
|
+
console.log(getAvailableVehicleTypes(config));
|
|
120
|
+
// Output : [VehicleType.CITY, VehicleType.SUV]
|
|
121
|
+
```
|
|
122
|
+
Returns the list of available vehicle types based on the `sights` property of a `CaptureAppConfig` object.
|
|
123
|
+
|
|
114
124
|
# Environment Utils
|
|
115
125
|
### getEnvOrThrow
|
|
116
126
|
```typescript
|
|
@@ -20,6 +20,7 @@ var searchParams_1 = require("./searchParams");
|
|
|
20
20
|
var appState_1 = require("./appState");
|
|
21
21
|
var monitoring_1 = require("./monitoring");
|
|
22
22
|
var analytics_1 = require("./analytics");
|
|
23
|
+
var utils_1 = require("../utils");
|
|
23
24
|
/**
|
|
24
25
|
* Local storage key used within Monk web applications to store the authentication token.
|
|
25
26
|
*/
|
|
@@ -44,11 +45,6 @@ function getSights(config, vehicleType, steeringWheel) {
|
|
|
44
45
|
return sights_1.sights[id];
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
function getAvailableVehicleTypes(config) {
|
|
48
|
-
return (config.enableSteeringWheelPosition
|
|
49
|
-
? Object.keys(config.sights.left)
|
|
50
|
-
: Object.keys(config.sights));
|
|
51
|
-
}
|
|
52
48
|
/**
|
|
53
49
|
* A React context provider that declares the state for the common parameters used by Monk applications. The parameters
|
|
54
50
|
* are described in the `MonkAppState` interface. Using options available in the App config (`config` prop), this
|
|
@@ -65,7 +61,7 @@ function MonkAppStateProvider(_a) {
|
|
|
65
61
|
var _c = (0, react_1.useState)(null), inspectionId = _c[0], setInspectionId = _c[1];
|
|
66
62
|
var _d = (0, react_1.useState)(null), vehicleType = _d[0], setVehicleType = _d[1];
|
|
67
63
|
var _e = (0, react_1.useState)(null), steeringWheel = _e[0], setSteeringWheel = _e[1];
|
|
68
|
-
var availableVehicleTypes = (0, react_1.useMemo)(function () { return getAvailableVehicleTypes(config); }, [config]);
|
|
64
|
+
var availableVehicleTypes = (0, react_1.useMemo)(function () { return (0, utils_1.getAvailableVehicleTypes)(config); }, [config]);
|
|
69
65
|
var monkSearchParams = (0, searchParams_1.useMonkSearchParams)({ availableVehicleTypes: availableVehicleTypes });
|
|
70
66
|
(0, monitoring_1.useAppStateMonitoring)({ authToken: authToken, inspectionId: inspectionId, vehicleType: vehicleType, steeringWheel: steeringWheel });
|
|
71
67
|
(0, analytics_1.useAppStateAnalytics)({ inspectionId: inspectionId });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAvailableVehicleTypes = void 0;
|
|
13
|
+
var array_utils_1 = require("./array.utils");
|
|
14
|
+
/**
|
|
15
|
+
* Util function used to extract the list of available vehicle types in a CaptureAppConfig object.
|
|
16
|
+
*/
|
|
17
|
+
function getAvailableVehicleTypes(config) {
|
|
18
|
+
return (config.enableSteeringWheelPosition
|
|
19
|
+
? (0, array_utils_1.uniq)(__spreadArray(__spreadArray([], Object.keys(config.sights.left), true), Object.keys(config.sights.right), true))
|
|
20
|
+
: Object.keys(config.sights));
|
|
21
|
+
}
|
|
22
|
+
exports.getAvailableVehicleTypes = getAvailableVehicleTypes;
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkvision/common",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.21",
|
|
4
4
|
"license": "BSD-3-Clause-Clear",
|
|
5
5
|
"packageManager": "yarn@3.2.4",
|
|
6
6
|
"description": "MonkJs common logic package",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@monkvision/analytics": "4.0.
|
|
32
|
-
"@monkvision/monitoring": "4.0.
|
|
33
|
-
"@monkvision/sights": "4.0.
|
|
34
|
-
"@monkvision/types": "4.0.
|
|
31
|
+
"@monkvision/analytics": "4.0.21",
|
|
32
|
+
"@monkvision/monitoring": "4.0.21",
|
|
33
|
+
"@monkvision/sights": "4.0.21",
|
|
34
|
+
"@monkvision/types": "4.0.21",
|
|
35
35
|
"i18next": "^23.4.5",
|
|
36
36
|
"jsonwebtoken": "^9.0.2",
|
|
37
37
|
"jwt-decode": "^4.0.0",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"react-router-dom": "^6.22.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@monkvision/eslint-config-base": "4.0.
|
|
51
|
-
"@monkvision/eslint-config-typescript": "4.0.
|
|
52
|
-
"@monkvision/eslint-config-typescript-react": "4.0.
|
|
53
|
-
"@monkvision/jest-config": "4.0.
|
|
54
|
-
"@monkvision/prettier-config": "4.0.
|
|
55
|
-
"@monkvision/test-utils": "4.0.
|
|
56
|
-
"@monkvision/typescript-config": "4.0.
|
|
50
|
+
"@monkvision/eslint-config-base": "4.0.21",
|
|
51
|
+
"@monkvision/eslint-config-typescript": "4.0.21",
|
|
52
|
+
"@monkvision/eslint-config-typescript-react": "4.0.21",
|
|
53
|
+
"@monkvision/jest-config": "4.0.21",
|
|
54
|
+
"@monkvision/prettier-config": "4.0.21",
|
|
55
|
+
"@monkvision/test-utils": "4.0.21",
|
|
56
|
+
"@monkvision/typescript-config": "4.0.21",
|
|
57
57
|
"@testing-library/react": "^12.1.5",
|
|
58
58
|
"@testing-library/react-hooks": "^8.0.1",
|
|
59
59
|
"@types/jest": "^29.2.2",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"url": "https://github.com/monkvision/monkjs/issues"
|
|
97
97
|
},
|
|
98
98
|
"homepage": "https://github.com/monkvision/monkjs",
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "6b016ec12274d4f388b359eee1a907980368051b"
|
|
100
100
|
}
|