@exige/web-scanner-sdk 0.2.27 → 0.2.28

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/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { C as e, L as t, S as n, _ as r, b as i, g as a, h as o, j as s, o as c, s as l, w as u } from "./finder-BlN89ZeT.js";
2
+ import { A as e, D as t, E as n, F as r, M as i, P as a, R as o, T as s, g as c, o as l, s as u } from "./finder-BvBpdbHa.js";
3
3
  import { createContext as d, useCallback as f, useContext as p, useEffect as m, useLayoutEffect as ee, useMemo as te, useRef as h, useState as g } from "react";
4
4
  import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
5
5
  //#region src/sdk/display-quad.ts
@@ -90,14 +90,14 @@ function ae(e) {
90
90
  return;
91
91
  }
92
92
  }
93
- function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", torch: _ = "defaultOff", onCapture: y, onCancel: b, onError: x, onSettings: S, onFinderStatus: C, modelUrl: w, ortWasmPaths: T, detectionIntervalMs: oe, apiRef: E, children: se }) {
94
- let D = e(p), O = h(void 0), k = h(void 0), A = h(void 0), j = h(void 0), M = h({}), N = h(new ne()), P = h(!1), F = h(!1), I = h({
93
+ function C({ open: s, autoCapture: d = "defaultOn", captureMode: p = "auto", torch: _ = "defaultOff", onCapture: y, onCancel: b, onError: x, onSettings: S, onFinderStatus: C, modelUrl: w, ortWasmPaths: T, detectionIntervalMs: oe, apiRef: E, children: se }) {
94
+ let D = a(p), O = h(void 0), k = h(void 0), A = h(void 0), j = h(void 0), M = h({}), N = h(new ne()), P = h(!1), F = h(!1), I = h({
95
95
  onCapture: y,
96
96
  onCancel: b,
97
97
  onError: x,
98
98
  onSettings: S,
99
99
  onFinderStatus: C
100
- }), L = h(null), [R, ce] = g(null), [le, z] = g(D && o ? "capturing" : D ? "ready" : "starting"), [B, V] = g(), [ue, H] = g(), [de, fe] = g({
100
+ }), L = h(null), [R, ce] = g(null), [le, z] = g(D && s ? "capturing" : D ? "ready" : "starting"), [B, V] = g(), [ue, H] = g(), [de, fe] = g({
101
101
  width: 1,
102
102
  height: 1
103
103
  }), [pe, me] = g(), [he, U] = g(), [ge, W] = g(""), [_e, ve] = g(0), [ye, G] = g(), [be, K] = g(), [xe, q] = g("idle"), [Se, Ce] = g(), J = h(void 0), [we, Te] = g({
@@ -124,12 +124,12 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
124
124
  x,
125
125
  S,
126
126
  C
127
- ]), m(() => t(Te), []);
127
+ ]), m(() => o(Te), []);
128
128
  let Ee = f((e) => {
129
129
  ce(e);
130
130
  }, []);
131
131
  m(() => {
132
- if (!o || !R) return;
132
+ if (!s || !R) return;
133
133
  let e = () => {
134
134
  let e = R.getBoundingClientRect();
135
135
  fe({
@@ -140,36 +140,36 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
140
140
  if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
141
141
  let t = new ResizeObserver(e);
142
142
  return t.observe(R), () => t.disconnect();
143
- }, [o, R]), m(() => {
144
- if (!o) return;
143
+ }, [s, R]), m(() => {
144
+ if (!s) return;
145
145
  let e = window.setInterval(() => {
146
146
  let e = O.current?.getDiagnostics();
147
147
  e && G(e);
148
148
  }, 500);
149
149
  return () => window.clearInterval(e);
150
- }, [o, _e]), m(() => {
151
- if (!o) return;
150
+ }, [s, _e]), m(() => {
151
+ if (!s) return;
152
152
  let e = 0, t = performance.now(), n = (r) => {
153
153
  let i = N.current.step(r - t);
154
154
  t = r, i && H(i), e = requestAnimationFrame(n);
155
155
  };
156
156
  return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
157
- }, [o]), m(() => {
158
- if (!o || D || !R) return;
157
+ }, [s]), m(() => {
158
+ if (!s || D || !R) return;
159
159
  let e = !1, t = () => {
160
160
  k.current?.stop(), k.current = void 0, O.current?.stop(), O.current = void 0, j.current = void 0, A.current = void 0, M.current = {}, Y();
161
161
  };
162
162
  return (async () => {
163
163
  t(), P.current = !1, z("starting"), W(""), V(void 0), U(void 0), K(void 0), q("idle"), Y();
164
164
  try {
165
- let t = await u(R, { torch: _ });
165
+ let t = await r(R, { torch: _ });
166
166
  if (e) {
167
167
  t.stop();
168
168
  return;
169
169
  }
170
170
  O.current = t;
171
171
  let n = t.getSettings();
172
- me(n), I.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), k.current = await l({
172
+ me(n), I.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), k.current = await u({
173
173
  source: R,
174
174
  autoCapture: d,
175
175
  intervalMs: oe,
@@ -224,7 +224,7 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
224
224
  e = !0, t();
225
225
  };
226
226
  }, [
227
- o,
227
+ s,
228
228
  R,
229
229
  D,
230
230
  d,
@@ -237,7 +237,7 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
237
237
  X
238
238
  ]);
239
239
  let De = {
240
- open: o,
240
+ open: s,
241
241
  phase: le,
242
242
  autoCapture: d,
243
243
  captureMode: p,
@@ -251,7 +251,7 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
251
251
  diagnostics: ye,
252
252
  shutterDiagnostics: be,
253
253
  copyState: xe,
254
- guidanceHint: B ? c(B.guidance, B.lighting) : void 0,
254
+ guidanceHint: B ? l(B.guidance, B.lighting) : void 0,
255
255
  detectorStatus: B?.modelStatus === "failed" ? `ML failed${B.modelError ? `: ${B.modelError}` : ""}` : B?.detector === "ml" ? `ML ${B.modelProvider ?? ""}`.trim() : "ML loading",
256
256
  modelDownload: we,
257
257
  frozenPreviewUrl: Se
@@ -265,21 +265,21 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
265
265
  if (!F.current) {
266
266
  F.current = !0, P.current = !1, W(""), H(void 0), N.current.clear(), z("capturing");
267
267
  try {
268
- let e = await n();
269
- X(e);
270
- let t = {
271
- width: e.width,
272
- height: e.height
268
+ let t = await i();
269
+ X(t);
270
+ let n = {
271
+ width: t.width,
272
+ height: t.height
273
273
  };
274
- me(t), I.current.onSettings?.(t), U("system-camera");
274
+ me(n), I.current.onSettings?.(n), U("system-camera");
275
275
  let r;
276
276
  try {
277
- let t = e.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, e.width, e.height).data;
278
- t && (r = i(t));
277
+ let n = t.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, t.width, t.height).data;
278
+ n && (r = e(n));
279
279
  } catch {
280
280
  r = void 0;
281
281
  }
282
- let a = await s(e, {
282
+ let a = await c(t, {
283
283
  modelUrl: w,
284
284
  ortWasmPaths: T
285
285
  });
@@ -292,11 +292,11 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
292
292
  sourceWidth: a.sourceWidth,
293
293
  sourceHeight: a.sourceHeight
294
294
  }, H(a.quad), z("captured"), await I.current.onCapture({
295
- frame: e,
295
+ frame: t,
296
296
  detection: a,
297
297
  reason: "manual",
298
298
  method: "system-camera",
299
- settings: t,
299
+ settings: n,
300
300
  luminance: r,
301
301
  displayedQuad: a.quad,
302
302
  displaySourceWidth: a.sourceWidth,
@@ -338,19 +338,19 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
338
338
  Ae.current = Z;
339
339
  let Q = h(!1);
340
340
  ee(() => {
341
- if (!o || !D) {
341
+ if (!s || !D) {
342
342
  Q.current = !1;
343
343
  return;
344
344
  }
345
345
  if (!Q.current) {
346
- if (Q.current = !0, P.current = !1, W(""), V(void 0), U(void 0), K(void 0), q("idle"), H(void 0), N.current.clear(), Y(), !r()) {
346
+ if (Q.current = !0, P.current = !1, W(""), V(void 0), U(void 0), K(void 0), q("idle"), H(void 0), N.current.clear(), Y(), !t()) {
347
347
  z("ready");
348
348
  return;
349
349
  }
350
350
  Ae.current();
351
351
  }
352
352
  }, [
353
- o,
353
+ s,
354
354
  D,
355
355
  Y
356
356
  ]);
@@ -373,33 +373,33 @@ function C({ open: o, autoCapture: d = "defaultOn", captureMode: p = "auto", tor
373
373
  }, []), Ne = f((e) => {
374
374
  k.current?.setAutoCapture(e);
375
375
  }, []), Pe = f(async () => {
376
- let e = L.current, t = O.current?.getDiagnostics() ?? e.diagnostics, n = e.finderStatus, r = a({
376
+ let e = L.current, t = O.current?.getDiagnostics() ?? e.diagnostics, r = e.finderStatus, i = n({
377
377
  error: e.error || void 0,
378
378
  captureMethod: e.captureMethod,
379
379
  luminance: j.current?.luminance,
380
380
  fallbackReason: j.current?.fallbackReason,
381
381
  shutter: e.shutterDiagnostics ?? j.current?.diagnostics,
382
382
  live: t,
383
- finder: n ? {
384
- state: n.state,
385
- confidence: n.confidence,
386
- stableFrames: n.stableFrames,
387
- requiredStableFrames: n.requiredStableFrames,
388
- detector: n.detector,
389
- modelStatus: n.modelStatus,
390
- modelError: n.modelError,
391
- modelProvider: n.modelProvider,
392
- modelNote: n.modelNote,
393
- inferenceMs: n.inferenceMs,
394
- sourceWidth: n.sourceWidth,
395
- sourceHeight: n.sourceHeight
383
+ finder: r ? {
384
+ state: r.state,
385
+ confidence: r.confidence,
386
+ stableFrames: r.stableFrames,
387
+ requiredStableFrames: r.requiredStableFrames,
388
+ detector: r.detector,
389
+ modelStatus: r.modelStatus,
390
+ modelError: r.modelError,
391
+ modelProvider: r.modelProvider,
392
+ modelNote: r.modelNote,
393
+ inferenceMs: r.inferenceMs,
394
+ sourceWidth: r.sourceWidth,
395
+ sourceHeight: r.sourceHeight
396
396
  } : void 0
397
397
  });
398
398
  try {
399
- if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(r);
399
+ if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(i);
400
400
  else {
401
401
  let e = document.createElement("textarea");
402
- e.value = r, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
402
+ e.value = i, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
403
403
  let t = document.execCommand("copy");
404
404
  if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
405
405
  }
@@ -687,7 +687,7 @@ function N() {
687
687
  });
688
688
  }
689
689
  function P() {
690
- let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: r, copyReport: i } = T(), a = e?.engine ?? o();
690
+ let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: r, copyReport: i } = T(), a = e?.engine ?? s();
691
691
  return /* @__PURE__ */ y("dl", {
692
692
  className: "scanner-camera-overlay__diagnostics",
693
693
  "aria-label": "Camera diagnostics",