@fishjam-cloud/react-native-client 0.1.0 → 0.2.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 (110) hide show
  1. package/README.md +403 -0
  2. package/android/build.gradle +6 -6
  3. package/app.plugin.js +1 -1
  4. package/build/RNFishjamClientModule.d.ts +7 -5
  5. package/build/RNFishjamClientModule.d.ts.map +1 -1
  6. package/build/RNFishjamClientModule.js.map +1 -1
  7. package/build/common/client.d.ts +8 -1
  8. package/build/common/client.d.ts.map +1 -1
  9. package/build/common/client.js +9 -2
  10. package/build/common/client.js.map +1 -1
  11. package/build/components/VideoPreviewView.d.ts +3 -3
  12. package/build/components/VideoPreviewView.d.ts.map +1 -1
  13. package/build/components/VideoPreviewView.js +1 -1
  14. package/build/components/VideoPreviewView.js.map +1 -1
  15. package/build/hooks/useAudioSettings.d.ts.map +1 -1
  16. package/build/hooks/useAudioSettings.js +4 -5
  17. package/build/hooks/useAudioSettings.js.map +1 -1
  18. package/build/hooks/useBandwidthEstimation.d.ts +0 -3
  19. package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
  20. package/build/hooks/useBandwidthEstimation.js +3 -6
  21. package/build/hooks/useBandwidthEstimation.js.map +1 -1
  22. package/build/hooks/useCamera.d.ts +12 -21
  23. package/build/hooks/useCamera.d.ts.map +1 -1
  24. package/build/hooks/useCamera.js +52 -52
  25. package/build/hooks/useCamera.js.map +1 -1
  26. package/build/{common/eventEmitter.d.ts → hooks/useFishjamEvent.d.ts} +2 -3
  27. package/build/hooks/useFishjamEvent.d.ts.map +1 -0
  28. package/build/{common/eventEmitter.js → hooks/useFishjamEvent.js} +11 -2
  29. package/build/hooks/useFishjamEvent.js.map +1 -0
  30. package/build/hooks/useMicrophone.d.ts.map +1 -1
  31. package/build/hooks/useMicrophone.js +3 -7
  32. package/build/hooks/useMicrophone.js.map +1 -1
  33. package/build/hooks/useParticipants.d.ts +0 -3
  34. package/build/hooks/useParticipants.d.ts.map +1 -1
  35. package/build/hooks/useParticipants.js +6 -6
  36. package/build/hooks/useParticipants.js.map +1 -1
  37. package/build/hooks/useReconnection.d.ts.map +1 -1
  38. package/build/hooks/useReconnection.js +8 -18
  39. package/build/hooks/useReconnection.js.map +1 -1
  40. package/build/hooks/useScreencast.d.ts.map +1 -1
  41. package/build/hooks/useScreencast.js +3 -7
  42. package/build/hooks/useScreencast.js.map +1 -1
  43. package/build/index.d.ts +4 -3
  44. package/build/index.d.ts.map +1 -1
  45. package/build/index.js +3 -1
  46. package/build/index.js.map +1 -1
  47. package/build/types.d.ts +25 -0
  48. package/build/types.d.ts.map +1 -1
  49. package/build/types.js +10 -1
  50. package/build/types.js.map +1 -1
  51. package/build/utils/foregroundService.d.ts +30 -0
  52. package/build/utils/foregroundService.d.ts.map +1 -0
  53. package/build/utils/foregroundService.js +41 -0
  54. package/build/utils/foregroundService.js.map +1 -0
  55. package/ios/RNFishjamClient.swift +37 -30
  56. package/ios/RNFishjamClientModule.swift +11 -7
  57. package/package.json +19 -19
  58. package/.eslintignore +0 -7
  59. package/.eslintrc +0 -6
  60. package/.prettierrc +0 -9
  61. package/.watchmanconfig +0 -1
  62. package/android/.editorconfig +0 -9
  63. package/android/src/main/AndroidManifest.xml +0 -2
  64. package/android/src/main/java/org/membraneframework/reactnative/AudioDeviceKind.kt +0 -34
  65. package/android/src/main/java/org/membraneframework/reactnative/AudioSwitchManager.kt +0 -61
  66. package/android/src/main/java/org/membraneframework/reactnative/EmitableEvents.kt +0 -14
  67. package/android/src/main/java/org/membraneframework/reactnative/Errors.kt +0 -31
  68. package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClient.kt +0 -866
  69. package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClientModule.kt +0 -294
  70. package/android/src/main/java/org/membraneframework/reactnative/Utils.kt +0 -11
  71. package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewView.kt +0 -40
  72. package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewViewModule.kt +0 -17
  73. package/android/src/main/java/org/membraneframework/reactnative/VideoRendererView.kt +0 -58
  74. package/android/src/main/java/org/membraneframework/reactnative/VideoRendererViewModule.kt +0 -25
  75. package/android/src/main/java/org/membraneframework/reactnative/VideoView.kt +0 -77
  76. package/babel.config.js +0 -2
  77. package/build/common/eventEmitter.d.ts.map +0 -1
  78. package/build/common/eventEmitter.js.map +0 -1
  79. package/expo-module.config.json +0 -17
  80. package/ios/RNFishjamClient.podspec +0 -30
  81. package/ios/swift-format-config.json +0 -56
  82. package/plugin/broadcastExtensionFiles/Info.plist +0 -27
  83. package/plugin/broadcastExtensionFiles/MembraneBroadcastSampleHandler.swift +0 -50
  84. package/plugin/broadcastExtensionFiles/MembraneScreenBroadcastExtension.entitlements +0 -10
  85. package/plugin/src/withMembrane.ts +0 -310
  86. package/plugin/tsconfig.json +0 -9
  87. package/scripts/lint.sh +0 -18
  88. package/scripts/lint_check.sh +0 -14
  89. package/src/RNFishjamClientModule.ts +0 -73
  90. package/src/__tests__/index.test.tsx +0 -199
  91. package/src/common/client.ts +0 -33
  92. package/src/common/eventEmitter.ts +0 -21
  93. package/src/common/metadata.ts +0 -12
  94. package/src/common/webRTC.ts +0 -31
  95. package/src/components/VideoPreviewView.tsx +0 -33
  96. package/src/components/VideoRendererView.tsx +0 -31
  97. package/src/hooks/useAudioSettings.ts +0 -115
  98. package/src/hooks/useBandwidthEstimation.ts +0 -24
  99. package/src/hooks/useCamera.ts +0 -270
  100. package/src/hooks/useMicrophone.ts +0 -38
  101. package/src/hooks/useParticipants.ts +0 -118
  102. package/src/hooks/useReconnection.ts +0 -41
  103. package/src/hooks/useScreencast.ts +0 -146
  104. package/src/index.tsx +0 -63
  105. package/src/protos/fishjam/peer_notifications.ts +0 -299
  106. package/src/stats/types.ts +0 -56
  107. package/src/stats/useRTCStatistics.ts +0 -97
  108. package/src/types.ts +0 -49
  109. package/tsconfig.json +0 -9
  110. package/typedoc.json +0 -5
@@ -1,118 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- import { GenericMetadata, TrackEncoding, TrackMetadata } from '../types';
4
- import RNFishjamClientModule from '../RNFishjamClientModule';
5
- import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
6
-
7
- export type TrackType = 'Audio' | 'Video';
8
-
9
- /**
10
- * Type describing Voice Activity Detection statuses.
11
- *
12
- * speech - voice activity has been detected
13
- * silence - lack of voice activity has been detected
14
- */
15
- export type VadStatus = 'silence' | 'speech';
16
-
17
- type TrackBase = {
18
- id: string;
19
- type: TrackType;
20
- isActive: boolean;
21
- };
22
-
23
- export type AudioTrack = TrackBase & {
24
- type: 'Audio';
25
- vadStatus: VadStatus | undefined;
26
- };
27
-
28
- export type VideoTrack = TrackBase & {
29
- type: 'Video';
30
- // Encoding that is currently received. Only present for remote tracks.
31
- encoding: TrackEncoding | null;
32
- // The reason of currently selected encoding. Only present for remote tracks.
33
- encodingReason: EncodingReason | null;
34
- };
35
-
36
- export type Track = VideoTrack | AudioTrack;
37
- /**
38
- * Type describing possible reasons of currently selected encoding.
39
- *
40
- * - other - the exact reason couldn't be determined
41
- * - encoding_inactive - previously selected encoding became inactive
42
- * - low_bandwidth - there is no longer enough bandwidth to maintain previously selected encoding
43
- */
44
- export type EncodingReason = 'other' | 'encoding_inactive' | 'low_bandwidth';
45
-
46
- export type Participant<
47
- ParticipantMetadata extends GenericMetadata = GenericMetadata,
48
- > = {
49
- /**
50
- * id used to identify a participant
51
- */
52
- id: string;
53
- /**
54
- * whether the participant is local or remote
55
- */
56
- isLocal: boolean;
57
- /**
58
- * a map indexed by strings, containing participant metadata from the server
59
- */
60
- metadata: ParticipantMetadata;
61
- /**
62
- * a list of participants's video and audio tracks
63
- */
64
- tracks: Track[];
65
- };
66
-
67
- export type ParticipantsUpdateEvent<
68
- ParticipantMetadata extends GenericMetadata = GenericMetadata,
69
- > = {
70
- PeersUpdate: Participant<ParticipantMetadata>[];
71
- };
72
-
73
- function addIsActiveToTracks<
74
- ParticipantMetadata extends GenericMetadata = GenericMetadata,
75
- >(
76
- participants: ReadonlyArray<Participant<ParticipantMetadata>>,
77
- ): Participant<ParticipantMetadata>[] {
78
- return participants.map((participant) => ({
79
- ...participant,
80
- tracks: participant.tracks.map((track) => ({
81
- ...track,
82
- isActive:
83
- (track as { metadata?: TrackMetadata })?.metadata?.active ?? true,
84
- })),
85
- }));
86
- }
87
- /**
88
- * This hook provides live updates of room participants.
89
- * @returns An array of room participants.
90
- */
91
- export function useParticipants<
92
- ParticipantMetadata extends GenericMetadata = GenericMetadata,
93
- >() {
94
- const [participants, setParticipants] = useState<
95
- Participant<ParticipantMetadata>[]
96
- >([]);
97
-
98
- useEffect(() => {
99
- async function updateParticipants() {
100
- const participants =
101
- await RNFishjamClientModule.getPeers<ParticipantMetadata>();
102
- setParticipants(addIsActiveToTracks<ParticipantMetadata>(participants));
103
- }
104
-
105
- const eventListener = eventEmitter.addListener<
106
- ParticipantsUpdateEvent<ParticipantMetadata>
107
- >(ReceivableEvents.PeersUpdate, (event) => {
108
- setParticipants(
109
- addIsActiveToTracks<ParticipantMetadata>(event.PeersUpdate),
110
- );
111
- });
112
-
113
- updateParticipants();
114
- return () => eventListener.remove();
115
- }, []);
116
-
117
- return { participants };
118
- }
@@ -1,41 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
3
-
4
- export type ReconnectionStatus = 'idle' | 'reconnecting' | 'error';
5
-
6
- export function useReconnection() {
7
- const [reconnectionStatus, setReconnectionStatus] =
8
- useState<ReconnectionStatus>('idle');
9
-
10
- useEffect(() => {
11
- const reconnectedEventListener = eventEmitter.addListener(
12
- ReceivableEvents.Reconnected,
13
- () => {
14
- setReconnectionStatus('idle');
15
- },
16
- );
17
-
18
- const reconnectionStartedEventListener = eventEmitter.addListener(
19
- ReceivableEvents.ReconnectionStarted,
20
- () => {
21
- setReconnectionStatus('reconnecting');
22
- },
23
- );
24
-
25
- const reconnectionRetriesLimitReachedEventListener =
26
- eventEmitter.addListener(
27
- ReceivableEvents.ReconnectionRetriesLimitReached,
28
- () => {
29
- setReconnectionStatus('error');
30
- },
31
- );
32
-
33
- return () => {
34
- reconnectedEventListener.remove();
35
- reconnectionStartedEventListener.remove();
36
- reconnectionRetriesLimitReachedEventListener.remove();
37
- };
38
- });
39
-
40
- return { reconnectionStatus };
41
- }
@@ -1,146 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
-
3
- import {
4
- BandwidthLimit,
5
- SimulcastConfig,
6
- TrackBandwidthLimit,
7
- TrackEncoding,
8
- TrackMetadata,
9
- } from '../types';
10
- import RNFishjamClientModule from '../RNFishjamClientModule';
11
- import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
12
- import { Platform } from 'react-native';
13
-
14
- type IsScreencastOnEvent = { IsScreencastOn: boolean };
15
-
16
- export type ScreencastQuality = 'VGA' | 'HD5' | 'HD15' | 'FHD15' | 'FHD30';
17
-
18
- export type ScreencastOptions = {
19
- /**
20
- * Resolution + fps of screencast track, one of: `VGA`, `HD5`, `HD15`, `FHD15`, `FHD30`.
21
- * Note that quality might be worse than specified due to device capabilities, internet
22
- * connection etc.
23
- * @default `HD15``
24
- */
25
- quality: ScreencastQuality;
26
- /**
27
- * bandwidth limit of a screencast track. By default there is no bandwidth limit.
28
- */
29
- maxBandwidth: TrackBandwidthLimit;
30
- };
31
- export type ScreencastOptionsInternal = {
32
- screencastMetadata: TrackMetadata & { displayName?: string };
33
- /**
34
- * SimulcastConfig of a screencast track. By default simulcast is disabled.
35
- */
36
- simulcastConfig: SimulcastConfig;
37
- };
38
-
39
- const defaultSimulcastConfig = () => ({
40
- enabled: false,
41
- activeEncodings: [],
42
- });
43
-
44
- let screencastSimulcastConfig: SimulcastConfig = defaultSimulcastConfig();
45
-
46
- /**
47
- * This hook can toggle screen sharing on/off and provides current screencast state.
48
- * @returns An object with functions to manage screencast.
49
- */
50
- export function useScreencast() {
51
- const [isScreencastOn, setIsScreencastOn] = useState<boolean>(
52
- RNFishjamClientModule.isScreencastOn,
53
- );
54
-
55
- const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(
56
- screencastSimulcastConfig,
57
- );
58
-
59
- useEffect(() => {
60
- const eventListener = eventEmitter.addListener<IsScreencastOnEvent>(
61
- ReceivableEvents.IsScreencastOn,
62
- (event) => setIsScreencastOn(event.IsScreencastOn),
63
- );
64
- setIsScreencastOn(RNFishjamClientModule.isScreencastOn);
65
- return () => eventListener.remove();
66
- }, []);
67
-
68
- /**
69
- * Toggles the screencast on/off
70
- */
71
- const toggleScreencast = useCallback(
72
- async (screencastOptions: Partial<ScreencastOptions> = {}) => {
73
- const options = {
74
- ...screencastOptions,
75
- screencastMetadata: {
76
- displayName: 'presenting',
77
- type: 'screensharing' as const,
78
- active: !isScreencastOn,
79
- },
80
- };
81
- await RNFishjamClientModule.toggleScreencast(options);
82
- screencastSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings
83
- setSimulcastConfig(screencastSimulcastConfig);
84
- },
85
- [isScreencastOn],
86
- );
87
-
88
- /**
89
- * Toggles simulcast encoding of a screencast track on/off
90
- * @param encoding encoding to toggle
91
- */
92
- const toggleScreencastTrackEncoding = useCallback(
93
- async (encoding: TrackEncoding) => {
94
- screencastSimulcastConfig =
95
- await RNFishjamClientModule.toggleScreencastTrackEncoding(encoding);
96
- setSimulcastConfig(screencastSimulcastConfig);
97
- },
98
- [],
99
- );
100
-
101
- /**
102
- * updates maximum bandwidth for the given simulcast encoding of the screencast track
103
- * @param encoding encoding to update
104
- * @param bandwidth BandwidthLimit to set
105
- */
106
- const setScreencastTrackEncodingBandwidth = useCallback(
107
- async (encoding: TrackEncoding, bandwidth: BandwidthLimit) => {
108
- await RNFishjamClientModule.setScreencastTrackEncodingBandwidth(
109
- encoding,
110
- bandwidth,
111
- );
112
- },
113
- [],
114
- );
115
-
116
- /**
117
- * updates maximum bandwidth for the screencast track. This value directly translates
118
- * to quality of the stream and the amount of RTP packets being sent. In case simulcast
119
- * is enabled bandwidth is split between all of the variant streams proportionally to
120
- * their resolution
121
- * @param bandwidth BandwidthLimit to set
122
- */
123
- const setScreencastTrackBandwidth = useCallback(
124
- async (bandwidth: BandwidthLimit) => {
125
- await RNFishjamClientModule.setScreencastTrackBandwidth(bandwidth);
126
- },
127
- [],
128
- );
129
-
130
- const handleScreencastPermission = useCallback(async () => {
131
- if (Platform.OS == 'android') {
132
- return await RNFishjamClientModule.handleScreencastPermission();
133
- }
134
- return 'denied';
135
- }, []);
136
-
137
- return {
138
- isScreencastOn,
139
- toggleScreencast,
140
- toggleScreencastTrackEncoding,
141
- simulcastConfig,
142
- setScreencastTrackEncodingBandwidth,
143
- setScreencastTrackBandwidth,
144
- handleScreencastPermission,
145
- };
146
- }
package/src/index.tsx DELETED
@@ -1,63 +0,0 @@
1
- export type {
2
- Participant,
3
- Track,
4
- TrackType,
5
- VadStatus,
6
- EncodingReason,
7
- } from './hooks/useParticipants';
8
- export { useParticipants } from './hooks/useParticipants';
9
-
10
- export type {
11
- AudioOutputDevice,
12
- AudioOutputDeviceType,
13
- AudioSessionMode,
14
- } from './hooks/useAudioSettings';
15
- export { useAudioSettings } from './hooks/useAudioSettings';
16
-
17
- export type { BandwidthEstimationEvent } from './hooks/useBandwidthEstimation';
18
- export { useBandwidthEstimation } from './hooks/useBandwidthEstimation';
19
-
20
- export type {
21
- CaptureDevice,
22
- CameraConfig,
23
- VideoQuality,
24
- } from './hooks/useCamera';
25
- export { useCamera } from './hooks/useCamera';
26
-
27
- export { useMicrophone } from './hooks/useMicrophone';
28
-
29
- export { useRTCStatistics } from './stats/useRTCStatistics';
30
-
31
- export type {
32
- ScreencastOptions,
33
- ScreencastQuality,
34
- } from './hooks/useScreencast';
35
- export { useScreencast } from './hooks/useScreencast';
36
-
37
- export type { ReconnectionStatus } from './hooks/useReconnection';
38
- export { useReconnection } from './hooks/useReconnection';
39
-
40
- export { updatePeerMetadata } from './common/metadata';
41
-
42
- export type { LoggingSeverity } from './common/webRTC';
43
- export {
44
- changeWebRTCLoggingSeverity,
45
- setTargetTrackEncoding,
46
- } from './common/webRTC';
47
-
48
- export { connect, leaveRoom } from './common/client';
49
-
50
- export type { VideoPreviewViewProps } from './components/VideoPreviewView';
51
- export { VideoPreviewView } from './components/VideoPreviewView';
52
-
53
- export type { VideoRendererProps } from './components/VideoRendererView';
54
- export { VideoRendererView } from './components/VideoRendererView';
55
-
56
- export type {
57
- TrackBandwidthLimit,
58
- TrackEncoding,
59
- SimulcastBandwidthLimit,
60
- BandwidthLimit,
61
- SimulcastConfig,
62
- VideoLayout,
63
- } from './types';
@@ -1,299 +0,0 @@
1
- // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
- // versions:
3
- // protoc-gen-ts_proto v1.178.0
4
- // protoc v5.26.1
5
- // source: protos/fishjam/peer_notifications.proto
6
-
7
- /* eslint-disable */
8
- import * as _m0 from "protobufjs/minimal";
9
-
10
- export const protobufPackage = "fishjam";
11
-
12
- /** Defines any type of message sent between FJ and a peer */
13
- export interface PeerMessage {
14
- authenticated?: PeerMessage_Authenticated | undefined;
15
- authRequest?: PeerMessage_AuthRequest | undefined;
16
- mediaEvent?: PeerMessage_MediaEvent | undefined;
17
- }
18
-
19
- /** Response sent by FJ, confirming successfull authentication */
20
- export interface PeerMessage_Authenticated {
21
- }
22
-
23
- /** Request sent by peer, to authenticate to FJ server */
24
- export interface PeerMessage_AuthRequest {
25
- token: string;
26
- }
27
-
28
- /** Any type of WebRTC messages passed betweend FJ and peer */
29
- export interface PeerMessage_MediaEvent {
30
- data: string;
31
- }
32
-
33
- function createBasePeerMessage(): PeerMessage {
34
- return { authenticated: undefined, authRequest: undefined, mediaEvent: undefined };
35
- }
36
-
37
- export const PeerMessage = {
38
- encode(message: PeerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
39
- if (message.authenticated !== undefined) {
40
- PeerMessage_Authenticated.encode(message.authenticated, writer.uint32(10).fork()).ldelim();
41
- }
42
- if (message.authRequest !== undefined) {
43
- PeerMessage_AuthRequest.encode(message.authRequest, writer.uint32(18).fork()).ldelim();
44
- }
45
- if (message.mediaEvent !== undefined) {
46
- PeerMessage_MediaEvent.encode(message.mediaEvent, writer.uint32(26).fork()).ldelim();
47
- }
48
- return writer;
49
- },
50
-
51
- decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage {
52
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
53
- let end = length === undefined ? reader.len : reader.pos + length;
54
- const message = createBasePeerMessage();
55
- while (reader.pos < end) {
56
- const tag = reader.uint32();
57
- switch (tag >>> 3) {
58
- case 1:
59
- if (tag !== 10) {
60
- break;
61
- }
62
-
63
- message.authenticated = PeerMessage_Authenticated.decode(reader, reader.uint32());
64
- continue;
65
- case 2:
66
- if (tag !== 18) {
67
- break;
68
- }
69
-
70
- message.authRequest = PeerMessage_AuthRequest.decode(reader, reader.uint32());
71
- continue;
72
- case 3:
73
- if (tag !== 26) {
74
- break;
75
- }
76
-
77
- message.mediaEvent = PeerMessage_MediaEvent.decode(reader, reader.uint32());
78
- continue;
79
- }
80
- if ((tag & 7) === 4 || tag === 0) {
81
- break;
82
- }
83
- reader.skipType(tag & 7);
84
- }
85
- return message;
86
- },
87
-
88
- fromJSON(object: any): PeerMessage {
89
- return {
90
- authenticated: isSet(object.authenticated) ? PeerMessage_Authenticated.fromJSON(object.authenticated) : undefined,
91
- authRequest: isSet(object.authRequest) ? PeerMessage_AuthRequest.fromJSON(object.authRequest) : undefined,
92
- mediaEvent: isSet(object.mediaEvent) ? PeerMessage_MediaEvent.fromJSON(object.mediaEvent) : undefined,
93
- };
94
- },
95
-
96
- toJSON(message: PeerMessage): unknown {
97
- const obj: any = {};
98
- if (message.authenticated !== undefined) {
99
- obj.authenticated = PeerMessage_Authenticated.toJSON(message.authenticated);
100
- }
101
- if (message.authRequest !== undefined) {
102
- obj.authRequest = PeerMessage_AuthRequest.toJSON(message.authRequest);
103
- }
104
- if (message.mediaEvent !== undefined) {
105
- obj.mediaEvent = PeerMessage_MediaEvent.toJSON(message.mediaEvent);
106
- }
107
- return obj;
108
- },
109
-
110
- create<I extends Exact<DeepPartial<PeerMessage>, I>>(base?: I): PeerMessage {
111
- return PeerMessage.fromPartial(base ?? ({} as any));
112
- },
113
- fromPartial<I extends Exact<DeepPartial<PeerMessage>, I>>(object: I): PeerMessage {
114
- const message = createBasePeerMessage();
115
- message.authenticated = (object.authenticated !== undefined && object.authenticated !== null)
116
- ? PeerMessage_Authenticated.fromPartial(object.authenticated)
117
- : undefined;
118
- message.authRequest = (object.authRequest !== undefined && object.authRequest !== null)
119
- ? PeerMessage_AuthRequest.fromPartial(object.authRequest)
120
- : undefined;
121
- message.mediaEvent = (object.mediaEvent !== undefined && object.mediaEvent !== null)
122
- ? PeerMessage_MediaEvent.fromPartial(object.mediaEvent)
123
- : undefined;
124
- return message;
125
- },
126
- };
127
-
128
- function createBasePeerMessage_Authenticated(): PeerMessage_Authenticated {
129
- return {};
130
- }
131
-
132
- export const PeerMessage_Authenticated = {
133
- encode(_: PeerMessage_Authenticated, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
134
- return writer;
135
- },
136
-
137
- decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage_Authenticated {
138
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
139
- let end = length === undefined ? reader.len : reader.pos + length;
140
- const message = createBasePeerMessage_Authenticated();
141
- while (reader.pos < end) {
142
- const tag = reader.uint32();
143
- switch (tag >>> 3) {
144
- }
145
- if ((tag & 7) === 4 || tag === 0) {
146
- break;
147
- }
148
- reader.skipType(tag & 7);
149
- }
150
- return message;
151
- },
152
-
153
- fromJSON(_: any): PeerMessage_Authenticated {
154
- return {};
155
- },
156
-
157
- toJSON(_: PeerMessage_Authenticated): unknown {
158
- const obj: any = {};
159
- return obj;
160
- },
161
-
162
- create<I extends Exact<DeepPartial<PeerMessage_Authenticated>, I>>(base?: I): PeerMessage_Authenticated {
163
- return PeerMessage_Authenticated.fromPartial(base ?? ({} as any));
164
- },
165
- fromPartial<I extends Exact<DeepPartial<PeerMessage_Authenticated>, I>>(_: I): PeerMessage_Authenticated {
166
- const message = createBasePeerMessage_Authenticated();
167
- return message;
168
- },
169
- };
170
-
171
- function createBasePeerMessage_AuthRequest(): PeerMessage_AuthRequest {
172
- return { token: "" };
173
- }
174
-
175
- export const PeerMessage_AuthRequest = {
176
- encode(message: PeerMessage_AuthRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
177
- if (message.token !== "") {
178
- writer.uint32(10).string(message.token);
179
- }
180
- return writer;
181
- },
182
-
183
- decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage_AuthRequest {
184
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
185
- let end = length === undefined ? reader.len : reader.pos + length;
186
- const message = createBasePeerMessage_AuthRequest();
187
- while (reader.pos < end) {
188
- const tag = reader.uint32();
189
- switch (tag >>> 3) {
190
- case 1:
191
- if (tag !== 10) {
192
- break;
193
- }
194
-
195
- message.token = reader.string();
196
- continue;
197
- }
198
- if ((tag & 7) === 4 || tag === 0) {
199
- break;
200
- }
201
- reader.skipType(tag & 7);
202
- }
203
- return message;
204
- },
205
-
206
- fromJSON(object: any): PeerMessage_AuthRequest {
207
- return { token: isSet(object.token) ? globalThis.String(object.token) : "" };
208
- },
209
-
210
- toJSON(message: PeerMessage_AuthRequest): unknown {
211
- const obj: any = {};
212
- if (message.token !== "") {
213
- obj.token = message.token;
214
- }
215
- return obj;
216
- },
217
-
218
- create<I extends Exact<DeepPartial<PeerMessage_AuthRequest>, I>>(base?: I): PeerMessage_AuthRequest {
219
- return PeerMessage_AuthRequest.fromPartial(base ?? ({} as any));
220
- },
221
- fromPartial<I extends Exact<DeepPartial<PeerMessage_AuthRequest>, I>>(object: I): PeerMessage_AuthRequest {
222
- const message = createBasePeerMessage_AuthRequest();
223
- message.token = object.token ?? "";
224
- return message;
225
- },
226
- };
227
-
228
- function createBasePeerMessage_MediaEvent(): PeerMessage_MediaEvent {
229
- return { data: "" };
230
- }
231
-
232
- export const PeerMessage_MediaEvent = {
233
- encode(message: PeerMessage_MediaEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
234
- if (message.data !== "") {
235
- writer.uint32(10).string(message.data);
236
- }
237
- return writer;
238
- },
239
-
240
- decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage_MediaEvent {
241
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
242
- let end = length === undefined ? reader.len : reader.pos + length;
243
- const message = createBasePeerMessage_MediaEvent();
244
- while (reader.pos < end) {
245
- const tag = reader.uint32();
246
- switch (tag >>> 3) {
247
- case 1:
248
- if (tag !== 10) {
249
- break;
250
- }
251
-
252
- message.data = reader.string();
253
- continue;
254
- }
255
- if ((tag & 7) === 4 || tag === 0) {
256
- break;
257
- }
258
- reader.skipType(tag & 7);
259
- }
260
- return message;
261
- },
262
-
263
- fromJSON(object: any): PeerMessage_MediaEvent {
264
- return { data: isSet(object.data) ? globalThis.String(object.data) : "" };
265
- },
266
-
267
- toJSON(message: PeerMessage_MediaEvent): unknown {
268
- const obj: any = {};
269
- if (message.data !== "") {
270
- obj.data = message.data;
271
- }
272
- return obj;
273
- },
274
-
275
- create<I extends Exact<DeepPartial<PeerMessage_MediaEvent>, I>>(base?: I): PeerMessage_MediaEvent {
276
- return PeerMessage_MediaEvent.fromPartial(base ?? ({} as any));
277
- },
278
- fromPartial<I extends Exact<DeepPartial<PeerMessage_MediaEvent>, I>>(object: I): PeerMessage_MediaEvent {
279
- const message = createBasePeerMessage_MediaEvent();
280
- message.data = object.data ?? "";
281
- return message;
282
- },
283
- };
284
-
285
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
286
-
287
- export type DeepPartial<T> = T extends Builtin ? T
288
- : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
289
- : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
290
- : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
291
- : Partial<T>;
292
-
293
- type KeysOfUnion<T> = T extends T ? keyof T : never;
294
- export type Exact<P, I extends P> = P extends Builtin ? P
295
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
296
-
297
- function isSet(value: any): boolean {
298
- return value !== null && value !== undefined;
299
- }