@exige/web-scanner-sdk 0.2.9
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 +330 -0
- package/dist/assets/document-worker.js +2 -0
- package/dist/assets/document-worker.js.map +1 -0
- package/dist/assets/ort-wasm-simd-threaded.jsep.mjs +108 -0
- package/dist/assets/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/dist/assets/ort.min.js +2937 -0
- package/dist/assets/ort.min.js.map +1 -0
- package/dist/assets/tesseract/eng.traineddata.LICENSE +201 -0
- package/dist/assets/tesseract/eng.traineddata.NOTICE +9 -0
- package/dist/assets/tesseract/eng.traineddata.gz +0 -0
- package/dist/assets/tesseract/tesseract-core-lstm.wasm.js +191 -0
- package/dist/assets/tesseract/tesseract-core-relaxedsimd-lstm.wasm.js +191 -0
- package/dist/assets/tesseract/tesseract-core-simd-lstm.wasm.js +191 -0
- package/dist/assets/tesseract/tesseract.js-core.LICENSE +202 -0
- package/dist/assets/tesseract/tesseract.js.LICENSE +201 -0
- package/dist/assets/tesseract/worker.min.js +3 -0
- package/dist/assets/tesseract/worker.min.js.LICENSE.txt +12 -0
- package/dist/assets-manifest.json +11 -0
- package/dist/components/ModelDownloadRing.d.ts +4 -0
- package/dist/components/scanner-camera-overlay.css +2 -0
- package/dist/finder-DFueuWuS.js +1225 -0
- package/dist/finder-DFueuWuS.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/live-overlay-geometry.d.ts +11 -0
- package/dist/react/context.d.ts +2 -0
- package/dist/react/hooks.d.ts +3 -0
- package/dist/react/parts.d.ts +16 -0
- package/dist/react/scanner-context.d.ts +5 -0
- package/dist/react/types.d.ts +113 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.js +594 -0
- package/dist/react.js.map +1 -0
- package/dist/scanner-sdk.js +1001 -0
- package/dist/scanner-sdk.js.map +1 -0
- package/dist/sdk/camera.d.ts +150 -0
- package/dist/sdk/display-quad.d.ts +23 -0
- package/dist/sdk/errors.d.ts +14 -0
- package/dist/sdk/face-model.d.ts +22 -0
- package/dist/sdk/field-model.d.ts +29 -0
- package/dist/sdk/finder-simulator.d.ts +17 -0
- package/dist/sdk/finder.d.ts +174 -0
- package/dist/sdk/frame-geometry.d.ts +6 -0
- package/dist/sdk/image.d.ts +18 -0
- package/dist/sdk/license-codec.d.ts +2 -0
- package/dist/sdk/license-public-key.d.ts +9 -0
- package/dist/sdk/license-runtime.d.ts +2 -0
- package/dist/sdk/license.d.ts +84 -0
- package/dist/sdk/lighting.d.ts +22 -0
- package/dist/sdk/model-download.d.ts +25 -0
- package/dist/sdk/ocr-runtime.d.ts +27 -0
- package/dist/sdk/ocr.d.ts +104 -0
- package/dist/sdk/ort-runtime.d.ts +23 -0
- package/dist/sdk/programmatic-redaction.d.ts +151 -0
- package/dist/sdk/redact.d.ts +17 -0
- package/dist/sdk/scan.d.ts +61 -0
- package/dist/sdk/types.d.ts +80 -0
- package/package.json +93 -0
package/dist/react.js
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { m as e, o as t, p as n, s as r, v as i } from "./finder-DFueuWuS.js";
|
|
3
|
+
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
4
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
+
//#region src/sdk/display-quad.ts
|
|
6
|
+
function m(e) {
|
|
7
|
+
return [
|
|
8
|
+
e.topLeft,
|
|
9
|
+
e.topRight,
|
|
10
|
+
e.bottomRight,
|
|
11
|
+
e.bottomLeft
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
function h(e) {
|
|
15
|
+
let [t, n, r, i] = e;
|
|
16
|
+
return {
|
|
17
|
+
topLeft: t,
|
|
18
|
+
topRight: n,
|
|
19
|
+
bottomRight: r,
|
|
20
|
+
bottomLeft: i,
|
|
21
|
+
edges: {
|
|
22
|
+
top: {
|
|
23
|
+
start: t,
|
|
24
|
+
end: n
|
|
25
|
+
},
|
|
26
|
+
right: {
|
|
27
|
+
start: n,
|
|
28
|
+
end: r
|
|
29
|
+
},
|
|
30
|
+
bottom: {
|
|
31
|
+
start: r,
|
|
32
|
+
end: i
|
|
33
|
+
},
|
|
34
|
+
left: {
|
|
35
|
+
start: i,
|
|
36
|
+
end: t
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function g(e) {
|
|
42
|
+
return h(m(e).map((e) => ({ ...e })));
|
|
43
|
+
}
|
|
44
|
+
var ee = class {
|
|
45
|
+
current;
|
|
46
|
+
target;
|
|
47
|
+
response;
|
|
48
|
+
snapDistance;
|
|
49
|
+
constructor(e = {}) {
|
|
50
|
+
this.response = e.response ?? 14, this.snapDistance = e.snapDistance ?? .1;
|
|
51
|
+
}
|
|
52
|
+
setTarget(e, t, n) {
|
|
53
|
+
let r = Math.max(1, Math.hypot(t, n)), i = !this.current || m(e).some((e, t) => {
|
|
54
|
+
let n = m(this.current)[t];
|
|
55
|
+
return Math.hypot(e.x - n.x, e.y - n.y) / r > this.snapDistance;
|
|
56
|
+
});
|
|
57
|
+
return this.target = g(e), i && (this.current = g(e)), {
|
|
58
|
+
quad: this.current,
|
|
59
|
+
snapped: i
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
step(e) {
|
|
63
|
+
if (!this.current || !this.target) return this.current;
|
|
64
|
+
let t = 1 - Math.exp(-this.response * Math.max(0, e) / 1e3);
|
|
65
|
+
return this.current = h(m(this.current).map((e, n) => {
|
|
66
|
+
let r = m(this.target)[n];
|
|
67
|
+
return {
|
|
68
|
+
x: e.x + (r.x - e.x) * t,
|
|
69
|
+
y: e.y + (r.y - e.y) * t
|
|
70
|
+
};
|
|
71
|
+
})), this.current;
|
|
72
|
+
}
|
|
73
|
+
clear() {
|
|
74
|
+
this.current = void 0, this.target = void 0;
|
|
75
|
+
}
|
|
76
|
+
getCurrent() {
|
|
77
|
+
return this.current;
|
|
78
|
+
}
|
|
79
|
+
}, _ = a(null);
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/react/context.tsx
|
|
82
|
+
function v({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onCapture: p, onCancel: m, onError: h, onSettings: g, onFinderStatus: v, modelUrl: y, ortWasmPaths: b, detectionIntervalMs: x, apiRef: S, children: C }) {
|
|
83
|
+
let w = u(void 0), T = u(void 0), E = u(void 0), D = u(void 0), O = u({}), k = u(new ee()), A = u(!1), j = u({
|
|
84
|
+
onCapture: p,
|
|
85
|
+
onCancel: m,
|
|
86
|
+
onError: h,
|
|
87
|
+
onSettings: g,
|
|
88
|
+
onFinderStatus: v
|
|
89
|
+
}), M = u(null), [N, te] = d(null), [ne, P] = d("starting"), [F, I] = d(), [re, L] = d(), [R, ie] = d({
|
|
90
|
+
width: 1,
|
|
91
|
+
height: 1
|
|
92
|
+
}), [ae, oe] = d(), [se, z] = d(), [ce, B] = d(""), [V, le] = d(0), [ue, H] = d(), [de, U] = d(), [fe, W] = d("idle");
|
|
93
|
+
c(() => {
|
|
94
|
+
j.current = {
|
|
95
|
+
onCapture: p,
|
|
96
|
+
onCancel: m,
|
|
97
|
+
onError: h,
|
|
98
|
+
onSettings: g,
|
|
99
|
+
onFinderStatus: v
|
|
100
|
+
};
|
|
101
|
+
}, [
|
|
102
|
+
p,
|
|
103
|
+
m,
|
|
104
|
+
h,
|
|
105
|
+
g,
|
|
106
|
+
v
|
|
107
|
+
]);
|
|
108
|
+
let pe = o((e) => {
|
|
109
|
+
te(e);
|
|
110
|
+
}, []);
|
|
111
|
+
c(() => {
|
|
112
|
+
if (!n || !N) return;
|
|
113
|
+
let e = () => {
|
|
114
|
+
let e = N.getBoundingClientRect();
|
|
115
|
+
ie({
|
|
116
|
+
width: e.width,
|
|
117
|
+
height: e.height
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
121
|
+
let t = new ResizeObserver(e);
|
|
122
|
+
return t.observe(N), () => t.disconnect();
|
|
123
|
+
}, [n, N]), c(() => {
|
|
124
|
+
if (!n) return;
|
|
125
|
+
let e = window.setInterval(() => {
|
|
126
|
+
let e = w.current?.getDiagnostics();
|
|
127
|
+
e && H(e);
|
|
128
|
+
}, 500);
|
|
129
|
+
return () => window.clearInterval(e);
|
|
130
|
+
}, [n, V]), c(() => {
|
|
131
|
+
if (!n) return;
|
|
132
|
+
let e = 0, t = performance.now(), r = (n) => {
|
|
133
|
+
let i = k.current.step(n - t);
|
|
134
|
+
t = n, i && L(i), e = requestAnimationFrame(r);
|
|
135
|
+
};
|
|
136
|
+
return e = requestAnimationFrame(r), () => cancelAnimationFrame(e);
|
|
137
|
+
}, [n]), c(() => {
|
|
138
|
+
if (!n || !N) return;
|
|
139
|
+
let e = !1, t = () => {
|
|
140
|
+
T.current?.stop(), T.current = void 0, w.current?.stop(), w.current = void 0, D.current = void 0, E.current = void 0, O.current = {};
|
|
141
|
+
};
|
|
142
|
+
return (async () => {
|
|
143
|
+
t(), A.current = !1, P("starting"), B(""), I(void 0), z(void 0), U(void 0), W("idle");
|
|
144
|
+
try {
|
|
145
|
+
let t = await i(N, { torch: s });
|
|
146
|
+
if (e) {
|
|
147
|
+
t.stop();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
w.current = t;
|
|
151
|
+
let n = t.getSettings();
|
|
152
|
+
oe(n), j.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), T.current = await r({
|
|
153
|
+
source: N,
|
|
154
|
+
autoCapture: a,
|
|
155
|
+
intervalMs: x,
|
|
156
|
+
detection: {
|
|
157
|
+
modelUrl: y,
|
|
158
|
+
ortWasmPaths: b
|
|
159
|
+
},
|
|
160
|
+
onStatus: (e) => {
|
|
161
|
+
if (E.current = e, I(e), j.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
|
|
162
|
+
let t = k.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
|
|
163
|
+
L(t.quad);
|
|
164
|
+
} else k.current.clear(), L(void 0);
|
|
165
|
+
e.state !== "captured" && !A.current && P("ready");
|
|
166
|
+
},
|
|
167
|
+
captureFrame: async () => {
|
|
168
|
+
P("capturing"), O.current = {
|
|
169
|
+
quad: k.current.getCurrent(),
|
|
170
|
+
sourceWidth: E.current?.sourceWidth,
|
|
171
|
+
sourceHeight: E.current?.sourceHeight
|
|
172
|
+
};
|
|
173
|
+
let e = await t.capturePhoto();
|
|
174
|
+
if (D.current = e, z(e.method), U(e.diagnostics), H(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.`);
|
|
175
|
+
return e.frame;
|
|
176
|
+
},
|
|
177
|
+
onCaptureError: (e) => {
|
|
178
|
+
A.current = !0, P("error"), B(e.message);
|
|
179
|
+
let t = w.current?.getDiagnostics();
|
|
180
|
+
t && H(t), j.current.onError?.(e);
|
|
181
|
+
},
|
|
182
|
+
onCapture: async (e) => {
|
|
183
|
+
let n = D.current;
|
|
184
|
+
await new Promise((e) => window.setTimeout(e, 140)), await j.current.onCapture({
|
|
185
|
+
...e,
|
|
186
|
+
method: n?.method ?? "video-frame",
|
|
187
|
+
settings: n?.settings ?? t.getSettings(),
|
|
188
|
+
fallbackReason: n?.fallbackReason,
|
|
189
|
+
luminance: n?.luminance,
|
|
190
|
+
diagnostics: n?.diagnostics,
|
|
191
|
+
displayedQuad: O.current.quad,
|
|
192
|
+
displaySourceWidth: O.current.sourceWidth,
|
|
193
|
+
displaySourceHeight: O.current.sourceHeight
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
} catch (n) {
|
|
198
|
+
if (e) return;
|
|
199
|
+
t();
|
|
200
|
+
let r = n instanceof Error ? n : /* @__PURE__ */ Error("Camera access failed.");
|
|
201
|
+
B(r.message), P("error"), j.current.onError?.(r);
|
|
202
|
+
}
|
|
203
|
+
})(), () => {
|
|
204
|
+
e = !0, t();
|
|
205
|
+
};
|
|
206
|
+
}, [
|
|
207
|
+
n,
|
|
208
|
+
N,
|
|
209
|
+
a,
|
|
210
|
+
s,
|
|
211
|
+
y,
|
|
212
|
+
b,
|
|
213
|
+
x,
|
|
214
|
+
V
|
|
215
|
+
]);
|
|
216
|
+
let G = {
|
|
217
|
+
open: n,
|
|
218
|
+
phase: ne,
|
|
219
|
+
autoCapture: a,
|
|
220
|
+
finderStatus: F,
|
|
221
|
+
displayQuad: re,
|
|
222
|
+
previewSize: R,
|
|
223
|
+
settings: ae,
|
|
224
|
+
captureMethod: se,
|
|
225
|
+
error: ce,
|
|
226
|
+
diagnostics: ue,
|
|
227
|
+
shutterDiagnostics: de,
|
|
228
|
+
copyState: fe,
|
|
229
|
+
guidanceHint: F ? t(F.guidance, F.lighting) : void 0,
|
|
230
|
+
detectorStatus: F?.modelStatus === "failed" ? "ML failed" : F?.detector === "ml" ? `ML ${F.modelProvider ?? ""}`.trim() : "ML loading"
|
|
231
|
+
};
|
|
232
|
+
c(() => {
|
|
233
|
+
M.current = G;
|
|
234
|
+
});
|
|
235
|
+
let K = o(() => {
|
|
236
|
+
j.current.onCancel();
|
|
237
|
+
}, []), q = o(async () => {
|
|
238
|
+
try {
|
|
239
|
+
await T.current?.capture();
|
|
240
|
+
} catch (e) {
|
|
241
|
+
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
|
|
242
|
+
A.current = !0, B(t.message);
|
|
243
|
+
let n = w.current?.getDiagnostics();
|
|
244
|
+
n && H(n), D.current?.diagnostics && U(D.current.diagnostics), P("error"), j.current.onError?.(t);
|
|
245
|
+
}
|
|
246
|
+
}, []), J = o(() => {
|
|
247
|
+
A.current = !1, B(""), U(void 0), W("idle");
|
|
248
|
+
let e = w.current;
|
|
249
|
+
P(e ? "ready" : "starting"), e || le((e) => e + 1);
|
|
250
|
+
}, []), Y = o(async (e) => {
|
|
251
|
+
let t = w.current;
|
|
252
|
+
t && (await t.setTorch(e), H(t.getDiagnostics()));
|
|
253
|
+
}, []), X = o((e) => {
|
|
254
|
+
T.current?.setAutoCapture(e);
|
|
255
|
+
}, []), Z = o(async () => {
|
|
256
|
+
let t = M.current, n = w.current?.getDiagnostics() ?? t.diagnostics, r = t.finderStatus, i = e({
|
|
257
|
+
error: t.error || void 0,
|
|
258
|
+
captureMethod: t.captureMethod,
|
|
259
|
+
luminance: D.current?.luminance,
|
|
260
|
+
fallbackReason: D.current?.fallbackReason,
|
|
261
|
+
shutter: t.shutterDiagnostics ?? D.current?.diagnostics,
|
|
262
|
+
live: n,
|
|
263
|
+
finder: r ? {
|
|
264
|
+
state: r.state,
|
|
265
|
+
confidence: r.confidence,
|
|
266
|
+
stableFrames: r.stableFrames,
|
|
267
|
+
requiredStableFrames: r.requiredStableFrames,
|
|
268
|
+
detector: r.detector,
|
|
269
|
+
modelStatus: r.modelStatus,
|
|
270
|
+
sourceWidth: r.sourceWidth,
|
|
271
|
+
sourceHeight: r.sourceHeight
|
|
272
|
+
} : void 0
|
|
273
|
+
});
|
|
274
|
+
try {
|
|
275
|
+
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(i);
|
|
276
|
+
else {
|
|
277
|
+
let e = document.createElement("textarea");
|
|
278
|
+
e.value = i, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
|
|
279
|
+
let t = document.execCommand("copy");
|
|
280
|
+
if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
|
|
281
|
+
}
|
|
282
|
+
W("copied");
|
|
283
|
+
} catch {
|
|
284
|
+
W("failed");
|
|
285
|
+
}
|
|
286
|
+
}, []), Q = o(() => M.current, []), $ = l(() => ({
|
|
287
|
+
capture: q,
|
|
288
|
+
cancel: K,
|
|
289
|
+
retry: J,
|
|
290
|
+
setTorch: Y,
|
|
291
|
+
setAutoCapture: X,
|
|
292
|
+
copyReport: Z,
|
|
293
|
+
getState: Q
|
|
294
|
+
}), [
|
|
295
|
+
q,
|
|
296
|
+
K,
|
|
297
|
+
J,
|
|
298
|
+
Y,
|
|
299
|
+
X,
|
|
300
|
+
Z,
|
|
301
|
+
Q
|
|
302
|
+
]);
|
|
303
|
+
c(() => {
|
|
304
|
+
if (S) return S.current = $, () => {
|
|
305
|
+
S.current = null;
|
|
306
|
+
};
|
|
307
|
+
}, [$, S]);
|
|
308
|
+
let me = {
|
|
309
|
+
...G,
|
|
310
|
+
...$,
|
|
311
|
+
bindPreview: pe
|
|
312
|
+
};
|
|
313
|
+
return /* @__PURE__ */ f(_.Provider, {
|
|
314
|
+
value: me,
|
|
315
|
+
children: C
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/react/hooks.ts
|
|
320
|
+
function y() {
|
|
321
|
+
return u(null);
|
|
322
|
+
}
|
|
323
|
+
function b() {
|
|
324
|
+
let e = s(_);
|
|
325
|
+
if (!e) throw Error("useScanner must be used within ScannerProvider.");
|
|
326
|
+
return e;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/live-overlay-geometry.ts
|
|
330
|
+
function x(e, t, n, r, i) {
|
|
331
|
+
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;
|
|
332
|
+
if (i === "contain") return {
|
|
333
|
+
viewBox: `0 0 ${a} ${o}`,
|
|
334
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
335
|
+
scale: d,
|
|
336
|
+
offsetX: f,
|
|
337
|
+
offsetY: p
|
|
338
|
+
};
|
|
339
|
+
let m = s / d, h = c / d;
|
|
340
|
+
return {
|
|
341
|
+
viewBox: `${-f / d} ${-p / d} ${m} ${h}`,
|
|
342
|
+
preserveAspectRatio: "none",
|
|
343
|
+
scale: d,
|
|
344
|
+
offsetX: f,
|
|
345
|
+
offsetY: p
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/components/ModelDownloadRing.tsx
|
|
350
|
+
function S({ snapshot: e }) {
|
|
351
|
+
if (!e.downloading) return null;
|
|
352
|
+
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;
|
|
353
|
+
return /* @__PURE__ */ p("div", {
|
|
354
|
+
className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
|
|
355
|
+
role: "progressbar",
|
|
356
|
+
"aria-label": "Model download",
|
|
357
|
+
"aria-valuemin": 0,
|
|
358
|
+
"aria-valuemax": 100,
|
|
359
|
+
"aria-valuenow": n ?? void 0,
|
|
360
|
+
"data-loaded": e.loaded,
|
|
361
|
+
"data-total": e.total ?? "",
|
|
362
|
+
children: [/* @__PURE__ */ p("svg", {
|
|
363
|
+
viewBox: "0 0 72 72",
|
|
364
|
+
"aria-hidden": "true",
|
|
365
|
+
children: [/* @__PURE__ */ f("circle", {
|
|
366
|
+
className: "track",
|
|
367
|
+
cx: "36",
|
|
368
|
+
cy: "36",
|
|
369
|
+
r: 28
|
|
370
|
+
}), /* @__PURE__ */ f("circle", {
|
|
371
|
+
className: "value",
|
|
372
|
+
cx: "36",
|
|
373
|
+
cy: "36",
|
|
374
|
+
r: 28,
|
|
375
|
+
strokeDasharray: t === null ? void 0 : `${r} ${r}`,
|
|
376
|
+
strokeDashoffset: t === null ? void 0 : r * (1 - t)
|
|
377
|
+
})]
|
|
378
|
+
}), n === null ? /* @__PURE__ */ f("strong", {
|
|
379
|
+
className: "model-download-ring__pending",
|
|
380
|
+
children: "…"
|
|
381
|
+
}) : /* @__PURE__ */ p("strong", { children: [n, "%"] })]
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/react/parts.tsx
|
|
386
|
+
var C = {
|
|
387
|
+
primaryColorHex: "--scanner-overlay-primary",
|
|
388
|
+
seekingColorHex: "--scanner-overlay-seeking",
|
|
389
|
+
detectingColorHex: "--scanner-overlay-detecting",
|
|
390
|
+
unstableColorHex: "--scanner-overlay-unstable",
|
|
391
|
+
readyColorHex: "--scanner-overlay-ready",
|
|
392
|
+
capturedColorHex: "--scanner-overlay-captured"
|
|
393
|
+
};
|
|
394
|
+
function w(e) {
|
|
395
|
+
if (!e) return;
|
|
396
|
+
let t = {};
|
|
397
|
+
for (let [n, r] of Object.entries(C)) {
|
|
398
|
+
let i = e[n]?.trim();
|
|
399
|
+
i && (t[r] = i);
|
|
400
|
+
}
|
|
401
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
402
|
+
}
|
|
403
|
+
function T({ theme: e, style: t, title: n = "Scan a document", children: r }) {
|
|
404
|
+
let i = b();
|
|
405
|
+
if (!i.open) return null;
|
|
406
|
+
let a = w(e), o = a ? {
|
|
407
|
+
...t,
|
|
408
|
+
...a
|
|
409
|
+
} : t;
|
|
410
|
+
return /* @__PURE__ */ f("div", {
|
|
411
|
+
className: `scanner-camera-overlay ${i.finderStatus?.state === "captured" ? "is-captured" : ""}`.trim(),
|
|
412
|
+
style: o,
|
|
413
|
+
role: "dialog",
|
|
414
|
+
"aria-modal": "true",
|
|
415
|
+
"aria-label": n,
|
|
416
|
+
children: r
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function E() {
|
|
420
|
+
let { bindPreview: e } = b();
|
|
421
|
+
return /* @__PURE__ */ f("video", {
|
|
422
|
+
ref: e,
|
|
423
|
+
className: "scanner-camera-overlay__video",
|
|
424
|
+
muted: !0,
|
|
425
|
+
autoPlay: !0,
|
|
426
|
+
playsInline: !0,
|
|
427
|
+
style: { objectFit: "cover" },
|
|
428
|
+
"aria-label": "Rear camera preview"
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function D() {
|
|
432
|
+
let { finderStatus: e, displayQuad: t, previewSize: n } = b();
|
|
433
|
+
if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
|
|
434
|
+
let r = x(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
|
|
435
|
+
return /* @__PURE__ */ f("svg", {
|
|
436
|
+
className: `scanner-camera-overlay__quad ${e.state}`,
|
|
437
|
+
viewBox: r.viewBox,
|
|
438
|
+
preserveAspectRatio: r.preserveAspectRatio,
|
|
439
|
+
"aria-label": `${e.state} document boundary`,
|
|
440
|
+
children: /* @__PURE__ */ f("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}` })
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function O({ title: e = "Scan a document" }) {
|
|
444
|
+
let { phase: t, guidanceHint: n, cancel: r } = b();
|
|
445
|
+
return /* @__PURE__ */ p("div", {
|
|
446
|
+
className: "scanner-camera-overlay__topbar",
|
|
447
|
+
children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("strong", { children: e }), /* @__PURE__ */ p("span", {
|
|
448
|
+
"aria-live": "polite",
|
|
449
|
+
children: [
|
|
450
|
+
t === "starting" && "Starting rear camera…",
|
|
451
|
+
t === "ready" && (n ?? "Place the document in the frame"),
|
|
452
|
+
t === "capturing" && "Capturing full resolution…",
|
|
453
|
+
t === "error" && "Camera unavailable"
|
|
454
|
+
]
|
|
455
|
+
})] }), /* @__PURE__ */ f("button", {
|
|
456
|
+
type: "button",
|
|
457
|
+
onClick: r,
|
|
458
|
+
"aria-label": "Close camera",
|
|
459
|
+
children: "×"
|
|
460
|
+
})]
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
function k() {
|
|
464
|
+
let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o } = b();
|
|
465
|
+
return e === "error" ? /* @__PURE__ */ p("div", {
|
|
466
|
+
className: "scanner-camera-overlay__message",
|
|
467
|
+
role: "alert",
|
|
468
|
+
children: [
|
|
469
|
+
/* @__PURE__ */ f("strong", { children: n ? "Capture failed" : "Could not open the camera" }),
|
|
470
|
+
/* @__PURE__ */ f("p", { children: t }),
|
|
471
|
+
/* @__PURE__ */ p("div", { children: [
|
|
472
|
+
/* @__PURE__ */ f("button", {
|
|
473
|
+
type: "button",
|
|
474
|
+
onClick: i,
|
|
475
|
+
children: "Try again"
|
|
476
|
+
}),
|
|
477
|
+
/* @__PURE__ */ f("button", {
|
|
478
|
+
type: "button",
|
|
479
|
+
onClick: () => void a(),
|
|
480
|
+
children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
|
|
481
|
+
}),
|
|
482
|
+
/* @__PURE__ */ f("button", {
|
|
483
|
+
type: "button",
|
|
484
|
+
onClick: o,
|
|
485
|
+
children: "Cancel"
|
|
486
|
+
})
|
|
487
|
+
] })
|
|
488
|
+
]
|
|
489
|
+
}) : e === "starting" ? /* @__PURE__ */ p("div", {
|
|
490
|
+
className: "scanner-camera-overlay__message",
|
|
491
|
+
"aria-live": "polite",
|
|
492
|
+
children: [
|
|
493
|
+
/* @__PURE__ */ f("span", { className: "scanner-camera-overlay__spinner" }),
|
|
494
|
+
/* @__PURE__ */ f("strong", { children: "Requesting the highest practical resolution" }),
|
|
495
|
+
/* @__PURE__ */ f("p", { children: "Allow camera access to continue." })
|
|
496
|
+
]
|
|
497
|
+
}) : null;
|
|
498
|
+
}
|
|
499
|
+
function A() {
|
|
500
|
+
let { finderStatus: e, detectorStatus: t, settings: n } = b(), r = n?.width, i = n?.height;
|
|
501
|
+
return /* @__PURE__ */ f("div", {
|
|
502
|
+
className: "scanner-camera-overlay__status",
|
|
503
|
+
"aria-live": "polite",
|
|
504
|
+
children: /* @__PURE__ */ p("div", {
|
|
505
|
+
className: "scanner-camera-overlay__status-line",
|
|
506
|
+
children: [
|
|
507
|
+
/* @__PURE__ */ f("span", { className: e?.state ?? "detecting" }),
|
|
508
|
+
e?.state ?? "detecting",
|
|
509
|
+
e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
|
|
510
|
+
` · ${t}`,
|
|
511
|
+
e?.inferenceMs === void 0 ? "" : ` · ${Math.round(e.inferenceMs)}ms`,
|
|
512
|
+
r && i ? ` · ${r}×${i}` : ""
|
|
513
|
+
]
|
|
514
|
+
})
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function j() {
|
|
518
|
+
let { diagnostics: e, shutterDiagnostics: t, captureMethod: r, copyState: i, copyReport: a } = b(), o = e?.engine ?? n();
|
|
519
|
+
return /* @__PURE__ */ p("dl", {
|
|
520
|
+
className: "scanner-camera-overlay__diagnostics",
|
|
521
|
+
"aria-label": "Camera diagnostics",
|
|
522
|
+
children: [
|
|
523
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "engine" }), /* @__PURE__ */ p("dd", { children: [
|
|
524
|
+
o.engine,
|
|
525
|
+
"/",
|
|
526
|
+
o.browser,
|
|
527
|
+
o.iosWebKit ? " ios" : ""
|
|
528
|
+
] })] }),
|
|
529
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "video" }), /* @__PURE__ */ f("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
|
|
530
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "track" }), /* @__PURE__ */ f("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
|
|
531
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "torch" }), /* @__PURE__ */ f("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
|
|
532
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "luma" }), /* @__PURE__ */ f("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
|
|
533
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "path" }), /* @__PURE__ */ f("dd", { children: r ?? "video-frame / live-mirror" })] }),
|
|
534
|
+
t ? /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "shutter" }), /* @__PURE__ */ f("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
|
|
535
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", { children: "share" }), /* @__PURE__ */ f("dd", { children: /* @__PURE__ */ f("button", {
|
|
536
|
+
type: "button",
|
|
537
|
+
className: "scanner-camera-overlay__copy",
|
|
538
|
+
onClick: () => void a(),
|
|
539
|
+
children: i === "copied" ? "Copied report" : i === "failed" ? "Copy failed" : "Copy report"
|
|
540
|
+
}) })] })
|
|
541
|
+
]
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function M() {
|
|
545
|
+
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l } = b(), u = a?.width, d = a?.height;
|
|
546
|
+
return /* @__PURE__ */ p("div", {
|
|
547
|
+
className: "scanner-camera-overlay__controls",
|
|
548
|
+
children: [
|
|
549
|
+
/* @__PURE__ */ f("button", {
|
|
550
|
+
type: "button",
|
|
551
|
+
className: "scanner-camera-overlay__cancel",
|
|
552
|
+
onClick: o,
|
|
553
|
+
children: "Cancel"
|
|
554
|
+
}),
|
|
555
|
+
/* @__PURE__ */ p("div", {
|
|
556
|
+
className: "scanner-camera-overlay__capture",
|
|
557
|
+
children: [e !== "only" && /* @__PURE__ */ f("button", {
|
|
558
|
+
type: "button",
|
|
559
|
+
className: "scanner-camera-overlay__shutter",
|
|
560
|
+
onClick: () => void s(),
|
|
561
|
+
disabled: t !== "ready",
|
|
562
|
+
"aria-label": "Capture full-resolution photo",
|
|
563
|
+
children: /* @__PURE__ */ f("span", {})
|
|
564
|
+
}), /* @__PURE__ */ p("div", {
|
|
565
|
+
className: "scanner-camera-overlay__toggles",
|
|
566
|
+
children: [n?.autoCapture.visible && /* @__PURE__ */ p("label", { children: [/* @__PURE__ */ f("input", {
|
|
567
|
+
type: "checkbox",
|
|
568
|
+
checked: n.autoCapture.checked,
|
|
569
|
+
onChange: (e) => c(e.target.checked)
|
|
570
|
+
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ p("label", {
|
|
571
|
+
title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
|
|
572
|
+
children: [/* @__PURE__ */ f("input", {
|
|
573
|
+
type: "checkbox",
|
|
574
|
+
checked: r.torch.on,
|
|
575
|
+
disabled: !r.torch.mutable,
|
|
576
|
+
onChange: (e) => void l(e.target.checked)
|
|
577
|
+
}), r.torch.automatic ? "Auto torch" : "Torch"]
|
|
578
|
+
})]
|
|
579
|
+
})]
|
|
580
|
+
}),
|
|
581
|
+
/* @__PURE__ */ p("div", {
|
|
582
|
+
className: "scanner-camera-overlay__quality",
|
|
583
|
+
children: [/* @__PURE__ */ f("span", { children: i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ f("strong", { children: u && d ? `${u} × ${d}` : "Measuring…" })]
|
|
584
|
+
})
|
|
585
|
+
]
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function N({ snapshot: e }) {
|
|
589
|
+
return b(), e ? /* @__PURE__ */ f(S, { snapshot: e }) : null;
|
|
590
|
+
}
|
|
591
|
+
//#endregion
|
|
592
|
+
export { M as ScannerControls, j as ScannerDiagnostics, T as ScannerFrame, N as ScannerModelDownload, k as ScannerNotice, E as ScannerPreview, v as ScannerProvider, D as ScannerQuad, A as ScannerStatus, O as ScannerTopBar, b as useScanner, y as useScannerRef };
|
|
593
|
+
|
|
594
|
+
//# sourceMappingURL=react.js.map
|