@stream-io/noise-cancellation-react-native 1.0.0-beta.0 → 1.0.0-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.
Files changed (30) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +44 -0
  3. package/android/build.gradle +50 -77
  4. package/android/src/main/AndroidManifest.xml +1 -2
  5. package/android/src/main/java/io/getstream/rn/noisecancellation/NoiseCancellationReactNativeModule.kt +12 -39
  6. package/android/src/main/java/io/getstream/rn/noisecancellation/NoiseCancellationReactNativePackage.kt +21 -9
  7. package/dist/commonjs/NativeNoiseCancellationReactNative.js +9 -0
  8. package/dist/commonjs/NativeNoiseCancellationReactNative.js.map +1 -0
  9. package/dist/commonjs/index.js +12 -20
  10. package/dist/commonjs/index.js.map +1 -1
  11. package/dist/module/NativeNoiseCancellationReactNative.js +5 -0
  12. package/dist/module/NativeNoiseCancellationReactNative.js.map +1 -0
  13. package/dist/module/index.js +6 -15
  14. package/dist/module/index.js.map +1 -1
  15. package/dist/typescript/NativeNoiseCancellationReactNative.d.ts +9 -0
  16. package/dist/typescript/NativeNoiseCancellationReactNative.d.ts.map +1 -0
  17. package/dist/typescript/index.d.ts +7 -6
  18. package/dist/typescript/index.d.ts.map +1 -1
  19. package/ios/Classes/NeuralEngineProvider.swift +1 -7
  20. package/ios/NoiseCancellationReactNative.h +5 -0
  21. package/ios/NoiseCancellationReactNative.mm +46 -13
  22. package/ios/NoiseCancellationReactNativeImpl.swift +33 -0
  23. package/package.json +26 -4
  24. package/src/NativeNoiseCancellationReactNative.ts +11 -0
  25. package/src/index.ts +9 -25
  26. package/stream-io-noise-cancellation-react-native.podspec +3 -3
  27. package/android/gradle.properties +0 -5
  28. package/android/src/main/AndroidManifestNew.xml +0 -2
  29. package/ios/NoiseCancellationReactNative-Bridging-Header.h +0 -2
  30. package/ios/NoiseCancellationReactNative.swift +0 -45
package/CHANGELOG.md CHANGED
@@ -2,6 +2,98 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.0.0-beta.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/noise-cancellation-react-native-1.0.0-beta.1...@stream-io/noise-cancellation-react-native-1.0.0-beta.2) (2026-10-16)
6
+
7
+ ### ⚠ BREAKING CHANGES
8
+
9
+ - remove deprecated APIs and legacy code for v2 (#2498)
10
+
11
+ ### Features
12
+
13
+ - remove deprecated APIs and legacy code for v2 ([#2498](https://github.com/GetStream/stream-video-js/issues/2498)) ([7a20921](https://github.com/GetStream/stream-video-js/commit/7a209213d0eddb7ad8f1d21e55bd43910391666e)), closes [#2493](https://github.com/GetStream/stream-video-js/issues/2493)
14
+
15
+ ## [1.0.0-beta.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/noise-cancellation-react-native-1.0.0-beta.0...@stream-io/noise-cancellation-react-native-1.0.0-beta.1) (2026-09-28)
16
+
17
+ ### ⚠ BREAKING CHANGES
18
+
19
+ - **react-native:** Requires React Native >=0.79.0 with the New
20
+ Architecture enabled. RN 0.79 provides the iOS module-provider
21
+ registration used by this implementation.
22
+
23
+ ### 📝 Implementation notes.
24
+
25
+ ### 1. Migration to React Native New Architecture and TurboModules
26
+
27
+ - Updated documentation in `README.md` to specify that the package now
28
+ requires React Native 0.79+ with the New Architecture enabled, and only
29
+ supports TurboModule registration.
30
+ - Refactored Android native module to use the TurboModule codegen
31
+ pattern, removing legacy code and simplifying the module/package
32
+ classes.
33
+ - Refactored iOS implementation to use a new Objective-C host
34
+ (`NoiseCancellationReactNative.h`/`.mm`) delegating to a Swift
35
+ implementation, fully adopting the TurboModule spec and removing legacy
36
+ bridging code.
37
+
38
+ ### 2. Android build system modernization
39
+
40
+ - Updated `build.gradle` to use AGP 8.7.2, Kotlin 2.0.21, Java 17, and
41
+ simplified/extensively cleaned up build logic, removing legacy property
42
+ indirection and supporting only the new namespace system.
43
+ - Removed obsolete manifest files and properties.
44
+
45
+ ### 3. iOS native module refactoring
46
+
47
+ - Removed old Swift implementation and replaced it with a new
48
+ implementation in `NoiseCancellationReactNativeImpl.swift`, with the
49
+ Objective-C wrapper delegating all logic to this class and conforming to
50
+ the TurboModule interface.
51
+
52
+ ### 4. JavaScript/TypeScript and testing improvements
53
+
54
+ - Added contract tests (`__tests__/native-module.test.cjs`) to verify
55
+ the JS interface against a stubbed TurboModule registry, ensuring
56
+ correct JS-native interaction and error propagation.
57
+ - Added a `test` script to `package.json` for running these contract
58
+ tests.
59
+
60
+ 🎫 Ticket: https://linear.app/stream/issue/XYZ-123
61
+
62
+ 📑 Docs: https://github.com/GetStream/docs-content/pull/<id>
63
+
64
+ <!-- This is an auto-generated comment: release notes by coderabbit.ai
65
+ -->
66
+
67
+ ## Summary by CodeRabbit
68
+
69
+ - **New Features**
70
+ - Noise-cancellation controls now provide synchronous status,
71
+ enablement, and device-support checks.
72
+ - The React Native integration now supports the New Architecture through
73
+ TurboModules.
74
+ - Noise-cancellation state and errors are handled more reliably in the
75
+ provider.
76
+
77
+ - **Bug Fixes**
78
+ - Checking whether noise cancellation is enabled before registration now
79
+ returns `false` instead of failing.
80
+
81
+ - **Documentation**
82
+ - Added setup requirements, native installation guidance, synchronous
83
+ API usage notes, and peer dependency information.
84
+ - Updated SDK installation guidance to require React Native 0.79+ with
85
+ the New Architecture enabled.
86
+
87
+ <!-- end of auto-generated comment: release notes by coderabbit.ai -->
88
+
89
+ ### Features
90
+
91
+ - **react-native:** Migrate noise cancellation module to TurboModule architecture ([#2447](https://github.com/GetStream/stream-video-js/issues/2447)) ([2842986](https://github.com/GetStream/stream-video-js/commit/2842986f6d3adeef8617af243fa11a3076aae4b2))
92
+
93
+ ### Bug Fixes
94
+
95
+ - **android:** skip explicit Kotlin plugin when AGP registers the kotlin extension ([#2417](https://github.com/GetStream/stream-video-js/issues/2417)) ([1bff5e0](https://github.com/GetStream/stream-video-js/commit/1bff5e0f5b4a2f2bbe62ab5eff2a6457251f6350)), closes [RevenueCat/react-native-purchases#1934](https://github.com/RevenueCat/react-native-purchases/issues/1934)
96
+
5
97
  ## [1.0.0-beta.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/noise-cancellation-react-native-0.11.0...@stream-io/noise-cancellation-react-native-1.0.0-beta.0) (2026-09-04)
6
98
 
7
99
  ## [0.11.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/noise-cancellation-react-native-0.10.0...@stream-io/noise-cancellation-react-native-0.11.0) (2026-08-18)
package/README.md CHANGED
@@ -2,8 +2,52 @@
2
2
 
3
3
  Noise Cancellation for React Native WebRTC
4
4
 
5
+ ## Requirements
6
+
7
+ - React Native `>=0.79.0` with the [New Architecture](https://reactnative.dev/architecture/landing-page)
8
+ enabled. This package ships as a TurboModule only: it is registered through the codegen
9
+ module provider that React Native 0.79 introduced, so older versions cannot link it. On
10
+ React Native 0.79–0.81 make sure the New Architecture is turned on; from 0.82 it is always on.
11
+ - `@stream-io/react-native-webrtc` `^145.3.1` installed as a peer dependency.
12
+
5
13
  ## Installation
6
14
 
7
15
  ```sh
8
16
  npm install @stream-io/noise-cancellation-react-native @stream-io/react-native-webrtc
9
17
  ```
18
+
19
+ See the [Stream Video React Native documentation](https://getstream.io/video/docs/reactnative/)
20
+ for the native setup steps and usage.
21
+
22
+ ## Direct helpers and SDK adapter
23
+
24
+ The native controls and directly exported `isEnabled()`, `setEnabled(enabled)`, and
25
+ `deviceSupportsAdvancedAudioProcessing()` helpers run synchronously and return booleans.
26
+
27
+ For these helpers, replace `.then()` / `.catch()` chains with direct calls and
28
+ `try` / `catch`:
29
+
30
+ ```ts
31
+ import {
32
+ isEnabled,
33
+ setEnabled,
34
+ } from '@stream-io/noise-cancellation-react-native';
35
+
36
+ try {
37
+ setEnabled(true);
38
+ const enabled = isEnabled();
39
+ } catch (error) {
40
+ // Handle setup errors, such as a missing native processor registration.
41
+ }
42
+ ```
43
+
44
+ Errors are thrown synchronously instead of rejecting a Promise. Native exceptions
45
+ do not guarantee the former Promise rejection's `code` property. Existing `await`
46
+ calls still work, but are unnecessary for these methods. A successful setter updates
47
+ the enabled state; it does not wait for internal DSP initialization or an audio frame.
48
+
49
+ The `NoiseCancellation` class remains a Promise-based adapter for the shared Video SDK
50
+ interface. Its `isEnabled()` and `canAutoEnable()` methods return `Promise<boolean>`;
51
+ `enable()`, `disable()`, `init()`, and `dispose()` return `Promise<void>`. Native errors
52
+ become rejected Promises, and change events are dispatched after successful native
53
+ calls. Existing SDK integrations using this class do not need to change.
@@ -1,101 +1,74 @@
1
1
  buildscript {
2
- ext.getExtOrDefault = { name -> return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['NoiseCancellationReactNative_' + name]
2
+ ext.NoiseCancellationReactNative = [
3
+ kotlinVersion: "2.0.21",
4
+ minSdkVersion: 24,
5
+ compileSdkVersion: 35
6
+ ]
7
+
8
+ ext.getExtOrDefault = { prop ->
9
+ if (rootProject.ext.has(prop)) {
10
+ return rootProject.ext.get(prop)
3
11
  }
4
12
 
5
- repositories {
6
- google()
7
- mavenCentral()
8
- }
13
+ return NoiseCancellationReactNative[prop]
14
+ }
9
15
 
10
- dependencies {
11
- classpath("com.android.tools.build:gradle:7.3.1")
12
- // noinspection DifferentKotlinGradleVersion
13
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
14
- }
15
- }
16
+ repositories {
17
+ google()
18
+ mavenCentral()
19
+ }
16
20
 
21
+ dependencies {
22
+ classpath "com.android.tools.build:gradle:8.7.2"
23
+ // noinspection DifferentKotlinGradleVersion
24
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
25
+ }
26
+ }
17
27
 
18
28
  apply plugin: "com.android.library"
19
- apply plugin: "kotlin-android"
20
-
21
29
 
22
- def getExtOrIntegerDefault(name) {
23
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NoiseCancellationReactNative_" + name]).toInteger()
30
+ if (project.extensions.findByName("kotlin") == null) {
31
+ apply plugin: "kotlin-android"
24
32
  }
25
33
 
26
- def supportsNamespace() {
27
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
28
- def major = parsed[0].toInteger()
29
- def minor = parsed[1].toInteger()
30
-
31
- // Namespace support was added in 7.3.0
32
- return (major == 7 && minor >= 3) || major >= 8
33
- }
34
+ apply plugin: "com.facebook.react"
34
35
 
35
36
  android {
36
- if (supportsNamespace()) {
37
- namespace "io.getstream.rn.noisecancellation"
38
-
39
- sourceSets {
40
- main {
41
- manifest.srcFile "src/main/AndroidManifestNew.xml"
42
- }
43
- }
44
- }
37
+ namespace "io.getstream.rn.noisecancellation"
45
38
 
46
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
39
+ compileSdkVersion getExtOrDefault("compileSdkVersion")
47
40
 
48
- defaultConfig {
49
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
50
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
51
- }
41
+ defaultConfig {
42
+ minSdkVersion getExtOrDefault("minSdkVersion")
43
+ }
52
44
 
53
- buildTypes {
54
- release {
55
- minifyEnabled false
56
- }
57
- }
58
-
59
- lintOptions {
60
- disable "GradleCompatible"
61
- }
45
+ compileOptions {
46
+ sourceCompatibility JavaVersion.VERSION_17
47
+ targetCompatibility JavaVersion.VERSION_17
48
+ }
49
+ }
62
50
 
63
- compileOptions {
64
- sourceCompatibility JavaVersion.VERSION_1_8
65
- targetCompatibility JavaVersion.VERSION_1_8
66
- }
51
+ kotlin {
52
+ compilerOptions {
53
+ jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
54
+ }
67
55
  }
68
56
 
57
+ // Intentionally retained for testing future snapshot releases of the native library.
69
58
  rootProject.allprojects {
70
- repositories {
71
- maven {
72
- name = 'Central Portal Snapshots'
73
- url = 'https://central.sonatype.com/repository/maven-snapshots/'
74
- content {
75
- // This efficiently tells Gradle to only look for this specific dependency in this repository
76
- includeModule('io.getstream', 'stream-video-android-noise-cancellation-libwebrtc')
77
- }
78
- }
59
+ repositories {
60
+ maven {
61
+ name = 'Central Portal Snapshots'
62
+ url = 'https://central.sonatype.com/repository/maven-snapshots/'
63
+ content {
64
+ includeModule('io.getstream', 'stream-video-android-noise-cancellation-libwebrtc')
65
+ }
79
66
  }
67
+ }
80
68
  }
81
69
 
82
- repositories {
83
- mavenCentral()
84
- google()
85
- }
86
-
87
- def kotlin_version = getExtOrDefault("kotlinVersion")
88
-
89
- println "Building Noise Cancellation React Native module with Kotlin version: $kotlin_version"
90
- println "Using compileSdkVersion: ${getExtOrIntegerDefault("compileSdkVersion")}"
91
- println "Using minSdkVersion: ${getExtOrIntegerDefault("minSdkVersion")}"
92
- println "Using targetSdkVersion: ${getExtOrIntegerDefault("targetSdkVersion")}"
93
-
94
-
95
70
  dependencies {
96
- implementation "com.facebook.react:react-native:+"
97
- implementation 'io.getstream:stream-video-android-noise-cancellation-libwebrtc:3.0.0'
98
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
99
- implementation project(':stream-io_react-native-webrtc')
71
+ implementation "com.facebook.react:react-android"
72
+ implementation 'io.getstream:stream-video-android-noise-cancellation-libwebrtc:3.0.0'
73
+ implementation project(':stream-io_react-native-webrtc')
100
74
  }
101
-
@@ -1,3 +1,2 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="io.getstream.rn.noisecancellation">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
2
  </manifest>
@@ -2,54 +2,27 @@ package io.getstream.rn.noisecancellation
2
2
 
3
3
  import android.content.pm.PackageManager
4
4
  import com.facebook.react.bridge.ReactApplicationContext
5
- import com.facebook.react.bridge.ReactContextBaseJavaModule
6
- import com.facebook.react.bridge.ReactMethod
7
- import com.facebook.react.bridge.Promise
8
- import android.util.Log
9
5
 
10
6
  class NoiseCancellationReactNativeModule(reactContext: ReactApplicationContext) :
11
- ReactContextBaseJavaModule(reactContext) {
7
+ NativeNoiseCancellationReactNativeSpec(reactContext) {
12
8
 
13
- override fun getName(): String {
14
- return NAME
15
- }
9
+ override fun isEnabled(): Boolean =
10
+ NoiseCancellationReactNative.controller?.noiseCancellation?.isEnabled() ?: false
16
11
 
17
- @ReactMethod
18
- fun isEnabled(promise: Promise) {
19
- val controller = guardControllerInit(promise)
20
- controller?.let {
21
- promise.resolve(it.noiseCancellation.isEnabled())
22
- }
12
+ override fun setEnabled(enabled: Boolean): Boolean {
13
+ requireController().noiseCancellation.setEnabled(enabled)
14
+ return true
23
15
  }
24
16
 
25
- @ReactMethod
26
- fun setEnabled(enabled: Boolean, promise: Promise) {
27
- val controller = guardControllerInit(promise)
28
- controller?.let {
29
- it.noiseCancellation.setEnabled(enabled)
30
- promise.resolve(true)
31
- }
32
- }
17
+ override fun deviceSupportsAdvancedAudioProcessing(): Boolean =
18
+ reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO)
33
19
 
34
- @ReactMethod
35
- fun deviceSupportsAdvancedAudioProcessing(promise: Promise) {
36
- val hasSupport = reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO)
37
- promise.resolve(hasSupport)
38
- }
39
-
40
- private fun guardControllerInit(promise: Promise): NoiseCancellationAudioProcessingController? {
41
- val controller = NoiseCancellationReactNative.controller
42
- if (controller == null) {
43
- Log.e(NAME, "Noise cancellation is not initialized")
44
- promise.reject(
45
- "NOT_INITIALIZED",
46
- "Noise cancellation is not initialized. Call registerProcessor first."
47
- )
20
+ private fun requireController(): NoiseCancellationAudioProcessingController =
21
+ checkNotNull(NoiseCancellationReactNative.controller) {
22
+ "NOT_INITIALIZED: Noise cancellation is not initialized. Call registerProcessor first."
48
23
  }
49
- return controller
50
- }
51
24
 
52
25
  companion object {
53
- const val NAME = "NoiseCancellationReactNative"
26
+ const val NAME = NativeNoiseCancellationReactNativeSpec.NAME
54
27
  }
55
28
  }
@@ -1,17 +1,29 @@
1
1
  package io.getstream.rn.noisecancellation
2
2
 
3
- import com.facebook.react.ReactPackage
3
+ import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ViewManager
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
7
8
 
9
+ class NoiseCancellationReactNativePackage : BaseReactPackage() {
10
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? =
11
+ if (name == NoiseCancellationReactNativeModule.NAME) {
12
+ NoiseCancellationReactNativeModule(reactContext)
13
+ } else {
14
+ null
15
+ }
8
16
 
9
- class NoiseCancellationReactNativePackage : ReactPackage {
10
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
- return listOf(NoiseCancellationReactNativeModule(reactContext))
12
- }
13
-
14
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
- return emptyList()
17
+ override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
18
+ mapOf(
19
+ NoiseCancellationReactNativeModule.NAME to ReactModuleInfo(
20
+ name = NoiseCancellationReactNativeModule.NAME,
21
+ className = NoiseCancellationReactNativeModule.NAME,
22
+ canOverrideExistingModule = false,
23
+ needsEagerInit = false,
24
+ isCxxModule = false,
25
+ isTurboModule = true
26
+ )
27
+ )
16
28
  }
17
29
  }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('NoiseCancellationReactNative');
9
+ //# sourceMappingURL=NativeNoiseCancellationReactNative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeNoiseCancellationReactNative.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAQtDC,gCAAmB,CAACC,YAAY,CAC7C,8BACF,CAAC","ignoreList":[]}
@@ -4,17 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setEnabled = exports.isEnabled = exports.deviceSupportsAdvancedAudioProcessing = exports.NoiseCancellation = void 0;
7
- var _reactNative = require("react-native");
8
- const LINKING_ERROR = `The package '@stream-io/noise-cancellation-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
9
- ios: "- You have run 'pod install'\n",
10
- default: ''
11
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
12
- const NoiseCancellationReactNative = _reactNative.NativeModules.NoiseCancellationReactNative ? _reactNative.NativeModules.NoiseCancellationReactNative : new Proxy({}, {
13
- get() {
14
- throw new Error(LINKING_ERROR);
15
- }
16
- });
17
-
7
+ var _NativeNoiseCancellationReactNative = _interopRequireDefault(require("./NativeNoiseCancellationReactNative"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
9
  /**
19
10
  * A wrapper around the native stream noise cancellation SDK.
20
11
  */
@@ -31,14 +22,14 @@ class NoiseCancellation {
31
22
  * Checks if the noise cancellation can be automatically enabled for the current device.
32
23
  * In react native, it will be auto enabled only if the device supports advanced audio processing.
33
24
  */
34
- canAutoEnable = deviceSupportsAdvancedAudioProcessing;
25
+ canAutoEnable = async () => deviceSupportsAdvancedAudioProcessing();
35
26
  init = () => Promise.resolve();
36
27
 
37
28
  /**
38
29
  * Enables the noise cancellation.
39
30
  */
40
31
  enable = async () => {
41
- await NoiseCancellationReactNative.setEnabled(true);
32
+ await _NativeNoiseCancellationReactNative.default.setEnabled(true);
42
33
  this.dispatch('change', true);
43
34
  };
44
35
 
@@ -46,7 +37,7 @@ class NoiseCancellation {
46
37
  * Disables the noise cancellation.
47
38
  */
48
39
  disable = async () => {
49
- await NoiseCancellationReactNative.setEnabled(false);
40
+ await _NativeNoiseCancellationReactNative.default.setEnabled(false);
50
41
  this.dispatch('change', false);
51
42
  };
52
43
 
@@ -114,30 +105,31 @@ class NoiseCancellation {
114
105
 
115
106
  /**
116
107
  * Checks if noise cancellation is currently enabled.
117
- * @returns A promise that resolves with a boolean indicating if noise cancellation is enabled.
108
+ * @returns Whether noise cancellation is enabled.
118
109
  */
119
110
  exports.NoiseCancellation = NoiseCancellation;
120
111
  const isEnabled = () => {
121
- return NoiseCancellationReactNative.isEnabled();
112
+ return _NativeNoiseCancellationReactNative.default.isEnabled();
122
113
  };
123
114
 
124
115
  /**
125
116
  * Enables or disables noise cancellation.
126
117
  * @param enabled - Whether to enable or disable noise cancellation.
127
- * @returns A promise that resolves when the operation is complete.
118
+ * @returns `true` when the enabled state has been updated.
119
+ * @throws If the native processor has not been registered.
128
120
  */
129
121
  exports.isEnabled = isEnabled;
130
122
  const setEnabled = enabled => {
131
- return NoiseCancellationReactNative.setEnabled(enabled);
123
+ return _NativeNoiseCancellationReactNative.default.setEnabled(enabled);
132
124
  };
133
125
 
134
126
  /**
135
127
  * Checks if the device supports advanced audio processing required for noise cancellation.
136
- * @returns A promise that resolves with a boolean indicating if the device supports advanced audio processing.
128
+ * @returns Whether the device supports advanced audio processing.
137
129
  */
138
130
  exports.setEnabled = setEnabled;
139
131
  const deviceSupportsAdvancedAudioProcessing = () => {
140
- return NoiseCancellationReactNative.deviceSupportsAdvancedAudioProcessing();
132
+ return _NativeNoiseCancellationReactNative.default.deviceSupportsAdvancedAudioProcessing();
141
133
  };
142
134
  exports.deviceSupportsAdvancedAudioProcessing = deviceSupportsAdvancedAudioProcessing;
143
135
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","NoiseCancellationReactNative","NativeModules","Proxy","get","Error","NoiseCancellation","listeners","isSupported","canAutoEnable","deviceSupportsAdvancedAudioProcessing","init","Promise","resolve","enable","setEnabled","dispatch","disable","dispose","setSuppressionLevel","resume","isEnabled","toFilter","mediaStream","output","on","event","callback","push","off","filter","cb","payload","listener","exports","enabled"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,aAAa,GACjB,qGAAqG,GACrGC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,4BAA4B,GAAGC,0BAAa,CAACD,4BAA4B,GAC3EC,0BAAa,CAACD,4BAA4B,GAC1C,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACO,MAAMU,iBAAiB,CAA+B;EAC1CC,SAAS,GAA8C,CAAC,CAAC;;EAE1E;AACF;AACA;AACA;EACEC,WAAW,GAAGA,CAAA,KAAM,IAAI;;EAExB;AACF;AACA;AACA;EACEC,aAAa,GAAGC,qCAAqC;EAErDC,IAAI,GAAGA,CAAA,KAAMC,OAAO,CAACC,OAAO,CAAC,CAAC;;EAE9B;AACF;AACA;EACEC,MAAM,GAAG,MAAAA,CAAA,KAAY;IACnB,MAAMb,4BAA4B,CAACc,UAAU,CAAC,IAAI,CAAC;IACnD,IAAI,CAACC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;EAC/B,CAAC;;EAED;AACF;AACA;EACEC,OAAO,GAAG,MAAAA,CAAA,KAAY;IACpB,MAAMhB,4BAA4B,CAACc,UAAU,CAAC,KAAK,CAAC;IACpD,IAAI,CAACC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;EAChC,CAAC;;EAED;AACF;AACA;EACEE,OAAO,GAAG,MAAAA,CAAA,KAAYN,OAAO,CAACC,OAAO,CAAC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S,GAAGA,CAAA,KAAwB;EAC/C,OAAOpB,4BAA4B,CAACoB,SAAS,CAAC,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAa,OAAA,CAAAb,SAAA,GAAAA,SAAA;AAKO,MAAMN,UAAU,GAAIoB,OAAgB,IAAuB;EAChE,OAAOlC,4BAA4B,CAACc,UAAU,CAACoB,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AAHAD,OAAA,CAAAnB,UAAA,GAAAA,UAAA;AAIO,MAAML,qCAAqC,GAAGA,CAAA,KAAwB;EAC3E,OAAOT,4BAA4B,CAACS,qCAAqC,CAAC,CAAC;AAC7E,CAAC;AAACwB,OAAA,CAAAxB,qCAAA,GAAAA,qCAAA","ignoreList":[]}
1
+ {"version":3,"names":["_NativeNoiseCancellationReactNative","_interopRequireDefault","require","e","__esModule","default","NoiseCancellation","listeners","isSupported","canAutoEnable","deviceSupportsAdvancedAudioProcessing","init","Promise","resolve","enable","NoiseCancellationReactNative","setEnabled","dispatch","disable","dispose","setSuppressionLevel","resume","isEnabled","toFilter","mediaStream","output","on","event","callback","push","off","filter","cb","payload","listener","exports","enabled"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,mCAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgF,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhF;AACA;AACA;AACO,MAAMG,iBAAiB,CAA+B;EAC1CC,SAAS,GAA8C,CAAC,CAAC;;EAE1E;AACF;AACA;AACA;EACEC,WAAW,GAAGA,CAAA,KAAM,IAAI;;EAExB;AACF;AACA;AACA;EACEC,aAAa,GAAG,MAAAA,CAAA,KAAYC,qCAAqC,CAAC,CAAC;EAEnEC,IAAI,GAAGA,CAAA,KAAMC,OAAO,CAACC,OAAO,CAAC,CAAC;;EAE9B;AACF;AACA;EACEC,MA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AAEC,EAAE,IAAKA,EAAE,KAAKJ,QAAQ,CAAC;EACnE,CAAC;;EAED;AACF;AACA;AACA;AACA;AACA;EACUX,QAAQ,GAAGA,CACjBU,KAAQ,EACRM,OAAU,KACP;IACH,MAAM1B,SAAS,GAAG,IAAI,CAACA,SAAS,CAACoB,KAAK,CAAC,IAAI,EAAE;IAC7C,KAAK,MAAMO,QAAQ,IAAI3B,SAAS,EAAE;MAChC2B,QAAQ,CAACD,OAAO,CAAC;IACnB;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AAHAE,OAAA,CAAA7B,iBAAA,GAAAA,iBAAA;AAIO,MAAMgB,SAAS,GAAGA,CAAA,KAAe;EACtC,OAAOP,2CAA4B,CAACO,SAAS,CAAC,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAa,OAAA,CAAAb,SAAA,GAAAA,SAAA;AAMO,MAAMN,UAAU,GAAIoB,OAAgB,IAAc;EACvD,OAAOrB,2CAA4B,CAACC,UAAU,CAACoB,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AAHAD,OAAA,CAAAnB,UAAA,GAAAA,UAAA;AAIO,MAAMN,qCAAqC,GAAGA,CAAA,KAAe;EAClE,OAAOK,2CAA4B,CAACL,qCAAqC,CAAC,CAAC;AAC7E,CAAC;AAACyB,OAAA,CAAAzB,qCAAA,GAAAA,qCAAA","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ export default TurboModuleRegistry.getEnforcing('NoiseCancellationReactNative');
5
+ //# sourceMappingURL=NativeNoiseCancellationReactNative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeNoiseCancellationReactNative.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AAQpE,eAAeA,mBAAmB,CAACC,YAAY,CAC7C,8BACF,CAAC","ignoreList":[]}
@@ -1,16 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { NativeModules, Platform } from 'react-native';
4
- const LINKING_ERROR = `The package '@stream-io/noise-cancellation-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
- ios: "- You have run 'pod install'\n",
6
- default: ''
7
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
8
- const NoiseCancellationReactNative = NativeModules.NoiseCancellationReactNative ? NativeModules.NoiseCancellationReactNative : new Proxy({}, {
9
- get() {
10
- throw new Error(LINKING_ERROR);
11
- }
12
- });
13
-
3
+ import NoiseCancellationReactNative from './NativeNoiseCancellationReactNative';
14
4
  /**
15
5
  * A wrapper around the native stream noise cancellation SDK.
16
6
  */
@@ -27,7 +17,7 @@ export class NoiseCancellation {
27
17
  * Checks if the noise cancellation can be automatically enabled for the current device.
28
18
  * In react native, it will be auto enabled only if the device supports advanced audio processing.
29
19
  */
30
- canAutoEnable = deviceSupportsAdvancedAudioProcessing;
20
+ canAutoEnable = async () => deviceSupportsAdvancedAudioProcessing();
31
21
  init = () => Promise.resolve();
32
22
 
33
23
  /**
@@ -110,7 +100,7 @@ export class NoiseCancellation {
110
100
 
111
101
  /**
112
102
  * Checks if noise cancellation is currently enabled.
113
- * @returns A promise that resolves with a boolean indicating if noise cancellation is enabled.
103
+ * @returns Whether noise cancellation is enabled.
114
104
  */
115
105
  export const isEnabled = () => {
116
106
  return NoiseCancellationReactNative.isEnabled();
@@ -119,7 +109,8 @@ export const isEnabled = () => {
119
109
  /**
120
110
  * Enables or disables noise cancellation.
121
111
  * @param enabled - Whether to enable or disable noise cancellation.
122
- * @returns A promise that resolves when the operation is complete.
112
+ * @returns `true` when the enabled state has been updated.
113
+ * @throws If the native processor has not been registered.
123
114
  */
124
115
  export const setEnabled = enabled => {
125
116
  return NoiseCancellationReactNative.setEnabled(enabled);
@@ -127,7 +118,7 @@ export const setEnabled = enabled => {
127
118
 
128
119
  /**
129
120
  * Checks if the device supports advanced audio processing required for noise cancellation.
130
- * @returns A promise that resolves with a boolean indicating if the device supports advanced audio processing.
121
+ * @returns Whether the device supports advanced audio processing.
131
122
  */
132
123
  export const deviceSupportsAdvancedAudioProcessing = () => {
133
124
  return NoiseCancellationReactNative.deviceSupportsAdvancedAudioProcessing();
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","NoiseCancellationReactNative","Proxy","get","Error","NoiseCancellation","listeners","isSupported","canAutoEnable","deviceSupportsAdvancedAudioProcessing","init","Promise","resolve","enable","setEnabled","dispatch","disable","dispose","setSuppressionLevel","resume","isEnabled","toFilter","mediaStream","output","on","event","callback","push","off","filter","cb","payload","listener","enabled"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAGtD,MAAMC,aAAa,GACjB,qGAAqG,GACrGD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,4BAA4B,GAAGN,aAAa,CAACM,4BAA4B,GAC3EN,aAAa,CAACM,4BAA4B,GAC1C,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA,OAAO,MAAMQ,iBAAiB,CAA+B;EAC1CC,SAAS,GAA8C,CAAC,CAAC;;EAE1E;AACF;AACA;AACA;EACEC,WAAW,GAAGA,CAAA,KAAM,IAAI;;EAExB;AACF;AACA;AACA;EACEC,aAAa,GAAGC,qCAAqC;EAErDC,IAAI,GAAGA,CAAA,KAAMC,OAAO,CAACC,OAAO,CAAC,CAAC;;EAE9B;AACF;AACA;EACEC,MAAM,GAAG,MAAAA,CAAA,KAAY;IACnB,MAAMZ,4BAA4B,CAACa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AC;;EAED;AACF;AACA;AACA;AACA;AACA;EACUX,QAAQ,GAAGA,CACjBU,KAAQ,EACRM,OAAU,KACP;IACH,MAAMzB,SAAS,GAAG,IAAI,CAACA,SAAS,CAACmB,KAAK,CAAC,IAAI,EAAE;IAC7C,KAAK,MAAMO,QAAQ,IAAI1B,SAAS,EAAE;MAChC0B,QAAQ,CAACD,OAAO,CAAC;IACnB;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMX,SAAS,GAAGA,CAAA,KAAwB;EAC/C,OAAOnB,4BAA4B,CAACmB,SAAS,CAAC,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMN,UAAU,GAAImB,OAAgB,IAAuB;EAChE,OAAOhC,4BAA4B,CAACa,UAAU,CAACmB,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMxB,qCAAqC,GAAGA,CAAA,KAAwB;EAC3E,OAAOR,4BAA4B,CAACQ,qCAAqC,CAAC,CAAC;AAC7E,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NoiseCancellationReactNative","NoiseCancellation","listeners","isSupported","canAutoEnable","deviceSupportsAdvancedAudioProcessing","init","Promise","resolve","enable","setEnabled","dispatch","disable","dispose","setSuppressionLevel","resume","isEnabled","toFilter","mediaStream","output","on","event","callback","push","off","filter","cb","payload","listener","enabled"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAOA,4BAA4B,MAAM,sCAAsC;AAG/E;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,CAA+B;EAC1CC,SAAS,GAA8C,CAAC,CAAC;;EAE1E;AACF;AACA;AACA;EACEC,WAAW,GAAGA,CAAA,KAAM,IAAI;;EAExB;AACF;AACA;AACA;EACEC,aAAa,GAAG,MAAAA,CAAA,KAAYC,qCAAqC,CAAC,CAAC;EAEnEC,IAAI,GAAGA,CAAA,KAAMC,OAAO,CAACC,OAAO,CAAC,CAAC;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AAGnB,SAAS,CAACuB,MAAM,CAAEC,EAAE,IAAKA,EAAE,KAAKJ,QAAQ,CAAC;EACnE,CAAC;;EAED;AACF;AACA;AACA;AACA;AACA;EACUX,QAAQ,GAAGA,CACjBU,KAAQ,EACRM,OAAU,KACP;IACH,MAAMzB,SAAS,GAAG,IAAI,CAACA,SAAS,CAACmB,KAAK,CAAC,IAAI,EAAE;IAC7C,KAAK,MAAMO,QAAQ,IAAI1B,SAAS,EAAE;MAChC0B,QAAQ,CAACD,OAAO,CAAC;IACnB;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMX,SAAS,GAAGA,CAAA,KAAe;EACtC,OAAOhB,4BAA4B,CAACgB,SAAS,CAAC,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMN,UAAU,GAAImB,OAAgB,IAAc;EACvD,OAAO7B,4BAA4B,CAACU,UAAU,CAACmB,OAAO,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMxB,qCAAqC,GAAGA,CAAA,KAAe;EAClE,OAAOL,4BAA4B,CAACK,qCAAqC,CAAC,CAAC;AAC7E,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { type TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ isEnabled(): boolean;
4
+ setEnabled(enabled: boolean): boolean;
5
+ deviceSupportsAdvancedAudioProcessing(): boolean;
6
+ }
7
+ declare const _default: Spec;
8
+ export default _default;
9
+ //# sourceMappingURL=NativeNoiseCancellationReactNative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeNoiseCancellationReactNative.d.ts","sourceRoot":"","sources":["../../src/NativeNoiseCancellationReactNative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,SAAS,IAAI,OAAO,CAAC;IACrB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IACtC,qCAAqC,IAAI,OAAO,CAAC;CAClD;;AAED,wBAEE"}
@@ -61,18 +61,19 @@ export declare class NoiseCancellation implements INoiseCancellation {
61
61
  }
62
62
  /**
63
63
  * Checks if noise cancellation is currently enabled.
64
- * @returns A promise that resolves with a boolean indicating if noise cancellation is enabled.
64
+ * @returns Whether noise cancellation is enabled.
65
65
  */
66
- export declare const isEnabled: () => Promise<boolean>;
66
+ export declare const isEnabled: () => boolean;
67
67
  /**
68
68
  * Enables or disables noise cancellation.
69
69
  * @param enabled - Whether to enable or disable noise cancellation.
70
- * @returns A promise that resolves when the operation is complete.
70
+ * @returns `true` when the enabled state has been updated.
71
+ * @throws If the native processor has not been registered.
71
72
  */
72
- export declare const setEnabled: (enabled: boolean) => Promise<boolean>;
73
+ export declare const setEnabled: (enabled: boolean) => boolean;
73
74
  /**
74
75
  * Checks if the device supports advanced audio processing required for noise cancellation.
75
- * @returns A promise that resolves with a boolean indicating if the device supports advanced audio processing.
76
+ * @returns Whether the device supports advanced audio processing.
76
77
  */
77
- export declare const deviceSupportsAdvancedAudioProcessing: () => Promise<boolean>;
78
+ export declare const deviceSupportsAdvancedAudioProcessing: () => boolean;
78
79
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAmB1D;;GAEG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiD;IAE3E;;;OAGG;IACH,WAAW,gBAAc;IAEzB;;;OAGG;IACH,aAAa,QAyG0C,OAAO,CAAC,OAAO,CAAC,CAzGjB;IAEtD,IAAI,sBAA2B;IAE/B;;OAEG;IACH,MAAM,sBAGJ;IAEF;;OAEG;IACH,OAAO,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,QAAQ,SAAU,aAAa,WAAW;;MAExC;IAEF;;;;;OAKG;IACH,EAAE,GAAI,CAAC,SAAS,MAAM,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,gBAKhE;IAEF;;;;;OAKG;IACH,GAAG,GAAI,CAAC,SAAS,MAAM,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,UAGjE;IAEF;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAQd;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAO,OAE5B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,KAAG,OAE7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qCAAqC,QAAO,OAExD,CAAC"}
@@ -1,12 +1,6 @@
1
1
  #if canImport(MLCompute)
2
2
  import MLCompute
3
- let neuralEngineExists = {
4
- if #available(iOS 15.0, *) {
5
- return MLCDevice.ane() != nil
6
- } else {
7
- return false
8
- }
9
- }()
3
+ let neuralEngineExists = MLCDevice.ane() != nil
10
4
  #else
11
5
  let neuralEngineExists = false
12
6
  #endif
@@ -0,0 +1,5 @@
1
+ #import <NoiseCancellationReactNativeSpec/NoiseCancellationReactNativeSpec.h>
2
+
3
+ @interface NoiseCancellationReactNative : NSObject <NativeNoiseCancellationReactNativeSpec>
4
+
5
+ @end
@@ -1,23 +1,56 @@
1
- #import <React/RCTBridgeModule.h>
1
+ #import "NoiseCancellationReactNative.h"
2
2
 
3
- @interface RCT_EXTERN_MODULE(NoiseCancellationReactNative, NSObject)
3
+ // The generated Swift header declares a subclass of RTCDefaultAudioProcessingModule, and this
4
+ // translation unit is compiled without modules, so its @import WebRTC is skipped.
5
+ #import <WebRTC/WebRTC.h>
4
6
 
5
- RCT_EXTERN_METHOD(registerProcessor:(RCTPromiseResolveBlock)resolve
6
- withRejecter:(RCTPromiseRejectBlock)reject)
7
+ #if __has_include("stream_io_noise_cancellation_react_native/stream_io_noise_cancellation_react_native-Swift.h")
8
+ #import "stream_io_noise_cancellation_react_native/stream_io_noise_cancellation_react_native-Swift.h"
9
+ #else
10
+ #import "stream_io_noise_cancellation_react_native-Swift.h"
11
+ #endif
7
12
 
8
- RCT_EXTERN_METHOD(isEnabled:(RCTPromiseResolveBlock)resolve
9
- withRejecter:(RCTPromiseRejectBlock)reject)
13
+ @implementation NoiseCancellationReactNative {
14
+ NoiseCancellationReactNativeImpl *_impl;
15
+ }
16
+
17
+ - (instancetype)init
18
+ {
19
+ if (self = [super init]) {
20
+ _impl = [NoiseCancellationReactNativeImpl new];
21
+ }
22
+ return self;
23
+ }
24
+
25
+ - (NSNumber *)isEnabled
26
+ {
27
+ return @([_impl isEnabled]);
28
+ }
10
29
 
11
- RCT_EXTERN_METHOD(setEnabled:(BOOL)enabled
12
- withResolver:(RCTPromiseResolveBlock)resolve
13
- withRejecter:(RCTPromiseRejectBlock)reject)
30
+ - (NSNumber *)setEnabled:(BOOL)enabled
31
+ {
32
+ if (![_impl setEnabled:enabled]) {
33
+ @throw [NSException exceptionWithName:@"NOISE_CANCELLATION_FILTER_NOT_REGISTERED"
34
+ reason:@"Noise cancellation filter not registered. Call registerProcessor first."
35
+ userInfo:nil];
36
+ }
37
+ return @YES;
38
+ }
14
39
 
15
- RCT_EXTERN_METHOD(deviceSupportsAdvancedAudioProcessing:(RCTPromiseResolveBlock)resolve
16
- withRejecter:(RCTPromiseRejectBlock)reject)
40
+ - (NSNumber *)deviceSupportsAdvancedAudioProcessing
41
+ {
42
+ return @([_impl deviceSupportsAdvancedAudioProcessing]);
43
+ }
44
+
45
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
46
+ (const facebook::react::ObjCTurboModule::InitParams &)params
47
+ {
48
+ return std::make_shared<facebook::react::NativeNoiseCancellationReactNativeSpecJSI>(params);
49
+ }
17
50
 
18
- + (BOOL)requiresMainQueueSetup
51
+ + (NSString *)moduleName
19
52
  {
20
- return NO;
53
+ return @"NoiseCancellationReactNative";
21
54
  }
22
55
 
23
56
  @end
@@ -0,0 +1,33 @@
1
+ import Foundation
2
+ import StreamVideoNoiseCancellation
3
+
4
+ @objc(NoiseCancellationReactNativeImpl)
5
+ public final class NoiseCancellationReactNativeImpl: NSObject {
6
+
7
+ @objc
8
+ public func isEnabled() -> Bool {
9
+ NoiseCancellationManager.getInstance().processingModule.activeAudioFilter != nil
10
+ }
11
+
12
+ /// Returns `false` when the noise cancellation filter has not been registered yet.
13
+ @objc
14
+ public func setEnabled(_ enabled: Bool) -> Bool {
15
+ let manager = NoiseCancellationManager.getInstance()
16
+ guard let filter = manager.noiseCancellationFilter else {
17
+ return false
18
+ }
19
+
20
+ if enabled {
21
+ manager.processingModule.setAudioFilter(filter)
22
+ } else if manager.processingModule.activeAudioFilter != nil {
23
+ manager.processingModule.setAudioFilter(nil)
24
+ }
25
+
26
+ return true
27
+ }
28
+
29
+ @objc
30
+ public func deviceSupportsAdvancedAudioProcessing() -> Bool {
31
+ neuralEngineExists
32
+ }
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/noise-cancellation-react-native",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "Noise cancellation for the Stream React Native Video SDK",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/module/index.js",
@@ -29,7 +29,10 @@
29
29
  "typecheck": "tsc --noEmit",
30
30
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
31
31
  "clean": "rimraf android/build && rimraf dist",
32
- "build": "yarn clean && bob build"
32
+ "build": "yarn clean && bob build",
33
+ "test": "jest --coverage && yarn test:types",
34
+ "test-ci": "yarn test",
35
+ "test:types": "tsc -p tsconfig.spec.json"
33
36
  },
34
37
  "keywords": [
35
38
  "react-native",
@@ -48,8 +51,14 @@
48
51
  },
49
52
  "homepage": "https://github.com/GetStream/stream-video-js#readme",
50
53
  "devDependencies": {
51
- "@stream-io/react-native-webrtc": "145.3.1",
54
+ "@babel/core": "^7.29.7",
55
+ "@react-native/babel-preset": "0.86.2",
56
+ "@react-native/jest-preset": "0.86.2",
57
+ "@stream-io/react-native-webrtc": "145.4.1",
52
58
  "@stream-io/typescript-config": "^0.0.0",
59
+ "@types/jest": "^29.5.14",
60
+ "@types/node": "^25.9.5",
61
+ "jest": "^29.7.0",
53
62
  "react": "19.2.3",
54
63
  "react-native": "0.86.2",
55
64
  "react-native-builder-bob": "^0.43.0",
@@ -58,7 +67,20 @@
58
67
  },
59
68
  "peerDependencies": {
60
69
  "@stream-io/react-native-webrtc": "^145.3.1",
61
- "react-native": "*"
70
+ "react-native": ">=0.79.0"
71
+ },
72
+ "codegenConfig": {
73
+ "name": "NoiseCancellationReactNativeSpec",
74
+ "type": "modules",
75
+ "jsSrcsDir": "src",
76
+ "android": {
77
+ "javaPackageName": "io.getstream.rn.noisecancellation"
78
+ },
79
+ "ios": {
80
+ "modulesProvider": {
81
+ "NoiseCancellationReactNative": "NoiseCancellationReactNative"
82
+ }
83
+ }
62
84
  },
63
85
  "react-native-builder-bob": {
64
86
  "source": "src",
@@ -0,0 +1,11 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+
3
+ export interface Spec extends TurboModule {
4
+ isEnabled(): boolean;
5
+ setEnabled(enabled: boolean): boolean;
6
+ deviceSupportsAdvancedAudioProcessing(): boolean;
7
+ }
8
+
9
+ export default TurboModuleRegistry.getEnforcing<Spec>(
10
+ 'NoiseCancellationReactNative',
11
+ );
package/src/index.ts CHANGED
@@ -1,23 +1,6 @@
1
- import { NativeModules, Platform } from 'react-native';
1
+ import NoiseCancellationReactNative from './NativeNoiseCancellationReactNative';
2
2
  import type { Events, INoiseCancellation } from './types';
3
3
 
4
- const LINKING_ERROR =
5
- `The package '@stream-io/noise-cancellation-react-native' doesn't seem to be linked. Make sure: \n\n` +
6
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
- '- You rebuilt the app after installing the package\n' +
8
- '- You are not using Expo Go\n';
9
-
10
- const NoiseCancellationReactNative = NativeModules.NoiseCancellationReactNative
11
- ? NativeModules.NoiseCancellationReactNative
12
- : new Proxy(
13
- {},
14
- {
15
- get() {
16
- throw new Error(LINKING_ERROR);
17
- },
18
- },
19
- );
20
-
21
4
  /**
22
5
  * A wrapper around the native stream noise cancellation SDK.
23
6
  */
@@ -34,7 +17,7 @@ export class NoiseCancellation implements INoiseCancellation {
34
17
  * Checks if the noise cancellation can be automatically enabled for the current device.
35
18
  * In react native, it will be auto enabled only if the device supports advanced audio processing.
36
19
  */
37
- canAutoEnable = deviceSupportsAdvancedAudioProcessing;
20
+ canAutoEnable = async () => deviceSupportsAdvancedAudioProcessing();
38
21
 
39
22
  init = () => Promise.resolve();
40
23
 
@@ -120,25 +103,26 @@ export class NoiseCancellation implements INoiseCancellation {
120
103
 
121
104
  /**
122
105
  * Checks if noise cancellation is currently enabled.
123
- * @returns A promise that resolves with a boolean indicating if noise cancellation is enabled.
106
+ * @returns Whether noise cancellation is enabled.
124
107
  */
125
- export const isEnabled = (): Promise<boolean> => {
108
+ export const isEnabled = (): boolean => {
126
109
  return NoiseCancellationReactNative.isEnabled();
127
110
  };
128
111
 
129
112
  /**
130
113
  * Enables or disables noise cancellation.
131
114
  * @param enabled - Whether to enable or disable noise cancellation.
132
- * @returns A promise that resolves when the operation is complete.
115
+ * @returns `true` when the enabled state has been updated.
116
+ * @throws If the native processor has not been registered.
133
117
  */
134
- export const setEnabled = (enabled: boolean): Promise<boolean> => {
118
+ export const setEnabled = (enabled: boolean): boolean => {
135
119
  return NoiseCancellationReactNative.setEnabled(enabled);
136
120
  };
137
121
 
138
122
  /**
139
123
  * Checks if the device supports advanced audio processing required for noise cancellation.
140
- * @returns A promise that resolves with a boolean indicating if the device supports advanced audio processing.
124
+ * @returns Whether the device supports advanced audio processing.
141
125
  */
142
- export const deviceSupportsAdvancedAudioProcessing = (): Promise<boolean> => {
126
+ export const deviceSupportsAdvancedAudioProcessing = (): boolean => {
143
127
  return NoiseCancellationReactNative.deviceSupportsAdvancedAudioProcessing();
144
128
  };
@@ -10,14 +10,14 @@ Pod::Spec.new do |s|
10
10
  s.license = package["license"]
11
11
  s.authors = package["author"]
12
12
 
13
- s.platforms = { :ios => '13.0' }
13
+ s.platforms = { :ios => min_ios_version_supported }
14
14
  s.source = { :git => "https://github.com/GetStream/stream-video-js.git", :tag => "#{s.version}" }
15
15
 
16
- s.source_files = "ios/**/*.{h,m,mm,swift}"
16
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
+ s.private_header_files = "ios/NoiseCancellationReactNative.h"
17
18
  s.dependency "stream-react-native-webrtc"
18
19
  s.dependency 'StreamVideoNoiseCancellation'
19
20
 
20
- public_header_files = 'ios/Headers/*.h'
21
21
  # Swift/Objective-C compatibility https://blog.cocoapods.org/CocoaPods-1.5.0/
22
22
  s.pod_target_xcconfig = {
23
23
  'DEFINES_MODULE' => 'YES'
@@ -1,5 +0,0 @@
1
- NoiseCancellationReactNative_kotlinVersion=1.9.25
2
- NoiseCancellationReactNative_minSdkVersion=24
3
- NoiseCancellationReactNative_targetSdkVersion=36
4
- NoiseCancellationReactNative_compileSdkVersion=36
5
- NoiseCancellationReactNative_ndkVersion=27.1.12297006
@@ -1,2 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- </manifest>
@@ -1,2 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTViewManager.h>
@@ -1,45 +0,0 @@
1
- import StreamVideoNoiseCancellation
2
-
3
- @objc(NoiseCancellationReactNative)
4
- class NoiseCancellationReactNative: NSObject {
5
-
6
- @objc(registerProcessor:withRejecter:)
7
- func registerProcessor(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
8
- // Delegate the processor registration logic to the singleton using getInstance()
9
- NoiseCancellationManager.getInstance().registerProcessor()
10
- resolve(true)
11
- }
12
-
13
- @objc(isEnabled:withRejecter:)
14
- func isEnabled(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
15
- resolve(NoiseCancellationManager.getInstance().processingModule.activeAudioFilter != nil)
16
- }
17
-
18
- @objc(setEnabled:withResolver:withRejecter:)
19
- func setEnabled(enabled: Bool, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
20
- if NoiseCancellationManager.getInstance().noiseCancellationFilter == nil {
21
- reject(
22
- "NOISE_CANCELLATION_FILTER_NOT_REGISTERED",
23
- "Noise cancellation filter not registered",
24
- nil
25
- )
26
- return
27
- }
28
-
29
- if enabled {
30
- NoiseCancellationManager.getInstance().processingModule.setAudioFilter(NoiseCancellationManager.getInstance().noiseCancellationFilter)
31
- } else {
32
- if NoiseCancellationManager.getInstance().processingModule.activeAudioFilter != nil {
33
- NoiseCancellationManager.getInstance().processingModule.setAudioFilter(nil)
34
- }
35
- }
36
-
37
-
38
- resolve(true)
39
- }
40
-
41
- @objc(deviceSupportsAdvancedAudioProcessing:withRejecter:)
42
- func deviceSupportsAdvancedAudioProcessing(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
43
- resolve(neuralEngineExists)
44
- }
45
- }