@exige/web-scanner-sdk 0.2.14 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets/document-worker.js +1 -1
- package/dist/assets/document-worker.js.map +1 -1
- package/dist/{finder-DdnCpnjz.js → finder-D0Wgl-6-.js} +211 -143
- package/dist/finder-D0Wgl-6-.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/scanner-sdk.js +1 -1
- package/dist/scanner-sdk.js.map +1 -1
- package/dist/sdk/camera.d.ts +19 -7
- package/dist/sdk/finder.d.ts +6 -2
- package/dist/sdk/preview-frame.d.ts +27 -0
- package/package.json +1 -1
- package/dist/finder-DdnCpnjz.js.map +0 -1
|
@@ -263,28 +263,28 @@ async function ie(t, n) {
|
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/sdk/ort-runtime.ts
|
|
265
265
|
var ae = new URL("./assets/ort-wasm-simd-threaded.jsep.wasm", import.meta.url), oe = new URL("./assets/ort-wasm-simd-threaded.jsep.mjs", import.meta.url);
|
|
266
|
-
function
|
|
266
|
+
function A() {
|
|
267
267
|
return {
|
|
268
268
|
wasm: ae.href,
|
|
269
269
|
mjs: oe.href
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function
|
|
273
|
-
return typeof e == "string" ? e.trim() ||
|
|
272
|
+
function se(e) {
|
|
273
|
+
return typeof e == "string" ? e.trim() || A() : e?.wasm.trim() && e.mjs.trim() ? {
|
|
274
274
|
wasm: e.wasm.trim(),
|
|
275
275
|
mjs: e.mjs.trim()
|
|
276
|
-
} :
|
|
276
|
+
} : A();
|
|
277
277
|
}
|
|
278
278
|
//#endregion
|
|
279
279
|
//#region src/sdk/image.ts
|
|
280
|
-
function
|
|
280
|
+
function ce(e, t, n) {
|
|
281
281
|
let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
|
|
282
282
|
return {
|
|
283
283
|
width: Math.max(1, Math.round(e * r)),
|
|
284
284
|
height: Math.max(1, Math.round(t * r))
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
|
-
async function
|
|
287
|
+
async function le(e) {
|
|
288
288
|
let t = URL.createObjectURL(e);
|
|
289
289
|
try {
|
|
290
290
|
let e = new Image();
|
|
@@ -293,26 +293,26 @@ async function ue(e) {
|
|
|
293
293
|
URL.revokeObjectURL(t);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
async function
|
|
296
|
+
async function j(e, n = {}) {
|
|
297
297
|
if (e instanceof HTMLCanvasElement && n.cloneCanvas === !1 && !n.maxDimension) return e;
|
|
298
298
|
let r = document.createElement("canvas"), i = r.getContext("2d", { willReadFrequently: !0 });
|
|
299
299
|
if (!i) throw t();
|
|
300
300
|
if (e instanceof Blob) {
|
|
301
301
|
if ("createImageBitmap" in window) try {
|
|
302
|
-
let t = await createImageBitmap(e), a =
|
|
302
|
+
let t = await createImageBitmap(e), a = ce(t.width, t.height, n.maxDimension);
|
|
303
303
|
return r.width = a.width, r.height = a.height, i.drawImage(t, 0, 0, a.width, a.height), t.close(), r;
|
|
304
304
|
} catch {}
|
|
305
|
-
e = await
|
|
305
|
+
e = await le(e);
|
|
306
306
|
}
|
|
307
307
|
let a = e instanceof HTMLImageElement ? e.naturalWidth : e.width, o = e instanceof HTMLImageElement ? e.naturalHeight : e.height;
|
|
308
308
|
if (!a || !o) throw Error("The image has no readable dimensions.");
|
|
309
|
-
let s =
|
|
309
|
+
let s = ce(a, o, n.maxDimension);
|
|
310
310
|
return r.width = s.width, r.height = s.height, i.drawImage(e, 0, 0, s.width, s.height), r;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function ue(e, t = "image/png", n = .92) {
|
|
313
313
|
return new Promise((r, i) => e.toBlob((e) => e ? r(e) : i(/* @__PURE__ */ Error("Could not encode the image.")), t, n));
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function de(e, t, n) {
|
|
316
316
|
let r = Math.max(0, Math.min(t, e.x)), i = Math.max(0, Math.min(n, e.y));
|
|
317
317
|
return {
|
|
318
318
|
x: r,
|
|
@@ -323,20 +323,20 @@ function fe(e, t, n) {
|
|
|
323
323
|
}
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/sdk/scan.ts
|
|
326
|
-
var
|
|
327
|
-
function
|
|
326
|
+
var fe = "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx", pe = 1280;
|
|
327
|
+
function me(e, t, n) {
|
|
328
328
|
if (n) return n;
|
|
329
|
-
let r = Math.max(e, t), i = r / Math.max(1, Math.min(e, t)), a =
|
|
330
|
-
return i >= 1.6 ? Math.min(r, Math.max(a,
|
|
329
|
+
let r = Math.max(e, t), i = r / Math.max(1, Math.min(e, t)), a = L() ? 560 : 900;
|
|
330
|
+
return i >= 1.6 ? Math.min(r, Math.max(a, pe)) : a;
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function M(e) {
|
|
333
333
|
return e?.trim() || "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx";
|
|
334
334
|
}
|
|
335
|
-
var
|
|
336
|
-
function
|
|
335
|
+
var he = 3, N, ge = 0, P = /* @__PURE__ */ new Map();
|
|
336
|
+
function F(e, t) {
|
|
337
337
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function I(e) {
|
|
340
340
|
return {
|
|
341
341
|
...e,
|
|
342
342
|
edges: {
|
|
@@ -359,7 +359,7 @@ function F(e) {
|
|
|
359
359
|
}
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function _e(e, t) {
|
|
363
363
|
let n = (e) => ({
|
|
364
364
|
x: e.x / t,
|
|
365
365
|
y: e.y / t
|
|
@@ -371,42 +371,42 @@ function ve(e, t) {
|
|
|
371
371
|
bottomLeft: n(e.bottomLeft)
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function L() {
|
|
375
375
|
return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0 || navigator.hardwareConcurrency <= 4 || typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches;
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function ve(t, n, r, i) {
|
|
378
378
|
return new Promise((a, o) => {
|
|
379
|
-
|
|
379
|
+
N || (N = new Worker(new URL("./assets/document-worker.js", import.meta.url), { type: "module" }), N.onmessage = (t) => {
|
|
380
380
|
if (t.data.download?.url) {
|
|
381
381
|
k(t.data.download.url, t.data.download);
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
let n =
|
|
385
|
-
n && (
|
|
386
|
-
},
|
|
384
|
+
let n = P.get(t.data.id);
|
|
385
|
+
n && (P.delete(t.data.id), t.data.error ? n.reject(t.data.errorCode ? new e(t.data.errorCode, t.data.error) : Error(t.data.error)) : t.data.result ? n.resolve(t.data.result) : n.reject(/* @__PURE__ */ Error("The document worker returned no result.")));
|
|
386
|
+
}, N.onerror = () => {
|
|
387
387
|
let t = new e("worker", "The document worker could not start.");
|
|
388
|
-
for (let e of
|
|
389
|
-
|
|
388
|
+
for (let e of P.values()) e.reject(t);
|
|
389
|
+
P.clear(), N?.terminate(), N = void 0;
|
|
390
390
|
});
|
|
391
|
-
let s = ++
|
|
392
|
-
|
|
391
|
+
let s = ++ge;
|
|
392
|
+
P.set(s, {
|
|
393
393
|
resolve: a,
|
|
394
394
|
reject: o
|
|
395
395
|
});
|
|
396
396
|
let c = t.slice().buffer;
|
|
397
|
-
|
|
397
|
+
N.postMessage({
|
|
398
398
|
id: s,
|
|
399
399
|
pixels: c,
|
|
400
400
|
width: n,
|
|
401
401
|
height: r,
|
|
402
|
-
modelUrl:
|
|
402
|
+
modelUrl: M(i.modelUrl),
|
|
403
403
|
heatmapThreshold: i.heatmapThreshold,
|
|
404
404
|
cacheModel: i.cacheModel,
|
|
405
|
-
ortWasmPaths:
|
|
405
|
+
ortWasmPaths: se(i.ortWasmPaths)
|
|
406
406
|
}, [c]);
|
|
407
407
|
});
|
|
408
408
|
}
|
|
409
|
-
async function
|
|
409
|
+
async function R(n, r) {
|
|
410
410
|
let { width: i, height: a } = n, o = r.minDimension ?? 360;
|
|
411
411
|
if (Math.min(i, a) < o) return {
|
|
412
412
|
status: "low-quality",
|
|
@@ -415,14 +415,14 @@ async function L(n, r) {
|
|
|
415
415
|
sourceWidth: i,
|
|
416
416
|
sourceHeight: a
|
|
417
417
|
};
|
|
418
|
-
let s =
|
|
418
|
+
let s = me(i, a, r.maxAnalysisDimension), c = Math.min(1, s / Math.max(i, a)), l = document.createElement("canvas");
|
|
419
419
|
l.width = Math.max(1, Math.round(i * c)), l.height = Math.max(1, Math.round(a * c));
|
|
420
420
|
let u = l.getContext("2d", { willReadFrequently: !0 });
|
|
421
421
|
if (!u) throw t();
|
|
422
422
|
u.drawImage(n, 0, 0, l.width, l.height);
|
|
423
423
|
let d = u.getImageData(0, 0, l.width, l.height).data, f;
|
|
424
424
|
if (r.useWorker !== !1 && typeof Worker < "u") try {
|
|
425
|
-
f = await
|
|
425
|
+
f = await ve(d, l.width, l.height, r);
|
|
426
426
|
} catch (t) {
|
|
427
427
|
if (t instanceof e && (t.code === "worker" || t.code === "model-http")) throw t;
|
|
428
428
|
f = {
|
|
@@ -445,7 +445,7 @@ async function L(n, r) {
|
|
|
445
445
|
modelError: v,
|
|
446
446
|
inferenceMs: y
|
|
447
447
|
};
|
|
448
|
-
if (p <
|
|
448
|
+
if (p < he) return {
|
|
449
449
|
status: "low-quality",
|
|
450
450
|
confidence: Math.min(.3, p / 18),
|
|
451
451
|
message: "The image is too soft or dark to resolve four document edges.",
|
|
@@ -461,7 +461,7 @@ async function L(n, r) {
|
|
|
461
461
|
sourceHeight: a,
|
|
462
462
|
...b
|
|
463
463
|
};
|
|
464
|
-
let x =
|
|
464
|
+
let x = _e(m.corners, c), S = I(x), C = r.minConfidence ?? .58;
|
|
465
465
|
return m.confidence < C ? {
|
|
466
466
|
status: "low-confidence",
|
|
467
467
|
quad: S,
|
|
@@ -482,15 +482,15 @@ async function L(n, r) {
|
|
|
482
482
|
...b
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
|
-
function
|
|
486
|
-
let n = Math.max(1, Math.round(Math.max(
|
|
485
|
+
function ye(e, t) {
|
|
486
|
+
let n = Math.max(1, Math.round(Math.max(F(e.topLeft, e.topRight), F(e.bottomLeft, e.bottomRight)))), r = Math.max(1, Math.round(Math.max(F(e.topLeft, e.bottomLeft), F(e.topRight, e.bottomRight)))), i = Math.min(1, t / Math.max(n, r));
|
|
487
487
|
return {
|
|
488
488
|
width: Math.max(1, Math.round(n * i)),
|
|
489
489
|
height: Math.max(1, Math.round(r * i))
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
|
-
function
|
|
493
|
-
let { width: i, height: a } =
|
|
492
|
+
function z(e, n, r) {
|
|
493
|
+
let { width: i, height: a } = ye(n, r), o = e.getContext("2d", { willReadFrequently: !0 });
|
|
494
494
|
if (!o) throw t();
|
|
495
495
|
let s = o.getImageData(0, 0, e.width, e.height), c = document.createElement("canvas");
|
|
496
496
|
c.width = i, c.height = a;
|
|
@@ -506,37 +506,37 @@ function R(e, n, r) {
|
|
|
506
506
|
}
|
|
507
507
|
return l.putImageData(u, 0, 0), c;
|
|
508
508
|
}
|
|
509
|
-
async function
|
|
510
|
-
return await x("scan"),
|
|
509
|
+
async function B(e, t = {}) {
|
|
510
|
+
return await x("scan"), R(await j(e, { cloneCanvas: !1 }), t);
|
|
511
511
|
}
|
|
512
|
-
async function
|
|
512
|
+
async function be(e, t, n = {}) {
|
|
513
513
|
await x("scan");
|
|
514
|
-
let r = await
|
|
514
|
+
let r = await j(e, { cloneCanvas: !1 }), i = n.maxOutputDimension ?? (L() ? 2048 : 4096);
|
|
515
515
|
return {
|
|
516
516
|
status: "success",
|
|
517
517
|
corners: t,
|
|
518
|
-
quad:
|
|
518
|
+
quad: I(t),
|
|
519
519
|
confidence: 1,
|
|
520
520
|
message: "Captured with the document edges shown in the finder.",
|
|
521
521
|
sourceWidth: r.width,
|
|
522
522
|
sourceHeight: r.height,
|
|
523
|
-
canvas:
|
|
523
|
+
canvas: z(r, t, i)
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
|
-
async function
|
|
526
|
+
async function xe(e, t = {}) {
|
|
527
527
|
await x("scan");
|
|
528
|
-
let n = await
|
|
528
|
+
let n = await j(e, { cloneCanvas: !1 }), r = await R(n, t);
|
|
529
529
|
if (r.status !== "success" || !r.corners) return r;
|
|
530
|
-
let i = t.maxOutputDimension ?? (
|
|
530
|
+
let i = t.maxOutputDimension ?? (L() ? 2048 : 4096);
|
|
531
531
|
return {
|
|
532
532
|
...r,
|
|
533
|
-
canvas:
|
|
533
|
+
canvas: z(n, r.corners, i),
|
|
534
534
|
message: "Four document edges detected and perspective-corrected."
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/sdk/camera.ts
|
|
539
|
-
function
|
|
539
|
+
function V(e, t) {
|
|
540
540
|
let { engine: n } = t;
|
|
541
541
|
return [
|
|
542
542
|
`${e}:`,
|
|
@@ -551,9 +551,9 @@ function B(e, t) {
|
|
|
551
551
|
` torch: ${t.torch.mode} supported=${t.torch.supported} on=${t.torch.on}`
|
|
552
552
|
].join("\n");
|
|
553
553
|
}
|
|
554
|
-
function
|
|
554
|
+
function Se(e) {
|
|
555
555
|
let t = ["Exige scanner capture report", `time: ${e.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString()}`];
|
|
556
|
-
if (e.error && t.push(`error: ${e.error}`), e.captureMethod && t.push(`method: ${e.captureMethod}`), e.luminance !== void 0 && t.push(`luminance: ${e.luminance.toFixed(1)}`), e.fallbackReason && t.push(`fallback: ${e.fallbackReason}`), e.shutter && t.push(
|
|
556
|
+
if (e.error && t.push(`error: ${e.error}`), e.captureMethod && t.push(`method: ${e.captureMethod}`), e.luminance !== void 0 && t.push(`luminance: ${e.luminance.toFixed(1)}`), e.fallbackReason && t.push(`fallback: ${e.fallbackReason}`), e.shutter && t.push(V("shutter", e.shutter)), e.live && t.push(V("live", e.live)), e.finder) {
|
|
557
557
|
let n = e.finder;
|
|
558
558
|
t.push([
|
|
559
559
|
"finder:",
|
|
@@ -566,7 +566,7 @@ function Ce(e) {
|
|
|
566
566
|
}
|
|
567
567
|
return `${t.join("\n")}\n`;
|
|
568
568
|
}
|
|
569
|
-
function
|
|
569
|
+
function H(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof navigator > "u" ? 0 : navigator.maxTouchPoints) {
|
|
570
570
|
let n = /CriOS|Chrome/i.test(e) ? "chrome" : /EdgiOS|Edg/i.test(e) ? "edge" : /FxiOS|Firefox/i.test(e) ? "firefox" : /Safari/i.test(e) ? "safari" : "unknown", r = /iPhone|iPad|iPod/i.test(e) || /Macintosh/i.test(e) && t > 1, i = /CriOS|EdgiOS|FxiOS|OPiOS|Mercury/i.test(e), a = r || i;
|
|
571
571
|
return {
|
|
572
572
|
engine: a || /AppleWebKit/i.test(e) && !/Chrome|Chromium|Edg/i.test(e) ? "webkit" : /Chrome|Chromium|Edg/i.test(e) ? "blink" : /Gecko\//i.test(e) ? "gecko" : "unknown",
|
|
@@ -575,12 +575,12 @@ function V(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof nav
|
|
|
575
575
|
userAgent: e
|
|
576
576
|
};
|
|
577
577
|
}
|
|
578
|
-
var we = 1920, Te = 1280;
|
|
579
|
-
function
|
|
580
|
-
let t = e ??
|
|
578
|
+
var Ce = 1080, we = 1920, Te = 1920, Ee = 1280;
|
|
579
|
+
function U(e) {
|
|
580
|
+
let t = e ?? H();
|
|
581
581
|
return !t.iosWebKit && t.browser === "chrome" && /Android/i.test(t.userAgent) && !/Edg|OPR|SamsungBrowser/i.test(t.userAgent);
|
|
582
582
|
}
|
|
583
|
-
var
|
|
583
|
+
var De = 10, W = class {
|
|
584
584
|
on = !1;
|
|
585
585
|
darkCount = 0;
|
|
586
586
|
brightCount = 0;
|
|
@@ -603,7 +603,7 @@ var Ee = 10, U = class {
|
|
|
603
603
|
return this.on;
|
|
604
604
|
}
|
|
605
605
|
};
|
|
606
|
-
function
|
|
606
|
+
function G(e, t) {
|
|
607
607
|
return t ? e === "alwaysOn" || e === "alwaysOff" ? {
|
|
608
608
|
mode: e,
|
|
609
609
|
supported: !0,
|
|
@@ -627,37 +627,37 @@ function W(e, t) {
|
|
|
627
627
|
automatic: e === "auto"
|
|
628
628
|
};
|
|
629
629
|
}
|
|
630
|
-
function
|
|
630
|
+
function K(e) {
|
|
631
631
|
let t = Math.floor(e.length / 4);
|
|
632
632
|
if (!t) return 0;
|
|
633
633
|
let n = 0;
|
|
634
634
|
for (let r = 0; r < t * 4; r += 4) n += e[r] * .299 + e[r + 1] * .587 + e[r + 2] * .114;
|
|
635
635
|
return n / t;
|
|
636
636
|
}
|
|
637
|
-
function
|
|
637
|
+
function Oe(e, t = 10) {
|
|
638
638
|
if (e.length < 4) return !0;
|
|
639
639
|
let n = Math.floor(e.length / 4), r = 0;
|
|
640
640
|
for (let i = 0; i < n * 4; i += 4) e[i] * .299 + e[i + 1] * .587 + e[i + 2] * .114 > t * 2 && (r += 1);
|
|
641
|
-
return
|
|
641
|
+
return K(e) <= t && r / n < .01;
|
|
642
642
|
}
|
|
643
|
-
function
|
|
643
|
+
function q(e, t, n) {
|
|
644
644
|
if (!t || !n) return 0;
|
|
645
645
|
let r = document.createElement("canvas");
|
|
646
646
|
r.width = Math.min(32, t), r.height = Math.min(32, n);
|
|
647
647
|
let i = r.getContext("2d", { willReadFrequently: !0 });
|
|
648
|
-
return i ? (i.drawImage(e, 0, 0, r.width, r.height),
|
|
648
|
+
return i ? (i.drawImage(e, 0, 0, r.width, r.height), K(i.getImageData(0, 0, r.width, r.height).data)) : 0;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
return
|
|
650
|
+
function ke(e) {
|
|
651
|
+
return q(e, e.width, e.height);
|
|
652
652
|
}
|
|
653
|
-
function
|
|
653
|
+
function Ae(e, t = 120) {
|
|
654
654
|
let n = document.createElement("canvas"), r = n.getContext("2d"), i = typeof e.requestVideoFrameCallback == "function", a = !0, o = 0, s = 0, c = 0, l = 0, u = 0, d = () => {
|
|
655
655
|
a && (o = i ? e.requestVideoFrameCallback(f) : requestAnimationFrame(f));
|
|
656
656
|
};
|
|
657
657
|
function f() {
|
|
658
658
|
if (!a) return;
|
|
659
659
|
let { videoWidth: i, videoHeight: o } = e, f = performance.now();
|
|
660
|
-
r && i && o && f - s >= t && (s = f, l =
|
|
660
|
+
r && i && o && f - s >= t && (s = f, l = q(e, i, o), l > 10 && ((n.width !== i || n.height !== o) && (n.width = i, n.height = o), r.drawImage(e, 0, 0, i, o), u = l, c = f)), d();
|
|
661
661
|
}
|
|
662
662
|
return d(), {
|
|
663
663
|
stop() {
|
|
@@ -669,13 +669,13 @@ function ke(e, t = 120) {
|
|
|
669
669
|
getMirrorAgeMs: () => c ? performance.now() - c : Infinity
|
|
670
670
|
};
|
|
671
671
|
}
|
|
672
|
-
function
|
|
672
|
+
function je(e) {
|
|
673
673
|
let t = document.createElement("canvas");
|
|
674
674
|
return t.width = e.width, t.height = e.height, t.getContext("2d")?.drawImage(e, 0, 0), t;
|
|
675
675
|
}
|
|
676
|
-
function
|
|
677
|
-
let n =
|
|
678
|
-
return e.maxWidth
|
|
676
|
+
function J(e = {}, t = H()) {
|
|
677
|
+
let n = U(t), r = e.idealWidth ?? (n ? 1080 : 3840), i = e.idealHeight ?? (n ? 1920 : 2160), a = { ideal: r }, o = { ideal: i };
|
|
678
|
+
return e.maxWidth && (a.max = e.maxWidth), e.maxHeight ? o.max = e.maxHeight : n && e.maxWidth === void 0 && (o.max = Te), {
|
|
679
679
|
audio: !1,
|
|
680
680
|
video: {
|
|
681
681
|
facingMode: { ideal: e.facingMode ?? "environment" },
|
|
@@ -688,42 +688,65 @@ function q(e = {}, t = V()) {
|
|
|
688
688
|
}
|
|
689
689
|
};
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function Me(e, t, n) {
|
|
692
|
+
let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
|
|
693
|
+
return {
|
|
694
|
+
width: Math.max(1, Math.round(e * r)),
|
|
695
|
+
height: Math.max(1, Math.round(t * r))
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function Y(e, n) {
|
|
692
699
|
if (!e.videoWidth || !e.videoHeight) throw Error("The camera is not ready to capture a frame.");
|
|
693
|
-
let r =
|
|
694
|
-
i.width =
|
|
700
|
+
let r = Me(e.videoWidth, e.videoHeight, n), i = document.createElement("canvas");
|
|
701
|
+
i.width = r.width, i.height = r.height;
|
|
695
702
|
let a = i.getContext("2d");
|
|
696
703
|
if (!a) throw t();
|
|
697
704
|
return a.drawImage(e, 0, 0, i.width, i.height), i;
|
|
698
705
|
}
|
|
699
|
-
function
|
|
700
|
-
let t =
|
|
701
|
-
return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [
|
|
702
|
-
|
|
706
|
+
function Ne(e) {
|
|
707
|
+
let t = H();
|
|
708
|
+
return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [J(e, t)] : U(t) ? [
|
|
709
|
+
J({
|
|
710
|
+
...e,
|
|
711
|
+
idealWidth: Ce,
|
|
712
|
+
idealHeight: we
|
|
713
|
+
}, t),
|
|
714
|
+
J({
|
|
715
|
+
...e,
|
|
716
|
+
idealWidth: 720,
|
|
717
|
+
idealHeight: 1280
|
|
718
|
+
}, t),
|
|
719
|
+
J({
|
|
720
|
+
...e,
|
|
721
|
+
idealWidth: 1920,
|
|
722
|
+
idealHeight: 1080
|
|
723
|
+
}, t)
|
|
724
|
+
] : [
|
|
725
|
+
J({
|
|
703
726
|
...e,
|
|
704
727
|
idealWidth: 3840,
|
|
705
728
|
idealHeight: 2160
|
|
706
729
|
}, t),
|
|
707
|
-
|
|
730
|
+
J({
|
|
708
731
|
...e,
|
|
709
732
|
idealWidth: 2560,
|
|
710
733
|
idealHeight: 1440
|
|
711
734
|
}, t),
|
|
712
|
-
|
|
735
|
+
J({
|
|
713
736
|
...e,
|
|
714
737
|
idealWidth: 1920,
|
|
715
738
|
idealHeight: 1080
|
|
716
739
|
}, t)
|
|
717
740
|
];
|
|
718
741
|
}
|
|
719
|
-
async function
|
|
742
|
+
async function Pe(t, n = {}) {
|
|
720
743
|
await x("scan");
|
|
721
744
|
let r = n.torch ?? "alwaysOff";
|
|
722
745
|
if (r !== "alwaysOff" && await x("torch"), !window.isSecureContext && location.hostname !== "localhost") throw new e("secure-context", "Camera access requires HTTPS.");
|
|
723
746
|
if (!navigator.mediaDevices?.getUserMedia) throw Error("Live camera access is unavailable. Use the native camera picker instead.");
|
|
724
747
|
t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.setAttribute("playsinline", "");
|
|
725
748
|
let i, a;
|
|
726
|
-
for (let e of
|
|
749
|
+
for (let e of Ne(n)) try {
|
|
727
750
|
i = await navigator.mediaDevices.getUserMedia(e);
|
|
728
751
|
break;
|
|
729
752
|
} catch (e) {
|
|
@@ -736,7 +759,7 @@ async function Me(t, n = {}) {
|
|
|
736
759
|
for (let e of i.getTracks()) e.stop();
|
|
737
760
|
throw Error("The camera did not provide a video track.");
|
|
738
761
|
}
|
|
739
|
-
let s =
|
|
762
|
+
let s = Ae(t), c = "ImageCapture" in globalThis, l = G(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
|
|
740
763
|
if (!l.supported || o.readyState !== "live") return !1;
|
|
741
764
|
try {
|
|
742
765
|
return await o.applyConstraints({ advanced: [{ torch: e }] }), l = {
|
|
@@ -754,7 +777,7 @@ async function Me(t, n = {}) {
|
|
|
754
777
|
}
|
|
755
778
|
};
|
|
756
779
|
l.on && await d(!0);
|
|
757
|
-
let f = r === "auto" && l.supported ? new
|
|
780
|
+
let f = r === "auto" && l.supported ? new W() : void 0, p = f ? window.setInterval(() => {
|
|
758
781
|
if (u || !l.supported) return;
|
|
759
782
|
let e = f.update(s.getLiveLuminance());
|
|
760
783
|
e !== void 0 && e !== l.on && (u = !0, d(e).finally(() => {
|
|
@@ -780,7 +803,7 @@ async function Me(t, n = {}) {
|
|
|
780
803
|
torchSupported: l.supported,
|
|
781
804
|
torchOn: l.on,
|
|
782
805
|
torch: { ...l },
|
|
783
|
-
engine:
|
|
806
|
+
engine: H()
|
|
784
807
|
};
|
|
785
808
|
};
|
|
786
809
|
return {
|
|
@@ -794,15 +817,15 @@ async function Me(t, n = {}) {
|
|
|
794
817
|
get torchOn() {
|
|
795
818
|
return l.on;
|
|
796
819
|
},
|
|
797
|
-
capture: (e) =>
|
|
820
|
+
capture: (e) => Y(t, e),
|
|
798
821
|
async capturePhoto() {
|
|
799
822
|
let e, n = 0;
|
|
800
823
|
try {
|
|
801
|
-
e =
|
|
824
|
+
e = Y(t), n = ke(e);
|
|
802
825
|
} catch {
|
|
803
826
|
e = void 0;
|
|
804
827
|
}
|
|
805
|
-
let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ?
|
|
828
|
+
let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ? je(r) : void 0);
|
|
806
829
|
if (!a) throw Error("The camera preview produced no visible pixels. Keep the scanner on screen, wait for the preview, and retake.");
|
|
807
830
|
return {
|
|
808
831
|
frame: a,
|
|
@@ -827,13 +850,59 @@ async function Me(t, n = {}) {
|
|
|
827
850
|
};
|
|
828
851
|
}
|
|
829
852
|
//#endregion
|
|
853
|
+
//#region src/sdk/preview-frame.ts
|
|
854
|
+
function Fe(e) {
|
|
855
|
+
let t = e.parentElement?.getBoundingClientRect();
|
|
856
|
+
return t && t.width > 0 && t.height > 0 ? t : e.getBoundingClientRect();
|
|
857
|
+
}
|
|
858
|
+
function Ie(e, t, n, r) {
|
|
859
|
+
let i = Math.max(1, e), a = Math.max(1, t);
|
|
860
|
+
if (n <= 0 || r <= 0) return {
|
|
861
|
+
sx: 0,
|
|
862
|
+
sy: 0,
|
|
863
|
+
sw: i,
|
|
864
|
+
sh: a
|
|
865
|
+
};
|
|
866
|
+
let o = i / a, s = n / r;
|
|
867
|
+
if (o > s) {
|
|
868
|
+
let e = a * s;
|
|
869
|
+
return {
|
|
870
|
+
sx: (i - e) / 2,
|
|
871
|
+
sy: 0,
|
|
872
|
+
sw: e,
|
|
873
|
+
sh: a
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
let c = i / s;
|
|
877
|
+
return {
|
|
878
|
+
sx: 0,
|
|
879
|
+
sy: (a - c) / 2,
|
|
880
|
+
sw: i,
|
|
881
|
+
sh: c
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function Le(e, t, n, r, i) {
|
|
885
|
+
let a = Ie(e, t, n, r);
|
|
886
|
+
return {
|
|
887
|
+
crop: a,
|
|
888
|
+
size: Me(a.sw, a.sh, i)
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function Re(e, n, r, i, a, o) {
|
|
892
|
+
let { crop: s, size: c } = Le(n, r, i, a, o), l = document.createElement("canvas");
|
|
893
|
+
l.width = c.width, l.height = c.height;
|
|
894
|
+
let u = l.getContext("2d");
|
|
895
|
+
if (!u) throw t();
|
|
896
|
+
return u.drawImage(e, s.sx, s.sy, s.sw, s.sh, 0, 0, c.width, c.height), l;
|
|
897
|
+
}
|
|
898
|
+
//#endregion
|
|
830
899
|
//#region src/sdk/lighting.ts
|
|
831
|
-
function
|
|
900
|
+
function ze(e, t) {
|
|
832
901
|
if (!e.length) return 0;
|
|
833
902
|
let n = [...e].sort((e, t) => e - t);
|
|
834
903
|
return n[Math.min(n.length - 1, Math.floor(n.length * t))];
|
|
835
904
|
}
|
|
836
|
-
function
|
|
905
|
+
function Be(e, t, n, r = 12) {
|
|
837
906
|
if (!t || !n || e.length < t * n) return {
|
|
838
907
|
strong: !1,
|
|
839
908
|
strength: 0,
|
|
@@ -856,7 +925,7 @@ function Pe(e, t, n, r = 12) {
|
|
|
856
925
|
});
|
|
857
926
|
}
|
|
858
927
|
}
|
|
859
|
-
let s =
|
|
928
|
+
let s = ze(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
|
|
860
929
|
for (let e = 0; e < o.length; e += 1) {
|
|
861
930
|
if (!c[e] || l[e]) continue;
|
|
862
931
|
let t = [], n = [e];
|
|
@@ -904,7 +973,7 @@ function Pe(e, t, n, r = 12) {
|
|
|
904
973
|
}
|
|
905
974
|
return d;
|
|
906
975
|
}
|
|
907
|
-
function
|
|
976
|
+
function Ve(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
|
|
908
977
|
let i = t + 1, a = new Uint32Array((t + 1) * (n + 1));
|
|
909
978
|
for (let r = 1; r <= n; r += 1) {
|
|
910
979
|
let n = 0;
|
|
@@ -920,7 +989,7 @@ function Fe(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
|
|
|
920
989
|
}
|
|
921
990
|
return o;
|
|
922
991
|
}
|
|
923
|
-
function
|
|
992
|
+
function He(e, t, n) {
|
|
924
993
|
let r = [
|
|
925
994
|
e.topLeft,
|
|
926
995
|
e.topRight,
|
|
@@ -934,8 +1003,8 @@ function Ie(e, t, n) {
|
|
|
934
1003
|
height: s - a
|
|
935
1004
|
};
|
|
936
1005
|
}
|
|
937
|
-
function
|
|
938
|
-
let n =
|
|
1006
|
+
function Ue(e, t) {
|
|
1007
|
+
let n = He(t, e.width, e.height);
|
|
939
1008
|
if (n.width <= 0 || n.height <= 0) return {
|
|
940
1009
|
strong: !1,
|
|
941
1010
|
strength: 0,
|
|
@@ -954,18 +1023,18 @@ function Le(e, t) {
|
|
|
954
1023
|
i.drawImage(e, n.left, n.top, n.width, n.height, 0, 0, r.width, r.height);
|
|
955
1024
|
let a = i.getImageData(0, 0, r.width, r.height).data, o = new Uint8Array(r.width * r.height);
|
|
956
1025
|
for (let e = 0, t = 0; e < o.length; e += 1, t += 4) o[e] = Math.round(a[t] * .299 + a[t + 1] * .587 + a[t + 2] * .114);
|
|
957
|
-
return
|
|
1026
|
+
return Be(o, r.width, r.height);
|
|
958
1027
|
}
|
|
959
1028
|
//#endregion
|
|
960
1029
|
//#region src/sdk/finder.ts
|
|
961
|
-
function
|
|
1030
|
+
function We(e, t) {
|
|
962
1031
|
return t.castShadow && (e.reason === "hold-still" || e.reason === "ready") ? t.hint ?? e.hint : e.hint;
|
|
963
1032
|
}
|
|
964
|
-
async function
|
|
1033
|
+
async function Ge(e, t) {
|
|
965
1034
|
let n = await e();
|
|
966
1035
|
return t(), n;
|
|
967
1036
|
}
|
|
968
|
-
function
|
|
1037
|
+
function Ke(e) {
|
|
969
1038
|
return e === "alwaysOn" || e === "only" ? {
|
|
970
1039
|
visible: !1,
|
|
971
1040
|
checked: !0,
|
|
@@ -980,7 +1049,7 @@ function Be(e) {
|
|
|
980
1049
|
mutable: !0
|
|
981
1050
|
};
|
|
982
1051
|
}
|
|
983
|
-
function
|
|
1052
|
+
function X(e) {
|
|
984
1053
|
return [
|
|
985
1054
|
e.topLeft,
|
|
986
1055
|
e.topRight,
|
|
@@ -988,11 +1057,11 @@ function Y(e) {
|
|
|
988
1057
|
e.bottomLeft
|
|
989
1058
|
];
|
|
990
1059
|
}
|
|
991
|
-
var
|
|
992
|
-
function
|
|
993
|
-
return
|
|
1060
|
+
var qe = 1600;
|
|
1061
|
+
function Je(e = H()) {
|
|
1062
|
+
return U(e) ? Ee : qe;
|
|
994
1063
|
}
|
|
995
|
-
function
|
|
1064
|
+
function Ye(e) {
|
|
996
1065
|
let t = 0;
|
|
997
1066
|
for (let n = 0; n < e.length; n += 1) {
|
|
998
1067
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -1000,42 +1069,42 @@ function Ue(e) {
|
|
|
1000
1069
|
}
|
|
1001
1070
|
return Math.abs(t) / 2;
|
|
1002
1071
|
}
|
|
1003
|
-
function
|
|
1072
|
+
function Z(e, t) {
|
|
1004
1073
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
1005
1074
|
}
|
|
1006
|
-
var
|
|
1075
|
+
var Q = {
|
|
1007
1076
|
widthFill: 0,
|
|
1008
1077
|
heightFill: 0,
|
|
1009
1078
|
limitingFill: 0,
|
|
1010
1079
|
areaFill: 0,
|
|
1011
1080
|
aspectRatio: 1
|
|
1012
1081
|
};
|
|
1013
|
-
function
|
|
1014
|
-
let r =
|
|
1082
|
+
function Xe(e, t, n) {
|
|
1083
|
+
let r = X(e), i = r.map(({ x: e }) => e), a = r.map(({ y: e }) => e), o = (Math.max(...i) - Math.min(...i)) / Math.max(1, t), s = (Math.max(...a) - Math.min(...a)) / Math.max(1, n), [c, l, u, d] = r, f = Math.max(Z(c, l), Z(d, u)), p = Math.max(Z(c, d), Z(l, u));
|
|
1015
1084
|
return {
|
|
1016
1085
|
widthFill: o,
|
|
1017
1086
|
heightFill: s,
|
|
1018
1087
|
limitingFill: Math.max(o, s),
|
|
1019
|
-
areaFill:
|
|
1088
|
+
areaFill: Ye(r) / Math.max(1, t * n),
|
|
1020
1089
|
aspectRatio: Math.max(f, p) / Math.max(1, Math.min(f, p))
|
|
1021
1090
|
};
|
|
1022
1091
|
}
|
|
1023
|
-
function
|
|
1092
|
+
function Ze(e, t, n, r = {}) {
|
|
1024
1093
|
let i = t ? r.exitFillRatio ?? .64 : r.minFillRatio ?? .72, a = r.highAspectRatio ?? 2.2;
|
|
1025
1094
|
if (e.aspectRatio < a) return i;
|
|
1026
1095
|
let o = t ? r.highAspectExitFillRatio : r.highAspectFillRatio;
|
|
1027
1096
|
return Math.min(o ?? i + .08, 1 - n * 2);
|
|
1028
1097
|
}
|
|
1029
|
-
function
|
|
1098
|
+
function Qe(e, t, n = {}) {
|
|
1030
1099
|
let r = n.confidenceThreshold ?? .72;
|
|
1031
1100
|
if (e.status !== "success" || !e.quad || e.confidence < r || !e.sourceWidth || !e.sourceHeight) return {
|
|
1032
1101
|
hint: "Place the document in the frame",
|
|
1033
1102
|
reason: "place-document",
|
|
1034
1103
|
fillRatio: 0,
|
|
1035
|
-
fill:
|
|
1104
|
+
fill: Q,
|
|
1036
1105
|
readyForAutoCapture: !1
|
|
1037
1106
|
};
|
|
1038
|
-
let i =
|
|
1107
|
+
let i = X(e.quad), a = Xe(e.quad, e.sourceWidth, e.sourceHeight), o = a.limitingFill, s = t.previouslyReady ? n.exitEdgeMarginRatio ?? .005 : n.edgeMarginRatio ?? .015, c = e.sourceWidth * s, l = e.sourceHeight * s;
|
|
1039
1108
|
if (i.some(({ x: t, y: n }) => t <= c || t >= e.sourceWidth - c || n <= l || n >= e.sourceHeight - l)) return {
|
|
1040
1109
|
hint: "Move farther away",
|
|
1041
1110
|
reason: "move-farther-away",
|
|
@@ -1043,14 +1112,14 @@ function Q(e, t, n = {}) {
|
|
|
1043
1112
|
fill: a,
|
|
1044
1113
|
readyForAutoCapture: !1
|
|
1045
1114
|
};
|
|
1046
|
-
let [u, d, f, p] = i, m =
|
|
1115
|
+
let [u, d, f, p] = i, m = Z(u, d), h = Z(d, f), g = Z(f, p), _ = Z(p, u);
|
|
1047
1116
|
return Math.min(Math.min(m, g) / Math.max(1, Math.max(m, g)), Math.min(_, h) / Math.max(1, Math.max(_, h))) < (t.previouslyReady ? n.exitMinPerspectiveRatio ?? .4 : n.minPerspectiveRatio ?? .48) ? {
|
|
1048
1117
|
hint: "Hold the camera straight",
|
|
1049
1118
|
reason: "straighten-camera",
|
|
1050
1119
|
fillRatio: o,
|
|
1051
1120
|
fill: a,
|
|
1052
1121
|
readyForAutoCapture: !1
|
|
1053
|
-
} : o <
|
|
1122
|
+
} : o < Ze(a, t.previouslyReady === !0, s, n) ? {
|
|
1054
1123
|
hint: "Move closer",
|
|
1055
1124
|
reason: "move-closer",
|
|
1056
1125
|
fillRatio: o,
|
|
@@ -1081,8 +1150,8 @@ var $ = class {
|
|
|
1081
1150
|
ready: !1,
|
|
1082
1151
|
movement: Infinity
|
|
1083
1152
|
};
|
|
1084
|
-
let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...
|
|
1085
|
-
let r =
|
|
1153
|
+
let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...X(e.quad).map((e, n) => {
|
|
1154
|
+
let r = X(this.previous)[n];
|
|
1086
1155
|
return Math.hypot(e.x - r.x, e.y - r.y) / Math.max(1, t);
|
|
1087
1156
|
})) : Infinity, r = this.options.exitCornerTolerance ?? Math.max(this.options.cornerTolerance, .036);
|
|
1088
1157
|
return this.ready && this.previous && n <= r ? this.count = Math.max(this.options.stableFrames, this.count + 1) : (this.ready = !1, this.count = this.previous && n <= this.options.cornerTolerance ? this.count + 1 : 1, this.count >= this.options.stableFrames && (this.ready = !0)), this.previous = e.quad, {
|
|
@@ -1092,14 +1161,13 @@ var $ = class {
|
|
|
1092
1161
|
};
|
|
1093
1162
|
}
|
|
1094
1163
|
};
|
|
1095
|
-
function
|
|
1096
|
-
let
|
|
1097
|
-
|
|
1098
|
-
let
|
|
1099
|
-
|
|
1100
|
-
return a.drawImage(e, 0, 0, i.width, i.height), i;
|
|
1164
|
+
function $e(e, t) {
|
|
1165
|
+
let n = e instanceof HTMLVideoElement ? e.videoWidth : e.width, r = e instanceof HTMLVideoElement ? e.videoHeight : e.height;
|
|
1166
|
+
if (!n || !r) throw Error("The camera is not ready to capture a frame.");
|
|
1167
|
+
let i = Fe(e);
|
|
1168
|
+
return Re(e, n, r, i.width, i.height, t);
|
|
1101
1169
|
}
|
|
1102
|
-
function
|
|
1170
|
+
function et() {
|
|
1103
1171
|
let e = window.AudioContext ?? window.webkitAudioContext;
|
|
1104
1172
|
if (!e) return;
|
|
1105
1173
|
let t = new e(), n = Math.round(t.sampleRate * .09), r = t.createBuffer(1, n, t.sampleRate), i = r.getChannelData(0);
|
|
@@ -1110,29 +1178,29 @@ function qe() {
|
|
|
1110
1178
|
let a = t.createBufferSource(), o = t.createBiquadFilter(), s = t.createGain();
|
|
1111
1179
|
o.type = "bandpass", o.frequency.value = 1400, s.gain.value = .42, a.buffer = r, a.connect(o).connect(s).connect(t.destination), a.start(), a.onended = () => void t.close();
|
|
1112
1180
|
}
|
|
1113
|
-
async function
|
|
1181
|
+
async function tt(e) {
|
|
1114
1182
|
let t = document.createElement("video");
|
|
1115
1183
|
return t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.srcObject = e, await t.play(), t;
|
|
1116
1184
|
}
|
|
1117
|
-
async function
|
|
1185
|
+
async function nt(t) {
|
|
1118
1186
|
await x("scan");
|
|
1119
|
-
let n =
|
|
1187
|
+
let n = Ke(t.autoCapture), r = new $({
|
|
1120
1188
|
stableFrames: t.stableFrames ?? 4,
|
|
1121
1189
|
confidenceThreshold: t.confidenceThreshold ?? .72,
|
|
1122
1190
|
cornerTolerance: t.cornerTolerance ?? .024,
|
|
1123
1191
|
exitCornerTolerance: t.exitCornerTolerance ?? .036
|
|
1124
|
-
}), i = t.maxFrameDimension ??
|
|
1192
|
+
}), i = t.maxFrameDimension ?? Je(), a = t.intervalMs ?? 140, o = {
|
|
1125
1193
|
minDimension: 220,
|
|
1126
1194
|
maxAnalysisDimension: i,
|
|
1127
1195
|
...t.detection
|
|
1128
|
-
}, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await
|
|
1196
|
+
}, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await tt(t.source) : t.source, c = !0, l = !1, u = !1, d = 0, f, p = {
|
|
1129
1197
|
state: "detecting",
|
|
1130
1198
|
confidence: 0,
|
|
1131
1199
|
guidance: {
|
|
1132
1200
|
hint: "Place the document in the frame",
|
|
1133
1201
|
reason: "place-document",
|
|
1134
1202
|
fillRatio: 0,
|
|
1135
|
-
fill:
|
|
1203
|
+
fill: Q,
|
|
1136
1204
|
readyForAutoCapture: !1
|
|
1137
1205
|
},
|
|
1138
1206
|
lighting: {
|
|
@@ -1142,7 +1210,7 @@ async function Ye(t) {
|
|
|
1142
1210
|
stableFrames: 0,
|
|
1143
1211
|
requiredStableFrames: t.stableFrames ?? 4,
|
|
1144
1212
|
autoCapture: { ...n }
|
|
1145
|
-
}, m = () =>
|
|
1213
|
+
}, m = () => $e(s, i), h = (e) => {
|
|
1146
1214
|
p = e, t.onStatus?.(e);
|
|
1147
1215
|
}, g = () => {
|
|
1148
1216
|
c = !1, window.clearTimeout(d), s instanceof HTMLVideoElement && s !== t.source && (s.srcObject = null);
|
|
@@ -1151,11 +1219,11 @@ async function Ye(t) {
|
|
|
1151
1219
|
l = !0;
|
|
1152
1220
|
let n;
|
|
1153
1221
|
try {
|
|
1154
|
-
n = await
|
|
1222
|
+
n = await Ge(t.captureFrame ?? m, () => {
|
|
1155
1223
|
h({
|
|
1156
1224
|
...p,
|
|
1157
1225
|
state: "captured"
|
|
1158
|
-
}), t.playShutterSound !== !1 &&
|
|
1226
|
+
}), t.playShutterSound !== !1 && et(), g();
|
|
1159
1227
|
});
|
|
1160
1228
|
} catch (e) {
|
|
1161
1229
|
throw l = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
|
|
@@ -1169,9 +1237,9 @@ async function Ye(t) {
|
|
|
1169
1237
|
}, v = async () => {
|
|
1170
1238
|
if (c && !l) {
|
|
1171
1239
|
try {
|
|
1172
|
-
let e = m(), i = await
|
|
1240
|
+
let e = m(), i = await B(e, o);
|
|
1173
1241
|
f = i;
|
|
1174
|
-
let a = i.quad ?
|
|
1242
|
+
let a = i.quad ? Ue(e, i.quad) : {
|
|
1175
1243
|
strong: !1,
|
|
1176
1244
|
strength: 0
|
|
1177
1245
|
}, s = a.strong ? {
|
|
@@ -1181,7 +1249,7 @@ async function Ye(t) {
|
|
|
1181
1249
|
} : {
|
|
1182
1250
|
castShadow: !1,
|
|
1183
1251
|
strength: a.strength
|
|
1184
|
-
}, c = r.update(i), l =
|
|
1252
|
+
}, c = r.update(i), l = Qe(i, {
|
|
1185
1253
|
...c,
|
|
1186
1254
|
previouslyReady: u
|
|
1187
1255
|
}, {
|
|
@@ -1226,7 +1294,7 @@ async function Ye(t) {
|
|
|
1226
1294
|
hint: "Place the document in the frame",
|
|
1227
1295
|
reason: "place-document",
|
|
1228
1296
|
fillRatio: 0,
|
|
1229
|
-
fill:
|
|
1297
|
+
fill: Q,
|
|
1230
1298
|
readyForAutoCapture: !1
|
|
1231
1299
|
},
|
|
1232
1300
|
lighting: {
|
|
@@ -1255,6 +1323,6 @@ async function Ye(t) {
|
|
|
1255
1323
|
};
|
|
1256
1324
|
}
|
|
1257
1325
|
//#endregion
|
|
1258
|
-
export { a as A,
|
|
1326
|
+
export { a as A, M as C, j as D, de as E, e as F, t as I, x as M, b as N, ie as O, y as P, B as S, ue as T, J as _, Qe as a, fe as b, Be as c, De as d, Y as f, K as g, Oe as h, Xe as i, o as j, ne as k, Ve as l, Se as m, Ke as n, We as o, H as p, Ze as r, nt as s, $ as t, W as u, Pe as v, xe as w, be as x, G as y };
|
|
1259
1327
|
|
|
1260
|
-
//# sourceMappingURL=finder-
|
|
1328
|
+
//# sourceMappingURL=finder-D0Wgl-6-.js.map
|