react-native-davoice-tts 1.0.52 → 1.0.53

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 +1 @@
1
- 6e1ed622e31a09bb247610bab906063e tts-1.0.0.aar
1
+ 7319a004de8f53e8f3650b376f00e4f3 tts-1.0.0.aar
@@ -1 +1 @@
1
- aa6ef86aedeb6f63ade90eed0956bf5553c085b9 tts-1.0.0.aar
1
+ 6135b0933aedf843a8967a0889e34ff8b2ae2386 tts-1.0.0.aar
@@ -1,15 +1,16 @@
1
+ // android/src/main/java/com/davoice/tts/rn/DaVoiceTTSBridge.java
1
2
  package com.davoice.tts.rn;
2
3
 
3
- import androidx.annotation.Nullable; // ✅ add
4
+ import androidx.annotation.Nullable;
4
5
  import com.facebook.react.bridge.Promise;
5
6
  import com.facebook.react.bridge.ReactApplicationContext;
6
7
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
7
8
  import com.facebook.react.bridge.ReactMethod;
8
9
  import com.facebook.react.bridge.ReadableMap;
9
- import com.facebook.react.bridge.WritableMap; // ✅ add
10
- import com.facebook.react.modules.core.DeviceEventManagerModule; // ✅ add
10
+ import com.facebook.react.bridge.WritableMap;
11
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
11
12
 
12
- import com.davoice.tts.DaVoiceTTSInterface; // keep
13
+ import com.davoice.tts.DaVoiceTTSInterface;
13
14
 
14
15
  public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
15
16
 
@@ -23,9 +24,7 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
23
24
  }
24
25
 
25
26
  @Override
26
- public String getName() {
27
- return "DaVoiceTTSBridge";
28
- }
27
+ public String getName() { return "DaVoiceTTSBridge"; }
29
28
 
30
29
  private void sendEvent(String name, @Nullable WritableMap params) {
31
30
  reactCtx.runOnUiQueueThread(() ->
@@ -44,10 +43,9 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
44
43
  }
45
44
  final String modelName = config.getString("model");
46
45
 
47
- // 1) attach listener (works even if called before init)
46
+ // fire RN event when the last utterance finishes
48
47
  tts.setOnFinishedSpeakingListenerJava(() -> sendEvent("onFinishedSpeaking", null));
49
48
 
50
- // 2) init
51
49
  DaVoiceTTSInterface.Config cfg = new DaVoiceTTSInterface.Config(
52
50
  modelName,
53
51
  "en-US",
@@ -84,7 +82,18 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
84
82
  }
85
83
  }
86
84
 
87
- // RN event API stubs
85
+ @ReactMethod
86
+ public void destroy(Promise promise) {
87
+ try {
88
+ // stop & free native resources; after this, JS should create a fresh instance before use
89
+ tts.destroy();
90
+ promise.resolve(null);
91
+ } catch (Exception e) {
92
+ promise.reject("DestroyError", e.getMessage(), e);
93
+ }
94
+ }
95
+
96
+ // RN event API stubs (required by RN)
88
97
  @ReactMethod public void addListener(String eventName) { /* no-op */ }
89
98
  @ReactMethod public void removeListeners(double count) { /* no-op */ }
90
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-davoice-tts",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "tts library for React Native",
5
5
  "main": "tts/index.js",
6
6
  "types": "tts/index.d.ts",