@monkvision/inspection-capture-web 5.0.21 → 5.1.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 (48) hide show
  1. package/README.md +1 -0
  2. package/lib/PhotoCapture/PhotoCapture.d.ts +2 -2
  3. package/lib/PhotoCapture/PhotoCapture.js +15 -6
  4. package/lib/PhotoCapture/PhotoCapture.styles.js +1 -1
  5. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.d.ts +10 -2
  6. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.js +3 -2
  7. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.d.ts +5 -1
  8. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.js +1 -1
  9. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.d.ts +1 -1
  10. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.js +7 -3
  11. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.styles.js +1 -0
  12. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.d.ts +5 -1
  13. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.d.ts +23 -0
  14. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.js +65 -0
  15. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.styles.d.ts +7308 -0
  16. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.styles.js +170 -0
  17. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/index.d.ts +1 -0
  18. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/index.js +5 -0
  19. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.d.ts +5 -1
  20. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.js +3 -2
  21. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.styles.js +9 -3
  22. package/lib/PhotoCapture/hooks/index.d.ts +1 -0
  23. package/lib/PhotoCapture/hooks/index.js +1 -0
  24. package/lib/PhotoCapture/hooks/useInspectionComplete.d.ts +5 -1
  25. package/lib/PhotoCapture/hooks/useInspectionComplete.js +64 -16
  26. package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.d.ts +3 -7
  27. package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.js +2 -2
  28. package/lib/PhotoCapture/hooks/usePhotoCaptureSightTutorial.d.ts +14 -0
  29. package/lib/PhotoCapture/hooks/usePhotoCaptureSightTutorial.js +16 -0
  30. package/lib/PhotoCapture/hooks/usePhotoCaptureTutorial.js +1 -1
  31. package/lib/components/SightTutorialButton/SightTutorialButton.d.ts +14 -0
  32. package/lib/components/SightTutorialButton/SightTutorialButton.js +36 -0
  33. package/lib/components/SightTutorialButton/SightTutorialButton.styles.d.ts +2 -0
  34. package/lib/components/SightTutorialButton/SightTutorialButton.styles.js +6 -0
  35. package/lib/components/SightTutorialButton/index.d.ts +1 -0
  36. package/lib/components/SightTutorialButton/index.js +5 -0
  37. package/lib/components/index.d.ts +1 -0
  38. package/lib/components/index.js +1 -0
  39. package/lib/hooks/index.d.ts +1 -0
  40. package/lib/hooks/index.js +1 -0
  41. package/lib/hooks/useCaptureDuration.d.ts +39 -0
  42. package/lib/hooks/useCaptureDuration.js +208 -0
  43. package/lib/hooks/useTracking.js +6 -0
  44. package/lib/translations/de.json +4 -0
  45. package/lib/translations/en.json +4 -0
  46. package/lib/translations/fr.json +4 -0
  47. package/lib/translations/nl.json +4 -0
  48. package/package.json +15 -15
@@ -0,0 +1,208 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.useCaptureDuration = void 0;
51
+ var common_1 = require("@monkvision/common");
52
+ var network_1 = require("@monkvision/network");
53
+ var react_1 = require("react");
54
+ var monitoring_1 = require("@monkvision/monitoring");
55
+ var CAPTURE_DURATION = 'capture_duration';
56
+ /**
57
+ * Custom hook used to track the duration of an inspection session.
58
+ */
59
+ function useCaptureDuration(_a) {
60
+ var _this = this;
61
+ var apiConfig = _a.apiConfig, inspectionId = _a.inspectionId, isInspectionCompleted = _a.isInspectionCompleted, _b = _a.heartbeatInterval, heartbeatInterval = _b === void 0 ? 30000 : _b, _c = _a.idleTimeout, idleTimeout = _c === void 0 ? 10000 : _c;
62
+ var startTimeRef = (0, react_1.useRef)(Date.now());
63
+ var totalActiveTimeRef = (0, react_1.useRef)(0);
64
+ var heartbeatTimerRef = (0, react_1.useRef)(null);
65
+ var idleTimerRef = (0, react_1.useRef)(null);
66
+ var pendingUpdateRef = (0, react_1.useRef)(false);
67
+ var captureDurationRef = (0, react_1.useRef)(0);
68
+ var isActive = (0, react_1.useRef)(true);
69
+ var cycleCountRef = (0, react_1.useRef)(0);
70
+ var updateAdditionalData = (0, network_1.useMonkApi)(apiConfig).updateAdditionalData;
71
+ var handleError = (0, monitoring_1.useMonitoring)().handleError;
72
+ var pauseTracking = (0, react_1.useCallback)(function () {
73
+ if (isActive.current) {
74
+ isActive.current = false;
75
+ totalActiveTimeRef.current += (Date.now() - startTimeRef.current) / 1000;
76
+ }
77
+ }, []);
78
+ var resumeTracking = (0, react_1.useCallback)(function () {
79
+ if (!isActive.current) {
80
+ startTimeRef.current = Date.now();
81
+ isActive.current = true;
82
+ }
83
+ }, []);
84
+ var updateDuration = (0, react_1.useCallback)(function (forceUpdate) {
85
+ if (forceUpdate === void 0) { forceUpdate = false; }
86
+ return __awaiter(_this, void 0, void 0, function () {
87
+ var existingDuration_1, err_1;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ if (isInspectionCompleted || pendingUpdateRef.current) {
92
+ return [2 /*return*/, 0];
93
+ }
94
+ if (forceUpdate) {
95
+ totalActiveTimeRef.current += (Date.now() - startTimeRef.current) / 1000;
96
+ }
97
+ _a.label = 1;
98
+ case 1:
99
+ _a.trys.push([1, 3, 4, 5]);
100
+ pendingUpdateRef.current = true;
101
+ existingDuration_1 = 0;
102
+ return [4 /*yield*/, updateAdditionalData({
103
+ id: inspectionId,
104
+ callback: function (existingData) {
105
+ existingDuration_1 = (existingData === null || existingData === void 0 ? void 0 : existingData[CAPTURE_DURATION])
106
+ ? existingData === null || existingData === void 0 ? void 0 : existingData[CAPTURE_DURATION]
107
+ : 0;
108
+ return __assign(__assign({}, existingData), { capture_duration: existingDuration_1 + totalActiveTimeRef.current });
109
+ },
110
+ })];
111
+ case 2:
112
+ _a.sent();
113
+ captureDurationRef.current = existingDuration_1 + totalActiveTimeRef.current;
114
+ startTimeRef.current = Date.now();
115
+ totalActiveTimeRef.current = 0;
116
+ return [2 /*return*/, captureDurationRef.current];
117
+ case 3:
118
+ err_1 = _a.sent();
119
+ handleError(err_1);
120
+ throw err_1;
121
+ case 4:
122
+ pendingUpdateRef.current = false;
123
+ return [7 /*endfinally*/];
124
+ case 5: return [2 /*return*/];
125
+ }
126
+ });
127
+ });
128
+ }, [updateAdditionalData, inspectionId, isInspectionCompleted, handleError]);
129
+ var restartIdleTimer = (0, react_1.useCallback)(function () {
130
+ if (idleTimerRef.current) {
131
+ clearInterval(idleTimerRef.current);
132
+ }
133
+ idleTimerRef.current = setInterval(function () {
134
+ pauseTracking();
135
+ }, idleTimeout);
136
+ }, [pauseTracking]);
137
+ (0, react_1.useEffect)(function () {
138
+ if (isInspectionCompleted) {
139
+ return undefined;
140
+ }
141
+ var activityEvents = [
142
+ 'touchstart',
143
+ 'touchmove',
144
+ 'touchend',
145
+ 'click',
146
+ 'scroll',
147
+ 'keydown',
148
+ 'mousedown',
149
+ 'mousemove',
150
+ ];
151
+ var handleActivity = function () {
152
+ if (!isActive.current) {
153
+ cycleCountRef.current += 1;
154
+ }
155
+ resumeTracking();
156
+ restartIdleTimer();
157
+ if (cycleCountRef.current >= 5) {
158
+ updateDuration(true);
159
+ cycleCountRef.current = 0;
160
+ }
161
+ };
162
+ var handleBeforeUnload = function () {
163
+ updateDuration();
164
+ };
165
+ var handleVisibilityChange = function () {
166
+ if (document.hidden) {
167
+ updateDuration();
168
+ pauseTracking();
169
+ }
170
+ else {
171
+ resumeTracking();
172
+ }
173
+ };
174
+ heartbeatTimerRef.current = setInterval(function () {
175
+ if (isActive.current) {
176
+ updateDuration(true);
177
+ }
178
+ }, heartbeatInterval);
179
+ restartIdleTimer();
180
+ document.addEventListener('visibilitychange', handleVisibilityChange);
181
+ window.addEventListener('beforeunload', handleBeforeUnload);
182
+ activityEvents.forEach(function (event) {
183
+ document.addEventListener(event, handleActivity, { passive: true });
184
+ });
185
+ return function () {
186
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
187
+ window.removeEventListener('beforeunload', handleBeforeUnload);
188
+ activityEvents.forEach(function (event) {
189
+ document.removeEventListener(event, handleActivity);
190
+ });
191
+ if (heartbeatTimerRef.current) {
192
+ clearInterval(heartbeatTimerRef.current);
193
+ }
194
+ if (idleTimerRef.current) {
195
+ clearInterval(idleTimerRef.current);
196
+ }
197
+ };
198
+ }, [
199
+ pauseTracking,
200
+ resumeTracking,
201
+ updateDuration,
202
+ heartbeatInterval,
203
+ isInspectionCompleted,
204
+ restartIdleTimer,
205
+ ]);
206
+ return (0, common_1.useObjectMemo)({ updateDuration: updateDuration });
207
+ }
208
+ exports.useCaptureDuration = useCaptureDuration;
@@ -14,6 +14,12 @@ function useTracking(_a) {
14
14
  var monitoring = (0, monitoring_1.useMonitoring)();
15
15
  (0, react_1.useEffect)(function () {
16
16
  var _a;
17
+ var currentAnalyticsUserId = analytics.getUserId();
18
+ var newAnalyticsUserId = "".concat(inspectionId, ":").concat(currentAnalyticsUserId);
19
+ if (currentAnalyticsUserId.includes(':')) {
20
+ newAnalyticsUserId = "".concat(inspectionId, ":").concat(currentAnalyticsUserId.split(':')[1]);
21
+ }
22
+ analytics.setUserId(newAnalyticsUserId);
17
23
  monitoring.setTags({
18
24
  inspectionId: inspectionId,
19
25
  });
@@ -42,6 +42,10 @@
42
42
  "sightTutorial": "Verwenden Sie das Bild unten links, um sich bei der Rahmung führen zu lassen.<br>Tippen Sie darauf, um eine detaillierte Erklärung zu erhalten.",
43
43
  "sight": "Richten Sie das Fahrzeug so gut wie möglich an den Linien aus, um das beste Foto zu erhalten.<br>Drücken Sie den Auslöser, um das Foto aufzunehmen.",
44
44
  "next": "Weiter"
45
+ },
46
+ "sightTutorial": {
47
+ "tip": "Tipp",
48
+ "defaultTutorial": "Positionieren Sie sich wie im linken Diagramm gezeigt und stellen Sie sicher, dass die Kamera auf der richtigen Höhe ist.\nFalls ein Referenzfoto vorhanden ist, versuchen Sie, Ihren Bildausschnitt entsprechend anzupassen."
45
49
  }
46
50
  },
47
51
  "gallery": {
@@ -42,6 +42,10 @@
42
42
  "sightTutorial": "Use bottom left image to guide you with the framing.<br>Tap it to see a detailed explanation.",
43
43
  "sight": "Align the vehicle with the lines as much as possible to get the best shot.<br>Press the shutter button to take the photo.",
44
44
  "next": "Next"
45
+ },
46
+ "sightTutorial": {
47
+ "tip": "Tip",
48
+ "defaultTutorial": "Position yourself as shown in the left diagram, ensuring the camera is at the correct height.\nIf a reference photo is provided, try to match your framing accordingly."
45
49
  }
46
50
  },
47
51
  "gallery": {
@@ -42,6 +42,10 @@
42
42
  "sightTutorial": "Utilisez l'image en bas à gauche pour vous guider dans le cadrage.<br>Appuyez dessus pour voir une explication détaillée.",
43
43
  "sight": "Alignez le véhicule avec les lignes autant que possible pour obtenir la meilleure photo.<br>Appuyez sur le déclencheur pour prendre la photo.",
44
44
  "next": "Suivant"
45
+ },
46
+ "sightTutorial": {
47
+ "tip": "Conseil",
48
+ "defaultTutorial": "Placez-vous comme indiqué dans le schéma de gauche en veillant à ce que la caméra soit à la bonne hauteur.\nSi une photo de référence est fournie, essayez d’adapter votre cadrage en conséquence."
45
49
  }
46
50
  },
47
51
  "gallery": {
@@ -42,6 +42,10 @@
42
42
  "sightTutorial": "Gebruik het plaatje linksonder om je te leiden bij het kadreren.<br>Klik erop voor een gedetailleerde uitleg.",
43
43
  "sight": "Richt het voertuig zo goed mogelijk uit op de lijnen om de beste foto te krijgen.<br>Druk op de knop om de foto te nemen.",
44
44
  "next": "Volgende"
45
+ },
46
+ "sightTutorial": {
47
+ "tip": "Tip",
48
+ "defaultTutorial": "Plaats jezelf zoals aangegeven in het linkerschema en zorg ervoor dat de camera op de juiste hoogte staat.\nAls er een referentiefoto is, probeer dan je kader hierop af te stemmen."
45
49
  }
46
50
  },
47
51
  "gallery": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkvision/inspection-capture-web",
3
- "version": "5.0.21",
3
+ "version": "5.1.0",
4
4
  "license": "BSD-3-Clause-Clear",
5
5
  "packageManager": "yarn@3.2.4",
6
6
  "description": "MonkJs inspection capture package for React (web) used to implement the Monk inspection capture workflow",
@@ -28,12 +28,12 @@
28
28
  "lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
29
29
  },
30
30
  "dependencies": {
31
- "@monkvision/analytics": "5.0.21",
32
- "@monkvision/camera-web": "5.0.21",
33
- "@monkvision/common": "5.0.21",
34
- "@monkvision/common-ui-web": "5.0.21",
35
- "@monkvision/network": "5.0.21",
36
- "@monkvision/sights": "5.0.21",
31
+ "@monkvision/analytics": "5.1.0",
32
+ "@monkvision/camera-web": "5.1.0",
33
+ "@monkvision/common": "5.1.0",
34
+ "@monkvision/common-ui-web": "5.1.0",
35
+ "@monkvision/network": "5.1.0",
36
+ "@monkvision/sights": "5.1.0",
37
37
  "i18next": "^23.4.5",
38
38
  "react-i18next": "^13.2.0"
39
39
  },
@@ -44,13 +44,13 @@
44
44
  "react-router-dom": "^6.22.3"
45
45
  },
46
46
  "devDependencies": {
47
- "@monkvision/eslint-config-base": "5.0.21",
48
- "@monkvision/eslint-config-typescript": "5.0.21",
49
- "@monkvision/eslint-config-typescript-react": "5.0.21",
50
- "@monkvision/jest-config": "5.0.21",
51
- "@monkvision/prettier-config": "5.0.21",
52
- "@monkvision/test-utils": "5.0.21",
53
- "@monkvision/typescript-config": "5.0.21",
47
+ "@monkvision/eslint-config-base": "5.1.0",
48
+ "@monkvision/eslint-config-typescript": "5.1.0",
49
+ "@monkvision/eslint-config-typescript-react": "5.1.0",
50
+ "@monkvision/jest-config": "5.1.0",
51
+ "@monkvision/prettier-config": "5.1.0",
52
+ "@monkvision/test-utils": "5.1.0",
53
+ "@monkvision/typescript-config": "5.1.0",
54
54
  "@testing-library/react": "^12.1.5",
55
55
  "@testing-library/react-hooks": "^8.0.1",
56
56
  "@types/copyfiles": "^2",
@@ -93,5 +93,5 @@
93
93
  "url": "https://github.com/monkvision/monkjs/issues"
94
94
  },
95
95
  "homepage": "https://github.com/monkvision/monkjs",
96
- "gitHead": "cd5e702c63e437dcd6daf445ba2b28294b8c03da"
96
+ "gitHead": "0ff06347d55681e32db67d69d36194061ca65780"
97
97
  }