@uziee/document-scanner 1.1.1 → 1.1.3
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/dist/index.es.js +391 -332
- package/dist/index.umd.js +10 -10
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(z,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(z=typeof globalThis<"u"?globalThis:z||self,E(z.DocumentScanner={},z.React))})(this,function(z,E){"use strict";var ce={exports:{}},q={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.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 Ee;function Le(){if(Ee)return q;Ee=1;var Y=E,m=Symbol.for("react.element"),U=Symbol.for("react.fragment"),P=Object.prototype.hasOwnProperty,M=Y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,G={key:!0,ref:!0,__self:!0,__source:!0};function A(L,d,J){var x,k={},S=null,X=null;J!==void 0&&(S=""+J),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(X=d.ref);for(x in d)P.call(d,x)&&!G.hasOwnProperty(x)&&(k[x]=d[x]);if(L&&L.defaultProps)for(x in d=L.defaultProps,d)k[x]===void 0&&(k[x]=d[x]);return{$$typeof:m,type:L,key:S,ref:X,props:k,_owner:M.current}}return q.Fragment=U,q.jsx=A,q.jsxs=A,q}var ee={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,19 +14,19 @@
|
|
|
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
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var _e;function Ne(){return _e||(_e=1,{}.NODE_ENV!=="production"&&function(){var Y=E,m=Symbol.for("react.element"),U=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),A=Symbol.for("react.provider"),L=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),ae=Symbol.iterator,ue="@@iterator";function fe(e){if(e===null||typeof e!="object")return null;var r=ae&&e[ae]||e[ue];return typeof r=="function"?r:null}var H=Y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];c("error",e,t)}}function c(e,r,t){{var n=H.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var v=!1,l=!1,s=!1,T=!1,D=!1,g;g=Symbol.for("react.module.reference");function w(e){return!!(typeof e=="string"||typeof e=="function"||e===P||e===G||D||e===M||e===J||e===x||T||e===X||v||l||s||typeof e=="object"&&e!==null&&(e.$$typeof===S||e.$$typeof===k||e.$$typeof===A||e.$$typeof===L||e.$$typeof===d||e.$$typeof===g||e.getModuleId!==void 0))}function _(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function N(e){return e.displayName||"Context"}function b(e){if(e==null)return null;if(typeof e.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case U:return"Portal";case G:return"Profiler";case M:return"StrictMode";case J:return"Suspense";case x:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case L:var r=e;return N(r)+".Consumer";case A:var t=e;return N(t._context)+".Provider";case d:return _(e,e.render,"ForwardRef");case k:var n=e.displayName||null;return n!==null?n:b(e.type)||"Memo";case S:{var i=e,u=i._payload,o=i._init;try{return b(o(u))}catch{return null}}}return null}var F=Object.assign,C=0,p,j,K,V,B,re,de;function Ce(){}Ce.__reactDisabledLog=!0;function Be(){{if(C===0){p=console.log,j=console.info,K=console.warn,V=console.error,B=console.group,re=console.groupCollapsed,de=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ce,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}C++}}function ze(){{if(C--,C===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:p}),info:F({},e,{value:j}),warn:F({},e,{value:K}),error:F({},e,{value:V}),group:F({},e,{value:B}),groupCollapsed:F({},e,{value:re}),groupEnd:F({},e,{value:de})})}C<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ve=H.ReactCurrentDispatcher,pe;function oe(e,r,t){{if(pe===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);pe=n&&n[1]||""}return`
|
|
18
|
+
`+pe+e}}var he=!1,ie;{var Je=typeof WeakMap=="function"?WeakMap:Map;ie=new Je}function je(e,r){if(!e||he)return"";{var t=ie.get(e);if(t!==void 0)return t}var n;he=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=ve.current,ve.current=null,Be();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(I){n=I}Reflect.construct(e,[],o)}else{try{o.call()}catch(I){n=I}e.call(o.prototype)}}else{try{throw Error()}catch(I){n=I}e()}}catch(I){if(I&&n&&typeof I.stack=="string"){for(var a=I.stack.split(`
|
|
19
|
+
`),O=n.stack.split(`
|
|
20
|
+
`),h=a.length-1,y=O.length-1;h>=1&&y>=0&&a[h]!==O[y];)y--;for(;h>=1&&y>=0;h--,y--)if(a[h]!==O[y]){if(h!==1||y!==1)do if(h--,y--,y<0||a[h]!==O[y]){var W=`
|
|
21
|
+
`+a[h].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),typeof e=="function"&&ie.set(e,W),W}while(h>=1&&y>=0);break}}}finally{he=!1,ve.current=u,ze(),Error.prepareStackTrace=i}var Q=e?e.displayName||e.name:"",$=Q?oe(Q):"";return typeof e=="function"&&ie.set(e,$),$}function He(e,r,t){return je(e,!1)}function Ke(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function se(e,r,t){if(e==null)return"";if(typeof e=="function")return je(e,Ke(e));if(typeof e=="string")return oe(e);switch(e){case J:return oe("Suspense");case x:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return He(e.render);case k:return se(e.type,r,t);case S:{var n=e,i=n._payload,u=n._init;try{return se(u(i),r,t)}catch{}}}return""}var te=Object.prototype.hasOwnProperty,Se={},Te=H.ReactDebugCurrentFrame;function le(e){if(e){var r=e._owner,t=se(e.type,e._source,r?r.type:null);Te.setExtraStackFrame(t)}else Te.setExtraStackFrame(null)}function Ge(e,r,t,n,i){{var u=Function.call.bind(te);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var O=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw O.name="Invariant Violation",O}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(h){a=h}a&&!(a instanceof Error)&&(le(i),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),le(null)),a instanceof Error&&!(a.message in Se)&&(Se[a.message]=!0,le(i),R("Failed %s type: %s",t,a.message),le(null))}}}var $e=Array.isArray;function ge(e){return $e(e)}function Xe(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Ze(e){try{return Oe(e),!1}catch{return!0}}function Oe(e){return""+e}function Pe(e){if(Ze(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Xe(e)),Oe(e)}var ne=H.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},ke,De,be;be={};function qe(e){if(te.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function er(e){if(te.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function rr(e,r){if(typeof e.ref=="string"&&ne.current&&r&&ne.current.stateNode!==r){var t=b(ne.current.type);be[t]||(R('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',b(ne.current.type),e.ref),be[t]=!0)}}function tr(e,r){{var t=function(){ke||(ke=!0,R("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function nr(e,r){{var t=function(){De||(De=!0,R("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ar=function(e,r,t,n,i,u,o){var a={$$typeof:m,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function or(e,r,t,n,i){{var u,o={},a=null,O=null;t!==void 0&&(Pe(t),a=""+t),er(r)&&(Pe(r.key),a=""+r.key),qe(r)&&(O=r.ref,rr(r,i));for(u in r)te.call(r,u)&&!Qe.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var h=e.defaultProps;for(u in h)o[u]===void 0&&(o[u]=h[u])}if(a||O){var y=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&tr(o,y),O&&nr(o,y)}return ar(e,a,O,i,n,ne.current,o)}}var ye=H.ReactCurrentOwner,Fe=H.ReactDebugCurrentFrame;function Z(e){if(e){var r=e._owner,t=se(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(t)}else Fe.setExtraStackFrame(null)}var me;me=!1;function xe(e){return typeof e=="object"&&e!==null&&e.$$typeof===m}function Ie(){{if(ye.current){var e=b(ye.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function ir(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+r+":"+t+"."}return""}}var
|
|
25
|
+
Check your code at `+r+":"+t+"."}return""}}var Ae={};function sr(e){{var r=Ie();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function We(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=sr(r);if(
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function We(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=sr(r);if(Ae[t])return;Ae[t]=!0;var n="";e&&e._owner&&e._owner!==ye.current&&(n=" It was passed a child from "+b(e._owner.type)+"."),Z(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),Z(null)}}function Me(e,r){{if(typeof e!="object")return;if(ge(e))for(var t=0;t<e.length;t++){var n=e[t];xe(n)&&We(n,r)}else if(xe(e))e._store&&(e._store.validated=!0);else if(e){var i=fe(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)xe(o.value)&&We(o.value,r)}}}function lr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===k))t=r.propTypes;else return;if(t){var n=b(r);Ge(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!me){me=!0;var i=b(r);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function cr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){Z(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),Z(null);break}}e.ref!==null&&(Z(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}var Ye={};function Ue(e,r,t,n,i,u){{var o=w(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var O=ir(i);O?a+=O:a+=Ie();var h;e===null?h="null":ge(e)?h="array":e!==void 0&&e.$$typeof===m?(h="<"+(b(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):h=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",h,a)}var y=or(e,r,t,i,u);if(y==null)return y;if(o){var W=r.children;if(W!==void 0)if(n)if(ge(W)){for(var Q=0;Q<W.length;Q++)Me(W[Q],e);Object.freeze&&Object.freeze(W)}else R("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 Me(W,e)}if(te.call(r,"key")){var $=b(e),I=Object.keys(r).filter(function(hr){return hr!=="key"}),Re=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!Ye[$+Re]){var pr=I.length>0?"{"+I.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
|
|
28
28
|
let props = %s;
|
|
29
29
|
<%s {...props} />
|
|
30
30
|
React keys must be passed directly to JSX without using spread:
|
|
31
31
|
let props = %s;
|
|
32
|
-
<%s key={someKey} {...props} />`,
|
|
32
|
+
<%s key={someKey} {...props} />`,Re,$,pr,$),Ye[$+Re]=!0}}return e===P?cr(y):lr(y),y}}function ur(e,r,t){return Ue(e,r,t,!0)}function fr(e,r,t){return Ue(e,r,t,!1)}var dr=fr,vr=ur;ee.Fragment=P,ee.jsx=dr,ee.jsxs=vr}()),ee}({}).NODE_ENV==="production"?ce.exports=Le():ce.exports=Ne();var f=ce.exports;const we=({onCapture:Y})=>{const m=E.useRef(null),U=E.useRef(null),P=E.useRef(null),[M,G]=E.useState(!1),[A,L]=E.useState(null),[d,J]=E.useState([]),x=E.useRef(null),k=E.useRef([]),S=E.useRef(0);E.useEffect(()=>{P.current||(P.current=document.createElement("canvas"));let c=null;async function v(){try{const s=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1920}}});m.current&&(m.current.srcObject=s,m.current.play(),c=requestAnimationFrame(l))}catch(s){console.error("Camera access error:",s)}}function l(){var s;if(((s=m.current)==null?void 0:s.readyState)>=2){const T=m.current,D=U.current;if(!D)return;const g=D.getContext("2d");D.width!==T.videoWidth&&(D.width=T.videoWidth,D.height=T.videoHeight),g.drawImage(T,0,0);const w=ae(T);if(w){x.current&&X(w,x.current)?S.current=Math.min(15,S.current+1):S.current=0,k.current.push(w),k.current.length>10&&k.current.shift();const _=ue(k.current);x.current=_,S.current>5&&(G(!0),L(_))}else S.current=Math.max(0,S.current-2),S.current===0&&(x.current=null,G(!1),L(null))}c=requestAnimationFrame(l)}return v(),()=>cancelAnimationFrame(c)},[]);const X=(c,v)=>Math.abs(c.tl[0]-v.tl[0])+Math.abs(c.tl[1]-v.tl[1])<50,ae=c=>{const l=Math.floor(c.videoWidth*.15),s=Math.floor(c.videoHeight*.15),T=P.current.getContext("2d");P.current.width=l,P.current.height=s,T.drawImage(c,0,0,l,s);const D=T.getImageData(0,0,l,s).data;let g=[l,s],w=[0,s],_=[l,0],N=[0,0],b=0;for(let p=10;p<s-10;p++)for(let j=10;j<l-10;j++){const K=(p*l+j)*4,V=D[K],B=D[K+1],re=D[K+2];V>180&&B>180&&re>170&&Math.abs(V-B)<25&&Math.abs(B-re)<25&&(b++,j+p<g[0]+g[1]&&(g=[j,p]),j-p>w[0]-w[1]&&(w=[j,p]),j-p<_[0]-_[1]&&(_=[j,p]),j+p>N[0]+N[1]&&(N=[j,p]))}const F=w[0]-g[0],C=_[1]-g[1];return b<l*s*.08||F<l*.3||C<s*.3?null:{tl:[g[0]/.15,g[1]/.15],tr:[w[0]/.15,w[1]/.15],bl:[_[0]/.15,_[1]/.15],br:[N[0]/.15,N[1]/.15]}},ue=c=>{const v={tl:[0,0],tr:[0,0],bl:[0,0],br:[0,0]};return c.forEach(l=>{["tl","tr","bl","br"].forEach(s=>{v[s][0]+=l[s][0]/c.length,v[s][1]+=l[s][1]/c.length})}),v},fe=()=>{const c=m.current,v=x.current;if(!c||!v)return;const l=1240,s=1754,T=document.createElement("canvas");T.width=l,T.height=s;const D=T.getContext("2d"),g=document.createElement("canvas");g.width=c.videoWidth,g.height=c.videoHeight,g.getContext("2d").drawImage(c,0,0);const w=g.getContext("2d").getImageData(0,0,g.width,g.height),_=D.createImageData(l,s);for(let b=0;b<s;b++)for(let F=0;F<l;F++){const C=F/l,p=b/s,j=Math.floor((1-C)*(1-p)*v.tl[0]+C*(1-p)*v.tr[0]+(1-C)*p*v.bl[0]+C*p*v.br[0]),K=Math.floor((1-C)*(1-p)*v.tl[1]+C*(1-p)*v.tr[1]+(1-C)*p*v.bl[1]+C*p*v.br[1]),V=(b*l+F)*4,B=(K*g.width+j)*4;_.data[V]=w.data[B],_.data[V+1]=w.data[B+1],_.data[V+2]=w.data[B+2],_.data[V+3]=255}D.putImageData(_,0,0);const N=T.toDataURL("image/jpeg",.92);J(b=>[...b,N])},H=()=>{d.length>0&&Y(d)},R=()=>{if(!A||!m.current)return"";const c=m.current.videoWidth,v=m.current.videoHeight,l=s=>`${s[0]/c*100},${s[1]/v*100}`;return`${l(A.tl)} ${l(A.tr)} ${l(A.br)} ${l(A.bl)}`};return f.jsxs("div",{style:{position:"fixed",inset:0,backgroundColor:"#000",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"hidden"},children:[f.jsx("video",{ref:m,style:{display:"none"},playsInline:!0,muted:!0}),f.jsx("canvas",{ref:U,style:{width:"100vw",height:"100vh",objectFit:"cover"}}),f.jsx("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10},children:A&&f.jsx("polygon",{points:R(),fill:"rgba(0, 255, 70, 0.15)",stroke:"#00FF46",strokeWidth:"0.5",style:{transition:"all 0.1s ease-out"}})}),f.jsx("div",{style:{position:"absolute",top:0,width:"100%",padding:"40px 0 20px",background:"linear-gradient(rgba(0,0,0,0.6), transparent)",textAlign:"center",zIndex:20},children:f.jsx("div",{style:{display:"inline-block",padding:"6px 16px",borderRadius:"20px",backgroundColor:M?"#00FF46":"rgba(255,255,255,0.2)",color:M?"#000":"#fff",fontSize:"12px",fontWeight:"bold"},children:M?"READY TO SCAN":"POSITION DOCUMENT"})}),f.jsxs("div",{style:{position:"absolute",bottom:0,width:"100%",height:"160px",background:"linear-gradient(transparent, rgba(0,0,0,0.8))",display:"flex",alignItems:"center",justifyContent:"space-around",zIndex:20},children:[f.jsxs("div",{onClick:H,style:{width:"64px",height:"64px",position:"relative",cursor:d.length>0?"pointer":"default",opacity:d.length>0?1:.4,transition:"transform 0.2s"},onMouseDown:c=>d.length>0&&(c.currentTarget.style.transform="scale(0.9)"),onMouseUp:c=>c.currentTarget.style.transform="scale(1)",children:[d.length>0?f.jsxs(f.Fragment,{children:[f.jsx("img",{src:d[d.length-1],style:{width:"100%",height:"100%",objectFit:"cover",border:"2px solid #fff",borderRadius:"4px"},alt:"preview"}),f.jsx("div",{style:{position:"absolute",top:"-8px",right:"-8px",background:"#00FF46",color:"#000",width:"22px",height:"22px",borderRadius:"50%",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid #000"},children:d.length})]}):f.jsx("div",{style:{width:"100%",height:"100%",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.1)",border:"1px dashed #555"}}),f.jsx("span",{style:{fontSize:"10px",display:"block",textAlign:"center",marginTop:"4px",color:"#fff"},children:"DONE"})]}),f.jsx("button",{onClick:fe,disabled:!M,style:{width:"84px",height:"84px",borderRadius:"50%",border:`4px solid ${M?"#00FF46":"#555"}`,backgroundColor:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("div",{style:{width:"68px",height:"68px",borderRadius:"50%",backgroundColor:M?"#fff":"#444"}})}),f.jsx("div",{style:{width:"64px"}})]})]})};function Ve(){const[Y,m]=E.useState(null);return f.jsxs("div",{style:{textAlign:"center",padding:"20px",fontFamily:"sans-serif"},children:[f.jsx("h1",{children:"JS Doc Scanner"}),Y?f.jsxs("div",{children:[f.jsx("h3",{children:"Scanned Result:"}),Y==null?void 0:Y.map((U,P)=>f.jsx("img",{src:U,style:{width:"100%",maxWidth:"400px",border:"2px solid #ccc",margin:"10px"}},P)),f.jsx("br",{}),f.jsx("button",{onClick:()=>m(null),children:"Scan Again"})]}):f.jsx(we,{onCapture:U=>m(U)})]})}z.App=Ve,z.DocumentScanner=we,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uziee/document-scanner",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A lightweight, zero-dependency React document scanner with real-time edge detection, stability filtering, and perspective correction (bilinear warping) for high-resolution A4 captures.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|