livevoice-sdk-react-native 2.0.1 → 3.0.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 (207) hide show
  1. package/README.md +105 -66
  2. package/android/build.gradle +5 -4
  3. package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +122 -188
  4. package/android/src/main/java/io/livevoice/react/__SDK.kt +2 -2
  5. package/ios/LiveVoiceRNBridge.swift +362 -0
  6. package/ios/LiveVoiceSdkReactNative.mm +187 -158
  7. package/ios/__SDK.h +1 -1
  8. package/ios/livevoice_spm_backport.rb +202 -0
  9. package/lib/module/components/BrandingView.js +58 -39
  10. package/lib/module/components/BrandingView.js.map +1 -1
  11. package/lib/module/components/ChannelView.js +355 -44
  12. package/lib/module/components/ChannelView.js.map +1 -1
  13. package/lib/module/components/ErrorView.js +5 -6
  14. package/lib/module/components/ErrorView.js.map +1 -1
  15. package/lib/module/components/LiveVoiceSpinner.js +81 -0
  16. package/lib/module/components/LiveVoiceSpinner.js.map +1 -0
  17. package/lib/module/components/LiveVoiceView.js +311 -133
  18. package/lib/module/components/LiveVoiceView.js.map +1 -1
  19. package/lib/module/components/PasswordPrompt.js +165 -0
  20. package/lib/module/components/PasswordPrompt.js.map +1 -0
  21. package/lib/module/components/PlayButtonView.js +180 -244
  22. package/lib/module/components/PlayButtonView.js.map +1 -1
  23. package/lib/module/components/ReconnectingView.js +31 -53
  24. package/lib/module/components/ReconnectingView.js.map +1 -1
  25. package/lib/module/icons/branding-ios.png +0 -0
  26. package/lib/module/icons/camera-off-android.png +0 -0
  27. package/lib/module/icons/camera-off-android@2x.png +0 -0
  28. package/lib/module/icons/camera-off-android@3x.png +0 -0
  29. package/lib/module/icons/cpu-android.png +0 -0
  30. package/lib/module/icons/cpu-android@2x.png +0 -0
  31. package/lib/module/icons/cpu-android@3x.png +0 -0
  32. package/lib/module/icons/cpu-ios.png +0 -0
  33. package/lib/module/icons/cpu-ios@2x.png +0 -0
  34. package/lib/module/icons/cpu-ios@3x.png +0 -0
  35. package/lib/module/icons/lock-android.png +0 -0
  36. package/lib/module/icons/lock-android@2x.png +0 -0
  37. package/lib/module/icons/lock-android@3x.png +0 -0
  38. package/lib/module/icons/lock-ios.png +0 -0
  39. package/lib/module/icons/lock-ios@2x.png +0 -0
  40. package/lib/module/icons/lock-ios@3x.png +0 -0
  41. package/lib/module/icons/mic-off-android.png +0 -0
  42. package/lib/module/icons/mic-off-android@2x.png +0 -0
  43. package/lib/module/icons/mic-off-android@3x.png +0 -0
  44. package/lib/module/icons/mic-slash-ios.png +0 -0
  45. package/lib/module/icons/mic-slash-ios@2x.png +0 -0
  46. package/lib/module/icons/mic-slash-ios@3x.png +0 -0
  47. package/lib/module/icons/video-slash-ios.png +0 -0
  48. package/lib/module/icons/video-slash-ios@2x.png +0 -0
  49. package/lib/module/icons/video-slash-ios@3x.png +0 -0
  50. package/lib/module/index.js +11 -6
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/module/sdk/Bridge.js +236 -0
  53. package/lib/module/sdk/Bridge.js.map +1 -0
  54. package/lib/module/sdk/Event.js +160 -0
  55. package/lib/module/sdk/Event.js.map +1 -0
  56. package/lib/module/sdk/Lifecycle.js +331 -0
  57. package/lib/module/sdk/Lifecycle.js.map +1 -0
  58. package/lib/module/sdk/LiveVoiceSdk.js +262 -268
  59. package/lib/module/sdk/LiveVoiceSdk.js.map +1 -1
  60. package/lib/module/sdk/LiveVoiceState.js +208 -40
  61. package/lib/module/sdk/LiveVoiceState.js.map +1 -1
  62. package/lib/module/sdk/LogEntries.js +99 -0
  63. package/lib/module/sdk/LogEntries.js.map +1 -0
  64. package/lib/module/sdk/Models.js +2 -0
  65. package/lib/module/{util/UIState.js.map → sdk/Models.js.map} +1 -1
  66. package/lib/module/{util/PlayingState.js → sdk/NativeSdkVersions.js} +9 -8
  67. package/lib/module/sdk/NativeSdkVersions.js.map +1 -0
  68. package/lib/module/sdk/Observables.js +391 -0
  69. package/lib/module/sdk/Observables.js.map +1 -0
  70. package/lib/module/sdk/Passwords.js +298 -0
  71. package/lib/module/sdk/Passwords.js.map +1 -0
  72. package/lib/module/sdk/Playback.js +35 -0
  73. package/lib/module/sdk/Playback.js.map +1 -0
  74. package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
  75. package/lib/module/util/Colors.js +2 -1
  76. package/lib/module/util/Colors.js.map +1 -1
  77. package/lib/module/util/Translations.js +34 -11
  78. package/lib/module/util/Translations.js.map +1 -1
  79. package/lib/module/util/freeze.js +26 -0
  80. package/lib/module/util/freeze.js.map +1 -0
  81. package/lib/module/util/logger.js +79 -41
  82. package/lib/module/util/logger.js.map +1 -1
  83. package/lib/typescript/src/components/BrandingView.d.ts +4 -0
  84. package/lib/typescript/src/components/BrandingView.d.ts.map +1 -1
  85. package/lib/typescript/src/components/ChannelView.d.ts +29 -3
  86. package/lib/typescript/src/components/ChannelView.d.ts.map +1 -1
  87. package/lib/typescript/src/components/ErrorView.d.ts +5 -3
  88. package/lib/typescript/src/components/ErrorView.d.ts.map +1 -1
  89. package/lib/typescript/src/components/LiveVoiceSpinner.d.ts +16 -0
  90. package/lib/typescript/src/components/LiveVoiceSpinner.d.ts.map +1 -0
  91. package/lib/typescript/src/components/LiveVoiceView.d.ts +81 -21
  92. package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -1
  93. package/lib/typescript/src/components/PasswordPrompt.d.ts +13 -0
  94. package/lib/typescript/src/components/PasswordPrompt.d.ts.map +1 -0
  95. package/lib/typescript/src/components/PlayButtonView.d.ts +12 -329
  96. package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -1
  97. package/lib/typescript/src/components/ReconnectingView.d.ts +6 -3
  98. package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -1
  99. package/lib/typescript/src/index.d.ts +15 -6
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/sdk/Bridge.d.ts +36 -0
  102. package/lib/typescript/src/sdk/Bridge.d.ts.map +1 -0
  103. package/lib/typescript/src/sdk/Event.d.ts +97 -0
  104. package/lib/typescript/src/sdk/Event.d.ts.map +1 -0
  105. package/lib/typescript/src/sdk/Lifecycle.d.ts +191 -0
  106. package/lib/typescript/src/sdk/Lifecycle.d.ts.map +1 -0
  107. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +195 -190
  108. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -1
  109. package/lib/typescript/src/sdk/LiveVoiceState.d.ts +77 -9
  110. package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -1
  111. package/lib/typescript/src/sdk/LogEntries.d.ts +28 -0
  112. package/lib/typescript/src/sdk/LogEntries.d.ts.map +1 -0
  113. package/lib/typescript/src/sdk/Models.d.ts +114 -0
  114. package/lib/typescript/src/sdk/Models.d.ts.map +1 -0
  115. package/lib/typescript/src/sdk/NativeSdkVersions.d.ts +6 -0
  116. package/lib/typescript/src/sdk/NativeSdkVersions.d.ts.map +1 -0
  117. package/lib/typescript/src/sdk/Observables.d.ts +123 -0
  118. package/lib/typescript/src/sdk/Observables.d.ts.map +1 -0
  119. package/lib/typescript/src/sdk/Passwords.d.ts +72 -0
  120. package/lib/typescript/src/sdk/Passwords.d.ts.map +1 -0
  121. package/lib/typescript/src/sdk/Playback.d.ts +9 -0
  122. package/lib/typescript/src/sdk/Playback.d.ts.map +1 -0
  123. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts +34 -31
  124. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -1
  125. package/lib/typescript/src/util/Colors.d.ts.map +1 -1
  126. package/lib/typescript/src/util/Translations.d.ts +30 -8
  127. package/lib/typescript/src/util/Translations.d.ts.map +1 -1
  128. package/lib/typescript/src/util/freeze.d.ts +6 -0
  129. package/lib/typescript/src/util/freeze.d.ts.map +1 -0
  130. package/lib/typescript/src/util/logger.d.ts +17 -7
  131. package/lib/typescript/src/util/logger.d.ts.map +1 -1
  132. package/livevoice-sdk-react-native.podspec +29 -4
  133. package/package.json +12 -9
  134. package/src/components/BrandingView.tsx +42 -55
  135. package/src/components/ChannelView.tsx +329 -38
  136. package/src/components/ErrorView.tsx +9 -12
  137. package/src/components/LiveVoiceSpinner.tsx +87 -0
  138. package/src/components/LiveVoiceView.tsx +319 -201
  139. package/src/components/PasswordPrompt.tsx +144 -0
  140. package/src/components/PlayButtonView.tsx +165 -269
  141. package/src/components/ReconnectingView.tsx +28 -81
  142. package/src/icons/branding-ios.png +0 -0
  143. package/src/icons/camera-off-android.png +0 -0
  144. package/src/icons/camera-off-android@2x.png +0 -0
  145. package/src/icons/camera-off-android@3x.png +0 -0
  146. package/src/icons/cpu-android.png +0 -0
  147. package/src/icons/cpu-android@2x.png +0 -0
  148. package/src/icons/cpu-android@3x.png +0 -0
  149. package/src/icons/cpu-ios.png +0 -0
  150. package/src/icons/cpu-ios@2x.png +0 -0
  151. package/src/icons/cpu-ios@3x.png +0 -0
  152. package/src/icons/lock-android.png +0 -0
  153. package/src/icons/lock-android@2x.png +0 -0
  154. package/src/icons/lock-android@3x.png +0 -0
  155. package/src/icons/lock-ios.png +0 -0
  156. package/src/icons/lock-ios@2x.png +0 -0
  157. package/src/icons/lock-ios@3x.png +0 -0
  158. package/src/icons/mic-off-android.png +0 -0
  159. package/src/icons/mic-off-android@2x.png +0 -0
  160. package/src/icons/mic-off-android@3x.png +0 -0
  161. package/src/icons/mic-slash-ios.png +0 -0
  162. package/src/icons/mic-slash-ios@2x.png +0 -0
  163. package/src/icons/mic-slash-ios@3x.png +0 -0
  164. package/src/icons/video-slash-ios.png +0 -0
  165. package/src/icons/video-slash-ios@2x.png +0 -0
  166. package/src/icons/video-slash-ios@3x.png +0 -0
  167. package/src/index.tsx +92 -6
  168. package/src/sdk/Bridge.ts +259 -0
  169. package/src/sdk/Event.ts +187 -0
  170. package/src/sdk/Lifecycle.ts +366 -0
  171. package/src/sdk/LiveVoiceSdk.ts +285 -309
  172. package/src/sdk/LiveVoiceState.ts +230 -60
  173. package/src/sdk/LogEntries.ts +88 -0
  174. package/src/sdk/Models.ts +129 -0
  175. package/src/{util/PlayingState.ts → sdk/NativeSdkVersions.ts} +7 -6
  176. package/src/sdk/Observables.ts +414 -0
  177. package/src/sdk/Passwords.ts +286 -0
  178. package/src/sdk/Playback.ts +30 -0
  179. package/src/specs/NativeLiveVoiceSdk.ts +42 -38
  180. package/src/util/Colors.ts +2 -1
  181. package/src/util/Translations.ts +34 -12
  182. package/src/util/freeze.ts +23 -0
  183. package/src/util/logger.ts +79 -52
  184. package/lib/module/components/AudioOutputSwitchView.js +0 -138
  185. package/lib/module/components/AudioOutputSwitchView.js.map +0 -1
  186. package/lib/module/components/index.js +0 -24
  187. package/lib/module/components/index.js.map +0 -1
  188. package/lib/module/icons/mic.png +0 -0
  189. package/lib/module/util/ForegroundServiceConfig.js +0 -38
  190. package/lib/module/util/ForegroundServiceConfig.js.map +0 -1
  191. package/lib/module/util/PlayingState.js.map +0 -1
  192. package/lib/module/util/UIState.js +0 -4
  193. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts +0 -6
  194. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  195. package/lib/typescript/src/components/index.d.ts +0 -9
  196. package/lib/typescript/src/components/index.d.ts.map +0 -1
  197. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +0 -19
  198. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  199. package/lib/typescript/src/util/PlayingState.d.ts +0 -7
  200. package/lib/typescript/src/util/PlayingState.d.ts.map +0 -1
  201. package/lib/typescript/src/util/UIState.d.ts +0 -86
  202. package/lib/typescript/src/util/UIState.d.ts.map +0 -1
  203. package/src/components/AudioOutputSwitchView.tsx +0 -146
  204. package/src/components/index.tsx +0 -21
  205. package/src/icons/mic.png +0 -0
  206. package/src/util/ForegroundServiceConfig.tsx +0 -42
  207. package/src/util/UIState.ts +0 -106
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+
3
+ //===----------------------------------------------------------------------===//
4
+ //
5
+ // This source file is part of the LiveVoice SDK project
6
+ //
7
+ // Copyright (c) LiveVoice GmbH
8
+ // Licensed under the MIT license
9
+ //
10
+ // See LICENSE for license information
11
+ //
12
+ // SPDX-License-Identifier: MIT
13
+ //
14
+ //===----------------------------------------------------------------------===//
15
+
16
+ // The joined event, its requestable languages and its linked events (bridge.md 2.9 to 2.11, 3.3).
17
+ // The lists need the custom-UI permission of the joined key, and so do their commands; native
18
+ // decides both. Their values are observed through Observables.ts.
19
+
20
+ import { awaitRevisions, record } from "./Bridge.js";
21
+ import { invoke, usageError } from "./Lifecycle.js";
22
+
23
+ /** An event's colours, `'#RRGGBB'`, for the light and the dark appearance. */
24
+
25
+ /** The joined event. */
26
+
27
+ /**
28
+ * Where a requestable language stands:
29
+ * - `requestable`: it can be requested.
30
+ * - `requested`: a request is on its way, or the server confirmed or accepted it and its channel
31
+ * has not arrived yet. Requests of other listeners count.
32
+ * - `available`: an AI translation of the channel the requests translate exists in that
33
+ * language. A channel translating another channel does not count.
34
+ * - `unavailable`: the event excludes it, because it is spoken on the channel the requests
35
+ * translate.
36
+ */
37
+
38
+ /** A language listeners can ask the event to add. */
39
+
40
+ /** An event linked to the joined one, to switch to with {@link switchToLinkedEvent}. */
41
+
42
+ /**
43
+ * Asks the event to add a language and resolves once the server confirmed the request.
44
+ *
45
+ * The language shows `requested` in {@link getCurrentRequestableLanguages} shortly after, and
46
+ * what happens next shows there too. It never starts playback. Needs a `ready` connection and an
47
+ * API key that permits custom UI.
48
+ *
49
+ * @param languageCode - The `languageCode` of a language in state `requestable`.
50
+ * @throws {LiveVoiceError} `not_joined` unless the connection is `ready`; `api_key_invalid`
51
+ * without the custom-UI permission; `invalid_argument` for a code that is unknown or not
52
+ * requestable (also one already requested); `timed_out` when the server does not confirm within
53
+ * 10 seconds (the request may still exist); `network_failed`; `cancelled` when a leave, a new
54
+ * join or a switch ended it; `generic` with `detail.reason` `language_request_declined` or
55
+ * `language_request_failed`. See {@link LiveVoiceErrorCode}.
56
+ */
57
+ export async function requestLanguage(languageCode) {
58
+ await invoke('requestLanguage', {
59
+ languageCode: validCode(languageCode, 'requestLanguage')
60
+ });
61
+ }
62
+
63
+ /**
64
+ * Withdraws the request for a language and resolves once the server confirmed the cancellation.
65
+ *
66
+ * The language shows `requestable` in {@link getCurrentRequestableLanguages} shortly after. A
67
+ * second cancellation of the same language waits for the first. Needs a `ready` connection and
68
+ * an API key that permits custom UI.
69
+ *
70
+ * @param languageCode - The `languageCode` of a language in state `requested`.
71
+ * @throws {LiveVoiceError} `not_joined` unless the connection is `ready`; `api_key_invalid`
72
+ * without the custom-UI permission; `invalid_argument` for a code that is unknown or not
73
+ * requested; `command_in_progress` while your own request for it is still being sent; `generic`
74
+ * with `detail.reason` `language_request_resolved` when the server decided first; `timed_out`
75
+ * when the server does not confirm within 10 seconds; `network_failed`; `cancelled` when a leave,
76
+ * a new join or a switch ended it; otherwise as {@link requestLanguage}. See
77
+ * {@link LiveVoiceErrorCode}.
78
+ */
79
+ export async function cancelLanguageRequest(languageCode) {
80
+ await invoke('cancelLanguageRequest', {
81
+ languageCode: validCode(languageCode, 'cancelLanguageRequest')
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Switches to a linked event and resolves once it is ready, with the same guarantees as
87
+ * `joinEvent`. Needs a `ready` connection and an API key that permits custom UI.
88
+ *
89
+ * When the promise resolves, the observed values already show the linked event, or the result of
90
+ * a newer call. Until then the connection is `joining` and the current event and its lists are
91
+ * `null`. After a completed switch the joined event stays valid: its `leave()` leaves the linked
92
+ * event. A leave while the switch is pending ends it with `cancelled` and leaves the event.
93
+ *
94
+ * A failed switch does not return to the previous event: the connection is `failed`, and
95
+ * `reconnect()` tries the linked event again if the error is retryable. The event is not checked
96
+ * against the linked events, so any event you have a join code for works.
97
+ *
98
+ * @param event - The event to switch to, usually one of {@link getCurrentLinkedEvents}.
99
+ * @throws {LiveVoiceError} `not_joined` when no event is ready and no switch is pending, also
100
+ * while reconnecting (the reconnect continues); `api_key_invalid` without the custom-UI
101
+ * permission; `superseded` when a newer switch or join replaced it; `cancelled` when a leave
102
+ * ended it; `timed_out` when the linked event was not ready within 30 seconds; otherwise why the
103
+ * join failed, such as `event_not_found`. See {@link LiveVoiceErrorCode}.
104
+ */
105
+ export async function switchToLinkedEvent(event) {
106
+ if (event == null || typeof event !== 'object' || typeof event.eventId !== 'number' || !Number.isSafeInteger(event.eventId) || event.eventId <= 0 || typeof event.name !== 'string' || typeof event.joinCode !== 'string' || !event.joinCode.trim()) {
107
+ throw usageError('invalid_argument', 'switchToLinkedEvent', 'A linked event needs a positive event id, a name and a non-empty join code.');
108
+ }
109
+ const reply = await invoke('switchToLinkedEvent', {
110
+ eventId: event.eventId,
111
+ name: event.name,
112
+ joinCode: event.joinCode
113
+ });
114
+ // When the switch resolves, the values already show the linked event (18 item 110).
115
+ await awaitRevisions(record(reply) ? reply.revisions : undefined);
116
+ }
117
+ function validCode(languageCode, operation) {
118
+ if (typeof languageCode !== 'string' || !languageCode.trim()) {
119
+ throw usageError('invalid_argument', operation, 'A language code is a non-empty string.');
120
+ }
121
+ return languageCode;
122
+ }
123
+
124
+ // The wire's values (bridge.md 2.9 to 2.11). Each decoder throws for a value it cannot read, so the
125
+ // last good value stays.
126
+
127
+ export function decodeEvent(wire) {
128
+ if (wire === null) return null;
129
+ if (!record(wire) || typeof wire.eventId !== 'number' || typeof wire.name !== 'string') throw new TypeError('currentEvent');
130
+ const colors = wire.brandColors;
131
+ return {
132
+ eventId: wire.eventId,
133
+ name: wire.name,
134
+ brandColors: record(colors) && typeof colors.light === 'string' && typeof colors.dark === 'string' ? {
135
+ light: colors.light,
136
+ dark: colors.dark
137
+ } : null
138
+ };
139
+ }
140
+ const languageStates = ['requestable', 'requested', 'available', 'unavailable'];
141
+ export function decodeLanguages(wire) {
142
+ if (wire === null) return null;
143
+ if (!Array.isArray(wire)) throw new TypeError('requestableLanguages');
144
+ return wire.filter(record).flatMap(language => typeof language.languageCode === 'string' && typeof language.localizedName === 'string' && typeof language.autonym === 'string' && typeof language.state === 'string' && languageStates.includes(language.state) ? [{
145
+ languageCode: language.languageCode,
146
+ localizedName: language.localizedName,
147
+ autonym: language.autonym,
148
+ state: language.state
149
+ }] : []);
150
+ }
151
+ export function decodeLinkedEvents(wire) {
152
+ if (wire === null) return null;
153
+ if (!Array.isArray(wire)) throw new TypeError('linkedEvents');
154
+ return wire.filter(record).flatMap(event => typeof event.eventId === 'number' && typeof event.name === 'string' && typeof event.joinCode === 'string' ? [{
155
+ eventId: event.eventId,
156
+ name: event.name,
157
+ joinCode: event.joinCode
158
+ }] : []);
159
+ }
160
+ //# sourceMappingURL=Event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["awaitRevisions","record","invoke","usageError","requestLanguage","languageCode","validCode","cancelLanguageRequest","switchToLinkedEvent","event","eventId","Number","isSafeInteger","name","joinCode","trim","reply","revisions","undefined","operation","decodeEvent","wire","TypeError","colors","brandColors","light","dark","languageStates","decodeLanguages","Array","isArray","filter","flatMap","language","localizedName","autonym","state","includes","decodeLinkedEvents"],"sourceRoot":"../../../src","sources":["sdk/Event.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAASA,cAAc,EAAEC,MAAM,QAAQ,aAAU;AACjD,SAASC,MAAM,EAAEC,UAAU,QAAQ,gBAAa;;AAEhD;;AAMA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAUA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,eAAeA,CAACC,YAAoB,EAAiB;EACzE,MAAMH,MAAM,CAAC,iBAAiB,EAAE;IAAEG,YAAY,EAAEC,SAAS,CAACD,YAAY,EAAE,iBAAiB;EAAE,CAAC,CAAC;AAC/F;;AAEA;AACA;AACA;AACA;AACA;AACA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QAAQ,CAACE,OAAO,KAAK,QAAQ,IAAI,OAAOF,QAAQ,CAACG,KAAK,KAAK,QAAQ,IAAIT,cAAc,CAACU,QAAQ,CAACJ,QAAQ,CAACG,KAAK,CAAC,GACjH,CAAC;IACC/B,YAAY,EAAE4B,QAAQ,CAAC5B,YAAY;IACnC6B,aAAa,EAAED,QAAQ,CAACC,aAAa;IACrCC,OAAO,EAAEF,QAAQ,CAACE,OAAO;IACzBC,KAAK,EAAEH,QAAQ,CAACG;EAClB,CAAC,CAAC,GACF,EAAE,CAAC;AACX;AAEA,OAAO,SAASE,kBAAkBA,CAACjB,IAAa,EAAiC;EAC/E,IAAIA,IAAI,KAAK,IAAI,EAAE,OAAO,IAAI;EAC9B,IAAI,CAACQ,KAAK,CAACC,OAAO,CAACT,IAAI,CAAC,EAAE,MAAM,IAAIC,SAAS,CAAC,cAAc,CAAC;EAC7D,OAAOD,IAAI,CAACU,MAAM,CAAC9B,MAAM,CAAC,CAAC+B,OAAO,CAACvB,KAAK,IACtC,OAAOA,KAAK,CAACC,OAAO,KAAK,QAAQ,IAAI,OAAOD,KAAK,CAACI,IAAI,KAAK,QAAQ,IAAI,OAAOJ,KAAK,CAACK,QAAQ,KAAK,QAAQ,GACrG,CAAC;IAAEJ,OAAO,EAAED,KAAK,CAACC,OAAO;IAAEG,IAAI,EAAEJ,KAAK,CAACI,IAAI;IAAEC,QAAQ,EAAEL,KAAK,CAACK;EAAS,CAAC,CAAC,GACxE,EAAE,CAAC;AACX","ignoreList":[]}
@@ -0,0 +1,331 @@
1
+ "use strict";
2
+
3
+ //===----------------------------------------------------------------------===//
4
+ //
5
+ // This source file is part of the LiveVoice SDK project
6
+ //
7
+ // Copyright (c) LiveVoice GmbH
8
+ // Licensed under the MIT license
9
+ //
10
+ // See LICENSE for license information
11
+ //
12
+ // SPDX-License-Identifier: MIT
13
+ //
14
+ //===----------------------------------------------------------------------===//
15
+
16
+ import Native from "../specs/NativeLiveVoiceSdk.js";
17
+ import { logDecodeError, logInfo, LiveVoiceLogEvent, writeLogEntry } from "../util/logger.js";
18
+ import { awaitRevisions, errorMessage, isInitialized, record as object } from "./Bridge.js";
19
+
20
+ /** Every {@link LiveVoiceErrorCode}, for example to check a value at runtime. */
21
+ export const liveVoiceErrorCodes = ['not_initialized', 'not_joined', 'invalid_argument', 'superseded', 'cancelled', 'timed_out', 'leave_incomplete', 'command_in_progress', 'api_key_invalid', 'event_not_found', 'event_inactive', 'wrong_password', 'listener_limit_reached', 'network_failed', 'no_network', 'generic', 'password_required', 'unsupported_sdk', 'channel_password_required', 'channel_wrong_password', 'channel_limit_reached', 'channel_unavailable', 'channel_forbidden', 'channel_offline'];
22
+
23
+ /**
24
+ * What went wrong, the same codes on every platform. Each call names the codes specific to it.
25
+ *
26
+ * Commands:
27
+ * - `not_initialized`: a call that needs `initialize()` was made before it resolved. Reading
28
+ * values, adding listeners and some setters work before it.
29
+ * - `invalid_argument`: an argument is malformed, or not allowed in the current state.
30
+ * - `not_joined`: the connection is not in a state the call allows; most calls need `ready`.
31
+ * - `superseded`: a newer call replaced a `joinEvent`, `reconnect` or `switchToLinkedEvent`. No
32
+ * other call fails with it.
33
+ * - `cancelled`: a leave, a newer command or a new join ended the call. Like `superseded` it
34
+ * needs no message to the user.
35
+ * - `timed_out`: no result within 30 seconds (join, switch, reconnect) or 10 seconds (a start or
36
+ * stop of playback, a subtitle start, the language calls).
37
+ * - `leave_incomplete`: local cleanup or an earlier stop has not finished within its deadline of
38
+ * 5 seconds. It comes from a leave (the event is left all the same), from a stop of playback
39
+ * while joining or failed, and from a start waiting behind an unfinished stop, which can be a
40
+ * stop in the current event. The cleanup is never abandoned; it continues.
41
+ * - `command_in_progress`: the same command is still running: an identical subtitle start, or
42
+ * the request a cancellation is meant to withdraw.
43
+ *
44
+ * Joining: `api_key_invalid` (also when the key does not permit custom UI, for a custom cell,
45
+ * `switchToLinkedEvent` and the language calls), `event_not_found`, `event_inactive`,
46
+ * `password_required` (no password was given), `wrong_password` (one was given and rejected),
47
+ * `listener_limit_reached`, `network_failed` (the connection failed or was lost, also before a
48
+ * call could reach the server), `no_network`, `unsupported_sdk` (the server requires a newer SDK,
49
+ * or the installed native SDK is not the version this package was built for), `generic` (see
50
+ * `detail.reason`).
51
+ *
52
+ * Channels and subtitles: `channel_password_required`, `channel_wrong_password`,
53
+ * `channel_limit_reached` (`detail.limitReason` is `participant` or `viewer`), `channel_offline`
54
+ * (a start of playback only; an offline channel's subtitles can be started),
55
+ * `channel_unavailable` (not part of the event, without audio, or a start of playback while
56
+ * reconnecting), `channel_forbidden`.
57
+ */
58
+
59
+ /** Optional details of an error. */
60
+
61
+ /** The codes worth trying again: the cause can go away by itself or with the user's help. */
62
+ const retryableCodes = new Set(['timed_out', 'event_inactive', 'wrong_password', 'password_required', 'listener_limit_reached', 'network_failed', 'no_network', 'channel_password_required', 'channel_wrong_password', 'channel_limit_reached', 'channel_offline']);
63
+ function knownCode(value) {
64
+ return typeof value === 'string' && liveVoiceErrorCodes.includes(value);
65
+ }
66
+ function typedDetail(value) {
67
+ if (!object(value)) return {};
68
+ const detail = {};
69
+ if (typeof value.httpStatus === 'number') detail.httpStatus = value.httpStatus;
70
+ if (typeof value.platformCode === 'number') detail.platformCode = value.platformCode;
71
+ if (typeof value.limitReason === 'string') detail.limitReason = value.limitReason;
72
+ if (typeof value.reason === 'string') detail.reason = value.reason;
73
+ return detail;
74
+ }
75
+ function wireError(value) {
76
+ if (!object(value) || !knownCode(value.code)) {
77
+ return new LiveVoiceError('generic', {
78
+ detail: {
79
+ reason: 'unknown_native_error'
80
+ }
81
+ });
82
+ }
83
+ return new LiveVoiceError(value.code, {
84
+ detail: typedDetail(value.detail),
85
+ message: typeof value.message === 'string' ? value.message : null
86
+ });
87
+ }
88
+
89
+ /**
90
+ * The error every LiveVoice call rejects with, and the one a `failed` connection carries. Its
91
+ * `message` is localised text to show as is. Codes only a developer can fix (`invalid_argument`,
92
+ * `not_initialized`, `api_key_invalid`, `unsupported_sdk`) share a generic text; the SDK log
93
+ * explains them.
94
+ */
95
+ export class LiveVoiceError extends Error {
96
+ /** What went wrong; stable, for your own handling. */
97
+
98
+ /** Whether trying again can succeed; it follows from the code. */
99
+
100
+ /** Optional details, `{}` when there are none. */
101
+
102
+ /**
103
+ * Creates an error, for tests and previews.
104
+ *
105
+ * @param code - What went wrong; `isRetryable` follows from it.
106
+ * @param options - `detail`: extra information for some codes. `message`: the text to show;
107
+ * leave it out or pass `null` for the code's localised text.
108
+ */
109
+ constructor(code, options = {}) {
110
+ super(options?.message ?? (errorMessage(code) || code));
111
+ this.name = 'LiveVoiceError';
112
+ this.code = code;
113
+ this.isRetryable = retryableCodes.has(code);
114
+ this.detail = Object.freeze(typedDetail(options?.detail));
115
+ }
116
+ }
117
+
118
+ /** When the next reconnect attempt runs. */
119
+
120
+ /**
121
+ * The connection to the event:
122
+ * - `idle`: nothing is joined or joining; also before `initialize()`.
123
+ * - `joining`: a join, a switch to a linked event, or the retry of a failed join is in progress.
124
+ * - `ready`: the event `eventId` is joined.
125
+ * - `reconnecting`: the connection was lost and is recovering; see `retry`. A `reconnect()` that
126
+ * times out leaves it here, and recovery continues.
127
+ * - `leaving`: a leave is running.
128
+ * - `failed`: a join, a switch or the retry of a join failed, or the joined event ended, with
129
+ * `error`. The join is kept: `reconnect()` retries it if the error is retryable, and
130
+ * `stopChannel` and `stopSubtitles` still work. It stays until that retry, a new join or a
131
+ * leave.
132
+ *
133
+ * Use it for display. To know that a call completed, await the call.
134
+ */
135
+
136
+ /** What `joinEvent` joins with. */
137
+
138
+ /**
139
+ * The joined event `joinEvent` returns. It follows a completed switch to a linked event.
140
+ *
141
+ * Its `leave()` leaves only the join this came from, including a linked event it switched to; it
142
+ * can never leave a newer join. If a newer join replaced its join, it does nothing and resolves at
143
+ * once. Otherwise it resolves as `leaveEvent` does: the event's local cleanup has ended, and the
144
+ * observed connection is `idle` unless a newer join exists. If its join was already left, it
145
+ * waits for that leave's cleanup.
146
+ *
147
+ * `leave()` rejects with a {@link LiveVoiceError} `leave_incomplete` when the cleanup has not
148
+ * finished within 5 seconds; the event is left all the same and the cleanup continues. Another
149
+ * leave then waits for the same cleanup and can fail with `leave_incomplete` again.
150
+ */
151
+
152
+ export function normalizeError(error) {
153
+ if (error instanceof LiveVoiceError) return error;
154
+ const native = object(error) ? error : {};
155
+ try {
156
+ const wire = JSON.parse(typeof native.message === 'string' ? native.message : '');
157
+ if (object(wire) && typeof wire.code === 'string') return wireError(wire);
158
+ } catch {/* Non-SDK failures retain a stable fallback. */}
159
+ return wireError(native);
160
+ }
161
+
162
+ /**
163
+ * A developer-only error the wrapper throws itself (bridge.md 3.6): its message is the generic
164
+ * text, and its explanation, a fixed sentence without argument values, goes to the SDK log as
165
+ * `LV_USAGE_ERROR`.
166
+ */
167
+ export function usageError(code, operation, explanation) {
168
+ writeLogEntry('LV_USAGE_ERROR', 'error', {
169
+ code,
170
+ operation,
171
+ explanation
172
+ });
173
+ return new LiveVoiceError(code);
174
+ }
175
+
176
+ /** The public call behind each command, for the log. */
177
+ const operations = {
178
+ join: 'joinEvent',
179
+ leave: 'leaveEvent'
180
+ };
181
+
182
+ /**
183
+ * Runs `command` natively. Before `initialize()` it fails with `not_initialized` without reaching
184
+ * native, the only error the wrapper owns (bridge.md 3.1). A reply that is not JSON resolves as
185
+ * `undefined`: native succeeded, so the call does too.
186
+ */
187
+ export async function invoke(command, args = {}) {
188
+ if (!isInitialized()) {
189
+ throw usageError('not_initialized', operations[command] ?? command, 'Call initialize() and await it first.');
190
+ }
191
+ let reply;
192
+ try {
193
+ reply = await Native.execute(command, JSON.stringify(args));
194
+ } catch (error) {
195
+ throw normalizeError(error);
196
+ }
197
+ try {
198
+ return JSON.parse(reply);
199
+ } catch {
200
+ logDecodeError('reply', command);
201
+ return undefined;
202
+ }
203
+ }
204
+ export async function join(request) {
205
+ if (!request || typeof request.joinCode !== 'string' || !request.joinCode.trim() || typeof request.apiKey !== 'string' || !request.apiKey.trim() || request.password != null && typeof request.password !== 'string') {
206
+ throw usageError('invalid_argument', 'joinEvent', 'The join request needs a non-empty join code and API key, and a password that is a string or null.');
207
+ }
208
+ logInfo(LiveVoiceLogEvent.joinRequest, {
209
+ joinCode: request.joinCode,
210
+ hasPassword: request.password != null
211
+ });
212
+ const result = await invoke('join', {
213
+ joinCode: request.joinCode,
214
+ password: request.password,
215
+ apiKey: request.apiKey
216
+ });
217
+ if (!object(result) || typeof result.entryId !== 'string' || !result.entryId.trim()) {
218
+ logDecodeError('reply', 'join');
219
+ throw new LiveVoiceError('generic', {
220
+ detail: {
221
+ reason: 'invalid_join_receipt'
222
+ }
223
+ });
224
+ }
225
+ const {
226
+ entryId
227
+ } = result;
228
+ // When joinEvent() resolves, the values already show the joined event (18 item 110).
229
+ await awaitRevisions(result.revisions);
230
+ let leaving;
231
+ return Object.freeze({
232
+ // When leave() resolves, the values already show what it left behind, as after a join.
233
+ leave: () => leaving ??= invoke('leave', {
234
+ entryId
235
+ }).then(reply => awaitRevisions(object(reply) ? reply.revisions : undefined), error => {
236
+ leaving = undefined;
237
+ throw error;
238
+ })
239
+ });
240
+ }
241
+ export function channelId(id, operation) {
242
+ if (!Number.isSafeInteger(id) || id <= 0) {
243
+ throw usageError('invalid_argument', operation, 'A channel id is a positive safe integer.');
244
+ }
245
+ return id;
246
+ }
247
+
248
+ /** A retry as the cache keeps it: the time in milliseconds, so every delivery gets its own `Date`. */
249
+
250
+ /** The connection as the cache keeps it, with the retry time in milliseconds. */
251
+
252
+ /** The wire's retry, or `undefined` when it is malformed. */
253
+ export function decodeRetry(wire) {
254
+ if (object(wire) && wire.kind === 'inProgress') return {
255
+ kind: 'inProgress'
256
+ };
257
+ if (object(wire) && wire.kind === 'scheduled' && typeof wire.at === 'number' && Number.isSafeInteger(wire.at)) {
258
+ return {
259
+ kind: 'scheduled',
260
+ at: wire.at
261
+ };
262
+ }
263
+ return undefined;
264
+ }
265
+
266
+ /** A public retry, with a `Date` of its own. */
267
+ export function publicRetry(retry) {
268
+ return retry.kind === 'scheduled' ? {
269
+ kind: 'scheduled',
270
+ at: new Date(retry.at)
271
+ } : {
272
+ kind: 'inProgress'
273
+ };
274
+ }
275
+
276
+ /** The wire's error as a `LiveVoiceError`; anything else becomes `generic`. */
277
+ export function decodeError(wire) {
278
+ return wireError(wire);
279
+ }
280
+
281
+ /** The wire's connection (bridge.md 2.3); throws for one it cannot read. */
282
+ export function decodeConnection(wire) {
283
+ if (!object(wire)) throw new LiveVoiceError('generic');
284
+ switch (wire.status) {
285
+ case 'idle':
286
+ case 'joining':
287
+ case 'leaving':
288
+ return {
289
+ status: wire.status
290
+ };
291
+ case 'ready':
292
+ case 'reconnecting':
293
+ {
294
+ const eventId = wire.eventId;
295
+ if (typeof eventId !== 'number' || !Number.isSafeInteger(eventId) || eventId <= 0) throw new LiveVoiceError('generic');
296
+ if (wire.status === 'ready') return {
297
+ status: 'ready',
298
+ eventId
299
+ };
300
+ const retry = decodeRetry(wire.retry);
301
+ if (retry === undefined) throw new LiveVoiceError('generic');
302
+ return {
303
+ status: 'reconnecting',
304
+ eventId,
305
+ retry
306
+ };
307
+ }
308
+ case 'failed':
309
+ return {
310
+ status: 'failed',
311
+ error: wireError(wire.error)
312
+ };
313
+ default:
314
+ throw new LiveVoiceError('generic');
315
+ }
316
+ }
317
+
318
+ /**
319
+ * The public connection. A scheduled retry gets a `Date` of its own on every call, so changing one
320
+ * changes no other; every other connection is the cached value itself.
321
+ */
322
+ export function publicConnection(value) {
323
+ if (value.status === 'reconnecting' && value.retry.kind === 'scheduled') {
324
+ return Object.freeze({
325
+ ...value,
326
+ retry: Object.freeze(publicRetry(value.retry))
327
+ });
328
+ }
329
+ return value;
330
+ }
331
+ //# sourceMappingURL=Lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","logDecodeError","logInfo","LiveVoiceLogEvent","writeLogEntry","awaitRevisions","errorMessage","isInitialized","record","object","liveVoiceErrorCodes","retryableCodes","Set","knownCode","value","includes","typedDetail","detail","httpStatus","platformCode","limitReason","reason","wireError","code","LiveVoiceError","message","Error","constructor","options","name","isRetryable","has","Object","freeze","normalizeError","error","native","wire","JSON","parse","usageError","operation","explanation","operations","join","leave","invoke","command","args","reply","execute","stringify","undefined","request","joinCode","trim","apiKey","password","joinRequest","hasPassword","result","entryId","revisions","leaving","then","channelId","id","Number","isSafeInteger","decodeRetry","kind","at","publicRetry","retry","Date","decodeError","decodeConnection","status","eventId","publicConnection"],"sourceRoot":"../../../src","sources":["sdk/Lifecycle.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,gCAA6B;AAChD,SAASC,cAAc,EAAEC,OAAO,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,mBAAgB;AAC1F,SAASC,cAAc,EAAEC,YAAY,EAAEC,aAAa,EAAEC,MAAM,IAAIC,MAAM,QAAQ,aAAU;;AAExF;AACA,OAAO,MAAMC,mBAAmB,GAAG,CACjC,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,CACT;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAYA;AACA,MAAMC,cAA+C,GAAG,IAAIC,GAAG,CAAqB,CAClF,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,mBAAm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