@capgo/capacitor-audio-recorder 7.0.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,6 +38,7 @@ npx cap sync
38
38
  * [`addListener('recordingPaused', ...)`](#addlistenerrecordingpaused-)
39
39
  * [`addListener('recordingStopped', ...)`](#addlistenerrecordingstopped-)
40
40
  * [`removeAllListeners()`](#removealllisteners)
41
+ * [`getPluginVersion()`](#getpluginversion)
41
42
  * [Interfaces](#interfaces)
42
43
  * [Type Aliases](#type-aliases)
43
44
  * [Enums](#enums)
@@ -238,6 +239,21 @@ Remove all registered listeners.
238
239
  --------------------
239
240
 
240
241
 
242
+ ### getPluginVersion()
243
+
244
+ ```typescript
245
+ getPluginVersion() => Promise<{ version: string; }>
246
+ ```
247
+
248
+ Get the native Capacitor plugin version.
249
+
250
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
251
+
252
+ **Since:** 1.0.0
253
+
254
+ --------------------
255
+
256
+
241
257
  ### Interfaces
242
258
 
243
259
 
@@ -25,6 +25,8 @@ import java.util.Locale;
25
25
  )
26
26
  public class CapacitorAudioRecorderPlugin extends com.getcapacitor.Plugin {
27
27
 
28
+ private final String PLUGIN_VERSION = "7.1.1";
29
+
28
30
  private enum RecordingStatus {
29
31
  INACTIVE,
30
32
  RECORDING,
@@ -282,4 +284,15 @@ public class CapacitorAudioRecorderPlugin extends com.getcapacitor.Plugin {
282
284
  return "prompt";
283
285
  }
284
286
  }
287
+
288
+ @PluginMethod
289
+ public void getPluginVersion(final PluginCall call) {
290
+ try {
291
+ final JSObject ret = new JSObject();
292
+ ret.put("version", this.PLUGIN_VERSION);
293
+ call.resolve(ret);
294
+ } catch (final Exception e) {
295
+ call.reject("Could not get plugin version", e);
296
+ }
297
+ }
285
298
  }
package/dist/docs.json CHANGED
@@ -254,6 +254,25 @@
254
254
  "docs": "Remove all registered listeners.",
255
255
  "complexTypes": [],
256
256
  "slug": "removealllisteners"
257
+ },
258
+ {
259
+ "name": "getPluginVersion",
260
+ "signature": "() => Promise<{ version: string; }>",
261
+ "parameters": [],
262
+ "returns": "Promise<{ version: string; }>",
263
+ "tags": [
264
+ {
265
+ "name": "returns",
266
+ "text": "Promise that resolves with the plugin version"
267
+ },
268
+ {
269
+ "name": "since",
270
+ "text": "1.0.0"
271
+ }
272
+ ],
273
+ "docs": "Get the native Capacitor plugin version.",
274
+ "complexTypes": [],
275
+ "slug": "getpluginversion"
257
276
  }
258
277
  ],
259
278
  "properties": []
@@ -228,4 +228,13 @@ export interface CapacitorAudioRecorderPlugin {
228
228
  * @since 1.0.0
229
229
  */
230
230
  removeAllListeners(): Promise<void>;
231
+ /**
232
+ * Get the native Capacitor plugin version.
233
+ *
234
+ * @returns Promise that resolves with the plugin version
235
+ * @since 1.0.0
236
+ */
237
+ getPluginVersion(): Promise<{
238
+ version: string;
239
+ }>;
231
240
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAqHA;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,oCAAiB,CAAA;AACnB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BASX;AATD,WAAY,0BAA0B;IACpC,6DAA+B,CAAA;IAC/B,gEAAkC,CAAA;IAClC,yEAA2C,CAAA;IAC3C,qEAAuC,CAAA;IACvC,wDAA0B,CAAA;IAC1B,iHAAmF,CAAA;IACnF,+DAAiC,CAAA;IACjC,4GAA8E,CAAA;AAChF,CAAC,EATW,0BAA0B,KAA1B,0BAA0B,QASrC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,0CAAsB,CAAA;IACtB,+CAA2B,CAAA;IAC3B,gDAA4B,CAAA;IAC5B,4CAAwB,CAAA;IACxB,sDAAkC,CAAA;IAClC,4CAAwB,CAAA;AAC1B,CAAC,EARW,gBAAgB,KAAhB,gBAAgB,QAQ3B","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Result returned by {@link CapacitorAudioRecorderPlugin.getRecordingStatus}.\n *\n * @since 1.0.0\n */\nexport interface GetRecordingStatusResult {\n /**\n * The current recording status.\n *\n * @since 1.0.0\n */\n status: RecordingStatus;\n}\n\n/**\n * Options accepted by {@link CapacitorAudioRecorderPlugin.startRecording}.\n *\n * @since 1.0.0\n */\nexport interface StartRecordingOptions {\n /**\n * The audio session category options for recording. Only available on iOS.\n *\n * @since 1.0.0\n */\n audioSessionCategoryOptions?: AudioSessionCategoryOption[];\n\n /**\n * The audio session mode for recording. Only available on iOS.\n *\n * @since 1.0.0\n */\n audioSessionMode?: AudioSessionMode;\n\n /**\n * The audio bit rate in bytes per second.\n * Only available on Android and iOS.\n *\n * @since 1.0.0\n */\n bitRate?: number;\n\n /**\n * The audio sample rate in Hz.\n * Only available on Android and iOS.\n *\n * @since 1.0.0\n */\n sampleRate?: number;\n}\n\n/**\n * Result returned by {@link CapacitorAudioRecorderPlugin.stopRecording}.\n *\n * @since 1.0.0\n */\nexport interface StopRecordingResult {\n /**\n * The recorded audio as a Blob. Only available on Web.\n *\n * @since 1.0.0\n */\n blob?: Blob;\n\n /**\n * The duration of the recording in milliseconds.\n *\n * @since 1.0.0\n */\n duration?: number;\n\n /**\n * The URI pointing to the recorded file. Only available on Android and iOS.\n *\n * @since 1.0.0\n */\n uri?: string;\n}\n\n/**\n * Permission information returned by {@link CapacitorAudioRecorderPlugin.checkPermissions}\n * and {@link CapacitorAudioRecorderPlugin.requestPermissions}.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /**\n * The permission state for audio recording.\n *\n * @since 1.0.0\n */\n recordAudio: PermissionState;\n}\n\n/**\n * Event emitted when an error occurs during recording.\n *\n * @since 1.0.0\n */\nexport interface RecordingErrorEvent {\n /**\n * The error message.\n *\n * @since 1.0.0\n */\n message: string;\n}\n\n/**\n * Event emitted when a recording completes.\n *\n * @since 1.0.0\n */\nexport type RecordingStoppedEvent = StopRecordingResult\n\n/**\n * The recording status.\n *\n * @since 1.0.0\n */\nexport enum RecordingStatus {\n Inactive = 'INACTIVE',\n Recording = 'RECORDING',\n Paused = 'PAUSED',\n}\n\n/**\n * Audio session category options available on iOS.\n *\n * @since 1.0.0\n */\nexport enum AudioSessionCategoryOption {\n AllowAirPlay = 'ALLOW_AIR_PLAY',\n AllowBluetooth = 'ALLOW_BLUETOOTH',\n AllowBluetoothA2DP = 'ALLOW_BLUETOOTH_A2DP',\n DefaultToSpeaker = 'DEFAULT_TO_SPEAKER',\n DuckOthers = 'DUCK_OTHERS',\n InterruptSpokenAudioAndMixWithOthers = 'INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS',\n MixWithOthers = 'MIX_WITH_OTHERS',\n OverrideMutedMicrophoneInterruption = 'OVERRIDE_MUTED_MICROPHONE_INTERRUPTION',\n}\n\n/**\n * Audio session modes available on iOS.\n *\n * @since 1.0.0\n */\nexport enum AudioSessionMode {\n Default = 'DEFAULT',\n GameChat = 'GAME_CHAT',\n Measurement = 'MEASUREMENT',\n SpokenAudio = 'SPOKEN_AUDIO',\n VideoChat = 'VIDEO_CHAT',\n VideoRecording = 'VIDEO_RECORDING',\n VoiceChat = 'VOICE_CHAT',\n}\n\n/**\n * Platform permission states supported by Capacitor.\n *\n * @since 1.0.0\n */\nexport type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';\n\n/**\n * Capacitor plugin contract for recording audio.\n *\n * @since 1.0.0\n */\nexport interface CapacitorAudioRecorderPlugin {\n /**\n * Start recording audio using the device microphone.\n *\n * @param options Recording configuration options.\n * @since 1.0.0\n */\n startRecording(options?: StartRecordingOptions): Promise<void>;\n\n /**\n * Pause the ongoing recording. Only available on Android (API 24+), iOS, and Web.\n *\n * @since 1.0.0\n */\n pauseRecording(): Promise<void>;\n\n /**\n * Resume a previously paused recording.\n *\n * @since 1.0.0\n */\n resumeRecording(): Promise<void>;\n\n /**\n * Stop the current recording and persist the recorded audio.\n *\n * @returns Recording metadata such as duration and URI/blob.\n * @since 1.0.0\n */\n stopRecording(): Promise<StopRecordingResult>;\n\n /**\n * Cancel the current recording and discard any captured audio.\n *\n * @since 1.0.0\n */\n cancelRecording(): Promise<void>;\n\n /**\n * Retrieve the current recording status.\n *\n * @since 1.0.0\n */\n getRecordingStatus(): Promise<GetRecordingStatusResult>;\n\n /**\n * Return the current permission state for accessing the microphone.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request permission to access the microphone.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Listen for recording errors.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'recordingError', listenerFunc: (event: RecordingErrorEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for pause events emitted when a recording is paused.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'recordingPaused', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for recording completion events.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'recordingStopped',\n listenerFunc: (event: RecordingStoppedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all registered listeners.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAqHA;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,0CAAuB,CAAA;IACvB,oCAAiB,CAAA;AACnB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BASX;AATD,WAAY,0BAA0B;IACpC,6DAA+B,CAAA;IAC/B,gEAAkC,CAAA;IAClC,yEAA2C,CAAA;IAC3C,qEAAuC,CAAA;IACvC,wDAA0B,CAAA;IAC1B,iHAAmF,CAAA;IACnF,+DAAiC,CAAA;IACjC,4GAA8E,CAAA;AAChF,CAAC,EATW,0BAA0B,KAA1B,0BAA0B,QASrC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,0CAAsB,CAAA;IACtB,+CAA2B,CAAA;IAC3B,gDAA4B,CAAA;IAC5B,4CAAwB,CAAA;IACxB,sDAAkC,CAAA;IAClC,4CAAwB,CAAA;AAC1B,CAAC,EARW,gBAAgB,KAAhB,gBAAgB,QAQ3B","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Result returned by {@link CapacitorAudioRecorderPlugin.getRecordingStatus}.\n *\n * @since 1.0.0\n */\nexport interface GetRecordingStatusResult {\n /**\n * The current recording status.\n *\n * @since 1.0.0\n */\n status: RecordingStatus;\n}\n\n/**\n * Options accepted by {@link CapacitorAudioRecorderPlugin.startRecording}.\n *\n * @since 1.0.0\n */\nexport interface StartRecordingOptions {\n /**\n * The audio session category options for recording. Only available on iOS.\n *\n * @since 1.0.0\n */\n audioSessionCategoryOptions?: AudioSessionCategoryOption[];\n\n /**\n * The audio session mode for recording. Only available on iOS.\n *\n * @since 1.0.0\n */\n audioSessionMode?: AudioSessionMode;\n\n /**\n * The audio bit rate in bytes per second.\n * Only available on Android and iOS.\n *\n * @since 1.0.0\n */\n bitRate?: number;\n\n /**\n * The audio sample rate in Hz.\n * Only available on Android and iOS.\n *\n * @since 1.0.0\n */\n sampleRate?: number;\n}\n\n/**\n * Result returned by {@link CapacitorAudioRecorderPlugin.stopRecording}.\n *\n * @since 1.0.0\n */\nexport interface StopRecordingResult {\n /**\n * The recorded audio as a Blob. Only available on Web.\n *\n * @since 1.0.0\n */\n blob?: Blob;\n\n /**\n * The duration of the recording in milliseconds.\n *\n * @since 1.0.0\n */\n duration?: number;\n\n /**\n * The URI pointing to the recorded file. Only available on Android and iOS.\n *\n * @since 1.0.0\n */\n uri?: string;\n}\n\n/**\n * Permission information returned by {@link CapacitorAudioRecorderPlugin.checkPermissions}\n * and {@link CapacitorAudioRecorderPlugin.requestPermissions}.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /**\n * The permission state for audio recording.\n *\n * @since 1.0.0\n */\n recordAudio: PermissionState;\n}\n\n/**\n * Event emitted when an error occurs during recording.\n *\n * @since 1.0.0\n */\nexport interface RecordingErrorEvent {\n /**\n * The error message.\n *\n * @since 1.0.0\n */\n message: string;\n}\n\n/**\n * Event emitted when a recording completes.\n *\n * @since 1.0.0\n */\nexport type RecordingStoppedEvent = StopRecordingResult;\n\n/**\n * The recording status.\n *\n * @since 1.0.0\n */\nexport enum RecordingStatus {\n Inactive = 'INACTIVE',\n Recording = 'RECORDING',\n Paused = 'PAUSED',\n}\n\n/**\n * Audio session category options available on iOS.\n *\n * @since 1.0.0\n */\nexport enum AudioSessionCategoryOption {\n AllowAirPlay = 'ALLOW_AIR_PLAY',\n AllowBluetooth = 'ALLOW_BLUETOOTH',\n AllowBluetoothA2DP = 'ALLOW_BLUETOOTH_A2DP',\n DefaultToSpeaker = 'DEFAULT_TO_SPEAKER',\n DuckOthers = 'DUCK_OTHERS',\n InterruptSpokenAudioAndMixWithOthers = 'INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS',\n MixWithOthers = 'MIX_WITH_OTHERS',\n OverrideMutedMicrophoneInterruption = 'OVERRIDE_MUTED_MICROPHONE_INTERRUPTION',\n}\n\n/**\n * Audio session modes available on iOS.\n *\n * @since 1.0.0\n */\nexport enum AudioSessionMode {\n Default = 'DEFAULT',\n GameChat = 'GAME_CHAT',\n Measurement = 'MEASUREMENT',\n SpokenAudio = 'SPOKEN_AUDIO',\n VideoChat = 'VIDEO_CHAT',\n VideoRecording = 'VIDEO_RECORDING',\n VoiceChat = 'VOICE_CHAT',\n}\n\n/**\n * Platform permission states supported by Capacitor.\n *\n * @since 1.0.0\n */\nexport type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';\n\n/**\n * Capacitor plugin contract for recording audio.\n *\n * @since 1.0.0\n */\nexport interface CapacitorAudioRecorderPlugin {\n /**\n * Start recording audio using the device microphone.\n *\n * @param options Recording configuration options.\n * @since 1.0.0\n */\n startRecording(options?: StartRecordingOptions): Promise<void>;\n\n /**\n * Pause the ongoing recording. Only available on Android (API 24+), iOS, and Web.\n *\n * @since 1.0.0\n */\n pauseRecording(): Promise<void>;\n\n /**\n * Resume a previously paused recording.\n *\n * @since 1.0.0\n */\n resumeRecording(): Promise<void>;\n\n /**\n * Stop the current recording and persist the recorded audio.\n *\n * @returns Recording metadata such as duration and URI/blob.\n * @since 1.0.0\n */\n stopRecording(): Promise<StopRecordingResult>;\n\n /**\n * Cancel the current recording and discard any captured audio.\n *\n * @since 1.0.0\n */\n cancelRecording(): Promise<void>;\n\n /**\n * Retrieve the current recording status.\n *\n * @since 1.0.0\n */\n getRecordingStatus(): Promise<GetRecordingStatusResult>;\n\n /**\n * Return the current permission state for accessing the microphone.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request permission to access the microphone.\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Listen for recording errors.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'recordingError',\n listenerFunc: (event: RecordingErrorEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for pause events emitted when a recording is paused.\n *\n * @since 1.0.0\n */\n addListener(eventName: 'recordingPaused', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for recording completion events.\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'recordingStopped',\n listenerFunc: (event: RecordingStoppedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all registered listeners.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @since 1.0.0\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { WebPlugin, type PluginListenerHandle } from '@capacitor/core';
2
- import { CapacitorAudioRecorderPlugin, PermissionStatus, RecordingErrorEvent, RecordingStatus, RecordingStoppedEvent, StartRecordingOptions, StopRecordingResult } from './definitions';
2
+ import type { CapacitorAudioRecorderPlugin, PermissionStatus, RecordingErrorEvent, RecordingStoppedEvent, StartRecordingOptions, StopRecordingResult } from './definitions';
3
+ import { RecordingStatus } from './definitions';
3
4
  export declare class CapacitorAudioRecorderWeb extends WebPlugin implements CapacitorAudioRecorderPlugin {
4
5
  private mediaRecorder;
5
6
  private mediaStream;
@@ -22,6 +23,9 @@ export declare class CapacitorAudioRecorderWeb extends WebPlugin implements Capa
22
23
  requestPermissions(): Promise<PermissionStatus>;
23
24
  addListener<T extends 'recordingError' | 'recordingPaused' | 'recordingStopped'>(eventName: T, listenerFunc: T extends 'recordingError' ? (event: RecordingErrorEvent) => void : T extends 'recordingStopped' ? (event: RecordingStoppedEvent) => void : () => void): Promise<PluginListenerHandle>;
24
25
  removeAllListeners(): Promise<void>;
26
+ getPluginVersion(): Promise<{
27
+ version: string;
28
+ }>;
25
29
  private supportsRecorderPause;
26
30
  private pickMimeType;
27
31
  private buildStopResult;
package/dist/esm/web.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import { RecordingStatus, } from './definitions';
2
+ import { RecordingStatus } from './definitions';
3
3
  export class CapacitorAudioRecorderWeb extends WebPlugin {
4
4
  constructor() {
5
5
  super(...arguments);
@@ -151,9 +151,14 @@ export class CapacitorAudioRecorderWeb extends WebPlugin {
151
151
  async removeAllListeners() {
152
152
  await super.removeAllListeners();
153
153
  }
154
+ async getPluginVersion() {
155
+ return { version: 'web' };
156
+ }
154
157
  // Helpers
155
158
  supportsRecorderPause() {
156
- return !!this.mediaRecorder && typeof this.mediaRecorder.pause === 'function' && typeof this.mediaRecorder.resume === 'function';
159
+ return (!!this.mediaRecorder &&
160
+ typeof this.mediaRecorder.pause === 'function' &&
161
+ typeof this.mediaRecorder.resume === 'function');
157
162
  }
158
163
  pickMimeType() {
159
164
  const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];
@@ -165,7 +170,9 @@ export class CapacitorAudioRecorderWeb extends WebPlugin {
165
170
  return undefined;
166
171
  }
167
172
  buildStopResult() {
168
- const blob = this.recordedChunks.length > 0 ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' }) : undefined;
173
+ const blob = this.recordedChunks.length > 0
174
+ ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' })
175
+ : undefined;
169
176
  let duration;
170
177
  if (this.startTimestamp) {
171
178
  duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAKL,eAAe,GAIhB,MAAM,eAAe,CAAC;AAEvB,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAAxD;;QACU,kBAAa,GAAyB,IAAI,CAAC;QAC3C,gBAAW,GAAuB,IAAI,CAAC;QACvC,mBAAc,GAAe,EAAE,CAAC;QAChC,WAAM,GAAoB,eAAe,CAAC,QAAQ,CAAC;QACnD,mBAAc,GAAkB,IAAI,CAAC;QACrC,oBAAe,GAAkB,IAAI,CAAC;QACtC,6BAAwB,GAAG,CAAC,CAAC;QAC7B,iBAAY,GAAmD,IAAI,CAAC;QACpE,iBAAY,GAAoC,IAAI,CAAC;IAiQ/D,CAAC;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;YACP,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,OAAe;QACjC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC;QACvC,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin, type PluginListenerHandle } from '@capacitor/core';\n\nimport {\n CapacitorAudioRecorderPlugin,\n PermissionState,\n PermissionStatus,\n RecordingErrorEvent,\n RecordingStatus,\n RecordingStoppedEvent,\n StartRecordingOptions,\n StopRecordingResult,\n} from './definitions';\n\nexport class CapacitorAudioRecorderWeb extends WebPlugin implements CapacitorAudioRecorderPlugin {\n private mediaRecorder: MediaRecorder | null = null;\n private mediaStream: MediaStream | null = null;\n private recordedChunks: BlobPart[] = [];\n private status: RecordingStatus = RecordingStatus.Inactive;\n private startTimestamp: number | null = null;\n private pausedTimestamp: number | null = null;\n private accumulatedPauseDuration = 0;\n private stopResolver: ((result: StopRecordingResult) => void) | null = null;\n private stopRejector: ((reason?: any) => void) | null = null;\n\n async startRecording(_options?: StartRecordingOptions): Promise<void> {\n if (this.status === RecordingStatus.Recording || this.status === RecordingStatus.Paused) {\n throw this.unavailable('Recording already in progress.');\n }\n\n await this.ensurePermission(true);\n\n try {\n this.mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });\n } catch (error) {\n this.handleError(`Unable to acquire microphone: ${(error as Error)?.message ?? error}`);\n throw error;\n }\n\n const mimeType = this.pickMimeType();\n try {\n this.mediaRecorder = new MediaRecorder(this.mediaStream, mimeType ? { mimeType } : undefined);\n } catch (error) {\n this.cleanupMediaStream();\n this.handleError(`Unable to initialise MediaRecorder: ${(error as Error)?.message ?? error}`);\n throw error;\n }\n\n this.recordedChunks = [];\n this.startTimestamp = Date.now();\n this.accumulatedPauseDuration = 0;\n this.pausedTimestamp = null;\n\n this.mediaRecorder.addEventListener('dataavailable', (event: BlobEvent) => {\n if (event.data.size > 0) {\n this.recordedChunks.push(event.data);\n }\n });\n\n this.mediaRecorder.addEventListener('stop', () => {\n const result = this.buildStopResult();\n if (this.stopResolver) {\n this.stopResolver(result);\n }\n this.notifyListeners('recordingStopped', result as RecordingStoppedEvent);\n this.resetStopHandlers();\n this.resetState();\n });\n\n this.mediaRecorder.addEventListener('error', (event: Event) => {\n const message = (event as any)?.error?.message ?? 'Recording error.';\n this.handleError(message);\n if (this.stopRejector) {\n this.stopRejector(new Error(message));\n }\n this.resetStopHandlers();\n this.resetState();\n });\n\n this.mediaRecorder.start();\n this.status = RecordingStatus.Recording;\n }\n\n async pauseRecording(): Promise<void> {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Recording) {\n throw this.unavailable('No active recording to pause.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.pause();\n this.status = RecordingStatus.Paused;\n this.pausedTimestamp = Date.now();\n this.notifyListeners('recordingPaused', {});\n } else {\n throw this.unavailable('Pausing recordings is not supported in this browser.');\n }\n }\n\n async resumeRecording(): Promise<void> {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Paused) {\n throw this.unavailable('No paused recording to resume.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.resume();\n if (this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n }\n this.pausedTimestamp = null;\n this.status = RecordingStatus.Recording;\n } else {\n throw this.unavailable('Resuming recordings is not supported in this browser.');\n }\n }\n\n async stopRecording(): Promise<StopRecordingResult> {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n throw this.unavailable('No active recording to stop.');\n }\n\n if (this.status === RecordingStatus.Paused && this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n this.pausedTimestamp = null;\n }\n\n const stopPromise = new Promise<StopRecordingResult>((resolve, reject) => {\n this.stopResolver = resolve;\n this.stopRejector = reject;\n });\n\n try {\n this.mediaRecorder.stop();\n } catch (error) {\n this.resetStopHandlers();\n this.resetState();\n this.handleError(`Unable to stop recorder: ${(error as Error)?.message ?? error}`);\n throw error;\n }\n\n return stopPromise;\n }\n\n async cancelRecording(): Promise<void> {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n this.resetState();\n return;\n }\n\n try {\n this.mediaRecorder.stop();\n } catch {\n // Ignored.\n }\n\n this.resetStopHandlers();\n this.resetState();\n }\n\n async getRecordingStatus(): Promise<{ status: RecordingStatus }> {\n return { status: this.status };\n }\n\n async checkPermissions(): Promise<PermissionStatus> {\n const state = await this.getPermissionState();\n return { recordAudio: state };\n }\n\n async requestPermissions(): Promise<PermissionStatus> {\n const state = await this.ensurePermission(true);\n return { recordAudio: state };\n }\n\n async addListener<T extends 'recordingError' | 'recordingPaused' | 'recordingStopped'>(\n eventName: T,\n listenerFunc: T extends 'recordingError'\n ? (event: RecordingErrorEvent) => void\n : T extends 'recordingStopped'\n ? (event: RecordingStoppedEvent) => void\n : () => void,\n ): Promise<PluginListenerHandle> {\n return super.addListener(eventName, listenerFunc as any);\n }\n\n async removeAllListeners(): Promise<void> {\n await super.removeAllListeners();\n }\n\n // Helpers\n\n private supportsRecorderPause(): boolean {\n return !!this.mediaRecorder && typeof this.mediaRecorder.pause === 'function' && typeof this.mediaRecorder.resume === 'function';\n }\n\n private pickMimeType(): string | undefined {\n const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];\n for (const type of preferred) {\n if ((window as any).MediaRecorder && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(type)) {\n return type;\n }\n }\n return undefined;\n }\n\n private buildStopResult(): StopRecordingResult {\n const blob = this.recordedChunks.length > 0 ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' }) : undefined;\n let duration: number | undefined;\n if (this.startTimestamp) {\n duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;\n }\n return {\n blob,\n duration,\n };\n }\n\n private resetStopHandlers(): void {\n this.stopResolver = null;\n this.stopRejector = null;\n }\n\n private resetState(): void {\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.recordedChunks = [];\n this.cleanupMediaStream();\n if (this.mediaRecorder) {\n const recorder = this.mediaRecorder;\n recorder.ondataavailable = null;\n recorder.onstop = null;\n recorder.onerror = null;\n }\n this.mediaRecorder = null;\n }\n\n private cleanupMediaStream(): void {\n if (this.mediaStream) {\n this.mediaStream.getTracks().forEach((track) => track.stop());\n }\n this.mediaStream = null;\n }\n\n private async ensurePermission(request: boolean): Promise<PermissionState> {\n const currentState = await this.getPermissionState();\n if (currentState === 'granted' || !request) {\n return currentState;\n }\n\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return 'granted';\n } catch (error) {\n return 'denied';\n }\n }\n\n private async getPermissionState(): Promise<PermissionState> {\n if (!navigator.permissions?.query) {\n return 'prompt';\n }\n\n try {\n const result = await navigator.permissions.query({ name: 'microphone' as PermissionName });\n switch (result.state) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n } catch {\n return 'prompt';\n }\n }\n\n private handleError(message: string): void {\n this.status = RecordingStatus.Inactive;\n this.notifyListeners('recordingError', { message });\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AAWvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAAxD;;QACU,kBAAa,GAAyB,IAAI,CAAC;QAC3C,gBAAW,GAAuB,IAAI,CAAC;QACvC,mBAAc,GAAe,EAAE,CAAC;QAChC,WAAM,GAAoB,eAAe,CAAC,QAAQ,CAAC;QACnD,mBAAc,GAAkB,IAAI,CAAC;QACrC,oBAAe,GAAk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8B,EAAE,CAAC,CAAC;YAC3F,QAAQ,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,KAAK,SAAS;oBACZ,OAAO,SAAS,CAAC;gBACnB,KAAK,QAAQ;oBACX,OAAO,QAAQ,CAAC;gBAClB;oBACE,OAAO,QAAQ,CAAC;YACpB,CAAC;QACH,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,OAAe;QACjC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC;QACvC,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin, type PluginListenerHandle } from '@capacitor/core';\n\nimport type {\n CapacitorAudioRecorderPlugin,\n PermissionState,\n PermissionStatus,\n RecordingErrorEvent,\n RecordingStoppedEvent,\n StartRecordingOptions,\n StopRecordingResult,\n} from './definitions';\nimport { RecordingStatus } from './definitions';\n\nexport class CapacitorAudioRecorderWeb extends WebPlugin implements CapacitorAudioRecorderPlugin {\n private mediaRecorder: MediaRecorder | null = null;\n private mediaStream: MediaStream | null = null;\n private recordedChunks: BlobPart[] = [];\n private status: RecordingStatus = RecordingStatus.Inactive;\n private startTimestamp: number | null = null;\n private pausedTimestamp: number | null = null;\n private accumulatedPauseDuration = 0;\n private stopResolver: ((result: StopRecordingResult) => void) | null = null;\n private stopRejector: ((reason?: any) => void) | null = null;\n\n async startRecording(_options?: StartRecordingOptions): Promise<void> {\n if (this.status === RecordingStatus.Recording || this.status === RecordingStatus.Paused) {\n throw this.unavailable('Recording already in progress.');\n }\n\n await this.ensurePermission(true);\n\n try {\n this.mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });\n } catch (error) {\n this.handleError(`Unable to acquire microphone: ${(error as Error)?.message ?? error}`);\n throw error;\n }\n\n const mimeType = this.pickMimeType();\n try {\n this.mediaRecorder = new MediaRecorder(this.mediaStream, mimeType ? { mimeType } : undefined);\n } catch (error) {\n this.cleanupMediaStream();\n this.handleError(`Unable to initialise MediaRecorder: ${(error as Error)?.message ?? error}`);\n throw error;\n }\n\n this.recordedChunks = [];\n this.startTimestamp = Date.now();\n this.accumulatedPauseDuration = 0;\n this.pausedTimestamp = null;\n\n this.mediaRecorder.addEventListener('dataavailable', (event: BlobEvent) => {\n if (event.data.size > 0) {\n this.recordedChunks.push(event.data);\n }\n });\n\n this.mediaRecorder.addEventListener('stop', () => {\n const result = this.buildStopResult();\n if (this.stopResolver) {\n this.stopResolver(result);\n }\n this.notifyListeners('recordingStopped', result as RecordingStoppedEvent);\n this.resetStopHandlers();\n this.resetState();\n });\n\n this.mediaRecorder.addEventListener('error', (event: Event) => {\n const message = (event as any)?.error?.message ?? 'Recording error.';\n this.handleError(message);\n if (this.stopRejector) {\n this.stopRejector(new Error(message));\n }\n this.resetStopHandlers();\n this.resetState();\n });\n\n this.mediaRecorder.start();\n this.status = RecordingStatus.Recording;\n }\n\n async pauseRecording(): Promise<void> {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Recording) {\n throw this.unavailable('No active recording to pause.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.pause();\n this.status = RecordingStatus.Paused;\n this.pausedTimestamp = Date.now();\n this.notifyListeners('recordingPaused', {});\n } else {\n throw this.unavailable('Pausing recordings is not supported in this browser.');\n }\n }\n\n async resumeRecording(): Promise<void> {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Paused) {\n throw this.unavailable('No paused recording to resume.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.resume();\n if (this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n }\n this.pausedTimestamp = null;\n this.status = RecordingStatus.Recording;\n } else {\n throw this.unavailable('Resuming recordings is not supported in this browser.');\n }\n }\n\n async stopRecording(): Promise<StopRecordingResult> {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n throw this.unavailable('No active recording to stop.');\n }\n\n if (this.status === RecordingStatus.Paused && this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n this.pausedTimestamp = null;\n }\n\n const stopPromise = new Promise<StopRecordingResult>((resolve, reject) => {\n this.stopResolver = resolve;\n this.stopRejector = reject;\n });\n\n try {\n this.mediaRecorder.stop();\n } catch (error) {\n this.resetStopHandlers();\n this.resetState();\n this.handleError(`Unable to stop recorder: ${(error as Error)?.message ?? error}`);\n throw error;\n }\n\n return stopPromise;\n }\n\n async cancelRecording(): Promise<void> {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n this.resetState();\n return;\n }\n\n try {\n this.mediaRecorder.stop();\n } catch {\n // Ignored.\n }\n\n this.resetStopHandlers();\n this.resetState();\n }\n\n async getRecordingStatus(): Promise<{ status: RecordingStatus }> {\n return { status: this.status };\n }\n\n async checkPermissions(): Promise<PermissionStatus> {\n const state = await this.getPermissionState();\n return { recordAudio: state };\n }\n\n async requestPermissions(): Promise<PermissionStatus> {\n const state = await this.ensurePermission(true);\n return { recordAudio: state };\n }\n\n async addListener<T extends 'recordingError' | 'recordingPaused' | 'recordingStopped'>(\n eventName: T,\n listenerFunc: T extends 'recordingError'\n ? (event: RecordingErrorEvent) => void\n : T extends 'recordingStopped'\n ? (event: RecordingStoppedEvent) => void\n : () => void,\n ): Promise<PluginListenerHandle> {\n return super.addListener(eventName, listenerFunc as any);\n }\n\n async removeAllListeners(): Promise<void> {\n await super.removeAllListeners();\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n // Helpers\n\n private supportsRecorderPause(): boolean {\n return (\n !!this.mediaRecorder &&\n typeof this.mediaRecorder.pause === 'function' &&\n typeof this.mediaRecorder.resume === 'function'\n );\n }\n\n private pickMimeType(): string | undefined {\n const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];\n for (const type of preferred) {\n if ((window as any).MediaRecorder && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(type)) {\n return type;\n }\n }\n return undefined;\n }\n\n private buildStopResult(): StopRecordingResult {\n const blob =\n this.recordedChunks.length > 0\n ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' })\n : undefined;\n let duration: number | undefined;\n if (this.startTimestamp) {\n duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;\n }\n return {\n blob,\n duration,\n };\n }\n\n private resetStopHandlers(): void {\n this.stopResolver = null;\n this.stopRejector = null;\n }\n\n private resetState(): void {\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.recordedChunks = [];\n this.cleanupMediaStream();\n if (this.mediaRecorder) {\n const recorder = this.mediaRecorder;\n recorder.ondataavailable = null;\n recorder.onstop = null;\n recorder.onerror = null;\n }\n this.mediaRecorder = null;\n }\n\n private cleanupMediaStream(): void {\n if (this.mediaStream) {\n this.mediaStream.getTracks().forEach((track) => track.stop());\n }\n this.mediaStream = null;\n }\n\n private async ensurePermission(request: boolean): Promise<PermissionState> {\n const currentState = await this.getPermissionState();\n if (currentState === 'granted' || !request) {\n return currentState;\n }\n\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return 'granted';\n } catch (error) {\n return 'denied';\n }\n }\n\n private async getPermissionState(): Promise<PermissionState> {\n if (!navigator.permissions?.query) {\n return 'prompt';\n }\n\n try {\n const result = await navigator.permissions.query({ name: 'microphone' as PermissionName });\n switch (result.state) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n } catch {\n return 'prompt';\n }\n }\n\n private handleError(message: string): void {\n this.status = RecordingStatus.Inactive;\n this.notifyListeners('recordingError', { message });\n }\n}\n"]}
@@ -200,9 +200,14 @@ class CapacitorAudioRecorderWeb extends core.WebPlugin {
200
200
  async removeAllListeners() {
201
201
  await super.removeAllListeners();
202
202
  }
203
+ async getPluginVersion() {
204
+ return { version: 'web' };
205
+ }
203
206
  // Helpers
204
207
  supportsRecorderPause() {
205
- return !!this.mediaRecorder && typeof this.mediaRecorder.pause === 'function' && typeof this.mediaRecorder.resume === 'function';
208
+ return (!!this.mediaRecorder &&
209
+ typeof this.mediaRecorder.pause === 'function' &&
210
+ typeof this.mediaRecorder.resume === 'function');
206
211
  }
207
212
  pickMimeType() {
208
213
  const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];
@@ -214,7 +219,9 @@ class CapacitorAudioRecorderWeb extends core.WebPlugin {
214
219
  return undefined;
215
220
  }
216
221
  buildStopResult() {
217
- const blob = this.recordedChunks.length > 0 ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' }) : undefined;
222
+ const blob = this.recordedChunks.length > 0
223
+ ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' })
224
+ : undefined;
218
225
  let duration;
219
226
  if (this.startTimestamp) {
220
227
  duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * The recording status.\n *\n * @since 1.0.0\n */\nexport var RecordingStatus;\n(function (RecordingStatus) {\n RecordingStatus[\"Inactive\"] = \"INACTIVE\";\n RecordingStatus[\"Recording\"] = \"RECORDING\";\n RecordingStatus[\"Paused\"] = \"PAUSED\";\n})(RecordingStatus || (RecordingStatus = {}));\n/**\n * Audio session category options available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionCategoryOption;\n(function (AudioSessionCategoryOption) {\n AudioSessionCategoryOption[\"AllowAirPlay\"] = \"ALLOW_AIR_PLAY\";\n AudioSessionCategoryOption[\"AllowBluetooth\"] = \"ALLOW_BLUETOOTH\";\n AudioSessionCategoryOption[\"AllowBluetoothA2DP\"] = \"ALLOW_BLUETOOTH_A2DP\";\n AudioSessionCategoryOption[\"DefaultToSpeaker\"] = \"DEFAULT_TO_SPEAKER\";\n AudioSessionCategoryOption[\"DuckOthers\"] = \"DUCK_OTHERS\";\n AudioSessionCategoryOption[\"InterruptSpokenAudioAndMixWithOthers\"] = \"INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"MixWithOthers\"] = \"MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"OverrideMutedMicrophoneInterruption\"] = \"OVERRIDE_MUTED_MICROPHONE_INTERRUPTION\";\n})(AudioSessionCategoryOption || (AudioSessionCategoryOption = {}));\n/**\n * Audio session modes available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionMode;\n(function (AudioSessionMode) {\n AudioSessionMode[\"Default\"] = \"DEFAULT\";\n AudioSessionMode[\"GameChat\"] = \"GAME_CHAT\";\n AudioSessionMode[\"Measurement\"] = \"MEASUREMENT\";\n AudioSessionMode[\"SpokenAudio\"] = \"SPOKEN_AUDIO\";\n AudioSessionMode[\"VideoChat\"] = \"VIDEO_CHAT\";\n AudioSessionMode[\"VideoRecording\"] = \"VIDEO_RECORDING\";\n AudioSessionMode[\"VoiceChat\"] = \"VOICE_CHAT\";\n})(AudioSessionMode || (AudioSessionMode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorAudioRecorder = registerPlugin('CapacitorAudioRecorder', {\n web: () => import('./web').then((m) => new m.CapacitorAudioRecorderWeb()),\n});\nexport * from './definitions';\nexport { CapacitorAudioRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { RecordingStatus, } from './definitions';\nexport class CapacitorAudioRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.mediaRecorder = null;\n this.mediaStream = null;\n this.recordedChunks = [];\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.stopResolver = null;\n this.stopRejector = null;\n }\n async startRecording(_options) {\n var _a, _b;\n if (this.status === RecordingStatus.Recording || this.status === RecordingStatus.Paused) {\n throw this.unavailable('Recording already in progress.');\n }\n await this.ensurePermission(true);\n try {\n this.mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });\n }\n catch (error) {\n this.handleError(`Unable to acquire microphone: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n const mimeType = this.pickMimeType();\n try {\n this.mediaRecorder = new MediaRecorder(this.mediaStream, mimeType ? { mimeType } : undefined);\n }\n catch (error) {\n this.cleanupMediaStream();\n this.handleError(`Unable to initialise MediaRecorder: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);\n throw error;\n }\n this.recordedChunks = [];\n this.startTimestamp = Date.now();\n this.accumulatedPauseDuration = 0;\n this.pausedTimestamp = null;\n this.mediaRecorder.addEventListener('dataavailable', (event) => {\n if (event.data.size > 0) {\n this.recordedChunks.push(event.data);\n }\n });\n this.mediaRecorder.addEventListener('stop', () => {\n const result = this.buildStopResult();\n if (this.stopResolver) {\n this.stopResolver(result);\n }\n this.notifyListeners('recordingStopped', result);\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.addEventListener('error', (event) => {\n var _a, _b;\n const message = (_b = (_a = event === null || event === void 0 ? void 0 : event.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Recording error.';\n this.handleError(message);\n if (this.stopRejector) {\n this.stopRejector(new Error(message));\n }\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.start();\n this.status = RecordingStatus.Recording;\n }\n async pauseRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Recording) {\n throw this.unavailable('No active recording to pause.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.pause();\n this.status = RecordingStatus.Paused;\n this.pausedTimestamp = Date.now();\n this.notifyListeners('recordingPaused', {});\n }\n else {\n throw this.unavailable('Pausing recordings is not supported in this browser.');\n }\n }\n async resumeRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Paused) {\n throw this.unavailable('No paused recording to resume.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.resume();\n if (this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n }\n this.pausedTimestamp = null;\n this.status = RecordingStatus.Recording;\n }\n else {\n throw this.unavailable('Resuming recordings is not supported in this browser.');\n }\n }\n async stopRecording() {\n var _a;\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n throw this.unavailable('No active recording to stop.');\n }\n if (this.status === RecordingStatus.Paused && this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n this.pausedTimestamp = null;\n }\n const stopPromise = new Promise((resolve, reject) => {\n this.stopResolver = resolve;\n this.stopRejector = reject;\n });\n try {\n this.mediaRecorder.stop();\n }\n catch (error) {\n this.resetStopHandlers();\n this.resetState();\n this.handleError(`Unable to stop recorder: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n return stopPromise;\n }\n async cancelRecording() {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n this.resetState();\n return;\n }\n try {\n this.mediaRecorder.stop();\n }\n catch (_a) {\n // Ignored.\n }\n this.resetStopHandlers();\n this.resetState();\n }\n async getRecordingStatus() {\n return { status: this.status };\n }\n async checkPermissions() {\n const state = await this.getPermissionState();\n return { recordAudio: state };\n }\n async requestPermissions() {\n const state = await this.ensurePermission(true);\n return { recordAudio: state };\n }\n async addListener(eventName, listenerFunc) {\n return super.addListener(eventName, listenerFunc);\n }\n async removeAllListeners() {\n await super.removeAllListeners();\n }\n // Helpers\n supportsRecorderPause() {\n return !!this.mediaRecorder && typeof this.mediaRecorder.pause === 'function' && typeof this.mediaRecorder.resume === 'function';\n }\n pickMimeType() {\n const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];\n for (const type of preferred) {\n if (window.MediaRecorder && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(type)) {\n return type;\n }\n }\n return undefined;\n }\n buildStopResult() {\n const blob = this.recordedChunks.length > 0 ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' }) : undefined;\n let duration;\n if (this.startTimestamp) {\n duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;\n }\n return {\n blob,\n duration,\n };\n }\n resetStopHandlers() {\n this.stopResolver = null;\n this.stopRejector = null;\n }\n resetState() {\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.recordedChunks = [];\n this.cleanupMediaStream();\n if (this.mediaRecorder) {\n const recorder = this.mediaRecorder;\n recorder.ondataavailable = null;\n recorder.onstop = null;\n recorder.onerror = null;\n }\n this.mediaRecorder = null;\n }\n cleanupMediaStream() {\n if (this.mediaStream) {\n this.mediaStream.getTracks().forEach((track) => track.stop());\n }\n this.mediaStream = null;\n }\n async ensurePermission(request) {\n const currentState = await this.getPermissionState();\n if (currentState === 'granted' || !request) {\n return currentState;\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return 'granted';\n }\n catch (error) {\n return 'denied';\n }\n }\n async getPermissionState() {\n var _a;\n if (!((_a = navigator.permissions) === null || _a === void 0 ? void 0 : _a.query)) {\n return 'prompt';\n }\n try {\n const result = await navigator.permissions.query({ name: 'microphone' });\n switch (result.state) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n catch (_b) {\n return 'prompt';\n }\n }\n handleError(message) {\n this.status = RecordingStatus.Inactive;\n this.notifyListeners('recordingError', { message });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["RecordingStatus","AudioSessionCategoryOption","AudioSessionMode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;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AAE;AACd,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,WAAW,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE;AAC3F,YAAY,OAAO,QAAQ;AAC3B,QAAQ;AACR,QAAQ,IAAI;AACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AACpF,YAAY,QAAQ,MAAM,CAAC,KAAK;AAChC,gBAAgB,KAAK,SAAS;AAC9B,oBAAoB,OAAO,SAAS;AACpC,gBAAgB,KAAK,QAAQ;AAC7B,oBAAoB,OAAO,QAAQ;AACnC,gBAAgB;AAChB,oBAAoB,OAAO,QAAQ;AACnC;AACA,QAAQ;AACR,QAAQ,OAAO,EAAE,EAAE;AACnB,YAAY,OAAO,QAAQ;AAC3B,QAAQ;AACR,IAAI;AACJ,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,MAAM,GAAGA,uBAAe,CAAC,QAAQ;AAC9C,QAAQ,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,CAAC;AAC3D,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * The recording status.\n *\n * @since 1.0.0\n */\nexport var RecordingStatus;\n(function (RecordingStatus) {\n RecordingStatus[\"Inactive\"] = \"INACTIVE\";\n RecordingStatus[\"Recording\"] = \"RECORDING\";\n RecordingStatus[\"Paused\"] = \"PAUSED\";\n})(RecordingStatus || (RecordingStatus = {}));\n/**\n * Audio session category options available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionCategoryOption;\n(function (AudioSessionCategoryOption) {\n AudioSessionCategoryOption[\"AllowAirPlay\"] = \"ALLOW_AIR_PLAY\";\n AudioSessionCategoryOption[\"AllowBluetooth\"] = \"ALLOW_BLUETOOTH\";\n AudioSessionCategoryOption[\"AllowBluetoothA2DP\"] = \"ALLOW_BLUETOOTH_A2DP\";\n AudioSessionCategoryOption[\"DefaultToSpeaker\"] = \"DEFAULT_TO_SPEAKER\";\n AudioSessionCategoryOption[\"DuckOthers\"] = \"DUCK_OTHERS\";\n AudioSessionCategoryOption[\"InterruptSpokenAudioAndMixWithOthers\"] = \"INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"MixWithOthers\"] = \"MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"OverrideMutedMicrophoneInterruption\"] = \"OVERRIDE_MUTED_MICROPHONE_INTERRUPTION\";\n})(AudioSessionCategoryOption || (AudioSessionCategoryOption = {}));\n/**\n * Audio session modes available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionMode;\n(function (AudioSessionMode) {\n AudioSessionMode[\"Default\"] = \"DEFAULT\";\n AudioSessionMode[\"GameChat\"] = \"GAME_CHAT\";\n AudioSessionMode[\"Measurement\"] = \"MEASUREMENT\";\n AudioSessionMode[\"SpokenAudio\"] = \"SPOKEN_AUDIO\";\n AudioSessionMode[\"VideoChat\"] = \"VIDEO_CHAT\";\n AudioSessionMode[\"VideoRecording\"] = \"VIDEO_RECORDING\";\n AudioSessionMode[\"VoiceChat\"] = \"VOICE_CHAT\";\n})(AudioSessionMode || (AudioSessionMode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorAudioRecorder = registerPlugin('CapacitorAudioRecorder', {\n web: () => import('./web').then((m) => new m.CapacitorAudioRecorderWeb()),\n});\nexport * from './definitions';\nexport { CapacitorAudioRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { RecordingStatus } from './definitions';\nexport class CapacitorAudioRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.mediaRecorder = null;\n this.mediaStream = null;\n this.recordedChunks = [];\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.stopResolver = null;\n this.stopRejector = null;\n }\n async startRecording(_options) {\n var _a, _b;\n if (this.status === RecordingStatus.Recording || this.status === RecordingStatus.Paused) {\n throw this.unavailable('Recording already in progress.');\n }\n await this.ensurePermission(true);\n try {\n this.mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });\n }\n catch (error) {\n this.handleError(`Unable to acquire microphone: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n const mimeType = this.pickMimeType();\n try {\n this.mediaRecorder = new MediaRecorder(this.mediaStream, mimeType ? { mimeType } : undefined);\n }\n catch (error) {\n this.cleanupMediaStream();\n this.handleError(`Unable to initialise MediaRecorder: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);\n throw error;\n }\n this.recordedChunks = [];\n this.startTimestamp = Date.now();\n this.accumulatedPauseDuration = 0;\n this.pausedTimestamp = null;\n this.mediaRecorder.addEventListener('dataavailable', (event) => {\n if (event.data.size > 0) {\n this.recordedChunks.push(event.data);\n }\n });\n this.mediaRecorder.addEventListener('stop', () => {\n const result = this.buildStopResult();\n if (this.stopResolver) {\n this.stopResolver(result);\n }\n this.notifyListeners('recordingStopped', result);\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.addEventListener('error', (event) => {\n var _a, _b;\n const message = (_b = (_a = event === null || event === void 0 ? void 0 : event.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Recording error.';\n this.handleError(message);\n if (this.stopRejector) {\n this.stopRejector(new Error(message));\n }\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.start();\n this.status = RecordingStatus.Recording;\n }\n async pauseRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Recording) {\n throw this.unavailable('No active recording to pause.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.pause();\n this.status = RecordingStatus.Paused;\n this.pausedTimestamp = Date.now();\n this.notifyListeners('recordingPaused', {});\n }\n else {\n throw this.unavailable('Pausing recordings is not supported in this browser.');\n }\n }\n async resumeRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Paused) {\n throw this.unavailable('No paused recording to resume.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.resume();\n if (this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n }\n this.pausedTimestamp = null;\n this.status = RecordingStatus.Recording;\n }\n else {\n throw this.unavailable('Resuming recordings is not supported in this browser.');\n }\n }\n async stopRecording() {\n var _a;\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n throw this.unavailable('No active recording to stop.');\n }\n if (this.status === RecordingStatus.Paused && this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n this.pausedTimestamp = null;\n }\n const stopPromise = new Promise((resolve, reject) => {\n this.stopResolver = resolve;\n this.stopRejector = reject;\n });\n try {\n this.mediaRecorder.stop();\n }\n catch (error) {\n this.resetStopHandlers();\n this.resetState();\n this.handleError(`Unable to stop recorder: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n return stopPromise;\n }\n async cancelRecording() {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n this.resetState();\n return;\n }\n try {\n this.mediaRecorder.stop();\n }\n catch (_a) {\n // Ignored.\n }\n this.resetStopHandlers();\n this.resetState();\n }\n async getRecordingStatus() {\n return { status: this.status };\n }\n async checkPermissions() {\n const state = await this.getPermissionState();\n return { recordAudio: state };\n }\n async requestPermissions() {\n const state = await this.ensurePermission(true);\n return { recordAudio: state };\n }\n async addListener(eventName, listenerFunc) {\n return super.addListener(eventName, listenerFunc);\n }\n async removeAllListeners() {\n await super.removeAllListeners();\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n // Helpers\n supportsRecorderPause() {\n return (!!this.mediaRecorder &&\n typeof this.mediaRecorder.pause === 'function' &&\n typeof this.mediaRecorder.resume === 'function');\n }\n pickMimeType() {\n const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];\n for (const type of preferred) {\n if (window.MediaRecorder && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(type)) {\n return type;\n }\n }\n return undefined;\n }\n buildStopResult() {\n const blob = this.recordedChunks.length > 0\n ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' })\n : undefined;\n let duration;\n if (this.startTimestamp) {\n duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;\n }\n return {\n blob,\n duration,\n };\n }\n resetStopHandlers() {\n this.stopResolver = null;\n this.stopRejector = null;\n }\n resetState() {\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.recordedChunks = [];\n this.cleanupMediaStream();\n if (this.mediaRecorder) {\n const recorder = this.mediaRecorder;\n recorder.ondataavailable = null;\n recorder.onstop = null;\n recorder.onerror = null;\n }\n this.mediaRecorder = null;\n }\n cleanupMediaStream() {\n if (this.mediaStream) {\n this.mediaStream.getTracks().forEach((track) => track.stop());\n }\n this.mediaStream = null;\n }\n async ensurePermission(request) {\n const currentState = await this.getPermissionState();\n if (currentState === 'granted' || !request) {\n return currentState;\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return 'granted';\n }\n catch (error) {\n return 'denied';\n }\n }\n async getPermissionState() {\n var _a;\n if (!((_a = navigator.permissions) === null || _a === void 0 ? void 0 : _a.query)) {\n return 'prompt';\n }\n try {\n const result = await navigator.permissions.query({ name: 'microphone' });\n switch (result.state) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n catch (_b) {\n return 'prompt';\n }\n }\n handleError(message) {\n this.status = RecordingStatus.Inactive;\n this.notifyListeners('recordingError', { message });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["RecordingStatus","AudioSessionCategoryOption","AudioSessionMode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,UAAU,CAAC,GAAG,UAAU;AAC5C,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW;AAC9C,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACxC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACWC;AACX,CAAC,UAAU,0BAA0B,EAAE;AACvC,IAAI,0BAA0B,CAAC,cAAc,CAAC,GAAG,gBAAgB;AACjE,IAAI,0BAA0B,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;AACpE,IAAI,0BAA0B,CAAC,oBAAoB,CAAC,GAAG,sBAAsB;AAC7E,IAAI,0BAA0B,CAAC,kBAAkB,CAAC,GAAG,oBAAoB;AACzE,IAAI,0BAA0B,CAAC,YAAY,CAAC,GAAG,aAAa;AAC5D,IAAI,0BAA0B,CAAC,sCAAsC,CAAC,GAAG,4CAA4C;AACrH,IAAI,0BAA0B,CAAC,eAAe,CAAC,GAAG,iBAAiB;AACnE,IAAI,0BAA0B,CAAC,qCAAqC,CAAC,GAAG,wCAAwC;AAChH,CAAC,EAAEA,kCAA0B,KAAKA,kCAA0B,GAAG,EAAE,CAAC,CAAC;AACnE;AACA;AACA;AACA;AACA;AACWC;AACX,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS;AAC3C,IAAI,gBAAgB,CAAC,UAAU,CAAC,GAAG,WAAW;AAC9C,IAAI,gBAAgB,CAAC,aAAa,CAAC,GAAG,aAAa;AACnD,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AAC;AACrF,YAAY,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;AAC/D,YAAY,OAAO,SAAS;AAC5B,QAAQ;AACR,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,OAAO,QAAQ;AAC3B,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,IAAI,EAAE;AACd,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,WAAW,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE;AAC3F,YAAY,OAAO,QAAQ;AAC3B,QAAQ;AACR,QAAQ,IAAI;AACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AACpF,YAAY,QAAQ,MAAM,CAAC,KAAK;AAChC,gBAAgB,KAAK,SAAS;AAC9B,oBAAoB,OAAO,SAAS;AACpC,gBAAgB,KAAK,QAAQ;AAC7B,oBAAoB,OAAO,QAAQ;AACnC,gBAAgB;AAChB,oBAAoB,OAAO,QAAQ;AACnC;AACA,QAAQ;AACR,QAAQ,OAAO,EAAE,EAAE;AACnB,YAAY,OAAO,QAAQ;AAC3B,QAAQ;AACR,IAAI;AACJ,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,MAAM,GAAGA,uBAAe,CAAC,QAAQ;AAC9C,QAAQ,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,CAAC;AAC3D,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -199,9 +199,14 @@ var capacitorCapacitorAudioRecorder = (function (exports, core) {
199
199
  async removeAllListeners() {
200
200
  await super.removeAllListeners();
201
201
  }
202
+ async getPluginVersion() {
203
+ return { version: 'web' };
204
+ }
202
205
  // Helpers
203
206
  supportsRecorderPause() {
204
- return !!this.mediaRecorder && typeof this.mediaRecorder.pause === 'function' && typeof this.mediaRecorder.resume === 'function';
207
+ return (!!this.mediaRecorder &&
208
+ typeof this.mediaRecorder.pause === 'function' &&
209
+ typeof this.mediaRecorder.resume === 'function');
205
210
  }
206
211
  pickMimeType() {
207
212
  const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];
@@ -213,7 +218,9 @@ var capacitorCapacitorAudioRecorder = (function (exports, core) {
213
218
  return undefined;
214
219
  }
215
220
  buildStopResult() {
216
- const blob = this.recordedChunks.length > 0 ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' }) : undefined;
221
+ const blob = this.recordedChunks.length > 0
222
+ ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' })
223
+ : undefined;
217
224
  let duration;
218
225
  if (this.startTimestamp) {
219
226
  duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * The recording status.\n *\n * @since 1.0.0\n */\nexport var RecordingStatus;\n(function (RecordingStatus) {\n RecordingStatus[\"Inactive\"] = \"INACTIVE\";\n RecordingStatus[\"Recording\"] = \"RECORDING\";\n RecordingStatus[\"Paused\"] = \"PAUSED\";\n})(RecordingStatus || (RecordingStatus = {}));\n/**\n * Audio session category options available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionCategoryOption;\n(function (AudioSessionCategoryOption) {\n AudioSessionCategoryOption[\"AllowAirPlay\"] = \"ALLOW_AIR_PLAY\";\n AudioSessionCategoryOption[\"AllowBluetooth\"] = \"ALLOW_BLUETOOTH\";\n AudioSessionCategoryOption[\"AllowBluetoothA2DP\"] = \"ALLOW_BLUETOOTH_A2DP\";\n AudioSessionCategoryOption[\"DefaultToSpeaker\"] = \"DEFAULT_TO_SPEAKER\";\n AudioSessionCategoryOption[\"DuckOthers\"] = \"DUCK_OTHERS\";\n AudioSessionCategoryOption[\"InterruptSpokenAudioAndMixWithOthers\"] = \"INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"MixWithOthers\"] = \"MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"OverrideMutedMicrophoneInterruption\"] = \"OVERRIDE_MUTED_MICROPHONE_INTERRUPTION\";\n})(AudioSessionCategoryOption || (AudioSessionCategoryOption = {}));\n/**\n * Audio session modes available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionMode;\n(function (AudioSessionMode) {\n AudioSessionMode[\"Default\"] = \"DEFAULT\";\n AudioSessionMode[\"GameChat\"] = \"GAME_CHAT\";\n AudioSessionMode[\"Measurement\"] = \"MEASUREMENT\";\n AudioSessionMode[\"SpokenAudio\"] = \"SPOKEN_AUDIO\";\n AudioSessionMode[\"VideoChat\"] = \"VIDEO_CHAT\";\n AudioSessionMode[\"VideoRecording\"] = \"VIDEO_RECORDING\";\n AudioSessionMode[\"VoiceChat\"] = \"VOICE_CHAT\";\n})(AudioSessionMode || (AudioSessionMode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorAudioRecorder = registerPlugin('CapacitorAudioRecorder', {\n web: () => import('./web').then((m) => new m.CapacitorAudioRecorderWeb()),\n});\nexport * from './definitions';\nexport { CapacitorAudioRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { RecordingStatus, } from './definitions';\nexport class CapacitorAudioRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.mediaRecorder = null;\n this.mediaStream = null;\n this.recordedChunks = [];\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.stopResolver = null;\n this.stopRejector = null;\n }\n async startRecording(_options) {\n var _a, _b;\n if (this.status === RecordingStatus.Recording || this.status === RecordingStatus.Paused) {\n throw this.unavailable('Recording already in progress.');\n }\n await this.ensurePermission(true);\n try {\n this.mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });\n }\n catch (error) {\n this.handleError(`Unable to acquire microphone: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n const mimeType = this.pickMimeType();\n try {\n this.mediaRecorder = new MediaRecorder(this.mediaStream, mimeType ? { mimeType } : undefined);\n }\n catch (error) {\n this.cleanupMediaStream();\n this.handleError(`Unable to initialise MediaRecorder: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);\n throw error;\n }\n this.recordedChunks = [];\n this.startTimestamp = Date.now();\n this.accumulatedPauseDuration = 0;\n this.pausedTimestamp = null;\n this.mediaRecorder.addEventListener('dataavailable', (event) => {\n if (event.data.size > 0) {\n this.recordedChunks.push(event.data);\n }\n });\n this.mediaRecorder.addEventListener('stop', () => {\n const result = this.buildStopResult();\n if (this.stopResolver) {\n this.stopResolver(result);\n }\n this.notifyListeners('recordingStopped', result);\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.addEventListener('error', (event) => {\n var _a, _b;\n const message = (_b = (_a = event === null || event === void 0 ? void 0 : event.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Recording error.';\n this.handleError(message);\n if (this.stopRejector) {\n this.stopRejector(new Error(message));\n }\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.start();\n this.status = RecordingStatus.Recording;\n }\n async pauseRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Recording) {\n throw this.unavailable('No active recording to pause.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.pause();\n this.status = RecordingStatus.Paused;\n this.pausedTimestamp = Date.now();\n this.notifyListeners('recordingPaused', {});\n }\n else {\n throw this.unavailable('Pausing recordings is not supported in this browser.');\n }\n }\n async resumeRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Paused) {\n throw this.unavailable('No paused recording to resume.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.resume();\n if (this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n }\n this.pausedTimestamp = null;\n this.status = RecordingStatus.Recording;\n }\n else {\n throw this.unavailable('Resuming recordings is not supported in this browser.');\n }\n }\n async stopRecording() {\n var _a;\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n throw this.unavailable('No active recording to stop.');\n }\n if (this.status === RecordingStatus.Paused && this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n this.pausedTimestamp = null;\n }\n const stopPromise = new Promise((resolve, reject) => {\n this.stopResolver = resolve;\n this.stopRejector = reject;\n });\n try {\n this.mediaRecorder.stop();\n }\n catch (error) {\n this.resetStopHandlers();\n this.resetState();\n this.handleError(`Unable to stop recorder: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n return stopPromise;\n }\n async cancelRecording() {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n this.resetState();\n return;\n }\n try {\n this.mediaRecorder.stop();\n }\n catch (_a) {\n // Ignored.\n }\n this.resetStopHandlers();\n this.resetState();\n }\n async getRecordingStatus() {\n return { status: this.status };\n }\n async checkPermissions() {\n const state = await this.getPermissionState();\n return { recordAudio: state };\n }\n async requestPermissions() {\n const state = await this.ensurePermission(true);\n return { recordAudio: state };\n }\n async addListener(eventName, listenerFunc) {\n return super.addListener(eventName, listenerFunc);\n }\n async removeAllListeners() {\n await super.removeAllListeners();\n }\n // Helpers\n supportsRecorderPause() {\n return !!this.mediaRecorder && typeof this.mediaRecorder.pause === 'function' && typeof this.mediaRecorder.resume === 'function';\n }\n pickMimeType() {\n const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];\n for (const type of preferred) {\n if (window.MediaRecorder && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(type)) {\n return type;\n }\n }\n return undefined;\n }\n buildStopResult() {\n const blob = this.recordedChunks.length > 0 ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' }) : undefined;\n let duration;\n if (this.startTimestamp) {\n duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;\n }\n return {\n blob,\n duration,\n };\n }\n resetStopHandlers() {\n this.stopResolver = null;\n this.stopRejector = null;\n }\n resetState() {\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.recordedChunks = [];\n this.cleanupMediaStream();\n if (this.mediaRecorder) {\n const recorder = this.mediaRecorder;\n recorder.ondataavailable = null;\n recorder.onstop = null;\n recorder.onerror = null;\n }\n this.mediaRecorder = null;\n }\n cleanupMediaStream() {\n if (this.mediaStream) {\n this.mediaStream.getTracks().forEach((track) => track.stop());\n }\n this.mediaStream = null;\n }\n async ensurePermission(request) {\n const currentState = await this.getPermissionState();\n if (currentState === 'granted' || !request) {\n return currentState;\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return 'granted';\n }\n catch (error) {\n return 'denied';\n }\n }\n async getPermissionState() {\n var _a;\n if (!((_a = navigator.permissions) === null || _a === void 0 ? void 0 : _a.query)) {\n return 'prompt';\n }\n try {\n const result = await navigator.permissions.query({ name: 'microphone' });\n switch (result.state) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n catch (_b) {\n return 'prompt';\n }\n }\n handleError(message) {\n this.status = RecordingStatus.Inactive;\n this.notifyListeners('recordingError', { message });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["RecordingStatus","AudioSessionCategoryOption","AudioSessionMode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA;IACX,C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AC,EAAE,GAAG,SAAS,CAAC,WAAW,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE;IAC3F,YAAY,OAAO,QAAQ;IAC3B,QAAQ;IACR,QAAQ,IAAI;IACZ,YAAY,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACpF,YAAY,QAAQ,MAAM,CAAC,KAAK;IAChC,gBAAgB,KAAK,SAAS;IAC9B,oBAAoB,OAAO,SAAS;IACpC,gBAAgB,KAAK,QAAQ;IAC7B,oBAAoB,OAAO,QAAQ;IACnC,gBAAgB;IAChB,oBAAoB,OAAO,QAAQ;IACnC;IACA,QAAQ;IACR,QAAQ,OAAO,EAAE,EAAE;IACnB,YAAY,OAAO,QAAQ;IAC3B,QAAQ;IACR,IAAI;IACJ,IAAI,WAAW,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,CAAC,MAAM,GAAGA,uBAAe,CAAC,QAAQ;IAC9C,QAAQ,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,CAAC;IAC3D,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * The recording status.\n *\n * @since 1.0.0\n */\nexport var RecordingStatus;\n(function (RecordingStatus) {\n RecordingStatus[\"Inactive\"] = \"INACTIVE\";\n RecordingStatus[\"Recording\"] = \"RECORDING\";\n RecordingStatus[\"Paused\"] = \"PAUSED\";\n})(RecordingStatus || (RecordingStatus = {}));\n/**\n * Audio session category options available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionCategoryOption;\n(function (AudioSessionCategoryOption) {\n AudioSessionCategoryOption[\"AllowAirPlay\"] = \"ALLOW_AIR_PLAY\";\n AudioSessionCategoryOption[\"AllowBluetooth\"] = \"ALLOW_BLUETOOTH\";\n AudioSessionCategoryOption[\"AllowBluetoothA2DP\"] = \"ALLOW_BLUETOOTH_A2DP\";\n AudioSessionCategoryOption[\"DefaultToSpeaker\"] = \"DEFAULT_TO_SPEAKER\";\n AudioSessionCategoryOption[\"DuckOthers\"] = \"DUCK_OTHERS\";\n AudioSessionCategoryOption[\"InterruptSpokenAudioAndMixWithOthers\"] = \"INTERRUPT_SPOKEN_AUDIO_AND_MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"MixWithOthers\"] = \"MIX_WITH_OTHERS\";\n AudioSessionCategoryOption[\"OverrideMutedMicrophoneInterruption\"] = \"OVERRIDE_MUTED_MICROPHONE_INTERRUPTION\";\n})(AudioSessionCategoryOption || (AudioSessionCategoryOption = {}));\n/**\n * Audio session modes available on iOS.\n *\n * @since 1.0.0\n */\nexport var AudioSessionMode;\n(function (AudioSessionMode) {\n AudioSessionMode[\"Default\"] = \"DEFAULT\";\n AudioSessionMode[\"GameChat\"] = \"GAME_CHAT\";\n AudioSessionMode[\"Measurement\"] = \"MEASUREMENT\";\n AudioSessionMode[\"SpokenAudio\"] = \"SPOKEN_AUDIO\";\n AudioSessionMode[\"VideoChat\"] = \"VIDEO_CHAT\";\n AudioSessionMode[\"VideoRecording\"] = \"VIDEO_RECORDING\";\n AudioSessionMode[\"VoiceChat\"] = \"VOICE_CHAT\";\n})(AudioSessionMode || (AudioSessionMode = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorAudioRecorder = registerPlugin('CapacitorAudioRecorder', {\n web: () => import('./web').then((m) => new m.CapacitorAudioRecorderWeb()),\n});\nexport * from './definitions';\nexport { CapacitorAudioRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { RecordingStatus } from './definitions';\nexport class CapacitorAudioRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.mediaRecorder = null;\n this.mediaStream = null;\n this.recordedChunks = [];\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.stopResolver = null;\n this.stopRejector = null;\n }\n async startRecording(_options) {\n var _a, _b;\n if (this.status === RecordingStatus.Recording || this.status === RecordingStatus.Paused) {\n throw this.unavailable('Recording already in progress.');\n }\n await this.ensurePermission(true);\n try {\n this.mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });\n }\n catch (error) {\n this.handleError(`Unable to acquire microphone: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n const mimeType = this.pickMimeType();\n try {\n this.mediaRecorder = new MediaRecorder(this.mediaStream, mimeType ? { mimeType } : undefined);\n }\n catch (error) {\n this.cleanupMediaStream();\n this.handleError(`Unable to initialise MediaRecorder: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);\n throw error;\n }\n this.recordedChunks = [];\n this.startTimestamp = Date.now();\n this.accumulatedPauseDuration = 0;\n this.pausedTimestamp = null;\n this.mediaRecorder.addEventListener('dataavailable', (event) => {\n if (event.data.size > 0) {\n this.recordedChunks.push(event.data);\n }\n });\n this.mediaRecorder.addEventListener('stop', () => {\n const result = this.buildStopResult();\n if (this.stopResolver) {\n this.stopResolver(result);\n }\n this.notifyListeners('recordingStopped', result);\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.addEventListener('error', (event) => {\n var _a, _b;\n const message = (_b = (_a = event === null || event === void 0 ? void 0 : event.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Recording error.';\n this.handleError(message);\n if (this.stopRejector) {\n this.stopRejector(new Error(message));\n }\n this.resetStopHandlers();\n this.resetState();\n });\n this.mediaRecorder.start();\n this.status = RecordingStatus.Recording;\n }\n async pauseRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Recording) {\n throw this.unavailable('No active recording to pause.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.pause();\n this.status = RecordingStatus.Paused;\n this.pausedTimestamp = Date.now();\n this.notifyListeners('recordingPaused', {});\n }\n else {\n throw this.unavailable('Pausing recordings is not supported in this browser.');\n }\n }\n async resumeRecording() {\n if (!this.mediaRecorder || this.status !== RecordingStatus.Paused) {\n throw this.unavailable('No paused recording to resume.');\n }\n if (this.supportsRecorderPause()) {\n this.mediaRecorder.resume();\n if (this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n }\n this.pausedTimestamp = null;\n this.status = RecordingStatus.Recording;\n }\n else {\n throw this.unavailable('Resuming recordings is not supported in this browser.');\n }\n }\n async stopRecording() {\n var _a;\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n throw this.unavailable('No active recording to stop.');\n }\n if (this.status === RecordingStatus.Paused && this.pausedTimestamp) {\n this.accumulatedPauseDuration += Date.now() - this.pausedTimestamp;\n this.pausedTimestamp = null;\n }\n const stopPromise = new Promise((resolve, reject) => {\n this.stopResolver = resolve;\n this.stopRejector = reject;\n });\n try {\n this.mediaRecorder.stop();\n }\n catch (error) {\n this.resetStopHandlers();\n this.resetState();\n this.handleError(`Unable to stop recorder: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);\n throw error;\n }\n return stopPromise;\n }\n async cancelRecording() {\n if (!this.mediaRecorder || this.status === RecordingStatus.Inactive) {\n this.resetState();\n return;\n }\n try {\n this.mediaRecorder.stop();\n }\n catch (_a) {\n // Ignored.\n }\n this.resetStopHandlers();\n this.resetState();\n }\n async getRecordingStatus() {\n return { status: this.status };\n }\n async checkPermissions() {\n const state = await this.getPermissionState();\n return { recordAudio: state };\n }\n async requestPermissions() {\n const state = await this.ensurePermission(true);\n return { recordAudio: state };\n }\n async addListener(eventName, listenerFunc) {\n return super.addListener(eventName, listenerFunc);\n }\n async removeAllListeners() {\n await super.removeAllListeners();\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n // Helpers\n supportsRecorderPause() {\n return (!!this.mediaRecorder &&\n typeof this.mediaRecorder.pause === 'function' &&\n typeof this.mediaRecorder.resume === 'function');\n }\n pickMimeType() {\n const preferred = ['audio/webm;codecs=opus', 'audio/ogg;codecs=opus', 'audio/mp4'];\n for (const type of preferred) {\n if (window.MediaRecorder && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(type)) {\n return type;\n }\n }\n return undefined;\n }\n buildStopResult() {\n const blob = this.recordedChunks.length > 0\n ? new Blob(this.recordedChunks, { type: this.pickMimeType() || 'audio/webm' })\n : undefined;\n let duration;\n if (this.startTimestamp) {\n duration = Date.now() - this.startTimestamp - this.accumulatedPauseDuration;\n }\n return {\n blob,\n duration,\n };\n }\n resetStopHandlers() {\n this.stopResolver = null;\n this.stopRejector = null;\n }\n resetState() {\n this.status = RecordingStatus.Inactive;\n this.startTimestamp = null;\n this.pausedTimestamp = null;\n this.accumulatedPauseDuration = 0;\n this.recordedChunks = [];\n this.cleanupMediaStream();\n if (this.mediaRecorder) {\n const recorder = this.mediaRecorder;\n recorder.ondataavailable = null;\n recorder.onstop = null;\n recorder.onerror = null;\n }\n this.mediaRecorder = null;\n }\n cleanupMediaStream() {\n if (this.mediaStream) {\n this.mediaStream.getTracks().forEach((track) => track.stop());\n }\n this.mediaStream = null;\n }\n async ensurePermission(request) {\n const currentState = await this.getPermissionState();\n if (currentState === 'granted' || !request) {\n return currentState;\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n stream.getTracks().forEach((track) => track.stop());\n return 'granted';\n }\n catch (error) {\n return 'denied';\n }\n }\n async getPermissionState() {\n var _a;\n if (!((_a = navigator.permissions) === null || _a === void 0 ? void 0 : _a.query)) {\n return 'prompt';\n }\n try {\n const result = await navigator.permissions.query({ name: 'microphone' });\n switch (result.state) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n catch (_b) {\n return 'prompt';\n }\n }\n handleError(message) {\n this.status = RecordingStatus.Inactive;\n this.notifyListeners('recordingError', { message });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["RecordingStatus","AudioSessionCategoryOption","AudioSessionMode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,UAAU,CAAC,GAAG,UAAU;IAC5C,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW;IAC9C,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,QAAQ;IACxC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC;IAC7C;IACA;IACA;IACA;IACA;AACWC;IACX,CAAC,UAAU,0BAA0B,EAAE;IACvC,IAAI,0BAA0B,CAAC,cAAc,CAAC,GAAG,gBAAgB;IACjE,IAAI,0BAA0B,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;IACpE,IAAI,0BAA0B,CAAC,oBAAoB,CAAC,GAAG,sBAAsB;IAC7E,IAAI,0BAA0B,CAAC,kBAAkB,CAAC,GAAG,oBAAoB;IACzE,IAAI,0BAA0B,CAAC,YAAY,CAAC,GAAG,aAAa;IAC5D,IAAI,0BAA0B,CAAC,sCAAsC,CAAC,GAAG,4CAA4C;IACrH,IAAI,0BAA0B,CAAC,eAAe,CAAC,GAAG,iBAAiB;IACnE,IAAI,0BAA0B,CAAC,qCAAqC,CAAC,GAAG,wCAAwC;IAChH,CAAC,EAAEA,kCAA0B,KAAKA,kCAA0B,GAAG,EAAE,CAAC,CAAC;IACnE;IACA;IACA;IACA;IACA;AACWC;IACX,CAAC,UAAU,gBAAgB,EAAE;IAC7B,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS;IAC3C,IAAI,gBAAgB,CAAC,UAAU,CAAC,GAAG,WAAW;IAC9C,IAAI,gBAAgB,CAAC,aAAa,CAAC,GAAG,aAAa;IACnD,IAAI,gBAAgB,CAAC,aAAa,CAA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.1.1"
7
8
  public let identifier = "CapacitorAudioRecorderPlugin"
8
9
  public let jsName = "CapacitorAudioRecorder"
9
10
  public let pluginMethods: [CAPPluginMethod] = [
@@ -16,6 +17,7 @@ public class CapacitorAudioRecorderPlugin: CAPPlugin, CAPBridgedPlugin, AVAudioR
16
17
  CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
17
18
  CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise),
18
19
  CAPPluginMethod(name: "removeAllListeners", returnType: CAPPluginReturnPromise),
20
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
19
21
  ]
20
22
 
21
23
  private enum RecordingStatus: String {
@@ -101,7 +103,7 @@ public class CapacitorAudioRecorderPlugin: CAPPlugin, CAPBridgedPlugin, AVAudioR
101
103
 
102
104
  let result: [String: Any] = [
103
105
  "duration": durationMilliseconds,
104
- "uri": uri,
106
+ "uri": uri
105
107
  ]
106
108
 
107
109
  notifyListeners("recordingStopped", data: result)
@@ -159,7 +161,7 @@ public class CapacitorAudioRecorderPlugin: CAPPlugin, CAPBridgedPlugin, AVAudioR
159
161
  let uri = currentFileURL?.absoluteString ?? ""
160
162
  let result: [String: Any] = [
161
163
  "duration": durationMilliseconds,
162
- "uri": uri,
164
+ "uri": uri
163
165
  ]
164
166
  notifyListeners("recordingStopped", data: result)
165
167
  } else {
@@ -203,7 +205,7 @@ public class CapacitorAudioRecorderPlugin: CAPPlugin, CAPBridgedPlugin, AVAudioR
203
205
  AVSampleRateKey: sampleRate,
204
206
  AVNumberOfChannelsKey: 1,
205
207
  AVEncoderBitRateKey: bitRate,
206
- AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue,
208
+ AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
207
209
  ]
208
210
 
209
211
  let recorder = try AVAudioRecorder(url: fileURL, settings: settings)
@@ -318,4 +320,8 @@ public class CapacitorAudioRecorderPlugin: CAPPlugin, CAPBridgedPlugin, AVAudioR
318
320
  return .default
319
321
  }
320
322
  }
323
+
324
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
325
+ call.resolve(["version": self.PLUGIN_VERSION])
326
+ }
321
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-audio-recorder",
3
- "version": "7.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "Record audio on iOS, Android, and Web with Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -40,7 +40,7 @@
40
40
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
41
41
  "verify:web": "npm run build",
42
42
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
43
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
43
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
44
44
  "eslint": "eslint . --ext .ts",
45
45
  "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
46
46
  "swiftlint": "node-swiftlint",