capacitor-microphone 0.0.5 → 0.0.8

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/README.md CHANGED
@@ -16,6 +16,10 @@ npx cap sync
16
16
  * [`checkPermission()`](#checkpermission)
17
17
  * [`requestPermission()`](#requestpermission)
18
18
  * [`checkRequestPermission()`](#checkrequestpermission)
19
+ * [`startListening(...)`](#startlistening)
20
+ * [`stopListening()`](#stoplistening)
21
+ * [`addListener('partialResult', ...)`](#addlistenerpartialresult-)
22
+ * [`removeAllListeners()`](#removealllisteners)
19
23
  * [Interfaces](#interfaces)
20
24
 
21
25
  </docgen-index>
@@ -56,6 +60,57 @@ checkRequestPermission() => Promise<MicrophonePermissions>
56
60
  --------------------
57
61
 
58
62
 
63
+ ### startListening(...)
64
+
65
+ ```typescript
66
+ startListening(options?: StartListeningOptions | undefined) => Promise<SpeechResult>
67
+ ```
68
+
69
+ | Param | Type |
70
+ | ------------- | ----------------------------------------------------------------------- |
71
+ | **`options`** | <code><a href="#startlisteningoptions">StartListeningOptions</a></code> |
72
+
73
+ **Returns:** <code>Promise&lt;<a href="#speechresult">SpeechResult</a>&gt;</code>
74
+
75
+ --------------------
76
+
77
+
78
+ ### stopListening()
79
+
80
+ ```typescript
81
+ stopListening() => Promise<{ stopped: boolean; }>
82
+ ```
83
+
84
+ **Returns:** <code>Promise&lt;{ stopped: boolean; }&gt;</code>
85
+
86
+ --------------------
87
+
88
+
89
+ ### addListener('partialResult', ...)
90
+
91
+ ```typescript
92
+ addListener(eventName: 'partialResult', listenerFunc: (data: SpeechResult) => void) => Promise<PluginListenerHandle>
93
+ ```
94
+
95
+ | Param | Type |
96
+ | ------------------ | ------------------------------------------------------------------------ |
97
+ | **`eventName`** | <code>'partialResult'</code> |
98
+ | **`listenerFunc`** | <code>(data: <a href="#speechresult">SpeechResult</a>) =&gt; void</code> |
99
+
100
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
101
+
102
+ --------------------
103
+
104
+
105
+ ### removeAllListeners()
106
+
107
+ ```typescript
108
+ removeAllListeners() => Promise<void>
109
+ ```
110
+
111
+ --------------------
112
+
113
+
59
114
  ### Interfaces
60
115
 
61
116
 
@@ -68,4 +123,26 @@ checkRequestPermission() => Promise<MicrophonePermissions>
68
123
  | **`status`** | <code>string</code> |
69
124
  | **`errorMessage`** | <code>string</code> |
70
125
 
126
+
127
+ #### SpeechResult
128
+
129
+ | Prop | Type |
130
+ | ------------- | -------------------- |
131
+ | **`text`** | <code>string</code> |
132
+ | **`isFinal`** | <code>boolean</code> |
133
+
134
+
135
+ #### StartListeningOptions
136
+
137
+ | Prop | Type |
138
+ | ---------- | ------------------- |
139
+ | **`lang`** | <code>string</code> |
140
+
141
+
142
+ #### PluginListenerHandle
143
+
144
+ | Prop | Type |
145
+ | ------------ | ----------------------------------------- |
146
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
147
+
71
148
  </docgen-api>
@@ -1,5 +1,5 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
2
 
3
3
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
4
-
4
+ <uses-permission android:name="android.permission.INTERNET" />
5
5
  </manifest>
@@ -17,6 +17,8 @@ import android.speech.RecognitionListener;
17
17
  import android.speech.RecognizerIntent;
18
18
  import android.speech.SpeechRecognizer;
19
19
 
20
+
21
+
20
22
  import java.util.ArrayList;
21
23
 
22
24
  @CapacitorPlugin(
@@ -32,6 +34,8 @@ public class CapacitorMicrophonePlugin extends Plugin {
32
34
 
33
35
  private SpeechRecognizer speechRecognizer;
34
36
  private PluginCall currentCall;
37
+ private Intent speechIntent;
38
+
35
39
 
36
40
  @PluginMethod
37
41
  public void checkPermission(PluginCall call) {
@@ -104,96 +108,117 @@ private PluginCall currentCall;
104
108
  @PluginMethod
105
109
  public void startListening(PluginCall call) {
106
110
 
107
- if (speechRecognizer != null) {
108
- call.reject("Speech recognition already running");
109
- return;
110
- }
111
-
112
111
  if (getPermissionState("microphone") != PermissionState.GRANTED) {
113
112
  call.reject("Microphone permission not granted");
114
113
  return;
115
114
  }
116
115
 
117
116
  if (!SpeechRecognizer.isRecognitionAvailable(getContext())) {
118
- call.reject("Speech recognition not available on this device");
119
- return;
117
+ call.reject("Speech recognition not available on this device");
118
+ return;
120
119
  }
121
120
 
122
- currentCall = call;
121
+ if (speechRecognizer != null) {
122
+ call.reject("Speech recognition already running");
123
+ return;
124
+ }
123
125
 
124
- speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getContext());
126
+ this.currentCall = call;
125
127
 
126
- Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
127
- intent.putExtra(
128
- RecognizerIntent.EXTRA_LANGUAGE_MODEL,
129
- RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
130
- );
131
- intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "es-MX");
132
- intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
128
+ String lang = call.getString("lang", "es-MX");
129
+
130
+ speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getActivity());
133
131
 
134
132
  speechRecognizer.setRecognitionListener(new RecognitionListener() {
135
133
 
134
+ @Override public void onReadyForSpeech(Bundle params) {}
135
+
136
+ @Override public void onBeginningOfSpeech() {}
137
+
138
+ @Override public void onRmsChanged(float rmsdB) {}
139
+
140
+ @Override public void onBufferReceived(byte[] buffer) {}
141
+
142
+ @Override public void onEndOfSpeech() {}
143
+
136
144
  @Override
137
- public void onResults(Bundle results) {
138
- ArrayList<String> matches =
139
- results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
145
+ public void onError(int error) {
146
+ notifyListeners("partialResult", new JSObject()
147
+ .put("text", "")
148
+ .put("isFinal", true)
149
+ .put("error", mapError(error))
150
+ );
140
151
 
141
- JSObject ret = new JSObject();
142
- ret.put("text", matches != null && !matches.isEmpty() ? matches.get(0) : "");
143
- ret.put("isFinal", true);
144
152
  if (currentCall != null) {
145
- currentCall.resolve(ret);
153
+ currentCall.reject(mapError(error));
146
154
  currentCall = null;
147
155
  }
156
+ stopSpeech();
148
157
  }
149
158
 
150
159
  @Override
151
- public void onPartialResults(Bundle partialResults) {
160
+ public void onResults(Bundle results) {
152
161
  ArrayList<String> matches =
153
- partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
162
+ results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
163
+
164
+ if (matches != null && matches.size() > 0) {
165
+ String text = matches.get(0);
154
166
 
155
- if (matches != null && !matches.isEmpty()) {
156
- JSObject ret = new JSObject();
157
- ret.put("text", matches.get(0));
158
- ret.put("isFinal", false);
167
+ notifyListeners("partialResult", new JSObject()
168
+ .put("text", text)
169
+ .put("isFinal", true));
159
170
 
160
- notifyListeners("partialResult", ret);
171
+ if (currentCall != null) {
172
+ currentCall.resolve(new JSObject()
173
+ .put("text", text)
174
+ .put("isFinal", true));
175
+ currentCall = null;
176
+ }
161
177
  }
178
+ stopSpeech();
162
179
  }
163
180
 
164
- @Override public void onError(int error) {
165
- if (currentCall != null) {
166
- currentCall.reject(mapError(error));
181
+ @Override
182
+ public void onPartialResults(Bundle partialResults) {
183
+ ArrayList<String> matches =
184
+ partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
167
185
 
168
- currentCall = null;
186
+ if (matches != null && matches.size() > 0) {
187
+ notifyListeners("partialResult", new JSObject()
188
+ .put("text", matches.get(0))
189
+ .put("isFinal", false));
169
190
  }
170
191
  }
171
192
 
172
- // Métodos obligatorios (vacíos)
173
- @Override public void onReadyForSpeech(Bundle params) {}
174
- @Override public void onBeginningOfSpeech() {}
175
- @Override public void onRmsChanged(float rmsdB) {}
176
- @Override public void onBufferReceived(byte[] buffer) {}
177
- @Override public void onEndOfSpeech() {}
178
193
  @Override public void onEvent(int eventType, Bundle params) {}
179
194
  });
180
195
 
181
- speechRecognizer.startListening(intent);
196
+ speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
197
+ speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
198
+ RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
199
+ speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, lang);
200
+ speechIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
201
+
202
+ speechRecognizer.startListening(speechIntent);
182
203
  }
183
204
 
205
+
206
+
184
207
  @PluginMethod
185
208
  public void stopListening(PluginCall call) {
209
+ stopSpeech();
210
+ call.resolve(new JSObject().put("stopped", true));
211
+ }
212
+
213
+ private void stopSpeech() {
186
214
  if (speechRecognizer != null) {
187
215
  speechRecognizer.stopListening();
188
216
  speechRecognizer.destroy();
189
217
  speechRecognizer = null;
190
218
  }
191
-
192
- JSObject ret = new JSObject();
193
- ret.put("stopped", true);
194
- call.resolve(ret);
195
219
  }
196
220
 
221
+
197
222
  @Override
198
223
  protected void handleOnDestroy() {
199
224
  if (speechRecognizer != null) {
package/dist/docs.json CHANGED
@@ -40,6 +40,69 @@
40
40
  "MicrophonePermissions"
41
41
  ],
42
42
  "slug": "checkrequestpermission"
43
+ },
44
+ {
45
+ "name": "startListening",
46
+ "signature": "(options?: StartListeningOptions | undefined) => Promise<SpeechResult>",
47
+ "parameters": [
48
+ {
49
+ "name": "options",
50
+ "docs": "",
51
+ "type": "StartListeningOptions | undefined"
52
+ }
53
+ ],
54
+ "returns": "Promise<SpeechResult>",
55
+ "tags": [],
56
+ "docs": "",
57
+ "complexTypes": [
58
+ "SpeechResult",
59
+ "StartListeningOptions"
60
+ ],
61
+ "slug": "startlistening"
62
+ },
63
+ {
64
+ "name": "stopListening",
65
+ "signature": "() => Promise<{ stopped: boolean; }>",
66
+ "parameters": [],
67
+ "returns": "Promise<{ stopped: boolean; }>",
68
+ "tags": [],
69
+ "docs": "",
70
+ "complexTypes": [],
71
+ "slug": "stoplistening"
72
+ },
73
+ {
74
+ "name": "addListener",
75
+ "signature": "(eventName: 'partialResult', listenerFunc: (data: SpeechResult) => void) => Promise<PluginListenerHandle>",
76
+ "parameters": [
77
+ {
78
+ "name": "eventName",
79
+ "docs": "",
80
+ "type": "'partialResult'"
81
+ },
82
+ {
83
+ "name": "listenerFunc",
84
+ "docs": "",
85
+ "type": "(data: SpeechResult) => void"
86
+ }
87
+ ],
88
+ "returns": "Promise<PluginListenerHandle>",
89
+ "tags": [],
90
+ "docs": "",
91
+ "complexTypes": [
92
+ "PluginListenerHandle",
93
+ "SpeechResult"
94
+ ],
95
+ "slug": "addlistenerpartialresult-"
96
+ },
97
+ {
98
+ "name": "removeAllListeners",
99
+ "signature": "() => Promise<void>",
100
+ "parameters": [],
101
+ "returns": "Promise<void>",
102
+ "tags": [],
103
+ "docs": "",
104
+ "complexTypes": [],
105
+ "slug": "removealllisteners"
43
106
  }
44
107
  ],
45
108
  "properties": []
@@ -81,6 +144,61 @@
81
144
  "type": "string"
82
145
  }
83
146
  ]
147
+ },
148
+ {
149
+ "name": "SpeechResult",
150
+ "slug": "speechresult",
151
+ "docs": "",
152
+ "tags": [],
153
+ "methods": [],
154
+ "properties": [
155
+ {
156
+ "name": "text",
157
+ "tags": [],
158
+ "docs": "",
159
+ "complexTypes": [],
160
+ "type": "string"
161
+ },
162
+ {
163
+ "name": "isFinal",
164
+ "tags": [],
165
+ "docs": "",
166
+ "complexTypes": [],
167
+ "type": "boolean"
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ "name": "StartListeningOptions",
173
+ "slug": "startlisteningoptions",
174
+ "docs": "",
175
+ "tags": [],
176
+ "methods": [],
177
+ "properties": [
178
+ {
179
+ "name": "lang",
180
+ "tags": [],
181
+ "docs": "",
182
+ "complexTypes": [],
183
+ "type": "string | undefined"
184
+ }
185
+ ]
186
+ },
187
+ {
188
+ "name": "PluginListenerHandle",
189
+ "slug": "pluginlistenerhandle",
190
+ "docs": "",
191
+ "tags": [],
192
+ "methods": [],
193
+ "properties": [
194
+ {
195
+ "name": "remove",
196
+ "tags": [],
197
+ "docs": "",
198
+ "complexTypes": [],
199
+ "type": "() => Promise<void>"
200
+ }
201
+ ]
84
202
  }
85
203
  ],
86
204
  "enums": [],
@@ -1,7 +1,14 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
1
2
  export interface CapacitorMicrophonePlugin {
2
3
  checkPermission(): Promise<MicrophonePermissions>;
3
4
  requestPermission(): Promise<MicrophonePermissions>;
4
5
  checkRequestPermission(): Promise<MicrophonePermissions>;
6
+ startListening(options?: StartListeningOptions): Promise<SpeechResult>;
7
+ stopListening(): Promise<{
8
+ stopped: boolean;
9
+ }>;
10
+ addListener(eventName: 'partialResult', listenerFunc: (data: SpeechResult) => void): Promise<PluginListenerHandle>;
11
+ removeAllListeners(): Promise<void>;
5
12
  }
6
13
  export interface MicrophonePermissions {
7
14
  details: string;
@@ -9,3 +16,10 @@ export interface MicrophonePermissions {
9
16
  status: string;
10
17
  errorMessage: string;
11
18
  }
19
+ export interface StartListeningOptions {
20
+ lang?: string;
21
+ }
22
+ export interface SpeechResult {
23
+ text: string;
24
+ isFinal: boolean;
25
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorMicrophonePlugin {\n checkPermission(): Promise<MicrophonePermissions>;\n requestPermission(): Promise<MicrophonePermissions>;\n checkRequestPermission(): Promise<MicrophonePermissions>;\n}\n\nexport interface MicrophonePermissions {\n details: string;\n granted: boolean;\n status:string;\n errorMessage: string;\n}"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface CapacitorMicrophonePlugin {\n checkPermission(): Promise<MicrophonePermissions>;\n requestPermission(): Promise<MicrophonePermissions>;\n checkRequestPermission(): Promise<MicrophonePermissions>;\n startListening(options?: StartListeningOptions): Promise<SpeechResult>;\n stopListening(): Promise<{ stopped: boolean }>;\n addListener(eventName: 'partialResult', listenerFunc: (data: SpeechResult) => void\n ): Promise<PluginListenerHandle>;\n removeAllListeners(): Promise<void>;\n}\n\nexport interface MicrophonePermissions {\n details: string;\n granted: boolean;\n status:string;\n errorMessage: string;\n}\n\nexport interface StartListeningOptions {\n lang?: string; //'es-MX', 'en-US'\n}\n\nexport interface SpeechResult {\n text: string;\n isFinal: boolean;\n}\n"]}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
2
  const capacitor_microphone = registerPlugin('CapacitorMicrophone', {
3
- web: () => import('./web').then((m) => new m.capacitor_microphoneWeb()),
3
+ web: () => import('./web').then((m) => new m.CapacitorMicrophoneWeb()),
4
4
  });
5
5
  export * from './definitions';
6
6
  export { capacitor_microphone };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,cAAc,CAA4B,qBAAqB,EAAE;IAC5F,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;CACxE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorMicrophonePlugin } from './definitions';\n\nconst capacitor_microphone = registerPlugin<CapacitorMicrophonePlugin>('CapacitorMicrophone', {\n web: () => import('./web').then((m) => new m.capacitor_microphoneWeb()),\n});\n\nexport * from './definitions';\nexport { capacitor_microphone };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,cAAc,CAA4B,qBAAqB,EAAE;IAC5F,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;CACvE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorMicrophonePlugin } from './definitions';\n\nconst capacitor_microphone = registerPlugin<CapacitorMicrophonePlugin>('CapacitorMicrophone', {\n web: () => import('./web').then((m) => new m.CapacitorMicrophoneWeb()),\n});\n\nexport * from './definitions';\nexport { capacitor_microphone };\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { CapacitorMicrophonePlugin, MicrophonePermissions } from './definitions';
3
- export declare class capacitor_microphoneWeb extends WebPlugin implements CapacitorMicrophonePlugin {
4
- echo(options: {
5
- value: string;
6
- }): Promise<{
7
- value: string;
8
- }>;
2
+ import type { CapacitorMicrophonePlugin, MicrophonePermissions, SpeechResult, StartListeningOptions } from './definitions';
3
+ export declare class CapacitorMicrophoneWeb extends WebPlugin implements CapacitorMicrophonePlugin {
4
+ private recognition;
9
5
  checkPermission(): Promise<MicrophonePermissions>;
10
6
  requestPermission(): Promise<MicrophonePermissions>;
11
7
  checkRequestPermission(): Promise<MicrophonePermissions>;
8
+ startListening(options?: StartListeningOptions): Promise<SpeechResult>;
9
+ stopListening(): Promise<{
10
+ stopped: boolean;
11
+ }>;
12
+ private stopRecognition;
12
13
  }
package/dist/esm/web.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- export class capacitor_microphoneWeb extends WebPlugin {
3
- async echo(options) {
4
- return options;
2
+ export class CapacitorMicrophoneWeb extends WebPlugin {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.recognition = null;
5
6
  }
6
7
  async checkPermission() {
7
8
  var _a;
@@ -60,5 +61,50 @@ export class capacitor_microphoneWeb extends WebPlugin {
60
61
  }
61
62
  return this.requestPermission();
62
63
  }
64
+ async startListening(options) {
65
+ var _a;
66
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
67
+ if (!SpeechRecognition) {
68
+ throw new Error('Speech recognition not supported in this browser');
69
+ }
70
+ if (this.recognition) {
71
+ throw new Error('Speech recognition already running');
72
+ }
73
+ const lang = (_a = options === null || options === void 0 ? void 0 : options.lang) !== null && _a !== void 0 ? _a : 'es-MX';
74
+ this.recognition = new SpeechRecognition();
75
+ this.recognition.lang = lang;
76
+ this.recognition.interimResults = true;
77
+ this.recognition.continuous = false;
78
+ return new Promise((resolve, reject) => {
79
+ this.recognition.onresult = (event) => {
80
+ const result = event.results[event.results.length - 1];
81
+ const text = result[0].transcript;
82
+ const isFinal = result.isFinal;
83
+ this.notifyListeners('partialResult', {
84
+ text,
85
+ isFinal,
86
+ });
87
+ if (isFinal) {
88
+ resolve({ text, isFinal: true });
89
+ this.stopRecognition();
90
+ }
91
+ };
92
+ this.recognition.onerror = (event) => {
93
+ reject(event.error || 'Speech recognition error');
94
+ this.stopRecognition();
95
+ };
96
+ this.recognition.start();
97
+ });
98
+ }
99
+ async stopListening() {
100
+ this.stopRecognition();
101
+ return { stopped: true };
102
+ }
103
+ stopRecognition() {
104
+ if (this.recognition) {
105
+ this.recognition.stop();
106
+ this.recognition = null;
107
+ }
108
+ }
63
109
  }
64
110
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACpD,KA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AA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,mCAAI,mCAAmC;aAClE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,sBAAsB;QAC1B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAEhD,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorMicrophonePlugin, MicrophonePermissions } from './definitions';\n\nexport class capacitor_microphoneWeb extends WebPlugin implements CapacitorMicrophonePlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n return options;\n }\n\n async checkPermission(): Promise<MicrophonePermissions> {\n if (!navigator.permissions) {\n return {\n granted: false,\n status: 'prompt',\n details: 'Permissions API not supported',\n errorMessage: '',\n };\n }\n\n try {\n const result = await navigator.permissions.query({\n name: 'microphone' as PermissionName,\n });\n\n return {\n granted: result.state === 'granted',\n status: result.state,\n details: 'Web checkPermission',\n errorMessage: '',\n };\n } catch (err: any) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web checkPermission error',\n errorMessage: err?.message ?? 'Unknown error',\n };\n }\n }\n\n async requestPermission(): Promise<MicrophonePermissions> {\n try {\n await navigator.mediaDevices.getUserMedia({ audio: true });\n\n return {\n granted: true,\n status: 'granted',\n details: 'Web requestPermission',\n errorMessage: '',\n };\n } catch (err: any) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web requestPermission',\n errorMessage: err?.message ?? 'User denied microphone permission',\n };\n }\n }\n\n async checkRequestPermission(): Promise<MicrophonePermissions> {\n const permission = await this.checkPermission();\n\n if (permission.granted) {\n return permission;\n }\n\n return this.requestPermission();\n }\n}\n\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,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AAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACvD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;gBAClC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;gBAE/B,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE;oBACpC,IAAI;oBACJ,OAAO;iBACR,CAAC,CAAC;gBAEH,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;oBACjC,IAAI,CAAC,eAAe,EAAE,CAAC;gBACzB,CAAC;YACH,CAAC,CAAC;YAEF,IAAI,CAAC,WAAY,CAAC,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;gBACzC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,0BAA0B,CAAC,CAAC;gBAClD,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,CAAC,CAAC;YAEF,IAAI,CAAC,WAAY,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAEO,eAAe;QACrB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorMicrophonePlugin, MicrophonePermissions, SpeechResult, StartListeningOptions } from './definitions';\n\nexport class CapacitorMicrophoneWeb extends WebPlugin implements CapacitorMicrophonePlugin {\n\n private recognition: any = null;\n\n async checkPermission(): Promise<MicrophonePermissions> {\n if (!navigator.permissions) {\n return {\n granted: false,\n status: 'prompt',\n details: 'Permissions API not supported',\n errorMessage: '',\n };\n }\n\n try {\n const result = await navigator.permissions.query({\n name: 'microphone' as any,\n });\n\n return {\n granted: result.state === 'granted',\n status: result.state as 'granted' | 'denied' | 'prompt',\n details: 'Web checkPermission',\n errorMessage: '',\n };\n } catch (err: any) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web checkPermission error',\n errorMessage: err?.message ?? 'Unknown error',\n };\n }\n }\n\n async requestPermission(): Promise<MicrophonePermissions> {\n try {\n await navigator.mediaDevices.getUserMedia({ audio: true });\n\n return {\n granted: true,\n status: 'granted',\n details: 'Web requestPermission',\n errorMessage: '',\n };\n } catch (err: any) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web requestPermission',\n errorMessage: err?.message ?? 'User denied microphone permission',\n };\n }\n }\n\n async checkRequestPermission(): Promise<MicrophonePermissions> {\n const permission = await this.checkPermission();\n\n if (permission.granted) {\n return permission;\n }\n\n return this.requestPermission();\n }\n\n async startListening(options?: StartListeningOptions): Promise<SpeechResult> {\n const SpeechRecognition = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition;\n\n if (!SpeechRecognition) {\n throw new Error('Speech recognition not supported in this browser');\n }\n\n if (this.recognition) {\n throw new Error('Speech recognition already running');\n }\n\n const lang = options?.lang ?? 'es-MX';\n\n this.recognition = new SpeechRecognition();\n this.recognition.lang = lang;\n this.recognition.interimResults = true;\n this.recognition.continuous = false;\n\n return new Promise((resolve, reject) => {\n this.recognition!.onresult = (event: any) => {\n const result = event.results[event.results.length - 1];\n const text = result[0].transcript;\n const isFinal = result.isFinal;\n\n this.notifyListeners('partialResult', {\n text,\n isFinal,\n });\n\n if (isFinal) {\n resolve({ text, isFinal: true });\n this.stopRecognition();\n }\n };\n\n this.recognition!.onerror = (event: any) => {\n reject(event.error || 'Speech recognition error');\n this.stopRecognition();\n };\n\n this.recognition!.start();\n });\n }\n\n async stopListening(): Promise<{ stopped: boolean }> {\n this.stopRecognition();\n return { stopped: true };\n }\n\n private stopRecognition() {\n if (this.recognition) {\n this.recognition.stop();\n this.recognition = null;\n }\n }\n}\n\n"]}
@@ -3,12 +3,13 @@
3
3
  var core = require('@capacitor/core');
4
4
 
5
5
  const capacitor_microphone = core.registerPlugin('CapacitorMicrophone', {
6
- web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.capacitor_microphoneWeb()),
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorMicrophoneWeb()),
7
7
  });
8
8
 
9
- class capacitor_microphoneWeb extends core.WebPlugin {
10
- async echo(options) {
11
- return options;
9
+ class CapacitorMicrophoneWeb extends core.WebPlugin {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.recognition = null;
12
13
  }
13
14
  async checkPermission() {
14
15
  var _a;
@@ -67,11 +68,56 @@ class capacitor_microphoneWeb extends core.WebPlugin {
67
68
  }
68
69
  return this.requestPermission();
69
70
  }
71
+ async startListening(options) {
72
+ var _a;
73
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
74
+ if (!SpeechRecognition) {
75
+ throw new Error('Speech recognition not supported in this browser');
76
+ }
77
+ if (this.recognition) {
78
+ throw new Error('Speech recognition already running');
79
+ }
80
+ const lang = (_a = options === null || options === void 0 ? void 0 : options.lang) !== null && _a !== void 0 ? _a : 'es-MX';
81
+ this.recognition = new SpeechRecognition();
82
+ this.recognition.lang = lang;
83
+ this.recognition.interimResults = true;
84
+ this.recognition.continuous = false;
85
+ return new Promise((resolve, reject) => {
86
+ this.recognition.onresult = (event) => {
87
+ const result = event.results[event.results.length - 1];
88
+ const text = result[0].transcript;
89
+ const isFinal = result.isFinal;
90
+ this.notifyListeners('partialResult', {
91
+ text,
92
+ isFinal,
93
+ });
94
+ if (isFinal) {
95
+ resolve({ text, isFinal: true });
96
+ this.stopRecognition();
97
+ }
98
+ };
99
+ this.recognition.onerror = (event) => {
100
+ reject(event.error || 'Speech recognition error');
101
+ this.stopRecognition();
102
+ };
103
+ this.recognition.start();
104
+ });
105
+ }
106
+ async stopListening() {
107
+ this.stopRecognition();
108
+ return { stopped: true };
109
+ }
110
+ stopRecognition() {
111
+ if (this.recognition) {
112
+ this.recognition.stop();
113
+ this.recognition = null;
114
+ }
115
+ }
70
116
  }
71
117
 
72
118
  var web = /*#__PURE__*/Object.freeze({
73
119
  __proto__: null,
74
- capacitor_microphoneWeb: capacitor_microphoneWeb
120
+ CapacitorMicrophoneWeb: CapacitorMicrophoneWeb
75
121
  });
76
122
 
77
123
  exports.capacitor_microphone = capacitor_microphone;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst capacitor_microphone = registerPlugin('CapacitorMicrophone', {\n web: () => import('./web').then((m) => new m.capacitor_microphoneWeb()),\n});\nexport * from './definitions';\nexport { capacitor_microphone };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class capacitor_microphoneWeb extends WebPlugin {\n async echo(options) {\n return options;\n }\n async checkPermission() {\n var _a;\n if (!navigator.permissions) {\n return {\n granted: false,\n status: 'prompt',\n details: 'Permissions API not supported',\n errorMessage: '',\n };\n }\n try {\n const result = await navigator.permissions.query({\n name: 'microphone',\n });\n return {\n granted: result.state === 'granted',\n status: result.state,\n details: 'Web checkPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web checkPermission error',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n try {\n await navigator.mediaDevices.getUserMedia({ audio: true });\n return {\n granted: true,\n status: 'granted',\n details: 'Web requestPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web requestPermission',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'User denied microphone permission',\n };\n }\n }\n async checkRequestPermission() {\n const permission = await this.checkPermission();\n if (permission.granted) {\n return permission;\n }\n return this.requestPermission();\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,oBAAoB,GAAGA,mBAAc,CAAC,qBAAqB,EAAE;AACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;AAC3E,CAAC;;ACFM,MAAM,uBAAuB,SAASC,cAAS,CAAC;AACvD,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,OAAO;AACtB,IAAI;AACJ,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,EAAE;AACd,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;AACpC,YAAY,OAAO;AACnB,gBAAgB,OAAO,EAAE,KAAK;AAC9B,gBAAgB,MAAM,EAAE,QAAQ;AAChC,gBAAgB,OAAO,EAAE,+BAA+B;AACxD,gBAAgB,YAAY,EAAE,EAAE;AAChC,aAAa;AACb,QAAQ;AACR,QAAQ,IAAI;AACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7D,gBAAgB,IAAI,EAAE,YAAY;AAClC,aAAa,CAAC;AACd,YAAY,OAAO;AACnB,gBAAgB,OAAO,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS;AACnD,gBAAgB,MAAM,EAAE,MAAM,CAAC,KAAK;AACpC,gBAAgB,OAAO,EAAE,qBAAqB;AAC9C,gBAAgB,YAAY,EAAE,EAAE;AAChC,aAAa;AACb,QAAQ;AACR,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,OAAO;AACnB,gBAAgB,OAAO,EAAE,KAAK;AAC9B,gBAAgB,MAAM,EAAE,QAAQ;AAChC,gBAAgB,OAAO,EAAE,2BAA2B;AACpD,gBAAgB,YAAY,EAAE,CAAC,EAAE,GAA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st capacitor_microphone = registerPlugin('CapacitorMicrophone', {\n web: () => import('./web').then((m) => new m.CapacitorMicrophoneWeb()),\n});\nexport * from './definitions';\nexport { capacitor_microphone };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorMicrophoneWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.recognition = null;\n }\n async checkPermission() {\n var _a;\n if (!navigator.permissions) {\n return {\n granted: false,\n status: 'prompt',\n details: 'Permissions API not supported',\n errorMessage: '',\n };\n }\n try {\n const result = await navigator.permissions.query({\n name: 'microphone',\n });\n return {\n granted: result.state === 'granted',\n status: result.state,\n details: 'Web checkPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web checkPermission error',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n try {\n await navigator.mediaDevices.getUserMedia({ audio: true });\n return {\n granted: true,\n status: 'granted',\n details: 'Web requestPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web requestPermission',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'User denied microphone permission',\n };\n }\n }\n async checkRequestPermission() {\n const permission = await this.checkPermission();\n if (permission.granted) {\n return permission;\n }\n return this.requestPermission();\n }\n async startListening(options) {\n var _a;\n const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;\n if (!SpeechRecognition) {\n throw new Error('Speech recognition not supported in this browser');\n }\n if (this.recognition) {\n throw new Error('Speech recognition already running');\n }\n const lang = (_a = options === null || options === void 0 ? void 0 : options.lang) !== null && _a !== void 0 ? _a : 'es-MX';\n this.recognition = new SpeechRecognition();\n this.recognition.lang = lang;\n this.recognition.interimResults = true;\n this.recognition.continuous = false;\n return new Promise((resolve, reject) => {\n this.recognition.onresult = (event) => {\n const result = event.results[event.results.length - 1];\n const text = result[0].transcript;\n const isFinal = result.isFinal;\n this.notifyListeners('partialResult', {\n text,\n isFinal,\n });\n if (isFinal) {\n resolve({ text, isFinal: true });\n this.stopRecognition();\n }\n };\n this.recognition.onerror = (event) => {\n reject(event.error || 'Speech recognition error');\n this.stopRecognition();\n };\n this.recognition.start();\n });\n }\n async stopListening() {\n this.stopRecognition();\n return { stopped: true };\n }\n stopRecognition() {\n if (this.recognition) {\n this.recognition.stop();\n this.recognition = null;\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,oBAAoB,GAAGA,mBAAc,CAAC,qBAAqB,EAAE;AACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;AAC1E,CAAC;;ACFM,MAAM,sBAAsB,SAASC,cAAS,CAAC;AACtD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;AAC3B,QAAQ,IAAI,CAAC,WAAW,GAAG,IAAI;AAC/B,IAAI;AACJ,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,EAAE;AACd,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;AACpC,YAAY,OAAO;AACnB,gBAAgB,OAAO,EAAE,KAAK;AAC9B,gBAAgB,MAAM,EAAE,QAAQ;AAChC,gBAAgB,OAAO,EAAE,+BAA+B;AACxD,gBAAgB,YAAY,EAAE,EAAE;AAChC,aAAa;AACb,QAAQ;AACR,QAAQ,IAAI;AACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7D,gBAAgB,IAAI,EAAE,YAAY;AAClC,aAAa,CAAC;AACd,YAAY,OAAO;AACnB,gBAAgB,OAAO,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS;AACnD,gBAAgB,MAAM,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,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU;AACjD,gBAAgB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;AAC9C,gBAAgB,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE;AACtD,oBAAoB,IAAI;AACxB,oBAAoB,OAAO;AAC3B,iBAAiB,CAAC;AAClB,gBAAgB,IAAI,OAAO,EAAE;AAC7B,oBAAoB,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACpD,oBAAoB,IAAI,CAAC,eAAe,EAAE;AAC1C,gBAAgB;AAChB,YAAY,CAAC;AACb,YAAY,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK;AAClD,gBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,0BAA0B,CAAC;AACjE,gBAAgB,IAAI,CAAC,eAAe,EAAE;AACtC,YAAY,CAAC;AACb,YAAY,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;AACpC,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,IAAI,CAAC,eAAe,EAAE;AAC9B,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChC,IAAI;AACJ,IAAI,eAAe,GAAG;AACtB,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE;AAC9B,YAAY,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;AACnC,YAAY,IAAI,CAAC,WAAW,GAAG,IAAI;AACnC,QAAQ;AACR,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -2,12 +2,13 @@ var capacitorcapacitor_microphone = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
4
  const capacitor_microphone = core.registerPlugin('CapacitorMicrophone', {
5
- web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.capacitor_microphoneWeb()),
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorMicrophoneWeb()),
6
6
  });
7
7
 
8
- class capacitor_microphoneWeb extends core.WebPlugin {
9
- async echo(options) {
10
- return options;
8
+ class CapacitorMicrophoneWeb extends core.WebPlugin {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.recognition = null;
11
12
  }
12
13
  async checkPermission() {
13
14
  var _a;
@@ -66,11 +67,56 @@ var capacitorcapacitor_microphone = (function (exports, core) {
66
67
  }
67
68
  return this.requestPermission();
68
69
  }
70
+ async startListening(options) {
71
+ var _a;
72
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
73
+ if (!SpeechRecognition) {
74
+ throw new Error('Speech recognition not supported in this browser');
75
+ }
76
+ if (this.recognition) {
77
+ throw new Error('Speech recognition already running');
78
+ }
79
+ const lang = (_a = options === null || options === void 0 ? void 0 : options.lang) !== null && _a !== void 0 ? _a : 'es-MX';
80
+ this.recognition = new SpeechRecognition();
81
+ this.recognition.lang = lang;
82
+ this.recognition.interimResults = true;
83
+ this.recognition.continuous = false;
84
+ return new Promise((resolve, reject) => {
85
+ this.recognition.onresult = (event) => {
86
+ const result = event.results[event.results.length - 1];
87
+ const text = result[0].transcript;
88
+ const isFinal = result.isFinal;
89
+ this.notifyListeners('partialResult', {
90
+ text,
91
+ isFinal,
92
+ });
93
+ if (isFinal) {
94
+ resolve({ text, isFinal: true });
95
+ this.stopRecognition();
96
+ }
97
+ };
98
+ this.recognition.onerror = (event) => {
99
+ reject(event.error || 'Speech recognition error');
100
+ this.stopRecognition();
101
+ };
102
+ this.recognition.start();
103
+ });
104
+ }
105
+ async stopListening() {
106
+ this.stopRecognition();
107
+ return { stopped: true };
108
+ }
109
+ stopRecognition() {
110
+ if (this.recognition) {
111
+ this.recognition.stop();
112
+ this.recognition = null;
113
+ }
114
+ }
69
115
  }
70
116
 
71
117
  var web = /*#__PURE__*/Object.freeze({
72
118
  __proto__: null,
73
- capacitor_microphoneWeb: capacitor_microphoneWeb
119
+ CapacitorMicrophoneWeb: CapacitorMicrophoneWeb
74
120
  });
75
121
 
76
122
  exports.capacitor_microphone = capacitor_microphone;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst capacitor_microphone = registerPlugin('CapacitorMicrophone', {\n web: () => import('./web').then((m) => new m.capacitor_microphoneWeb()),\n});\nexport * from './definitions';\nexport { capacitor_microphone };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class capacitor_microphoneWeb extends WebPlugin {\n async echo(options) {\n return options;\n }\n async checkPermission() {\n var _a;\n if (!navigator.permissions) {\n return {\n granted: false,\n status: 'prompt',\n details: 'Permissions API not supported',\n errorMessage: '',\n };\n }\n try {\n const result = await navigator.permissions.query({\n name: 'microphone',\n });\n return {\n granted: result.state === 'granted',\n status: result.state,\n details: 'Web checkPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web checkPermission error',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n try {\n await navigator.mediaDevices.getUserMedia({ audio: true });\n return {\n granted: true,\n status: 'granted',\n details: 'Web requestPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web requestPermission',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'User denied microphone permission',\n };\n }\n }\n async checkRequestPermission() {\n const permission = await this.checkPermission();\n if (permission.granted) {\n return permission;\n }\n return this.requestPermission();\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,oBAAoB,GAAGA,mBAAc,CAAC,qBAAqB,EAAE;IACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,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;IACZ,YAAY,MAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACtE,YAAY,OAAO;IACnB,gBAAgB,OAAO,EAAE,IAAI;IAC7B,gBAAgB,MAAM,EAAE,SAAS;IACjC,gBAAgB,OAAO,EAAE,uBAAuB;IAChD,gBAAgB,YAAY,EAAE,EAAE;IAChC,aAAa;IACb,QAAQ;IACR,QAAQ,OAAO,GAAG,EAAE;IACpB,YAAY,OAAO;IACnB,gBAAgB,OAAO,EAAE,KAAK;IAC9B,gBAAgB,MAAM,EAAE,QAAQ;IAChC,gBAAgB,OAAO,EAAE,uBAAuB;IAChD,gBAAgB,YAAY,EAAE,CAAC,EAAE,GAAG,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,mCAAmC;IAC/J,aAAa;IACb,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,sBAAsB,GAAG;IACnC,QAAQ,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE;IACvD,QAAQ,IAAI,UAAU,CAAC,OAAO,EAAE;IAChC,YAAY,OAAO,UAAU;IAC7B,QAAQ;IACR,QAAQ,OAAO,IAAI,CAAC,iBAAiB,EAAE;IACvC,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst capacitor_microphone = registerPlugin('CapacitorMicrophone', {\n web: () => import('./web').then((m) => new m.CapacitorMicrophoneWeb()),\n});\nexport * from './definitions';\nexport { capacitor_microphone };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorMicrophoneWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.recognition = null;\n }\n async checkPermission() {\n var _a;\n if (!navigator.permissions) {\n return {\n granted: false,\n status: 'prompt',\n details: 'Permissions API not supported',\n errorMessage: '',\n };\n }\n try {\n const result = await navigator.permissions.query({\n name: 'microphone',\n });\n return {\n granted: result.state === 'granted',\n status: result.state,\n details: 'Web checkPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web checkPermission error',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown error',\n };\n }\n }\n async requestPermission() {\n var _a;\n try {\n await navigator.mediaDevices.getUserMedia({ audio: true });\n return {\n granted: true,\n status: 'granted',\n details: 'Web requestPermission',\n errorMessage: '',\n };\n }\n catch (err) {\n return {\n granted: false,\n status: 'denied',\n details: 'Web requestPermission',\n errorMessage: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'User denied microphone permission',\n };\n }\n }\n async checkRequestPermission() {\n const permission = await this.checkPermission();\n if (permission.granted) {\n return permission;\n }\n return this.requestPermission();\n }\n async startListening(options) {\n var _a;\n const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;\n if (!SpeechRecognition) {\n throw new Error('Speech recognition not supported in this browser');\n }\n if (this.recognition) {\n throw new Error('Speech recognition already running');\n }\n const lang = (_a = options === null || options === void 0 ? void 0 : options.lang) !== null && _a !== void 0 ? _a : 'es-MX';\n this.recognition = new SpeechRecognition();\n this.recognition.lang = lang;\n this.recognition.interimResults = true;\n this.recognition.continuous = false;\n return new Promise((resolve, reject) => {\n this.recognition.onresult = (event) => {\n const result = event.results[event.results.length - 1];\n const text = result[0].transcript;\n const isFinal = result.isFinal;\n this.notifyListeners('partialResult', {\n text,\n isFinal,\n });\n if (isFinal) {\n resolve({ text, isFinal: true });\n this.stopRecognition();\n }\n };\n this.recognition.onerror = (event) => {\n reject(event.error || 'Speech recognition error');\n this.stopRecognition();\n };\n this.recognition.start();\n });\n }\n async stopListening() {\n this.stopRecognition();\n return { stopped: true };\n }\n stopRecognition() {\n if (this.recognition) {\n this.recognition.stop();\n this.recognition = null;\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,oBAAoB,GAAGA,mBAAc,CAAC,qBAAqB,EAAE;IACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,sBAAsB,EAAE,CAAC;IAC1E,CAAC;;ICFM,MAAM,sBAAsB,SAASC,cAAS,CAAC;IACtD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3B,QAAQ,IAAI,CAAC,WAAW,GAAG,IAAI;IAC/B,IAAI;IACJ,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,IAAI,EAAE;IACd,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACpC,YAAY,OAAO;IACnB,gBAAgB,OAAO,EAAE,KAAK;IAC9B,gBAAgB,MAAM,EAAE,QAAQ;IAChC,gBAAgB,OAAO,EAAE,+BAA+B;IACxD,gBAAgB,YAAY,EAAE,EAAE;IAChC,aAAa;IACb,QAAQ;IACR,QAAQ,IAAI;IACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;IAC7D,gBAAgB,IAAI,EAAE,YAAY;IAClC,aAAa,CAAC;IACd,YAAY,OAAO;IACnB,gBAAgB,OAAO,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS;IACnD,gBAAgB,MAAM,EAAE,MAAM,CAAC,KAAK;IACpC,gBAAgB,OAAO,EAAE,qBAAqB;IAC9C,gBAAgB,YAAY,EAAE,EAAE;IAChC,aAAa;IACb,QAAQ;IACR,QAAQ,OAAO,GAAG,EAAE;IACpB,YAAY,OAAO;IACnB,gBAAgB,OAAO,EAAE,KAAK;IAC9B,gBAAgB,MAAM,EAAE,QAAQ;IAChC,gBAAgB,OAAO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B,oBAAoB,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACpD,oBAAoB,IAAI,CAAC,eAAe,EAAE;IAC1C,gBAAgB;IAChB,YAAY,CAAC;IACb,YAAY,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK;IAClD,gBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,0BAA0B,CAAC;IACjE,gBAAgB,IAAI,CAAC,eAAe,EAAE;IACtC,YAAY,CAAC;IACb,YAAY,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;IACpC,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,IAAI,CAAC,eAAe,EAAE;IAC9B,QAAQ,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;IAChC,IAAI;IACJ,IAAI,eAAe,GAAG;IACtB,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE;IAC9B,YAAY,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;IACnC,YAAY,IAAI,CAAC,WAAW,GAAG,IAAI;IACnC,QAAQ;IACR,IAAI;IACJ;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-microphone",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "description": "plugin to use the microphone",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",