react-native-ble-manager 11.5.7 → 12.0.0-rc.0

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.
Files changed (40) hide show
  1. package/README.md +16 -3
  2. package/RNBleManager.podspec +24 -0
  3. package/android/build.gradle +116 -43
  4. package/android/gradle.properties +1 -0
  5. package/android/src/main/java/it/innove/BleManager.java +174 -148
  6. package/android/src/main/java/it/innove/BleManagerPackage.java +15 -14
  7. package/android/src/main/java/it/innove/CompanionScanner.java +13 -3
  8. package/android/src/main/java/it/innove/DefaultPeripheral.java +4 -4
  9. package/android/src/main/java/it/innove/DefaultScanManager.java +16 -16
  10. package/android/src/main/java/it/innove/Peripheral.java +20 -17
  11. package/dist/cjs/NativeBleManager.d.ts +241 -0
  12. package/dist/cjs/NativeBleManager.js +5 -0
  13. package/dist/cjs/NativeBleManager.js.map +1 -0
  14. package/dist/cjs/index.d.ts +15 -3
  15. package/dist/cjs/index.js +89 -38
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/types.d.ts +11 -11
  18. package/dist/esm/NativeBleManager.d.ts +241 -0
  19. package/dist/esm/NativeBleManager.js +3 -0
  20. package/dist/esm/NativeBleManager.js.map +1 -0
  21. package/dist/esm/index.d.ts +15 -3
  22. package/dist/esm/index.js +92 -41
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/types.d.ts +11 -11
  25. package/ios/BleManager-Bridging-Header.h +7 -1
  26. package/ios/BleManager.h +39 -2
  27. package/ios/BleManager.mm +277 -0
  28. package/ios/Helper.swift +6 -6
  29. package/ios/RNBleManager.h +7 -0
  30. package/ios/{BleManager.swift → SwiftBleManager.swift} +322 -355
  31. package/package.json +107 -56
  32. package/src/NativeBleManager.ts +409 -0
  33. package/src/index.ts +162 -77
  34. package/src/types.ts +31 -31
  35. package/android/src/main/java/it/innove/LegacyScanManager.java +0 -112
  36. package/ios/BleManager.m +0 -153
  37. package/ios/BleManager.xcodeproj/project.pbxproj +0 -324
  38. package/ios/BleManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  39. package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  40. package/react-native-ble-manager.podspec +0 -17
package/README.md CHANGED
@@ -14,15 +14,16 @@ The library is a simple connection with the OS APIs, the BLE stack should be sta
14
14
 
15
15
  ## Requirements
16
16
 
17
- RN 0.60+
17
+ RN 0.76+
18
18
 
19
+ RN 0.60-0.75 supported until 11.5.X
19
20
  RN 0.40-0.59 supported until 6.7.X
20
21
  RN 0.30-0.39 supported until 2.4.3
21
22
 
22
23
  ## Supported Platforms
23
24
 
24
- - iOS 10+
25
- - Android (API 19+)
25
+ - iOS 15.1+
26
+ - Android (API 23+)
26
27
 
27
28
  ## Install
28
29
 
@@ -69,3 +70,15 @@ npm run build
69
70
  ```
70
71
 
71
72
  > if you are modifying the typescript files of the library (in `src/`) on the fly, you can run `npm run watch` instead. If you are modifying files from the native counterparts, you'll need to rebuild the whole app for your target environnement (`npm run android/ios`).
73
+
74
+ ## Generate the native code from specs
75
+ A react-native project is needed to generate the code via *codegen*.
76
+
77
+ #### Generate Android code
78
+ - in the example folder generate the android project from expo: `npx expo prebuild --platform android`
79
+ - in the example/android folder run: `./gradlew generateCodegenArtifactsFromSchema` (you can add --info to have debug messages)
80
+ - if you have problems with the gradle cache `cd android && ./gradlew --stop && rm -rf ~/.gradle/caches`
81
+
82
+ #### Generate iOS code
83
+ - in the example folder generate the ios project from expo: `npx expo prebuild --platform ios`
84
+ - the codegen run during the first build, if you need to run it again use `pod install` in the ios folder
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "RNBleManager"
7
+ s.summary = package['description']
8
+ s.version = package['version']
9
+ s.authors = package["author"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.platform = :ios, "11.0"
13
+ s.source = { :git => "https://github.com/innoveit/react-native-ble-manager.git" }
14
+ s.source_files = "ios/**/*.{h,mm,swift}"
15
+
16
+ s.static_framework = true
17
+
18
+ s.pod_target_xcconfig = {
19
+ 'DEFINES_MODULE' => 'YES',
20
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
21
+ }
22
+
23
+ install_modules_dependencies(s)
24
+ end
@@ -1,59 +1,132 @@
1
1
  buildscript {
2
- // The Android Gradle plugin is only required when opening the android folder stand-alone.
3
- // This avoids unnecessary downloads and potential conflicts when the library is included as a
4
- // module dependency in an application project.
5
- if (project == rootProject) {
6
- repositories {
7
- google()
8
- jcenter()
9
- }
10
-
11
- dependencies {
12
- classpath("com.android.tools.build:gradle:7.3.1")
13
- }
14
- }
2
+
3
+ if (project == rootProject) {
4
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["kotlinVersion"]
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:7.2.1"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15
+ }
16
+ }
17
+
15
18
  }
19
+
20
+ def reactNativeArchitectures() {
21
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
22
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
23
+ }
24
+
25
+ def isNewArchitectureEnabled() {
26
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
27
+ }
28
+
16
29
  apply plugin: 'com.android.library'
30
+ apply plugin: "kotlin-android"
31
+
32
+ if (isNewArchitectureEnabled()) {
33
+ apply plugin: 'com.facebook.react'
34
+ }
17
35
 
18
36
  def safeExtGet(prop, fallback) {
19
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
37
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
38
+ }
39
+
40
+ def getExtOrDefault(name) {
41
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["BleManager_" + name]
42
+ }
43
+
44
+ static def supportsNamespace() {
45
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
46
+ def major = parsed[0].toInteger()
47
+ def minor = parsed[1].toInteger()
48
+
49
+ // Namespace support was added in 7.3.0
50
+ return (major == 7 && minor >= 3) || major >= 8
20
51
  }
21
52
 
22
53
  android {
23
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
24
- if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
25
- namespace "it.innove"
26
- }
27
-
28
- compileSdk safeExtGet("compileSdk", 34)
29
-
30
- compileOptions {
31
- sourceCompatibility JavaVersion.VERSION_1_9
32
- targetCompatibility JavaVersion.VERSION_1_9
33
- }
34
-
35
- defaultConfig {
36
- minSdkVersion safeExtGet("minSdkVersion", 21)
37
- targetSdk safeExtGet("targetSdk", 34)
38
- }
39
- lintOptions {
40
- abortOnError false
41
- }
54
+ if (supportsNamespace()) {
55
+ namespace "it.innove"
56
+
57
+ sourceSets {
58
+ main {
59
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
60
+ }
61
+ }
62
+ }
63
+
64
+ compileSdk safeExtGet("compileSdk", 34)
65
+
66
+ compileOptions {
67
+ sourceCompatibility JavaVersion.VERSION_1_9
68
+ targetCompatibility JavaVersion.VERSION_1_9
69
+ }
70
+
71
+ defaultConfig {
72
+ minSdkVersion safeExtGet("minSdkVersion", 21)
73
+ targetSdk safeExtGet("targetSdk", 34)
74
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
75
+ }
76
+
77
+ buildFeatures {
78
+ buildConfig true
79
+ }
80
+
81
+ buildTypes {
82
+ release {
83
+ minifyEnabled false
84
+ }
85
+ }
86
+
87
+ lintOptions {
88
+ disable "GradleCompatible"
89
+ }
90
+
91
+ // To support legacy module in the future
92
+ /*
93
+ sourceSets {
94
+ main {
95
+ if (isNewArchitectureEnabled()) {
96
+ java.srcDirs += [
97
+ "src/newarch",
98
+ // Codegen specs
99
+ "generated/java",
100
+ "generated/jni"
101
+ ]
102
+ } else {
103
+ java.srcDirs += ["src/oldarch"]
104
+ }
105
+ }
106
+ }
107
+ */
42
108
  }
43
109
 
110
+
44
111
  repositories {
45
- mavenCentral()
46
- google()
47
- jcenter()
48
- maven {
49
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
50
- //url "$rootDir/../node_modules/react-native/android"
51
- url "$rootDir/../example/node_modules/react-native/android"
52
- }
112
+ mavenCentral()
113
+ google()
53
114
  }
54
115
 
116
+ def kotlin_version = getExtOrDefault("kotlinVersion")
55
117
 
56
118
  dependencies {
57
- implementation "com.facebook.react:react-native:+"
58
- // implementation "org.jetbrains.trove4j: trove4j: 20160824"
119
+ // For < 0.71, this will be from the local maven repo
120
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
121
+ //noinspection GradleDynamicVersion
122
+ implementation "com.facebook.react:react-native:+"
123
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
59
124
  }
125
+
126
+ if (isNewArchitectureEnabled()) {
127
+ react {
128
+ jsRootDir = file("../src/")
129
+ libraryName = "BleManager"
130
+ codegenJavaPackageName = "it.innove"
131
+ }
132
+ }
@@ -1,3 +1,4 @@
1
+ kotlinVersion=1.7.0
1
2
  android.useAndroidX=true
2
3
  android.enableJetifier=true
3
4
  # https://github.com/facebook/react-native/issues/35168