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