react-native-audio-api 0.11.0-nightly-b30bac9-20260114 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +3 -10
  2. package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +0 -4
  3. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +4 -83
  4. package/android/src/main/java/com/swmansion/audioapi/system/CentralizedForegroundService.kt +14 -29
  5. package/android/src/main/java/com/swmansion/audioapi/system/ForegroundServiceManager.kt +10 -9
  6. package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +10 -51
  7. package/android/src/main/java/com/swmansion/audioapi/system/notification/BaseNotification.kt +6 -14
  8. package/android/src/main/java/com/swmansion/audioapi/system/notification/NotificationRegistry.kt +79 -60
  9. package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +249 -411
  10. package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotificationReceiver.kt +8 -3
  11. package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotification.kt +240 -222
  12. package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +11 -22
  13. package/android/src/main/java/com/swmansion/audioapi/system/notification/state/RecordingNotificationState.kt +24 -0
  14. package/android/src/main/res/layout/btn_round_ripple.xml +9 -0
  15. package/android/src/main/res/layout/notification_collapsed.xml +45 -0
  16. package/android/src/main/res/layout/notification_expanded.xml +44 -0
  17. package/android/src/oldarch/NativeAudioAPIModuleSpec.java +1 -13
  18. package/common/cpp/audioapi/core/utils/AudioFileWriter.cpp +1 -1
  19. package/ios/audioapi/ios/AudioAPIModule.mm +5 -48
  20. package/ios/audioapi/ios/system/notification/BaseNotification.h +0 -7
  21. package/ios/audioapi/ios/system/notification/NotificationRegistry.h +5 -25
  22. package/ios/audioapi/ios/system/notification/NotificationRegistry.mm +19 -64
  23. package/ios/audioapi/ios/system/notification/PlaybackNotification.mm +4 -15
  24. package/lib/commonjs/AudioAPIModule/AudioAPIModule.js +2 -1
  25. package/lib/commonjs/AudioAPIModule/AudioAPIModule.js.map +1 -1
  26. package/lib/commonjs/api.js +1 -29
  27. package/lib/commonjs/api.js.map +1 -1
  28. package/lib/commonjs/core/AudioDecoder.js +42 -16
  29. package/lib/commonjs/core/AudioDecoder.js.map +1 -1
  30. package/lib/commonjs/core/AudioRecorder.js +2 -1
  31. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  32. package/lib/commonjs/core/AudioStretcher.js +2 -1
  33. package/lib/commonjs/core/AudioStretcher.js.map +1 -1
  34. package/lib/commonjs/core/BaseAudioContext.js +2 -5
  35. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  36. package/lib/commonjs/errors/AudioApiError.js +14 -0
  37. package/lib/commonjs/errors/AudioApiError.js.map +1 -0
  38. package/lib/commonjs/errors/index.js +7 -0
  39. package/lib/commonjs/errors/index.js.map +1 -1
  40. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  41. package/lib/commonjs/specs/NativeAudioAPIModule.web.js +0 -9
  42. package/lib/commonjs/specs/NativeAudioAPIModule.web.js.map +1 -1
  43. package/lib/commonjs/system/notification/PlaybackNotificationManager.js +40 -85
  44. package/lib/commonjs/system/notification/PlaybackNotificationManager.js.map +1 -1
  45. package/lib/commonjs/system/notification/RecordingNotificationManager.ios.js +51 -0
  46. package/lib/commonjs/system/notification/RecordingNotificationManager.ios.js.map +1 -0
  47. package/lib/commonjs/system/notification/RecordingNotificationManager.js +30 -144
  48. package/lib/commonjs/system/notification/RecordingNotificationManager.js.map +1 -1
  49. package/lib/commonjs/system/notification/index.js +1 -9
  50. package/lib/commonjs/system/notification/index.js.map +1 -1
  51. package/lib/commonjs/utils/index.js +3 -2
  52. package/lib/commonjs/utils/index.js.map +1 -1
  53. package/lib/commonjs/utils/paths.js +18 -0
  54. package/lib/commonjs/utils/paths.js.map +1 -0
  55. package/lib/commonjs/web-core/AudioContext.js +20 -11
  56. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  57. package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js +0 -1
  58. package/lib/commonjs/web-system/notification/PlaybackNotificationManager.js.map +1 -1
  59. package/lib/commonjs/web-system/notification/RecordingNotificationManager.js +1 -6
  60. package/lib/commonjs/web-system/notification/RecordingNotificationManager.js.map +1 -1
  61. package/lib/module/AudioAPIModule/AudioAPIModule.js +2 -1
  62. package/lib/module/AudioAPIModule/AudioAPIModule.js.map +1 -1
  63. package/lib/module/api.js +3 -2
  64. package/lib/module/api.js.map +1 -1
  65. package/lib/module/core/AudioDecoder.js +42 -16
  66. package/lib/module/core/AudioDecoder.js.map +1 -1
  67. package/lib/module/core/AudioRecorder.js +3 -1
  68. package/lib/module/core/AudioRecorder.js.map +1 -1
  69. package/lib/module/core/AudioStretcher.js +2 -1
  70. package/lib/module/core/AudioStretcher.js.map +1 -1
  71. package/lib/module/core/BaseAudioContext.js +2 -5
  72. package/lib/module/core/BaseAudioContext.js.map +1 -1
  73. package/lib/module/errors/AudioApiError.js +10 -0
  74. package/lib/module/errors/AudioApiError.js.map +1 -0
  75. package/lib/module/errors/index.js +1 -0
  76. package/lib/module/errors/index.js.map +1 -1
  77. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  78. package/lib/module/specs/NativeAudioAPIModule.web.js +0 -9
  79. package/lib/module/specs/NativeAudioAPIModule.web.js.map +1 -1
  80. package/lib/module/system/notification/PlaybackNotificationManager.js +40 -85
  81. package/lib/module/system/notification/PlaybackNotificationManager.js.map +1 -1
  82. package/lib/module/system/notification/RecordingNotificationManager.ios.js +47 -0
  83. package/lib/module/system/notification/RecordingNotificationManager.ios.js.map +1 -0
  84. package/lib/module/system/notification/RecordingNotificationManager.js +30 -144
  85. package/lib/module/system/notification/RecordingNotificationManager.js.map +1 -1
  86. package/lib/module/system/notification/index.js +1 -2
  87. package/lib/module/system/notification/index.js.map +1 -1
  88. package/lib/module/utils/index.js +3 -2
  89. package/lib/module/utils/index.js.map +1 -1
  90. package/lib/module/utils/paths.js +12 -0
  91. package/lib/module/utils/paths.js.map +1 -0
  92. package/lib/module/web-core/AudioContext.js +20 -11
  93. package/lib/module/web-core/AudioContext.js.map +1 -1
  94. package/lib/module/web-system/notification/PlaybackNotificationManager.js +0 -1
  95. package/lib/module/web-system/notification/PlaybackNotificationManager.js.map +1 -1
  96. package/lib/module/web-system/notification/RecordingNotificationManager.js +1 -6
  97. package/lib/module/web-system/notification/RecordingNotificationManager.js.map +1 -1
  98. package/lib/typescript/AudioAPIModule/AudioAPIModule.d.ts.map +1 -1
  99. package/lib/typescript/api.d.ts +3 -2
  100. package/lib/typescript/api.d.ts.map +1 -1
  101. package/lib/typescript/core/AudioDecoder.d.ts +2 -1
  102. package/lib/typescript/core/AudioDecoder.d.ts.map +1 -1
  103. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  104. package/lib/typescript/core/AudioStretcher.d.ts.map +1 -1
  105. package/lib/typescript/core/BaseAudioContext.d.ts +2 -2
  106. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  107. package/lib/typescript/errors/AudioApiError.d.ts +5 -0
  108. package/lib/typescript/errors/AudioApiError.d.ts.map +1 -0
  109. package/lib/typescript/errors/index.d.ts +1 -0
  110. package/lib/typescript/errors/index.d.ts.map +1 -1
  111. package/lib/typescript/interfaces.d.ts +1 -1
  112. package/lib/typescript/interfaces.d.ts.map +1 -1
  113. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +2 -5
  114. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  115. package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts +1 -4
  116. package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts.map +1 -1
  117. package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts +32 -9
  118. package/lib/typescript/system/notification/PlaybackNotificationManager.d.ts.map +1 -1
  119. package/lib/typescript/system/notification/RecordingNotificationManager.d.ts +26 -13
  120. package/lib/typescript/system/notification/RecordingNotificationManager.d.ts.map +1 -1
  121. package/lib/typescript/system/notification/RecordingNotificationManager.ios.d.ts +36 -0
  122. package/lib/typescript/system/notification/RecordingNotificationManager.ios.d.ts.map +1 -0
  123. package/lib/typescript/system/notification/index.d.ts +0 -1
  124. package/lib/typescript/system/notification/index.d.ts.map +1 -1
  125. package/lib/typescript/system/notification/types.d.ts +12 -22
  126. package/lib/typescript/system/notification/types.d.ts.map +1 -1
  127. package/lib/typescript/types.d.ts +1 -0
  128. package/lib/typescript/types.d.ts.map +1 -1
  129. package/lib/typescript/utils/index.d.ts.map +1 -1
  130. package/lib/typescript/utils/paths.d.ts +4 -0
  131. package/lib/typescript/utils/paths.d.ts.map +1 -0
  132. package/lib/typescript/web-core/AudioContext.d.ts +8 -9
  133. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  134. package/lib/typescript/web-core/BaseAudioContext.d.ts +6 -7
  135. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  136. package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts +1 -2
  137. package/lib/typescript/web-system/notification/PlaybackNotificationManager.d.ts.map +1 -1
  138. package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts +2 -7
  139. package/lib/typescript/web-system/notification/RecordingNotificationManager.d.ts.map +1 -1
  140. package/package.json +1 -1
  141. package/src/AudioAPIModule/AudioAPIModule.ts +2 -1
  142. package/src/api.ts +2 -8
  143. package/src/core/AudioDecoder.ts +91 -21
  144. package/src/core/AudioRecorder.ts +2 -1
  145. package/src/core/AudioStretcher.ts +2 -1
  146. package/src/core/BaseAudioContext.ts +4 -6
  147. package/src/errors/AudioApiError.ts +8 -0
  148. package/src/errors/index.ts +1 -0
  149. package/src/interfaces.ts +1 -1
  150. package/src/specs/NativeAudioAPIModule.ts +5 -15
  151. package/src/specs/NativeAudioAPIModule.web.ts +1 -12
  152. package/src/system/notification/PlaybackNotificationManager.ts +42 -117
  153. package/src/system/notification/RecordingNotificationManager.ios.ts +65 -0
  154. package/src/system/notification/RecordingNotificationManager.ts +33 -183
  155. package/src/system/notification/index.ts +0 -1
  156. package/src/system/notification/types.ts +15 -37
  157. package/src/types.ts +2 -0
  158. package/src/utils/index.ts +3 -2
  159. package/src/utils/paths.ts +11 -0
  160. package/src/web-core/AudioContext.tsx +34 -19
  161. package/src/web-core/BaseAudioContext.tsx +9 -7
  162. package/src/web-system/notification/PlaybackNotificationManager.ts +1 -7
  163. package/src/web-system/notification/RecordingNotificationManager.ts +1 -16
  164. package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioPlayer.kt +0 -26
  165. package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioRecorder.kt +0 -26
  166. package/android/src/main/java/com/swmansion/audioapi/system/notification/SimpleNotification.kt +0 -119
  167. package/lib/commonjs/system/notification/SimpleNotificationManager.js +0 -125
  168. package/lib/commonjs/system/notification/SimpleNotificationManager.js.map +0 -1
  169. package/lib/module/system/notification/SimpleNotificationManager.js +0 -121
  170. package/lib/module/system/notification/SimpleNotificationManager.js.map +0 -1
  171. package/lib/typescript/system/notification/SimpleNotificationManager.d.ts +0 -21
  172. package/lib/typescript/system/notification/SimpleNotificationManager.d.ts.map +0 -1
  173. package/src/system/notification/SimpleNotificationManager.ts +0 -175
@@ -1,119 +0,0 @@
1
- package com.swmansion.audioapi.system.notification
2
-
3
- import android.app.Notification
4
- import android.app.NotificationChannel
5
- import android.app.NotificationManager
6
- import android.app.PendingIntent
7
- import android.content.Context
8
- import android.os.Build
9
- import androidx.core.app.NotificationCompat
10
- import com.facebook.react.bridge.ReactApplicationContext
11
- import com.facebook.react.bridge.ReadableMap
12
- import com.swmansion.audioapi.R
13
- import java.lang.ref.WeakReference
14
-
15
- /**
16
- * This serves as a reference implementation and starting point for more complex notifications.
17
- */
18
- class SimpleNotification(
19
- private val reactContext: WeakReference<ReactApplicationContext>,
20
- private val notificationId: Int = DEFAULT_NOTIFICATION_ID,
21
- ) : BaseNotification {
22
- companion object {
23
- const val DEFAULT_NOTIFICATION_ID = 200
24
- const val CHANNEL_ID = "react-native-audio-api-simple"
25
- const val CHANNEL_NAME = "Simple Notifications"
26
- }
27
-
28
- private var title: String = "Audio Playing"
29
- private var text: String = ""
30
-
31
- init {
32
- createNotificationChannel()
33
- }
34
-
35
- override fun init(options: ReadableMap?): Notification {
36
- // Parse options from JavaScript
37
- if (options != null) {
38
- if (options.hasKey("title")) {
39
- title = options.getString("title") ?: "Audio Playing"
40
- }
41
- if (options.hasKey("text")) {
42
- text = options.getString("text") ?: ""
43
- }
44
- }
45
-
46
- return buildNotification()
47
- }
48
-
49
- override fun update(options: ReadableMap?): Notification {
50
- // Update works the same as init for simple notifications
51
- return init(options)
52
- }
53
-
54
- override fun reset() {
55
- // Reset to default values
56
- title = "Audio Playing"
57
- text = ""
58
- }
59
-
60
- override fun getNotificationId(): Int = notificationId
61
-
62
- override fun getChannelId(): String = CHANNEL_ID
63
-
64
- private fun buildNotification(): Notification {
65
- val context = reactContext.get() ?: throw IllegalStateException("React context is null")
66
-
67
- // Use a system icon that's guaranteed to exist
68
- val icon = android.R.drawable.ic_dialog_info
69
-
70
- val builder =
71
- NotificationCompat
72
- .Builder(context, CHANNEL_ID)
73
- .setContentTitle(title)
74
- .setContentText(text)
75
- .setSmallIcon(icon)
76
- .setPriority(NotificationCompat.PRIORITY_HIGH)
77
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
78
- .setOngoing(false)
79
- .setAutoCancel(false)
80
-
81
- // Add content intent to open the app when notification is tapped
82
- val packageName = context.packageName
83
- val openAppIntent = context.packageManager?.getLaunchIntentForPackage(packageName)
84
- if (openAppIntent != null) {
85
- val pendingIntent =
86
- PendingIntent.getActivity(
87
- context,
88
- 0,
89
- openAppIntent,
90
- PendingIntent.FLAG_IMMUTABLE,
91
- )
92
- builder.setContentIntent(pendingIntent)
93
- }
94
-
95
- return builder.build()
96
- }
97
-
98
- private fun createNotificationChannel() {
99
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
100
- val context = reactContext.get() ?: return
101
- val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
102
-
103
- val channel =
104
- NotificationChannel(
105
- CHANNEL_ID,
106
- CHANNEL_NAME,
107
- NotificationManager.IMPORTANCE_HIGH,
108
- ).apply {
109
- description = "Simple notification channel for audio playback"
110
- setShowBadge(true)
111
- lockscreenVisibility = Notification.VISIBILITY_PUBLIC
112
- enableLights(true)
113
- enableVibration(false)
114
- }
115
-
116
- notificationManager.createNotificationChannel(channel)
117
- }
118
- }
119
- }
@@ -1,125 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _events = require("../../events");
8
- var _specs = require("../../specs");
9
- /// Simple notification manager for basic notifications with title and text.
10
- /// Implements the generic NotificationManager interface.
11
- // It is only a showcase
12
- class SimpleNotificationManager {
13
- isRegistered_ = false;
14
- isShown_ = false;
15
- notificationKey = 'simple';
16
- constructor() {
17
- this.audioEventEmitter = new _events.AudioEventEmitter(global.AudioEventEmitter);
18
- }
19
-
20
- /// Register the simple notification (must be called before showing).
21
- async register() {
22
- if (this.isRegistered_) {
23
- console.warn('SimpleNotification is already registered');
24
- return;
25
- }
26
- if (!_specs.NativeAudioAPIModule) {
27
- throw new Error('NativeAudioAPIModule is not available');
28
- }
29
- const result = await _specs.NativeAudioAPIModule.registerNotification('simple', this.notificationKey);
30
- if (result.error) {
31
- throw new Error(result.error);
32
- }
33
- this.isRegistered_ = true;
34
- }
35
-
36
- /// Show the notification with initial options.
37
- async show(options) {
38
- if (!this.isRegistered_) {
39
- throw new Error('SimpleNotification must be registered before showing. Call register() first.');
40
- }
41
- if (!_specs.NativeAudioAPIModule) {
42
- throw new Error('NativeAudioAPIModule is not available');
43
- }
44
- const result = await _specs.NativeAudioAPIModule.showNotification(this.notificationKey, options);
45
- if (result.error) {
46
- throw new Error(result.error);
47
- }
48
- this.isShown_ = true;
49
- }
50
-
51
- /// Update the notification with new options.
52
- async update(options) {
53
- if (!this.isShown_) {
54
- console.warn('SimpleNotification is not shown. Call show() first.');
55
- return;
56
- }
57
- if (!_specs.NativeAudioAPIModule) {
58
- throw new Error('NativeAudioAPIModule is not available');
59
- }
60
- const result = await _specs.NativeAudioAPIModule.updateNotification(this.notificationKey, options);
61
- if (result.error) {
62
- throw new Error(result.error);
63
- }
64
- }
65
-
66
- /// Hide the notification (can be shown again later).
67
- async hide() {
68
- if (!this.isShown_) {
69
- return;
70
- }
71
- if (!_specs.NativeAudioAPIModule) {
72
- throw new Error('NativeAudioAPIModule is not available');
73
- }
74
- const result = await _specs.NativeAudioAPIModule.hideNotification(this.notificationKey);
75
- if (result.error) {
76
- throw new Error(result.error);
77
- }
78
- this.isShown_ = false;
79
- }
80
-
81
- /// Unregister the notification (must register again to use).
82
- async unregister() {
83
- if (!this.isRegistered_) {
84
- return;
85
- }
86
- if (this.isShown_) {
87
- await this.hide();
88
- }
89
- if (!_specs.NativeAudioAPIModule) {
90
- throw new Error('NativeAudioAPIModule is not available');
91
- }
92
- const result = await _specs.NativeAudioAPIModule.unregisterNotification(this.notificationKey);
93
- if (result.error) {
94
- throw new Error(result.error);
95
- }
96
- this.isRegistered_ = false;
97
- }
98
-
99
- /// Check if the notification is currently active.
100
- async isActive() {
101
- if (!_specs.NativeAudioAPIModule) {
102
- return false;
103
- }
104
- return await _specs.NativeAudioAPIModule.isNotificationActive(this.notificationKey);
105
- }
106
- isRegistered() {
107
- return this.isRegistered_;
108
- }
109
-
110
- /// Add an event listener (SimpleNotification doesn't emit events).
111
- addEventListener(_eventName, _callback) {
112
- // SimpleNotification doesn't emit events, return a no-op subscription
113
- console.warn('SimpleNotification does not support event listeners');
114
- return this.audioEventEmitter.addAudioEventListener(
115
- // Using a valid event name for the no-op subscription
116
- 'playbackNotificationPlay', () => {});
117
- }
118
-
119
- /// Remove an event listener.
120
- removeEventListener(subscription) {
121
- subscription.remove();
122
- }
123
- }
124
- var _default = exports.default = new SimpleNotificationManager();
125
- //# sourceMappingURL=SimpleNotificationManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_events","require","_specs","SimpleNotificationManager","isRegistered_","isShown_","notificationKey","constructor","audioEventEmitter","AudioEventEmitter","global","register","console","warn","NativeAudioAPIModule","Error","result","registerNotification","error","show","options","showNotification","update","updateNotification","hide","hideNotification","unregister","unregisterNotification","isActive","isNotificationActive","isRegistered","addEventListener","_eventName","_callback","addAudioEventListener","removeEventListener","subscription","remove","_default","exports","default"],"sourceRoot":"../../../../src","sources":["system/notification/SimpleNotificationManager.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA;AACA;AACA;AACA,MAAME,yBAAyB,CAO/B;EACUC,aAAa,GAAG,KAAK;EACrBC,QAAQ,GAAG,KAAK;EAEhBC,eAAe,GAAG,QAAQ;EAGlCC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,iBAAiB,GAAG,IAAIC,yBAAiB,CAACC,MAAM,CAACD,iBAAiB,CAAC;EAC1E;;EAEA;EACA,MAAME,QAAQA,CAAA,EAAkB;IAC9B,IAAI,IAAI,CAACP,aAAa,EAAE;MACtBQ,OAAO,CAACC,IAAI,CAAC,0CAA0C,CAAC;MACxD;IACF;IAEA,IAAI,CAACC,2BAAoB,EAAE;MACzB,MAAM,IAAIC,KAAK,CAAC,uCAAuC,CAAC;IAC1D;IAEA,MAAMC,MAAM,GAAG,MAAMF,2BAAoB,CAACG,oBAAoB,CAC5D,QAAQ,EACR,IAAI,CAACX,eACP,CAAC;IAED,IAAIU,MAAM,CAACE,KAAK,EAAE;MAChB,MAAM,IAAIH,KAAK,CAACC,MAAM,CAACE,KAAK,CAAC;IAC/B;IAEA,IAAI,CAACd,aAAa,GAAG,IAAI;EAC3B;;EAEA;EACA,MAAMe,IAAIA,CAACC,OA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../events/index.js";
4
- import { NativeAudioAPIModule } from "../../specs/index.js";
5
- /// Simple notification manager for basic notifications with title and text.
6
- /// Implements the generic NotificationManager interface.
7
- // It is only a showcase
8
- class SimpleNotificationManager {
9
- isRegistered_ = false;
10
- isShown_ = false;
11
- notificationKey = 'simple';
12
- constructor() {
13
- this.audioEventEmitter = new AudioEventEmitter(global.AudioEventEmitter);
14
- }
15
-
16
- /// Register the simple notification (must be called before showing).
17
- async register() {
18
- if (this.isRegistered_) {
19
- console.warn('SimpleNotification is already registered');
20
- return;
21
- }
22
- if (!NativeAudioAPIModule) {
23
- throw new Error('NativeAudioAPIModule is not available');
24
- }
25
- const result = await NativeAudioAPIModule.registerNotification('simple', this.notificationKey);
26
- if (result.error) {
27
- throw new Error(result.error);
28
- }
29
- this.isRegistered_ = true;
30
- }
31
-
32
- /// Show the notification with initial options.
33
- async show(options) {
34
- if (!this.isRegistered_) {
35
- throw new Error('SimpleNotification must be registered before showing. Call register() first.');
36
- }
37
- if (!NativeAudioAPIModule) {
38
- throw new Error('NativeAudioAPIModule is not available');
39
- }
40
- const result = await NativeAudioAPIModule.showNotification(this.notificationKey, options);
41
- if (result.error) {
42
- throw new Error(result.error);
43
- }
44
- this.isShown_ = true;
45
- }
46
-
47
- /// Update the notification with new options.
48
- async update(options) {
49
- if (!this.isShown_) {
50
- console.warn('SimpleNotification is not shown. Call show() first.');
51
- return;
52
- }
53
- if (!NativeAudioAPIModule) {
54
- throw new Error('NativeAudioAPIModule is not available');
55
- }
56
- const result = await NativeAudioAPIModule.updateNotification(this.notificationKey, options);
57
- if (result.error) {
58
- throw new Error(result.error);
59
- }
60
- }
61
-
62
- /// Hide the notification (can be shown again later).
63
- async hide() {
64
- if (!this.isShown_) {
65
- return;
66
- }
67
- if (!NativeAudioAPIModule) {
68
- throw new Error('NativeAudioAPIModule is not available');
69
- }
70
- const result = await NativeAudioAPIModule.hideNotification(this.notificationKey);
71
- if (result.error) {
72
- throw new Error(result.error);
73
- }
74
- this.isShown_ = false;
75
- }
76
-
77
- /// Unregister the notification (must register again to use).
78
- async unregister() {
79
- if (!this.isRegistered_) {
80
- return;
81
- }
82
- if (this.isShown_) {
83
- await this.hide();
84
- }
85
- if (!NativeAudioAPIModule) {
86
- throw new Error('NativeAudioAPIModule is not available');
87
- }
88
- const result = await NativeAudioAPIModule.unregisterNotification(this.notificationKey);
89
- if (result.error) {
90
- throw new Error(result.error);
91
- }
92
- this.isRegistered_ = false;
93
- }
94
-
95
- /// Check if the notification is currently active.
96
- async isActive() {
97
- if (!NativeAudioAPIModule) {
98
- return false;
99
- }
100
- return await NativeAudioAPIModule.isNotificationActive(this.notificationKey);
101
- }
102
- isRegistered() {
103
- return this.isRegistered_;
104
- }
105
-
106
- /// Add an event listener (SimpleNotification doesn't emit events).
107
- addEventListener(_eventName, _callback) {
108
- // SimpleNotification doesn't emit events, return a no-op subscription
109
- console.warn('SimpleNotification does not support event listeners');
110
- return this.audioEventEmitter.addAudioEventListener(
111
- // Using a valid event name for the no-op subscription
112
- 'playbackNotificationPlay', () => {});
113
- }
114
-
115
- /// Remove an event listener.
116
- removeEventListener(subscription) {
117
- subscription.remove();
118
- }
119
- }
120
- export default new SimpleNotificationManager();
121
- //# sourceMappingURL=SimpleNotificationManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["AudioEventEmitter","NativeAudioAPIModule","SimpleNotificationManager","isRegistered_","isShown_","notificationKey","constructor","audioEventEmitter","global","register","console","warn","Error","result","registerNotification","error","show","options","showNotification","update","updateNotification","hide","hideNotification","unregister","unregisterNotification","isActive","isNotificationActive","isRegistered","addEventListener","_eventName","_callback","addAudioEventListener","removeEventListener","subscription","remove"],"sourceRoot":"../../../../src","sources":["system/notification/SimpleNotificationManager.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAgC,uBAAc;AACxE,SAASC,oBAAoB,QAAQ,sBAAa;AAGlD;AACA;AACA;AACA,MAAMC,yBAAyB,CAO/B;EACUC,aAAa,GAAG,KAAK;EACrBC,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,QAAQA,CAAA,EAAqB;IACjC,IAAI,CAACxB,oBAAoB,EAAE;MACzB,OAAO,KAAK;IACd;IAEA,OAAO,MAAMA,oBAAoB,CAACyB,oBAAoB,CACpD,IAAI,CAACrB,eACP,CAAC;EACH;EAEAsB,YAAYA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACxB,aAAa;EAC3B;;EAEA;EACAyB,gBAAgBA,CACdC,UAAa,EACbC,SAAiC,EACT;IACxB;IACApB,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;IACnE,OAAO,IAAI,CAACJ,iBAAiB,CAACwB,qBAAqB;IACjD;IACA,0BAA0B,EAC1B,MAAM,CAAC,CACT,CAAC;EACH;;EAEA;EACAC,mBAAmBA,CAACC,YAAoC,EAAQ;IAC9DA,YAAY,CAACC,MAAM,CAAC,CAAC;EACvB;AACF;AAEA,eAAe,IAAIhC,yBAAyB,CAAC,CAAC","ignoreList":[]}
@@ -1,21 +0,0 @@
1
- import { AudioEventSubscription } from '../../events';
2
- import type { NotificationManager, SimpleNotificationOptions } from './types';
3
- declare class SimpleNotificationManager implements NotificationManager<SimpleNotificationOptions, SimpleNotificationOptions, never> {
4
- private isRegistered_;
5
- private isShown_;
6
- private notificationKey;
7
- private audioEventEmitter;
8
- constructor();
9
- register(): Promise<void>;
10
- show(options: SimpleNotificationOptions): Promise<void>;
11
- update(options: SimpleNotificationOptions): Promise<void>;
12
- hide(): Promise<void>;
13
- unregister(): Promise<void>;
14
- isActive(): Promise<boolean>;
15
- isRegistered(): boolean;
16
- addEventListener<T extends never>(_eventName: T, _callback: (event: never) => void): AudioEventSubscription;
17
- removeEventListener(subscription: AudioEventSubscription): void;
18
- }
19
- declare const _default: SimpleNotificationManager;
20
- export default _default;
21
- //# sourceMappingURL=SimpleNotificationManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SimpleNotificationManager.d.ts","sourceRoot":"","sources":["../../../../src/system/notification/SimpleNotificationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAK9E,cAAM,yBACJ,YACE,mBAAmB,CACjB,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,CACN;IAEH,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,iBAAiB,CAAoB;;IAOvC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBzB,IAAI,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBvD,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBrB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAUlC,YAAY,IAAI,OAAO;IAKvB,gBAAgB,CAAC,CAAC,SAAS,KAAK,EAC9B,UAAU,EAAE,CAAC,EACb,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAChC,sBAAsB;IAWzB,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI;CAGhE;;AAED,wBAA+C"}
@@ -1,175 +0,0 @@
1
- import { AudioEventEmitter, AudioEventSubscription } from '../../events';
2
- import { NativeAudioAPIModule } from '../../specs';
3
- import type { NotificationManager, SimpleNotificationOptions } from './types';
4
-
5
- /// Simple notification manager for basic notifications with title and text.
6
- /// Implements the generic NotificationManager interface.
7
- // It is only a showcase
8
- class SimpleNotificationManager
9
- implements
10
- NotificationManager<
11
- SimpleNotificationOptions,
12
- SimpleNotificationOptions,
13
- never
14
- >
15
- {
16
- private isRegistered_ = false;
17
- private isShown_ = false;
18
-
19
- private notificationKey = 'simple';
20
- private audioEventEmitter: AudioEventEmitter;
21
-
22
- constructor() {
23
- this.audioEventEmitter = new AudioEventEmitter(global.AudioEventEmitter);
24
- }
25
-
26
- /// Register the simple notification (must be called before showing).
27
- async register(): Promise<void> {
28
- if (this.isRegistered_) {
29
- console.warn('SimpleNotification is already registered');
30
- return;
31
- }
32
-
33
- if (!NativeAudioAPIModule) {
34
- throw new Error('NativeAudioAPIModule is not available');
35
- }
36
-
37
- const result = await NativeAudioAPIModule.registerNotification(
38
- 'simple',
39
- this.notificationKey
40
- );
41
-
42
- if (result.error) {
43
- throw new Error(result.error);
44
- }
45
-
46
- this.isRegistered_ = true;
47
- }
48
-
49
- /// Show the notification with initial options.
50
- async show(options: SimpleNotificationOptions): Promise<void> {
51
- if (!this.isRegistered_) {
52
- throw new Error(
53
- 'SimpleNotification must be registered before showing. Call register() first.'
54
- );
55
- }
56
-
57
- if (!NativeAudioAPIModule) {
58
- throw new Error('NativeAudioAPIModule is not available');
59
- }
60
-
61
- const result = await NativeAudioAPIModule.showNotification(
62
- this.notificationKey,
63
- options as Record<string, string | number | boolean | undefined>
64
- );
65
-
66
- if (result.error) {
67
- throw new Error(result.error);
68
- }
69
-
70
- this.isShown_ = true;
71
- }
72
-
73
- /// Update the notification with new options.
74
- async update(options: SimpleNotificationOptions): Promise<void> {
75
- if (!this.isShown_) {
76
- console.warn('SimpleNotification is not shown. Call show() first.');
77
- return;
78
- }
79
-
80
- if (!NativeAudioAPIModule) {
81
- throw new Error('NativeAudioAPIModule is not available');
82
- }
83
-
84
- const result = await NativeAudioAPIModule.updateNotification(
85
- this.notificationKey,
86
- options as Record<string, string | number | boolean | undefined>
87
- );
88
-
89
- if (result.error) {
90
- throw new Error(result.error);
91
- }
92
- }
93
-
94
- /// Hide the notification (can be shown again later).
95
- async hide(): Promise<void> {
96
- if (!this.isShown_) {
97
- return;
98
- }
99
-
100
- if (!NativeAudioAPIModule) {
101
- throw new Error('NativeAudioAPIModule is not available');
102
- }
103
-
104
- const result = await NativeAudioAPIModule.hideNotification(
105
- this.notificationKey
106
- );
107
-
108
- if (result.error) {
109
- throw new Error(result.error);
110
- }
111
-
112
- this.isShown_ = false;
113
- }
114
-
115
- /// Unregister the notification (must register again to use).
116
- async unregister(): Promise<void> {
117
- if (!this.isRegistered_) {
118
- return;
119
- }
120
-
121
- if (this.isShown_) {
122
- await this.hide();
123
- }
124
-
125
- if (!NativeAudioAPIModule) {
126
- throw new Error('NativeAudioAPIModule is not available');
127
- }
128
-
129
- const result = await NativeAudioAPIModule.unregisterNotification(
130
- this.notificationKey
131
- );
132
-
133
- if (result.error) {
134
- throw new Error(result.error);
135
- }
136
-
137
- this.isRegistered_ = false;
138
- }
139
-
140
- /// Check if the notification is currently active.
141
- async isActive(): Promise<boolean> {
142
- if (!NativeAudioAPIModule) {
143
- return false;
144
- }
145
-
146
- return await NativeAudioAPIModule.isNotificationActive(
147
- this.notificationKey
148
- );
149
- }
150
-
151
- isRegistered(): boolean {
152
- return this.isRegistered_;
153
- }
154
-
155
- /// Add an event listener (SimpleNotification doesn't emit events).
156
- addEventListener<T extends never>(
157
- _eventName: T,
158
- _callback: (event: never) => void
159
- ): AudioEventSubscription {
160
- // SimpleNotification doesn't emit events, return a no-op subscription
161
- console.warn('SimpleNotification does not support event listeners');
162
- return this.audioEventEmitter.addAudioEventListener(
163
- // Using a valid event name for the no-op subscription
164
- 'playbackNotificationPlay',
165
- () => {}
166
- );
167
- }
168
-
169
- /// Remove an event listener.
170
- removeEventListener(subscription: AudioEventSubscription): void {
171
- subscription.remove();
172
- }
173
- }
174
-
175
- export default new SimpleNotificationManager();