@nddeps/barcode-scanner 0.4.1 → 0.5.1

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.
@@ -0,0 +1,7 @@
1
+ declare const WORKER_DECODE_TIMEOUT: number;
2
+ declare const WORKER_DECODE_TIMEOUT_CAUSE = "decode-timeout";
3
+ declare const WORKER_DECODE_FAILURE_CAUSE = "decode-failure";
4
+ declare const WORKER_LOAD_FAILURE_CAUSE = "worker-load-failure";
5
+ declare const WORKER_LOAD_TIMEOUT: number;
6
+ declare const WORKER_LOAD_TIMEOUT_CAUSE = "worker-load-timeout";
7
+ export { WORKER_DECODE_FAILURE_CAUSE, WORKER_DECODE_TIMEOUT, WORKER_DECODE_TIMEOUT_CAUSE, WORKER_LOAD_FAILURE_CAUSE, WORKER_LOAD_TIMEOUT, WORKER_LOAD_TIMEOUT_CAUSE, };
@@ -1,34 +1,45 @@
1
+ import type { BarcodeFormat } from 'barcode-detector/ponyfill';
1
2
  import { type ScanArea } from './utils';
2
- type DecodeFailureHandler = (this: State) => Promise<void> | void;
3
- type DecodeSuccessHandler = (this: State, data: string, area: ScanArea) => Promise<void> | void;
4
- type LifecycleHook = (this: State) => void;
3
+ type Context = {
4
+ state: State;
5
+ };
6
+ type DecodeFailureHandler = () => Promise<void> | void;
7
+ type DecodeSuccessHandler = (data: string, area: ScanArea) => Promise<void> | void;
8
+ type Lifecycle = {
9
+ onBeforeCreate?: LifecycleHook;
10
+ onBeforeDecode?: LifecycleHook;
11
+ onBeforePause?: LifecycleHook;
12
+ onBeforeStart?: LifecycleHook;
13
+ onBeforeStop?: LifecycleHook;
14
+ onCreate?: LifecycleHook;
15
+ onDecode?: LifecycleHook;
16
+ onPause?: LifecycleHook;
17
+ onStart?: LifecycleHook;
18
+ onStop?: LifecycleHook;
19
+ };
20
+ type LifecycleHook = (ctx: Context) => void;
21
+ type Options = {
22
+ debug?: boolean;
23
+ formats?: BarcodeFormat[];
24
+ getScanArea?: (video: HTMLVideoElement) => ScanArea;
25
+ handleDecodeFailure?: DecodeFailureHandler;
26
+ handleDecodeSuccess?: DecodeSuccessHandler;
27
+ lifecycle?: Lifecycle;
28
+ scanRate?: number;
29
+ };
5
30
  type State = {
6
31
  decodeFrameTs: number;
7
32
  isDecodeFrameProcessed: boolean;
8
33
  isDestroyed: boolean;
9
34
  isVideoActive: boolean;
10
35
  isVideoPaused: boolean;
36
+ isWorkerLoadFailure: boolean;
11
37
  scanArea: ScanArea;
12
38
  scanRate: number;
13
39
  video: HTMLVideoElement;
14
40
  };
15
- declare function createBarcodeScanner(video: HTMLVideoElement, { debug, getScanArea, handleDecodeFailure, handleDecodeSuccess, lifecycle, scanRate, }?: {
16
- debug?: boolean;
17
- getScanArea?: (video: HTMLVideoElement) => ScanArea;
18
- handleDecodeFailure?: DecodeFailureHandler;
19
- handleDecodeSuccess?: DecodeSuccessHandler;
20
- lifecycle?: {
21
- onBeforeCreate?: LifecycleHook;
22
- onBeforeDecode?: LifecycleHook;
23
- onBeforeStart?: LifecycleHook;
24
- onBeforeStop?: LifecycleHook;
25
- onCreate?: LifecycleHook;
26
- onDecode?: LifecycleHook;
27
- onStart?: LifecycleHook;
28
- onStop?: LifecycleHook;
29
- };
30
- scanRate?: number;
31
- }): Promise<{
41
+ declare function createBarcodeScanner(video: HTMLVideoElement, { debug, formats, getScanArea, handleDecodeFailure, handleDecodeSuccess, lifecycle, scanRate, }?: Options): Promise<{
42
+ decode: (imageData: ImageData) => Promise<import("barcode-detector/ponyfill").DetectedBarcode | null>;
32
43
  destroy: () => void;
33
44
  pause: () => Promise<void>;
34
45
  start: ({ facingMode, ...rest }?: {
@@ -1,5 +1,7 @@
1
- import type { DetectedBarcode } from 'barcode-detector/ponyfill';
2
- declare function createWorker(): {
1
+ import type { BarcodeFormat, DetectedBarcode } from 'barcode-detector/ponyfill';
2
+ declare function createWorker({ formats }: {
3
+ formats: BarcodeFormat[];
4
+ }): {
3
5
  decode: (imageData: ImageData) => Promise<DetectedBarcode | null>;
4
6
  worker: Worker;
5
7
  };
package/dist/index.js CHANGED
@@ -1,112 +1,96 @@
1
- function x(t) {
2
- const r = new EventTarget(), a = new Proxy(t, {
3
- get(i, o, c) {
4
- return Reflect.get(i, o, c);
5
- },
6
- set(i, o, c, s) {
7
- const d = Reflect.set(i, o, c, s);
8
- return r.dispatchEvent(new CustomEvent("change")), d;
9
- }
10
- });
11
- function n(i, o) {
12
- let c = i();
13
- function s() {
14
- const d = i();
15
- JSON.stringify(d) !== JSON.stringify(c) && (c = d, o(d));
16
- }
17
- return r.addEventListener("change", s), () => r.removeEventListener("change", s);
18
- }
19
- return {
20
- state: a,
21
- watch: n
22
- };
23
- }
24
- const O = 1e3 * 32, F = 1e3 * 16;
25
- function T() {
26
- const t = new Worker(new URL(
1
+ const L = "decode-timeout", O = "worker-load-failure";
2
+ const R = "worker-load-timeout", V = "" + new URL("zxing-reader.wasm", import.meta.url).href;
3
+ function H({ formats: e }) {
4
+ const o = new Worker(new URL(
27
5
  /* @vite-ignore */
28
6
  "" + new URL("worker.js", import.meta.url).href,
29
7
  import.meta.url
30
- ), { type: "module" }), r = new Promise((n, i) => {
31
- const o = setTimeout(() => {
32
- i(new Error("Worker load timeout"));
33
- }, O);
34
- t.addEventListener(
35
- "message",
36
- ({ data: { payload: c, type: s } }) => {
37
- s === "init" && (clearTimeout(o), c.status === "success" ? n(!0) : i(new Error("Worker failed to load")));
8
+ ), { type: "module" }), a = new Promise((i, s) => {
9
+ const r = setTimeout(() => {
10
+ o.removeEventListener("message", h), s(new Error(R));
11
+ }, 32e3), h = ({ data: { payload: c, type: u } }) => {
12
+ u === "init" && (clearTimeout(r), o.removeEventListener("message", h), c.status === "success" ? i(!0) : s(new Error(O)));
13
+ };
14
+ o.addEventListener("message", h), o.postMessage({
15
+ payload: {
16
+ formats: e,
17
+ wasmUrl: V
38
18
  },
39
- {
40
- once: !0
41
- }
42
- );
19
+ type: "config"
20
+ });
43
21
  });
44
- async function a(n) {
45
- await r;
46
- const i = `${performance.now()}-${Math.random().toString(36).slice(2)}`;
47
- return new Promise((o, c) => {
48
- const s = setTimeout(() => {
49
- t.removeEventListener("message", d), c(new Error("Decode timeout"));
50
- }, F), d = ({ data: { payload: w, type: g } }) => {
51
- g !== "decode" || w.uuid !== i || (clearTimeout(s), t.removeEventListener("message", d), o(w.data));
22
+ async function n(i) {
23
+ await a;
24
+ const s = `${performance.now()}-${Math.random().toString(36).slice(2)}`;
25
+ return new Promise((r, h) => {
26
+ const c = setTimeout(() => {
27
+ o.removeEventListener("message", u), h(new Error(L));
28
+ }, 16e3), u = ({ data: { payload: g, type: p } }) => {
29
+ p !== "decode" || g.uuid !== s || (clearTimeout(c), o.removeEventListener("message", u), r(g.data));
52
30
  };
53
- t.addEventListener("message", d), t.postMessage({ payload: { data: n, uuid: i }, type: "decode" });
31
+ o.addEventListener("message", u), o.postMessage({
32
+ payload: {
33
+ data: i,
34
+ uuid: s
35
+ },
36
+ type: "decode"
37
+ });
54
38
  });
55
39
  }
56
40
  return {
57
- decode: a,
58
- worker: t
41
+ decode: n,
42
+ worker: o
59
43
  };
60
44
  }
61
- async function V() {
45
+ async function _() {
62
46
  try {
63
47
  return (await navigator.permissions.query({ name: "camera" })).state === "granted";
64
48
  } catch {
65
49
  return (await navigator.mediaDevices.enumerateDevices()).filter((a) => a.deviceId && a.kind === "videoinput").length > 0;
66
50
  }
67
51
  }
68
- async function H() {
69
- if (await V())
52
+ async function b() {
53
+ if (await _())
70
54
  return !0;
71
55
  try {
72
- const r = (await navigator.mediaDevices.getUserMedia({ video: !0 })).getTracks();
73
- for (const a of r)
56
+ const o = (await navigator.mediaDevices.getUserMedia({ video: !0 })).getTracks();
57
+ for (const a of o)
74
58
  a.stop();
75
59
  return !0;
76
60
  } catch {
77
61
  return !1;
78
62
  }
79
63
  }
80
- function k(t) {
81
- const r = Math.round(0.6666666666666666 * Math.min(t.videoWidth, t.videoHeight));
64
+ function C(e) {
65
+ const o = Math.round(0.6666666666666666 * Math.min(e.videoWidth, e.videoHeight));
82
66
  return {
83
- height: r,
84
- width: r,
85
- x: Math.round((t.videoWidth - r) / 2),
86
- y: Math.round((t.videoHeight - r) / 2)
67
+ height: o,
68
+ width: o,
69
+ x: Math.round((e.videoWidth - o) / 2),
70
+ y: Math.round((e.videoHeight - o) / 2)
87
71
  };
88
72
  }
89
- function A(t, r) {
90
- const a = window.getComputedStyle(t), [n, i] = a.objectPosition.split(" ").map(
91
- (o, c) => o.endsWith("%") ? (c === 0 ? t.offsetWidth - r.width : t.offsetHeight - r.height) * parseFloat(o) / 100 : parseFloat(o)
73
+ function W(e, o) {
74
+ const a = window.getComputedStyle(e), [n, i] = a.objectPosition.split(" ").map(
75
+ (s, r) => s.endsWith("%") ? (r === 0 ? e.offsetWidth - o.width : e.offsetHeight - o.height) * parseFloat(s) / 100 : parseFloat(s)
92
76
  );
93
77
  return {
94
78
  x: n,
95
79
  y: i
96
80
  };
97
81
  }
98
- function W(t) {
99
- const r = window.getComputedStyle(t), a = { height: t.offsetHeight, width: t.offsetWidth }, n = a.width / a.height, i = { height: t.videoHeight, width: t.videoWidth }, o = i.width / i.height;
100
- switch (r.objectFit) {
82
+ function S(e) {
83
+ const o = window.getComputedStyle(e), a = { height: e.offsetHeight, width: e.offsetWidth }, n = a.width / a.height, i = { height: e.videoHeight, width: e.videoWidth }, s = i.width / i.height;
84
+ switch (o.objectFit) {
101
85
  case "contain":
102
86
  return {
103
- height: o < n ? t.offsetHeight : t.offsetWidth / o,
104
- width: o < n ? t.offsetHeight * o : t.offsetWidth
87
+ height: s < n ? e.offsetHeight : e.offsetWidth / s,
88
+ width: s < n ? e.offsetHeight * s : e.offsetWidth
105
89
  };
106
90
  case "cover":
107
91
  return {
108
- height: o > n ? t.offsetHeight : t.offsetWidth / o,
109
- width: o > n ? t.offsetHeight * o : t.offsetWidth
92
+ height: s > n ? e.offsetHeight : e.offsetWidth / s,
93
+ width: s > n ? e.offsetHeight * s : e.offsetWidth
110
94
  };
111
95
  case "fill":
112
96
  return a;
@@ -115,175 +99,168 @@ function W(t) {
115
99
  case "scale-down":
116
100
  return {
117
101
  height: Math.min(
118
- o < n ? t.offsetHeight : t.offsetWidth / o,
119
- t.videoHeight
102
+ s < n ? e.offsetHeight : e.offsetWidth / s,
103
+ e.videoHeight
120
104
  ),
121
105
  width: Math.min(
122
- o < n ? t.offsetHeight * o : t.offsetWidth,
123
- t.videoWidth
106
+ s < n ? e.offsetHeight * s : e.offsetWidth,
107
+ e.videoWidth
124
108
  )
125
109
  };
126
110
  default:
127
111
  return i;
128
112
  }
129
113
  }
130
- function L(t) {
131
- return "BarcodeDetector" in t;
114
+ function U(e) {
115
+ return "BarcodeDetector" in e;
132
116
  }
133
- function j(t, r) {
134
- const a = /scaleX\(-1\)/.test(t.style.transform), n = W(t), i = A(t, n), o = a ? t.videoWidth - r.x - r.width : r.x, c = r.y;
117
+ function I(e, o) {
118
+ const a = /scaleX\(-1\)/.test(e.style.transform), n = S(e), i = W(e, n), s = a ? e.videoWidth - o.x - o.width : o.x, r = o.y;
135
119
  return {
136
- height: r.height / t.videoHeight * n.height,
137
- width: r.width / t.videoWidth * n.width,
138
- x: o / t.videoWidth * n.width + i.x,
139
- y: c / t.videoHeight * n.height + i.y
120
+ height: o.height / e.videoHeight * n.height,
121
+ width: o.width / e.videoWidth * n.width,
122
+ x: s / e.videoWidth * n.width + i.x,
123
+ y: r / e.videoHeight * n.height + i.y
140
124
  };
141
125
  }
142
- function C(t, r) {
143
- const a = /scaleX\(-1\)/.test(t.style.transform), n = W(t), i = A(t, n), o = a ? n.width - (r.x - i.x) - r.width : r.x - i.x, c = r.y - i.y, s = t.videoHeight / n.height, d = t.videoWidth / n.width;
126
+ function B(e, o) {
127
+ const a = /scaleX\(-1\)/.test(e.style.transform), n = S(e), i = W(e, n), s = a ? n.width - (o.x - i.x) - o.width : o.x - i.x, r = o.y - i.y, h = e.videoHeight / n.height, c = e.videoWidth / n.width;
144
128
  return {
145
- height: r.height * s,
146
- width: r.width * d,
147
- x: o * d,
148
- y: c * s
129
+ height: o.height * h,
130
+ width: o.width * c,
131
+ x: s * c,
132
+ y: r * h
149
133
  };
150
134
  }
151
- function U(t) {
152
- return new Promise((r) => setTimeout(r, t));
135
+ function j(e) {
136
+ return new Promise((o) => setTimeout(o, e));
153
137
  }
154
- async function B(t, {
155
- debug: r,
156
- getScanArea: a = k,
157
- handleDecodeFailure: n = () => {
158
- },
159
- handleDecodeSuccess: i = () => {
160
- },
161
- lifecycle: o = {},
162
- scanRate: c = 24
138
+ async function q(e, {
139
+ debug: o,
140
+ formats: a = ["qr_code"],
141
+ getScanArea: n = C,
142
+ handleDecodeFailure: i,
143
+ handleDecodeSuccess: s,
144
+ lifecycle: r = {},
145
+ scanRate: h = 24
163
146
  } = {}) {
164
- if (!(t instanceof HTMLVideoElement))
147
+ if (!(e instanceof HTMLVideoElement))
165
148
  throw new Error("video is not a HTMLVideoElement");
166
- if (!(i instanceof Function))
149
+ if (!(s instanceof Function))
167
150
  throw new Error("handleDecodeSuccess is not a function");
168
- if (!(n instanceof Function))
151
+ if (!(i instanceof Function))
169
152
  throw new Error("handleDecodeFailure is not a function");
170
- const s = document.createElement("canvas"), d = s.getContext("2d", { willReadFrequently: !0 });
171
- if (!d)
153
+ const c = document.createElement("canvas"), u = c.getContext("2d", { willReadFrequently: !0 });
154
+ if (!u)
172
155
  throw new Error("canvas context is not supported");
173
- const { decode: w, worker: g } = T(), { state: e } = x({
156
+ const { decode: g, worker: p } = H({ formats: a }), t = {
174
157
  decodeFrameTs: performance.now(),
175
158
  isDecodeFrameProcessed: !1,
176
159
  isDestroyed: !1,
177
160
  isVideoActive: !1,
178
161
  isVideoPaused: !1,
179
- scanArea: a(t),
180
- scanRate: c,
181
- video: t
182
- }), v = t.requestVideoFrameCallback?.bind(t) ?? requestAnimationFrame;
183
- e.video.autoplay = !0, e.video.disablePictureInPicture = !0, e.video.hidden = !1, e.video.muted = !0, e.video.playsInline = !0, o.onCreate && o.onCreate.call(e);
184
- function b(h, u) {
185
- v(m);
186
- async function m() {
187
- if (e.isDestroyed || e.isVideoActive === !1)
162
+ isWorkerLoadFailure: !1,
163
+ scanArea: n(e),
164
+ scanRate: h,
165
+ video: e
166
+ }, f = { state: t }, v = e.requestVideoFrameCallback?.bind(e) ?? requestAnimationFrame;
167
+ t.video.autoplay = !0, t.video.disablePictureInPicture = !0, t.video.hidden = !1, t.video.muted = !0, t.video.playsInline = !0, r.onCreate && r.onCreate(f);
168
+ function T(m, l = () => {
169
+ }) {
170
+ v(w);
171
+ async function w() {
172
+ if (t.isDestroyed || t.isVideoActive === !1)
188
173
  return;
189
174
  if (
190
175
  // Skip if the time since the last request frame is less than the scan rate
191
- performance.now() - e.decodeFrameTs < 1e3 / e.scanRate || // Skip if the frame is already processed
192
- e.isDecodeFrameProcessed || // Skip if the video is not ready
193
- e.video.readyState <= 1
176
+ performance.now() - t.decodeFrameTs < 1e3 / t.scanRate || // Skip if the frame is already processed
177
+ t.isDecodeFrameProcessed || // Skip if the video is not ready
178
+ t.video.readyState <= 1
194
179
  ) {
195
- v(m);
180
+ v(w);
196
181
  return;
197
182
  }
198
- e.isDecodeFrameProcessed = !0, e.scanArea = a(e.video), o.onBeforeDecode && o.onBeforeDecode.call(e), s.height = e.scanArea.height, s.width = e.scanArea.width, d.clearRect(0, 0, s.width, s.height), d.drawImage(
199
- e.video,
200
- e.scanArea.x,
201
- e.scanArea.y,
202
- e.scanArea.width,
203
- e.scanArea.height,
183
+ t.isDecodeFrameProcessed = !0, t.scanArea = n(t.video), r.onBeforeDecode && r.onBeforeDecode(f), c.height = t.scanArea.height, c.width = t.scanArea.width, u.clearRect(0, 0, c.width, c.height), u.drawImage(
184
+ t.video,
185
+ t.scanArea.x,
186
+ t.scanArea.y,
187
+ t.scanArea.width,
188
+ t.scanArea.height,
204
189
  0,
205
190
  0,
206
- s.width,
207
- s.height
191
+ c.width,
192
+ c.height
208
193
  );
209
- const l = d.getImageData(0, 0, s.width, s.height);
210
- r && window.dispatchEvent(
194
+ const E = u.getImageData(0, 0, c.width, c.height);
195
+ o && window.dispatchEvent(
211
196
  new CustomEvent("barcode-scanner:decode-frame", {
212
197
  detail: {
213
- imageData: l
198
+ imageData: E
214
199
  }
215
200
  })
216
201
  );
217
202
  try {
218
- const f = await w(l);
219
- if (f) {
220
- const p = f.cornerPoints.map((E) => E.x), y = f.cornerPoints.map((E) => E.y), P = {
221
- height: Math.max(...y) - Math.min(...y),
222
- width: Math.max(...p) - Math.min(...p),
223
- x: Math.min(...p) + e.scanArea.x,
224
- y: Math.min(...y) + e.scanArea.y
203
+ const d = await g(E);
204
+ if (d) {
205
+ const D = d.cornerPoints.map((y) => y.x), A = d.cornerPoints.map((y) => y.y), k = {
206
+ height: Math.max(...A) - Math.min(...A),
207
+ width: Math.max(...D) - Math.min(...D),
208
+ x: Math.min(...D) + t.scanArea.x,
209
+ y: Math.min(...A) + t.scanArea.y
225
210
  };
226
- await Promise.resolve(h.call(e, f.rawValue, P));
211
+ await Promise.resolve(m(d.rawValue, k));
227
212
  } else
228
- await Promise.resolve(u.call(e));
229
- } catch (f) {
230
- console.warn("Failed to decode barcode"), f && console.error(f);
213
+ await Promise.resolve(l());
214
+ } catch (d) {
215
+ console.warn("Failed to decode barcode"), d && (console.error(d), d instanceof Error && (d.cause === O || d.cause === R) && (t.isWorkerLoadFailure = !0));
231
216
  } finally {
232
- o.onDecode && o.onDecode.call(e), e.decodeFrameTs = performance.now(), e.isDecodeFrameProcessed = !1, v(m);
217
+ r.onDecode && r.onDecode(f), t.isWorkerLoadFailure === !1 && (t.isDecodeFrameProcessed = !1, t.decodeFrameTs = performance.now(), v(w));
233
218
  }
234
219
  }
235
220
  }
236
- function R() {
237
- e.isDestroyed || (D(), g.terminate(), e.isDestroyed = !0);
221
+ function F() {
222
+ t.isDestroyed || (M(), p.terminate(), t.isDestroyed = !0);
238
223
  }
239
- async function S() {
240
- if (e.isVideoActive === !1 || e.isVideoPaused || e.isDestroyed)
241
- return;
242
- e.video.pause(), s.height = e.video.videoHeight, s.width = e.video.videoWidth, d.drawImage(e.video, 0, 0, s.width, s.height, 0, 0, s.width, s.height);
243
- const h = await new Promise((u, m) => {
244
- s.toBlob(
245
- (l) => {
246
- l ? u(l) : m(new Error("Failed to convert canvas to blob"));
247
- },
248
- "image/jpeg",
249
- 0.9
250
- );
251
- });
252
- e.video.poster.startsWith("blob:") && URL.revokeObjectURL(e.video.poster), e.video.poster = URL.createObjectURL(h), e.video.srcObject instanceof MediaStream && e.video.srcObject.getTracks().forEach((u) => u.stop()), e.isVideoPaused = !0, e.video.srcObject = null;
224
+ async function P() {
225
+ t.isVideoActive === !1 || t.isVideoPaused || t.isDestroyed || (r.onBeforePause && r.onBeforePause(f), t.video.srcObject instanceof MediaStream && (t.video.srcObject.getTracks().forEach((m) => m.stop()), t.video.srcObject = null), t.isVideoPaused = !0, r.onPause && r.onPause(f));
253
226
  }
254
- async function M({
255
- facingMode: h = "environment",
256
- ...u
227
+ async function x({
228
+ facingMode: m = "environment",
229
+ ...l
257
230
  } = {}) {
258
- if (o.onBeforeStart && o.onBeforeStart.call(e), !await H())
231
+ const w = l.handleDecodeSuccess ?? s, E = l.handleDecodeFailure ?? i;
232
+ if (!w)
233
+ throw new Error("handleDecodeSuccess is required");
234
+ if (r.onBeforeStart && r.onBeforeStart(f), !await b())
259
235
  throw new Error("No camera access");
260
- e.video.srcObject instanceof MediaStream || (e.video.srcObject = await navigator.mediaDevices.getUserMedia({
236
+ t.video.srcObject instanceof MediaStream || (t.video.srcObject = await navigator.mediaDevices.getUserMedia({
261
237
  video: {
262
- facingMode: h
238
+ facingMode: m
263
239
  }
264
- }), await e.video.play(), e.isVideoActive = !0, e.isVideoPaused = !1, e.scanArea = a(e.video), e.video.style.transform = h === "user" ? "scaleX(-1)" : "none", o.onStart && o.onStart.call(e), b(u.handleDecodeSuccess ?? i, u.handleDecodeFailure ?? n));
240
+ }), await t.video.play(), t.isVideoActive = !0, t.isVideoPaused = !1, t.scanArea = n(t.video), t.video.style.transform = m === "user" ? "scaleX(-1)" : "none", r.onStart && r.onStart(f), T(w, E));
265
241
  }
266
- async function D() {
267
- e.isVideoActive === !1 || e.isDestroyed || (o.onBeforeStop && o.onBeforeStop.call(e), e.video.srcObject instanceof MediaStream && e.video.srcObject.getTracks().forEach((h) => h.stop()), e.video.poster.startsWith("blob:") && URL.revokeObjectURL(e.video.poster), e.isVideoActive = !1, e.isVideoPaused = !1, e.video.poster = "", e.video.srcObject = null, o.onStop && o.onStop.call(e));
242
+ async function M() {
243
+ t.isVideoActive === !1 || t.isDestroyed || (r.onBeforeStop && r.onBeforeStop(f), t.video.srcObject instanceof MediaStream && (t.video.srcObject.getTracks().forEach((m) => m.stop()), t.video.srcObject = null), t.isVideoActive = !1, t.isVideoPaused = !1, t.video.poster = "", r.onStop && r.onStop(f));
268
244
  }
269
245
  return {
270
- destroy: R,
271
- pause: S,
272
- start: M,
273
- state: e,
274
- stop: D
246
+ decode: g,
247
+ destroy: F,
248
+ pause: P,
249
+ start: x,
250
+ state: t,
251
+ stop: M
275
252
  };
276
253
  }
277
254
  export {
278
- B as createBarcodeScanner,
279
- B as default,
280
- H as getCameraAccess,
281
- k as getScanArea,
282
- A as getVideoRenderOffset,
283
- W as getVideoRenderSize,
284
- V as hasCameraAccess,
285
- L as isBarcodeDetectorAvailable,
286
- j as translateAreaToVideoRender,
287
- C as translateAreaToVideoSource,
288
- U as wait
255
+ q as createBarcodeScanner,
256
+ q as default,
257
+ b as getCameraAccess,
258
+ C as getScanArea,
259
+ W as getVideoRenderOffset,
260
+ S as getVideoRenderSize,
261
+ _ as hasCameraAccess,
262
+ U as isBarcodeDetectorAvailable,
263
+ I as translateAreaToVideoRender,
264
+ B as translateAreaToVideoSource,
265
+ j as wait
289
266
  };