@monkvision/camera-web 5.1.2 → 5.1.4

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.
@@ -196,6 +196,7 @@ function getStreamDimensions(stream, checkOrientation) {
196
196
  */
197
197
  function useUserMedia(constraints, videoRef) {
198
198
  var _this = this;
199
+ var streamRef = (0, react_1.useRef)(null);
199
200
  var _a = (0, react_1.useState)(null), stream = _a[0], setStream = _a[1];
200
201
  var _b = (0, react_1.useState)(null), dimensions = _b[0], setDimensions = _b[1];
201
202
  var _c = (0, react_1.useState)(false), isLoading = _c[0], setIsLoading = _c[1];
@@ -265,6 +266,7 @@ function useUserMedia(constraints, videoRef) {
265
266
  str === null || str === void 0 ? void 0 : str.addEventListener('inactive', onStreamInactive);
266
267
  if (isMounted()) {
267
268
  setStream(str);
269
+ streamRef.current = str;
268
270
  setDimensions(getStreamDimensions(str, true));
269
271
  setIsLoading(false);
270
272
  setAvailableCameraDevices(deviceDetails.availableDevices);
@@ -343,6 +345,14 @@ function useUserMedia(constraints, videoRef) {
343
345
  };
344
346
  }
345
347
  }, [stream, videoRef]);
348
+ (0, react_1.useEffect)(function () {
349
+ return function () {
350
+ var _a;
351
+ (_a = streamRef.current) === null || _a === void 0 ? void 0 : _a.getTracks().forEach(function (track) {
352
+ track.stop();
353
+ });
354
+ };
355
+ }, []);
346
356
  return (0, common_1.useObjectMemo)({
347
357
  getUserMedia: getUserMedia,
348
358
  stream: stream,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkvision/camera-web",
3
- "version": "5.1.2",
3
+ "version": "5.1.4",
4
4
  "license": "BSD-3-Clause-Clear",
5
5
  "packageManager": "yarn@3.2.4",
6
6
  "description": "MonkJs camera package for React (web) used to display a camera preview and take pictures",
@@ -28,9 +28,9 @@
28
28
  "lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
29
29
  },
30
30
  "dependencies": {
31
- "@monkvision/common": "5.1.2",
32
- "@monkvision/common-ui-web": "5.1.2",
33
- "@monkvision/monitoring": "5.1.2",
31
+ "@monkvision/common": "5.1.4",
32
+ "@monkvision/common-ui-web": "5.1.4",
33
+ "@monkvision/monitoring": "5.1.4",
34
34
  "fast-deep-equal": "^3.1.3",
35
35
  "i18next": "^23.4.5",
36
36
  "react-i18next": "^13.2.0"
@@ -42,13 +42,13 @@
42
42
  "react-router-dom": "^6.22.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@monkvision/eslint-config-base": "5.1.2",
46
- "@monkvision/eslint-config-typescript": "5.1.2",
47
- "@monkvision/eslint-config-typescript-react": "5.1.2",
48
- "@monkvision/jest-config": "5.1.2",
49
- "@monkvision/prettier-config": "5.1.2",
50
- "@monkvision/test-utils": "5.1.2",
51
- "@monkvision/typescript-config": "5.1.2",
45
+ "@monkvision/eslint-config-base": "5.1.4",
46
+ "@monkvision/eslint-config-typescript": "5.1.4",
47
+ "@monkvision/eslint-config-typescript-react": "5.1.4",
48
+ "@monkvision/jest-config": "5.1.4",
49
+ "@monkvision/prettier-config": "5.1.4",
50
+ "@monkvision/test-utils": "5.1.4",
51
+ "@monkvision/typescript-config": "5.1.4",
52
52
  "@testing-library/react": "^12.1.5",
53
53
  "@testing-library/react-hooks": "^8.0.1",
54
54
  "@types/fscreen": "^1.0.1",
@@ -90,5 +90,5 @@
90
90
  "url": "https://github.com/monkvision/monkjs/issues"
91
91
  },
92
92
  "homepage": "https://github.com/monkvision/monkjs",
93
- "gitHead": "1ac73a2cae564f8e42b207b01dc909f1ee04f878"
93
+ "gitHead": "d6235358964c496cecbe3932fc00b03ac69e79eb"
94
94
  }