@scrumble-nl/react-native-honeywell-scanner 1.3.11 → 1.4.1

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.
@@ -1,27 +1,23 @@
1
1
  // android/build.gradle
2
2
 
3
- // based on:
4
- //
5
- // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6
- // original location:
7
- // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8
- //
9
- // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10
- // original location:
11
- // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12
-
13
- def DEFAULT_COMPILE_SDK_VERSION = 30
14
- def DEFAULT_BUILD_TOOLS_VERSION = "30.0.2"
15
- def DEFAULT_MIN_SDK_VERSION = 21
16
- def DEFAULT_TARGET_SDK_VERSION = 30
17
- def DEFAULT_NDK_VERSION = "21.4.7075529"
18
-
19
3
  def safeExtGet(prop, fallback) {
20
4
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
21
5
  }
22
6
 
23
- apply plugin: 'com.android.library'
24
- apply plugin: 'maven'
7
+ def myAttribute = Attribute.of("com.android.build.api.attributes.BuildTypeAttr", String)
8
+
9
+ dependencies.attributesSchema {
10
+ // registers this attribute to the attributes attributes
11
+ attribute(myAttribute)
12
+ }
13
+
14
+ configurations {
15
+ implementation {
16
+ attributes {
17
+ attribute(myAttribute, "release")
18
+ }
19
+ }
20
+ }
25
21
 
26
22
  buildscript {
27
23
  // The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -31,19 +27,23 @@ buildscript {
31
27
  if (project == rootProject) {
32
28
  repositories {
33
29
  google()
34
- jcenter()
30
+ mavenCentral()
35
31
  }
36
32
  dependencies {
37
- classpath 'com.android.tools.build:gradle:4.2.2'
33
+ classpath 'com.android.tools.build:gradle:4.1.1'
38
34
  }
39
35
  }
40
36
  }
41
37
 
42
38
  apply plugin: 'com.android.library'
43
- apply plugin: 'maven'
39
+ apply plugin: 'maven-publish'
40
+
41
+ def DEFAULT_COMPILE_SDK_VERSION = 31
42
+ def DEFAULT_BUILD_TOOLS_VERSION = "31.0.0"
43
+ def DEFAULT_MIN_SDK_VERSION = 21
44
+ def DEFAULT_TARGET_SDK_VERSION = 31
44
45
 
45
46
  android {
46
- ndkVersion safeExtGet('ndkVersion', DEFAULT_NDK_VERSION)
47
47
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
48
48
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
49
49
  defaultConfig {
@@ -58,22 +58,28 @@ android {
58
58
  }
59
59
 
60
60
  repositories {
61
- // ref: https://www.baeldung.com/maven-local-repository
62
- mavenLocal()
63
61
  maven {
64
62
  // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
65
- url "$rootDir/../node_modules/react-native/android"
63
+ url("$rootDir/../node_modules/react-native/android")
66
64
  }
67
65
  maven {
68
66
  // Android JSC is installed from npm
69
- url "$rootDir/../node_modules/jsc-android/dist"
67
+ url("$rootDir/../node_modules/jsc-android/dist")
68
+ }
69
+ mavenCentral {
70
+ // We don't want to fetch react-native from Maven Central as there are
71
+ // older versions over there.
72
+ content {
73
+ excludeGroup "com.facebook.react"
74
+ }
70
75
  }
71
76
  google()
72
- jcenter()
77
+ maven { url 'https://www.jitpack.io' }
78
+ mavenCentral()
73
79
  }
74
80
 
75
81
  dependencies {
76
- compile fileTree(dir: "libs", include: ["*.jar"])
82
+ implementation fileTree(dir: "libs", include: ["*.jar"])
77
83
  //noinspection GradleDynamicVersion
78
84
  implementation 'com.facebook.react:react-native:+' // From node_modules
79
85
  }
@@ -85,7 +91,7 @@ def configureReactNativePom(def pom) {
85
91
  name packageJson.title
86
92
  artifactId packageJson.name
87
93
  version = packageJson.version
88
- group = "com.reactlibrary"
94
+ group = "com.scrumble.honeywellscannerinterface"
89
95
  description packageJson.description
90
96
  url packageJson.repository
91
97
 
@@ -111,7 +117,8 @@ afterEvaluate { project ->
111
117
  task androidJavadoc(type: Javadoc) {
112
118
  source = android.sourceSets.main.java.srcDirs
113
119
  classpath += files(android.bootClasspath)
114
- classpath += files(project.getConfigurations().getByName('compile').asList())
120
+ project.getConfigurations().getByName('implementation').setCanBeResolved(true)
121
+ classpath += files(project.getConfigurations().getByName('implementation').asList())
115
122
  include '**/*.java'
116
123
  }
117
124
 
@@ -128,10 +135,8 @@ afterEvaluate { project ->
128
135
 
129
136
  android.libraryVariants.all { variant ->
130
137
  def name = variant.name.capitalize()
131
- def javaCompileTask = variant.javaCompileProvider.get()
132
-
133
138
  task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
134
- from javaCompileTask.destinationDir
139
+ from variant.javaCompile.destinationDir
135
140
  }
136
141
  }
137
142
 
@@ -140,12 +145,11 @@ afterEvaluate { project ->
140
145
  archives androidJavadocJar
141
146
  }
142
147
 
143
- task installArchives(type: Upload) {
144
- configuration = configurations.archives
145
- repositories.mavenDeployer {
146
- // Deploy to react-native-event-bridge/maven, ready to publish to npm
147
- repository url: "file://${projectDir}/../android/maven"
148
- configureReactNativePom pom
148
+ publishing {
149
+ publications {
150
+ maven(MavenPublication) {
151
+ artifact androidSourcesJar
152
+ }
149
153
  }
150
154
  }
151
155
  }
@@ -1,5 +1,5 @@
1
1
  #Wed Jan 15 14:51:07 MSK 2020
2
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
2
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3
3
  distributionBase=GRADLE_USER_HOME
4
4
  distributionPath=wrapper/dists
5
5
  zipStorePath=wrapper/dists
@@ -1,4 +1,4 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.reactlibrary">
2
+ package="com.scrumble.honeywellscannerinterface">
3
3
  <uses-permission android:name="com.honeywell.decode.permission.DECODE" />
4
4
  </manifest>
@@ -1,17 +1,12 @@
1
- package com.reactlibrary;
1
+ package com.scrumble.honeywellscannerinterface;
2
2
 
3
3
  import android.os.Build;
4
4
  import android.util.Log;
5
- import android.os.Bundle;
6
- import android.app.AlertDialog;
7
- import android.content.DialogInterface;
8
- import android.widget.Toast;
9
5
 
10
6
  import com.facebook.react.bridge.*;
11
7
  import com.facebook.react.modules.core.DeviceEventManagerModule;
12
8
  import com.honeywell.aidc.*;
13
9
  import com.honeywell.aidc.AidcManager.CreatedCallback;
14
- import com.honeywell.aidc.AidcManager.*;
15
10
 
16
11
  import javax.annotation.Nullable;
17
12
 
@@ -19,12 +14,12 @@ import java.util.HashMap;
19
14
  import java.util.Map;
20
15
  import java.util.List;
21
16
 
22
- import static com.reactlibrary.HoneywellScannerPackage.HoneyWellTAG;
17
+ import static com.scrumble.honeywellscannerinterface.HoneywellScannerPackage.HoneyWellTAG;
23
18
 
24
19
  public class HoneywellScannerModule extends ReactContextBaseJavaModule implements BarcodeReader.BarcodeListener {
25
20
 
26
21
  // Debugging
27
- private static final boolean D = true;
22
+ private static final boolean D = false;
28
23
 
29
24
  private final ReactApplicationContext reactContext;
30
25
  private AidcManager manager;
@@ -1,4 +1,4 @@
1
- package com.reactlibrary;
1
+ package com.scrumble.honeywellscannerinterface;
2
2
 
3
3
  import java.util.Arrays;
4
4
  import java.util.Collections;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,28 @@
1
- declare const HoneywellScanner: any;
2
- export default HoneywellScanner;
1
+ /**
2
+ * Listen for available events
3
+ * @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
4
+ * @param {Function} handler Event handler
5
+ */
6
+ interface Scanner {
7
+ registerListener: (event: (event: {
8
+ data: string;
9
+ }) => void) => void;
10
+ clearEventListeners: () => void;
11
+ onBarcodeReadFail?: (event: (event: {
12
+ data: string;
13
+ }) => void) => void;
14
+ }
15
+ declare class Honeywell implements Scanner {
16
+ subscriptionBarcodeReadSuccess: any;
17
+ subscriptionBarcodeReadFail: any;
18
+ constructor();
19
+ registerListener: (event: (event: {
20
+ data: string;
21
+ }) => void) => void;
22
+ clearEventListeners: () => void;
23
+ onBarcodeReadFail: (event: (event: {
24
+ data: string;
25
+ }) => void) => void;
26
+ }
27
+ declare const _default: Honeywell;
28
+ export default _default;
package/dist/index.js CHANGED
@@ -2,33 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_native_1 = require("react-native");
4
4
  const { HoneywellScanner } = react_native_1.NativeModules;
5
- /**
6
- * Listen for available events
7
- * @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
8
- * @param {Function} handler Event handler
9
- */
10
5
  const barcodeReaderEmitter = new react_native_1.NativeEventEmitter(HoneywellScanner);
11
- var subscriptionBarcodeReadSuccess = null;
12
- var subscriptionBarcodeReadFail = null;
13
- HoneywellScanner.onBarcodeReadSuccess = (handler) => {
14
- subscriptionBarcodeReadSuccess === null || subscriptionBarcodeReadSuccess === void 0 ? void 0 : subscriptionBarcodeReadSuccess.remove();
15
- subscriptionBarcodeReadSuccess = null;
16
- subscriptionBarcodeReadSuccess = barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_SUCCESS, handler);
17
- };
18
- HoneywellScanner.onBarcodeReadFail = (handler) => {
19
- subscriptionBarcodeReadFail === null || subscriptionBarcodeReadFail === void 0 ? void 0 : subscriptionBarcodeReadFail.remove();
20
- subscriptionBarcodeReadFail = null;
21
- subscriptionBarcodeReadFail = barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_FAIL, handler);
22
- };
23
- /**
24
- * Stop listening for event
25
- * @param {String} eventName Name of event one of barcodeReadSuccess, barcodeReadFail
26
- * @param {Function} handler Event handler
27
- */
28
- HoneywellScanner.offBarcodeReadSuccess = () => {
29
- subscriptionBarcodeReadSuccess === null || subscriptionBarcodeReadSuccess === void 0 ? void 0 : subscriptionBarcodeReadSuccess.remove();
30
- };
31
- HoneywellScanner.offBarcodeReadFail = () => {
32
- subscriptionBarcodeReadFail === null || subscriptionBarcodeReadFail === void 0 ? void 0 : subscriptionBarcodeReadFail.remove();
33
- };
34
- exports.default = HoneywellScanner;
6
+ class Honeywell {
7
+ constructor() {
8
+ this.registerListener = (event) => {
9
+ console.log('register event 1: ', event);
10
+ HoneywellScanner.startReader().then(() => {
11
+ var _a;
12
+ console.log('register event 2: ', event);
13
+ (_a = this.subscriptionBarcodeReadSuccess) === null || _a === void 0 ? void 0 : _a.remove();
14
+ this.subscriptionBarcodeReadSuccess = null;
15
+ this.subscriptionBarcodeReadSuccess = barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_SUCCESS, event);
16
+ console.log('success', this.subscriptionBarcodeReadSuccess);
17
+ });
18
+ };
19
+ this.clearEventListeners = () => {
20
+ console.log('clear 1');
21
+ HoneywellScanner.stopReader().then(() => {
22
+ var _a;
23
+ console.log('clear 2');
24
+ (_a = this.subscriptionBarcodeReadSuccess) === null || _a === void 0 ? void 0 : _a.remove();
25
+ });
26
+ };
27
+ this.onBarcodeReadFail = (event) => {
28
+ var _a;
29
+ (_a = this.subscriptionBarcodeReadFail) === null || _a === void 0 ? void 0 : _a.remove();
30
+ this.subscriptionBarcodeReadFail = null;
31
+ this.subscriptionBarcodeReadFail = barcodeReaderEmitter.addListener(HoneywellScanner.BARCODE_READ_FAIL, event);
32
+ };
33
+ this.subscriptionBarcodeReadSuccess = null;
34
+ this.subscriptionBarcodeReadFail = null;
35
+ }
36
+ }
37
+ exports.default = new Honeywell();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scrumble-nl/react-native-honeywell-scanner",
3
3
  "title": "React Native Honeywell Scanner",
4
- "version": "1.3.11",
4
+ "version": "1.4.1",
5
5
  "description": "Bridge to use the Honeywell scanner",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -25,8 +25,12 @@
25
25
  "license": "MIT",
26
26
  "licenseFilename": "LICENSE",
27
27
  "readmeFilename": "README.md",
28
- "dependencies": {
29
- "react": "^17.0.2",
30
- "react-native": "^0.68.5"
28
+ "peerDependencies": {
29
+ "react": "18.*",
30
+ "react-native": "0.*"
31
+ },
32
+ "devDependencies": {
33
+ "react": "^18.*",
34
+ "react-native": "0.*"
31
35
  }
32
36
  }