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