@twintag/twintag-core 0.2.284-fix-stream-visibility-9ac029dedd8eb46b8c97b6a6b8dfdb114e5e5de8 → 0.2.284-fix-scanner-stream-visibility-fa1b63f803fa98c0ac1314c5943dd3461e208cfb

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.
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514],"devices":[32],"decoderIsBusy":[32]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
17
+ return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514],"devices":[32],"decoderIsBusy":[32]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
18
+ return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
19
19
  });
@@ -19,11 +19,11 @@ const TwintagQRScanner = class {
19
19
  this.symbol = index.createEvent(this, "symbol", 7);
20
20
  this.streamIsActive = index.createEvent(this, "streamIsActive", 7);
21
21
  this.frame = index.createEvent(this, "frame", 7);
22
+ this.stage = 0;
22
23
  this.stageScale = 1;
23
- this.eventsController = new AbortController();
24
24
  this.videoIsPlaying = false;
25
- this.devices = [];
26
25
  this.decoderIsBusy = false;
26
+ this.eventsController = new AbortController();
27
27
  this.stream = null;
28
28
  this.mode = 'single';
29
29
  this.format = 'QRCode';
@@ -56,7 +56,6 @@ const TwintagQRScanner = class {
56
56
  if (event.code === 'ready') {
57
57
  this.decoderIsBusy = false;
58
58
  this.symbol.emit(event.result);
59
- this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
60
59
  if (this.mode === 'single') {
61
60
  this.eventsController.abort();
62
61
  this.stopStream();
@@ -109,32 +108,35 @@ const TwintagQRScanner = class {
109
108
  }
110
109
  }
111
110
  readBarcodeFromCanvas() {
111
+ this.reqAnimFrame = requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
112
+ if (!this.stage)
113
+ return;
112
114
  this.drawInCanvas();
113
- const imageData = this.context.getImageData(0, 0, this.canvas.width, this.canvas.height);
115
+ const imageData = this.context.getImageData(0, 0, this.stage, this.stage);
114
116
  const sourceBuffer = imageData.data;
115
117
  if (!this.decoderIsBusy) {
116
118
  worker.postMessage({
117
119
  type: 'read',
118
120
  format: this.format,
119
121
  details: {
120
- width: this.canvas.width,
121
- height: this.canvas.height,
122
+ width: this.stage,
123
+ height: this.stage,
122
124
  sourceBuffer: sourceBuffer,
123
125
  },
124
126
  });
127
+ this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
125
128
  }
126
- requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
127
129
  }
128
130
  drawInCanvas() {
129
- const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
130
- const squareLength = stage * this.crop;
131
+ const videoStage = Math.min(this.video.videoWidth, this.video.videoHeight);
132
+ const squareLength = videoStage * this.crop;
131
133
  const center = {
132
134
  x: this.video.videoWidth / 2,
133
135
  y: this.video.videoHeight / 2,
134
136
  };
135
137
  const sx = center.x - squareLength / 2;
136
138
  const sy = center.y - squareLength / 2;
137
- this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, stage * this.stageScale, stage * this.stageScale);
139
+ this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, videoStage * this.stageScale, videoStage * this.stageScale);
138
140
  }
139
141
  async updateStream(constraints) {
140
142
  if (this.stream) {
@@ -181,20 +183,20 @@ const TwintagQRScanner = class {
181
183
  };
182
184
  try {
183
185
  await this.updateStream(constraints);
184
- const devices = await navigator.mediaDevices.enumerateDevices();
185
- this.devices = devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
186
+ const raw_devices = await navigator.mediaDevices.enumerateDevices();
187
+ const devices = raw_devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
186
188
  device.label.toLowerCase().includes('back'));
187
- if (this.devices.length === 0) {
189
+ if (devices.length === 0) {
188
190
  return;
189
191
  }
190
- if (this.devices.length === 1) {
192
+ if (devices.length === 1) {
191
193
  constraints.video.deviceId = {
192
- exact: this.devices[0].deviceId,
194
+ exact: devices[0].deviceId,
193
195
  };
194
196
  await this.updateStream(constraints);
195
197
  }
196
- let backCameraIndex = this.devices.length - 1;
197
- const cameraResolutions = this.devices.map((camera) => {
198
+ let backCameraIndex = devices.length - 1;
199
+ const cameraResolutions = devices.map((camera) => {
198
200
  const match = camera.label.match(/\b([0-9]+)MP?\b/i);
199
201
  if (match != null) {
200
202
  return parseInt(match[1], 10);
@@ -205,7 +207,7 @@ const TwintagQRScanner = class {
205
207
  backCameraIndex = cameraResolutions.lastIndexOf(Math.max(...cameraResolutions));
206
208
  }
207
209
  // back camera with the highest resolution
208
- const backCamera = this.devices[backCameraIndex];
210
+ const backCamera = devices[backCameraIndex];
209
211
  if (backCamera) {
210
212
  constraints.video.deviceId = {
211
213
  exact: backCamera.deviceId,
@@ -250,11 +252,11 @@ const TwintagQRScanner = class {
250
252
  const currentStage = Math.min(this.video.videoWidth, this.video.videoHeight);
251
253
  const maxStageValue = 400;
252
254
  this.stageScale = Math.min(currentStage, maxStageValue) / currentStage;
253
- const stage = currentStage * this.stageScale;
254
- this.canvas.width = stage;
255
- this.canvas.height = stage;
256
- this.context.canvas.width = stage;
257
- this.context.canvas.height = stage;
255
+ this.stage = currentStage * this.stageScale;
256
+ this.canvas.width = this.stage;
257
+ this.canvas.height = this.stage;
258
+ this.context.canvas.width = this.stage;
259
+ this.context.canvas.height = this.stage;
258
260
  this.readBarcodeFromCanvas();
259
261
  },
260
262
  });
@@ -262,10 +264,11 @@ const TwintagQRScanner = class {
262
264
  }
263
265
  stopStream() {
264
266
  this.streamIsActive.emit(false);
267
+ this.video.srcObject = null;
265
268
  this.stream.getTracks().forEach((track) => {
266
269
  track.stop();
267
270
  });
268
- this.video.srcObject = null;
271
+ cancelAnimationFrame(this.reqAnimFrame);
269
272
  this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
270
273
  index$1.gsapWithCSS.to(this.videoContainerRef, {
271
274
  duration: 0.2,
@@ -3,11 +3,11 @@ import gsap from 'gsap';
3
3
  import { worker } from '../../scanner.worker?worker';
4
4
  export class TwintagQRScanner {
5
5
  constructor() {
6
+ this.stage = 0;
6
7
  this.stageScale = 1;
7
- this.eventsController = new AbortController();
8
8
  this.videoIsPlaying = false;
9
- this.devices = [];
10
9
  this.decoderIsBusy = false;
10
+ this.eventsController = new AbortController();
11
11
  this.stream = null;
12
12
  this.mode = 'single';
13
13
  this.format = 'QRCode';
@@ -40,7 +40,6 @@ export class TwintagQRScanner {
40
40
  if (event.code === 'ready') {
41
41
  this.decoderIsBusy = false;
42
42
  this.symbol.emit(event.result);
43
- this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
44
43
  if (this.mode === 'single') {
45
44
  this.eventsController.abort();
46
45
  this.stopStream();
@@ -93,32 +92,35 @@ export class TwintagQRScanner {
93
92
  }
94
93
  }
95
94
  readBarcodeFromCanvas() {
95
+ this.reqAnimFrame = requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
96
+ if (!this.stage)
97
+ return;
96
98
  this.drawInCanvas();
97
- const imageData = this.context.getImageData(0, 0, this.canvas.width, this.canvas.height);
99
+ const imageData = this.context.getImageData(0, 0, this.stage, this.stage);
98
100
  const sourceBuffer = imageData.data;
99
101
  if (!this.decoderIsBusy) {
100
102
  worker.postMessage({
101
103
  type: 'read',
102
104
  format: this.format,
103
105
  details: {
104
- width: this.canvas.width,
105
- height: this.canvas.height,
106
+ width: this.stage,
107
+ height: this.stage,
106
108
  sourceBuffer: sourceBuffer,
107
109
  },
108
110
  });
111
+ this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
109
112
  }
110
- requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
111
113
  }
112
114
  drawInCanvas() {
113
- const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
114
- const squareLength = stage * this.crop;
115
+ const videoStage = Math.min(this.video.videoWidth, this.video.videoHeight);
116
+ const squareLength = videoStage * this.crop;
115
117
  const center = {
116
118
  x: this.video.videoWidth / 2,
117
119
  y: this.video.videoHeight / 2,
118
120
  };
119
121
  const sx = center.x - squareLength / 2;
120
122
  const sy = center.y - squareLength / 2;
121
- this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, stage * this.stageScale, stage * this.stageScale);
123
+ this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, videoStage * this.stageScale, videoStage * this.stageScale);
122
124
  }
123
125
  async updateStream(constraints) {
124
126
  if (this.stream) {
@@ -165,20 +167,20 @@ export class TwintagQRScanner {
165
167
  };
166
168
  try {
167
169
  await this.updateStream(constraints);
168
- const devices = await navigator.mediaDevices.enumerateDevices();
169
- this.devices = devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
170
+ const raw_devices = await navigator.mediaDevices.enumerateDevices();
171
+ const devices = raw_devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
170
172
  device.label.toLowerCase().includes('back'));
171
- if (this.devices.length === 0) {
173
+ if (devices.length === 0) {
172
174
  return;
173
175
  }
174
- if (this.devices.length === 1) {
176
+ if (devices.length === 1) {
175
177
  constraints.video.deviceId = {
176
- exact: this.devices[0].deviceId,
178
+ exact: devices[0].deviceId,
177
179
  };
178
180
  await this.updateStream(constraints);
179
181
  }
180
- let backCameraIndex = this.devices.length - 1;
181
- const cameraResolutions = this.devices.map((camera) => {
182
+ let backCameraIndex = devices.length - 1;
183
+ const cameraResolutions = devices.map((camera) => {
182
184
  const match = camera.label.match(/\b([0-9]+)MP?\b/i);
183
185
  if (match != null) {
184
186
  return parseInt(match[1], 10);
@@ -189,7 +191,7 @@ export class TwintagQRScanner {
189
191
  backCameraIndex = cameraResolutions.lastIndexOf(Math.max(...cameraResolutions));
190
192
  }
191
193
  // back camera with the highest resolution
192
- const backCamera = this.devices[backCameraIndex];
194
+ const backCamera = devices[backCameraIndex];
193
195
  if (backCamera) {
194
196
  constraints.video.deviceId = {
195
197
  exact: backCamera.deviceId,
@@ -234,11 +236,11 @@ export class TwintagQRScanner {
234
236
  const currentStage = Math.min(this.video.videoWidth, this.video.videoHeight);
235
237
  const maxStageValue = 400;
236
238
  this.stageScale = Math.min(currentStage, maxStageValue) / currentStage;
237
- const stage = currentStage * this.stageScale;
238
- this.canvas.width = stage;
239
- this.canvas.height = stage;
240
- this.context.canvas.width = stage;
241
- this.context.canvas.height = stage;
239
+ this.stage = currentStage * this.stageScale;
240
+ this.canvas.width = this.stage;
241
+ this.canvas.height = this.stage;
242
+ this.context.canvas.width = this.stage;
243
+ this.context.canvas.height = this.stage;
242
244
  this.readBarcodeFromCanvas();
243
245
  },
244
246
  });
@@ -246,10 +248,11 @@ export class TwintagQRScanner {
246
248
  }
247
249
  stopStream() {
248
250
  this.streamIsActive.emit(false);
251
+ this.video.srcObject = null;
249
252
  this.stream.getTracks().forEach((track) => {
250
253
  track.stop();
251
254
  });
252
- this.video.srcObject = null;
255
+ cancelAnimationFrame(this.reqAnimFrame);
253
256
  this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
254
257
  gsap.to(this.videoContainerRef, {
255
258
  duration: 0.2,
@@ -359,12 +362,6 @@ export class TwintagQRScanner {
359
362
  }
360
363
  };
361
364
  }
362
- static get states() {
363
- return {
364
- "devices": {},
365
- "decoderIsBusy": {}
366
- };
367
- }
368
365
  static get events() {
369
366
  return [{
370
367
  "method": "symbol",
@@ -2,4 +2,4 @@
2
2
  /**
3
3
  * The library version.
4
4
  */
5
- export const VERSION = '0.2.284-fix-stream-visibility-9ac029dedd8eb46b8c97b6a6b8dfdb114e5e5de8';
5
+ export const VERSION = '0.2.284-fix-scanner-stream-visibility-fa1b63f803fa98c0ac1314c5943dd3461e208cfb';
@@ -17,11 +17,11 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
17
17
  this.symbol = createEvent(this, "symbol", 7);
18
18
  this.streamIsActive = createEvent(this, "streamIsActive", 7);
19
19
  this.frame = createEvent(this, "frame", 7);
20
+ this.stage = 0;
20
21
  this.stageScale = 1;
21
- this.eventsController = new AbortController();
22
22
  this.videoIsPlaying = false;
23
- this.devices = [];
24
23
  this.decoderIsBusy = false;
24
+ this.eventsController = new AbortController();
25
25
  this.stream = null;
26
26
  this.mode = 'single';
27
27
  this.format = 'QRCode';
@@ -54,7 +54,6 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
54
54
  if (event.code === 'ready') {
55
55
  this.decoderIsBusy = false;
56
56
  this.symbol.emit(event.result);
57
- this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
58
57
  if (this.mode === 'single') {
59
58
  this.eventsController.abort();
60
59
  this.stopStream();
@@ -107,32 +106,35 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
107
106
  }
108
107
  }
109
108
  readBarcodeFromCanvas() {
109
+ this.reqAnimFrame = requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
110
+ if (!this.stage)
111
+ return;
110
112
  this.drawInCanvas();
111
- const imageData = this.context.getImageData(0, 0, this.canvas.width, this.canvas.height);
113
+ const imageData = this.context.getImageData(0, 0, this.stage, this.stage);
112
114
  const sourceBuffer = imageData.data;
113
115
  if (!this.decoderIsBusy) {
114
116
  worker.postMessage({
115
117
  type: 'read',
116
118
  format: this.format,
117
119
  details: {
118
- width: this.canvas.width,
119
- height: this.canvas.height,
120
+ width: this.stage,
121
+ height: this.stage,
120
122
  sourceBuffer: sourceBuffer,
121
123
  },
122
124
  });
125
+ this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
123
126
  }
124
- requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
125
127
  }
126
128
  drawInCanvas() {
127
- const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
128
- const squareLength = stage * this.crop;
129
+ const videoStage = Math.min(this.video.videoWidth, this.video.videoHeight);
130
+ const squareLength = videoStage * this.crop;
129
131
  const center = {
130
132
  x: this.video.videoWidth / 2,
131
133
  y: this.video.videoHeight / 2,
132
134
  };
133
135
  const sx = center.x - squareLength / 2;
134
136
  const sy = center.y - squareLength / 2;
135
- this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, stage * this.stageScale, stage * this.stageScale);
137
+ this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, videoStage * this.stageScale, videoStage * this.stageScale);
136
138
  }
137
139
  async updateStream(constraints) {
138
140
  if (this.stream) {
@@ -179,20 +181,20 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
179
181
  };
180
182
  try {
181
183
  await this.updateStream(constraints);
182
- const devices = await navigator.mediaDevices.enumerateDevices();
183
- this.devices = devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
184
+ const raw_devices = await navigator.mediaDevices.enumerateDevices();
185
+ const devices = raw_devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
184
186
  device.label.toLowerCase().includes('back'));
185
- if (this.devices.length === 0) {
187
+ if (devices.length === 0) {
186
188
  return;
187
189
  }
188
- if (this.devices.length === 1) {
190
+ if (devices.length === 1) {
189
191
  constraints.video.deviceId = {
190
- exact: this.devices[0].deviceId,
192
+ exact: devices[0].deviceId,
191
193
  };
192
194
  await this.updateStream(constraints);
193
195
  }
194
- let backCameraIndex = this.devices.length - 1;
195
- const cameraResolutions = this.devices.map((camera) => {
196
+ let backCameraIndex = devices.length - 1;
197
+ const cameraResolutions = devices.map((camera) => {
196
198
  const match = camera.label.match(/\b([0-9]+)MP?\b/i);
197
199
  if (match != null) {
198
200
  return parseInt(match[1], 10);
@@ -203,7 +205,7 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
203
205
  backCameraIndex = cameraResolutions.lastIndexOf(Math.max(...cameraResolutions));
204
206
  }
205
207
  // back camera with the highest resolution
206
- const backCamera = this.devices[backCameraIndex];
208
+ const backCamera = devices[backCameraIndex];
207
209
  if (backCamera) {
208
210
  constraints.video.deviceId = {
209
211
  exact: backCamera.deviceId,
@@ -248,11 +250,11 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
248
250
  const currentStage = Math.min(this.video.videoWidth, this.video.videoHeight);
249
251
  const maxStageValue = 400;
250
252
  this.stageScale = Math.min(currentStage, maxStageValue) / currentStage;
251
- const stage = currentStage * this.stageScale;
252
- this.canvas.width = stage;
253
- this.canvas.height = stage;
254
- this.context.canvas.width = stage;
255
- this.context.canvas.height = stage;
253
+ this.stage = currentStage * this.stageScale;
254
+ this.canvas.width = this.stage;
255
+ this.canvas.height = this.stage;
256
+ this.context.canvas.width = this.stage;
257
+ this.context.canvas.height = this.stage;
256
258
  this.readBarcodeFromCanvas();
257
259
  },
258
260
  });
@@ -260,10 +262,11 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
260
262
  }
261
263
  stopStream() {
262
264
  this.streamIsActive.emit(false);
265
+ this.video.srcObject = null;
263
266
  this.stream.getTracks().forEach((track) => {
264
267
  track.stop();
265
268
  });
266
- this.video.srcObject = null;
269
+ cancelAnimationFrame(this.reqAnimFrame);
267
270
  this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
268
271
  gsapWithCSS.to(this.videoContainerRef, {
269
272
  duration: 0.2,
@@ -283,9 +286,7 @@ const TwintagQRScanner = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
283
286
  "stream": [1040],
284
287
  "mode": [1],
285
288
  "format": [1],
286
- "crop": [514],
287
- "devices": [32],
288
- "decoderIsBusy": [32]
289
+ "crop": [514]
289
290
  }, [[1, "updateZoom", "updateZoom"]]]);
290
291
  function defineCustomElement$1() {
291
292
  if (typeof customElements === "undefined") {
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514],"devices":[32],"decoderIsBusy":[32]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
13
+ return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514],"devices":[32],"decoderIsBusy":[32]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
16
+ return bootstrapLazy([["twintag-preview",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback",[[1,"twintag-auth-callback"]]],["twintag-auth-logout",[[1,"twintag-auth-logout"]]],["twintag-media",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
17
17
  });
@@ -15,11 +15,11 @@ const TwintagQRScanner = class {
15
15
  this.symbol = createEvent(this, "symbol", 7);
16
16
  this.streamIsActive = createEvent(this, "streamIsActive", 7);
17
17
  this.frame = createEvent(this, "frame", 7);
18
+ this.stage = 0;
18
19
  this.stageScale = 1;
19
- this.eventsController = new AbortController();
20
20
  this.videoIsPlaying = false;
21
- this.devices = [];
22
21
  this.decoderIsBusy = false;
22
+ this.eventsController = new AbortController();
23
23
  this.stream = null;
24
24
  this.mode = 'single';
25
25
  this.format = 'QRCode';
@@ -52,7 +52,6 @@ const TwintagQRScanner = class {
52
52
  if (event.code === 'ready') {
53
53
  this.decoderIsBusy = false;
54
54
  this.symbol.emit(event.result);
55
- this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
56
55
  if (this.mode === 'single') {
57
56
  this.eventsController.abort();
58
57
  this.stopStream();
@@ -105,32 +104,35 @@ const TwintagQRScanner = class {
105
104
  }
106
105
  }
107
106
  readBarcodeFromCanvas() {
107
+ this.reqAnimFrame = requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
108
+ if (!this.stage)
109
+ return;
108
110
  this.drawInCanvas();
109
- const imageData = this.context.getImageData(0, 0, this.canvas.width, this.canvas.height);
111
+ const imageData = this.context.getImageData(0, 0, this.stage, this.stage);
110
112
  const sourceBuffer = imageData.data;
111
113
  if (!this.decoderIsBusy) {
112
114
  worker.postMessage({
113
115
  type: 'read',
114
116
  format: this.format,
115
117
  details: {
116
- width: this.canvas.width,
117
- height: this.canvas.height,
118
+ width: this.stage,
119
+ height: this.stage,
118
120
  sourceBuffer: sourceBuffer,
119
121
  },
120
122
  });
123
+ this.frame.emit(this.canvas.toDataURL('image/png', 0.7));
121
124
  }
122
- requestAnimationFrame(this.readBarcodeFromCanvas.bind(this));
123
125
  }
124
126
  drawInCanvas() {
125
- const stage = Math.min(this.video.videoWidth, this.video.videoHeight);
126
- const squareLength = stage * this.crop;
127
+ const videoStage = Math.min(this.video.videoWidth, this.video.videoHeight);
128
+ const squareLength = videoStage * this.crop;
127
129
  const center = {
128
130
  x: this.video.videoWidth / 2,
129
131
  y: this.video.videoHeight / 2,
130
132
  };
131
133
  const sx = center.x - squareLength / 2;
132
134
  const sy = center.y - squareLength / 2;
133
- this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, stage * this.stageScale, stage * this.stageScale);
135
+ this.context.drawImage(this.video, sx, sy, squareLength, squareLength, 0, 0, videoStage * this.stageScale, videoStage * this.stageScale);
134
136
  }
135
137
  async updateStream(constraints) {
136
138
  if (this.stream) {
@@ -177,20 +179,20 @@ const TwintagQRScanner = class {
177
179
  };
178
180
  try {
179
181
  await this.updateStream(constraints);
180
- const devices = await navigator.mediaDevices.enumerateDevices();
181
- this.devices = devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
182
+ const raw_devices = await navigator.mediaDevices.enumerateDevices();
183
+ const devices = raw_devices.filter((device) => device.kind.toLowerCase() === 'videoinput' &&
182
184
  device.label.toLowerCase().includes('back'));
183
- if (this.devices.length === 0) {
185
+ if (devices.length === 0) {
184
186
  return;
185
187
  }
186
- if (this.devices.length === 1) {
188
+ if (devices.length === 1) {
187
189
  constraints.video.deviceId = {
188
- exact: this.devices[0].deviceId,
190
+ exact: devices[0].deviceId,
189
191
  };
190
192
  await this.updateStream(constraints);
191
193
  }
192
- let backCameraIndex = this.devices.length - 1;
193
- const cameraResolutions = this.devices.map((camera) => {
194
+ let backCameraIndex = devices.length - 1;
195
+ const cameraResolutions = devices.map((camera) => {
194
196
  const match = camera.label.match(/\b([0-9]+)MP?\b/i);
195
197
  if (match != null) {
196
198
  return parseInt(match[1], 10);
@@ -201,7 +203,7 @@ const TwintagQRScanner = class {
201
203
  backCameraIndex = cameraResolutions.lastIndexOf(Math.max(...cameraResolutions));
202
204
  }
203
205
  // back camera with the highest resolution
204
- const backCamera = this.devices[backCameraIndex];
206
+ const backCamera = devices[backCameraIndex];
205
207
  if (backCamera) {
206
208
  constraints.video.deviceId = {
207
209
  exact: backCamera.deviceId,
@@ -246,11 +248,11 @@ const TwintagQRScanner = class {
246
248
  const currentStage = Math.min(this.video.videoWidth, this.video.videoHeight);
247
249
  const maxStageValue = 400;
248
250
  this.stageScale = Math.min(currentStage, maxStageValue) / currentStage;
249
- const stage = currentStage * this.stageScale;
250
- this.canvas.width = stage;
251
- this.canvas.height = stage;
252
- this.context.canvas.width = stage;
253
- this.context.canvas.height = stage;
251
+ this.stage = currentStage * this.stageScale;
252
+ this.canvas.width = this.stage;
253
+ this.canvas.height = this.stage;
254
+ this.context.canvas.width = this.stage;
255
+ this.context.canvas.height = this.stage;
254
256
  this.readBarcodeFromCanvas();
255
257
  },
256
258
  });
@@ -258,10 +260,11 @@ const TwintagQRScanner = class {
258
260
  }
259
261
  stopStream() {
260
262
  this.streamIsActive.emit(false);
263
+ this.video.srcObject = null;
261
264
  this.stream.getTracks().forEach((track) => {
262
265
  track.stop();
263
266
  });
264
- this.video.srcObject = null;
267
+ cancelAnimationFrame(this.reqAnimFrame);
265
268
  this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
266
269
  gsapWithCSS.to(this.videoContainerRef, {
267
270
  duration: 0.2,
@@ -0,0 +1 @@
1
+ import{r as t,c as a,h as i,H as n}from"./p-cb286d41.js";import{g as r}from"./p-60325667.js";import{c as s}from"./p-5e046324.js";const c=s(new URL("p-02c80109.js",import.meta.url).href,"scanner.worker","stencil.scanner.worker"),e=class{constructor(i){t(this,i),this.symbol=a(this,"symbol",7),this.streamIsActive=a(this,"streamIsActive",7),this.frame=a(this,"frame",7),this.stage=0,this.stageScale=1,this.videoIsPlaying=!1,this.decoderIsBusy=!1,this.eventsController=new AbortController,this.stream=null,this.mode="single",this.format="QRCode",this.crop=1}async updateZoom(t){const[a]=this.stream.getVideoTracks();if(a.getCapabilities&&"function"==typeof a.applyConstraints){const i=a.getCapabilities();if("zoom"in a.getSettings()){const n=i.zoom.min,r=i.zoom.max;await a.applyConstraints({advanced:[{zoom:n+(r-n)*t.detail}]})}}}messageHandler(t){const a=t.data;"busy"===a.code&&(this.decoderIsBusy=!0),"ready"===a.code&&(this.decoderIsBusy=!1,this.symbol.emit(a.result),"single"===this.mode&&(this.eventsController.abort(),this.stopStream()))}componentWillLoad(){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",{alpha:!1,willReadFrequently:!0})}async componentDidLoad(){c.addEventListener("message",(t=>{const a=t.data;"busy"===a.code&&(this.decoderIsBusy=!0),"ready"===a.code&&(this.decoderIsBusy=!1,this.symbol.emit(a.result),"single"===this.mode&&(this.eventsController.abort(),this.stopStream()))}),{passive:!0,signal:this.eventsController.signal}),document.addEventListener("visibilitychange",(async()=>{document.hidden?this.stream&&this.stopStream():await this.startStream()}),{passive:!0,signal:this.eventsController.signal}),this.videoContainerRef.style.setProperty("--crop",""+50*(1-this.crop)),document.hidden||await this.startStream()}readBarcodeFromCanvas(){if(this.reqAnimFrame=requestAnimationFrame(this.readBarcodeFromCanvas.bind(this)),!this.stage)return;this.drawInCanvas();const t=this.context.getImageData(0,0,this.stage,this.stage);this.decoderIsBusy||(c.postMessage({type:"read",format:this.format,details:{width:this.stage,height:this.stage,sourceBuffer:t.data}}),this.frame.emit(this.canvas.toDataURL("image/png",.7)))}drawInCanvas(){const t=Math.min(this.video.videoWidth,this.video.videoHeight),a=t*this.crop;this.context.drawImage(this.video,this.video.videoWidth/2-a/2,this.video.videoHeight/2-a/2,a,a,0,0,t*this.stageScale,t*this.stageScale)}async updateStream(t){this.stream&&this.stream.getTracks().forEach((t=>{t.stop()}));try{this.stream=await navigator.mediaDevices.getUserMedia(t),this.video.srcObject=null,this.video.srcObject=this.stream,this.video.setAttribute("playsinline","true"),this.video.onplaying=()=>{this.videoIsPlaying=!0},this.video.onpause=()=>{this.videoIsPlaying=!1},this.videoIsPlaying||(await this.video.play(),this.videoIsPlaying=!0)}catch(t){console.error(t)}}async getTrackSettings(t){try{return(await navigator.mediaDevices.getUserMedia(t)).getVideoTracks()[0].getSettings()}catch(t){console.error(t)}}async getMedia(t){t.video.width={min:1080,ideal:1600,max:1920};try{await this.updateStream(t);const a=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind.toLowerCase()&&t.label.toLowerCase().includes("back")));if(0===a.length)return;1===a.length&&(t.video.deviceId={exact:a[0].deviceId},await this.updateStream(t));let i=a.length-1;const n=a.map((t=>{const a=t.label.match(/\b([0-9]+)MP?\b/i);return null!=a?parseInt(a[1],10):NaN}));n.some((t=>isNaN(t)))||(i=n.lastIndexOf(Math.max(...n)));const r=a[i];if(r)return t.video.deviceId={exact:r.deviceId},void await this.updateStream(t);const s=await this.getTrackSettings(t);s.focusDistance&&(t.video.advanced=[{focusMode:"continuous",focusDistance:s.focusDistance}],await this.updateStream(t))}catch(t){console.error(t)}this.stream&&this.streamIsActive.emit(!0)}async startStream(){const t={audio:!1,video:{aspectRatio:{ideal:1},facingMode:"environment"}};navigator.mediaDevices.getSupportedConstraints().zoom&&(t.video.zoom=!0),await this.getMedia(t),this.videoIsPlaying&&r.to(this.videoContainerRef,{duration:.2,opacity:1,onComplete:()=>{const t=Math.min(this.video.videoWidth,this.video.videoHeight);this.stageScale=Math.min(t,400)/t,this.stage=t*this.stageScale,this.canvas.width=this.stage,this.canvas.height=this.stage,this.context.canvas.width=this.stage,this.context.canvas.height=this.stage,this.readBarcodeFromCanvas()}})}stopStream(){this.streamIsActive.emit(!1),this.video.srcObject=null,this.stream.getTracks().forEach((t=>{t.stop()})),cancelAnimationFrame(this.reqAnimFrame),this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height),r.to(this.videoContainerRef,{duration:.2,opacity:0})}disconnectedCallback(){this.eventsController.abort(),this.stopStream()}render(){return i(n,null,i("div",{class:"video-container",ref:t=>this.videoContainerRef=t},i("div",{class:"video-corners"}),i("video",{crossOrigin:"Anonymous",autoplay:!0,playsinline:!0,ref:t=>this.video=t})))}static get assetsDirs(){return["assets"]}};e.style=':host{--twintag-scanner-bg-select-cameras:white;--twintag-scanner-text-select-cameras:black;--twintag-scanner-radius-select-cameras:6px 0 0 0;--twintag-scanner-min-height:min-content;--twintag-scanner-corners-color:white;--twintag-scanner-corners-width:4px;--twintag-scanner-corners-length:36px;--twintag-scanner-corners-offset:24px;display:grid;place-items:center;position:relative;width:100%}:host .icon-container{display:grid;place-items:center;position:absolute;inset:0;z-index:-2222}:host .icon-container .check-icon{opacity:0;z-index:2222}:host .video-container{--crop:0;--crop-x:var(--crop);--crop-y:var(--crop);display:flex;align-items:center;justify-content:center;position:relative;width:100%;height:100%;opacity:0;overflow:hidden;z-index:1}:host .video-container::after{content:"";position:absolute;width:100%;height:100%;opacity:inherit;background:rgba(0, 0, 0, 0.5);-webkit-clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%);clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%)}:host .video-container:before{display:block;content:"";width:100%;padding-top:100%}:host .video-container .video-corners{position:absolute;width:calc((1 - var(--crop-x) / 50) * 100% + var(--twintag-scanner-corners-offset));height:calc((1 - var(--crop-y) / 50) * 100% + var(--twintag-scanner-corners-offset));opacity:inherit;background:linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%;background-size:var(--twintag-scanner-corners-length) var(--twintag-scanner-corners-length);background-repeat:no-repeat;z-index:2222}:host .video-container video{position:absolute;width:100% !important;object-fit:cover;object-position:center;aspect-ratio:1/1 !important;min-height:var(--twintag-scanner-min-height)}';export{e as twintag_qr_scanner}
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-cb286d41.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((e=>t([["p-fb43176d",[[1,"twintag-preview",{item:[1],initial:[16],smoothExtinction:[2,"smooth-extinction"],extension:[1],showButtons:[4,"show-buttons"],previewableItem:[32],type:[32]}]]],["p-821ba724",[[1,"twintag-auth-callback"]]],["p-0be73e86",[[1,"twintag-auth-logout"]]],["p-84e1cfed",[[1,"twintag-media",{first:[1],middle:[1],last:[1]}]]],["p-dff77416",[[1,"twintag-ocr-scanner",{stream:[1040],mode:[1],cropX:[2,"crop-x"],cropY:[2,"crop-y"],devices:[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["p-67e2625e",[[1,"twintag-offline-actions",{enableSingleRetry:[4,"enable-single-retry"],header:[1],showTimestamp:[4,"show-timestamp"],showDescription:[4,"show-description"],closeText:[1,"close-text"],retryText:[1,"retry-text"],noPendingActionsText:[1,"no-pending-actions-text"],pendingOfflineRequests:[32],processing:[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["p-37b2160f",[[1,"twintag-offline-state",{onlineState:[32],pendingRequests:[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["p-5f1060fe",[[1,"twintag-offline-support",{autoSync:[4,"auto-sync"],forceOffline:[4,"force-offline"],config:[16]}]]],["p-b3abcf46",[[1,"twintag-qr-scanner",{stream:[1040],mode:[1],format:[1],crop:[514],devices:[32],decoderIsBusy:[32]},[[1,"updateZoom","updateZoom"]]]]],["p-feeba1cd",[[1,"twintag-share",{url:[1],modalTitle:[1,"modal-title"],modalSubtitle:[1,"modal-subtitle"],closeBtn:[1,"close-btn"],copyClipboardBtn:[1,"copy-clipboard-btn"],open:[1540]},[[0,"keydown","handleKeyDown"]]]]],["p-4a001573",[[1,"twintag-spinner",{color:[513],duration:[2],name:[1]}]]],["p-01d4afb8",[[0,"twintag-pdf-viewer",{src:[1],fileName:[1,"file-name"],file:[32],fileURL:[32]}]]]],e)));
1
+ import{p as e,b as t}from"./p-cb286d41.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((e=>t([["p-fb43176d",[[1,"twintag-preview",{item:[1],initial:[16],smoothExtinction:[2,"smooth-extinction"],extension:[1],showButtons:[4,"show-buttons"],previewableItem:[32],type:[32]}]]],["p-821ba724",[[1,"twintag-auth-callback"]]],["p-0be73e86",[[1,"twintag-auth-logout"]]],["p-84e1cfed",[[1,"twintag-media",{first:[1],middle:[1],last:[1]}]]],["p-dff77416",[[1,"twintag-ocr-scanner",{stream:[1040],mode:[1],cropX:[2,"crop-x"],cropY:[2,"crop-y"],devices:[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["p-67e2625e",[[1,"twintag-offline-actions",{enableSingleRetry:[4,"enable-single-retry"],header:[1],showTimestamp:[4,"show-timestamp"],showDescription:[4,"show-description"],closeText:[1,"close-text"],retryText:[1,"retry-text"],noPendingActionsText:[1,"no-pending-actions-text"],pendingOfflineRequests:[32],processing:[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["p-37b2160f",[[1,"twintag-offline-state",{onlineState:[32],pendingRequests:[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["p-5f1060fe",[[1,"twintag-offline-support",{autoSync:[4,"auto-sync"],forceOffline:[4,"force-offline"],config:[16]}]]],["p-6e35bc47",[[1,"twintag-qr-scanner",{stream:[1040],mode:[1],format:[1],crop:[514]},[[1,"updateZoom","updateZoom"]]]]],["p-feeba1cd",[[1,"twintag-share",{url:[1],modalTitle:[1,"modal-title"],modalSubtitle:[1,"modal-subtitle"],closeBtn:[1,"close-btn"],copyClipboardBtn:[1,"copy-clipboard-btn"],open:[1540]},[[0,"keydown","handleKeyDown"]]]]],["p-4a001573",[[1,"twintag-spinner",{color:[513],duration:[2],name:[1]}]]],["p-01d4afb8",[[0,"twintag-pdf-viewer",{src:[1],fileName:[1,"file-name"],file:[32],fileURL:[32]}]]]],e)));
@@ -7,11 +7,12 @@ export declare class TwintagQRScanner {
7
7
  canvas: HTMLCanvasElement;
8
8
  context: CanvasRenderingContext2D;
9
9
  preprocessor: Preprocessing;
10
+ stage: number;
10
11
  stageScale: number;
11
- eventsController: AbortController;
12
+ reqAnimFrame: number;
12
13
  videoIsPlaying: boolean;
13
- devices: MediaDeviceInfo[];
14
14
  decoderIsBusy: boolean;
15
+ eventsController: AbortController;
15
16
  stream: MediaStream | null;
16
17
  mode: 'single' | 'streaming';
17
18
  format: Format;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * The library version.
3
3
  */
4
- export declare const VERSION = "0.2.284-fix-stream-visibility-9ac029dedd8eb46b8c97b6a6b8dfdb114e5e5de8";
4
+ export declare const VERSION = "0.2.284-fix-scanner-stream-visibility-fa1b63f803fa98c0ac1314c5943dd3461e208cfb";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twintag/twintag-core",
3
- "version": "0.2.284-fix-stream-visibility-9ac029dedd8eb46b8c97b6a6b8dfdb114e5e5de8",
3
+ "version": "0.2.284-fix-scanner-stream-visibility-fa1b63f803fa98c0ac1314c5943dd3461e208cfb",
4
4
  "author": "Twintag",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- import{r as t,c as a,h as i,H as n}from"./p-cb286d41.js";import{g as r}from"./p-60325667.js";import{c as s}from"./p-5e046324.js";const c=s(new URL("p-02c80109.js",import.meta.url).href,"scanner.worker","stencil.scanner.worker"),e=class{constructor(i){t(this,i),this.symbol=a(this,"symbol",7),this.streamIsActive=a(this,"streamIsActive",7),this.frame=a(this,"frame",7),this.stageScale=1,this.eventsController=new AbortController,this.videoIsPlaying=!1,this.devices=[],this.decoderIsBusy=!1,this.stream=null,this.mode="single",this.format="QRCode",this.crop=1}async updateZoom(t){const[a]=this.stream.getVideoTracks();if(a.getCapabilities&&"function"==typeof a.applyConstraints){const i=a.getCapabilities();if("zoom"in a.getSettings()){const n=i.zoom.min,r=i.zoom.max;await a.applyConstraints({advanced:[{zoom:n+(r-n)*t.detail}]})}}}messageHandler(t){const a=t.data;"busy"===a.code&&(this.decoderIsBusy=!0),"ready"===a.code&&(this.decoderIsBusy=!1,this.symbol.emit(a.result),this.frame.emit(this.canvas.toDataURL("image/png",.7)),"single"===this.mode&&(this.eventsController.abort(),this.stopStream()))}componentWillLoad(){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",{alpha:!1,willReadFrequently:!0})}async componentDidLoad(){c.addEventListener("message",(t=>{const a=t.data;"busy"===a.code&&(this.decoderIsBusy=!0),"ready"===a.code&&(this.decoderIsBusy=!1,this.symbol.emit(a.result),"single"===this.mode&&(this.eventsController.abort(),this.stopStream()))}),{passive:!0,signal:this.eventsController.signal}),document.addEventListener("visibilitychange",(async()=>{document.hidden?this.stream&&this.stopStream():await this.startStream()}),{passive:!0,signal:this.eventsController.signal}),this.videoContainerRef.style.setProperty("--crop",""+50*(1-this.crop)),document.hidden||await this.startStream()}readBarcodeFromCanvas(){this.drawInCanvas();const t=this.context.getImageData(0,0,this.canvas.width,this.canvas.height);this.decoderIsBusy||c.postMessage({type:"read",format:this.format,details:{width:this.canvas.width,height:this.canvas.height,sourceBuffer:t.data}}),requestAnimationFrame(this.readBarcodeFromCanvas.bind(this))}drawInCanvas(){const t=Math.min(this.video.videoWidth,this.video.videoHeight),a=t*this.crop;this.context.drawImage(this.video,this.video.videoWidth/2-a/2,this.video.videoHeight/2-a/2,a,a,0,0,t*this.stageScale,t*this.stageScale)}async updateStream(t){this.stream&&this.stream.getTracks().forEach((t=>{t.stop()}));try{this.stream=await navigator.mediaDevices.getUserMedia(t),this.video.srcObject=null,this.video.srcObject=this.stream,this.video.setAttribute("playsinline","true"),this.video.onplaying=()=>{this.videoIsPlaying=!0},this.video.onpause=()=>{this.videoIsPlaying=!1},this.videoIsPlaying||(await this.video.play(),this.videoIsPlaying=!0)}catch(t){console.error(t)}}async getTrackSettings(t){try{return(await navigator.mediaDevices.getUserMedia(t)).getVideoTracks()[0].getSettings()}catch(t){console.error(t)}}async getMedia(t){t.video.width={min:1080,ideal:1600,max:1920};try{await this.updateStream(t);const a=await navigator.mediaDevices.enumerateDevices();if(this.devices=a.filter((t=>"videoinput"===t.kind.toLowerCase()&&t.label.toLowerCase().includes("back"))),0===this.devices.length)return;1===this.devices.length&&(t.video.deviceId={exact:this.devices[0].deviceId},await this.updateStream(t));let i=this.devices.length-1;const n=this.devices.map((t=>{const a=t.label.match(/\b([0-9]+)MP?\b/i);return null!=a?parseInt(a[1],10):NaN}));n.some((t=>isNaN(t)))||(i=n.lastIndexOf(Math.max(...n)));const r=this.devices[i];if(r)return t.video.deviceId={exact:r.deviceId},void await this.updateStream(t);const s=await this.getTrackSettings(t);s.focusDistance&&(t.video.advanced=[{focusMode:"continuous",focusDistance:s.focusDistance}],await this.updateStream(t))}catch(t){console.error(t)}this.stream&&this.streamIsActive.emit(!0)}async startStream(){const t={audio:!1,video:{aspectRatio:{ideal:1},facingMode:"environment"}};navigator.mediaDevices.getSupportedConstraints().zoom&&(t.video.zoom=!0),await this.getMedia(t),this.videoIsPlaying&&r.to(this.videoContainerRef,{duration:.2,opacity:1,onComplete:()=>{const t=Math.min(this.video.videoWidth,this.video.videoHeight);this.stageScale=Math.min(t,400)/t;const a=t*this.stageScale;this.canvas.width=a,this.canvas.height=a,this.context.canvas.width=a,this.context.canvas.height=a,this.readBarcodeFromCanvas()}})}stopStream(){this.streamIsActive.emit(!1),this.stream.getTracks().forEach((t=>{t.stop()})),this.video.srcObject=null,this.context.clearRect(0,0,this.context.canvas.width,this.context.canvas.height),r.to(this.videoContainerRef,{duration:.2,opacity:0})}disconnectedCallback(){this.eventsController.abort(),this.stopStream()}render(){return i(n,null,i("div",{class:"video-container",ref:t=>this.videoContainerRef=t},i("div",{class:"video-corners"}),i("video",{crossOrigin:"Anonymous",autoplay:!0,playsinline:!0,ref:t=>this.video=t})))}static get assetsDirs(){return["assets"]}};e.style=':host{--twintag-scanner-bg-select-cameras:white;--twintag-scanner-text-select-cameras:black;--twintag-scanner-radius-select-cameras:6px 0 0 0;--twintag-scanner-min-height:min-content;--twintag-scanner-corners-color:white;--twintag-scanner-corners-width:4px;--twintag-scanner-corners-length:36px;--twintag-scanner-corners-offset:24px;display:grid;place-items:center;position:relative;width:100%}:host .icon-container{display:grid;place-items:center;position:absolute;inset:0;z-index:-2222}:host .icon-container .check-icon{opacity:0;z-index:2222}:host .video-container{--crop:0;--crop-x:var(--crop);--crop-y:var(--crop);display:flex;align-items:center;justify-content:center;position:relative;width:100%;height:100%;opacity:0;overflow:hidden;z-index:1}:host .video-container::after{content:"";position:absolute;width:100%;height:100%;opacity:inherit;background:rgba(0, 0, 0, 0.5);-webkit-clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%);clip-path:polygon(0% 0%, 0% 100%, calc(var(--crop-x) * 1%) 100%, calc(var(--crop-x) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(var(--crop-y) * 1%), calc(calc(100 - var(--crop-x)) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) calc(calc(100 - var(--crop-y)) * 1%), calc(var(--crop-x) * 1%) 100%, 100% 100%, 100% 0%)}:host .video-container:before{display:block;content:"";width:100%;padding-top:100%}:host .video-container .video-corners{position:absolute;width:calc((1 - var(--crop-x) / 50) * 100% + var(--twintag-scanner-corners-offset));height:calc((1 - var(--crop-y) / 50) * 100% + var(--twintag-scanner-corners-offset));opacity:inherit;background:linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to right, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to left, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 0, linear-gradient(to bottom, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 0, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 0 100%, linear-gradient(to top, var(--twintag-scanner-corners-color) var(--twintag-scanner-corners-width), transparent var(--twintag-scanner-corners-width)) 100% 100%;background-size:var(--twintag-scanner-corners-length) var(--twintag-scanner-corners-length);background-repeat:no-repeat;z-index:2222}:host .video-container video{position:absolute;width:100% !important;object-fit:cover;object-position:center;aspect-ratio:1/1 !important;min-height:var(--twintag-scanner-min-height)}';export{e as twintag_qr_scanner}