adp-web-components 0.0.70 → 0.0.72
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/cjs/contact-us-form.cjs.entry.js +3 -3
- package/dist/cjs/dead-stock-lookup_3.cjs.entry.js +2 -2
- package/dist/cjs/dynamic-claim_6.cjs.entry.js +7 -7
- package/dist/cjs/dynamic-redeem.cjs.entry.js +3 -3
- package/dist/cjs/form-dialog_8.cjs.entry.js +12 -12
- package/dist/cjs/{get-local-language-ed398f45.js → get-local-language-f9a029a2.js} +2 -2
- package/dist/cjs/{index-603d8f32.js → index-5612fce0.js} +4 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/loading-spinner.cjs.entry.js +2 -2
- package/dist/cjs/part-lookup.cjs.entry.js +2 -2
- package/dist/cjs/service-booking-form.cjs.entry.js +3 -3
- package/dist/cjs/shift-components.cjs.js +2 -2
- package/dist/cjs/validate-vin-32e95695.js +66 -0
- package/dist/cjs/vehicle-lookup.cjs.entry.js +5 -63
- package/dist/cjs/vin-extractor.cjs.entry.js +355 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/components/loading-spinner.css +1 -1
- package/dist/collection/components/form-elements/form-dialog.css +1 -1
- package/dist/collection/components/form-elements/form-input.css +1 -1
- package/dist/collection/components/form-elements/form-select.css +1 -1
- package/dist/collection/components/form-elements/form-select.js +1 -1
- package/dist/collection/components/form-elements/form-shadow-input.css +1 -1
- package/dist/collection/components/form-elements/form-structure-error.css +1 -1
- package/dist/collection/components/form-elements/form-structure.css +1 -1
- package/dist/collection/components/form-elements/form-submit.css +1 -1
- package/dist/collection/components/form-elements/form-submit.js +1 -1
- package/dist/collection/components/form-elements/form-text-area.css +1 -1
- package/dist/collection/components/forms/contact-us/form.css +1 -1
- package/dist/collection/components/forms/service-booking/form.css +1 -1
- package/dist/collection/components/vehicle-lookup/dynamic-claim.css +1 -1
- package/dist/collection/components/vehicle-lookup/dynamic-redeem.css +1 -1
- package/dist/collection/components/vehicle-lookup/paint-thickness.css +1 -1
- package/dist/collection/components/vehicle-lookup/service-history.css +1 -1
- package/dist/collection/components/vehicle-lookup/vehicle-lookup.css +1 -1
- package/dist/collection/components/vehicle-lookup/vehicle-specification.css +1 -1
- package/dist/collection/components/vehicle-lookup/warranty-details.css +1 -1
- package/dist/collection/components/vin-extractor/vin-extractor.css +1 -0
- package/dist/collection/components/vin-extractor/vin-extractor.js +685 -0
- package/dist/components/contact-us-form.js +1 -1
- package/dist/components/dead-stock-lookup.js +1 -1
- package/dist/components/distributor-lookup.js +1 -1
- package/dist/components/dynamic-claim.js +1 -1
- package/dist/components/dynamic-redeem.js +1 -1
- package/dist/components/form-dialog.js +1 -1
- package/dist/components/form-input.js +1 -1
- package/dist/components/form-select.js +1 -1
- package/dist/components/form-shadow-input.js +1 -1
- package/dist/components/form-structure-error.js +1 -1
- package/dist/components/form-structure.js +1 -1
- package/dist/components/form-submit.js +1 -1
- package/dist/components/form-text-area.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/loading-spinner.js +1 -1
- package/dist/components/manufacturer-lookup.js +1 -1
- package/dist/components/{p-50486237.js → p-1a148a93.js} +1 -1
- package/dist/components/{p-c3e9cdab.js → p-2f3e9990.js} +1 -1
- package/dist/components/p-2f4307b6.js +5 -0
- package/dist/components/p-30cd9b80.js +5 -0
- package/dist/components/{p-406105c4.js → p-34ab8f50.js} +1 -1
- package/dist/components/{p-55010f0f.js → p-36daa524.js} +1 -1
- package/dist/components/p-383b4ddf.js +5 -0
- package/dist/components/p-390074b8.js +5 -0
- package/dist/components/p-4058ba1c.js +5 -0
- package/dist/components/{p-390f3642.js → p-46c215bc.js} +1 -1
- package/dist/components/{p-dc50f82c.js → p-4b66daaa.js} +1 -1
- package/dist/components/{p-bff4a56f.js → p-7c5bb2f0.js} +1 -1
- package/dist/components/p-83551794.js +5 -0
- package/dist/components/{p-86ab6816.js → p-8532d520.js} +1 -1
- package/dist/components/p-85e2d0e9.js +5 -0
- package/dist/components/{p-3bac7226.js → p-8beea546.js} +1 -1
- package/dist/components/{p-ea7b01f1.js → p-9a7ba161.js} +1 -1
- package/dist/components/{p-75476014.js → p-c2432b50.js} +1 -1
- package/dist/components/p-c7367b78.js +5 -0
- package/dist/components/p-cacd1d45.js +5 -0
- package/dist/components/{p-c828a561.js → p-cbadc580.js} +1 -1
- package/dist/components/p-df6c0330.js +5 -0
- package/dist/components/paint-thickness.js +1 -1
- package/dist/components/part-lookup.js +1 -1
- package/dist/components/service-booking-form.js +1 -1
- package/dist/components/service-history.js +1 -1
- package/dist/components/vehicle-accessories.js +1 -1
- package/dist/components/vehicle-lookup.js +1 -1
- package/dist/components/vehicle-specification.js +1 -1
- package/dist/components/vin-extractor.d.ts +11 -0
- package/dist/components/vin-extractor.js +5 -0
- package/dist/components/warranty-details.js +1 -1
- package/dist/esm/contact-us-form.entry.js +3 -3
- package/dist/esm/dead-stock-lookup_3.entry.js +2 -2
- package/dist/esm/dynamic-claim_6.entry.js +7 -7
- package/dist/esm/dynamic-redeem.entry.js +3 -3
- package/dist/esm/form-dialog_8.entry.js +12 -12
- package/dist/esm/{get-local-language-3a521229.js → get-local-language-54067db8.js} +2 -2
- package/dist/esm/{index-cac905b0.js → index-aec4162d.js} +4 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/loading-spinner.entry.js +2 -2
- package/dist/esm/part-lookup.entry.js +2 -2
- package/dist/esm/service-booking-form.entry.js +3 -3
- package/dist/esm/shift-components.js +3 -3
- package/dist/esm/validate-vin-f4d23a44.js +64 -0
- package/dist/esm/vehicle-lookup.entry.js +4 -62
- package/dist/esm/vin-extractor.entry.js +351 -0
- package/dist/shift-components/{p-101ea340.entry.js → p-0434d1ff.entry.js} +1 -1
- package/dist/shift-components/p-0e7fa34e.entry.js +5 -0
- package/dist/shift-components/p-383b4ddf.js +5 -0
- package/dist/shift-components/{p-65102e7a.js → p-42396de9.js} +2 -2
- package/dist/shift-components/p-7a54d2cc.entry.js +5 -0
- package/dist/shift-components/{p-b4953779.entry.js → p-90137c09.entry.js} +1 -1
- package/dist/shift-components/{p-7037e294.js → p-abbc56c4.js} +1 -1
- package/dist/shift-components/{p-13fe4960.entry.js → p-c9c30dd9.entry.js} +1 -1
- package/dist/shift-components/{p-20ca212b.entry.js → p-cd1bd1b3.entry.js} +1 -1
- package/dist/shift-components/{p-466d8ff8.entry.js → p-d1b5af4a.entry.js} +1 -1
- package/dist/shift-components/{p-0913b3c0.entry.js → p-f1341ffc.entry.js} +1 -1
- package/dist/shift-components/p-f8d63182.entry.js +5 -0
- package/dist/shift-components/p-f980b4dd.entry.js +5 -0
- package/dist/shift-components/shift-components.esm.js +1 -1
- package/dist/types/components/vin-extractor/vin-extractor.d.ts +58 -0
- package/dist/types/components.d.ts +44 -0
- package/package.json +1 -1
- package/dist/components/p-006db64e.js +0 -5
- package/dist/components/p-045d8c28.js +0 -5
- package/dist/components/p-21926252.js +0 -5
- package/dist/components/p-39dc4ee4.js +0 -5
- package/dist/components/p-512ea6f9.js +0 -5
- package/dist/components/p-661d64e2.js +0 -5
- package/dist/components/p-75b4d568.js +0 -5
- package/dist/components/p-e7371f3f.js +0 -5
- package/dist/components/p-e92bb96c.js +0 -5
- package/dist/shift-components/p-4d191607.entry.js +0 -5
- package/dist/shift-components/p-64f48109.entry.js +0 -5
- package/dist/shift-components/p-d8fe381b.entry.js +0 -5
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built by ShiftSoftware
|
|
3
|
+
* Copyright (c)
|
|
4
|
+
*/
|
|
5
|
+
import { h, Host } from "@stencil/core";
|
|
6
|
+
import cn from "../../global/lib/cn";
|
|
7
|
+
import validateVin from "../../global/lib/validate-vin";
|
|
8
|
+
const CAPTURE_INTERVAL = 2000;
|
|
9
|
+
const ACTIVE_CAMERA_ID_KEY = 'activeCameraId';
|
|
10
|
+
export class VinExtractor {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.registerFileUploader = () => {
|
|
13
|
+
if (this.readSticker && !this.codeReader) {
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
this.componentDidLoad();
|
|
16
|
+
}, 100);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.fileButton = document.querySelector('#' + this.uploaderButtonId);
|
|
20
|
+
this.fileInput = this.el.shadowRoot.querySelector('.vin-extractor-input');
|
|
21
|
+
this.fileButton.removeEventListener('click', this.onFileUploaderClick);
|
|
22
|
+
this.fileInput.removeEventListener('change', this.onFileUploaderChange);
|
|
23
|
+
this.fileButton.addEventListener('click', this.onFileUploaderClick);
|
|
24
|
+
this.fileInput.addEventListener('change', this.onFileUploaderChange);
|
|
25
|
+
};
|
|
26
|
+
this.onFileUploaderClick = () => {
|
|
27
|
+
this.fileInput.click();
|
|
28
|
+
};
|
|
29
|
+
this.onFileUploaderChange = () => {
|
|
30
|
+
var _a;
|
|
31
|
+
const file = (_a = this.fileInput.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
32
|
+
if (!file)
|
|
33
|
+
return;
|
|
34
|
+
const img = new Image();
|
|
35
|
+
const reader = new FileReader();
|
|
36
|
+
reader.onload = () => {
|
|
37
|
+
img.src = reader.result;
|
|
38
|
+
};
|
|
39
|
+
img.onload = async () => {
|
|
40
|
+
this.handleOnProcessing(true);
|
|
41
|
+
const ctx = this.videoCanvas.getContext('2d');
|
|
42
|
+
this.videoCanvas.width = img.width;
|
|
43
|
+
this.videoCanvas.height = img.height;
|
|
44
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(img, 0, 0);
|
|
45
|
+
const imageDataUrl = this.videoCanvas.toDataURL('image/png');
|
|
46
|
+
await this.handleImage(imageDataUrl);
|
|
47
|
+
this.handleOnProcessing(false);
|
|
48
|
+
};
|
|
49
|
+
reader.readAsDataURL(file);
|
|
50
|
+
};
|
|
51
|
+
this.triggerCallback = (callback, ...args) => {
|
|
52
|
+
var _a;
|
|
53
|
+
if (callback) {
|
|
54
|
+
if (typeof callback === 'function')
|
|
55
|
+
callback(...args);
|
|
56
|
+
else if (this.blazorRef && typeof callback === 'string' && !!callback)
|
|
57
|
+
(_a = this.blazorRef) === null || _a === void 0 ? void 0 : _a.invokeMethodAsync(callback, ...args);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this.handleError = (error) => {
|
|
61
|
+
this.triggerCallback(this.onError, error);
|
|
62
|
+
};
|
|
63
|
+
this.handleExtract = (vin) => {
|
|
64
|
+
this.triggerCallback(this.onExtract, vin);
|
|
65
|
+
};
|
|
66
|
+
this.handleOnProcessing = (isProcessing) => {
|
|
67
|
+
this.triggerCallback(this.onProcessing, isProcessing);
|
|
68
|
+
};
|
|
69
|
+
this.captureFrame = async (manualCapture = false) => {
|
|
70
|
+
if (!this.isOpen)
|
|
71
|
+
return;
|
|
72
|
+
if (!this.videoPlayer || !this.videoCanvas)
|
|
73
|
+
return this.componentDidLoad();
|
|
74
|
+
const ctx = this.videoCanvas.getContext('2d');
|
|
75
|
+
if (!ctx)
|
|
76
|
+
return;
|
|
77
|
+
this.handleOnProcessing(true);
|
|
78
|
+
if (manualCapture) {
|
|
79
|
+
this.videoPlayer.pause();
|
|
80
|
+
this.manualCaptureLoading = true;
|
|
81
|
+
}
|
|
82
|
+
this.videoCanvas.width = this.videoPlayer.videoWidth;
|
|
83
|
+
this.videoCanvas.height = this.videoPlayer.videoHeight;
|
|
84
|
+
ctx.drawImage(this.videoPlayer, 0, 0, this.videoCanvas.width, this.videoCanvas.height);
|
|
85
|
+
const imageDataUrl = this.videoCanvas.toDataURL('image/png');
|
|
86
|
+
this.handleImage(imageDataUrl);
|
|
87
|
+
if (!this.manualCapture) {
|
|
88
|
+
this.frameCaptureTimeoutRef = setTimeout(this.captureFrame, this.captureInterval);
|
|
89
|
+
this.handleOnProcessing(false);
|
|
90
|
+
}
|
|
91
|
+
if (manualCapture) {
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
this.videoPlayer.play();
|
|
94
|
+
this.manualCaptureLoading = false;
|
|
95
|
+
this.handleOnProcessing(false);
|
|
96
|
+
}, 1000);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
this.handleImage = async (imageDataUrl) => {
|
|
100
|
+
if (this.readSticker)
|
|
101
|
+
await this.stickerHandler(imageDataUrl);
|
|
102
|
+
if (this.useOcr && this.ocrEndpoint)
|
|
103
|
+
await this.ocrHandler(imageDataUrl);
|
|
104
|
+
};
|
|
105
|
+
this.ocrHandler = async (imageDataUrl) => {
|
|
106
|
+
try {
|
|
107
|
+
const response = await fetch(this.ocrEndpoint, {
|
|
108
|
+
method: 'POST',
|
|
109
|
+
headers: {
|
|
110
|
+
'Content-Type': 'application/json',
|
|
111
|
+
},
|
|
112
|
+
signal: this.abortController.signal,
|
|
113
|
+
body: JSON.stringify({ image: imageDataUrl.split(',')[1] }),
|
|
114
|
+
});
|
|
115
|
+
if (!response.ok)
|
|
116
|
+
throw new Error('Failed to fetch OCR result');
|
|
117
|
+
if (this.verbose)
|
|
118
|
+
console.log(response);
|
|
119
|
+
const data = await response.text();
|
|
120
|
+
if (this.skipValidation || (!!data.trim() && validateVin(data)))
|
|
121
|
+
this.handleExtract(data);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
this.handleError(error);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
this.stickerHandler = async (imageDataUrl) => {
|
|
128
|
+
try {
|
|
129
|
+
if (this.verbose)
|
|
130
|
+
console.log('try detecting sticker');
|
|
131
|
+
const result = await this.codeReader.decodeFromImage(undefined, imageDataUrl);
|
|
132
|
+
const text = result.getText();
|
|
133
|
+
if (this.verbose)
|
|
134
|
+
console.log(text);
|
|
135
|
+
if (!!text.trim()) {
|
|
136
|
+
if (this.skipValidation)
|
|
137
|
+
this.handleExtract(text.trim());
|
|
138
|
+
else {
|
|
139
|
+
const vin = text.replace(/[qo]/g, '0').replace(/i/g, '1').replace(/ /g, '');
|
|
140
|
+
if (vin.length === 17 && validateVin(vin))
|
|
141
|
+
this.handleExtract(vin);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
this.handleError(error);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
this.openScanner = async () => {
|
|
150
|
+
var _a;
|
|
151
|
+
try {
|
|
152
|
+
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
153
|
+
this.abortController = new AbortController();
|
|
154
|
+
const permissionStatus = await navigator.permissions.query({
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
name: 'camera',
|
|
157
|
+
});
|
|
158
|
+
if (permissionStatus.state === 'prompt') {
|
|
159
|
+
try {
|
|
160
|
+
await navigator.mediaDevices.getUserMedia({
|
|
161
|
+
video: true,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
throw new Error('no camera access');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (permissionStatus.state === 'denied') {
|
|
169
|
+
throw new Error('no camera access');
|
|
170
|
+
}
|
|
171
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
172
|
+
const videoInputs = devices.filter(device => {
|
|
173
|
+
if (device.kind !== 'videoinput')
|
|
174
|
+
return false;
|
|
175
|
+
// TODO: this code only works for IOS however android has no standards
|
|
176
|
+
// const label = device.label.toLowerCase();
|
|
177
|
+
// const hasDirection = label.includes('front') || label.includes('back');
|
|
178
|
+
// const isValid = label.includes('front camera') || label.includes('back camera');
|
|
179
|
+
// return hasDirection ? isValid : true;
|
|
180
|
+
return true;
|
|
181
|
+
});
|
|
182
|
+
if (videoInputs.length === 0)
|
|
183
|
+
throw new Error('No Camera Found');
|
|
184
|
+
this.videoInputs = videoInputs;
|
|
185
|
+
if (!videoInputs.some(input => input.deviceId === this.activeCameraId)) {
|
|
186
|
+
const selectedCamera = videoInputs.find(({ label }) => label.toLowerCase().includes('back') || label.toLowerCase().includes('environment')) || videoInputs[0];
|
|
187
|
+
this.activeCameraId = selectedCamera.deviceId;
|
|
188
|
+
localStorage.setItem(ACTIVE_CAMERA_ID_KEY, this.activeCameraId);
|
|
189
|
+
}
|
|
190
|
+
await this.startCamera();
|
|
191
|
+
if (!this.manualCapture)
|
|
192
|
+
this.frameCaptureTimeoutRef = setTimeout(this.captureFrame, this.captureInterval + 300);
|
|
193
|
+
if (document)
|
|
194
|
+
document.body.style.overflow = 'hidden';
|
|
195
|
+
this.isCameraReady = true;
|
|
196
|
+
this.containerAnimation = 'show-container';
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
this.handleError(error);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
this.startCamera = async () => {
|
|
203
|
+
try {
|
|
204
|
+
const constraints = {
|
|
205
|
+
video: {
|
|
206
|
+
deviceId: this.activeCameraId,
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
this.streamRef = await navigator.mediaDevices.getUserMedia(constraints);
|
|
210
|
+
if (this.videoPlayer) {
|
|
211
|
+
this.videoPlayer.srcObject = this.streamRef;
|
|
212
|
+
this.videoPlayer.play();
|
|
213
|
+
}
|
|
214
|
+
this.manualCaptureLoading = false;
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
if (this.verbose)
|
|
218
|
+
console.error(error);
|
|
219
|
+
throw new Error('Error accessing camera: ');
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
this.closeScanner = () => {
|
|
223
|
+
this.isCameraReady = false;
|
|
224
|
+
this.abortController.abort();
|
|
225
|
+
clearTimeout(this.frameCaptureTimeoutRef);
|
|
226
|
+
if (this.codeReader)
|
|
227
|
+
this.codeReader.reset();
|
|
228
|
+
if (document)
|
|
229
|
+
document.body.style.overflow = 'auto';
|
|
230
|
+
this.containerAnimation = 'hide-container';
|
|
231
|
+
};
|
|
232
|
+
this.stopCamera = () => {
|
|
233
|
+
if (this.streamRef) {
|
|
234
|
+
this.streamRef.getTracks().forEach(track => track.stop());
|
|
235
|
+
this.streamRef = null;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
this.switchCamera = () => {
|
|
239
|
+
if (this.videoInputs.length > 1) {
|
|
240
|
+
const currentIndex = this.videoInputs.findIndex(device => device.deviceId === this.activeCameraId);
|
|
241
|
+
const newCameraIndex = (currentIndex + 1) % this.videoInputs.length;
|
|
242
|
+
this.activeCameraId = this.videoInputs[newCameraIndex].deviceId;
|
|
243
|
+
localStorage.setItem(ACTIVE_CAMERA_ID_KEY, this.activeCameraId);
|
|
244
|
+
this.stopCamera();
|
|
245
|
+
this.startCamera();
|
|
246
|
+
this.switchRotateDegree += 90;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
this.title = '';
|
|
250
|
+
this.isOpen = false;
|
|
251
|
+
this.captureInterval = CAPTURE_INTERVAL;
|
|
252
|
+
this.verbose = false;
|
|
253
|
+
this.useOcr = false;
|
|
254
|
+
this.readSticker = false;
|
|
255
|
+
this.uploaderButtonId = undefined;
|
|
256
|
+
this.manualCapture = false;
|
|
257
|
+
this.skipValidation = false;
|
|
258
|
+
this.ocrEndpoint = undefined;
|
|
259
|
+
this.onExtract = undefined;
|
|
260
|
+
this.onError = undefined;
|
|
261
|
+
this.onProcessing = undefined;
|
|
262
|
+
this.onOpenChange = undefined;
|
|
263
|
+
this.streamRef = undefined;
|
|
264
|
+
this.isAnimating = false;
|
|
265
|
+
this.isCameraReady = false;
|
|
266
|
+
this.switchRotateDegree = 0;
|
|
267
|
+
this.containerAnimation = '';
|
|
268
|
+
this.blazorRef = undefined;
|
|
269
|
+
this.videoInputs = [];
|
|
270
|
+
this.manualCaptureLoading = false;
|
|
271
|
+
this.activeCameraId = localStorage.getItem(ACTIVE_CAMERA_ID_KEY) || '';
|
|
272
|
+
}
|
|
273
|
+
async componentDidLoad() {
|
|
274
|
+
this.videoPlayer = this.el.shadowRoot.querySelector('.video-player');
|
|
275
|
+
this.videoCanvas = this.el.shadowRoot.querySelector('.video-canvas');
|
|
276
|
+
this.abortController = new AbortController();
|
|
277
|
+
if (!this.readSticker && this.uploaderButtonId)
|
|
278
|
+
this.registerFileUploader();
|
|
279
|
+
if (this.readSticker) {
|
|
280
|
+
const ZXingSrc = 'https://unpkg.com/@zxing/library@0.21.3/umd/index.min.js';
|
|
281
|
+
const alreadyLoaded = Array.from(document.scripts).some(script => script.src === ZXingSrc);
|
|
282
|
+
if (alreadyLoaded && this.uploaderButtonId)
|
|
283
|
+
this.registerFileUploader();
|
|
284
|
+
if (!alreadyLoaded) {
|
|
285
|
+
const script = document.createElement('script');
|
|
286
|
+
script.src = ZXingSrc;
|
|
287
|
+
script.defer = true;
|
|
288
|
+
document.head.appendChild(script);
|
|
289
|
+
script.onload = () => {
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
if (ZXing)
|
|
292
|
+
this.codeReader = new ZXing.BrowserMultiFormatReader();
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
else if (!this.codeReader) {
|
|
296
|
+
try {
|
|
297
|
+
// @ts-ignore
|
|
298
|
+
if (ZXing)
|
|
299
|
+
this.codeReader = new ZXing.BrowserMultiFormatReader();
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
setTimeout(() => {
|
|
303
|
+
this.componentDidLoad();
|
|
304
|
+
}, 100);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
setBlazorRef(newBlazorRef) {
|
|
310
|
+
this.blazorRef = newBlazorRef;
|
|
311
|
+
}
|
|
312
|
+
open() {
|
|
313
|
+
this.isOpen = true;
|
|
314
|
+
}
|
|
315
|
+
async close() {
|
|
316
|
+
this.isOpen = false;
|
|
317
|
+
}
|
|
318
|
+
isOpenHandler(newValue) {
|
|
319
|
+
if (newValue)
|
|
320
|
+
this.openScanner();
|
|
321
|
+
else
|
|
322
|
+
this.closeScanner();
|
|
323
|
+
this.triggerCallback(this.onOpenChange, newValue);
|
|
324
|
+
}
|
|
325
|
+
QRChanged(newValue) {
|
|
326
|
+
if (newValue)
|
|
327
|
+
this.componentDidLoad();
|
|
328
|
+
}
|
|
329
|
+
animationHandler(newValue) {
|
|
330
|
+
if (!newValue && !this.isOpen)
|
|
331
|
+
this.stopCamera();
|
|
332
|
+
}
|
|
333
|
+
render() {
|
|
334
|
+
const ariaExpanded = this.isOpen && this.isCameraReady && (this.useOcr || this.readSticker);
|
|
335
|
+
return (h(Host, { key: 'd9312226320c91737681368c4dd2792fdfd9f3e5' }, h("slot", { key: 'f4f045e3bb7eb1531424f2a7b9f525868ac21097' }), h("input", { key: 'cd50cba3a41ea514f1f1aedb78435b85bb40f509', class: "vin-extractor-input", type: "file", accept: "image/*", capture: "environment", hidden: true }), h("canvas", { key: 'e50ec0bd15eb6f07639974374ccd9593e7df8e16', class: "video-canvas hidden" }), !this.uploaderButtonId && (h("div", { key: '5bd81346260512c17f2f54e0c700e55d284539f4', onClick: () => (this.isOpen = false), "aria-expanded": ariaExpanded.toString(), class: "vin-extractor-background md:aria-expanded:bg-black/40 md:transition-all md:duration-300 fixed flex items-center justify-center w-[100dvw] h-[100dvh] top-0 left-0 z-[9999]" }, h("div", { key: '37f22e346e17420f3e6fc5a62b2e2b0f67adf81f', onClick: e => e.stopPropagation(), "aria-expanded": ariaExpanded.toString(), onAnimationEnd: () => (this.isAnimating = false), onAnimationStart: () => (this.isAnimating = true), class: cn('vin-extractor-container md:w-[600px] md:rounded-lg md:overflow-hidden opacity-0 md:h-auto aria-expanded:pointer-events-auto w-full h-full relative transition-all duration-500', this.containerAnimation) }, h("div", { key: 'ec9762ce16f7a6de0f3dd56b1ac52b4fc0e0d670', class: "vin-extractor-heading items-center md:py-[8px] w-full md:!opacity-100 md:!translate-x-0 p-[16px] md:bg-white bg-black/30 shadow-md z-10 md:relative absolute top-0 left-0 flex justify-between" }, this.videoInputs.length > 1 ? (h("button", { type: "button", onClick: this.switchCamera, class: "size-[32px] md:border-none md:bg-white md:hover:bg-slate-100 bg-slate-100 rounded-lg p-1 hover:text-slate-700 border transition-colors duration-300 hover:bg-slate-300 border-slate-600 text-slate-600 hover:border-slate-700" }, h("svg", { width: "24", height: "24", fill: "none", "stroke-width": "2", viewBox: "0 0 24 24", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", xmlns: "http://www.w3.org/2000/svg", class: "size-full transition-all duration-300", style: { rotate: `${this.switchRotateDegree}deg` } }, h("path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" }), h("path", { d: "M21 3v5h-5" }), h("path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" }), h("path", { d: "M8 16H3v5" })))) : (h("div", { class: "size-8" })), h("h1", { key: 'b94566ef63fe91c9dde534ab23d4e1aee6eb4202', class: "text-center md:text-3xl md:text-black text-slate-100 text-xl" }, this.title), h("button", { key: 'cc573cc740b0b57fa375c12438034c08035ee952', type: "button", onClick: () => (this.isOpen = false), class: "size-[32px] md:border-none md:bg-white md:hover:bg-slate-100 bg-slate-100 rounded-lg p-1 hover:text-slate-700 border transition-colors duration-300 hover:bg-slate-300 border-slate-600 text-slate-600 hover:border-slate-700" }, h("svg", { key: '76a221a32de010ea3149450cdfdac11fec45009d', fill: "none", "stroke-width": "2", class: "size-full", viewBox: "0 0 24 24", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: 'a07797044b13941c174ea9ae5c12b963841f720c', d: "M18 6 6 18" }), h("path", { key: 'c5dd1a2ebabb47f07edfa64a5fe4499656192eae', d: "m6 6 12 12" })))), this.manualCapture && (h("button", { key: 'ea2b100590631861b79b75dc63a7d97c069e35ea', type: "button", disabled: this.manualCaptureLoading, onClick: this.captureFrame.bind(this, true), class: "absolute disabled:bg-white/75 outline-none cursor-pointer left-1/2 -translate-x-1/2 flex justify-center items-center h-[60px] py-[10px] w-[100px] rounded-full shadow-lg border border-slate-500 text-slate-500 z-10 bg-white bottom-4" }, this.manualCaptureLoading ? (h("svg", { fill: "none", "stroke-width": "2", viewBox: "0 0 24 24", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", class: "size-full animate-spin", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }))) : (h("svg", { fill: "none", "stroke-width": "2", class: "size-full", viewBox: "0 0 24 24", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z" }), h("circle", { cx: "12", cy: "13", r: "3" }))))), h("video", { key: 'c433241d3c01cfe199bc5b0bc50901b5cb15eb86', id: "video", autoPlay: true, playsInline: true, class: "video-player md:aspect-auto bg-black min-w-full min-h-full object-cover object-center" }))))));
|
|
336
|
+
}
|
|
337
|
+
static get is() { return "vin-extractor"; }
|
|
338
|
+
static get encapsulation() { return "shadow"; }
|
|
339
|
+
static get originalStyleUrls() {
|
|
340
|
+
return {
|
|
341
|
+
"$": ["vin-extractor.css"]
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
static get styleUrls() {
|
|
345
|
+
return {
|
|
346
|
+
"$": ["vin-extractor.css"]
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
static get properties() {
|
|
350
|
+
return {
|
|
351
|
+
"title": {
|
|
352
|
+
"type": "string",
|
|
353
|
+
"mutable": false,
|
|
354
|
+
"complexType": {
|
|
355
|
+
"original": "string",
|
|
356
|
+
"resolved": "string",
|
|
357
|
+
"references": {}
|
|
358
|
+
},
|
|
359
|
+
"required": false,
|
|
360
|
+
"optional": false,
|
|
361
|
+
"docs": {
|
|
362
|
+
"tags": [],
|
|
363
|
+
"text": ""
|
|
364
|
+
},
|
|
365
|
+
"attribute": "title",
|
|
366
|
+
"reflect": false,
|
|
367
|
+
"defaultValue": "''"
|
|
368
|
+
},
|
|
369
|
+
"isOpen": {
|
|
370
|
+
"type": "boolean",
|
|
371
|
+
"mutable": false,
|
|
372
|
+
"complexType": {
|
|
373
|
+
"original": "boolean",
|
|
374
|
+
"resolved": "boolean",
|
|
375
|
+
"references": {}
|
|
376
|
+
},
|
|
377
|
+
"required": false,
|
|
378
|
+
"optional": false,
|
|
379
|
+
"docs": {
|
|
380
|
+
"tags": [],
|
|
381
|
+
"text": ""
|
|
382
|
+
},
|
|
383
|
+
"attribute": "is-open",
|
|
384
|
+
"reflect": false,
|
|
385
|
+
"defaultValue": "false"
|
|
386
|
+
},
|
|
387
|
+
"captureInterval": {
|
|
388
|
+
"type": "number",
|
|
389
|
+
"mutable": false,
|
|
390
|
+
"complexType": {
|
|
391
|
+
"original": "number",
|
|
392
|
+
"resolved": "number",
|
|
393
|
+
"references": {}
|
|
394
|
+
},
|
|
395
|
+
"required": false,
|
|
396
|
+
"optional": false,
|
|
397
|
+
"docs": {
|
|
398
|
+
"tags": [],
|
|
399
|
+
"text": ""
|
|
400
|
+
},
|
|
401
|
+
"attribute": "capture-interval",
|
|
402
|
+
"reflect": false,
|
|
403
|
+
"defaultValue": "CAPTURE_INTERVAL"
|
|
404
|
+
},
|
|
405
|
+
"verbose": {
|
|
406
|
+
"type": "boolean",
|
|
407
|
+
"mutable": false,
|
|
408
|
+
"complexType": {
|
|
409
|
+
"original": "boolean",
|
|
410
|
+
"resolved": "boolean",
|
|
411
|
+
"references": {}
|
|
412
|
+
},
|
|
413
|
+
"required": false,
|
|
414
|
+
"optional": false,
|
|
415
|
+
"docs": {
|
|
416
|
+
"tags": [],
|
|
417
|
+
"text": ""
|
|
418
|
+
},
|
|
419
|
+
"attribute": "verbose",
|
|
420
|
+
"reflect": false,
|
|
421
|
+
"defaultValue": "false"
|
|
422
|
+
},
|
|
423
|
+
"useOcr": {
|
|
424
|
+
"type": "boolean",
|
|
425
|
+
"mutable": false,
|
|
426
|
+
"complexType": {
|
|
427
|
+
"original": "boolean",
|
|
428
|
+
"resolved": "boolean",
|
|
429
|
+
"references": {}
|
|
430
|
+
},
|
|
431
|
+
"required": false,
|
|
432
|
+
"optional": false,
|
|
433
|
+
"docs": {
|
|
434
|
+
"tags": [],
|
|
435
|
+
"text": ""
|
|
436
|
+
},
|
|
437
|
+
"attribute": "use-ocr",
|
|
438
|
+
"reflect": false,
|
|
439
|
+
"defaultValue": "false"
|
|
440
|
+
},
|
|
441
|
+
"readSticker": {
|
|
442
|
+
"type": "boolean",
|
|
443
|
+
"mutable": false,
|
|
444
|
+
"complexType": {
|
|
445
|
+
"original": "boolean",
|
|
446
|
+
"resolved": "boolean",
|
|
447
|
+
"references": {}
|
|
448
|
+
},
|
|
449
|
+
"required": false,
|
|
450
|
+
"optional": false,
|
|
451
|
+
"docs": {
|
|
452
|
+
"tags": [],
|
|
453
|
+
"text": ""
|
|
454
|
+
},
|
|
455
|
+
"attribute": "read-sticker",
|
|
456
|
+
"reflect": false,
|
|
457
|
+
"defaultValue": "false"
|
|
458
|
+
},
|
|
459
|
+
"uploaderButtonId": {
|
|
460
|
+
"type": "string",
|
|
461
|
+
"mutable": false,
|
|
462
|
+
"complexType": {
|
|
463
|
+
"original": "string",
|
|
464
|
+
"resolved": "string",
|
|
465
|
+
"references": {}
|
|
466
|
+
},
|
|
467
|
+
"required": false,
|
|
468
|
+
"optional": false,
|
|
469
|
+
"docs": {
|
|
470
|
+
"tags": [],
|
|
471
|
+
"text": ""
|
|
472
|
+
},
|
|
473
|
+
"attribute": "uploader-button-id",
|
|
474
|
+
"reflect": false
|
|
475
|
+
},
|
|
476
|
+
"manualCapture": {
|
|
477
|
+
"type": "boolean",
|
|
478
|
+
"mutable": false,
|
|
479
|
+
"complexType": {
|
|
480
|
+
"original": "boolean",
|
|
481
|
+
"resolved": "boolean",
|
|
482
|
+
"references": {}
|
|
483
|
+
},
|
|
484
|
+
"required": false,
|
|
485
|
+
"optional": false,
|
|
486
|
+
"docs": {
|
|
487
|
+
"tags": [],
|
|
488
|
+
"text": ""
|
|
489
|
+
},
|
|
490
|
+
"attribute": "manual-capture",
|
|
491
|
+
"reflect": false,
|
|
492
|
+
"defaultValue": "false"
|
|
493
|
+
},
|
|
494
|
+
"skipValidation": {
|
|
495
|
+
"type": "boolean",
|
|
496
|
+
"mutable": false,
|
|
497
|
+
"complexType": {
|
|
498
|
+
"original": "boolean",
|
|
499
|
+
"resolved": "boolean",
|
|
500
|
+
"references": {}
|
|
501
|
+
},
|
|
502
|
+
"required": false,
|
|
503
|
+
"optional": false,
|
|
504
|
+
"docs": {
|
|
505
|
+
"tags": [],
|
|
506
|
+
"text": ""
|
|
507
|
+
},
|
|
508
|
+
"attribute": "skip-validation",
|
|
509
|
+
"reflect": false,
|
|
510
|
+
"defaultValue": "false"
|
|
511
|
+
},
|
|
512
|
+
"ocrEndpoint": {
|
|
513
|
+
"type": "string",
|
|
514
|
+
"mutable": false,
|
|
515
|
+
"complexType": {
|
|
516
|
+
"original": "string",
|
|
517
|
+
"resolved": "string",
|
|
518
|
+
"references": {}
|
|
519
|
+
},
|
|
520
|
+
"required": false,
|
|
521
|
+
"optional": false,
|
|
522
|
+
"docs": {
|
|
523
|
+
"tags": [],
|
|
524
|
+
"text": ""
|
|
525
|
+
},
|
|
526
|
+
"attribute": "ocr-endpoint",
|
|
527
|
+
"reflect": false
|
|
528
|
+
},
|
|
529
|
+
"onExtract": {
|
|
530
|
+
"type": "string",
|
|
531
|
+
"mutable": false,
|
|
532
|
+
"complexType": {
|
|
533
|
+
"original": "((vin: string) => void) | string",
|
|
534
|
+
"resolved": "((vin: string) => void) | string",
|
|
535
|
+
"references": {}
|
|
536
|
+
},
|
|
537
|
+
"required": false,
|
|
538
|
+
"optional": true,
|
|
539
|
+
"docs": {
|
|
540
|
+
"tags": [],
|
|
541
|
+
"text": ""
|
|
542
|
+
},
|
|
543
|
+
"attribute": "on-extract",
|
|
544
|
+
"reflect": false
|
|
545
|
+
},
|
|
546
|
+
"onError": {
|
|
547
|
+
"type": "string",
|
|
548
|
+
"mutable": false,
|
|
549
|
+
"complexType": {
|
|
550
|
+
"original": "((newError: Error) => void) | string",
|
|
551
|
+
"resolved": "((newError: Error) => void) | string",
|
|
552
|
+
"references": {
|
|
553
|
+
"Error": {
|
|
554
|
+
"location": "global",
|
|
555
|
+
"id": "global::Error"
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
"required": false,
|
|
560
|
+
"optional": true,
|
|
561
|
+
"docs": {
|
|
562
|
+
"tags": [],
|
|
563
|
+
"text": ""
|
|
564
|
+
},
|
|
565
|
+
"attribute": "on-error",
|
|
566
|
+
"reflect": false
|
|
567
|
+
},
|
|
568
|
+
"onProcessing": {
|
|
569
|
+
"type": "string",
|
|
570
|
+
"mutable": false,
|
|
571
|
+
"complexType": {
|
|
572
|
+
"original": "((vin: string) => void) | string",
|
|
573
|
+
"resolved": "((vin: string) => void) | string",
|
|
574
|
+
"references": {}
|
|
575
|
+
},
|
|
576
|
+
"required": false,
|
|
577
|
+
"optional": true,
|
|
578
|
+
"docs": {
|
|
579
|
+
"tags": [],
|
|
580
|
+
"text": ""
|
|
581
|
+
},
|
|
582
|
+
"attribute": "on-processing",
|
|
583
|
+
"reflect": false
|
|
584
|
+
},
|
|
585
|
+
"onOpenChange": {
|
|
586
|
+
"type": "string",
|
|
587
|
+
"mutable": false,
|
|
588
|
+
"complexType": {
|
|
589
|
+
"original": "((newError: boolean) => void) | string",
|
|
590
|
+
"resolved": "((newError: boolean) => void) | string",
|
|
591
|
+
"references": {}
|
|
592
|
+
},
|
|
593
|
+
"required": false,
|
|
594
|
+
"optional": true,
|
|
595
|
+
"docs": {
|
|
596
|
+
"tags": [],
|
|
597
|
+
"text": ""
|
|
598
|
+
},
|
|
599
|
+
"attribute": "on-open-change",
|
|
600
|
+
"reflect": false
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
static get states() {
|
|
605
|
+
return {
|
|
606
|
+
"streamRef": {},
|
|
607
|
+
"isAnimating": {},
|
|
608
|
+
"isCameraReady": {},
|
|
609
|
+
"switchRotateDegree": {},
|
|
610
|
+
"containerAnimation": {},
|
|
611
|
+
"blazorRef": {},
|
|
612
|
+
"videoInputs": {},
|
|
613
|
+
"manualCaptureLoading": {},
|
|
614
|
+
"activeCameraId": {}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
static get methods() {
|
|
618
|
+
return {
|
|
619
|
+
"setBlazorRef": {
|
|
620
|
+
"complexType": {
|
|
621
|
+
"signature": "(newBlazorRef: DotNetObjectReference) => Promise<void>",
|
|
622
|
+
"parameters": [{
|
|
623
|
+
"name": "newBlazorRef",
|
|
624
|
+
"type": "{ invokeMethodAsync: (methodName: string, ...args: any[]) => Promise<any>; }",
|
|
625
|
+
"docs": ""
|
|
626
|
+
}],
|
|
627
|
+
"references": {
|
|
628
|
+
"DotNetObjectReference": {
|
|
629
|
+
"location": "import",
|
|
630
|
+
"path": "~types/components",
|
|
631
|
+
"id": "src/global/types/components.ts::DotNetObjectReference"
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
"return": "Promise<void>"
|
|
635
|
+
},
|
|
636
|
+
"docs": {
|
|
637
|
+
"text": "",
|
|
638
|
+
"tags": []
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
"open": {
|
|
642
|
+
"complexType": {
|
|
643
|
+
"signature": "() => Promise<void>",
|
|
644
|
+
"parameters": [],
|
|
645
|
+
"references": {},
|
|
646
|
+
"return": "Promise<void>"
|
|
647
|
+
},
|
|
648
|
+
"docs": {
|
|
649
|
+
"text": "",
|
|
650
|
+
"tags": []
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
"close": {
|
|
654
|
+
"complexType": {
|
|
655
|
+
"signature": "() => Promise<void>",
|
|
656
|
+
"parameters": [],
|
|
657
|
+
"references": {
|
|
658
|
+
"Promise": {
|
|
659
|
+
"location": "global",
|
|
660
|
+
"id": "global::Promise"
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
"return": "Promise<void>"
|
|
664
|
+
},
|
|
665
|
+
"docs": {
|
|
666
|
+
"text": "",
|
|
667
|
+
"tags": []
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
static get elementRef() { return "el"; }
|
|
673
|
+
static get watchers() {
|
|
674
|
+
return [{
|
|
675
|
+
"propName": "isOpen",
|
|
676
|
+
"methodName": "isOpenHandler"
|
|
677
|
+
}, {
|
|
678
|
+
"propName": "readSticker",
|
|
679
|
+
"methodName": "QRChanged"
|
|
680
|
+
}, {
|
|
681
|
+
"propName": "isAnimating",
|
|
682
|
+
"methodName": "animationHandler"
|
|
683
|
+
}];
|
|
684
|
+
}
|
|
685
|
+
}
|