@exige/web-scanner-sdk 0.2.35 → 0.2.36
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/{driver-license-CV0oawgf.js → driver-license-CBDCGp14.js} +481 -441
- package/dist/driver-license-CBDCGp14.js.map +1 -0
- package/dist/react.js +319 -317
- package/dist/react.js.map +1 -1
- package/dist/scanner-sdk.js +3 -3
- package/dist/sdk/barcode.d.ts +17 -5
- package/package.json +1 -1
- package/dist/driver-license-CV0oawgf.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as h, useCallback as g, useContext as
|
|
4
|
-
import { Fragment as
|
|
2
|
+
import { H as e, K as t, L as n, R as r, T as i, W as a, Y as o, a as s, f as c, j as l, o as u, p as d, q as f, r as p, w as ee, y as m, z as te } from "./driver-license-CBDCGp14.js";
|
|
3
|
+
import { createContext as h, useCallback as g, useContext as ne, useEffect as _, useLayoutEffect as re, useMemo as ie, useRef as v, useState as y } from "react";
|
|
4
|
+
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
5
5
|
//#region src/sdk/display-quad.ts
|
|
6
|
-
function
|
|
6
|
+
function C(e) {
|
|
7
7
|
return [
|
|
8
8
|
e.topLeft,
|
|
9
9
|
e.topRight,
|
|
@@ -11,7 +11,7 @@ function w(e) {
|
|
|
11
11
|
e.bottomLeft
|
|
12
12
|
];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function w(e) {
|
|
15
15
|
let [t, n, r, i] = e;
|
|
16
16
|
return {
|
|
17
17
|
topLeft: t,
|
|
@@ -38,10 +38,10 @@ function T(e) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
41
|
+
function T(e) {
|
|
42
|
+
return w(C(e).map((e) => ({ ...e })));
|
|
43
43
|
}
|
|
44
|
-
var
|
|
44
|
+
var ae = class {
|
|
45
45
|
current;
|
|
46
46
|
target;
|
|
47
47
|
response;
|
|
@@ -50,11 +50,11 @@ var ie = class {
|
|
|
50
50
|
this.response = e.response ?? 14, this.snapDistance = e.snapDistance ?? .1;
|
|
51
51
|
}
|
|
52
52
|
setTarget(e, t, n) {
|
|
53
|
-
let r = Math.max(1, Math.hypot(t, n)), i = !this.current ||
|
|
54
|
-
let n =
|
|
53
|
+
let r = Math.max(1, Math.hypot(t, n)), i = !this.current || C(e).some((e, t) => {
|
|
54
|
+
let n = C(this.current)[t];
|
|
55
55
|
return Math.hypot(e.x - n.x, e.y - n.y) / r > this.snapDistance;
|
|
56
56
|
});
|
|
57
|
-
return this.target =
|
|
57
|
+
return this.target = T(e), i && (this.current = T(e)), {
|
|
58
58
|
quad: this.current,
|
|
59
59
|
snapped: i
|
|
60
60
|
};
|
|
@@ -62,8 +62,8 @@ var ie = class {
|
|
|
62
62
|
step(e) {
|
|
63
63
|
if (!this.current || !this.target) return this.current;
|
|
64
64
|
let t = 1 - Math.exp(-this.response * Math.max(0, e) / 1e3);
|
|
65
|
-
return this.current =
|
|
66
|
-
let r =
|
|
65
|
+
return this.current = w(C(this.current).map((e, n) => {
|
|
66
|
+
let r = C(this.target)[n];
|
|
67
67
|
return {
|
|
68
68
|
x: e.x + (r.x - e.x) * t,
|
|
69
69
|
y: e.y + (r.y - e.y) * t
|
|
@@ -76,13 +76,13 @@ var ie = class {
|
|
|
76
76
|
getCurrent() {
|
|
77
77
|
return this.current;
|
|
78
78
|
}
|
|
79
|
-
},
|
|
79
|
+
}, oe = h(null);
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/react/context.tsx
|
|
82
|
-
function
|
|
82
|
+
function se(e) {
|
|
83
83
|
e?.startsWith("blob:") && URL.revokeObjectURL(e);
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function ce(e) {
|
|
86
86
|
try {
|
|
87
87
|
let t = e.toDataURL("image/jpeg", .92);
|
|
88
88
|
return t.startsWith("data:image/") ? t : void 0;
|
|
@@ -90,130 +90,130 @@ function se(e) {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function le(e, t) {
|
|
94
94
|
if (typeof e == "function") return e(t);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
let k =
|
|
98
|
-
onCapture:
|
|
99
|
-
onDriverLicense:
|
|
100
|
-
onCancel:
|
|
101
|
-
onError:
|
|
102
|
-
onSettings:
|
|
103
|
-
onFinderStatus:
|
|
96
|
+
function ue({ open: n, useCase: p = "document", autoCapture: m = "defaultOn", captureMode: h = "auto", torch: ne = "defaultOff", onCapture: b, onDriverLicense: S, onCancel: C, onError: w, onSettings: T, onFinderStatus: ue, modelUrl: E, ortWasmPaths: D, detectionIntervalMs: de, apiRef: O, children: fe }) {
|
|
97
|
+
let k = t(h), A = v(void 0), j = v(void 0), pe = v(void 0), M = v(void 0), N = v({}), P = v(new ae()), F = v(!1), me = v(!1), I = v({
|
|
98
|
+
onCapture: b,
|
|
99
|
+
onDriverLicense: S,
|
|
100
|
+
onCancel: C,
|
|
101
|
+
onError: w,
|
|
102
|
+
onSettings: T,
|
|
103
|
+
onFinderStatus: ue,
|
|
104
104
|
useCase: p
|
|
105
|
-
}),
|
|
105
|
+
}), L = v(void 0), he = v(void 0), R = v(async () => void 0), z = v(!1), B = v(void 0), ge = v(null), [V, _e] = y(null), [ve, H] = y(k && n ? "capturing" : k ? "ready" : "starting"), [U, W] = y(), [ye, G] = y(), [be, xe] = y({
|
|
106
106
|
width: 1,
|
|
107
107
|
height: 1
|
|
108
|
-
}), [
|
|
108
|
+
}), [Se, Ce] = y(), [we, K] = y(), [Te, q] = y(""), [Ee, De] = y(0), [Oe, J] = y(), [ke, Y] = y(), [Ae, X] = y("idle"), [je, Me] = y(), Ne = v(void 0), [Pe, Fe] = y("front"), Ie = v("front"), [Le, Re] = y(!1), [ze, Be] = y({
|
|
109
109
|
downloading: !1,
|
|
110
110
|
loaded: 0,
|
|
111
111
|
total: null
|
|
112
112
|
}), Z = g(() => {
|
|
113
|
-
|
|
113
|
+
se(Ne.current), Ne.current = void 0, Me(void 0);
|
|
114
114
|
}, []), Q = g((e, t) => {
|
|
115
|
-
let n =
|
|
116
|
-
|
|
115
|
+
let n = ce(e);
|
|
116
|
+
se(Ne.current), Ne.current = n, Me(n), t?.pause();
|
|
117
117
|
}, []);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
onCapture:
|
|
121
|
-
onDriverLicense:
|
|
122
|
-
onCancel:
|
|
123
|
-
onError:
|
|
124
|
-
onSettings:
|
|
125
|
-
onFinderStatus:
|
|
118
|
+
re(() => {
|
|
119
|
+
I.current = {
|
|
120
|
+
onCapture: b,
|
|
121
|
+
onDriverLicense: S,
|
|
122
|
+
onCancel: C,
|
|
123
|
+
onError: w,
|
|
124
|
+
onSettings: T,
|
|
125
|
+
onFinderStatus: ue,
|
|
126
126
|
useCase: p
|
|
127
127
|
};
|
|
128
128
|
}, [
|
|
129
|
-
|
|
129
|
+
b,
|
|
130
|
+
S,
|
|
130
131
|
C,
|
|
131
132
|
w,
|
|
132
133
|
T,
|
|
133
|
-
|
|
134
|
-
le,
|
|
134
|
+
ue,
|
|
135
135
|
p
|
|
136
|
-
]), _(() =>
|
|
137
|
-
if (!
|
|
138
|
-
|
|
136
|
+
]), _(() => o(Be), []), _(() => {
|
|
137
|
+
if (!n || p !== "drivers-license") {
|
|
138
|
+
he.current = void 0, L.current = void 0, z.current = !1, Fe("front"), Re(!1);
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
|
-
let e =
|
|
141
|
+
let e = s({ scan: {
|
|
142
142
|
modelUrl: E,
|
|
143
143
|
ortWasmPaths: D
|
|
144
144
|
} });
|
|
145
|
-
return
|
|
146
|
-
|
|
145
|
+
return he.current = e, e.then((e) => {
|
|
146
|
+
L.current = e;
|
|
147
147
|
}), () => {
|
|
148
|
-
e.then((e) => e.cancel()),
|
|
148
|
+
e.then((e) => e.cancel()), L.current &&= void 0, he.current = void 0;
|
|
149
149
|
};
|
|
150
150
|
}, [
|
|
151
|
-
|
|
151
|
+
n,
|
|
152
152
|
p,
|
|
153
153
|
E,
|
|
154
154
|
D
|
|
155
155
|
]);
|
|
156
|
-
let
|
|
157
|
-
|
|
156
|
+
let Ve = g((e) => {
|
|
157
|
+
_e(e);
|
|
158
158
|
}, []);
|
|
159
159
|
_(() => {
|
|
160
|
-
if (!
|
|
160
|
+
if (!n || !V) return;
|
|
161
161
|
let e = () => {
|
|
162
|
-
let e =
|
|
163
|
-
|
|
162
|
+
let e = V.getBoundingClientRect();
|
|
163
|
+
xe({
|
|
164
164
|
width: e.width,
|
|
165
165
|
height: e.height
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
168
|
if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
169
169
|
let t = new ResizeObserver(e);
|
|
170
|
-
return t.observe(
|
|
171
|
-
}, [
|
|
172
|
-
if (!
|
|
170
|
+
return t.observe(V), () => t.disconnect();
|
|
171
|
+
}, [n, V]), _(() => {
|
|
172
|
+
if (!n) return;
|
|
173
173
|
let e = window.setInterval(() => {
|
|
174
174
|
let e = A.current?.getDiagnostics();
|
|
175
|
-
e &&
|
|
175
|
+
e && J(e);
|
|
176
176
|
}, 500);
|
|
177
177
|
return () => window.clearInterval(e);
|
|
178
|
-
}, [
|
|
179
|
-
if (!
|
|
180
|
-
let e = 0, t = performance.now(),
|
|
181
|
-
let i =
|
|
182
|
-
t =
|
|
178
|
+
}, [n, Ee]), _(() => {
|
|
179
|
+
if (!n) return;
|
|
180
|
+
let e = 0, t = performance.now(), r = (n) => {
|
|
181
|
+
let i = P.current.step(n - t);
|
|
182
|
+
t = n, i && G(i), e = requestAnimationFrame(r);
|
|
183
183
|
};
|
|
184
|
-
return e = requestAnimationFrame(
|
|
185
|
-
}, [
|
|
186
|
-
if (!
|
|
184
|
+
return e = requestAnimationFrame(r), () => cancelAnimationFrame(e);
|
|
185
|
+
}, [n]), _(() => {
|
|
186
|
+
if (!n || k || !V) return;
|
|
187
187
|
let e = !1, t = new AbortController();
|
|
188
|
-
|
|
189
|
-
let
|
|
190
|
-
t.abort(),
|
|
188
|
+
B.current = t;
|
|
189
|
+
let r = () => {
|
|
190
|
+
t.abort(), B.current === t && (B.current = void 0), j.current?.stop(), j.current = void 0, A.current?.stop(), A.current = void 0, M.current = void 0, pe.current = void 0, N.current = {}, Z();
|
|
191
191
|
};
|
|
192
192
|
return (async () => {
|
|
193
|
-
|
|
193
|
+
r(), t = new AbortController(), B.current = t, F.current = !1, H("starting"), q(""), W(void 0), K(void 0), Y(void 0), X("idle"), Z();
|
|
194
194
|
try {
|
|
195
|
-
let n = await
|
|
195
|
+
let n = await f(V, { torch: ne });
|
|
196
196
|
if (e) {
|
|
197
197
|
n.stop();
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
200
|
A.current = n;
|
|
201
201
|
let r = n.getSettings();
|
|
202
|
-
if (
|
|
203
|
-
|
|
202
|
+
if (Ce(r), I.current.onSettings?.(r), console.info("[ScannerProvider] camera settings", r), I.current.useCase === "drivers-license" && Ie.current === "back") {
|
|
203
|
+
W(void 0), G(void 0), P.current.clear(), H("ready"), (async () => {
|
|
204
204
|
try {
|
|
205
|
-
let r = await
|
|
205
|
+
let r = await u(() => {
|
|
206
206
|
try {
|
|
207
|
-
return n.capture();
|
|
207
|
+
return n.capture(c);
|
|
208
208
|
} catch {
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
211
211
|
}, {
|
|
212
|
-
intervalMs:
|
|
212
|
+
intervalMs: de ?? 140,
|
|
213
213
|
signal: t.signal
|
|
214
214
|
});
|
|
215
|
-
if (e || t.signal.aborted ||
|
|
216
|
-
|
|
215
|
+
if (e || t.signal.aborted || z.current) return;
|
|
216
|
+
z.current = !0, Q(r, V), K("video-frame"), H("captured"), await R.current({
|
|
217
217
|
frame: r,
|
|
218
218
|
reason: "auto",
|
|
219
219
|
method: "video-frame",
|
|
@@ -222,43 +222,43 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
222
222
|
} catch (n) {
|
|
223
223
|
if (e || t.signal.aborted || n instanceof DOMException && n.name === "AbortError") return;
|
|
224
224
|
let r = n instanceof Error ? n : /* @__PURE__ */ Error("Could not read the barcode.");
|
|
225
|
-
|
|
225
|
+
F.current = !0, q(r.message), H("error"), I.current.onError?.(r);
|
|
226
226
|
}
|
|
227
227
|
})();
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
j.current = await
|
|
231
|
-
source:
|
|
230
|
+
j.current = await i({
|
|
231
|
+
source: V,
|
|
232
232
|
autoCapture: m,
|
|
233
|
-
intervalMs:
|
|
233
|
+
intervalMs: de,
|
|
234
234
|
detection: {
|
|
235
235
|
modelUrl: E,
|
|
236
236
|
ortWasmPaths: D
|
|
237
237
|
},
|
|
238
238
|
onStatus: (e) => {
|
|
239
|
-
if (
|
|
240
|
-
let t =
|
|
241
|
-
|
|
242
|
-
} else
|
|
243
|
-
e.state !== "captured" && !
|
|
239
|
+
if (pe.current = e, W(e), I.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
|
|
240
|
+
let t = P.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
|
|
241
|
+
G(t.quad);
|
|
242
|
+
} else P.current.clear(), G(void 0);
|
|
243
|
+
e.state !== "captured" && !F.current && H("ready");
|
|
244
244
|
},
|
|
245
245
|
captureFrame: async () => {
|
|
246
|
-
|
|
247
|
-
quad:
|
|
248
|
-
sourceWidth:
|
|
249
|
-
sourceHeight:
|
|
246
|
+
H("capturing"), N.current = {
|
|
247
|
+
quad: P.current.getCurrent(),
|
|
248
|
+
sourceWidth: pe.current?.sourceWidth,
|
|
249
|
+
sourceHeight: pe.current?.sourceHeight
|
|
250
250
|
};
|
|
251
251
|
let e = await n.capturePhoto();
|
|
252
|
-
if (
|
|
253
|
-
return Q(e.frame,
|
|
252
|
+
if (M.current = e, K(e.method), Y(e.diagnostics), J(e.diagnostics), e.luminance <= 10) throw Error(`The captured frame was blank (luminance ${e.luminance.toFixed(1)} via ${e.method}). Keep the scanner visible while capturing and retake.`);
|
|
253
|
+
return Q(e.frame, V), H("captured"), e.frame;
|
|
254
254
|
},
|
|
255
255
|
onCaptureError: (e) => {
|
|
256
|
-
|
|
256
|
+
F.current = !0, H("error"), q(e.message);
|
|
257
257
|
let t = A.current?.getDiagnostics();
|
|
258
|
-
t &&
|
|
258
|
+
t && J(t), I.current.onError?.(e);
|
|
259
259
|
},
|
|
260
260
|
onCapture: async (e) => {
|
|
261
|
-
let t =
|
|
261
|
+
let t = M.current;
|
|
262
262
|
await new Promise((e) => window.setTimeout(e, 140));
|
|
263
263
|
let r = {
|
|
264
264
|
...e,
|
|
@@ -267,87 +267,87 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
267
267
|
fallbackReason: t?.fallbackReason,
|
|
268
268
|
luminance: t?.luminance,
|
|
269
269
|
diagnostics: t?.diagnostics,
|
|
270
|
-
displayedQuad:
|
|
271
|
-
displaySourceWidth:
|
|
272
|
-
displaySourceHeight:
|
|
270
|
+
displayedQuad: N.current.quad,
|
|
271
|
+
displaySourceWidth: N.current.sourceWidth,
|
|
272
|
+
displaySourceHeight: N.current.sourceHeight
|
|
273
273
|
};
|
|
274
|
-
if (
|
|
275
|
-
await
|
|
274
|
+
if (I.current.useCase === "drivers-license") {
|
|
275
|
+
await R.current(r);
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
|
-
await
|
|
278
|
+
await le(I.current.onCapture, r);
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
281
|
} catch (t) {
|
|
282
282
|
if (e) return;
|
|
283
|
-
|
|
284
|
-
let
|
|
285
|
-
|
|
283
|
+
r();
|
|
284
|
+
let n = t instanceof Error ? t : /* @__PURE__ */ Error("Camera access failed.");
|
|
285
|
+
q(n.message), H("error"), I.current.onError?.(n);
|
|
286
286
|
}
|
|
287
287
|
})(), () => {
|
|
288
|
-
e = !0,
|
|
288
|
+
e = !0, r();
|
|
289
289
|
};
|
|
290
290
|
}, [
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
n,
|
|
292
|
+
V,
|
|
293
293
|
k,
|
|
294
294
|
m,
|
|
295
|
-
|
|
295
|
+
ne,
|
|
296
296
|
E,
|
|
297
297
|
D,
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
de,
|
|
299
|
+
Ee,
|
|
300
300
|
Z,
|
|
301
301
|
Q
|
|
302
302
|
]);
|
|
303
|
-
let
|
|
304
|
-
open:
|
|
305
|
-
phase:
|
|
303
|
+
let He = {
|
|
304
|
+
open: n,
|
|
305
|
+
phase: ve,
|
|
306
306
|
autoCapture: m,
|
|
307
307
|
captureMode: h,
|
|
308
308
|
usingSystemCamera: k,
|
|
309
|
-
finderStatus:
|
|
310
|
-
displayQuad:
|
|
311
|
-
previewSize:
|
|
312
|
-
settings:
|
|
313
|
-
captureMethod:
|
|
314
|
-
error:
|
|
315
|
-
diagnostics:
|
|
316
|
-
shutterDiagnostics:
|
|
317
|
-
copyState:
|
|
318
|
-
guidanceHint:
|
|
319
|
-
detectorStatus:
|
|
320
|
-
modelDownload:
|
|
321
|
-
frozenPreviewUrl:
|
|
309
|
+
finderStatus: U,
|
|
310
|
+
displayQuad: ye,
|
|
311
|
+
previewSize: be,
|
|
312
|
+
settings: Se,
|
|
313
|
+
captureMethod: we,
|
|
314
|
+
error: Te,
|
|
315
|
+
diagnostics: Oe,
|
|
316
|
+
shutterDiagnostics: ke,
|
|
317
|
+
copyState: Ae,
|
|
318
|
+
guidanceHint: U ? ee(U.guidance, U.lighting) : void 0,
|
|
319
|
+
detectorStatus: p === "drivers-license" && Pe === "back" && !k ? "zxing" : U?.modelStatus === "failed" ? `ML failed${U.modelError ? `: ${U.modelError}` : ""}` : U?.detector === "ml" ? `ML ${U.modelProvider ?? ""}`.trim() : "ML loading",
|
|
320
|
+
modelDownload: ze,
|
|
321
|
+
frozenPreviewUrl: je,
|
|
322
322
|
useCase: p,
|
|
323
|
-
licenseSide: p === "drivers-license" ?
|
|
324
|
-
licenseBusy: p === "drivers-license" ?
|
|
323
|
+
licenseSide: p === "drivers-license" ? Pe : void 0,
|
|
324
|
+
licenseBusy: p === "drivers-license" ? Le : void 0
|
|
325
325
|
};
|
|
326
326
|
_(() => {
|
|
327
|
-
|
|
327
|
+
ge.current = He;
|
|
328
328
|
});
|
|
329
|
-
let
|
|
330
|
-
|
|
329
|
+
let Ue = g(() => {
|
|
330
|
+
I.current.onCancel();
|
|
331
331
|
}, []), $ = g(async () => {
|
|
332
|
-
if (!
|
|
333
|
-
|
|
332
|
+
if (!me.current) {
|
|
333
|
+
me.current = !0, F.current = !1, q(""), G(void 0), P.current.clear(), H("capturing");
|
|
334
334
|
try {
|
|
335
|
-
let t = await
|
|
335
|
+
let t = await a();
|
|
336
336
|
Q(t);
|
|
337
337
|
let n = {
|
|
338
338
|
width: t.width,
|
|
339
339
|
height: t.height
|
|
340
340
|
};
|
|
341
|
-
|
|
341
|
+
Ce(n), I.current.onSettings?.(n), K("system-camera");
|
|
342
342
|
let r;
|
|
343
343
|
try {
|
|
344
|
-
let
|
|
345
|
-
|
|
344
|
+
let n = t.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, t.width, t.height).data;
|
|
345
|
+
n && (r = e(n));
|
|
346
346
|
} catch {
|
|
347
347
|
r = void 0;
|
|
348
348
|
}
|
|
349
|
-
if (
|
|
350
|
-
|
|
349
|
+
if (I.current.useCase === "drivers-license" && Ie.current === "back") {
|
|
350
|
+
G(void 0), P.current.clear(), N.current = {}, H("captured"), await R.current({
|
|
351
351
|
frame: t,
|
|
352
352
|
reason: "manual",
|
|
353
353
|
method: "system-camera",
|
|
@@ -356,20 +356,20 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
356
356
|
});
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
|
-
let i = await
|
|
359
|
+
let i = await l(t, {
|
|
360
360
|
modelUrl: E,
|
|
361
361
|
ortWasmPaths: D
|
|
362
362
|
});
|
|
363
363
|
if (i.status !== "success" || !i.corners || !i.quad) {
|
|
364
|
-
|
|
364
|
+
F.current = !0, H("error"), q(i.message), I.current.onError?.(Error(i.message));
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
|
-
|
|
367
|
+
N.current = {
|
|
368
368
|
quad: i.quad,
|
|
369
369
|
sourceWidth: i.sourceWidth,
|
|
370
370
|
sourceHeight: i.sourceHeight
|
|
371
|
-
}, i.quad &&
|
|
372
|
-
let
|
|
371
|
+
}, i.quad && G(i.quad), H("captured");
|
|
372
|
+
let o = {
|
|
373
373
|
frame: t,
|
|
374
374
|
detection: i,
|
|
375
375
|
reason: "manual",
|
|
@@ -380,75 +380,75 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
380
380
|
displaySourceWidth: i.sourceWidth,
|
|
381
381
|
displaySourceHeight: i.sourceHeight
|
|
382
382
|
};
|
|
383
|
-
if (
|
|
384
|
-
await
|
|
383
|
+
if (I.current.useCase === "drivers-license") {
|
|
384
|
+
await R.current(o);
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
|
-
await
|
|
387
|
+
await le(I.current.onCapture, o);
|
|
388
388
|
} catch (e) {
|
|
389
389
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not take a photo.");
|
|
390
390
|
if (t.message === "No photo was selected.") {
|
|
391
|
-
if (
|
|
392
|
-
|
|
391
|
+
if (Ne.current) {
|
|
392
|
+
H("error");
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
|
-
|
|
395
|
+
I.current.onCancel();
|
|
396
396
|
return;
|
|
397
397
|
}
|
|
398
|
-
|
|
398
|
+
F.current = !0, q(t.message), H("error"), I.current.onError?.(t);
|
|
399
399
|
} finally {
|
|
400
|
-
|
|
400
|
+
me.current = !1;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
}, [
|
|
404
404
|
Q,
|
|
405
405
|
E,
|
|
406
406
|
D
|
|
407
|
-
]),
|
|
408
|
-
let t = await
|
|
407
|
+
]), We = g(async (e) => {
|
|
408
|
+
let t = await he.current;
|
|
409
409
|
if (t) {
|
|
410
|
-
|
|
410
|
+
Re(!0);
|
|
411
411
|
try {
|
|
412
412
|
let n = await t.submitStill(e.frame, e.detection);
|
|
413
413
|
if (n.kind === "need-back") {
|
|
414
|
-
if (
|
|
415
|
-
|
|
414
|
+
if (Ie.current = "back", z.current = !1, Fe("back"), F.current = !1, q(""), W(void 0), G(void 0), P.current.clear(), Z(), k) {
|
|
415
|
+
H("ready");
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
|
-
|
|
418
|
+
V?.paused && V.play(), H("starting"), De((e) => e + 1);
|
|
419
419
|
return;
|
|
420
420
|
}
|
|
421
421
|
if (n.kind === "retry") {
|
|
422
|
-
|
|
422
|
+
F.current = !0, q(n.message), H("error");
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
await
|
|
425
|
+
await le(I.current.onDriverLicense, n.result);
|
|
426
426
|
} catch (e) {
|
|
427
427
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Driver’s license scan failed.");
|
|
428
|
-
|
|
428
|
+
F.current = !0, q(t.message), H("error"), I.current.onError?.(t);
|
|
429
429
|
} finally {
|
|
430
|
-
|
|
430
|
+
Re(!1);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
}, [
|
|
434
434
|
Z,
|
|
435
|
-
|
|
435
|
+
V,
|
|
436
436
|
k
|
|
437
437
|
]);
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}, [
|
|
441
|
-
let
|
|
438
|
+
re(() => {
|
|
439
|
+
R.current = We;
|
|
440
|
+
}, [We]);
|
|
441
|
+
let Ge = g(async () => {
|
|
442
442
|
if (k) {
|
|
443
443
|
await $();
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
446
|
let e = A.current;
|
|
447
|
-
if (e &&
|
|
447
|
+
if (e && I.current.useCase === "drivers-license" && Ie.current === "back") {
|
|
448
448
|
try {
|
|
449
449
|
let t = await e.capturePhoto();
|
|
450
|
-
if (!(await d(t.frame))?.text ||
|
|
451
|
-
|
|
450
|
+
if (!(await d(t.frame))?.text || z.current) return;
|
|
451
|
+
z.current = !0, B.current?.abort(), M.current = t, K(t.method), Y(t.diagnostics), J(t.diagnostics), Q(t.frame, V), H("captured"), await R.current({
|
|
452
452
|
frame: t.frame,
|
|
453
453
|
reason: "manual",
|
|
454
454
|
method: t.method,
|
|
@@ -459,9 +459,9 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
459
459
|
});
|
|
460
460
|
} catch (e) {
|
|
461
461
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
|
|
462
|
-
|
|
462
|
+
F.current = !0, q(t.message);
|
|
463
463
|
let n = A.current?.getDiagnostics();
|
|
464
|
-
n &&
|
|
464
|
+
n && J(n), M.current?.diagnostics && Y(M.current.diagnostics), H("error"), I.current.onError?.(t);
|
|
465
465
|
}
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
@@ -469,64 +469,64 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
469
469
|
await j.current?.capture();
|
|
470
470
|
} catch (e) {
|
|
471
471
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
|
|
472
|
-
|
|
472
|
+
F.current = !0, q(t.message);
|
|
473
473
|
let n = A.current?.getDiagnostics();
|
|
474
|
-
n &&
|
|
474
|
+
n && J(n), M.current?.diagnostics && Y(M.current.diagnostics), H("error"), I.current.onError?.(t);
|
|
475
475
|
}
|
|
476
476
|
}, [
|
|
477
477
|
$,
|
|
478
478
|
Q,
|
|
479
|
-
|
|
479
|
+
V,
|
|
480
480
|
k
|
|
481
|
-
]),
|
|
482
|
-
|
|
483
|
-
let
|
|
484
|
-
|
|
485
|
-
if (!
|
|
486
|
-
|
|
481
|
+
]), Ke = v($);
|
|
482
|
+
Ke.current = $;
|
|
483
|
+
let qe = v(!1);
|
|
484
|
+
re(() => {
|
|
485
|
+
if (!n || !k) {
|
|
486
|
+
qe.current = !1;
|
|
487
487
|
return;
|
|
488
488
|
}
|
|
489
|
-
if (!
|
|
490
|
-
if (
|
|
491
|
-
|
|
489
|
+
if (!qe.current) {
|
|
490
|
+
if (qe.current = !0, F.current = !1, q(""), W(void 0), K(void 0), Y(void 0), X("idle"), G(void 0), P.current.clear(), Z(), !te()) {
|
|
491
|
+
H("ready");
|
|
492
492
|
return;
|
|
493
493
|
}
|
|
494
|
-
|
|
494
|
+
Ke.current();
|
|
495
495
|
}
|
|
496
496
|
}, [
|
|
497
|
-
|
|
497
|
+
n,
|
|
498
498
|
k,
|
|
499
499
|
Z
|
|
500
500
|
]);
|
|
501
|
-
let
|
|
502
|
-
if (
|
|
501
|
+
let Je = g(() => {
|
|
502
|
+
if (F.current = !1, z.current = !1, q(""), Y(void 0), X("idle"), W(void 0), G(void 0), P.current.clear(), k) {
|
|
503
503
|
$();
|
|
504
504
|
return;
|
|
505
505
|
}
|
|
506
506
|
if (Z(), p === "drivers-license") {
|
|
507
|
-
|
|
507
|
+
H("starting"), De((e) => e + 1);
|
|
508
508
|
return;
|
|
509
509
|
}
|
|
510
510
|
let e = A.current;
|
|
511
|
-
|
|
511
|
+
V?.paused && V.play(), H(e ? "ready" : "starting"), e || De((e) => e + 1);
|
|
512
512
|
}, [
|
|
513
513
|
$,
|
|
514
514
|
Z,
|
|
515
|
-
|
|
515
|
+
V,
|
|
516
516
|
p,
|
|
517
517
|
k
|
|
518
|
-
]),
|
|
518
|
+
]), Ye = g(async (e) => {
|
|
519
519
|
let t = A.current;
|
|
520
|
-
t && (await t.setTorch(e),
|
|
521
|
-
}, []),
|
|
520
|
+
t && (await t.setTorch(e), J(t.getDiagnostics()));
|
|
521
|
+
}, []), Xe = g((e) => {
|
|
522
522
|
j.current?.setAutoCapture(e);
|
|
523
|
-
}, []),
|
|
524
|
-
let e =
|
|
523
|
+
}, []), Ze = g(async () => {
|
|
524
|
+
let e = ge.current, t = A.current?.getDiagnostics() ?? e.diagnostics, n = e.finderStatus, i = r({
|
|
525
525
|
error: e.error || void 0,
|
|
526
526
|
captureMethod: e.captureMethod,
|
|
527
|
-
luminance:
|
|
528
|
-
fallbackReason:
|
|
529
|
-
shutter: e.shutterDiagnostics ??
|
|
527
|
+
luminance: M.current?.luminance,
|
|
528
|
+
fallbackReason: M.current?.fallbackReason,
|
|
529
|
+
shutter: e.shutterDiagnostics ?? M.current?.diagnostics,
|
|
530
530
|
live: t,
|
|
531
531
|
finder: n ? {
|
|
532
532
|
state: n.state,
|
|
@@ -544,62 +544,62 @@ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", ca
|
|
|
544
544
|
} : void 0
|
|
545
545
|
});
|
|
546
546
|
try {
|
|
547
|
-
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(
|
|
547
|
+
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(i);
|
|
548
548
|
else {
|
|
549
549
|
let e = document.createElement("textarea");
|
|
550
|
-
e.value =
|
|
550
|
+
e.value = i, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
|
|
551
551
|
let t = document.execCommand("copy");
|
|
552
552
|
if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
|
|
553
553
|
}
|
|
554
|
-
|
|
554
|
+
X("copied");
|
|
555
555
|
} catch {
|
|
556
|
-
|
|
556
|
+
X("failed");
|
|
557
557
|
}
|
|
558
|
-
}, []),
|
|
559
|
-
capture:
|
|
560
|
-
cancel:
|
|
561
|
-
retry:
|
|
562
|
-
setTorch:
|
|
563
|
-
setAutoCapture:
|
|
564
|
-
copyReport:
|
|
565
|
-
getState:
|
|
558
|
+
}, []), Qe = g(() => ge.current, []), $e = ie(() => ({
|
|
559
|
+
capture: Ge,
|
|
560
|
+
cancel: Ue,
|
|
561
|
+
retry: Je,
|
|
562
|
+
setTorch: Ye,
|
|
563
|
+
setAutoCapture: Xe,
|
|
564
|
+
copyReport: Ze,
|
|
565
|
+
getState: Qe
|
|
566
566
|
}), [
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
qe,
|
|
567
|
+
Ge,
|
|
568
|
+
Ue,
|
|
570
569
|
Je,
|
|
571
570
|
Ye,
|
|
572
571
|
Xe,
|
|
573
|
-
Ze
|
|
572
|
+
Ze,
|
|
573
|
+
Qe
|
|
574
574
|
]);
|
|
575
575
|
_(() => {
|
|
576
|
-
if (O) return O.current =
|
|
576
|
+
if (O) return O.current = $e, () => {
|
|
577
577
|
O.current = null;
|
|
578
578
|
};
|
|
579
|
-
}, [
|
|
580
|
-
let
|
|
581
|
-
...
|
|
582
|
-
|
|
583
|
-
bindPreview:
|
|
579
|
+
}, [$e, O]);
|
|
580
|
+
let et = {
|
|
581
|
+
...He,
|
|
582
|
+
...$e,
|
|
583
|
+
bindPreview: Ve
|
|
584
584
|
};
|
|
585
|
-
return /* @__PURE__ */
|
|
586
|
-
value:
|
|
587
|
-
children:
|
|
585
|
+
return /* @__PURE__ */ x(oe.Provider, {
|
|
586
|
+
value: et,
|
|
587
|
+
children: fe
|
|
588
588
|
});
|
|
589
589
|
}
|
|
590
590
|
//#endregion
|
|
591
591
|
//#region src/react/hooks.ts
|
|
592
592
|
function E() {
|
|
593
|
-
return
|
|
593
|
+
return v(null);
|
|
594
594
|
}
|
|
595
595
|
function D() {
|
|
596
|
-
let e =
|
|
596
|
+
let e = ne(oe);
|
|
597
597
|
if (!e) throw Error("useScanner must be used within ScannerProvider.");
|
|
598
598
|
return e;
|
|
599
599
|
}
|
|
600
600
|
//#endregion
|
|
601
601
|
//#region src/live-overlay-geometry.ts
|
|
602
|
-
function
|
|
602
|
+
function de(e, t, n, r, i) {
|
|
603
603
|
let a = Math.max(1, e), o = Math.max(1, t), s = Math.max(1, n), c = Math.max(1, r), l = s / a, u = c / o, d = i === "cover" ? Math.max(l, u) : Math.min(l, u), f = (s - a * d) / 2, p = (c - o * d) / 2;
|
|
604
604
|
if (i === "contain") return {
|
|
605
605
|
viewBox: `0 0 ${a} ${o}`,
|
|
@@ -608,9 +608,9 @@ function ue(e, t, n, r, i) {
|
|
|
608
608
|
offsetX: f,
|
|
609
609
|
offsetY: p
|
|
610
610
|
};
|
|
611
|
-
let
|
|
611
|
+
let ee = s / d, m = c / d;
|
|
612
612
|
return {
|
|
613
|
-
viewBox: `${-f / d} ${-p / d} ${
|
|
613
|
+
viewBox: `${-f / d} ${-p / d} ${ee} ${m}`,
|
|
614
614
|
preserveAspectRatio: "none",
|
|
615
615
|
scale: d,
|
|
616
616
|
offsetX: f,
|
|
@@ -622,7 +622,7 @@ function ue(e, t, n, r, i) {
|
|
|
622
622
|
function O({ snapshot: e }) {
|
|
623
623
|
if (!e.downloading) return null;
|
|
624
624
|
let t = e.total && e.total > 0 ? Math.min(1, e.loaded / e.total) : null, n = t === null ? null : Math.round(t * 100), r = 2 * Math.PI * 28;
|
|
625
|
-
return /* @__PURE__ */
|
|
625
|
+
return /* @__PURE__ */ S("div", {
|
|
626
626
|
className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
|
|
627
627
|
role: "progressbar",
|
|
628
628
|
"aria-label": "Model download",
|
|
@@ -631,15 +631,15 @@ function O({ snapshot: e }) {
|
|
|
631
631
|
"aria-valuenow": n ?? void 0,
|
|
632
632
|
"data-loaded": e.loaded,
|
|
633
633
|
"data-total": e.total ?? "",
|
|
634
|
-
children: [/* @__PURE__ */
|
|
634
|
+
children: [/* @__PURE__ */ S("svg", {
|
|
635
635
|
viewBox: "0 0 72 72",
|
|
636
636
|
"aria-hidden": "true",
|
|
637
|
-
children: [/* @__PURE__ */
|
|
637
|
+
children: [/* @__PURE__ */ x("circle", {
|
|
638
638
|
className: "track",
|
|
639
639
|
cx: "36",
|
|
640
640
|
cy: "36",
|
|
641
641
|
r: 28
|
|
642
|
-
}), /* @__PURE__ */
|
|
642
|
+
}), /* @__PURE__ */ x("circle", {
|
|
643
643
|
className: "value",
|
|
644
644
|
cx: "36",
|
|
645
645
|
cy: "36",
|
|
@@ -647,15 +647,15 @@ function O({ snapshot: e }) {
|
|
|
647
647
|
strokeDasharray: t === null ? void 0 : `${r} ${r}`,
|
|
648
648
|
strokeDashoffset: t === null ? void 0 : r * (1 - t)
|
|
649
649
|
})]
|
|
650
|
-
}), n === null ? /* @__PURE__ */
|
|
650
|
+
}), n === null ? /* @__PURE__ */ x("strong", {
|
|
651
651
|
className: "model-download-ring__pending",
|
|
652
652
|
children: "…"
|
|
653
|
-
}) : /* @__PURE__ */
|
|
653
|
+
}) : /* @__PURE__ */ S("strong", { children: [n, "%"] })]
|
|
654
654
|
});
|
|
655
655
|
}
|
|
656
656
|
//#endregion
|
|
657
657
|
//#region src/react/guidance.ts
|
|
658
|
-
function
|
|
658
|
+
function fe(e) {
|
|
659
659
|
if (!(e.usingSystemCamera || e.licenseBusy) && e.phase !== "error") return e.phase === "starting" ? e.licenseHeadline : e.phase === "capturing" ? "Capturing full resolution…" : e.phase === "captured" ? "Document captured" : e.holdStillSeconds && e.holdStillSeconds > 0 ? m(e.holdStillSeconds) : e.guidanceHint && e.guidanceReason && e.guidanceReason !== "place-document" ? e.guidanceHint : e.licenseHeadline ?? e.guidanceHint ?? "Place the document in the frame";
|
|
660
660
|
}
|
|
661
661
|
//#endregion
|
|
@@ -684,30 +684,30 @@ function j({ theme: e, style: t, title: n, children: r }) {
|
|
|
684
684
|
...t,
|
|
685
685
|
...o
|
|
686
686
|
} : t;
|
|
687
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ S("div", {
|
|
688
688
|
className: `scanner-camera-overlay ${i.phase === "captured" || i.finderStatus?.state === "captured" ? "is-captured" : ""} ${i.usingSystemCamera ? "is-system-camera" : ""}`.trim(),
|
|
689
689
|
style: s,
|
|
690
690
|
role: "dialog",
|
|
691
691
|
"aria-modal": "true",
|
|
692
692
|
"aria-label": a,
|
|
693
|
-
children: [r, /* @__PURE__ */
|
|
693
|
+
children: [r, /* @__PURE__ */ x(L, {})]
|
|
694
694
|
});
|
|
695
695
|
}
|
|
696
|
-
function
|
|
697
|
-
let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r =
|
|
696
|
+
function pe() {
|
|
697
|
+
let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r = v(null), i = g((t) => {
|
|
698
698
|
r.current = t, e(t);
|
|
699
699
|
}, [e]);
|
|
700
700
|
return _(() => {
|
|
701
701
|
t && r.current?.pause();
|
|
702
|
-
}, [t]), n ? t ? /* @__PURE__ */
|
|
702
|
+
}, [t]), n ? t ? /* @__PURE__ */ x("img", {
|
|
703
703
|
src: t,
|
|
704
704
|
className: "scanner-camera-overlay__video scanner-camera-overlay__still",
|
|
705
705
|
alt: "",
|
|
706
706
|
"aria-label": "Captured document"
|
|
707
|
-
}) : /* @__PURE__ */
|
|
707
|
+
}) : /* @__PURE__ */ x("div", {
|
|
708
708
|
className: "scanner-camera-overlay__video",
|
|
709
709
|
"aria-hidden": "true"
|
|
710
|
-
}) : /* @__PURE__ */
|
|
710
|
+
}) : /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("video", {
|
|
711
711
|
ref: i,
|
|
712
712
|
className: "scanner-camera-overlay__video",
|
|
713
713
|
muted: !0,
|
|
@@ -716,35 +716,35 @@ function M() {
|
|
|
716
716
|
style: { objectFit: "cover" },
|
|
717
717
|
"aria-hidden": !!t,
|
|
718
718
|
"aria-label": "Rear camera preview"
|
|
719
|
-
}), t ? /* @__PURE__ */
|
|
719
|
+
}), t ? /* @__PURE__ */ x("img", {
|
|
720
720
|
src: t,
|
|
721
721
|
className: "scanner-camera-overlay__video scanner-camera-overlay__still",
|
|
722
722
|
alt: "",
|
|
723
723
|
"aria-label": "Captured document"
|
|
724
724
|
}) : null] });
|
|
725
725
|
}
|
|
726
|
-
function
|
|
726
|
+
function M() {
|
|
727
727
|
let { finderStatus: e, displayQuad: t, previewSize: n } = D();
|
|
728
728
|
if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
|
|
729
|
-
let r =
|
|
730
|
-
return /* @__PURE__ */
|
|
729
|
+
let r = de(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
|
|
730
|
+
return /* @__PURE__ */ x("svg", {
|
|
731
731
|
className: `scanner-camera-overlay__quad ${e.state}`,
|
|
732
732
|
viewBox: r.viewBox,
|
|
733
733
|
preserveAspectRatio: r.preserveAspectRatio,
|
|
734
734
|
"aria-label": `${e.state} document boundary`,
|
|
735
|
-
children: /* @__PURE__ */
|
|
735
|
+
children: /* @__PURE__ */ x("polygon", { points: `${t.topLeft.x},${t.topLeft.y} ${t.topRight.x},${t.topRight.y} ${t.bottomRight.x},${t.bottomRight.y} ${t.bottomLeft.x},${t.bottomLeft.y}` })
|
|
736
736
|
});
|
|
737
737
|
}
|
|
738
|
-
function
|
|
738
|
+
function N({ title: e }) {
|
|
739
739
|
let { phase: t, cancel: n, usingSystemCamera: r, useCase: i, licenseSide: a, licenseBusy: o } = D(), s = i === "drivers-license" ? p(a ?? "front", r) : void 0, c = e ?? s?.title ?? "Scan a document";
|
|
740
|
-
return /* @__PURE__ */
|
|
740
|
+
return /* @__PURE__ */ S("div", {
|
|
741
741
|
className: "scanner-camera-overlay__topbar",
|
|
742
|
-
children: [/* @__PURE__ */
|
|
742
|
+
children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("strong", { children: c }), /* @__PURE__ */ S("span", {
|
|
743
743
|
"aria-live": "polite",
|
|
744
744
|
children: [
|
|
745
745
|
o && (a === "back" ? "Reading the barcode…" : "Reading the front…"),
|
|
746
746
|
!o && s && t === "error" && (a === "back" ? "Could not read the back" : "Could not read the front"),
|
|
747
|
-
!o && !s && r && /* @__PURE__ */
|
|
747
|
+
!o && !s && r && /* @__PURE__ */ S(b, { children: [
|
|
748
748
|
t === "starting" && "Preparing the system camera…",
|
|
749
749
|
t === "ready" && "Take a photo. There is no live document guide.",
|
|
750
750
|
t === "capturing" && "Looking for a document…",
|
|
@@ -753,7 +753,7 @@ function P({ title: e }) {
|
|
|
753
753
|
] }),
|
|
754
754
|
!o && !s && !r && t === "error" && "Camera unavailable"
|
|
755
755
|
]
|
|
756
|
-
})] }), /* @__PURE__ */
|
|
756
|
+
})] }), /* @__PURE__ */ x("button", {
|
|
757
757
|
type: "button",
|
|
758
758
|
onClick: n,
|
|
759
759
|
"aria-label": "Close camera",
|
|
@@ -761,84 +761,86 @@ function P({ title: e }) {
|
|
|
761
761
|
})]
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
function
|
|
764
|
+
function P() {
|
|
765
765
|
let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o, usingSystemCamera: s, frozenPreviewUrl: c, useCase: l, licenseSide: u, licenseBusy: d } = D(), f = l === "drivers-license" ? p(u ?? "front", s) : void 0;
|
|
766
|
-
return e === "error" ? /* @__PURE__ */
|
|
766
|
+
return e === "error" ? /* @__PURE__ */ S("div", {
|
|
767
767
|
className: "scanner-camera-overlay__message",
|
|
768
768
|
role: "alert",
|
|
769
769
|
children: [
|
|
770
|
-
/* @__PURE__ */
|
|
771
|
-
/* @__PURE__ */
|
|
772
|
-
/* @__PURE__ */
|
|
773
|
-
/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ x("strong", { children: f ? u === "back" ? "Could not read the back" : "Could not read the front" : s ? c ? "No document found" : "Could not take a photo" : n ? "Capture failed" : "Could not open the camera" }),
|
|
771
|
+
/* @__PURE__ */ x("p", { children: t }),
|
|
772
|
+
/* @__PURE__ */ S("div", { children: [
|
|
773
|
+
/* @__PURE__ */ x("button", {
|
|
774
774
|
type: "button",
|
|
775
775
|
onClick: i,
|
|
776
776
|
children: "Try again"
|
|
777
777
|
}),
|
|
778
|
-
/* @__PURE__ */
|
|
778
|
+
/* @__PURE__ */ x("button", {
|
|
779
779
|
type: "button",
|
|
780
780
|
onClick: () => void a(),
|
|
781
781
|
children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
|
|
782
782
|
}),
|
|
783
|
-
/* @__PURE__ */
|
|
783
|
+
/* @__PURE__ */ x("button", {
|
|
784
784
|
type: "button",
|
|
785
785
|
onClick: o,
|
|
786
786
|
children: "Cancel"
|
|
787
787
|
})
|
|
788
788
|
] })
|
|
789
789
|
]
|
|
790
|
-
}) : d ? /* @__PURE__ */
|
|
790
|
+
}) : d ? /* @__PURE__ */ S("div", {
|
|
791
791
|
className: "scanner-camera-overlay__message",
|
|
792
792
|
"aria-live": "polite",
|
|
793
793
|
children: [
|
|
794
|
-
/* @__PURE__ */
|
|
795
|
-
/* @__PURE__ */
|
|
796
|
-
/* @__PURE__ */
|
|
794
|
+
/* @__PURE__ */ x("span", { className: "scanner-camera-overlay__spinner" }),
|
|
795
|
+
/* @__PURE__ */ x("strong", { children: u === "back" ? "Reading the barcode" : "Reading the front" }),
|
|
796
|
+
/* @__PURE__ */ x("p", { children: u === "back" ? "Decoding the AAMVA PDF417 on the back." : "Finding the card and reading the front with OCR." })
|
|
797
797
|
]
|
|
798
|
-
}) : s && e === "capturing" && !c ? /* @__PURE__ */
|
|
798
|
+
}) : s && e === "capturing" && !c ? /* @__PURE__ */ S("div", {
|
|
799
799
|
className: "scanner-camera-overlay__message",
|
|
800
800
|
"aria-live": "polite",
|
|
801
801
|
children: [
|
|
802
|
-
/* @__PURE__ */
|
|
803
|
-
/* @__PURE__ */
|
|
804
|
-
/* @__PURE__ */
|
|
802
|
+
/* @__PURE__ */ x("span", { className: "scanner-camera-overlay__spinner" }),
|
|
803
|
+
/* @__PURE__ */ x("strong", { children: f ? f.headline : "Opening the system camera" }),
|
|
804
|
+
/* @__PURE__ */ x("p", { children: f ? f.detail : "There is no live document guide. We find the page after you take the photo." })
|
|
805
805
|
]
|
|
806
|
-
}) : s && e === "ready" && !c ? /* @__PURE__ */
|
|
806
|
+
}) : s && e === "ready" && !c ? /* @__PURE__ */ S("div", {
|
|
807
807
|
className: "scanner-camera-overlay__message",
|
|
808
808
|
"aria-live": "polite",
|
|
809
|
-
children: [/* @__PURE__ */
|
|
810
|
-
}) : e === "starting" && !s ? /* @__PURE__ */
|
|
809
|
+
children: [/* @__PURE__ */ x("strong", { children: f ? f.headline : "System camera" }), /* @__PURE__ */ x("p", { children: f ? f.detail : "Tap the shutter to open the Camera app. There is no live document guide." })]
|
|
810
|
+
}) : e === "starting" && !s ? /* @__PURE__ */ S("div", {
|
|
811
811
|
className: "scanner-camera-overlay__message",
|
|
812
812
|
"aria-live": "polite",
|
|
813
813
|
children: [
|
|
814
|
-
/* @__PURE__ */
|
|
815
|
-
/* @__PURE__ */
|
|
816
|
-
/* @__PURE__ */
|
|
814
|
+
/* @__PURE__ */ x("span", { className: "scanner-camera-overlay__spinner" }),
|
|
815
|
+
/* @__PURE__ */ x("strong", { children: "Requesting the highest practical resolution" }),
|
|
816
|
+
/* @__PURE__ */ x("p", { children: "Allow camera access to continue." })
|
|
817
817
|
]
|
|
818
818
|
}) : null;
|
|
819
819
|
}
|
|
820
|
-
function
|
|
820
|
+
function F() {
|
|
821
821
|
let { finderStatus: e, detectorStatus: t, settings: n, usingSystemCamera: r, captureMethod: i, phase: a, useCase: o, licenseSide: s } = D(), c = n?.width, l = n?.height, u = o === "drivers-license" ? ` · ${s === "back" ? "back" : "front"}` : "";
|
|
822
|
-
|
|
822
|
+
if (r) return /* @__PURE__ */ x("div", {
|
|
823
823
|
className: "scanner-camera-overlay__status",
|
|
824
824
|
"aria-live": "polite",
|
|
825
|
-
children: /* @__PURE__ */
|
|
825
|
+
children: /* @__PURE__ */ S("div", {
|
|
826
826
|
className: "scanner-camera-overlay__status-line",
|
|
827
827
|
children: [
|
|
828
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ x("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
|
|
829
829
|
i === "system-camera" ? "system camera" : "system camera · waiting",
|
|
830
830
|
u,
|
|
831
831
|
c && l ? ` · ${c}×${l}` : ""
|
|
832
832
|
]
|
|
833
833
|
})
|
|
834
|
-
})
|
|
834
|
+
});
|
|
835
|
+
let d = o === "drivers-license" && s === "back", f = d && !e ? "reading" : e?.state ?? "detecting";
|
|
836
|
+
return /* @__PURE__ */ x("div", {
|
|
835
837
|
className: "scanner-camera-overlay__status",
|
|
836
838
|
"aria-live": "polite",
|
|
837
|
-
children: /* @__PURE__ */
|
|
839
|
+
children: /* @__PURE__ */ S("div", {
|
|
838
840
|
className: "scanner-camera-overlay__status-line",
|
|
839
841
|
children: [
|
|
840
|
-
/* @__PURE__ */
|
|
841
|
-
|
|
842
|
+
/* @__PURE__ */ x("span", { className: d && !e ? "detecting" : e?.state ?? "detecting" }),
|
|
843
|
+
f,
|
|
842
844
|
u,
|
|
843
845
|
e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
|
|
844
846
|
` · ${t}`,
|
|
@@ -848,25 +850,25 @@ function I() {
|
|
|
848
850
|
})
|
|
849
851
|
});
|
|
850
852
|
}
|
|
851
|
-
function
|
|
852
|
-
let { diagnostics: e, shutterDiagnostics: t, captureMethod:
|
|
853
|
-
return /* @__PURE__ */
|
|
853
|
+
function me() {
|
|
854
|
+
let { diagnostics: e, shutterDiagnostics: t, captureMethod: r, copyState: i, copyReport: a } = D(), o = e?.engine ?? n();
|
|
855
|
+
return /* @__PURE__ */ S("dl", {
|
|
854
856
|
className: "scanner-camera-overlay__diagnostics",
|
|
855
857
|
"aria-label": "Camera diagnostics",
|
|
856
858
|
children: [
|
|
857
|
-
/* @__PURE__ */
|
|
859
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "engine" }), /* @__PURE__ */ S("dd", { children: [
|
|
858
860
|
o.engine,
|
|
859
861
|
"/",
|
|
860
862
|
o.browser,
|
|
861
863
|
o.iosWebKit ? " ios" : ""
|
|
862
864
|
] })] }),
|
|
863
|
-
/* @__PURE__ */
|
|
864
|
-
/* @__PURE__ */
|
|
865
|
-
/* @__PURE__ */
|
|
866
|
-
/* @__PURE__ */
|
|
867
|
-
/* @__PURE__ */
|
|
868
|
-
t ? /* @__PURE__ */
|
|
869
|
-
/* @__PURE__ */
|
|
865
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "video" }), /* @__PURE__ */ x("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
|
|
866
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "track" }), /* @__PURE__ */ x("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
|
|
867
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "torch" }), /* @__PURE__ */ x("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
|
|
868
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "luma" }), /* @__PURE__ */ x("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
|
|
869
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "path" }), /* @__PURE__ */ x("dd", { children: r ?? "video-frame / live-mirror" })] }),
|
|
870
|
+
t ? /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "shutter" }), /* @__PURE__ */ x("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
|
|
871
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("dt", { children: "share" }), /* @__PURE__ */ x("dd", { children: /* @__PURE__ */ x("button", {
|
|
870
872
|
type: "button",
|
|
871
873
|
className: "scanner-camera-overlay__copy",
|
|
872
874
|
onClick: () => void a(),
|
|
@@ -875,50 +877,50 @@ function fe() {
|
|
|
875
877
|
]
|
|
876
878
|
});
|
|
877
879
|
}
|
|
878
|
-
function
|
|
879
|
-
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u, licenseBusy: d, useCase: f, licenseSide:
|
|
880
|
+
function I() {
|
|
881
|
+
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u, licenseBusy: d, useCase: f, licenseSide: ee, guidanceHint: m } = D(), te = a?.width, h = a?.height, g = u ? t === "ready" : e !== "only", ne = f === "drivers-license" ? p(ee ?? "front", u) : void 0, _ = fe({
|
|
880
882
|
usingSystemCamera: u,
|
|
881
883
|
phase: t,
|
|
882
884
|
licenseBusy: d,
|
|
883
885
|
holdStillSeconds: n?.holdStillSeconds,
|
|
884
|
-
guidanceHint:
|
|
886
|
+
guidanceHint: m,
|
|
885
887
|
guidanceReason: n?.guidance.reason,
|
|
886
|
-
licenseHeadline:
|
|
887
|
-
}),
|
|
888
|
-
return /* @__PURE__ */
|
|
888
|
+
licenseHeadline: ne?.headline
|
|
889
|
+
}), re = !!n?.holdStillSeconds;
|
|
890
|
+
return /* @__PURE__ */ S("div", {
|
|
889
891
|
className: "scanner-camera-overlay__controls",
|
|
890
892
|
children: [
|
|
891
|
-
/* @__PURE__ */
|
|
893
|
+
/* @__PURE__ */ x("button", {
|
|
892
894
|
type: "button",
|
|
893
895
|
className: "scanner-camera-overlay__cancel",
|
|
894
896
|
onClick: o,
|
|
895
897
|
children: "Cancel"
|
|
896
898
|
}),
|
|
897
|
-
/* @__PURE__ */
|
|
899
|
+
/* @__PURE__ */ S("div", {
|
|
898
900
|
className: "scanner-camera-overlay__capture",
|
|
899
901
|
children: [
|
|
900
|
-
|
|
901
|
-
className: `scanner-camera-overlay__guidance${
|
|
902
|
+
_ && /* @__PURE__ */ x("p", {
|
|
903
|
+
className: `scanner-camera-overlay__guidance${re ? " is-ready" : ""}`,
|
|
902
904
|
"aria-live": "polite",
|
|
903
|
-
children:
|
|
905
|
+
children: _
|
|
904
906
|
}),
|
|
905
|
-
|
|
907
|
+
g && /* @__PURE__ */ x("button", {
|
|
906
908
|
type: "button",
|
|
907
909
|
className: "scanner-camera-overlay__shutter",
|
|
908
910
|
onClick: () => void s(),
|
|
909
911
|
disabled: t !== "ready" || !!d,
|
|
910
912
|
"aria-label": u ? "Take a photo with the system camera" : "Capture full-resolution photo",
|
|
911
|
-
children: /* @__PURE__ */
|
|
913
|
+
children: /* @__PURE__ */ x("span", {})
|
|
912
914
|
}),
|
|
913
|
-
!u && /* @__PURE__ */
|
|
915
|
+
!u && /* @__PURE__ */ S("div", {
|
|
914
916
|
className: "scanner-camera-overlay__toggles",
|
|
915
|
-
children: [n?.autoCapture.visible && /* @__PURE__ */
|
|
917
|
+
children: [n?.autoCapture.visible && /* @__PURE__ */ S("label", { children: [/* @__PURE__ */ x("input", {
|
|
916
918
|
type: "checkbox",
|
|
917
919
|
checked: n.autoCapture.checked,
|
|
918
920
|
onChange: (e) => c(e.target.checked)
|
|
919
|
-
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */
|
|
921
|
+
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ S("label", {
|
|
920
922
|
title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
|
|
921
|
-
children: [/* @__PURE__ */
|
|
923
|
+
children: [/* @__PURE__ */ x("input", {
|
|
922
924
|
type: "checkbox",
|
|
923
925
|
checked: r.torch.on,
|
|
924
926
|
disabled: !r.torch.mutable,
|
|
@@ -928,18 +930,18 @@ function L() {
|
|
|
928
930
|
})
|
|
929
931
|
]
|
|
930
932
|
}),
|
|
931
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ S("div", {
|
|
932
934
|
className: "scanner-camera-overlay__quality",
|
|
933
|
-
children: [/* @__PURE__ */
|
|
935
|
+
children: [/* @__PURE__ */ x("span", { children: u ? "System camera" : i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ x("strong", { children: te && h ? `${te} × ${h}` : u ? "Tap to photograph" : "Measuring…" })]
|
|
934
936
|
})
|
|
935
937
|
]
|
|
936
938
|
});
|
|
937
939
|
}
|
|
938
|
-
function
|
|
940
|
+
function L({ snapshot: e }) {
|
|
939
941
|
let { modelDownload: t } = D();
|
|
940
|
-
return /* @__PURE__ */
|
|
942
|
+
return /* @__PURE__ */ x(O, { snapshot: e ?? t });
|
|
941
943
|
}
|
|
942
944
|
//#endregion
|
|
943
|
-
export {
|
|
945
|
+
export { I as ScannerControls, me as ScannerDiagnostics, j as ScannerFrame, L as ScannerModelDownload, P as ScannerNotice, pe as ScannerPreview, ue as ScannerProvider, M as ScannerQuad, F as ScannerStatus, N as ScannerTopBar, D as useScanner, E as useScannerRef };
|
|
944
946
|
|
|
945
947
|
//# sourceMappingURL=react.js.map
|