@nddeps/barcode-scanner 0.6.0 → 0.6.2

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