@monkvision/inspection-capture-web 5.3.5 → 5.3.6

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.
@@ -1,15 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -67,17 +56,20 @@ var CAPTURE_DURATION = 'capture_duration';
67
56
  */
68
57
  function useCaptureDuration(_a) {
69
58
  var _this = this;
70
- 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;
59
+ var _b, _c;
60
+ var apiConfig = _a.apiConfig, inspectionId = _a.inspectionId, isInspectionCompleted = _a.isInspectionCompleted, _d = _a.heartbeatInterval, heartbeatInterval = _d === void 0 ? 30000 : _d, _e = _a.idleTimeout, idleTimeout = _e === void 0 ? 10000 : _e;
71
61
  var startTimeRef = (0, react_1.useRef)(Date.now());
72
62
  var totalActiveTimeRef = (0, react_1.useRef)(0);
73
63
  var heartbeatTimerRef = (0, react_1.useRef)(null);
74
64
  var idleTimerRef = (0, react_1.useRef)(null);
75
65
  var pendingUpdateRef = (0, react_1.useRef)(false);
76
- var captureDurationRef = (0, react_1.useRef)(0);
77
66
  var isActive = (0, react_1.useRef)(true);
78
67
  var cycleCountRef = (0, react_1.useRef)(0);
79
68
  var updateAdditionalData = (0, network_1.useMonkApi)(apiConfig).updateAdditionalData;
80
69
  var handleError = (0, monitoring_1.useMonitoring)().handleError;
70
+ var state = (0, common_1.useMonkState)().state;
71
+ var initialDuration = (_c = (_b = state.inspections.find(function (insp) { return insp.id === inspectionId; })) === null || _b === void 0 ? void 0 : _b.additionalData) === null || _c === void 0 ? void 0 : _c[CAPTURE_DURATION];
72
+ var captureDurationRef = (0, react_1.useRef)(typeof initialDuration === 'number' ? initialDuration : 0);
81
73
  var pauseTracking = (0, react_1.useCallback)(function () {
82
74
  if (isActive.current) {
83
75
  isActive.current = false;
@@ -96,7 +88,7 @@ function useCaptureDuration(_a) {
96
88
  args_1[_i] = arguments[_i];
97
89
  }
98
90
  return __awaiter(_this, __spreadArray([], args_1, true), void 0, function (forceUpdate) {
99
- var existingDuration_1, err_1;
91
+ var err_1;
100
92
  if (forceUpdate === void 0) { forceUpdate = false; }
101
93
  return __generator(this, function (_a) {
102
94
  switch (_a.label) {
@@ -111,19 +103,17 @@ function useCaptureDuration(_a) {
111
103
  case 1:
112
104
  _a.trys.push([1, 3, 4, 5]);
113
105
  pendingUpdateRef.current = true;
114
- existingDuration_1 = 0;
115
106
  return [4 /*yield*/, updateAdditionalData({
116
107
  id: inspectionId,
117
- callback: function (existingData) {
118
- existingDuration_1 = (existingData === null || existingData === void 0 ? void 0 : existingData[CAPTURE_DURATION])
119
- ? existingData === null || existingData === void 0 ? void 0 : existingData[CAPTURE_DURATION]
120
- : 0;
121
- return __assign(__assign({}, existingData), { capture_duration: existingDuration_1 + totalActiveTimeRef.current });
108
+ callback: function () {
109
+ captureDurationRef.current += totalActiveTimeRef.current;
110
+ return {
111
+ capture_duration: captureDurationRef.current,
112
+ };
122
113
  },
123
114
  })];
124
115
  case 2:
125
116
  _a.sent();
126
- captureDurationRef.current = existingDuration_1 + totalActiveTimeRef.current;
127
117
  startTimeRef.current = Date.now();
128
118
  totalActiveTimeRef.current = 0;
129
119
  return [2 /*return*/, captureDurationRef.current];
@@ -177,8 +167,8 @@ function useCaptureDuration(_a) {
177
167
  };
178
168
  var handleVisibilityChange = function () {
179
169
  if (document.hidden) {
180
- updateDuration();
181
170
  pauseTracking();
171
+ updateDuration(true);
182
172
  }
183
173
  else {
184
174
  resumeTracking();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkvision/inspection-capture-web",
3
- "version": "5.3.5",
3
+ "version": "5.3.6",
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.3.5",
32
- "@monkvision/camera-web": "5.3.5",
33
- "@monkvision/common": "5.3.5",
34
- "@monkvision/common-ui-web": "5.3.5",
35
- "@monkvision/network": "5.3.5",
36
- "@monkvision/sights": "5.3.5",
31
+ "@monkvision/analytics": "5.3.6",
32
+ "@monkvision/camera-web": "5.3.6",
33
+ "@monkvision/common": "5.3.6",
34
+ "@monkvision/common-ui-web": "5.3.6",
35
+ "@monkvision/network": "5.3.6",
36
+ "@monkvision/sights": "5.3.6",
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.3.5",
48
- "@monkvision/eslint-config-typescript": "5.3.5",
49
- "@monkvision/eslint-config-typescript-react": "5.3.5",
50
- "@monkvision/jest-config": "5.3.5",
51
- "@monkvision/prettier-config": "5.3.5",
52
- "@monkvision/test-utils": "5.3.5",
53
- "@monkvision/typescript-config": "5.3.5",
47
+ "@monkvision/eslint-config-base": "5.3.6",
48
+ "@monkvision/eslint-config-typescript": "5.3.6",
49
+ "@monkvision/eslint-config-typescript-react": "5.3.6",
50
+ "@monkvision/jest-config": "5.3.6",
51
+ "@monkvision/prettier-config": "5.3.6",
52
+ "@monkvision/test-utils": "5.3.6",
53
+ "@monkvision/typescript-config": "5.3.6",
54
54
  "@testing-library/react": "^16.3.0",
55
55
  "@types/copyfiles": "^2",
56
56
  "@types/fscreen": "^1.0.1",
@@ -92,5 +92,5 @@
92
92
  "url": "https://github.com/monkvision/monkjs/issues"
93
93
  },
94
94
  "homepage": "https://github.com/monkvision/monkjs",
95
- "gitHead": "cfca4988f50b55abca344f0ae3408a7798d61978"
95
+ "gitHead": "c325284471cdae050f187893ceb06a3a1fbfb011"
96
96
  }