@exige/web-scanner-sdk 0.2.13 → 0.2.14
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/assets/document-worker.js +1 -1
- package/dist/assets/document-worker.js.map +1 -1
- package/dist/{finder-CLEe-Zhj.js → finder-DdnCpnjz.js} +153 -154
- package/dist/finder-DdnCpnjz.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/scanner-sdk.js +1 -1
- package/dist/sdk/camera.d.ts +8 -4
- package/dist/sdk/finder.d.ts +3 -1
- package/dist/sdk/scan.d.ts +3 -0
- package/package.json +1 -1
- package/dist/finder-CLEe-Zhj.js.map +0 -1
|
@@ -198,22 +198,22 @@ function te() {
|
|
|
198
198
|
total: n ? t : null
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function O() {
|
|
202
202
|
let e = te();
|
|
203
203
|
for (let t of T) t(e);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function ne(e) {
|
|
206
206
|
return e(te()), T.add(e), () => {
|
|
207
207
|
T.delete(e);
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function k(e, t) {
|
|
211
211
|
t.done ? w.delete(e) : w.set(e, {
|
|
212
212
|
loaded: t.loaded,
|
|
213
213
|
total: t.total
|
|
214
|
-
}),
|
|
214
|
+
}), O();
|
|
215
215
|
}
|
|
216
|
-
async function
|
|
216
|
+
async function re(e, t) {
|
|
217
217
|
let n = ee(e);
|
|
218
218
|
if (!e.body) {
|
|
219
219
|
let r = await e.arrayBuffer();
|
|
@@ -238,53 +238,53 @@ async function ie(e, t) {
|
|
|
238
238
|
total: n
|
|
239
239
|
}), o.buffer;
|
|
240
240
|
}
|
|
241
|
-
async function
|
|
241
|
+
async function ie(t, n) {
|
|
242
242
|
let r = E.get(t);
|
|
243
243
|
if (r) return r.slice(0);
|
|
244
244
|
let i = D.get(t);
|
|
245
245
|
if (i) return i.then((e) => e.slice(0));
|
|
246
246
|
let a = (async () => {
|
|
247
|
-
|
|
247
|
+
k(t, {
|
|
248
248
|
loaded: 0,
|
|
249
249
|
total: null
|
|
250
250
|
});
|
|
251
251
|
let r = await fetch(t, { cache: n?.cache });
|
|
252
252
|
if (!r.ok) throw new e("model-http", `Model request failed with HTTP ${r.status}.`);
|
|
253
|
-
return
|
|
253
|
+
return re(r, (e) => k(t, e));
|
|
254
254
|
})();
|
|
255
255
|
D.set(t, a);
|
|
256
256
|
try {
|
|
257
257
|
let e = await a;
|
|
258
258
|
return E.set(t, e), e.slice(0);
|
|
259
259
|
} finally {
|
|
260
|
-
D.delete(t), w.has(t) && (w.delete(t),
|
|
260
|
+
D.delete(t), w.has(t) && (w.delete(t), O());
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/sdk/ort-runtime.ts
|
|
265
|
-
var
|
|
266
|
-
function
|
|
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 se() {
|
|
267
267
|
return {
|
|
268
|
-
wasm:
|
|
269
|
-
mjs:
|
|
268
|
+
wasm: ae.href,
|
|
269
|
+
mjs: oe.href
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
272
|
function ce(e) {
|
|
273
|
-
return typeof e == "string" ? e.trim() ||
|
|
273
|
+
return typeof e == "string" ? e.trim() || se() : e?.wasm.trim() && e.mjs.trim() ? {
|
|
274
274
|
wasm: e.wasm.trim(),
|
|
275
275
|
mjs: e.mjs.trim()
|
|
276
|
-
} :
|
|
276
|
+
} : se();
|
|
277
277
|
}
|
|
278
278
|
//#endregion
|
|
279
279
|
//#region src/sdk/image.ts
|
|
280
|
-
function
|
|
280
|
+
function le(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 ue(e) {
|
|
288
288
|
let t = URL.createObjectURL(e);
|
|
289
289
|
try {
|
|
290
290
|
let e = new Image();
|
|
@@ -293,26 +293,26 @@ async function le(e) {
|
|
|
293
293
|
URL.revokeObjectURL(t);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
async function
|
|
296
|
+
async function A(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 = le(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 ue(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 = le(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 de(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 fe(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,15 +323,20 @@ function de(e, t, n) {
|
|
|
323
323
|
}
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/sdk/scan.ts
|
|
326
|
-
var
|
|
327
|
-
function
|
|
326
|
+
var pe = "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx", me = 1280;
|
|
327
|
+
function he(e, t, n) {
|
|
328
|
+
if (n) return n;
|
|
329
|
+
let r = Math.max(e, t), i = r / Math.max(1, Math.min(e, t)), a = I() ? 560 : 900;
|
|
330
|
+
return i >= 1.6 ? Math.min(r, Math.max(a, me)) : a;
|
|
331
|
+
}
|
|
332
|
+
function j(e) {
|
|
328
333
|
return e?.trim() || "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx";
|
|
329
334
|
}
|
|
330
|
-
var
|
|
331
|
-
function
|
|
335
|
+
var ge = 3, M, _e = 0, N = /* @__PURE__ */ new Map();
|
|
336
|
+
function P(e, t) {
|
|
332
337
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
333
338
|
}
|
|
334
|
-
function
|
|
339
|
+
function F(e) {
|
|
335
340
|
return {
|
|
336
341
|
...e,
|
|
337
342
|
edges: {
|
|
@@ -354,7 +359,7 @@ function I(e) {
|
|
|
354
359
|
}
|
|
355
360
|
};
|
|
356
361
|
}
|
|
357
|
-
function
|
|
362
|
+
function ve(e, t) {
|
|
358
363
|
let n = (e) => ({
|
|
359
364
|
x: e.x / t,
|
|
360
365
|
y: e.y / t
|
|
@@ -366,42 +371,42 @@ function he(e, t) {
|
|
|
366
371
|
bottomLeft: n(e.bottomLeft)
|
|
367
372
|
};
|
|
368
373
|
}
|
|
369
|
-
function
|
|
374
|
+
function I() {
|
|
370
375
|
return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0 || navigator.hardwareConcurrency <= 4 || typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches;
|
|
371
376
|
}
|
|
372
|
-
function
|
|
377
|
+
function ye(t, n, r, i) {
|
|
373
378
|
return new Promise((a, o) => {
|
|
374
|
-
|
|
379
|
+
M || (M = new Worker(new URL("./assets/document-worker.js", import.meta.url), { type: "module" }), M.onmessage = (t) => {
|
|
375
380
|
if (t.data.download?.url) {
|
|
376
|
-
|
|
381
|
+
k(t.data.download.url, t.data.download);
|
|
377
382
|
return;
|
|
378
383
|
}
|
|
379
|
-
let n =
|
|
380
|
-
n && (
|
|
381
|
-
},
|
|
384
|
+
let n = N.get(t.data.id);
|
|
385
|
+
n && (N.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
|
+
}, M.onerror = () => {
|
|
382
387
|
let t = new e("worker", "The document worker could not start.");
|
|
383
|
-
for (let e of
|
|
384
|
-
|
|
388
|
+
for (let e of N.values()) e.reject(t);
|
|
389
|
+
N.clear(), M?.terminate(), M = void 0;
|
|
385
390
|
});
|
|
386
|
-
let s = ++
|
|
387
|
-
|
|
391
|
+
let s = ++_e;
|
|
392
|
+
N.set(s, {
|
|
388
393
|
resolve: a,
|
|
389
394
|
reject: o
|
|
390
395
|
});
|
|
391
396
|
let c = t.slice().buffer;
|
|
392
|
-
|
|
397
|
+
M.postMessage({
|
|
393
398
|
id: s,
|
|
394
399
|
pixels: c,
|
|
395
400
|
width: n,
|
|
396
401
|
height: r,
|
|
397
|
-
modelUrl:
|
|
402
|
+
modelUrl: j(i.modelUrl),
|
|
398
403
|
heatmapThreshold: i.heatmapThreshold,
|
|
399
404
|
cacheModel: i.cacheModel,
|
|
400
405
|
ortWasmPaths: ce(i.ortWasmPaths)
|
|
401
406
|
}, [c]);
|
|
402
407
|
});
|
|
403
408
|
}
|
|
404
|
-
async function
|
|
409
|
+
async function L(n, r) {
|
|
405
410
|
let { width: i, height: a } = n, o = r.minDimension ?? 360;
|
|
406
411
|
if (Math.min(i, a) < o) return {
|
|
407
412
|
status: "low-quality",
|
|
@@ -410,14 +415,14 @@ async function R(n, r) {
|
|
|
410
415
|
sourceWidth: i,
|
|
411
416
|
sourceHeight: a
|
|
412
417
|
};
|
|
413
|
-
let s =
|
|
418
|
+
let s = he(i, a, r.maxAnalysisDimension), c = Math.min(1, s / Math.max(i, a)), l = document.createElement("canvas");
|
|
414
419
|
l.width = Math.max(1, Math.round(i * c)), l.height = Math.max(1, Math.round(a * c));
|
|
415
420
|
let u = l.getContext("2d", { willReadFrequently: !0 });
|
|
416
421
|
if (!u) throw t();
|
|
417
422
|
u.drawImage(n, 0, 0, l.width, l.height);
|
|
418
423
|
let d = u.getImageData(0, 0, l.width, l.height).data, f;
|
|
419
424
|
if (r.useWorker !== !1 && typeof Worker < "u") try {
|
|
420
|
-
f = await
|
|
425
|
+
f = await ye(d, l.width, l.height, r);
|
|
421
426
|
} catch (t) {
|
|
422
427
|
if (t instanceof e && (t.code === "worker" || t.code === "model-http")) throw t;
|
|
423
428
|
f = {
|
|
@@ -440,7 +445,7 @@ async function R(n, r) {
|
|
|
440
445
|
modelError: v,
|
|
441
446
|
inferenceMs: y
|
|
442
447
|
};
|
|
443
|
-
if (p <
|
|
448
|
+
if (p < ge) return {
|
|
444
449
|
status: "low-quality",
|
|
445
450
|
confidence: Math.min(.3, p / 18),
|
|
446
451
|
message: "The image is too soft or dark to resolve four document edges.",
|
|
@@ -456,7 +461,7 @@ async function R(n, r) {
|
|
|
456
461
|
sourceHeight: a,
|
|
457
462
|
...b
|
|
458
463
|
};
|
|
459
|
-
let x =
|
|
464
|
+
let x = ve(m.corners, c), S = F(x), C = r.minConfidence ?? .58;
|
|
460
465
|
return m.confidence < C ? {
|
|
461
466
|
status: "low-confidence",
|
|
462
467
|
quad: S,
|
|
@@ -477,15 +482,15 @@ async function R(n, r) {
|
|
|
477
482
|
...b
|
|
478
483
|
};
|
|
479
484
|
}
|
|
480
|
-
function
|
|
481
|
-
let n = Math.max(1, Math.round(Math.max(
|
|
485
|
+
function be(e, t) {
|
|
486
|
+
let n = Math.max(1, Math.round(Math.max(P(e.topLeft, e.topRight), P(e.bottomLeft, e.bottomRight)))), r = Math.max(1, Math.round(Math.max(P(e.topLeft, e.bottomLeft), P(e.topRight, e.bottomRight)))), i = Math.min(1, t / Math.max(n, r));
|
|
482
487
|
return {
|
|
483
488
|
width: Math.max(1, Math.round(n * i)),
|
|
484
489
|
height: Math.max(1, Math.round(r * i))
|
|
485
490
|
};
|
|
486
491
|
}
|
|
487
|
-
function
|
|
488
|
-
let { width: i, height: a } =
|
|
492
|
+
function R(e, n, r) {
|
|
493
|
+
let { width: i, height: a } = be(n, r), o = e.getContext("2d", { willReadFrequently: !0 });
|
|
489
494
|
if (!o) throw t();
|
|
490
495
|
let s = o.getImageData(0, 0, e.width, e.height), c = document.createElement("canvas");
|
|
491
496
|
c.width = i, c.height = a;
|
|
@@ -501,37 +506,37 @@ function z(e, n, r) {
|
|
|
501
506
|
}
|
|
502
507
|
return l.putImageData(u, 0, 0), c;
|
|
503
508
|
}
|
|
504
|
-
async function
|
|
505
|
-
return await x("scan"),
|
|
509
|
+
async function z(e, t = {}) {
|
|
510
|
+
return await x("scan"), L(await A(e, { cloneCanvas: !1 }), t);
|
|
506
511
|
}
|
|
507
|
-
async function
|
|
512
|
+
async function xe(e, t, n = {}) {
|
|
508
513
|
await x("scan");
|
|
509
|
-
let r = await
|
|
514
|
+
let r = await A(e, { cloneCanvas: !1 }), i = n.maxOutputDimension ?? (I() ? 2048 : 4096);
|
|
510
515
|
return {
|
|
511
516
|
status: "success",
|
|
512
517
|
corners: t,
|
|
513
|
-
quad:
|
|
518
|
+
quad: F(t),
|
|
514
519
|
confidence: 1,
|
|
515
520
|
message: "Captured with the document edges shown in the finder.",
|
|
516
521
|
sourceWidth: r.width,
|
|
517
522
|
sourceHeight: r.height,
|
|
518
|
-
canvas:
|
|
523
|
+
canvas: R(r, t, i)
|
|
519
524
|
};
|
|
520
525
|
}
|
|
521
|
-
async function
|
|
526
|
+
async function Se(e, t = {}) {
|
|
522
527
|
await x("scan");
|
|
523
|
-
let n = await
|
|
528
|
+
let n = await A(e, { cloneCanvas: !1 }), r = await L(n, t);
|
|
524
529
|
if (r.status !== "success" || !r.corners) return r;
|
|
525
|
-
let i = t.maxOutputDimension ?? (
|
|
530
|
+
let i = t.maxOutputDimension ?? (I() ? 2048 : 4096);
|
|
526
531
|
return {
|
|
527
532
|
...r,
|
|
528
|
-
canvas:
|
|
533
|
+
canvas: R(n, r.corners, i),
|
|
529
534
|
message: "Four document edges detected and perspective-corrected."
|
|
530
535
|
};
|
|
531
536
|
}
|
|
532
537
|
//#endregion
|
|
533
538
|
//#region src/sdk/camera.ts
|
|
534
|
-
function
|
|
539
|
+
function B(e, t) {
|
|
535
540
|
let { engine: n } = t;
|
|
536
541
|
return [
|
|
537
542
|
`${e}:`,
|
|
@@ -546,9 +551,9 @@ function V(e, t) {
|
|
|
546
551
|
` torch: ${t.torch.mode} supported=${t.torch.supported} on=${t.torch.on}`
|
|
547
552
|
].join("\n");
|
|
548
553
|
}
|
|
549
|
-
function
|
|
554
|
+
function Ce(e) {
|
|
550
555
|
let t = ["Exige scanner capture report", `time: ${e.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString()}`];
|
|
551
|
-
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(B("shutter", e.shutter)), e.live && t.push(B("live", e.live)), e.finder) {
|
|
552
557
|
let n = e.finder;
|
|
553
558
|
t.push([
|
|
554
559
|
"finder:",
|
|
@@ -561,7 +566,7 @@ function be(e) {
|
|
|
561
566
|
}
|
|
562
567
|
return `${t.join("\n")}\n`;
|
|
563
568
|
}
|
|
564
|
-
function
|
|
569
|
+
function V(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof navigator > "u" ? 0 : navigator.maxTouchPoints) {
|
|
565
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;
|
|
566
571
|
return {
|
|
567
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",
|
|
@@ -570,12 +575,12 @@ function H(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof nav
|
|
|
570
575
|
userAgent: e
|
|
571
576
|
};
|
|
572
577
|
}
|
|
573
|
-
var
|
|
574
|
-
function
|
|
575
|
-
let t = e ??
|
|
578
|
+
var we = 1920, Te = 1280;
|
|
579
|
+
function H(e) {
|
|
580
|
+
let t = e ?? V();
|
|
576
581
|
return !t.iosWebKit && t.browser === "chrome" && /Android/i.test(t.userAgent) && !/Edg|OPR|SamsungBrowser/i.test(t.userAgent);
|
|
577
582
|
}
|
|
578
|
-
var
|
|
583
|
+
var Ee = 10, U = class {
|
|
579
584
|
on = !1;
|
|
580
585
|
darkCount = 0;
|
|
581
586
|
brightCount = 0;
|
|
@@ -598,7 +603,7 @@ var Ce = 10, W = class {
|
|
|
598
603
|
return this.on;
|
|
599
604
|
}
|
|
600
605
|
};
|
|
601
|
-
function
|
|
606
|
+
function W(e, t) {
|
|
602
607
|
return t ? e === "alwaysOn" || e === "alwaysOff" ? {
|
|
603
608
|
mode: e,
|
|
604
609
|
supported: !0,
|
|
@@ -622,37 +627,37 @@ function G(e, t) {
|
|
|
622
627
|
automatic: e === "auto"
|
|
623
628
|
};
|
|
624
629
|
}
|
|
625
|
-
function
|
|
630
|
+
function G(e) {
|
|
626
631
|
let t = Math.floor(e.length / 4);
|
|
627
632
|
if (!t) return 0;
|
|
628
633
|
let n = 0;
|
|
629
634
|
for (let r = 0; r < t * 4; r += 4) n += e[r] * .299 + e[r + 1] * .587 + e[r + 2] * .114;
|
|
630
635
|
return n / t;
|
|
631
636
|
}
|
|
632
|
-
function
|
|
637
|
+
function De(e, t = 10) {
|
|
633
638
|
if (e.length < 4) return !0;
|
|
634
639
|
let n = Math.floor(e.length / 4), r = 0;
|
|
635
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);
|
|
636
|
-
return
|
|
641
|
+
return G(e) <= t && r / n < .01;
|
|
637
642
|
}
|
|
638
|
-
function
|
|
643
|
+
function K(e, t, n) {
|
|
639
644
|
if (!t || !n) return 0;
|
|
640
645
|
let r = document.createElement("canvas");
|
|
641
646
|
r.width = Math.min(32, t), r.height = Math.min(32, n);
|
|
642
647
|
let i = r.getContext("2d", { willReadFrequently: !0 });
|
|
643
|
-
return i ? (i.drawImage(e, 0, 0, r.width, r.height),
|
|
648
|
+
return i ? (i.drawImage(e, 0, 0, r.width, r.height), G(i.getImageData(0, 0, r.width, r.height).data)) : 0;
|
|
644
649
|
}
|
|
645
|
-
function
|
|
646
|
-
return
|
|
650
|
+
function Oe(e) {
|
|
651
|
+
return K(e, e.width, e.height);
|
|
647
652
|
}
|
|
648
|
-
function
|
|
653
|
+
function ke(e, t = 120) {
|
|
649
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 = () => {
|
|
650
655
|
a && (o = i ? e.requestVideoFrameCallback(f) : requestAnimationFrame(f));
|
|
651
656
|
};
|
|
652
657
|
function f() {
|
|
653
658
|
if (!a) return;
|
|
654
659
|
let { videoWidth: i, videoHeight: o } = e, f = performance.now();
|
|
655
|
-
r && i && o && f - s >= t && (s = f, l =
|
|
660
|
+
r && i && o && f - s >= t && (s = f, l = K(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();
|
|
656
661
|
}
|
|
657
662
|
return d(), {
|
|
658
663
|
stop() {
|
|
@@ -664,24 +669,18 @@ function Ee(e, t = 120) {
|
|
|
664
669
|
getMirrorAgeMs: () => c ? performance.now() - c : Infinity
|
|
665
670
|
};
|
|
666
671
|
}
|
|
667
|
-
function
|
|
672
|
+
function Ae(e) {
|
|
668
673
|
let t = document.createElement("canvas");
|
|
669
674
|
return t.width = e.width, t.height = e.height, t.getContext("2d")?.drawImage(e, 0, 0), t;
|
|
670
675
|
}
|
|
671
|
-
function
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
function J(e = {}, t = H()) {
|
|
676
|
-
let n = { ideal: e.idealWidth ?? 3840 }, r = { ideal: e.idealHeight ?? 2160 };
|
|
677
|
-
e.maxWidth && (n.max = e.maxWidth);
|
|
678
|
-
let i = Oe(e, t);
|
|
679
|
-
return i && (r.max = i), {
|
|
676
|
+
function q(e = {}, t = V()) {
|
|
677
|
+
let n = H(t) && e.maxWidth === void 0 && e.maxHeight === void 0 ? we : void 0, r = e.idealWidth ?? 3840, i = e.idealHeight ?? 2160, a = { ideal: n ? Math.min(r, n) : r }, o = { ideal: n ? Math.min(i, n) : i };
|
|
678
|
+
return e.maxWidth ? a.max = e.maxWidth : n && (a.max = n), e.maxHeight ? o.max = e.maxHeight : n && (o.max = n), {
|
|
680
679
|
audio: !1,
|
|
681
680
|
video: {
|
|
682
681
|
facingMode: { ideal: e.facingMode ?? "environment" },
|
|
683
|
-
width:
|
|
684
|
-
height:
|
|
682
|
+
width: a,
|
|
683
|
+
height: o,
|
|
685
684
|
frameRate: {
|
|
686
685
|
ideal: e.maxFrameRate ?? 30,
|
|
687
686
|
max: e.maxFrameRate ?? 30
|
|
@@ -689,7 +688,7 @@ function J(e = {}, t = H()) {
|
|
|
689
688
|
}
|
|
690
689
|
};
|
|
691
690
|
}
|
|
692
|
-
function
|
|
691
|
+
function J(e, n) {
|
|
693
692
|
if (!e.videoWidth || !e.videoHeight) throw Error("The camera is not ready to capture a frame.");
|
|
694
693
|
let r = n ? Math.min(1, n / Math.max(e.videoWidth, e.videoHeight)) : 1, i = document.createElement("canvas");
|
|
695
694
|
i.width = Math.max(1, Math.round(e.videoWidth * r)), i.height = Math.max(1, Math.round(e.videoHeight * r));
|
|
@@ -697,34 +696,34 @@ function Y(e, n) {
|
|
|
697
696
|
if (!a) throw t();
|
|
698
697
|
return a.drawImage(e, 0, 0, i.width, i.height), i;
|
|
699
698
|
}
|
|
700
|
-
function
|
|
701
|
-
let t =
|
|
702
|
-
return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [
|
|
703
|
-
|
|
699
|
+
function je(e) {
|
|
700
|
+
let t = V();
|
|
701
|
+
return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [q(e, t)] : [
|
|
702
|
+
q({
|
|
704
703
|
...e,
|
|
705
704
|
idealWidth: 3840,
|
|
706
705
|
idealHeight: 2160
|
|
707
706
|
}, t),
|
|
708
|
-
|
|
707
|
+
q({
|
|
709
708
|
...e,
|
|
710
709
|
idealWidth: 2560,
|
|
711
710
|
idealHeight: 1440
|
|
712
711
|
}, t),
|
|
713
|
-
|
|
712
|
+
q({
|
|
714
713
|
...e,
|
|
715
714
|
idealWidth: 1920,
|
|
716
715
|
idealHeight: 1080
|
|
717
716
|
}, t)
|
|
718
717
|
];
|
|
719
718
|
}
|
|
720
|
-
async function
|
|
719
|
+
async function Me(t, n = {}) {
|
|
721
720
|
await x("scan");
|
|
722
721
|
let r = n.torch ?? "alwaysOff";
|
|
723
722
|
if (r !== "alwaysOff" && await x("torch"), !window.isSecureContext && location.hostname !== "localhost") throw new e("secure-context", "Camera access requires HTTPS.");
|
|
724
723
|
if (!navigator.mediaDevices?.getUserMedia) throw Error("Live camera access is unavailable. Use the native camera picker instead.");
|
|
725
724
|
t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.setAttribute("playsinline", "");
|
|
726
725
|
let i, a;
|
|
727
|
-
for (let e of
|
|
726
|
+
for (let e of je(n)) try {
|
|
728
727
|
i = await navigator.mediaDevices.getUserMedia(e);
|
|
729
728
|
break;
|
|
730
729
|
} catch (e) {
|
|
@@ -737,7 +736,7 @@ async function Ae(t, n = {}) {
|
|
|
737
736
|
for (let e of i.getTracks()) e.stop();
|
|
738
737
|
throw Error("The camera did not provide a video track.");
|
|
739
738
|
}
|
|
740
|
-
let s =
|
|
739
|
+
let s = ke(t), c = "ImageCapture" in globalThis, l = W(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
|
|
741
740
|
if (!l.supported || o.readyState !== "live") return !1;
|
|
742
741
|
try {
|
|
743
742
|
return await o.applyConstraints({ advanced: [{ torch: e }] }), l = {
|
|
@@ -755,7 +754,7 @@ async function Ae(t, n = {}) {
|
|
|
755
754
|
}
|
|
756
755
|
};
|
|
757
756
|
l.on && await d(!0);
|
|
758
|
-
let f = r === "auto" && l.supported ? new
|
|
757
|
+
let f = r === "auto" && l.supported ? new U() : void 0, p = f ? window.setInterval(() => {
|
|
759
758
|
if (u || !l.supported) return;
|
|
760
759
|
let e = f.update(s.getLiveLuminance());
|
|
761
760
|
e !== void 0 && e !== l.on && (u = !0, d(e).finally(() => {
|
|
@@ -781,7 +780,7 @@ async function Ae(t, n = {}) {
|
|
|
781
780
|
torchSupported: l.supported,
|
|
782
781
|
torchOn: l.on,
|
|
783
782
|
torch: { ...l },
|
|
784
|
-
engine:
|
|
783
|
+
engine: V()
|
|
785
784
|
};
|
|
786
785
|
};
|
|
787
786
|
return {
|
|
@@ -795,15 +794,15 @@ async function Ae(t, n = {}) {
|
|
|
795
794
|
get torchOn() {
|
|
796
795
|
return l.on;
|
|
797
796
|
},
|
|
798
|
-
capture: (e) =>
|
|
797
|
+
capture: (e) => J(t, e),
|
|
799
798
|
async capturePhoto() {
|
|
800
799
|
let e, n = 0;
|
|
801
800
|
try {
|
|
802
|
-
e =
|
|
801
|
+
e = J(t), n = Oe(e);
|
|
803
802
|
} catch {
|
|
804
803
|
e = void 0;
|
|
805
804
|
}
|
|
806
|
-
let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ?
|
|
805
|
+
let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ? Ae(r) : void 0);
|
|
807
806
|
if (!a) throw Error("The camera preview produced no visible pixels. Keep the scanner on screen, wait for the preview, and retake.");
|
|
808
807
|
return {
|
|
809
808
|
frame: a,
|
|
@@ -829,12 +828,12 @@ async function Ae(t, n = {}) {
|
|
|
829
828
|
}
|
|
830
829
|
//#endregion
|
|
831
830
|
//#region src/sdk/lighting.ts
|
|
832
|
-
function
|
|
831
|
+
function Ne(e, t) {
|
|
833
832
|
if (!e.length) return 0;
|
|
834
833
|
let n = [...e].sort((e, t) => e - t);
|
|
835
834
|
return n[Math.min(n.length - 1, Math.floor(n.length * t))];
|
|
836
835
|
}
|
|
837
|
-
function
|
|
836
|
+
function Pe(e, t, n, r = 12) {
|
|
838
837
|
if (!t || !n || e.length < t * n) return {
|
|
839
838
|
strong: !1,
|
|
840
839
|
strength: 0,
|
|
@@ -857,7 +856,7 @@ function X(e, t, n, r = 12) {
|
|
|
857
856
|
});
|
|
858
857
|
}
|
|
859
858
|
}
|
|
860
|
-
let s =
|
|
859
|
+
let s = Ne(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
|
|
861
860
|
for (let e = 0; e < o.length; e += 1) {
|
|
862
861
|
if (!c[e] || l[e]) continue;
|
|
863
862
|
let t = [], n = [e];
|
|
@@ -905,7 +904,7 @@ function X(e, t, n, r = 12) {
|
|
|
905
904
|
}
|
|
906
905
|
return d;
|
|
907
906
|
}
|
|
908
|
-
function
|
|
907
|
+
function Fe(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
|
|
909
908
|
let i = t + 1, a = new Uint32Array((t + 1) * (n + 1));
|
|
910
909
|
for (let r = 1; r <= n; r += 1) {
|
|
911
910
|
let n = 0;
|
|
@@ -921,7 +920,7 @@ function Me(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
|
|
|
921
920
|
}
|
|
922
921
|
return o;
|
|
923
922
|
}
|
|
924
|
-
function
|
|
923
|
+
function Ie(e, t, n) {
|
|
925
924
|
let r = [
|
|
926
925
|
e.topLeft,
|
|
927
926
|
e.topRight,
|
|
@@ -935,8 +934,8 @@ function Ne(e, t, n) {
|
|
|
935
934
|
height: s - a
|
|
936
935
|
};
|
|
937
936
|
}
|
|
938
|
-
function
|
|
939
|
-
let n =
|
|
937
|
+
function Le(e, t) {
|
|
938
|
+
let n = Ie(t, e.width, e.height);
|
|
940
939
|
if (n.width <= 0 || n.height <= 0) return {
|
|
941
940
|
strong: !1,
|
|
942
941
|
strength: 0,
|
|
@@ -955,18 +954,18 @@ function Pe(e, t) {
|
|
|
955
954
|
i.drawImage(e, n.left, n.top, n.width, n.height, 0, 0, r.width, r.height);
|
|
956
955
|
let a = i.getImageData(0, 0, r.width, r.height).data, o = new Uint8Array(r.width * r.height);
|
|
957
956
|
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);
|
|
958
|
-
return
|
|
957
|
+
return Pe(o, r.width, r.height);
|
|
959
958
|
}
|
|
960
959
|
//#endregion
|
|
961
960
|
//#region src/sdk/finder.ts
|
|
962
|
-
function
|
|
961
|
+
function Re(e, t) {
|
|
963
962
|
return t.castShadow && (e.reason === "hold-still" || e.reason === "ready") ? t.hint ?? e.hint : e.hint;
|
|
964
963
|
}
|
|
965
|
-
async function
|
|
964
|
+
async function ze(e, t) {
|
|
966
965
|
let n = await e();
|
|
967
966
|
return t(), n;
|
|
968
967
|
}
|
|
969
|
-
function
|
|
968
|
+
function Be(e) {
|
|
970
969
|
return e === "alwaysOn" || e === "only" ? {
|
|
971
970
|
visible: !1,
|
|
972
971
|
checked: !0,
|
|
@@ -981,7 +980,7 @@ function Le(e) {
|
|
|
981
980
|
mutable: !0
|
|
982
981
|
};
|
|
983
982
|
}
|
|
984
|
-
function
|
|
983
|
+
function Y(e) {
|
|
985
984
|
return [
|
|
986
985
|
e.topLeft,
|
|
987
986
|
e.topRight,
|
|
@@ -989,11 +988,11 @@ function Z(e) {
|
|
|
989
988
|
e.bottomLeft
|
|
990
989
|
];
|
|
991
990
|
}
|
|
992
|
-
var
|
|
993
|
-
function
|
|
994
|
-
return
|
|
991
|
+
var Ve = 1600;
|
|
992
|
+
function He(e = V()) {
|
|
993
|
+
return H(e) ? Te : Ve;
|
|
995
994
|
}
|
|
996
|
-
function
|
|
995
|
+
function Ue(e) {
|
|
997
996
|
let t = 0;
|
|
998
997
|
for (let n = 0; n < e.length; n += 1) {
|
|
999
998
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -1001,42 +1000,42 @@ function Be(e) {
|
|
|
1001
1000
|
}
|
|
1002
1001
|
return Math.abs(t) / 2;
|
|
1003
1002
|
}
|
|
1004
|
-
function
|
|
1003
|
+
function X(e, t) {
|
|
1005
1004
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
1006
1005
|
}
|
|
1007
|
-
var
|
|
1006
|
+
var Z = {
|
|
1008
1007
|
widthFill: 0,
|
|
1009
1008
|
heightFill: 0,
|
|
1010
1009
|
limitingFill: 0,
|
|
1011
1010
|
areaFill: 0,
|
|
1012
1011
|
aspectRatio: 1
|
|
1013
1012
|
};
|
|
1014
|
-
function
|
|
1015
|
-
let r =
|
|
1013
|
+
function We(e, t, n) {
|
|
1014
|
+
let r = Y(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(X(c, l), X(d, u)), p = Math.max(X(c, d), X(l, u));
|
|
1016
1015
|
return {
|
|
1017
1016
|
widthFill: o,
|
|
1018
1017
|
heightFill: s,
|
|
1019
1018
|
limitingFill: Math.max(o, s),
|
|
1020
|
-
areaFill:
|
|
1019
|
+
areaFill: Ue(r) / Math.max(1, t * n),
|
|
1021
1020
|
aspectRatio: Math.max(f, p) / Math.max(1, Math.min(f, p))
|
|
1022
1021
|
};
|
|
1023
1022
|
}
|
|
1024
|
-
function
|
|
1023
|
+
function Ge(e, t, n, r = {}) {
|
|
1025
1024
|
let i = t ? r.exitFillRatio ?? .64 : r.minFillRatio ?? .72, a = r.highAspectRatio ?? 2.2;
|
|
1026
1025
|
if (e.aspectRatio < a) return i;
|
|
1027
1026
|
let o = t ? r.highAspectExitFillRatio : r.highAspectFillRatio;
|
|
1028
1027
|
return Math.min(o ?? i + .08, 1 - n * 2);
|
|
1029
1028
|
}
|
|
1030
|
-
function
|
|
1029
|
+
function Q(e, t, n = {}) {
|
|
1031
1030
|
let r = n.confidenceThreshold ?? .72;
|
|
1032
1031
|
if (e.status !== "success" || !e.quad || e.confidence < r || !e.sourceWidth || !e.sourceHeight) return {
|
|
1033
1032
|
hint: "Place the document in the frame",
|
|
1034
1033
|
reason: "place-document",
|
|
1035
1034
|
fillRatio: 0,
|
|
1036
|
-
fill:
|
|
1035
|
+
fill: Z,
|
|
1037
1036
|
readyForAutoCapture: !1
|
|
1038
1037
|
};
|
|
1039
|
-
let i =
|
|
1038
|
+
let i = Y(e.quad), a = We(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;
|
|
1040
1039
|
if (i.some(({ x: t, y: n }) => t <= c || t >= e.sourceWidth - c || n <= l || n >= e.sourceHeight - l)) return {
|
|
1041
1040
|
hint: "Move farther away",
|
|
1042
1041
|
reason: "move-farther-away",
|
|
@@ -1044,14 +1043,14 @@ function Ue(e, t, n = {}) {
|
|
|
1044
1043
|
fill: a,
|
|
1045
1044
|
readyForAutoCapture: !1
|
|
1046
1045
|
};
|
|
1047
|
-
let [u, d, f, p] = i, m =
|
|
1046
|
+
let [u, d, f, p] = i, m = X(u, d), h = X(d, f), g = X(f, p), _ = X(p, u);
|
|
1048
1047
|
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) ? {
|
|
1049
1048
|
hint: "Hold the camera straight",
|
|
1050
1049
|
reason: "straighten-camera",
|
|
1051
1050
|
fillRatio: o,
|
|
1052
1051
|
fill: a,
|
|
1053
1052
|
readyForAutoCapture: !1
|
|
1054
|
-
} : o <
|
|
1053
|
+
} : o < Ge(a, t.previouslyReady === !0, s, n) ? {
|
|
1055
1054
|
hint: "Move closer",
|
|
1056
1055
|
reason: "move-closer",
|
|
1057
1056
|
fillRatio: o,
|
|
@@ -1065,7 +1064,7 @@ function Ue(e, t, n = {}) {
|
|
|
1065
1064
|
readyForAutoCapture: t.ready
|
|
1066
1065
|
};
|
|
1067
1066
|
}
|
|
1068
|
-
var
|
|
1067
|
+
var $ = class {
|
|
1069
1068
|
previous;
|
|
1070
1069
|
count = 0;
|
|
1071
1070
|
ready = !1;
|
|
@@ -1082,8 +1081,8 @@ var We = class {
|
|
|
1082
1081
|
ready: !1,
|
|
1083
1082
|
movement: Infinity
|
|
1084
1083
|
};
|
|
1085
|
-
let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...
|
|
1086
|
-
let r =
|
|
1084
|
+
let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...Y(e.quad).map((e, n) => {
|
|
1085
|
+
let r = Y(this.previous)[n];
|
|
1087
1086
|
return Math.hypot(e.x - r.x, e.y - r.y) / Math.max(1, t);
|
|
1088
1087
|
})) : Infinity, r = this.options.exitCornerTolerance ?? Math.max(this.options.cornerTolerance, .036);
|
|
1089
1088
|
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, {
|
|
@@ -1093,14 +1092,14 @@ var We = class {
|
|
|
1093
1092
|
};
|
|
1094
1093
|
}
|
|
1095
1094
|
};
|
|
1096
|
-
function
|
|
1095
|
+
function Ke(e, n) {
|
|
1097
1096
|
let r = Math.min(1, n / Math.max(e.width, e.height)), i = document.createElement("canvas");
|
|
1098
1097
|
i.width = Math.max(1, Math.round(e.width * r)), i.height = Math.max(1, Math.round(e.height * r));
|
|
1099
1098
|
let a = i.getContext("2d");
|
|
1100
1099
|
if (!a) throw t();
|
|
1101
1100
|
return a.drawImage(e, 0, 0, i.width, i.height), i;
|
|
1102
1101
|
}
|
|
1103
|
-
function
|
|
1102
|
+
function qe() {
|
|
1104
1103
|
let e = window.AudioContext ?? window.webkitAudioContext;
|
|
1105
1104
|
if (!e) return;
|
|
1106
1105
|
let t = new e(), n = Math.round(t.sampleRate * .09), r = t.createBuffer(1, n, t.sampleRate), i = r.getChannelData(0);
|
|
@@ -1111,29 +1110,29 @@ function Ke() {
|
|
|
1111
1110
|
let a = t.createBufferSource(), o = t.createBiquadFilter(), s = t.createGain();
|
|
1112
1111
|
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();
|
|
1113
1112
|
}
|
|
1114
|
-
async function
|
|
1113
|
+
async function Je(e) {
|
|
1115
1114
|
let t = document.createElement("video");
|
|
1116
1115
|
return t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.srcObject = e, await t.play(), t;
|
|
1117
1116
|
}
|
|
1118
|
-
async function
|
|
1117
|
+
async function Ye(t) {
|
|
1119
1118
|
await x("scan");
|
|
1120
|
-
let n =
|
|
1119
|
+
let n = Be(t.autoCapture), r = new $({
|
|
1121
1120
|
stableFrames: t.stableFrames ?? 4,
|
|
1122
1121
|
confidenceThreshold: t.confidenceThreshold ?? .72,
|
|
1123
1122
|
cornerTolerance: t.cornerTolerance ?? .024,
|
|
1124
1123
|
exitCornerTolerance: t.exitCornerTolerance ?? .036
|
|
1125
|
-
}), i = t.maxFrameDimension ??
|
|
1124
|
+
}), i = t.maxFrameDimension ?? He(), a = t.intervalMs ?? 140, o = {
|
|
1126
1125
|
minDimension: 220,
|
|
1127
|
-
maxAnalysisDimension:
|
|
1126
|
+
maxAnalysisDimension: i,
|
|
1128
1127
|
...t.detection
|
|
1129
|
-
}, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await
|
|
1128
|
+
}, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await Je(t.source) : t.source, c = !0, l = !1, u = !1, d = 0, f, p = {
|
|
1130
1129
|
state: "detecting",
|
|
1131
1130
|
confidence: 0,
|
|
1132
1131
|
guidance: {
|
|
1133
1132
|
hint: "Place the document in the frame",
|
|
1134
1133
|
reason: "place-document",
|
|
1135
1134
|
fillRatio: 0,
|
|
1136
|
-
fill:
|
|
1135
|
+
fill: Z,
|
|
1137
1136
|
readyForAutoCapture: !1
|
|
1138
1137
|
},
|
|
1139
1138
|
lighting: {
|
|
@@ -1143,7 +1142,7 @@ async function Je(t) {
|
|
|
1143
1142
|
stableFrames: 0,
|
|
1144
1143
|
requiredStableFrames: t.stableFrames ?? 4,
|
|
1145
1144
|
autoCapture: { ...n }
|
|
1146
|
-
}, m = () => s instanceof HTMLCanvasElement ?
|
|
1145
|
+
}, m = () => s instanceof HTMLCanvasElement ? Ke(s, i) : J(s, i), h = (e) => {
|
|
1147
1146
|
p = e, t.onStatus?.(e);
|
|
1148
1147
|
}, g = () => {
|
|
1149
1148
|
c = !1, window.clearTimeout(d), s instanceof HTMLVideoElement && s !== t.source && (s.srcObject = null);
|
|
@@ -1152,11 +1151,11 @@ async function Je(t) {
|
|
|
1152
1151
|
l = !0;
|
|
1153
1152
|
let n;
|
|
1154
1153
|
try {
|
|
1155
|
-
n = await
|
|
1154
|
+
n = await ze(t.captureFrame ?? m, () => {
|
|
1156
1155
|
h({
|
|
1157
1156
|
...p,
|
|
1158
1157
|
state: "captured"
|
|
1159
|
-
}), t.playShutterSound !== !1 &&
|
|
1158
|
+
}), t.playShutterSound !== !1 && qe(), g();
|
|
1160
1159
|
});
|
|
1161
1160
|
} catch (e) {
|
|
1162
1161
|
throw l = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
|
|
@@ -1170,9 +1169,9 @@ async function Je(t) {
|
|
|
1170
1169
|
}, v = async () => {
|
|
1171
1170
|
if (c && !l) {
|
|
1172
1171
|
try {
|
|
1173
|
-
let e = m(), i = await
|
|
1172
|
+
let e = m(), i = await z(e, o);
|
|
1174
1173
|
f = i;
|
|
1175
|
-
let a = i.quad ?
|
|
1174
|
+
let a = i.quad ? Le(e, i.quad) : {
|
|
1176
1175
|
strong: !1,
|
|
1177
1176
|
strength: 0
|
|
1178
1177
|
}, s = a.strong ? {
|
|
@@ -1182,7 +1181,7 @@ async function Je(t) {
|
|
|
1182
1181
|
} : {
|
|
1183
1182
|
castShadow: !1,
|
|
1184
1183
|
strength: a.strength
|
|
1185
|
-
}, c = r.update(i), l =
|
|
1184
|
+
}, c = r.update(i), l = Q(i, {
|
|
1186
1185
|
...c,
|
|
1187
1186
|
previouslyReady: u
|
|
1188
1187
|
}, {
|
|
@@ -1227,7 +1226,7 @@ async function Je(t) {
|
|
|
1227
1226
|
hint: "Place the document in the frame",
|
|
1228
1227
|
reason: "place-document",
|
|
1229
1228
|
fillRatio: 0,
|
|
1230
|
-
fill:
|
|
1229
|
+
fill: Z,
|
|
1231
1230
|
readyForAutoCapture: !1
|
|
1232
1231
|
},
|
|
1233
1232
|
lighting: {
|
|
@@ -1256,6 +1255,6 @@ async function Je(t) {
|
|
|
1256
1255
|
};
|
|
1257
1256
|
}
|
|
1258
1257
|
//#endregion
|
|
1259
|
-
export { a as A,
|
|
1258
|
+
export { a as A, j as C, A as D, fe as E, e as F, t as I, x as M, b as N, ie as O, y as P, z as S, de as T, q as _, Q as a, pe as b, Pe as c, Ee as d, J as f, G as g, De as h, We as i, o as j, ne as k, Fe as l, Ce as m, Be as n, Re as o, V as p, Ge as r, Ye as s, $ as t, U as u, Me as v, Se as w, xe as x, W as y };
|
|
1260
1259
|
|
|
1261
|
-
//# sourceMappingURL=finder-
|
|
1260
|
+
//# sourceMappingURL=finder-DdnCpnjz.js.map
|