react-native-scanbot-barcode-scanner-sdk 5.1.0 → 5.1.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries.txt +30 -30
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerView.kt +14 -4
- package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/components/barcode_scanner_view/ScanbotBarcodeScannerViewManager.kt +5 -0
- package/app.plugin.js +1 -0
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.h +1 -1
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerLegacyView.m +39 -29
- package/ios/Components/BarcodeScannerView/RNScanbotBarcodeScannerView.mm +21 -22
- package/package.json +9 -2
- package/plugin/build/pluginTypes.d.ts +6 -0
- package/plugin/build/pluginTypes.js +2 -0
- package/plugin/build/withAndroidCameraPermission.d.ts +3 -0
- package/plugin/build/withAndroidCameraPermission.js +25 -0
- package/plugin/build/withAndroidFeature.d.ts +3 -0
- package/plugin/build/withAndroidFeature.js +26 -0
- package/plugin/build/withAndroidMavenURLs.d.ts +4 -0
- package/plugin/build/withAndroidMavenURLs.js +44 -0
- package/plugin/build/withIOSCameraPermission.d.ts +3 -0
- package/plugin/build/withIOSCameraPermission.js +14 -0
- package/plugin/build/withScanbotSDK.d.ts +4 -0
- package/plugin/build/withScanbotSDK.js +17 -0
- package/plugin/src/pluginTypes.ts +6 -0
- package/plugin/src/withAndroidCameraPermission.ts +33 -0
- package/plugin/src/withAndroidFeature.ts +33 -0
- package/plugin/src/withAndroidMavenURLs.ts +51 -0
- package/plugin/src/withIOSCameraPermission.ts +15 -0
- package/plugin/src/withScanbotSDK.ts +19 -0
- package/plugin/tsconfig.json +8 -0
package/Libraries.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Open Source libraries used in the Scanbot Barcode SDK for React Native version 5.1.
|
|
1
|
+
Open Source libraries used in the Scanbot Barcode SDK for React Native version 5.1.1
|
|
2
2
|
|
|
3
3
|
Open Source libraries used in ScanbotBarcodeScannerSDK for iOS version 5.1.3:
|
|
4
4
|
|
|
@@ -77,7 +77,7 @@ record keeping.)
|
|
|
77
77
|
* are met:
|
|
78
78
|
*
|
|
79
79
|
* 1. Redistributions of source code must retain the above copyright
|
|
80
|
-
* notice, this list of conditions and the following disclaimer.
|
|
80
|
+
* notice, this list of conditions and the following disclaimer.
|
|
81
81
|
*
|
|
82
82
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
83
83
|
* notice, this list of conditions and the following disclaimer in
|
|
@@ -132,21 +132,21 @@ record keeping.)
|
|
|
132
132
|
* This package is an SSL implementation written
|
|
133
133
|
* by Eric Young (eay@cryptsoft.com).
|
|
134
134
|
* The implementation was written so as to conform with Netscapes SSL.
|
|
135
|
-
*
|
|
135
|
+
*
|
|
136
136
|
* This library is free for commercial and non-commercial use as long as
|
|
137
137
|
* the following conditions are aheared to. The following conditions
|
|
138
138
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
139
139
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
140
140
|
* included with this distribution is covered by the same copyright terms
|
|
141
141
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
142
|
-
*
|
|
142
|
+
*
|
|
143
143
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
144
144
|
* the code are not to be removed.
|
|
145
145
|
* If this package is used in a product, Eric Young should be given attribution
|
|
146
146
|
* as the author of the parts of the library used.
|
|
147
147
|
* This can be in the form of a textual message at program startup or
|
|
148
148
|
* in documentation (online or textual) provided with the package.
|
|
149
|
-
*
|
|
149
|
+
*
|
|
150
150
|
* Redistribution and use in source and binary forms, with or without
|
|
151
151
|
* modification, are permitted provided that the following conditions
|
|
152
152
|
* are met:
|
|
@@ -161,10 +161,10 @@ record keeping.)
|
|
|
161
161
|
* Eric Young (eay@cryptsoft.com)"
|
|
162
162
|
* The word 'cryptographic' can be left out if the rouines from the library
|
|
163
163
|
* being used are not cryptographic related :-).
|
|
164
|
-
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
164
|
+
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
165
165
|
* the apps directory (application code) you must include an acknowledgement:
|
|
166
166
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
167
|
-
*
|
|
167
|
+
*
|
|
168
168
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
169
169
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
170
170
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
@@ -176,7 +176,7 @@ record keeping.)
|
|
|
176
176
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
177
177
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
178
178
|
* SUCH DAMAGE.
|
|
179
|
-
*
|
|
179
|
+
*
|
|
180
180
|
* The licence and distribution terms for any publically available version or
|
|
181
181
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
182
182
|
* copied and put under another distribution licence
|
|
@@ -830,7 +830,7 @@ JSON for Modern C++
|
|
|
830
830
|
Version v3.11.2
|
|
831
831
|
(https://github.com/nlohmann/json)
|
|
832
832
|
|
|
833
|
-
MIT License
|
|
833
|
+
MIT License
|
|
834
834
|
|
|
835
835
|
Copyright (c) 2013-2022 Niels Lohmann
|
|
836
836
|
|
|
@@ -901,18 +901,18 @@ Copyright (C) 2007-2009 Antony Dovgal
|
|
|
901
901
|
|
|
902
902
|
This software is provided 'as-is', without any express or implied warranty.
|
|
903
903
|
|
|
904
|
-
In no event will the authors be held liable for any damages arising from the
|
|
904
|
+
In no event will the authors be held liable for any damages arising from the
|
|
905
905
|
use of this software.
|
|
906
906
|
|
|
907
|
-
Permission is granted to anyone to use this software for any purpose,including
|
|
908
|
-
commercial applications, and to alter it and redistribute it freely, subject
|
|
907
|
+
Permission is granted to anyone to use this software for any purpose,including
|
|
908
|
+
commercial applications, and to alter it and redistribute it freely, subject
|
|
909
909
|
to the following restrictions:
|
|
910
910
|
|
|
911
|
-
1. The origin of this software must not be misrepresented; you must not claim
|
|
912
|
-
that you wrote the original software. If you use this software in a
|
|
913
|
-
product, an acknowledgment in the product documentation would be
|
|
911
|
+
1. The origin of this software must not be misrepresented; you must not claim
|
|
912
|
+
that you wrote the original software. If you use this software in a
|
|
913
|
+
product, an acknowledgment in the product documentation would be
|
|
914
914
|
appreciated but is not required.
|
|
915
|
-
2. Altered source versions must be plainly marked as such, and must not be
|
|
915
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
|
916
916
|
misrepresented as being the original software.
|
|
917
917
|
3. This notice may not be removed or altered from any source distribution.
|
|
918
918
|
|
|
@@ -1211,7 +1211,7 @@ Version 4.2.0
|
|
|
1211
1211
|
Copyright (c) 1988-1997 Sam Leffler
|
|
1212
1212
|
Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
1213
1213
|
|
|
1214
|
-
Permission to use, copy, modify, distribute, and sell this software and
|
|
1214
|
+
Permission to use, copy, modify, distribute, and sell this software and
|
|
1215
1215
|
its documentation for any purpose is hereby granted without fee, provided
|
|
1216
1216
|
that (i) the above copyright notices and this permission notice appear in
|
|
1217
1217
|
all copies of the software and related documentation, and (ii) the names of
|
|
@@ -1219,15 +1219,15 @@ Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
|
1219
1219
|
publicity relating to the software without the specific, prior written
|
|
1220
1220
|
permission of Sam Leffler and Silicon Graphics.
|
|
1221
1221
|
|
|
1222
|
-
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
1223
|
-
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
1224
|
-
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
1222
|
+
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
1223
|
+
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
1224
|
+
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
1225
1225
|
|
|
1226
1226
|
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
1227
1227
|
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
1228
1228
|
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
1229
|
-
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
1230
|
-
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
1229
|
+
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
1230
|
+
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
1231
1231
|
OF THIS SOFTWARE.
|
|
1232
1232
|
|
|
1233
1233
|
|
|
@@ -1540,7 +1540,7 @@ Version 1.1.1t
|
|
|
1540
1540
|
* are met:
|
|
1541
1541
|
*
|
|
1542
1542
|
* 1. Redistributions of source code must retain the above copyright
|
|
1543
|
-
* notice, this list of conditions and the following disclaimer.
|
|
1543
|
+
* notice, this list of conditions and the following disclaimer.
|
|
1544
1544
|
*
|
|
1545
1545
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
1546
1546
|
* notice, this list of conditions and the following disclaimer in
|
|
@@ -1595,21 +1595,21 @@ Version 1.1.1t
|
|
|
1595
1595
|
* This package is an SSL implementation written
|
|
1596
1596
|
* by Eric Young (eay@cryptsoft.com).
|
|
1597
1597
|
* The implementation was written so as to conform with Netscapes SSL.
|
|
1598
|
-
*
|
|
1598
|
+
*
|
|
1599
1599
|
* This library is free for commercial and non-commercial use as long as
|
|
1600
1600
|
* the following conditions are aheared to. The following conditions
|
|
1601
1601
|
* apply to all code found in this distribution, be it the RC4, RSA,
|
|
1602
1602
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
|
1603
1603
|
* included with this distribution is covered by the same copyright terms
|
|
1604
1604
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
|
1605
|
-
*
|
|
1605
|
+
*
|
|
1606
1606
|
* Copyright remains Eric Young's, and as such any Copyright notices in
|
|
1607
1607
|
* the code are not to be removed.
|
|
1608
1608
|
* If this package is used in a product, Eric Young should be given attribution
|
|
1609
1609
|
* as the author of the parts of the library used.
|
|
1610
1610
|
* This can be in the form of a textual message at program startup or
|
|
1611
1611
|
* in documentation (online or textual) provided with the package.
|
|
1612
|
-
*
|
|
1612
|
+
*
|
|
1613
1613
|
* Redistribution and use in source and binary forms, with or without
|
|
1614
1614
|
* modification, are permitted provided that the following conditions
|
|
1615
1615
|
* are met:
|
|
@@ -1624,10 +1624,10 @@ Version 1.1.1t
|
|
|
1624
1624
|
* Eric Young (eay@cryptsoft.com)"
|
|
1625
1625
|
* The word 'cryptographic' can be left out if the rouines from the library
|
|
1626
1626
|
* being used are not cryptographic related :-).
|
|
1627
|
-
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
1627
|
+
* 4. If you include any Windows specific code (or a derivative thereof) from
|
|
1628
1628
|
* the apps directory (application code) you must include an acknowledgement:
|
|
1629
1629
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
|
1630
|
-
*
|
|
1630
|
+
*
|
|
1631
1631
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
|
1632
1632
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
1633
1633
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
@@ -1639,7 +1639,7 @@ Version 1.1.1t
|
|
|
1639
1639
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
1640
1640
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
1641
1641
|
* SUCH DAMAGE.
|
|
1642
|
-
*
|
|
1642
|
+
*
|
|
1643
1643
|
* The licence and distribution terms for any publically available version or
|
|
1644
1644
|
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
|
1645
1645
|
* copied and put under another distribution licence
|
|
@@ -1657,7 +1657,7 @@ Version v1.9.2
|
|
|
1657
1657
|
|
|
1658
1658
|
The MIT License (MIT)
|
|
1659
1659
|
|
|
1660
|
-
Copyright (c) 2016 Gabi Melman.
|
|
1660
|
+
Copyright (c) 2016 Gabi Melman.
|
|
1661
1661
|
|
|
1662
1662
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1663
1663
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -88,11 +88,7 @@ class ScanbotBarcodeScannerView(
|
|
|
88
88
|
addView(barcodeScanner)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
override fun onDetachedFromWindow() {
|
|
92
|
-
(context as ReactContext).removeLifecycleEventListener(lifecycleEventListener)
|
|
93
91
|
|
|
94
|
-
super.onDetachedFromWindow()
|
|
95
|
-
}
|
|
96
92
|
|
|
97
93
|
private fun initBarcodeScannerView() {
|
|
98
94
|
barcodeScanner = BarcodeScannerView(context).apply {
|
|
@@ -189,6 +185,20 @@ class ScanbotBarcodeScannerView(
|
|
|
189
185
|
})
|
|
190
186
|
}
|
|
191
187
|
|
|
188
|
+
override fun onAttachedToWindow() {
|
|
189
|
+
super.onAttachedToWindow()
|
|
190
|
+
this.barcodeScanner.viewController.onResume()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
override fun onDetachedFromWindow() {
|
|
194
|
+
this.barcodeScanner.viewController.onPause()
|
|
195
|
+
super.onDetachedFromWindow()
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fun removeAttachedListeners() {
|
|
199
|
+
(context as ReactContext).removeLifecycleEventListener(lifecycleEventListener)
|
|
200
|
+
}
|
|
201
|
+
|
|
192
202
|
override fun requestLayout() {
|
|
193
203
|
super.requestLayout()
|
|
194
204
|
post {
|
|
@@ -64,6 +64,11 @@ class ScanbotBarcodeScannerViewManager : SimpleViewManager<ScanbotBarcodeScanner
|
|
|
64
64
|
)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
override fun onDropViewInstance(view: ScanbotBarcodeScannerView) {
|
|
68
|
+
view.removeAttachedListeners()
|
|
69
|
+
super.onDropViewInstance(view)
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
//region Commands
|
|
68
73
|
|
|
69
74
|
override fun unfreezeCamera(view: ScanbotBarcodeScannerView) {
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withScanbotSDK');
|
|
@@ -1,41 +1,51 @@
|
|
|
1
1
|
|
|
2
2
|
#if !defined(RCT_NEW_ARCH_ENABLED)
|
|
3
3
|
#import "RNScanbotBarcodeScannerLegacyView.h"
|
|
4
|
-
#import "BarcodeItem.h"
|
|
5
4
|
|
|
6
5
|
@interface RNScanbotBarcodeScannerLegacyView()
|
|
7
6
|
@property (strong, nonatomic) SBSDKBarcodeScannerViewController *scannerViewController;
|
|
7
|
+
@property (strong, nonatomic) UIViewController *vc;
|
|
8
8
|
@property (nonatomic) BOOL scanningEnabled;
|
|
9
9
|
@end
|
|
10
10
|
|
|
11
11
|
@implementation RNScanbotBarcodeScannerLegacyView
|
|
12
12
|
|
|
13
|
+
|
|
14
|
+
|
|
13
15
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
14
16
|
{
|
|
17
|
+
|
|
15
18
|
if (self = [super initWithFrame:frame]) {
|
|
16
19
|
_scanningEnabled = true;
|
|
17
|
-
_scannerViewController = [RNScanbotBarcodeScannerViewControllerWrapper initController];
|
|
18
|
-
_scannerViewController.delegate = self;
|
|
19
|
-
_scannerViewController.trackingOverlayController.delegate = self;
|
|
20
20
|
_selectedBarcodes = [NSMutableSet set];
|
|
21
|
+
|
|
22
|
+
self.vc = [[UIViewController alloc] init];
|
|
23
|
+
self.vc.view = self;
|
|
24
|
+
self.scannerViewController = [RNScanbotBarcodeScannerViewControllerWrapper initController];
|
|
25
|
+
self.scannerViewController.delegate = self;
|
|
26
|
+
self.scannerViewController.trackingOverlayController.delegate = self;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
return self;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
- (void)didMoveToWindow {
|
|
27
|
-
UIViewController *vc = [[UIViewController alloc] init];
|
|
28
|
-
vc.view = self;
|
|
29
|
-
[_scannerViewController attachWithParentViewController:vc parentView:self];
|
|
30
33
|
[super didMoveToWindow];
|
|
34
|
+
if(self.window){
|
|
35
|
+
[self.vc sbsdk_attachViewController:self.scannerViewController inView:self];
|
|
36
|
+
} else {
|
|
37
|
+
[self.vc sbsdk_detachViewController:self.scannerViewController];
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
- (void)removeFromSuperview {
|
|
34
42
|
self.scannerViewController = nil;
|
|
43
|
+
self.vc = nil;
|
|
35
44
|
self.selectedBarcodes = [NSMutableSet set];
|
|
36
45
|
[super removeFromSuperview];
|
|
37
46
|
}
|
|
38
47
|
|
|
48
|
+
|
|
39
49
|
- (void) setScanningEnabled:(BOOL)value {
|
|
40
50
|
_scanningEnabled = value;
|
|
41
51
|
}
|
|
@@ -73,28 +83,28 @@
|
|
|
73
83
|
NSNumber *left = [value valueForKey:@"left"];
|
|
74
84
|
NSNumber *bottom = [value valueForKey:@"bottom"];
|
|
75
85
|
NSNumber *right = [value valueForKey:@"right"];
|
|
76
|
-
|
|
86
|
+
|
|
77
87
|
SBSDKBaseScannerViewFinderConfiguration *finderConfig = self.scannerViewController.viewFinderConfiguration;
|
|
78
|
-
|
|
88
|
+
|
|
79
89
|
[RNScanbotBarcodeScannerViewControllerWrapper setFinderInset:finderConfig
|
|
80
90
|
top:top != nil ? [top floatValue] : 10
|
|
81
91
|
left:left != nil ? [left floatValue]: 10
|
|
82
92
|
bottom:bottom != nil ? [bottom floatValue] : 10
|
|
83
93
|
right:right != nil ? [right floatValue] : 10];
|
|
84
|
-
|
|
94
|
+
|
|
85
95
|
self.scannerViewController.viewFinderConfiguration = finderConfig;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
- (void) setFinderRequiredAspectRatios:(NSDictionary * _Nullable)value {
|
|
89
99
|
NSNumber *width = [value valueForKey:@"width"];
|
|
90
100
|
NSNumber *height = [value valueForKey:@"height"];
|
|
91
|
-
|
|
101
|
+
|
|
92
102
|
SBSDKBaseScannerViewFinderConfiguration *finderConfig = self.scannerViewController.viewFinderConfiguration;
|
|
93
|
-
|
|
103
|
+
|
|
94
104
|
[RNScanbotBarcodeScannerViewControllerWrapper setFinderRequiredAspectRatios:finderConfig
|
|
95
105
|
width:width != nil ? [width doubleValue] : 4
|
|
96
106
|
height:height != nil ? [height doubleValue] : 3];
|
|
97
|
-
|
|
107
|
+
|
|
98
108
|
self.scannerViewController.viewFinderConfiguration = finderConfig;
|
|
99
109
|
}
|
|
100
110
|
|
|
@@ -107,13 +117,13 @@
|
|
|
107
117
|
- (void) setCameraZoomRange:(NSDictionary * _Nullable)value {
|
|
108
118
|
NSNumber *minZoom = [value valueForKey:@"minZoom"];
|
|
109
119
|
NSNumber *maxZoom = [value valueForKey:@"maxZoom"];
|
|
110
|
-
|
|
120
|
+
|
|
111
121
|
SBSDKBaseScannerZoomConfiguration *zoomConfig = self.scannerViewController.zoomConfiguration;
|
|
112
|
-
|
|
122
|
+
|
|
113
123
|
[RNScanbotBarcodeScannerViewControllerWrapper setCameraZoomRange:zoomConfig
|
|
114
124
|
minZoom: minZoom != nil ? [minZoom floatValue] : 1
|
|
115
125
|
maxZoom: maxZoom != nil ? [maxZoom floatValue] : 12];
|
|
116
|
-
|
|
126
|
+
|
|
117
127
|
self.scannerViewController.zoomConfiguration = zoomConfig;
|
|
118
128
|
}
|
|
119
129
|
|
|
@@ -127,28 +137,28 @@
|
|
|
127
137
|
|
|
128
138
|
- (void) setDetectorConfig:(NSDictionary * _Nullable)configDict {
|
|
129
139
|
SBBWrapperBarcodeCameraViewConfiguration* decodedConfig = [SBBWrapperBarcodeCameraViewConfiguration fromDicitonary: configDict];
|
|
130
|
-
|
|
140
|
+
|
|
131
141
|
SBSDKBarcodeAdditionalParameters *additionalConfig = self.scannerViewController.additionalDetectionParameters;
|
|
132
142
|
|
|
133
143
|
[RNScanbotBarcodeScannerViewControllerWrapper setBarcodeFormats:self.scannerViewController acceptedBarcodeTypes:decodedConfig.acceptedBarcodeTypes];
|
|
134
|
-
|
|
144
|
+
|
|
135
145
|
[RNScanbotBarcodeScannerViewControllerWrapper setDocumentFormats:self.scannerViewController acceptedDocumentTypes:decodedConfig.acceptedDocumentTypes];
|
|
136
146
|
|
|
137
147
|
[RNScanbotBarcodeScannerViewControllerWrapper setEngineMode:self.scannerViewController engineMode:decodedConfig.engineMode];
|
|
138
|
-
|
|
148
|
+
|
|
139
149
|
[RNScanbotBarcodeScannerViewControllerWrapper setBarcodeExtensionFilter:self.scannerViewController
|
|
140
150
|
filter:decodedConfig.barcodesExtensionFilter];
|
|
141
151
|
|
|
142
152
|
[RNScanbotBarcodeScannerViewControllerWrapper setLowPowerMode:self.scannerViewController value:decodedConfig.lowPowerMode];
|
|
143
|
-
|
|
153
|
+
|
|
144
154
|
[RNScanbotBarcodeScannerViewControllerWrapper setMinimumTextLenght:additionalConfig value:decodedConfig.minimumTextLength];
|
|
145
155
|
|
|
146
156
|
[RNScanbotBarcodeScannerViewControllerWrapper setMaximumTextLenght:additionalConfig value:decodedConfig.maximumTextLength];
|
|
147
|
-
|
|
157
|
+
|
|
148
158
|
[RNScanbotBarcodeScannerViewControllerWrapper setMinimum1DBarcodesQuietZone:additionalConfig value:decodedConfig.minimum1DBarcodesQuietZone];
|
|
149
|
-
|
|
159
|
+
|
|
150
160
|
[RNScanbotBarcodeScannerViewControllerWrapper setStripCheckDigits:additionalConfig value:decodedConfig.stripCheckDigits];
|
|
151
|
-
|
|
161
|
+
|
|
152
162
|
[RNScanbotBarcodeScannerViewControllerWrapper setGS1HandlingMode:additionalConfig gs1HandlingMode:decodedConfig.gs1Handling];
|
|
153
163
|
|
|
154
164
|
[RNScanbotBarcodeScannerViewControllerWrapper setMsiPlesseyChecksumAlgorithm:additionalConfig msiPlesseyChecksumAlgorithm:decodedConfig.msiPlesseyChecksumAlgorithm];
|
|
@@ -196,7 +206,7 @@
|
|
|
196
206
|
|
|
197
207
|
- (void) setOverlayTextFormat:(NSString * _Nullable) value {
|
|
198
208
|
SBSDKBarcodeOverlayFormat newFormat = [SBSDKBarcodeOverlayFormatDecoder fromString:value];
|
|
199
|
-
|
|
209
|
+
|
|
200
210
|
[RNScanbotBarcodeScannerViewControllerWrapper setOverlayTextFormat:self.scannerViewController value:newFormat];
|
|
201
211
|
}
|
|
202
212
|
|
|
@@ -230,11 +240,11 @@
|
|
|
230
240
|
}
|
|
231
241
|
|
|
232
242
|
- (void)barcodeTrackingOverlay:(SBSDKBarcodeTrackingOverlayController * _Nonnull)controller didTapOnBarcode:(SBSDKBarcodeScannerResult * _Nonnull)barcode {
|
|
233
|
-
|
|
243
|
+
|
|
234
244
|
if(!self.onSelectBarcodeResult){
|
|
235
245
|
return;
|
|
236
246
|
}
|
|
237
|
-
|
|
247
|
+
|
|
238
248
|
NSString *result = [RNScanbotBarcodeScannerViewControllerWrapper jsonFromResultOrNil:@[barcode]];
|
|
239
249
|
if(result != nil){
|
|
240
250
|
self.onSelectBarcodeResult(@{@"result":result});
|
|
@@ -243,15 +253,15 @@
|
|
|
243
253
|
}
|
|
244
254
|
|
|
245
255
|
- (SBSDKBarcodeTrackedViewPolygonStyle *)barcodeTrackingOverlay:(SBSDKBarcodeTrackingOverlayController * _Nonnull)controller polygonStyleFor:(SBSDKBarcodeScannerResult * _Nonnull)barcode {
|
|
246
|
-
|
|
256
|
+
|
|
247
257
|
return [RNScanbotBarcodeScannerViewControllerWrapper polygonForSelectedBarcode:barcode
|
|
248
258
|
selectedBarcodes:self.selectedBarcodes
|
|
249
259
|
controller:self.scannerViewController];
|
|
250
|
-
|
|
260
|
+
|
|
251
261
|
}
|
|
252
262
|
|
|
253
263
|
- (SBSDKBarcodeTrackedViewTextStyle *)barcodeTrackingOverlay:(SBSDKBarcodeTrackingOverlayController * _Nonnull)controller textStyleFor:(SBSDKBarcodeScannerResult * _Nonnull)barcode {
|
|
254
|
-
|
|
264
|
+
|
|
255
265
|
return [RNScanbotBarcodeScannerViewControllerWrapper textStyleForSelectedBarcode:barcode
|
|
256
266
|
selectedBarcodes:self.selectedBarcodes
|
|
257
267
|
controller:self.scannerViewController];
|
|
@@ -31,46 +31,45 @@ using namespace facebook::react;
|
|
|
31
31
|
static const auto defaultProps = std::make_shared<const ScanbotBarcodeScannerViewProps>();
|
|
32
32
|
_props = defaultProps;
|
|
33
33
|
_scanningEnabled = true;
|
|
34
|
-
_scannerViewController = [RNScanbotBarcodeScannerViewControllerWrapper initController];
|
|
35
|
-
_scannerViewController.delegate = self;
|
|
36
|
-
_scannerViewController.trackingOverlayController.delegate = self;
|
|
37
34
|
_selectedBarcodes = [NSMutableSet set];
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
|
|
36
|
+
self.vc = [[UIViewController alloc] init];
|
|
37
|
+
self.vc.view = self;
|
|
38
|
+
self.scannerViewController = [RNScanbotBarcodeScannerViewControllerWrapper initController];
|
|
39
|
+
self.scannerViewController.delegate = self;
|
|
40
|
+
self.scannerViewController.trackingOverlayController.delegate = self;
|
|
41
|
+
}
|
|
42
|
+
|
|
40
43
|
return self;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
- (void)didMoveToWindow {
|
|
44
47
|
[super didMoveToWindow];
|
|
45
|
-
|
|
46
|
-
if(self.window){
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[_scannerViewController attachWithParentViewController:_vc parentView:self];
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
if (_scannerViewController != nil) {
|
|
54
|
-
[_vc sbsdk_detachViewController:_scannerViewController];
|
|
55
|
-
_vc = nil;
|
|
48
|
+
|
|
49
|
+
if(self.window) {
|
|
50
|
+
if (self.vc == nil){
|
|
51
|
+
self.vc = [[UIViewController alloc] init];
|
|
52
|
+
self.vc.view = self;
|
|
56
53
|
}
|
|
54
|
+
[self.scannerViewController attachWithParentViewController:self.vc parentView:self];
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
- (void)prepareForRecycle {
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
self.scannerViewController = nil;
|
|
60
|
+
self.vc = nil;
|
|
63
61
|
self.selectedBarcodes = [NSMutableSet set];
|
|
64
62
|
static const auto defaultProps = std::make_shared<const ScanbotBarcodeScannerViewProps>();
|
|
65
63
|
_props = defaultProps;
|
|
64
|
+
[super prepareForRecycle];
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
69
68
|
{
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
if (self.scannerViewController == nil) {
|
|
70
|
+
self.scannerViewController = [RNScanbotBarcodeScannerViewControllerWrapper initController];
|
|
71
|
+
self.scannerViewController.delegate = self;
|
|
72
|
+
self.scannerViewController.trackingOverlayController.delegate = self;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
const auto &oldViewProps = *std::static_pointer_cast<ScanbotBarcodeScannerViewProps const>(_props);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-scanbot-barcode-scanner-sdk",
|
|
3
3
|
"title": "Scanbot Barcode Scanner SDK for React Native",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.1-beta.2",
|
|
5
5
|
"description": "Scanbot Barcode Scanner SDK React Native Plugin for Android and iOS",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
7
7
|
"module": "lib/module/index",
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"README.md",
|
|
20
20
|
"Libraries.txt",
|
|
21
21
|
"LICENSE",
|
|
22
|
+
"plugin",
|
|
23
|
+
"app.plugin.js",
|
|
22
24
|
"!ios/build",
|
|
23
25
|
"!android/build",
|
|
24
26
|
"!android/gradle",
|
|
@@ -34,7 +36,8 @@
|
|
|
34
36
|
"typecheck": "tsc --noEmit",
|
|
35
37
|
"lint": "eslint --fix --ext .ts,.tsx .",
|
|
36
38
|
"docgen": "typedoc",
|
|
37
|
-
"
|
|
39
|
+
"expo:plugin": "tsc --build plugin",
|
|
40
|
+
"prepare": "bob build && npm run expo:plugin && npm run docgen"
|
|
38
41
|
},
|
|
39
42
|
"keywords": [
|
|
40
43
|
"scanbot",
|
|
@@ -71,12 +74,16 @@
|
|
|
71
74
|
"url": "https://scanbot.io"
|
|
72
75
|
}
|
|
73
76
|
],
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@expo/config-plugins": "^8.0.8"
|
|
79
|
+
},
|
|
74
80
|
"devDependencies": {
|
|
75
81
|
"@react-native/eslint-config": "^0.73.1",
|
|
76
82
|
"@types/react": "^18.2.44",
|
|
77
83
|
"eslint": "^8.51.0",
|
|
78
84
|
"eslint-config-prettier": "^9.0.0",
|
|
79
85
|
"eslint-plugin-prettier": "^5.0.1",
|
|
86
|
+
"expo-module-scripts": "^3.5.2",
|
|
80
87
|
"prettier": "^3.0.3",
|
|
81
88
|
"react": "18.2.0",
|
|
82
89
|
"react-native": "0.74.1",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withAndroidCameraPermission = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const withAndroidCameraPermission = (config, { androidCameraPermission }) => {
|
|
6
|
+
if (androidCameraPermission) {
|
|
7
|
+
config = (0, config_plugins_1.withAndroidManifest)(config, (manifestProps) => {
|
|
8
|
+
const { manifest } = manifestProps.modResults;
|
|
9
|
+
const permissionKey = 'uses-permission';
|
|
10
|
+
if (!Array.isArray(manifest[permissionKey])) {
|
|
11
|
+
manifest[permissionKey] = [];
|
|
12
|
+
}
|
|
13
|
+
if (!manifest[permissionKey].find((item) => item.$['android:name'] === 'android.permission.CAMERA')) {
|
|
14
|
+
manifest[permissionKey].push({
|
|
15
|
+
$: {
|
|
16
|
+
'android:name': 'android.permission.CAMERA',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return manifestProps;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return config;
|
|
24
|
+
};
|
|
25
|
+
exports.withAndroidCameraPermission = withAndroidCameraPermission;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withAndroidFeature = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const withAndroidFeature = (config, { androidCameraFeature }) => {
|
|
6
|
+
if (androidCameraFeature) {
|
|
7
|
+
config = (0, config_plugins_1.withAndroidManifest)(config, (manifestProps) => {
|
|
8
|
+
const { manifest } = manifestProps.modResults;
|
|
9
|
+
const featureKey = 'uses-feature';
|
|
10
|
+
if (!Array.isArray(manifest[featureKey])) {
|
|
11
|
+
manifest[featureKey] = [];
|
|
12
|
+
}
|
|
13
|
+
if (!manifest[featureKey].find((item) => item.$['android:name'] === 'android.hardware.camera')) {
|
|
14
|
+
manifest[featureKey].push({
|
|
15
|
+
$: {
|
|
16
|
+
'android:name': 'android.hardware.camera',
|
|
17
|
+
'android:required': 'true',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return manifestProps;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
};
|
|
26
|
+
exports.withAndroidFeature = withAndroidFeature;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import { ScanbotConfigPlugin } from './pluginTypes';
|
|
3
|
+
export declare const withAndroidMavenURLs: ConfigPlugin<Pick<ScanbotConfigPlugin, 'mavenURLs'>>;
|
|
4
|
+
export declare const addMavenRepo: (projectBuildGradle: string) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addMavenRepo = exports.withAndroidMavenURLs = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const android_plugins_1 = require("@expo/config-plugins/build/plugins/android-plugins");
|
|
6
|
+
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
7
|
+
const withAndroidMavenURLs = (config, { mavenURLs }) => {
|
|
8
|
+
if (mavenURLs) {
|
|
9
|
+
config = (0, android_plugins_1.withProjectBuildGradle)(config, (gradleProps) => {
|
|
10
|
+
try {
|
|
11
|
+
gradleProps.modResults.contents = (0, exports.addMavenRepo)(gradleProps.modResults.contents);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
config_plugins_1.WarningAggregator.addWarningAndroid('react-native-scanbot-barcode-scanner-sdk', `Could not add maven URL to project build.gradle. Please insert the following\n` +
|
|
15
|
+
'maven { url "https://nexus.scanbot.io/nexus/content/repositories/releases/" }\n' +
|
|
16
|
+
'maven { url "https://nexus.scanbot.io/nexus/content/repositories/snapshots/" }\n' +
|
|
17
|
+
error.message ?? '');
|
|
18
|
+
}
|
|
19
|
+
return gradleProps;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return config;
|
|
23
|
+
};
|
|
24
|
+
exports.withAndroidMavenURLs = withAndroidMavenURLs;
|
|
25
|
+
const addMavenRepo = (projectBuildGradle) => {
|
|
26
|
+
const regex = new RegExp(/(?=allprojects\s*\{\s*\s*repositories\s*)[\s\S]*/, 'gm');
|
|
27
|
+
const allProjectRepositories = projectBuildGradle.match(regex);
|
|
28
|
+
if (allProjectRepositories && allProjectRepositories.length > 0) {
|
|
29
|
+
const merged = (0, generateCode_1.mergeContents)({
|
|
30
|
+
src: allProjectRepositories[0],
|
|
31
|
+
newSrc: ' maven { url "https://nexus.scanbot.io/nexus/content/repositories/releases/" }\n' +
|
|
32
|
+
' maven { url "https://nexus.scanbot.io/nexus/content/repositories/snapshots/" }',
|
|
33
|
+
tag: `react-native-scanbot-barcode-scanner-sdk`,
|
|
34
|
+
anchor: new RegExp('repositories {', 'gm'),
|
|
35
|
+
offset: 1,
|
|
36
|
+
comment: '//',
|
|
37
|
+
}).contents;
|
|
38
|
+
return projectBuildGradle.replace(regex, merged);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error('Could not find project repositories');
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.addMavenRepo = addMavenRepo;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withIOSCameraPermission = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
const withIOSCameraPermission = (config, { iOSCameraUsageDescription } = {}) => {
|
|
6
|
+
if (!!iOSCameraUsageDescription) {
|
|
7
|
+
config = (0, config_plugins_1.withInfoPlist)(config, (infoPlistProps) => {
|
|
8
|
+
infoPlistProps.modResults.NSCameraUsageDescription = iOSCameraUsageDescription;
|
|
9
|
+
return infoPlistProps;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return config;
|
|
13
|
+
};
|
|
14
|
+
exports.withIOSCameraPermission = withIOSCameraPermission;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
+
const withAndroidCameraPermission_1 = require("./withAndroidCameraPermission");
|
|
5
|
+
const withAndroidFeature_1 = require("./withAndroidFeature");
|
|
6
|
+
const withIOSCameraPermission_1 = require("./withIOSCameraPermission");
|
|
7
|
+
const withAndroidMavenURLs_1 = require("./withAndroidMavenURLs");
|
|
8
|
+
const pkg = require('../../package.json');
|
|
9
|
+
const withScanbotSDK = (config, props = {}) => {
|
|
10
|
+
return (0, config_plugins_1.withPlugins)(config, [
|
|
11
|
+
[withAndroidCameraPermission_1.withAndroidCameraPermission, props],
|
|
12
|
+
[withAndroidFeature_1.withAndroidFeature, props],
|
|
13
|
+
[withIOSCameraPermission_1.withIOSCameraPermission, props],
|
|
14
|
+
[withAndroidMavenURLs_1.withAndroidMavenURLs, props],
|
|
15
|
+
]);
|
|
16
|
+
};
|
|
17
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withScanbotSDK, pkg.name, pkg.version);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConfigPlugin, withAndroidManifest } from '@expo/config-plugins';
|
|
2
|
+
import { ScanbotConfigPlugin } from './pluginTypes';
|
|
3
|
+
|
|
4
|
+
export const withAndroidCameraPermission: ConfigPlugin<
|
|
5
|
+
Pick<ScanbotConfigPlugin, 'androidCameraPermission'>
|
|
6
|
+
> = (config, { androidCameraPermission }) => {
|
|
7
|
+
if (androidCameraPermission) {
|
|
8
|
+
config = withAndroidManifest(config, (manifestProps) => {
|
|
9
|
+
const { manifest } = manifestProps.modResults;
|
|
10
|
+
const permissionKey = 'uses-permission';
|
|
11
|
+
|
|
12
|
+
if (!Array.isArray(manifest[permissionKey])) {
|
|
13
|
+
manifest[permissionKey] = [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (
|
|
17
|
+
!manifest[permissionKey].find(
|
|
18
|
+
(item) => item.$['android:name'] === 'android.permission.CAMERA'
|
|
19
|
+
)
|
|
20
|
+
) {
|
|
21
|
+
manifest[permissionKey].push({
|
|
22
|
+
$: {
|
|
23
|
+
'android:name': 'android.permission.CAMERA',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return manifestProps;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return config;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConfigPlugin, withAndroidManifest } from '@expo/config-plugins';
|
|
2
|
+
import { ScanbotConfigPlugin } from './pluginTypes';
|
|
3
|
+
|
|
4
|
+
export const withAndroidFeature: ConfigPlugin<Pick<ScanbotConfigPlugin, 'androidCameraFeature'>> = (
|
|
5
|
+
config,
|
|
6
|
+
{ androidCameraFeature }
|
|
7
|
+
) => {
|
|
8
|
+
if (androidCameraFeature) {
|
|
9
|
+
config = withAndroidManifest(config, (manifestProps) => {
|
|
10
|
+
const { manifest } = manifestProps.modResults;
|
|
11
|
+
const featureKey = 'uses-feature';
|
|
12
|
+
|
|
13
|
+
if (!Array.isArray(manifest[featureKey])) {
|
|
14
|
+
manifest[featureKey] = [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (
|
|
18
|
+
!manifest[featureKey].find((item) => item.$['android:name'] === 'android.hardware.camera')
|
|
19
|
+
) {
|
|
20
|
+
manifest[featureKey].push({
|
|
21
|
+
$: {
|
|
22
|
+
'android:name': 'android.hardware.camera',
|
|
23
|
+
'android:required': 'true',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return manifestProps;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return config;
|
|
33
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ConfigPlugin, WarningAggregator } from '@expo/config-plugins';
|
|
2
|
+
import { withProjectBuildGradle } from '@expo/config-plugins/build/plugins/android-plugins';
|
|
3
|
+
import { mergeContents } from '@expo/config-plugins/build/utils/generateCode';
|
|
4
|
+
import { ScanbotConfigPlugin } from './pluginTypes';
|
|
5
|
+
|
|
6
|
+
export const withAndroidMavenURLs: ConfigPlugin<Pick<ScanbotConfigPlugin, 'mavenURLs'>> = (
|
|
7
|
+
config,
|
|
8
|
+
{ mavenURLs }
|
|
9
|
+
) => {
|
|
10
|
+
if (mavenURLs) {
|
|
11
|
+
config = withProjectBuildGradle(config, (gradleProps) => {
|
|
12
|
+
try {
|
|
13
|
+
gradleProps.modResults.contents = addMavenRepo(gradleProps.modResults.contents);
|
|
14
|
+
} catch (error: any) {
|
|
15
|
+
WarningAggregator.addWarningAndroid(
|
|
16
|
+
'react-native-scanbot-barcode-scanner-sdk',
|
|
17
|
+
`Could not add maven URL to project build.gradle. Please insert the following\n` +
|
|
18
|
+
'maven { url "https://nexus.scanbot.io/nexus/content/repositories/releases/" }\n' +
|
|
19
|
+
'maven { url "https://nexus.scanbot.io/nexus/content/repositories/snapshots/" }\n' +
|
|
20
|
+
error.message ?? ''
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return gradleProps;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return config;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const addMavenRepo = (projectBuildGradle: string) => {
|
|
32
|
+
const regex = new RegExp(/(?=allprojects\s*\{\s*\s*repositories\s*)[\s\S]*/, 'gm');
|
|
33
|
+
const allProjectRepositories = projectBuildGradle.match(regex);
|
|
34
|
+
|
|
35
|
+
if (allProjectRepositories && allProjectRepositories.length > 0) {
|
|
36
|
+
const merged = mergeContents({
|
|
37
|
+
src: allProjectRepositories[0],
|
|
38
|
+
newSrc:
|
|
39
|
+
' maven { url "https://nexus.scanbot.io/nexus/content/repositories/releases/" }\n' +
|
|
40
|
+
' maven { url "https://nexus.scanbot.io/nexus/content/repositories/snapshots/" }',
|
|
41
|
+
tag: `react-native-scanbot-barcode-scanner-sdk`,
|
|
42
|
+
anchor: new RegExp('repositories {', 'gm'),
|
|
43
|
+
offset: 1,
|
|
44
|
+
comment: '//',
|
|
45
|
+
}).contents;
|
|
46
|
+
|
|
47
|
+
return projectBuildGradle.replace(regex, merged);
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error('Could not find project repositories');
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfigPlugin, withInfoPlist } from '@expo/config-plugins';
|
|
2
|
+
import { ScanbotConfigPlugin } from './pluginTypes';
|
|
3
|
+
|
|
4
|
+
export const withIOSCameraPermission: ConfigPlugin<
|
|
5
|
+
Pick<ScanbotConfigPlugin, 'iOSCameraUsageDescription'>
|
|
6
|
+
> = (config, { iOSCameraUsageDescription } = {}) => {
|
|
7
|
+
if (!!iOSCameraUsageDescription) {
|
|
8
|
+
config = withInfoPlist(config, (infoPlistProps) => {
|
|
9
|
+
infoPlistProps.modResults.NSCameraUsageDescription = iOSCameraUsageDescription;
|
|
10
|
+
return infoPlistProps;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return config;
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConfigPlugin, createRunOncePlugin, withPlugins } from '@expo/config-plugins';
|
|
2
|
+
import { withAndroidCameraPermission } from './withAndroidCameraPermission';
|
|
3
|
+
import { withAndroidFeature } from './withAndroidFeature';
|
|
4
|
+
import { withIOSCameraPermission } from './withIOSCameraPermission';
|
|
5
|
+
import { withAndroidMavenURLs } from './withAndroidMavenURLs';
|
|
6
|
+
import { ScanbotConfigPlugin } from './pluginTypes';
|
|
7
|
+
|
|
8
|
+
const pkg = require('../../package.json');
|
|
9
|
+
|
|
10
|
+
const withScanbotSDK: ConfigPlugin<ScanbotConfigPlugin> = (config, props = {}) => {
|
|
11
|
+
return withPlugins(config, [
|
|
12
|
+
[withAndroidCameraPermission, props],
|
|
13
|
+
[withAndroidFeature, props],
|
|
14
|
+
[withIOSCameraPermission, props],
|
|
15
|
+
[withAndroidMavenURLs, props],
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default createRunOncePlugin(withScanbotSDK, pkg.name, pkg.version);
|