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