@shivantra/react-web-camera 1.0.0 β 1.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.
- package/README.md +15 -11
- package/dist/WebCamera.d.ts +1 -0
- package/dist/react-web-camera.cjs +4 -4
- package/dist/react-web-camera.js +145 -142
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Web Camera
|
|
2
2
|
|
|
3
3
|
A lightweight and flexible React component for capturing images from the userβs camera (front or back) with support for `jpeg`, `png`, and `webp` formats. Built with modern React (`hooks` + `forwardRef`) and works on both desktop and mobile browsers.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Table of Contents
|
|
6
6
|
|
|
7
7
|
- [Why?](#why-)
|
|
8
8
|
- [Our Solution](#our-solution-)
|
|
@@ -21,7 +21,7 @@ A lightweight and flexible React component for capturing images from the userβ
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
## Why?
|
|
24
|
+
## Why?
|
|
25
25
|
|
|
26
26
|
Capturing multiple images from a webcam is a common need in modern web apps, especially Progressive Web Apps (PWAs).
|
|
27
27
|
Existing solutions are often:
|
|
@@ -43,7 +43,7 @@ This creates a poor user experience for apps needing **multi-photo sessions** (f
|
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
46
|
-
## Our Solution
|
|
46
|
+
## Our Solution
|
|
47
47
|
|
|
48
48
|
`react-web-camera` provides a headless, platform-independent React component that gives you full control over your UI. It handles the complex logic of accessing the webcam, capturing multiple images, and managing state, while you focus on styling and user experience.
|
|
49
49
|
|
|
@@ -55,7 +55,7 @@ This makes it:
|
|
|
55
55
|
|
|
56
56
|
---
|
|
57
57
|
|
|
58
|
-
## Features
|
|
58
|
+
## Features
|
|
59
59
|
|
|
60
60
|
- **π· Front & Back Camera Support** β Easily capture images from both cameras.
|
|
61
61
|
- **πΌ Multiple Image Formats** β Export images as jpeg, png, or webp.
|
|
@@ -68,22 +68,26 @@ This makes it:
|
|
|
68
68
|
|
|
69
69
|
---
|
|
70
70
|
|
|
71
|
-
## Installation
|
|
71
|
+
## Installation
|
|
72
72
|
|
|
73
73
|
```bash
|
|
74
74
|
# If using npm
|
|
75
75
|
npm install @shivantra/react-web-camera
|
|
76
|
+
```
|
|
76
77
|
|
|
78
|
+
```bash
|
|
77
79
|
# Or with yarn
|
|
78
80
|
yarn add @shivantra/react-web-camera
|
|
81
|
+
```
|
|
79
82
|
|
|
83
|
+
```bash
|
|
80
84
|
# Or with pnpm
|
|
81
85
|
pnpm add @shivantra/react-web-camera
|
|
82
86
|
```
|
|
83
87
|
|
|
84
88
|
---
|
|
85
89
|
|
|
86
|
-
## Usage
|
|
90
|
+
## Usage
|
|
87
91
|
|
|
88
92
|
- **Basic Example**
|
|
89
93
|
|
|
@@ -228,7 +232,7 @@ export default function PWAApp() {
|
|
|
228
232
|
|
|
229
233
|
---
|
|
230
234
|
|
|
231
|
-
## Ref Methods
|
|
235
|
+
## Ref Methods
|
|
232
236
|
|
|
233
237
|
Access these methods via `ref`:
|
|
234
238
|
|
|
@@ -240,7 +244,7 @@ Access these methods via `ref`:
|
|
|
240
244
|
|
|
241
245
|
---
|
|
242
246
|
|
|
243
|
-
## Notes
|
|
247
|
+
## Notes
|
|
244
248
|
|
|
245
249
|
- On mobile devices, some browsers may require HTTPS to access the camera.
|
|
246
250
|
- Ensure the user grants camera permissions; otherwise, the component will throw an error.
|
|
@@ -248,13 +252,13 @@ Access these methods via `ref`:
|
|
|
248
252
|
|
|
249
253
|
---
|
|
250
254
|
|
|
251
|
-
## License
|
|
255
|
+
## License
|
|
252
256
|
|
|
253
257
|
MIT License Β© 2025 Shivantra Solutions Private Limited
|
|
254
258
|
|
|
255
259
|
---
|
|
256
260
|
|
|
257
|
-
## Contact
|
|
261
|
+
## Contact
|
|
258
262
|
|
|
259
263
|
For more details about our projects, services, or any general information regarding **react-web-camera**, feel free to reach out to us. We are here to provide support and answer any questions you may have. Below are the best ways to contact our team:
|
|
260
264
|
|
package/dist/WebCamera.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export type WebCameraHandler = {
|
|
|
17
17
|
capture: () => Promise<File | null>;
|
|
18
18
|
switch: (facingMode?: FacingMode) => Promise<void>;
|
|
19
19
|
getMode: () => CaptureMode;
|
|
20
|
+
stop: () => void;
|
|
20
21
|
};
|
|
21
22
|
export declare const WebCamera: import('react').ForwardRefExoticComponent<WebCameraProps & import('react').RefAttributes<WebCameraHandler>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react");var G={exports:{}},N={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Q;function te(){if(Q)return N;Q=1;var v=Symbol.for("react.transitional.element"),h=Symbol.for("react.fragment");function k(g,o,l){var b=null;if(l!==void 0&&(b=""+l),o.key!==void 0&&(b=""+o.key),"key"in o){l={};for(var R in o)R!=="key"&&(l[R]=o[R])}else l=o;return o=l.ref,{$$typeof:v,type:g,key:b,ref:o!==void 0?o:null,props:l}}return N.Fragment=h,N.jsx=k,N.jsxs=k,N}var M={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var K;function ne(){return K||(K=1,process.env.NODE_ENV!=="production"&&function(){function v(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Y?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case A:return"Fragment";case W:return"Profiler";case x:return"StrictMode";case a:return"Suspense";case n:return"SuspenseList";case _:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case p:return"Portal";case O:return(e.displayName||"Context")+".Provider";case D:return(e._context.displayName||"Context")+".Consumer";case I:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case w:return r=e.displayName||null,r!==null?r:v(e.type)||"Memo";case i:r=e._payload,e=e._init;try{return v(e(r))}catch{}}return null}function h(e){return""+e}function k(e){try{h(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),h(e)}}function g(e){if(e===A)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===i)return"<...>";try{var r=v(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function o(){var e=S.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function b(e){if(C.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function t(){J||(J=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function f(){var e=v(this.type);return X[e]||(X[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function $(e,r,t,s,T,m,U,V){return t=m.ref,e={$$typeof:P,type:e,key:r,props:m,_owner:T},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:f}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,r,t,s,T,m,U,V){var c=r.children;if(c!==void 0)if(s)if(F(c)){for(s=0;s<c.length;s++)y(c[s]);Object.freeze&&Object.freeze(c)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(c);if(C.call(r,"key")){c=v(e);var j=Object.keys(r).filter(function(re){return re!=="key"});s=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",Z[c+s]||(j=0<j.length?"{"+j.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,s,c,
|
|
22
|
+
<%s key={someKey} {...props} />`,s,c,j,c),Z[c+s]=!0)}if(c=null,t!==void 0&&(k(t),c=""+t),b(r)&&(k(r.key),c=""+r.key),"key"in r){t={};for(var q in r)q!=="key"&&(t[q]=r[q])}else t=r;return c&&R(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),$(e,c,m,T,o(),t,U,V)}function y(e){typeof e=="object"&&e!==null&&e.$$typeof===P&&e._store&&(e._store.validated=1)}var E=u,P=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),O=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),Y=Symbol.for("react.client.reference"),S=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,F=Array.isArray,L=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var J,X={},H=E.react_stack_bottom_frame.bind(E,l)(),B=L(g(l)),Z={};M.Fragment=A,M.jsx=function(e,r,t,s,T){var m=1e4>S.recentlyCreatedOwnerStacks++;return d(e,r,t,!1,s,T,m?Error("react-stack-top-frame"):H,m?L(g(e)):B)},M.jsxs=function(e,r,t,s,T){var m=1e4>S.recentlyCreatedOwnerStacks++;return d(e,r,t,!0,s,T,m?Error("react-stack-top-frame"):H,m?L(g(e)):B)}}()),M}process.env.NODE_ENV==="production"?G.exports=te():G.exports=ne();var z=G.exports;const ae={back:"environment",front:"user"},ee=u.forwardRef(({className:v,style:h,videoClassName:k,videoStyle:g,getFileName:o,captureMode:l="back",captureType:b="jpeg",captureQuality:R=.8,onError:f},$)=>{const d=u.useRef(null),y=u.useRef(null),[E,P]=u.useState(null),[p,A]=u.useState(ae[l]),[x,W]=u.useState([]),D=u.useCallback(async()=>{const a=d.current,n=y.current;return!a||!n||a.readyState<2?null:new Promise(w=>{const i=n.getContext("2d"),_=a.videoWidth||640,Y=a.videoHeight||480;n.width=_,n.height=Y,i.drawImage(a,0,0,_,Y);const S=`image/${b}`;n.toBlob(async C=>{if(!C)return;const F=new File([C],(o==null?void 0:o())??`capture-${Date.now()}.${b}`,{type:S,lastModified:Date.now()});w(F)},S,R)})},[b,R,o]),O=u.useCallback(()=>{E&&(E.getTracks().forEach(a=>a.stop()),d.current&&(d.current.srcObject=null))},[E]),I=u.useCallback(async()=>{O();const a=p==="user"?"environment":"user";A(a);try{let n;if(x.length>=2){const i=x.find(_=>a==="user"?_.label.toLowerCase().includes("front"):_.label.toLowerCase().includes("back"));n=i?{video:{deviceId:{exact:i.deviceId}}}:{video:{facingMode:{ideal:a}}}}else n={video:{facingMode:{ideal:a}}};const w=await navigator.mediaDevices.getUserMedia(n);d.current&&(d.current.srcObject=w),P(w)}catch(n){f==null||f(n)}},[O,p,x,f]);return u.useImperativeHandle($,()=>({capture:D,stop:O,switch:I,getMode:()=>p==="environment"?"back":"front"}),[p,D,O,I]),u.useEffect(()=>{let a;const n=d.current;return(async()=>{try{const i=await navigator.mediaDevices.enumerateDevices();W(i.filter(_=>_.kind==="videoinput")),a=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:p}}}),n&&(n.srcObject=a,n.onloadedmetadata=()=>n==null?void 0:n.play()),P(a)}catch(i){f==null||f(i)}})(),()=>{a==null||a.getTracks().forEach(i=>i.stop()),n&&(n.srcObject=null)}},[p,f]),z.jsxs("div",{className:v,style:h,children:[z.jsx("video",{ref:d,className:k,autoPlay:!0,playsInline:!0,muted:!0,style:{...g,display:"block",objectFit:"cover",height:"100%",width:"100%"},children:"Video stream not available."}),z.jsx("canvas",{ref:y,style:{display:"none"}})]})});exports.WebCamera=ee;exports.default=ee;
|
package/dist/react-web-camera.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ne, { forwardRef as ae, useRef as
|
|
2
|
-
var
|
|
1
|
+
import ne, { forwardRef as ae, useRef as K, useState as z, useCallback as q, useImperativeHandle as oe, useEffect as se } from "react";
|
|
2
|
+
var J = { exports: {} }, C = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -9,29 +9,29 @@ var q = { exports: {} }, P = {};
|
|
|
9
9
|
* This source code is licensed under the MIT license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
|
-
var
|
|
12
|
+
var ee;
|
|
13
13
|
function ce() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
function T(k, o,
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
|
|
14
|
+
if (ee) return C;
|
|
15
|
+
ee = 1;
|
|
16
|
+
var m = Symbol.for("react.transitional.element"), g = Symbol.for("react.fragment");
|
|
17
|
+
function T(k, o, l) {
|
|
18
|
+
var v = null;
|
|
19
|
+
if (l !== void 0 && (v = "" + l), o.key !== void 0 && (v = "" + o.key), "key" in o) {
|
|
20
|
+
l = {};
|
|
21
21
|
for (var R in o)
|
|
22
|
-
R !== "key" && (
|
|
23
|
-
} else
|
|
24
|
-
return o =
|
|
25
|
-
$$typeof:
|
|
22
|
+
R !== "key" && (l[R] = o[R]);
|
|
23
|
+
} else l = o;
|
|
24
|
+
return o = l.ref, {
|
|
25
|
+
$$typeof: m,
|
|
26
26
|
type: k,
|
|
27
|
-
key:
|
|
27
|
+
key: v,
|
|
28
28
|
ref: o !== void 0 ? o : null,
|
|
29
|
-
props:
|
|
29
|
+
props: l
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return C.Fragment = g, C.jsx = T, C.jsxs = T, C;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var N = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -41,26 +41,26 @@ var x = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
44
|
+
var re;
|
|
45
45
|
function ie() {
|
|
46
|
-
return
|
|
47
|
-
function
|
|
46
|
+
return re || (re = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
|
+
function m(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof ===
|
|
50
|
+
return e.$$typeof === I ? null : e.displayName || e.name || null;
|
|
51
51
|
if (typeof e == "string") return e;
|
|
52
52
|
switch (e) {
|
|
53
|
-
case
|
|
53
|
+
case A:
|
|
54
54
|
return "Fragment";
|
|
55
55
|
case $:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case P:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case a:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case n:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case b:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof e == "object")
|
|
@@ -69,19 +69,19 @@ function ie() {
|
|
|
69
69
|
), e.$$typeof) {
|
|
70
70
|
case E:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case
|
|
72
|
+
case h:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
|
-
case
|
|
74
|
+
case D:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
76
|
+
case M:
|
|
77
77
|
var r = e.render;
|
|
78
78
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
-
case
|
|
80
|
-
return r = e.displayName || null, r !== null ? r :
|
|
81
|
-
case
|
|
79
|
+
case w:
|
|
80
|
+
return r = e.displayName || null, r !== null ? r : m(e.type) || "Memo";
|
|
81
|
+
case i:
|
|
82
82
|
r = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
|
-
return
|
|
84
|
+
return m(e(r));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -99,8 +99,8 @@ function ie() {
|
|
|
99
99
|
}
|
|
100
100
|
if (r) {
|
|
101
101
|
r = console;
|
|
102
|
-
var
|
|
103
|
-
return
|
|
102
|
+
var t = r.error, s = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return t.call(
|
|
104
104
|
r,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
106
|
s
|
|
@@ -108,56 +108,56 @@ function ie() {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function k(e) {
|
|
111
|
-
if (e ===
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
111
|
+
if (e === A) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === i)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var r =
|
|
115
|
+
var r = m(e);
|
|
116
116
|
return r ? "<" + r + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function o() {
|
|
122
|
-
var e =
|
|
122
|
+
var e = O.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function l() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
128
|
+
function v(e) {
|
|
129
|
+
if (x.call(e, "key")) {
|
|
130
130
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
131
|
if (r && r.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
135
|
function R(e, r) {
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function t() {
|
|
137
|
+
X || (X = !0, console.error(
|
|
138
138
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
139
|
r
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
142
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: t,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
function u() {
|
|
148
|
-
var e =
|
|
149
|
-
return
|
|
148
|
+
var e = m(this.type);
|
|
149
|
+
return H[e] || (H[e] = !0, console.error(
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
152
|
}
|
|
153
|
-
function Y(e, r,
|
|
154
|
-
return
|
|
155
|
-
$$typeof:
|
|
153
|
+
function Y(e, r, t, s, p, d, U, W) {
|
|
154
|
+
return t = d.ref, e = {
|
|
155
|
+
$$typeof: S,
|
|
156
156
|
type: e,
|
|
157
157
|
key: r,
|
|
158
|
-
props:
|
|
158
|
+
props: d,
|
|
159
159
|
_owner: p
|
|
160
|
-
}, (
|
|
160
|
+
}, (t !== void 0 ? t : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
162
|
get: u
|
|
163
163
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
@@ -174,33 +174,33 @@ function ie() {
|
|
|
174
174
|
configurable: !1,
|
|
175
175
|
enumerable: !1,
|
|
176
176
|
writable: !0,
|
|
177
|
-
value:
|
|
177
|
+
value: U
|
|
178
178
|
}), Object.defineProperty(e, "_debugTask", {
|
|
179
179
|
configurable: !1,
|
|
180
180
|
enumerable: !1,
|
|
181
181
|
writable: !0,
|
|
182
|
-
value:
|
|
182
|
+
value: W
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function f(e, r,
|
|
185
|
+
function f(e, r, t, s, p, d, U, W) {
|
|
186
186
|
var c = r.children;
|
|
187
187
|
if (c !== void 0)
|
|
188
188
|
if (s)
|
|
189
|
-
if (
|
|
189
|
+
if (F(c)) {
|
|
190
190
|
for (s = 0; s < c.length; s++)
|
|
191
|
-
|
|
191
|
+
y(c[s]);
|
|
192
192
|
Object.freeze && Object.freeze(c);
|
|
193
193
|
} else
|
|
194
194
|
console.error(
|
|
195
195
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
196
|
);
|
|
197
|
-
else
|
|
198
|
-
if (
|
|
199
|
-
c =
|
|
200
|
-
var
|
|
197
|
+
else y(c);
|
|
198
|
+
if (x.call(r, "key")) {
|
|
199
|
+
c = m(e);
|
|
200
|
+
var j = Object.keys(r).filter(function(te) {
|
|
201
201
|
return te !== "key";
|
|
202
202
|
});
|
|
203
|
-
s = 0 <
|
|
203
|
+
s = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", Q[c + s] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
204
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
205
|
let props = %s;
|
|
206
206
|
<%s {...props} />
|
|
@@ -209,33 +209,33 @@ React keys must be passed directly to JSX without using spread:
|
|
|
209
209
|
<%s key={someKey} {...props} />`,
|
|
210
210
|
s,
|
|
211
211
|
c,
|
|
212
|
-
|
|
212
|
+
j,
|
|
213
213
|
c
|
|
214
|
-
),
|
|
214
|
+
), Q[c + s] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (c = null,
|
|
217
|
-
|
|
218
|
-
for (var
|
|
219
|
-
|
|
220
|
-
} else
|
|
216
|
+
if (c = null, t !== void 0 && (T(t), c = "" + t), v(r) && (T(r.key), c = "" + r.key), "key" in r) {
|
|
217
|
+
t = {};
|
|
218
|
+
for (var V in r)
|
|
219
|
+
V !== "key" && (t[V] = r[V]);
|
|
220
|
+
} else t = r;
|
|
221
221
|
return c && R(
|
|
222
|
-
|
|
222
|
+
t,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
224
|
), Y(
|
|
225
225
|
e,
|
|
226
226
|
c,
|
|
227
|
-
|
|
227
|
+
d,
|
|
228
228
|
p,
|
|
229
229
|
o(),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
t,
|
|
231
|
+
U,
|
|
232
|
+
W
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
235
|
+
function y(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === S && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var _ = ne,
|
|
238
|
+
var _ = ne, S = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), P = Symbol.for("react.strict_mode"), $ = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), h = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), a = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), w = Symbol.for("react.memo"), i = Symbol.for("react.lazy"), b = Symbol.for("react.activity"), I = Symbol.for("react.client.reference"), O = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, F = Array.isArray, L = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
241
|
_ = {
|
|
@@ -243,123 +243,126 @@ React keys must be passed directly to JSX without using spread:
|
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var
|
|
246
|
+
var X, H = {}, B = _.react_stack_bottom_frame.bind(
|
|
247
247
|
_,
|
|
248
|
-
|
|
249
|
-
)(),
|
|
250
|
-
|
|
251
|
-
var
|
|
248
|
+
l
|
|
249
|
+
)(), Z = L(k(l)), Q = {};
|
|
250
|
+
N.Fragment = A, N.jsx = function(e, r, t, s, p) {
|
|
251
|
+
var d = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return f(
|
|
253
253
|
e,
|
|
254
254
|
r,
|
|
255
|
-
|
|
255
|
+
t,
|
|
256
256
|
!1,
|
|
257
257
|
s,
|
|
258
258
|
p,
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
d ? Error("react-stack-top-frame") : B,
|
|
260
|
+
d ? L(k(e)) : Z
|
|
261
261
|
);
|
|
262
|
-
},
|
|
263
|
-
var
|
|
262
|
+
}, N.jsxs = function(e, r, t, s, p) {
|
|
263
|
+
var d = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return f(
|
|
265
265
|
e,
|
|
266
266
|
r,
|
|
267
|
-
|
|
267
|
+
t,
|
|
268
268
|
!0,
|
|
269
269
|
s,
|
|
270
270
|
p,
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
d ? Error("react-stack-top-frame") : B,
|
|
272
|
+
d ? L(k(e)) : Z
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
}()),
|
|
275
|
+
}()), N;
|
|
276
276
|
}
|
|
277
|
-
process.env.NODE_ENV === "production" ?
|
|
278
|
-
var
|
|
277
|
+
process.env.NODE_ENV === "production" ? J.exports = ce() : J.exports = ie();
|
|
278
|
+
var G = J.exports;
|
|
279
279
|
const le = {
|
|
280
280
|
back: "environment",
|
|
281
281
|
front: "user"
|
|
282
282
|
}, fe = ae(
|
|
283
283
|
({
|
|
284
|
-
className:
|
|
284
|
+
className: m,
|
|
285
285
|
style: g,
|
|
286
286
|
videoClassName: T,
|
|
287
287
|
videoStyle: k,
|
|
288
288
|
getFileName: o,
|
|
289
|
-
captureMode:
|
|
290
|
-
captureType:
|
|
289
|
+
captureMode: l = "back",
|
|
290
|
+
captureType: v = "jpeg",
|
|
291
291
|
captureQuality: R = 0.8,
|
|
292
292
|
onError: u
|
|
293
293
|
}, Y) => {
|
|
294
|
-
const f =
|
|
295
|
-
le[
|
|
296
|
-
), [
|
|
297
|
-
const a = f.current,
|
|
298
|
-
return !a || !
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
async (
|
|
304
|
-
if (!
|
|
305
|
-
const
|
|
306
|
-
[
|
|
307
|
-
(o == null ? void 0 : o()) ?? `capture-${Date.now()}.${
|
|
294
|
+
const f = K(null), y = K(null), [_, S] = z(null), [E, A] = z(
|
|
295
|
+
le[l]
|
|
296
|
+
), [P, $] = z([]), D = q(async () => {
|
|
297
|
+
const a = f.current, n = y.current;
|
|
298
|
+
return !a || !n || a.readyState < 2 ? null : new Promise((w) => {
|
|
299
|
+
const i = n.getContext("2d"), b = a.videoWidth || 640, I = a.videoHeight || 480;
|
|
300
|
+
n.width = b, n.height = I, i.drawImage(a, 0, 0, b, I);
|
|
301
|
+
const O = `image/${v}`;
|
|
302
|
+
n.toBlob(
|
|
303
|
+
async (x) => {
|
|
304
|
+
if (!x) return;
|
|
305
|
+
const F = new File(
|
|
306
|
+
[x],
|
|
307
|
+
(o == null ? void 0 : o()) ?? `capture-${Date.now()}.${v}`,
|
|
308
308
|
{
|
|
309
|
-
type:
|
|
309
|
+
type: O,
|
|
310
310
|
lastModified: Date.now()
|
|
311
311
|
}
|
|
312
312
|
);
|
|
313
|
-
w(
|
|
313
|
+
w(F);
|
|
314
314
|
},
|
|
315
|
-
|
|
315
|
+
O,
|
|
316
316
|
R
|
|
317
317
|
);
|
|
318
318
|
});
|
|
319
|
-
}, [
|
|
320
|
-
_ && (_.getTracks().forEach((
|
|
319
|
+
}, [v, R, o]), h = q(() => {
|
|
320
|
+
_ && (_.getTracks().forEach((a) => a.stop()), f.current && (f.current.srcObject = null));
|
|
321
|
+
}, [_]), M = q(async () => {
|
|
322
|
+
h();
|
|
321
323
|
const a = E === "user" ? "environment" : "user";
|
|
322
|
-
|
|
324
|
+
A(a);
|
|
323
325
|
try {
|
|
324
|
-
let
|
|
325
|
-
if (
|
|
326
|
-
const
|
|
327
|
-
(
|
|
326
|
+
let n;
|
|
327
|
+
if (P.length >= 2) {
|
|
328
|
+
const i = P.find(
|
|
329
|
+
(b) => a === "user" ? b.label.toLowerCase().includes("front") : b.label.toLowerCase().includes("back")
|
|
328
330
|
);
|
|
329
|
-
|
|
331
|
+
n = i ? { video: { deviceId: { exact: i.deviceId } } } : { video: { facingMode: { ideal: a } } };
|
|
330
332
|
} else
|
|
331
|
-
|
|
332
|
-
const w = await navigator.mediaDevices.getUserMedia(
|
|
333
|
-
f.current && (f.current.srcObject = w),
|
|
334
|
-
} catch (
|
|
335
|
-
u == null || u(
|
|
333
|
+
n = { video: { facingMode: { ideal: a } } };
|
|
334
|
+
const w = await navigator.mediaDevices.getUserMedia(n);
|
|
335
|
+
f.current && (f.current.srcObject = w), S(w);
|
|
336
|
+
} catch (n) {
|
|
337
|
+
u == null || u(n);
|
|
336
338
|
}
|
|
337
|
-
}, [
|
|
339
|
+
}, [h, E, P, u]);
|
|
338
340
|
return oe(
|
|
339
341
|
Y,
|
|
340
342
|
() => ({
|
|
341
|
-
capture:
|
|
342
|
-
|
|
343
|
+
capture: D,
|
|
344
|
+
stop: h,
|
|
345
|
+
switch: M,
|
|
343
346
|
getMode: () => E === "environment" ? "back" : "front"
|
|
344
347
|
}),
|
|
345
|
-
[E,
|
|
348
|
+
[E, D, h, M]
|
|
346
349
|
), se(() => {
|
|
347
350
|
let a;
|
|
348
|
-
const
|
|
351
|
+
const n = f.current;
|
|
349
352
|
return (async () => {
|
|
350
353
|
try {
|
|
351
|
-
const
|
|
352
|
-
$(
|
|
354
|
+
const i = await navigator.mediaDevices.enumerateDevices();
|
|
355
|
+
$(i.filter((b) => b.kind === "videoinput")), a = await navigator.mediaDevices.getUserMedia({
|
|
353
356
|
video: { facingMode: { ideal: E } }
|
|
354
|
-
}),
|
|
355
|
-
} catch (
|
|
356
|
-
u == null || u(
|
|
357
|
+
}), n && (n.srcObject = a, n.onloadedmetadata = () => n == null ? void 0 : n.play()), S(a);
|
|
358
|
+
} catch (i) {
|
|
359
|
+
u == null || u(i);
|
|
357
360
|
}
|
|
358
361
|
})(), () => {
|
|
359
|
-
a == null || a.getTracks().forEach((
|
|
362
|
+
a == null || a.getTracks().forEach((i) => i.stop()), n && (n.srcObject = null);
|
|
360
363
|
};
|
|
361
|
-
}, [E, u]), /* @__PURE__ */
|
|
362
|
-
/* @__PURE__ */
|
|
364
|
+
}, [E, u]), /* @__PURE__ */ G.jsxs("div", { className: m, style: g, children: [
|
|
365
|
+
/* @__PURE__ */ G.jsx(
|
|
363
366
|
"video",
|
|
364
367
|
{
|
|
365
368
|
ref: f,
|
|
@@ -377,7 +380,7 @@ const le = {
|
|
|
377
380
|
children: "Video stream not available."
|
|
378
381
|
}
|
|
379
382
|
),
|
|
380
|
-
/* @__PURE__ */
|
|
383
|
+
/* @__PURE__ */ G.jsx("canvas", { ref: y, style: { display: "none" } })
|
|
381
384
|
] });
|
|
382
385
|
}
|
|
383
386
|
);
|