@exige/web-scanner-sdk 0.2.24 → 0.2.26
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 +2 -2
- package/dist/{finder-B3kHQ2Jh.js → finder-Dcg3mVJM.js} +268 -198
- package/dist/finder-Dcg3mVJM.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/react/context.d.ts +1 -1
- package/dist/react/types.d.ts +13 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +381 -274
- package/dist/react.js.map +1 -1
- package/dist/scanner-sdk.js +239 -239
- package/dist/scanner-sdk.js.map +1 -1
- package/dist/sdk/camera.d.ts +44 -2
- package/dist/sdk/ocr.d.ts +1 -1
- package/dist/sdk/scan.d.ts +12 -0
- package/package.json +1 -1
- package/dist/finder-B3kHQ2Jh.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { Fragment as
|
|
2
|
+
import { A as e, C as t, I as n, S as r, g as i, h as a, o, s, x as c, y as l } from "./finder-Dcg3mVJM.js";
|
|
3
|
+
import { createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as ee, useRef as m, useState as h } from "react";
|
|
4
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
5
5
|
//#region src/sdk/display-quad.ts
|
|
6
|
-
function
|
|
6
|
+
function y(e) {
|
|
7
7
|
return [
|
|
8
8
|
e.topLeft,
|
|
9
9
|
e.topRight,
|
|
@@ -11,7 +11,7 @@ function g(e) {
|
|
|
11
11
|
e.bottomLeft
|
|
12
12
|
];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function b(e) {
|
|
15
15
|
let [t, n, r, i] = e;
|
|
16
16
|
return {
|
|
17
17
|
topLeft: t,
|
|
@@ -38,10 +38,10 @@ function _(e) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
41
|
+
function x(e) {
|
|
42
|
+
return b(y(e).map((e) => ({ ...e })));
|
|
43
43
|
}
|
|
44
|
-
var
|
|
44
|
+
var te = class {
|
|
45
45
|
current;
|
|
46
46
|
target;
|
|
47
47
|
response;
|
|
@@ -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 || y(e).some((e, t) => {
|
|
54
|
+
let n = y(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 = x(e), i && (this.current = x(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 =
|
|
66
|
-
let r =
|
|
65
|
+
return this.current = b(y(this.current).map((e, n) => {
|
|
66
|
+
let r = y(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 ee = class {
|
|
|
76
76
|
getCurrent() {
|
|
77
77
|
return this.current;
|
|
78
78
|
}
|
|
79
|
-
},
|
|
79
|
+
}, ne = u(null);
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/react/context.tsx
|
|
82
|
-
function
|
|
82
|
+
function re(e) {
|
|
83
83
|
e?.startsWith("blob:") && URL.revokeObjectURL(e);
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function ie(e) {
|
|
86
86
|
try {
|
|
87
87
|
let t = e.toDataURL("image/jpeg", .92);
|
|
88
88
|
return t.startsWith("data:image/") ? t : void 0;
|
|
@@ -90,272 +90,350 @@ function te(e) {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
let
|
|
95
|
-
onCapture:
|
|
96
|
-
onCancel:
|
|
97
|
-
onError:
|
|
98
|
-
onSettings:
|
|
99
|
-
onFinderStatus:
|
|
100
|
-
}),
|
|
93
|
+
function S({ open: a, autoCapture: u = "defaultOn", captureMode: f = "auto", torch: g = "defaultOff", onCapture: v, onCancel: y, onError: b, onSettings: x, onFinderStatus: S, modelUrl: C, ortWasmPaths: w, detectionIntervalMs: T, apiRef: E, children: ae }) {
|
|
94
|
+
let D = r(f), O = m(void 0), k = m(void 0), A = m(void 0), j = m(void 0), M = m({}), N = m(new te()), P = m(!1), F = m(!1), I = m({
|
|
95
|
+
onCapture: v,
|
|
96
|
+
onCancel: y,
|
|
97
|
+
onError: b,
|
|
98
|
+
onSettings: x,
|
|
99
|
+
onFinderStatus: S
|
|
100
|
+
}), L = m(null), [R, oe] = h(null), [se, z] = h(D ? "ready" : "starting"), [B, V] = h(), [ce, H] = h(), [le, ue] = h({
|
|
101
101
|
width: 1,
|
|
102
102
|
height: 1
|
|
103
|
-
}), [
|
|
103
|
+
}), [de, U] = h(), [fe, W] = h(), [pe, G] = h(""), [K, me] = h(0), [he, q] = h(), [ge, J] = h(), [_e, Y] = h("idle"), [ve, ye] = h(), X = m(void 0), [be, xe] = h({
|
|
104
104
|
downloading: !1,
|
|
105
105
|
loaded: 0,
|
|
106
106
|
total: null
|
|
107
|
-
}),
|
|
108
|
-
|
|
109
|
-
}, []),
|
|
110
|
-
let n =
|
|
111
|
-
|
|
107
|
+
}), Z = d(() => {
|
|
108
|
+
re(X.current), X.current = void 0, ye(void 0);
|
|
109
|
+
}, []), Q = d((e, t) => {
|
|
110
|
+
let n = ie(e);
|
|
111
|
+
re(X.current), X.current = n, ye(n), t?.pause();
|
|
112
112
|
}, []);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
onCapture:
|
|
116
|
-
onCancel:
|
|
117
|
-
onError:
|
|
118
|
-
onSettings:
|
|
119
|
-
onFinderStatus:
|
|
113
|
+
p(() => {
|
|
114
|
+
I.current = {
|
|
115
|
+
onCapture: v,
|
|
116
|
+
onCancel: y,
|
|
117
|
+
onError: b,
|
|
118
|
+
onSettings: x,
|
|
119
|
+
onFinderStatus: S
|
|
120
120
|
};
|
|
121
121
|
}, [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]),
|
|
128
|
-
let
|
|
129
|
-
|
|
122
|
+
v,
|
|
123
|
+
y,
|
|
124
|
+
b,
|
|
125
|
+
x,
|
|
126
|
+
S
|
|
127
|
+
]), p(() => n(xe), []);
|
|
128
|
+
let Se = d((e) => {
|
|
129
|
+
oe(e);
|
|
130
130
|
}, []);
|
|
131
|
-
|
|
132
|
-
if (!
|
|
131
|
+
p(() => {
|
|
132
|
+
if (!a || !R) return;
|
|
133
133
|
let e = () => {
|
|
134
|
-
let e =
|
|
135
|
-
|
|
134
|
+
let e = R.getBoundingClientRect();
|
|
135
|
+
ue({
|
|
136
136
|
width: e.width,
|
|
137
137
|
height: e.height
|
|
138
138
|
});
|
|
139
139
|
};
|
|
140
140
|
if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
141
141
|
let t = new ResizeObserver(e);
|
|
142
|
-
return t.observe(
|
|
143
|
-
}, [
|
|
144
|
-
if (!
|
|
142
|
+
return t.observe(R), () => t.disconnect();
|
|
143
|
+
}, [a, R]), p(() => {
|
|
144
|
+
if (!a) return;
|
|
145
145
|
let e = window.setInterval(() => {
|
|
146
|
-
let e =
|
|
147
|
-
e &&
|
|
146
|
+
let e = O.current?.getDiagnostics();
|
|
147
|
+
e && q(e);
|
|
148
148
|
}, 500);
|
|
149
149
|
return () => window.clearInterval(e);
|
|
150
|
-
}, [
|
|
151
|
-
if (!
|
|
152
|
-
let e = 0, t = performance.now(),
|
|
153
|
-
let i =
|
|
154
|
-
t =
|
|
150
|
+
}, [a, K]), p(() => {
|
|
151
|
+
if (!a) return;
|
|
152
|
+
let e = 0, t = performance.now(), n = (r) => {
|
|
153
|
+
let i = N.current.step(r - t);
|
|
154
|
+
t = r, i && H(i), e = requestAnimationFrame(n);
|
|
155
155
|
};
|
|
156
|
-
return e = requestAnimationFrame(
|
|
157
|
-
}, [
|
|
158
|
-
if (!
|
|
159
|
-
let
|
|
160
|
-
|
|
156
|
+
return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
|
|
157
|
+
}, [a]), p(() => {
|
|
158
|
+
if (!a || D || !R) return;
|
|
159
|
+
let e = !1, n = () => {
|
|
160
|
+
k.current?.stop(), k.current = void 0, O.current?.stop(), O.current = void 0, j.current = void 0, A.current = void 0, M.current = {}, Z();
|
|
161
161
|
};
|
|
162
162
|
return (async () => {
|
|
163
|
-
|
|
163
|
+
n(), P.current = !1, z("starting"), G(""), V(void 0), W(void 0), J(void 0), Y("idle"), Z();
|
|
164
164
|
try {
|
|
165
|
-
let n = await
|
|
166
|
-
if (
|
|
165
|
+
let n = await t(R, { torch: g });
|
|
166
|
+
if (e) {
|
|
167
167
|
n.stop();
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
O.current = n;
|
|
171
171
|
let r = n.getSettings();
|
|
172
|
-
|
|
173
|
-
source:
|
|
174
|
-
autoCapture:
|
|
175
|
-
intervalMs:
|
|
172
|
+
U(r), I.current.onSettings?.(r), console.info("[ScannerProvider] camera settings", r), k.current = await s({
|
|
173
|
+
source: R,
|
|
174
|
+
autoCapture: u,
|
|
175
|
+
intervalMs: T,
|
|
176
176
|
detection: {
|
|
177
|
-
modelUrl:
|
|
178
|
-
ortWasmPaths:
|
|
177
|
+
modelUrl: C,
|
|
178
|
+
ortWasmPaths: w
|
|
179
179
|
},
|
|
180
180
|
onStatus: (e) => {
|
|
181
|
-
if (
|
|
182
|
-
let t =
|
|
183
|
-
|
|
184
|
-
} else
|
|
185
|
-
e.state !== "captured" && !
|
|
181
|
+
if (A.current = e, V(e), I.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
|
|
182
|
+
let t = N.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
|
|
183
|
+
H(t.quad);
|
|
184
|
+
} else N.current.clear(), H(void 0);
|
|
185
|
+
e.state !== "captured" && !P.current && z("ready");
|
|
186
186
|
},
|
|
187
187
|
captureFrame: async () => {
|
|
188
|
-
|
|
189
|
-
quad:
|
|
190
|
-
sourceWidth:
|
|
191
|
-
sourceHeight:
|
|
188
|
+
z("capturing"), M.current = {
|
|
189
|
+
quad: N.current.getCurrent(),
|
|
190
|
+
sourceWidth: A.current?.sourceWidth,
|
|
191
|
+
sourceHeight: A.current?.sourceHeight
|
|
192
192
|
};
|
|
193
193
|
let e = await n.capturePhoto();
|
|
194
|
-
if (
|
|
195
|
-
return
|
|
194
|
+
if (j.current = e, W(e.method), J(e.diagnostics), q(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.`);
|
|
195
|
+
return Q(e.frame, R), z("captured"), e.frame;
|
|
196
196
|
},
|
|
197
197
|
onCaptureError: (e) => {
|
|
198
|
-
|
|
199
|
-
let t =
|
|
200
|
-
t &&
|
|
198
|
+
P.current = !0, z("error"), G(e.message);
|
|
199
|
+
let t = O.current?.getDiagnostics();
|
|
200
|
+
t && q(t), I.current.onError?.(e);
|
|
201
201
|
},
|
|
202
202
|
onCapture: async (e) => {
|
|
203
|
-
let t =
|
|
204
|
-
await new Promise((e) => window.setTimeout(e, 140)), await
|
|
203
|
+
let t = j.current;
|
|
204
|
+
await new Promise((e) => window.setTimeout(e, 140)), await I.current.onCapture({
|
|
205
205
|
...e,
|
|
206
206
|
method: t?.method ?? "video-frame",
|
|
207
207
|
settings: t?.settings ?? n.getSettings(),
|
|
208
208
|
fallbackReason: t?.fallbackReason,
|
|
209
209
|
luminance: t?.luminance,
|
|
210
210
|
diagnostics: t?.diagnostics,
|
|
211
|
-
displayedQuad:
|
|
212
|
-
displaySourceWidth:
|
|
213
|
-
displaySourceHeight:
|
|
211
|
+
displayedQuad: M.current.quad,
|
|
212
|
+
displaySourceWidth: M.current.sourceWidth,
|
|
213
|
+
displaySourceHeight: M.current.sourceHeight
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
|
-
} catch (
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
217
|
+
} catch (t) {
|
|
218
|
+
if (e) return;
|
|
219
|
+
n();
|
|
220
|
+
let r = t instanceof Error ? t : /* @__PURE__ */ Error("Camera access failed.");
|
|
221
|
+
G(r.message), z("error"), I.current.onError?.(r);
|
|
222
222
|
}
|
|
223
223
|
})(), () => {
|
|
224
|
-
|
|
224
|
+
e = !0, n();
|
|
225
225
|
};
|
|
226
226
|
}, [
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
S,
|
|
227
|
+
a,
|
|
228
|
+
R,
|
|
229
|
+
D,
|
|
230
|
+
u,
|
|
231
|
+
g,
|
|
233
232
|
C,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
w,
|
|
234
|
+
T,
|
|
235
|
+
K,
|
|
236
|
+
Z,
|
|
237
|
+
Q
|
|
238
|
+
]), p(() => {
|
|
239
|
+
a && D && (P.current = !1, F.current = !1, z("ready"), G(""), V(void 0), W(void 0), J(void 0), Y("idle"), U(void 0), H(void 0), N.current.clear(), Z());
|
|
240
|
+
}, [
|
|
241
|
+
a,
|
|
242
|
+
D,
|
|
243
|
+
K,
|
|
244
|
+
Z
|
|
237
245
|
]);
|
|
238
|
-
let
|
|
239
|
-
open:
|
|
240
|
-
phase:
|
|
241
|
-
autoCapture:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
let Ce = {
|
|
247
|
+
open: a,
|
|
248
|
+
phase: se,
|
|
249
|
+
autoCapture: u,
|
|
250
|
+
captureMode: f,
|
|
251
|
+
usingSystemCamera: D,
|
|
252
|
+
finderStatus: B,
|
|
253
|
+
displayQuad: ce,
|
|
254
|
+
previewSize: le,
|
|
255
|
+
settings: de,
|
|
256
|
+
captureMethod: fe,
|
|
257
|
+
error: pe,
|
|
258
|
+
diagnostics: he,
|
|
259
|
+
shutterDiagnostics: ge,
|
|
260
|
+
copyState: _e,
|
|
261
|
+
guidanceHint: B ? o(B.guidance, B.lighting) : void 0,
|
|
262
|
+
detectorStatus: B?.modelStatus === "failed" ? `ML failed${B.modelError ? `: ${B.modelError}` : ""}` : B?.detector === "ml" ? `ML ${B.modelProvider ?? ""}`.trim() : "ML loading",
|
|
263
|
+
modelDownload: be,
|
|
264
|
+
frozenPreviewUrl: ve
|
|
255
265
|
};
|
|
256
|
-
|
|
257
|
-
|
|
266
|
+
p(() => {
|
|
267
|
+
L.current = Ce;
|
|
258
268
|
});
|
|
259
|
-
let
|
|
260
|
-
|
|
261
|
-
}, []),
|
|
269
|
+
let we = d(() => {
|
|
270
|
+
I.current.onCancel();
|
|
271
|
+
}, []), $ = d(async () => {
|
|
272
|
+
if (!F.current) {
|
|
273
|
+
F.current = !0, P.current = !1, G(""), H(void 0), N.current.clear(), z("capturing");
|
|
274
|
+
try {
|
|
275
|
+
let t = await c();
|
|
276
|
+
Q(t);
|
|
277
|
+
let n = {
|
|
278
|
+
width: t.width,
|
|
279
|
+
height: t.height
|
|
280
|
+
};
|
|
281
|
+
U(n), I.current.onSettings?.(n), W("system-camera");
|
|
282
|
+
let r;
|
|
283
|
+
try {
|
|
284
|
+
let e = t.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, t.width, t.height).data;
|
|
285
|
+
e && (r = l(e));
|
|
286
|
+
} catch {
|
|
287
|
+
r = void 0;
|
|
288
|
+
}
|
|
289
|
+
let i = await e(t, {
|
|
290
|
+
modelUrl: C,
|
|
291
|
+
ortWasmPaths: w
|
|
292
|
+
});
|
|
293
|
+
if (i.status !== "success" || !i.corners || !i.quad) {
|
|
294
|
+
P.current = !0, z("error"), G(i.message), I.current.onError?.(Error(i.message));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
M.current = {
|
|
298
|
+
quad: i.quad,
|
|
299
|
+
sourceWidth: i.sourceWidth,
|
|
300
|
+
sourceHeight: i.sourceHeight
|
|
301
|
+
}, H(i.quad), z("captured"), await I.current.onCapture({
|
|
302
|
+
frame: t,
|
|
303
|
+
detection: i,
|
|
304
|
+
reason: "manual",
|
|
305
|
+
method: "system-camera",
|
|
306
|
+
settings: n,
|
|
307
|
+
luminance: r,
|
|
308
|
+
displayedQuad: i.quad,
|
|
309
|
+
displaySourceWidth: i.sourceWidth,
|
|
310
|
+
displaySourceHeight: i.sourceHeight
|
|
311
|
+
});
|
|
312
|
+
} catch (e) {
|
|
313
|
+
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not take a photo.");
|
|
314
|
+
if (t.message === "No photo was selected.") {
|
|
315
|
+
z("ready");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
P.current = !0, G(t.message), z("error"), I.current.onError?.(t);
|
|
319
|
+
} finally {
|
|
320
|
+
F.current = !1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}, [
|
|
324
|
+
Q,
|
|
325
|
+
C,
|
|
326
|
+
w
|
|
327
|
+
]), Te = d(async () => {
|
|
328
|
+
if (D) {
|
|
329
|
+
await $();
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
262
332
|
try {
|
|
263
|
-
await
|
|
333
|
+
await k.current?.capture();
|
|
264
334
|
} catch (e) {
|
|
265
335
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
|
|
266
|
-
|
|
267
|
-
let n =
|
|
268
|
-
n &&
|
|
336
|
+
P.current = !0, G(t.message);
|
|
337
|
+
let n = O.current?.getDiagnostics();
|
|
338
|
+
n && q(n), j.current?.diagnostics && J(j.current.diagnostics), z("error"), I.current.onError?.(t);
|
|
269
339
|
}
|
|
270
|
-
}, []),
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
let
|
|
276
|
-
|
|
277
|
-
}, [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
340
|
+
}, [$, D]), Ee = d(() => {
|
|
341
|
+
if (P.current = !1, G(""), J(void 0), Y("idle"), Z(), H(void 0), N.current.clear(), D) {
|
|
342
|
+
z("ready"), $();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
let e = O.current;
|
|
346
|
+
R?.paused && R.play(), z(e ? "ready" : "starting"), e || me((e) => e + 1);
|
|
347
|
+
}, [
|
|
348
|
+
$,
|
|
349
|
+
Z,
|
|
350
|
+
R,
|
|
351
|
+
D
|
|
352
|
+
]), De = d(async (e) => {
|
|
353
|
+
let t = O.current;
|
|
354
|
+
t && (await t.setTorch(e), q(t.getDiagnostics()));
|
|
355
|
+
}, []), Oe = d((e) => {
|
|
356
|
+
k.current?.setAutoCapture(e);
|
|
357
|
+
}, []), ke = d(async () => {
|
|
358
|
+
let e = L.current, t = O.current?.getDiagnostics() ?? e.diagnostics, n = e.finderStatus, r = i({
|
|
281
359
|
error: e.error || void 0,
|
|
282
360
|
captureMethod: e.captureMethod,
|
|
283
|
-
luminance:
|
|
284
|
-
fallbackReason:
|
|
285
|
-
shutter: e.shutterDiagnostics ??
|
|
286
|
-
live:
|
|
287
|
-
finder:
|
|
288
|
-
state:
|
|
289
|
-
confidence:
|
|
290
|
-
stableFrames:
|
|
291
|
-
requiredStableFrames:
|
|
292
|
-
detector:
|
|
293
|
-
modelStatus:
|
|
294
|
-
modelError:
|
|
295
|
-
modelProvider:
|
|
296
|
-
modelNote:
|
|
297
|
-
inferenceMs:
|
|
298
|
-
sourceWidth:
|
|
299
|
-
sourceHeight:
|
|
361
|
+
luminance: j.current?.luminance,
|
|
362
|
+
fallbackReason: j.current?.fallbackReason,
|
|
363
|
+
shutter: e.shutterDiagnostics ?? j.current?.diagnostics,
|
|
364
|
+
live: t,
|
|
365
|
+
finder: n ? {
|
|
366
|
+
state: n.state,
|
|
367
|
+
confidence: n.confidence,
|
|
368
|
+
stableFrames: n.stableFrames,
|
|
369
|
+
requiredStableFrames: n.requiredStableFrames,
|
|
370
|
+
detector: n.detector,
|
|
371
|
+
modelStatus: n.modelStatus,
|
|
372
|
+
modelError: n.modelError,
|
|
373
|
+
modelProvider: n.modelProvider,
|
|
374
|
+
modelNote: n.modelNote,
|
|
375
|
+
inferenceMs: n.inferenceMs,
|
|
376
|
+
sourceWidth: n.sourceWidth,
|
|
377
|
+
sourceHeight: n.sourceHeight
|
|
300
378
|
} : void 0
|
|
301
379
|
});
|
|
302
380
|
try {
|
|
303
|
-
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(
|
|
381
|
+
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(r);
|
|
304
382
|
else {
|
|
305
383
|
let e = document.createElement("textarea");
|
|
306
|
-
e.value =
|
|
384
|
+
e.value = r, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
|
|
307
385
|
let t = document.execCommand("copy");
|
|
308
386
|
if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
|
|
309
387
|
}
|
|
310
|
-
|
|
388
|
+
Y("copied");
|
|
311
389
|
} catch {
|
|
312
|
-
|
|
390
|
+
Y("failed");
|
|
313
391
|
}
|
|
314
|
-
}, []),
|
|
315
|
-
capture:
|
|
316
|
-
cancel:
|
|
317
|
-
retry:
|
|
318
|
-
setTorch:
|
|
319
|
-
setAutoCapture:
|
|
320
|
-
copyReport:
|
|
321
|
-
getState:
|
|
392
|
+
}, []), Ae = d(() => L.current, []), je = ee(() => ({
|
|
393
|
+
capture: Te,
|
|
394
|
+
cancel: we,
|
|
395
|
+
retry: Ee,
|
|
396
|
+
setTorch: De,
|
|
397
|
+
setAutoCapture: Oe,
|
|
398
|
+
copyReport: ke,
|
|
399
|
+
getState: Ae
|
|
322
400
|
}), [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
401
|
+
Te,
|
|
402
|
+
we,
|
|
403
|
+
Ee,
|
|
404
|
+
De,
|
|
405
|
+
Oe,
|
|
406
|
+
ke,
|
|
407
|
+
Ae
|
|
330
408
|
]);
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
|
|
409
|
+
p(() => {
|
|
410
|
+
if (E) return E.current = je, () => {
|
|
411
|
+
E.current = null;
|
|
334
412
|
};
|
|
335
|
-
}, [
|
|
336
|
-
let
|
|
337
|
-
...
|
|
338
|
-
|
|
339
|
-
bindPreview:
|
|
413
|
+
}, [je, E]);
|
|
414
|
+
let Me = {
|
|
415
|
+
...Ce,
|
|
416
|
+
...je,
|
|
417
|
+
bindPreview: Se
|
|
340
418
|
};
|
|
341
|
-
return /* @__PURE__ */
|
|
342
|
-
value:
|
|
343
|
-
children:
|
|
419
|
+
return /* @__PURE__ */ _(ne.Provider, {
|
|
420
|
+
value: Me,
|
|
421
|
+
children: ae
|
|
344
422
|
});
|
|
345
423
|
}
|
|
346
424
|
//#endregion
|
|
347
425
|
//#region src/react/hooks.ts
|
|
348
|
-
function S() {
|
|
349
|
-
return d(null);
|
|
350
|
-
}
|
|
351
426
|
function C() {
|
|
352
|
-
|
|
427
|
+
return m(null);
|
|
428
|
+
}
|
|
429
|
+
function w() {
|
|
430
|
+
let e = f(ne);
|
|
353
431
|
if (!e) throw Error("useScanner must be used within ScannerProvider.");
|
|
354
432
|
return e;
|
|
355
433
|
}
|
|
356
434
|
//#endregion
|
|
357
435
|
//#region src/live-overlay-geometry.ts
|
|
358
|
-
function
|
|
436
|
+
function T(e, t, n, r, i) {
|
|
359
437
|
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;
|
|
360
438
|
if (i === "contain") return {
|
|
361
439
|
viewBox: `0 0 ${a} ${o}`,
|
|
@@ -364,9 +442,9 @@ function w(e, t, n, r, i) {
|
|
|
364
442
|
offsetX: f,
|
|
365
443
|
offsetY: p
|
|
366
444
|
};
|
|
367
|
-
let
|
|
445
|
+
let ee = s / d, m = c / d;
|
|
368
446
|
return {
|
|
369
|
-
viewBox: `${-f / d} ${-p / d} ${
|
|
447
|
+
viewBox: `${-f / d} ${-p / d} ${ee} ${m}`,
|
|
370
448
|
preserveAspectRatio: "none",
|
|
371
449
|
scale: d,
|
|
372
450
|
offsetX: f,
|
|
@@ -375,10 +453,10 @@ function w(e, t, n, r, i) {
|
|
|
375
453
|
}
|
|
376
454
|
//#endregion
|
|
377
455
|
//#region src/components/ModelDownloadRing.tsx
|
|
378
|
-
function
|
|
456
|
+
function E({ snapshot: e }) {
|
|
379
457
|
if (!e.downloading) return null;
|
|
380
458
|
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;
|
|
381
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ v("div", {
|
|
382
460
|
className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
|
|
383
461
|
role: "progressbar",
|
|
384
462
|
"aria-label": "Model download",
|
|
@@ -387,15 +465,15 @@ function T({ snapshot: e }) {
|
|
|
387
465
|
"aria-valuenow": n ?? void 0,
|
|
388
466
|
"data-loaded": e.loaded,
|
|
389
467
|
"data-total": e.total ?? "",
|
|
390
|
-
children: [/* @__PURE__ */
|
|
468
|
+
children: [/* @__PURE__ */ v("svg", {
|
|
391
469
|
viewBox: "0 0 72 72",
|
|
392
470
|
"aria-hidden": "true",
|
|
393
|
-
children: [/* @__PURE__ */
|
|
471
|
+
children: [/* @__PURE__ */ _("circle", {
|
|
394
472
|
className: "track",
|
|
395
473
|
cx: "36",
|
|
396
474
|
cy: "36",
|
|
397
475
|
r: 28
|
|
398
|
-
}), /* @__PURE__ */
|
|
476
|
+
}), /* @__PURE__ */ _("circle", {
|
|
399
477
|
className: "value",
|
|
400
478
|
cx: "36",
|
|
401
479
|
cy: "36",
|
|
@@ -403,15 +481,15 @@ function T({ snapshot: e }) {
|
|
|
403
481
|
strokeDasharray: t === null ? void 0 : `${r} ${r}`,
|
|
404
482
|
strokeDashoffset: t === null ? void 0 : r * (1 - t)
|
|
405
483
|
})]
|
|
406
|
-
}), n === null ? /* @__PURE__ */
|
|
484
|
+
}), n === null ? /* @__PURE__ */ _("strong", {
|
|
407
485
|
className: "model-download-ring__pending",
|
|
408
486
|
children: "…"
|
|
409
|
-
}) : /* @__PURE__ */
|
|
487
|
+
}) : /* @__PURE__ */ v("strong", { children: [n, "%"] })]
|
|
410
488
|
});
|
|
411
489
|
}
|
|
412
490
|
//#endregion
|
|
413
491
|
//#region src/react/parts.tsx
|
|
414
|
-
var
|
|
492
|
+
var ae = {
|
|
415
493
|
primaryColorHex: "--scanner-overlay-primary",
|
|
416
494
|
seekingColorHex: "--scanner-overlay-seeking",
|
|
417
495
|
detectingColorHex: "--scanner-overlay-detecting",
|
|
@@ -422,36 +500,44 @@ var E = {
|
|
|
422
500
|
function D(e) {
|
|
423
501
|
if (!e) return;
|
|
424
502
|
let t = {};
|
|
425
|
-
for (let [n, r] of Object.entries(
|
|
503
|
+
for (let [n, r] of Object.entries(ae)) {
|
|
426
504
|
let i = e[n]?.trim();
|
|
427
505
|
i && (t[r] = i);
|
|
428
506
|
}
|
|
429
507
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
430
508
|
}
|
|
431
509
|
function O({ theme: e, style: t, title: n = "Scan a document", children: r }) {
|
|
432
|
-
let i =
|
|
510
|
+
let i = w();
|
|
433
511
|
if (!i.open) return null;
|
|
434
512
|
let a = D(e), o = a ? {
|
|
435
513
|
...t,
|
|
436
514
|
...a
|
|
437
515
|
} : t;
|
|
438
|
-
return /* @__PURE__ */
|
|
439
|
-
className: `scanner-camera-overlay ${i.finderStatus?.state === "captured" ? "is-captured" : ""}`.trim(),
|
|
516
|
+
return /* @__PURE__ */ v("div", {
|
|
517
|
+
className: `scanner-camera-overlay ${i.phase === "captured" || i.finderStatus?.state === "captured" ? "is-captured" : ""} ${i.usingSystemCamera ? "is-system-camera" : ""}`.trim(),
|
|
440
518
|
style: o,
|
|
441
519
|
role: "dialog",
|
|
442
520
|
"aria-modal": "true",
|
|
443
521
|
"aria-label": n,
|
|
444
|
-
children: [r, /* @__PURE__ */
|
|
522
|
+
children: [r, /* @__PURE__ */ _(I, {})]
|
|
445
523
|
});
|
|
446
524
|
}
|
|
447
525
|
function k() {
|
|
448
|
-
let { bindPreview: e, frozenPreviewUrl: t } =
|
|
449
|
-
|
|
526
|
+
let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = w(), r = m(null), i = d((t) => {
|
|
527
|
+
r.current = t, e(t);
|
|
450
528
|
}, [e]);
|
|
451
|
-
return
|
|
452
|
-
t &&
|
|
453
|
-
}, [t]),
|
|
454
|
-
|
|
529
|
+
return p(() => {
|
|
530
|
+
t && r.current?.pause();
|
|
531
|
+
}, [t]), n ? t ? /* @__PURE__ */ _("img", {
|
|
532
|
+
src: t,
|
|
533
|
+
className: "scanner-camera-overlay__video scanner-camera-overlay__still",
|
|
534
|
+
alt: "",
|
|
535
|
+
"aria-label": "Captured document"
|
|
536
|
+
}) : /* @__PURE__ */ _("div", {
|
|
537
|
+
className: "scanner-camera-overlay__video",
|
|
538
|
+
"aria-hidden": "true"
|
|
539
|
+
}) : /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _("video", {
|
|
540
|
+
ref: i,
|
|
455
541
|
className: "scanner-camera-overlay__video",
|
|
456
542
|
muted: !0,
|
|
457
543
|
autoPlay: !0,
|
|
@@ -459,7 +545,7 @@ function k() {
|
|
|
459
545
|
style: { objectFit: "cover" },
|
|
460
546
|
"aria-hidden": !!t,
|
|
461
547
|
"aria-label": "Rear camera preview"
|
|
462
|
-
}), t ? /* @__PURE__ */
|
|
548
|
+
}), t ? /* @__PURE__ */ _("img", {
|
|
463
549
|
src: t,
|
|
464
550
|
className: "scanner-camera-overlay__video scanner-camera-overlay__still",
|
|
465
551
|
alt: "",
|
|
@@ -467,31 +553,37 @@ function k() {
|
|
|
467
553
|
}) : null] });
|
|
468
554
|
}
|
|
469
555
|
function A() {
|
|
470
|
-
let { finderStatus: e, displayQuad: t, previewSize: n } =
|
|
556
|
+
let { finderStatus: e, displayQuad: t, previewSize: n } = w();
|
|
471
557
|
if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
|
|
472
|
-
let r =
|
|
473
|
-
return /* @__PURE__ */
|
|
558
|
+
let r = T(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
|
|
559
|
+
return /* @__PURE__ */ _("svg", {
|
|
474
560
|
className: `scanner-camera-overlay__quad ${e.state}`,
|
|
475
561
|
viewBox: r.viewBox,
|
|
476
562
|
preserveAspectRatio: r.preserveAspectRatio,
|
|
477
563
|
"aria-label": `${e.state} document boundary`,
|
|
478
|
-
children: /* @__PURE__ */
|
|
564
|
+
children: /* @__PURE__ */ _("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}` })
|
|
479
565
|
});
|
|
480
566
|
}
|
|
481
567
|
function j({ title: e = "Scan a document" }) {
|
|
482
|
-
let { phase: t, guidanceHint: n, cancel: r } =
|
|
483
|
-
return /* @__PURE__ */
|
|
568
|
+
let { phase: t, guidanceHint: n, cancel: r, usingSystemCamera: i } = w();
|
|
569
|
+
return /* @__PURE__ */ v("div", {
|
|
484
570
|
className: "scanner-camera-overlay__topbar",
|
|
485
|
-
children: [/* @__PURE__ */
|
|
571
|
+
children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("strong", { children: e }), /* @__PURE__ */ _("span", {
|
|
486
572
|
"aria-live": "polite",
|
|
487
|
-
children: [
|
|
573
|
+
children: i ? /* @__PURE__ */ v(g, { children: [
|
|
574
|
+
t === "starting" && "Preparing the system camera…",
|
|
575
|
+
t === "ready" && "Take a photo. There is no live document guide.",
|
|
576
|
+
t === "capturing" && "Looking for a document…",
|
|
577
|
+
t === "captured" && "Document captured",
|
|
578
|
+
t === "error" && "No document found"
|
|
579
|
+
] }) : /* @__PURE__ */ v(g, { children: [
|
|
488
580
|
t === "starting" && "Starting rear camera…",
|
|
489
581
|
t === "ready" && (n ?? "Place the document in the frame"),
|
|
490
582
|
t === "capturing" && "Capturing full resolution…",
|
|
491
583
|
t === "captured" && "Document captured",
|
|
492
584
|
t === "error" && "Camera unavailable"
|
|
493
|
-
]
|
|
494
|
-
})] }), /* @__PURE__ */
|
|
585
|
+
] })
|
|
586
|
+
})] }), /* @__PURE__ */ _("button", {
|
|
495
587
|
type: "button",
|
|
496
588
|
onClick: r,
|
|
497
589
|
"aria-label": "Close camera",
|
|
@@ -500,115 +592,130 @@ function j({ title: e = "Scan a document" }) {
|
|
|
500
592
|
});
|
|
501
593
|
}
|
|
502
594
|
function M() {
|
|
503
|
-
let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o } =
|
|
504
|
-
return e === "error" ? /* @__PURE__ */
|
|
595
|
+
let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o, usingSystemCamera: s, frozenPreviewUrl: c } = w();
|
|
596
|
+
return e === "error" ? /* @__PURE__ */ v("div", {
|
|
505
597
|
className: "scanner-camera-overlay__message",
|
|
506
598
|
role: "alert",
|
|
507
599
|
children: [
|
|
508
|
-
/* @__PURE__ */
|
|
509
|
-
/* @__PURE__ */
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
/* @__PURE__ */
|
|
600
|
+
/* @__PURE__ */ _("strong", { children: s ? c ? "No document found" : "Could not take a photo" : n ? "Capture failed" : "Could not open the camera" }),
|
|
601
|
+
/* @__PURE__ */ _("p", { children: t }),
|
|
602
|
+
/* @__PURE__ */ v("div", { children: [
|
|
603
|
+
/* @__PURE__ */ _("button", {
|
|
512
604
|
type: "button",
|
|
513
605
|
onClick: i,
|
|
514
606
|
children: "Try again"
|
|
515
607
|
}),
|
|
516
|
-
/* @__PURE__ */
|
|
608
|
+
/* @__PURE__ */ _("button", {
|
|
517
609
|
type: "button",
|
|
518
610
|
onClick: () => void a(),
|
|
519
611
|
children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
|
|
520
612
|
}),
|
|
521
|
-
/* @__PURE__ */
|
|
613
|
+
/* @__PURE__ */ _("button", {
|
|
522
614
|
type: "button",
|
|
523
615
|
onClick: o,
|
|
524
616
|
children: "Cancel"
|
|
525
617
|
})
|
|
526
618
|
] })
|
|
527
619
|
]
|
|
528
|
-
}) : e === "
|
|
620
|
+
}) : s && e === "ready" && !c ? /* @__PURE__ */ v("div", {
|
|
621
|
+
className: "scanner-camera-overlay__message",
|
|
622
|
+
"aria-live": "polite",
|
|
623
|
+
children: [/* @__PURE__ */ _("strong", { children: "System camera" }), /* @__PURE__ */ _("p", { children: "Chrome cannot match Camera-app quality in a live preview. Take a photo, then we find the page in that JPEG. There is no live document guide." })]
|
|
624
|
+
}) : e === "starting" && !s ? /* @__PURE__ */ v("div", {
|
|
529
625
|
className: "scanner-camera-overlay__message",
|
|
530
626
|
"aria-live": "polite",
|
|
531
627
|
children: [
|
|
532
|
-
/* @__PURE__ */
|
|
533
|
-
/* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
628
|
+
/* @__PURE__ */ _("span", { className: "scanner-camera-overlay__spinner" }),
|
|
629
|
+
/* @__PURE__ */ _("strong", { children: "Requesting the highest practical resolution" }),
|
|
630
|
+
/* @__PURE__ */ _("p", { children: "Allow camera access to continue." })
|
|
535
631
|
]
|
|
536
632
|
}) : null;
|
|
537
633
|
}
|
|
538
634
|
function N() {
|
|
539
|
-
let { finderStatus: e, detectorStatus: t, settings: n } =
|
|
540
|
-
return /* @__PURE__ */
|
|
635
|
+
let { finderStatus: e, detectorStatus: t, settings: n, usingSystemCamera: r, captureMethod: i, phase: a } = w(), o = n?.width, s = n?.height;
|
|
636
|
+
return r ? /* @__PURE__ */ _("div", {
|
|
637
|
+
className: "scanner-camera-overlay__status",
|
|
638
|
+
"aria-live": "polite",
|
|
639
|
+
children: /* @__PURE__ */ v("div", {
|
|
640
|
+
className: "scanner-camera-overlay__status-line",
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ _("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
|
|
643
|
+
i === "system-camera" ? "system camera" : "system camera · waiting",
|
|
644
|
+
o && s ? ` · ${o}×${s}` : ""
|
|
645
|
+
]
|
|
646
|
+
})
|
|
647
|
+
}) : /* @__PURE__ */ _("div", {
|
|
541
648
|
className: "scanner-camera-overlay__status",
|
|
542
649
|
"aria-live": "polite",
|
|
543
|
-
children: /* @__PURE__ */
|
|
650
|
+
children: /* @__PURE__ */ v("div", {
|
|
544
651
|
className: "scanner-camera-overlay__status-line",
|
|
545
652
|
children: [
|
|
546
|
-
/* @__PURE__ */
|
|
653
|
+
/* @__PURE__ */ _("span", { className: e?.state ?? "detecting" }),
|
|
547
654
|
e?.state ?? "detecting",
|
|
548
655
|
e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
|
|
549
656
|
` · ${t}`,
|
|
550
657
|
e?.inferenceMs === void 0 ? "" : ` · ${Math.round(e.inferenceMs)}ms`,
|
|
551
|
-
|
|
658
|
+
o && s ? ` · ${o}×${s}` : ""
|
|
552
659
|
]
|
|
553
660
|
})
|
|
554
661
|
});
|
|
555
662
|
}
|
|
556
663
|
function P() {
|
|
557
|
-
let { diagnostics: e, shutterDiagnostics: t, captureMethod:
|
|
558
|
-
return /* @__PURE__ */
|
|
664
|
+
let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: r, copyReport: i } = w(), o = e?.engine ?? a();
|
|
665
|
+
return /* @__PURE__ */ v("dl", {
|
|
559
666
|
className: "scanner-camera-overlay__diagnostics",
|
|
560
667
|
"aria-label": "Camera diagnostics",
|
|
561
668
|
children: [
|
|
562
|
-
/* @__PURE__ */
|
|
669
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "engine" }), /* @__PURE__ */ v("dd", { children: [
|
|
563
670
|
o.engine,
|
|
564
671
|
"/",
|
|
565
672
|
o.browser,
|
|
566
673
|
o.iosWebKit ? " ios" : ""
|
|
567
674
|
] })] }),
|
|
568
|
-
/* @__PURE__ */
|
|
569
|
-
/* @__PURE__ */
|
|
570
|
-
/* @__PURE__ */
|
|
571
|
-
/* @__PURE__ */
|
|
572
|
-
/* @__PURE__ */
|
|
573
|
-
t ? /* @__PURE__ */
|
|
574
|
-
/* @__PURE__ */
|
|
675
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "video" }), /* @__PURE__ */ _("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
|
|
676
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "track" }), /* @__PURE__ */ _("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
|
|
677
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "torch" }), /* @__PURE__ */ _("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
|
|
678
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "luma" }), /* @__PURE__ */ _("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
|
|
679
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "path" }), /* @__PURE__ */ _("dd", { children: n ?? "video-frame / live-mirror" })] }),
|
|
680
|
+
t ? /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "shutter" }), /* @__PURE__ */ _("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
|
|
681
|
+
/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: "share" }), /* @__PURE__ */ _("dd", { children: /* @__PURE__ */ _("button", {
|
|
575
682
|
type: "button",
|
|
576
683
|
className: "scanner-camera-overlay__copy",
|
|
577
|
-
onClick: () => void
|
|
578
|
-
children:
|
|
684
|
+
onClick: () => void i(),
|
|
685
|
+
children: r === "copied" ? "Copied report" : r === "failed" ? "Copy failed" : "Copy report"
|
|
579
686
|
}) })] })
|
|
580
687
|
]
|
|
581
688
|
});
|
|
582
689
|
}
|
|
583
690
|
function F() {
|
|
584
|
-
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l } =
|
|
585
|
-
return /* @__PURE__ */
|
|
691
|
+
let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u } = w(), d = a?.width, f = a?.height;
|
|
692
|
+
return /* @__PURE__ */ v("div", {
|
|
586
693
|
className: "scanner-camera-overlay__controls",
|
|
587
694
|
children: [
|
|
588
|
-
/* @__PURE__ */
|
|
695
|
+
/* @__PURE__ */ _("button", {
|
|
589
696
|
type: "button",
|
|
590
697
|
className: "scanner-camera-overlay__cancel",
|
|
591
698
|
onClick: o,
|
|
592
699
|
children: "Cancel"
|
|
593
700
|
}),
|
|
594
|
-
/* @__PURE__ */
|
|
701
|
+
/* @__PURE__ */ v("div", {
|
|
595
702
|
className: "scanner-camera-overlay__capture",
|
|
596
|
-
children: [e !== "only" && /* @__PURE__ */
|
|
703
|
+
children: [(u || e !== "only") && /* @__PURE__ */ _("button", {
|
|
597
704
|
type: "button",
|
|
598
705
|
className: "scanner-camera-overlay__shutter",
|
|
599
706
|
onClick: () => void s(),
|
|
600
707
|
disabled: t !== "ready",
|
|
601
|
-
"aria-label": "Capture full-resolution photo",
|
|
602
|
-
children: /* @__PURE__ */
|
|
603
|
-
}), /* @__PURE__ */
|
|
708
|
+
"aria-label": u ? "Take a photo with the system camera" : "Capture full-resolution photo",
|
|
709
|
+
children: /* @__PURE__ */ _("span", {})
|
|
710
|
+
}), !u && /* @__PURE__ */ v("div", {
|
|
604
711
|
className: "scanner-camera-overlay__toggles",
|
|
605
|
-
children: [n?.autoCapture.visible && /* @__PURE__ */
|
|
712
|
+
children: [n?.autoCapture.visible && /* @__PURE__ */ v("label", { children: [/* @__PURE__ */ _("input", {
|
|
606
713
|
type: "checkbox",
|
|
607
714
|
checked: n.autoCapture.checked,
|
|
608
715
|
onChange: (e) => c(e.target.checked)
|
|
609
|
-
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */
|
|
716
|
+
}), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ v("label", {
|
|
610
717
|
title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
|
|
611
|
-
children: [/* @__PURE__ */
|
|
718
|
+
children: [/* @__PURE__ */ _("input", {
|
|
612
719
|
type: "checkbox",
|
|
613
720
|
checked: r.torch.on,
|
|
614
721
|
disabled: !r.torch.mutable,
|
|
@@ -617,18 +724,18 @@ function F() {
|
|
|
617
724
|
})]
|
|
618
725
|
})]
|
|
619
726
|
}),
|
|
620
|
-
/* @__PURE__ */
|
|
727
|
+
/* @__PURE__ */ v("div", {
|
|
621
728
|
className: "scanner-camera-overlay__quality",
|
|
622
|
-
children: [/* @__PURE__ */
|
|
729
|
+
children: [/* @__PURE__ */ _("span", { children: u ? "System camera" : i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ _("strong", { children: d && f ? `${d} × ${f}` : u ? "Tap to photograph" : "Measuring…" })]
|
|
623
730
|
})
|
|
624
731
|
]
|
|
625
732
|
});
|
|
626
733
|
}
|
|
627
734
|
function I({ snapshot: e }) {
|
|
628
|
-
let { modelDownload: t } =
|
|
629
|
-
return /* @__PURE__ */
|
|
735
|
+
let { modelDownload: t } = w();
|
|
736
|
+
return /* @__PURE__ */ _(E, { snapshot: e ?? t });
|
|
630
737
|
}
|
|
631
738
|
//#endregion
|
|
632
|
-
export { F as ScannerControls, P as ScannerDiagnostics, O as ScannerFrame, I as ScannerModelDownload, M as ScannerNotice, k as ScannerPreview,
|
|
739
|
+
export { F as ScannerControls, P as ScannerDiagnostics, O as ScannerFrame, I as ScannerModelDownload, M as ScannerNotice, k as ScannerPreview, S as ScannerProvider, A as ScannerQuad, N as ScannerStatus, j as ScannerTopBar, w as useScanner, C as useScannerRef };
|
|
633
740
|
|
|
634
741
|
//# sourceMappingURL=react.js.map
|