@mleonard9/vin-scanner 1.4.0 → 1.4.3
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/README.md +6 -38
- package/ios/VisionCameraBarcodeScanner.m +4 -4
- package/ios/VisionCameraTextRecognition.m +5 -5
- package/lib/commonjs/ManualVinInput.js +1 -2
- package/lib/commonjs/ManualVinInput.js.map +1 -1
- package/lib/commonjs/PendingVinBanner.js.map +1 -1
- package/lib/commonjs/TextVinPrompt.js.map +1 -1
- package/lib/commonjs/haptics.js +1 -1
- package/lib/commonjs/haptics.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/scanBarcodes.js.map +1 -1
- package/lib/commonjs/scanText.js.map +1 -1
- package/lib/commonjs/useVinScanner.js.map +1 -1
- package/lib/commonjs/vinUtils.js +8 -8
- package/lib/commonjs/vinUtils.js.map +1 -1
- package/lib/module/ManualVinInput.js +1 -2
- package/lib/module/ManualVinInput.js.map +1 -1
- package/lib/module/PendingVinBanner.js.map +1 -1
- package/lib/module/TextVinPrompt.js.map +1 -1
- package/lib/module/haptics.js +1 -1
- package/lib/module/haptics.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/scanBarcodes.js.map +1 -1
- package/lib/module/scanText.js.map +1 -1
- package/lib/module/useVinScanner.js.map +1 -1
- package/lib/module/vinUtils.js +8 -8
- package/lib/module/vinUtils.js.map +1 -1
- package/lib/typescript/src/ManualVinInput.d.ts.map +1 -1
- package/lib/typescript/src/PendingVinBanner.d.ts.map +1 -1
- package/lib/typescript/src/TextVinPrompt.d.ts.map +1 -1
- package/lib/typescript/src/haptics.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/scanBarcodes.d.ts.map +1 -1
- package/lib/typescript/src/scanText.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/useVinScanner.d.ts.map +1 -1
- package/lib/typescript/src/vinUtils.d.ts.map +1 -1
- package/package.json +1 -3
- package/src/ManualVinInput.tsx +44 -5
- package/src/PendingVinBanner.tsx +4 -5
- package/src/TextVinPrompt.tsx +10 -2
- package/src/haptics.ts +2 -5
- package/src/index.tsx +46 -22
- package/src/scanBarcodes.ts +5 -1
- package/src/scanText.ts +5 -1
- package/src/types.ts +9 -4
- package/src/useVinScanner.ts +38 -28
- package/src/vinUtils.ts +112 -70
package/src/vinUtils.ts
CHANGED
|
@@ -81,9 +81,9 @@ const DEFAULT_RESOLVED_OPTIONS: ResolvedVinScannerOptions = {
|
|
|
81
81
|
},
|
|
82
82
|
showOverlay: false,
|
|
83
83
|
overlayColors: {
|
|
84
|
-
high:
|
|
85
|
-
medium:
|
|
86
|
-
low:
|
|
84
|
+
high: '#00FF00',
|
|
85
|
+
medium: '#FFFF00',
|
|
86
|
+
low: '#FF0000',
|
|
87
87
|
},
|
|
88
88
|
duplicateDebounceMs: 1500,
|
|
89
89
|
};
|
|
@@ -96,7 +96,7 @@ export const resolveOptions = (
|
|
|
96
96
|
const textScanInterval = Math.max(
|
|
97
97
|
1,
|
|
98
98
|
options?.detection?.textScanInterval ??
|
|
99
|
-
|
|
99
|
+
DEFAULT_RESOLVED_OPTIONS.detection.textScanInterval
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
return {
|
|
@@ -115,7 +115,8 @@ export const resolveOptions = (
|
|
|
115
115
|
options?.text?.requireConfirmation ??
|
|
116
116
|
DEFAULT_RESOLVED_OPTIONS.text.requireConfirmation,
|
|
117
117
|
pendingTtlMs:
|
|
118
|
-
options?.text?.pendingTtlMs ??
|
|
118
|
+
options?.text?.pendingTtlMs ??
|
|
119
|
+
DEFAULT_RESOLVED_OPTIONS.text.pendingTtlMs,
|
|
119
120
|
},
|
|
120
121
|
detection: {
|
|
121
122
|
textScanInterval,
|
|
@@ -125,15 +126,25 @@ export const resolveOptions = (
|
|
|
125
126
|
forceOrientation:
|
|
126
127
|
options?.detection?.forceOrientation ??
|
|
127
128
|
DEFAULT_RESOLVED_OPTIONS.detection.forceOrientation,
|
|
128
|
-
scanRegion:
|
|
129
|
+
scanRegion:
|
|
130
|
+
options?.detection?.scanRegion ??
|
|
131
|
+
DEFAULT_RESOLVED_OPTIONS.detection.scanRegion,
|
|
129
132
|
minLuma:
|
|
130
|
-
options?.detection?.
|
|
133
|
+
options?.detection?.enableFrameQualityCheck === false
|
|
134
|
+
? 0
|
|
135
|
+
: (options?.detection?.minLuma ??
|
|
136
|
+
DEFAULT_RESOLVED_OPTIONS.detection.minLuma),
|
|
131
137
|
minSharpness:
|
|
132
|
-
options?.detection?.
|
|
138
|
+
options?.detection?.enableFrameQualityCheck === false
|
|
139
|
+
? 0
|
|
140
|
+
: (options?.detection?.minSharpness ??
|
|
141
|
+
DEFAULT_RESOLVED_OPTIONS.detection.minSharpness),
|
|
133
142
|
minConfidence:
|
|
134
|
-
options?.detection?.minConfidence ??
|
|
143
|
+
options?.detection?.minConfidence ??
|
|
144
|
+
DEFAULT_RESOLVED_OPTIONS.detection.minConfidence,
|
|
135
145
|
barcodeFallbackAfter:
|
|
136
|
-
options?.detection?.barcodeFallbackAfter ??
|
|
146
|
+
options?.detection?.barcodeFallbackAfter ??
|
|
147
|
+
DEFAULT_RESOLVED_OPTIONS.detection.barcodeFallbackAfter,
|
|
137
148
|
},
|
|
138
149
|
showOverlay: options?.showOverlay ?? false,
|
|
139
150
|
overlayColors: {
|
|
@@ -307,24 +318,56 @@ const calculateConfidence = (
|
|
|
307
318
|
// Known manufacturer WMI prefixes (first 3 characters) increase confidence
|
|
308
319
|
const wmi = value.slice(0, 3);
|
|
309
320
|
const knownManufacturers = [
|
|
310
|
-
'1G1',
|
|
311
|
-
'
|
|
312
|
-
'
|
|
313
|
-
'
|
|
314
|
-
'
|
|
315
|
-
'
|
|
316
|
-
'
|
|
317
|
-
'
|
|
318
|
-
'
|
|
319
|
-
'
|
|
320
|
-
'
|
|
321
|
-
'
|
|
322
|
-
'
|
|
323
|
-
'
|
|
324
|
-
'
|
|
325
|
-
'
|
|
326
|
-
'
|
|
327
|
-
'
|
|
321
|
+
'1G1',
|
|
322
|
+
'1G2',
|
|
323
|
+
'1G3',
|
|
324
|
+
'1G4',
|
|
325
|
+
'1G6', // GM
|
|
326
|
+
'1FA',
|
|
327
|
+
'1FB',
|
|
328
|
+
'1FC',
|
|
329
|
+
'1FD',
|
|
330
|
+
'1FM',
|
|
331
|
+
'1FT', // Ford
|
|
332
|
+
'1HG',
|
|
333
|
+
'1HC', // Honda
|
|
334
|
+
'1N4',
|
|
335
|
+
'1N6', // Nissan
|
|
336
|
+
'2C3',
|
|
337
|
+
'2C4', // Chrysler
|
|
338
|
+
'2HG',
|
|
339
|
+
'2HM', // Honda
|
|
340
|
+
'2T1',
|
|
341
|
+
'2T2',
|
|
342
|
+
'2T3', // Toyota
|
|
343
|
+
'3FA',
|
|
344
|
+
'3FE', // Ford Mexico
|
|
345
|
+
'4T1',
|
|
346
|
+
'4T3', // Toyota
|
|
347
|
+
'5FN',
|
|
348
|
+
'5FY', // Honda
|
|
349
|
+
'5TD',
|
|
350
|
+
'5TF',
|
|
351
|
+
'5TJ', // Toyota
|
|
352
|
+
'JHM',
|
|
353
|
+
'JHL', // Honda Japan
|
|
354
|
+
'JT2',
|
|
355
|
+
'JT3',
|
|
356
|
+
'JTD', // Toyota Japan
|
|
357
|
+
'KM8',
|
|
358
|
+
'KNA',
|
|
359
|
+
'KND', // Hyundai/Kia
|
|
360
|
+
'WBA',
|
|
361
|
+
'WBS',
|
|
362
|
+
'WBY', // BMW
|
|
363
|
+
'WDB',
|
|
364
|
+
'WDC',
|
|
365
|
+
'WDD', // Mercedes
|
|
366
|
+
'WAU',
|
|
367
|
+
'WA1', // Audi
|
|
368
|
+
'WVW',
|
|
369
|
+
'WV1',
|
|
370
|
+
'WV2', // VW
|
|
328
371
|
];
|
|
329
372
|
if (knownManufacturers.includes(wmi)) {
|
|
330
373
|
score += 0.15;
|
|
@@ -383,7 +426,6 @@ const calculateConfidence = (
|
|
|
383
426
|
return Math.min(1.0, Math.max(0.0, score));
|
|
384
427
|
};
|
|
385
428
|
|
|
386
|
-
|
|
387
429
|
/**
|
|
388
430
|
* Tokenize and extract VIN candidates from raw text
|
|
389
431
|
* Includes OCR error correction and context-aware extraction
|
|
@@ -508,24 +550,24 @@ export const isValidVin = (value: string): boolean => {
|
|
|
508
550
|
const toBoundingBox = (
|
|
509
551
|
candidate:
|
|
510
552
|
| Pick<
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
553
|
+
BarcodeDetection,
|
|
554
|
+
'top' | 'bottom' | 'left' | 'right' | 'width' | 'height'
|
|
555
|
+
>
|
|
514
556
|
| Pick<
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
557
|
+
TextDetection,
|
|
558
|
+
| 'blockFrameTop'
|
|
559
|
+
| 'blockFrameBottom'
|
|
560
|
+
| 'blockFrameLeft'
|
|
561
|
+
| 'blockFrameRight'
|
|
562
|
+
| 'lineFrameTop'
|
|
563
|
+
| 'lineFrameBottom'
|
|
564
|
+
| 'lineFrameLeft'
|
|
565
|
+
| 'lineFrameRight'
|
|
566
|
+
| 'elementFrameTop'
|
|
567
|
+
| 'elementFrameBottom'
|
|
568
|
+
| 'elementFrameLeft'
|
|
569
|
+
| 'elementFrameRight'
|
|
570
|
+
>,
|
|
529
571
|
preferred: 'block' | 'line' | 'element' | 'barcode'
|
|
530
572
|
) => {
|
|
531
573
|
'worklet';
|
|
@@ -554,39 +596,39 @@ const toBoundingBox = (
|
|
|
554
596
|
const block = candidate as TextDetection;
|
|
555
597
|
const blockBox =
|
|
556
598
|
typeof block.blockFrameTop === 'number' &&
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
599
|
+
typeof block.blockFrameBottom === 'number' &&
|
|
600
|
+
typeof block.blockFrameLeft === 'number' &&
|
|
601
|
+
typeof block.blockFrameRight === 'number'
|
|
560
602
|
? {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
603
|
+
top: block.blockFrameTop,
|
|
604
|
+
bottom: block.blockFrameBottom,
|
|
605
|
+
left: block.blockFrameLeft,
|
|
606
|
+
right: block.blockFrameRight,
|
|
607
|
+
}
|
|
566
608
|
: undefined;
|
|
567
609
|
const lineBox =
|
|
568
610
|
typeof block.lineFrameTop === 'number' &&
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
611
|
+
typeof block.lineFrameBottom === 'number' &&
|
|
612
|
+
typeof block.lineFrameLeft === 'number' &&
|
|
613
|
+
typeof block.lineFrameRight === 'number'
|
|
572
614
|
? {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
615
|
+
top: block.lineFrameTop,
|
|
616
|
+
bottom: block.lineFrameBottom,
|
|
617
|
+
left: block.lineFrameLeft,
|
|
618
|
+
right: block.lineFrameRight,
|
|
619
|
+
}
|
|
578
620
|
: undefined;
|
|
579
621
|
const elementBox =
|
|
580
622
|
typeof block.elementFrameTop === 'number' &&
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
623
|
+
typeof block.elementFrameBottom === 'number' &&
|
|
624
|
+
typeof block.elementFrameLeft === 'number' &&
|
|
625
|
+
typeof block.elementFrameRight === 'number'
|
|
584
626
|
? {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
627
|
+
top: block.elementFrameTop,
|
|
628
|
+
bottom: block.elementFrameBottom,
|
|
629
|
+
left: block.elementFrameLeft,
|
|
630
|
+
right: block.elementFrameRight,
|
|
631
|
+
}
|
|
590
632
|
: undefined;
|
|
591
633
|
|
|
592
634
|
if (preferred === 'element' && elementBox) {
|