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