react-native-webrtc 1.94.2 → 1.100.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +1 -1
  2. package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +1 -1
  3. package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +17 -21
  4. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +3 -0
  5. package/ios/RCTWebRTC/RCTConvert+WebRTC.m +3 -0
  6. package/ios/RCTWebRTC/ScreenCaptureController.m +4 -0
  7. package/ios/RCTWebRTC/ScreenCapturer.m +8 -0
  8. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +3 -1
  9. package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.h +1 -1
  10. package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +3 -9
  11. package/lib/commonjs/EventEmitter.js +16 -0
  12. package/lib/commonjs/EventEmitter.js.map +1 -0
  13. package/lib/commonjs/MediaDevices.js +61 -0
  14. package/lib/commonjs/MediaDevices.js.map +1 -0
  15. package/lib/commonjs/MediaStream.js +158 -0
  16. package/lib/commonjs/MediaStream.js.map +1 -0
  17. package/lib/commonjs/MediaStreamError.js +26 -0
  18. package/lib/commonjs/MediaStreamError.js.map +1 -0
  19. package/lib/commonjs/MediaStreamErrorEvent.js +23 -0
  20. package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -0
  21. package/lib/commonjs/MediaStreamEvent.js +23 -0
  22. package/lib/commonjs/MediaStreamEvent.js.map +1 -0
  23. package/lib/commonjs/MediaStreamTrack.js +127 -0
  24. package/lib/commonjs/MediaStreamTrack.js.map +1 -0
  25. package/lib/commonjs/MediaStreamTrackEvent.js +23 -0
  26. package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -0
  27. package/lib/commonjs/MessageEvent.js +23 -0
  28. package/lib/commonjs/MessageEvent.js.map +1 -0
  29. package/lib/commonjs/Permissions.js +125 -0
  30. package/lib/commonjs/Permissions.js.map +1 -0
  31. package/lib/commonjs/RTCDataChannel.js +198 -0
  32. package/lib/commonjs/RTCDataChannel.js.map +1 -0
  33. package/lib/commonjs/RTCDataChannelEvent.js +23 -0
  34. package/lib/commonjs/RTCDataChannelEvent.js.map +1 -0
  35. package/lib/commonjs/RTCEvent.js +20 -0
  36. package/lib/commonjs/RTCEvent.js.map +1 -0
  37. package/lib/commonjs/RTCIceCandidate.js +34 -0
  38. package/lib/commonjs/RTCIceCandidate.js.map +1 -0
  39. package/lib/commonjs/RTCIceCandidateEvent.js +25 -0
  40. package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -0
  41. package/lib/commonjs/RTCPeerConnection.js +371 -0
  42. package/lib/commonjs/RTCPeerConnection.js.map +1 -0
  43. package/lib/commonjs/RTCSessionDescription.js +43 -0
  44. package/lib/commonjs/RTCSessionDescription.js.map +1 -0
  45. package/lib/commonjs/RTCUtil.js +218 -0
  46. package/lib/commonjs/RTCUtil.js.map +1 -0
  47. package/lib/commonjs/RTCView.js +68 -0
  48. package/lib/commonjs/RTCView.js.map +1 -0
  49. package/lib/commonjs/ScreenCapturePickerView.js +13 -0
  50. package/lib/commonjs/ScreenCapturePickerView.js.map +1 -0
  51. package/lib/commonjs/getDisplayMedia.js +39 -0
  52. package/lib/commonjs/getDisplayMedia.js.map +1 -0
  53. package/lib/commonjs/getUserMedia.js +122 -0
  54. package/lib/commonjs/getUserMedia.js.map +1 -0
  55. package/lib/commonjs/index.js +101 -0
  56. package/lib/commonjs/index.js.map +1 -0
  57. package/lib/commonjs/typings.d.js +2 -0
  58. package/lib/commonjs/typings.d.js.map +1 -0
  59. package/lib/module/EventEmitter.js +7 -0
  60. package/lib/module/EventEmitter.js.map +1 -0
  61. package/lib/module/MediaDevices.js +46 -0
  62. package/lib/module/MediaDevices.js.map +1 -0
  63. package/lib/module/MediaStream.js +142 -0
  64. package/lib/module/MediaStream.js.map +1 -0
  65. package/lib/module/MediaStreamError.js +17 -0
  66. package/lib/module/MediaStreamError.js.map +1 -0
  67. package/lib/module/MediaStreamErrorEvent.js +14 -0
  68. package/lib/module/MediaStreamErrorEvent.js.map +1 -0
  69. package/lib/module/MediaStreamEvent.js +14 -0
  70. package/lib/module/MediaStreamEvent.js.map +1 -0
  71. package/lib/module/MediaStreamTrack.js +116 -0
  72. package/lib/module/MediaStreamTrack.js.map +1 -0
  73. package/lib/module/MediaStreamTrackEvent.js +14 -0
  74. package/lib/module/MediaStreamTrackEvent.js.map +1 -0
  75. package/lib/module/MessageEvent.js +14 -0
  76. package/lib/module/MessageEvent.js.map +1 -0
  77. package/lib/module/Permissions.js +115 -0
  78. package/lib/module/Permissions.js.map +1 -0
  79. package/lib/module/RTCDataChannel.js +176 -0
  80. package/lib/module/RTCDataChannel.js.map +1 -0
  81. package/lib/module/RTCDataChannelEvent.js +14 -0
  82. package/lib/module/RTCDataChannelEvent.js.map +1 -0
  83. package/lib/module/RTCEvent.js +11 -0
  84. package/lib/module/RTCEvent.js.map +1 -0
  85. package/lib/module/RTCIceCandidate.js +25 -0
  86. package/lib/module/RTCIceCandidate.js.map +1 -0
  87. package/lib/module/RTCIceCandidateEvent.js +16 -0
  88. package/lib/module/RTCIceCandidateEvent.js.map +1 -0
  89. package/lib/module/RTCPeerConnection.js +342 -0
  90. package/lib/module/RTCPeerConnection.js.map +1 -0
  91. package/lib/module/RTCSessionDescription.js +34 -0
  92. package/lib/module/RTCSessionDescription.js.map +1 -0
  93. package/lib/module/RTCUtil.js +207 -0
  94. package/lib/module/RTCUtil.js.map +1 -0
  95. package/lib/module/RTCView.js +59 -0
  96. package/lib/module/RTCView.js.map +1 -0
  97. package/lib/module/ScreenCapturePickerView.js +3 -0
  98. package/lib/module/ScreenCapturePickerView.js.map +1 -0
  99. package/lib/module/getDisplayMedia.js +26 -0
  100. package/lib/module/getDisplayMedia.js.map +1 -0
  101. package/lib/module/getUserMedia.js +103 -0
  102. package/lib/module/getUserMedia.js.map +1 -0
  103. package/lib/module/index.js +31 -0
  104. package/lib/module/index.js.map +1 -0
  105. package/lib/module/typings.d.js +2 -0
  106. package/lib/module/typings.d.js.map +1 -0
  107. package/lib/typescript/EventEmitter.d.ts +3 -0
  108. package/lib/typescript/MediaDevices.d.ts +27 -0
  109. package/lib/typescript/MediaStream.d.ts +39 -0
  110. package/lib/typescript/MediaStreamError.d.ts +6 -0
  111. package/lib/typescript/MediaStreamErrorEvent.d.ts +6 -0
  112. package/lib/typescript/MediaStreamEvent.d.ts +8 -0
  113. package/lib/typescript/MediaStreamTrack.d.ts +34 -0
  114. package/lib/typescript/MediaStreamTrackEvent.d.ts +8 -0
  115. package/lib/typescript/MessageEvent.d.ts +9 -0
  116. package/lib/typescript/Permissions.d.ts +55 -0
  117. package/lib/typescript/RTCDataChannel.d.ts +33 -0
  118. package/lib/typescript/RTCDataChannelEvent.d.ts +8 -0
  119. package/lib/typescript/RTCEvent.d.ts +4 -0
  120. package/lib/typescript/RTCIceCandidate.d.ts +11 -0
  121. package/lib/typescript/RTCIceCandidateEvent.d.ts +6 -0
  122. package/lib/typescript/RTCPeerConnection.d.ts +58 -0
  123. package/lib/typescript/RTCSessionDescription.d.ts +14 -0
  124. package/lib/typescript/RTCUtil.d.ts +28 -0
  125. package/lib/typescript/RTCView.d.ts +53 -0
  126. package/lib/typescript/ScreenCapturePickerView.d.ts +2 -0
  127. package/lib/typescript/getDisplayMedia.d.ts +1 -0
  128. package/lib/typescript/getUserMedia.d.ts +6 -0
  129. package/lib/typescript/index.d.ts +11 -0
  130. package/package.json +24 -8
  131. package/src/{EventEmitter.js → EventEmitter.ts} +0 -0
  132. package/src/{MediaDevices.js → MediaDevices.ts} +2 -3
  133. package/src/{MediaStream.js → MediaStream.ts} +1 -1
  134. package/src/{MediaStreamError.js → MediaStreamError.ts} +2 -2
  135. package/src/{MediaStreamErrorEvent.js → MediaStreamErrorEvent.ts} +1 -1
  136. package/src/{MediaStreamEvent.js → MediaStreamEvent.ts} +2 -2
  137. package/src/{MediaStreamTrack.js → MediaStreamTrack.ts} +9 -7
  138. package/src/{MediaStreamTrackEvent.js → MediaStreamTrackEvent.ts} +2 -2
  139. package/src/MessageEvent.ts +11 -0
  140. package/src/{Permissions.js → Permissions.ts} +6 -6
  141. package/src/{RTCDataChannel.js → RTCDataChannel.ts} +12 -8
  142. package/src/{RTCDataChannelEvent.js → RTCDataChannelEvent.ts} +2 -2
  143. package/src/{RTCEvent.js → RTCEvent.ts} +1 -2
  144. package/src/{RTCIceCandidate.js → RTCIceCandidate.ts} +0 -0
  145. package/src/{RTCIceCandidateEvent.js → RTCIceCandidateEvent.ts} +2 -6
  146. package/src/{RTCPeerConnection.js → RTCPeerConnection.ts} +28 -19
  147. package/src/{RTCSessionDescription.js → RTCSessionDescription.ts} +6 -3
  148. package/src/{RTCUtil.js → RTCUtil.ts} +5 -1
  149. package/src/{RTCView.js → RTCView.ts} +0 -0
  150. package/src/{ScreenCapturePickerView.js → ScreenCapturePickerView.ts} +0 -0
  151. package/src/{getDisplayMedia.js → getDisplayMedia.ts} +0 -0
  152. package/src/{getUserMedia.js → getUserMedia.ts} +7 -2
  153. package/src/{index.js → index.ts} +6 -7
  154. package/src/typings.d.ts +1 -0
  155. package/tools/build-webrtc.py +25 -19
  156. package/tsconfig.json +14 -0
  157. package/src/MessageEvent.js +0 -10
@@ -0,0 +1,39 @@
1
+ import { defineCustomEventTarget } from 'event-target-shim';
2
+ import MediaStreamTrack from './MediaStreamTrack';
3
+ declare const MediaStream_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string, import("event-target-shim").Event<string>>, "standard">;
4
+ export default class MediaStream extends MediaStream_base {
5
+ id: string;
6
+ active: boolean;
7
+ _tracks: Array<MediaStreamTrack>;
8
+ /**
9
+ * The identifier of this MediaStream unique within the associated
10
+ * WebRTCModule instance. As the id of a remote MediaStream instance is unique
11
+ * only within the associated RTCPeerConnection, it is not sufficiently unique
12
+ * to identify this MediaStream across multiple RTCPeerConnections and to
13
+ * unambiguously differentiate it from a local MediaStream instance not added
14
+ * to an RTCPeerConnection.
15
+ */
16
+ _reactTag: string;
17
+ /**
18
+ * A MediaStream can be constructed in several ways, depending on the paramters
19
+ * that are passed here.
20
+ *
21
+ * - undefined: just a new stream, with no tracks.
22
+ * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.
23
+ * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.
24
+ * - object: a new stream instance, represented by the passed info object, this is always
25
+ * done internally, when the stream is first created in native and the JS wrapper is
26
+ * built afterwards.
27
+ */
28
+ constructor(arg: any);
29
+ addTrack(track: MediaStreamTrack): void;
30
+ removeTrack(track: MediaStreamTrack): void;
31
+ getTracks(): Array<MediaStreamTrack>;
32
+ getTrackById(trackId: any): MediaStreamTrack | undefined;
33
+ getAudioTracks(): Array<MediaStreamTrack>;
34
+ getVideoTracks(): Array<MediaStreamTrack>;
35
+ clone(): void;
36
+ toURL(): string;
37
+ release(releaseTracks?: boolean): void;
38
+ }
39
+ export {};
@@ -0,0 +1,6 @@
1
+ export default class MediaStreamError {
2
+ name: string;
3
+ message?: string;
4
+ constraintName?: string;
5
+ constructor(error: any);
6
+ }
@@ -0,0 +1,6 @@
1
+ import type MediaStreamError from './MediaStreamError';
2
+ export default class MediaStreamErrorEvent {
3
+ type: string;
4
+ error?: MediaStreamError;
5
+ constructor(type: any, eventInitDict: any);
6
+ }
@@ -0,0 +1,8 @@
1
+ import type MediaStream from './MediaStream';
2
+ export default class MediaStreamEvent {
3
+ type: string;
4
+ stream: MediaStream;
5
+ constructor(type: any, eventInitDict: {
6
+ stream: MediaStream;
7
+ });
8
+ }
@@ -0,0 +1,34 @@
1
+ import { defineCustomEventTarget } from 'event-target-shim';
2
+ declare type MediaStreamTrackState = 'live' | 'ended';
3
+ declare const MediaStreamTrack_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string, import("event-target-shim").Event<string>>, "standard">;
4
+ declare class MediaStreamTrack extends MediaStreamTrack_base {
5
+ _constraints: object;
6
+ _enabled: boolean;
7
+ _settings: object;
8
+ _muted: boolean;
9
+ id: string;
10
+ kind: string;
11
+ label: string;
12
+ readyState: MediaStreamTrackState;
13
+ remote: boolean;
14
+ constructor(info: any);
15
+ get enabled(): boolean;
16
+ set enabled(enabled: boolean);
17
+ get muted(): boolean;
18
+ stop(): void;
19
+ /**
20
+ * Private / custom API for switching the cameras on the fly, without the
21
+ * need for adding / removing tracks or doing any SDP renegotiation.
22
+ *
23
+ * This is how the reference application (AppRTCMobile) implements camera
24
+ * switching.
25
+ */
26
+ _switchCamera(): void;
27
+ applyConstraints(): void;
28
+ clone(): void;
29
+ getCapabilities(): void;
30
+ getConstraints(): any;
31
+ getSettings(): any;
32
+ release(): void;
33
+ }
34
+ export default MediaStreamTrack;
@@ -0,0 +1,8 @@
1
+ import type MediaStreamTrack from './MediaStreamTrack';
2
+ export default class MediaStreamTrackEvent {
3
+ type: string;
4
+ track: MediaStreamTrack;
5
+ constructor(type: any, eventInitDict: {
6
+ track: MediaStreamTrack;
7
+ });
8
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react-native" />
2
+ export declare type MessageEventData = string | ArrayBuffer | Blob;
3
+ export default class MessageEvent {
4
+ type: string;
5
+ data: MessageEventData;
6
+ constructor(type: string, eventInitDict: {
7
+ data: MessageEventData;
8
+ });
9
+ }
@@ -0,0 +1,55 @@
1
+ import { Permission } from 'react-native';
2
+ /**
3
+ * Type declaration for a permissions descriptor.
4
+ */
5
+ declare type PermissionDescriptor = {
6
+ name: string;
7
+ };
8
+ /**
9
+ * Class implementing a subset of W3C's Permissions API as defined by:
10
+ * https://www.w3.org/TR/permissions/
11
+ */
12
+ declare class Permissions {
13
+ /**
14
+ * Possible result values for {@link query}, in accordance with:
15
+ * https://www.w3.org/TR/permissions/#status-of-a-permission
16
+ */
17
+ RESULT: {
18
+ DENIED: string;
19
+ GRANTED: string;
20
+ PROMPT: string;
21
+ };
22
+ /**
23
+ * This implementation only supports requesting these permissions, a subset
24
+ * of: https://www.w3.org/TR/permissions/#permission-registry
25
+ */
26
+ VALID_PERMISSIONS: string[];
27
+ _lastReq: Promise<any>;
28
+ /**
29
+ * Helper for requesting Android permissions. On Android only one permission
30
+ * can be requested at a time (unless the multi-permission API is used,
31
+ * but we are not using that for symmetry with the W3C API for querying)
32
+ * so we'll queue them up.
33
+ *
34
+ * @param perm - The requested permission from
35
+ * {@link PermissionsAndroid.PERMISSIONS}
36
+ * https://facebook.github.io/react-native/docs/permissionsandroid#permissions-that-require-prompting-the-user
37
+ */
38
+ _requestPermissionAndroid(perm: Permission): Promise<unknown>;
39
+ /**
40
+ * Validates the given permission descriptor.
41
+ */
42
+ _validatePermissionDescriptior(permissionDesc: any): void;
43
+ /**
44
+ * Method for querying the status of a permission, according to:
45
+ * https://www.w3.org/TR/permissions/#permissions-interface
46
+ */
47
+ query(permissionDesc: PermissionDescriptor): any;
48
+ /**
49
+ * Custom method NOT defined by W3C's permissions API, which allows the
50
+ * caller to request a permission.
51
+ */
52
+ request(permissionDesc: PermissionDescriptor): any;
53
+ }
54
+ declare const _default: Permissions;
55
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import { defineCustomEventTarget } from 'event-target-shim';
2
+ declare type RTCDataChannelState = 'connecting' | 'open' | 'closing' | 'closed';
3
+ declare const RTCDataChannel_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string, import("event-target-shim").Event<string>>, "standard">;
4
+ export default class RTCDataChannel extends RTCDataChannel_base {
5
+ _peerConnectionId: number;
6
+ _reactTag: string;
7
+ _id: number;
8
+ _label: string;
9
+ _maxPacketLifeTime?: number;
10
+ _maxRetransmits?: number;
11
+ _negotiated: boolean;
12
+ _ordered: boolean;
13
+ _protocol: string;
14
+ _readyState: RTCDataChannelState;
15
+ _subscriptions: Array<any>;
16
+ binaryType: string;
17
+ bufferedAmount: number;
18
+ bufferedAmountLowThreshold: number;
19
+ constructor(info: any);
20
+ get label(): string;
21
+ get id(): number;
22
+ get ordered(): boolean;
23
+ get maxPacketLifeTime(): number | undefined;
24
+ get maxRetransmits(): number | undefined;
25
+ get protocol(): string;
26
+ get negotiated(): boolean;
27
+ get readyState(): string;
28
+ send(data: string | ArrayBuffer | ArrayBufferView): void;
29
+ close(): void;
30
+ _unregisterEvents(): void;
31
+ _registerEvents(): void;
32
+ }
33
+ export {};
@@ -0,0 +1,8 @@
1
+ import type RTCDataChannel from './RTCDataChannel';
2
+ export default class RTCDataChannelEvent {
3
+ type: string;
4
+ channel: RTCDataChannel;
5
+ constructor(type: any, eventInitDict: {
6
+ channel: RTCDataChannel;
7
+ });
8
+ }
@@ -0,0 +1,4 @@
1
+ export default class RTCEvent {
2
+ type: string;
3
+ constructor(type: any);
4
+ }
@@ -0,0 +1,11 @@
1
+ export default class RTCIceCandidate {
2
+ candidate: string;
3
+ sdpMLineIndex: number;
4
+ sdpMid: string;
5
+ constructor(info: any);
6
+ toJSON(): {
7
+ candidate: string;
8
+ sdpMLineIndex: number;
9
+ sdpMid: string;
10
+ };
11
+ }
@@ -0,0 +1,6 @@
1
+ import type RTCIceCandidate from './RTCIceCandidate';
2
+ export default class RTCIceCandidateEvent {
3
+ type: string;
4
+ candidate: RTCIceCandidate | null;
5
+ constructor(type: any, eventInitDict: any);
6
+ }
@@ -0,0 +1,58 @@
1
+ import { defineCustomEventTarget } from 'event-target-shim';
2
+ import MediaStream from './MediaStream';
3
+ import RTCDataChannel from './RTCDataChannel';
4
+ import RTCSessionDescription from './RTCSessionDescription';
5
+ declare type RTCSignalingState = 'stable' | 'have-local-offer' | 'have-remote-offer' | 'have-local-pranswer' | 'have-remote-pranswer' | 'closed';
6
+ declare type RTCIceGatheringState = 'new' | 'gathering' | 'complete';
7
+ declare type RTCPeerConnectionState = 'new' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'closed';
8
+ declare type RTCIceConnectionState = 'new' | 'checking' | 'connected' | 'completed' | 'failed' | 'disconnected' | 'closed';
9
+ declare type RTCDataChannelInit = {
10
+ ordered?: boolean;
11
+ maxPacketLifeTime?: number;
12
+ maxRetransmits?: number;
13
+ protocol?: string;
14
+ negotiated?: boolean;
15
+ id?: number;
16
+ };
17
+ declare const RTCPeerConnection_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string, import("event-target-shim").Event<string>>, "standard">;
18
+ export default class RTCPeerConnection extends RTCPeerConnection_base {
19
+ localDescription: RTCSessionDescription | null;
20
+ remoteDescription: RTCSessionDescription | null;
21
+ signalingState: RTCSignalingState;
22
+ iceGatheringState: RTCIceGatheringState;
23
+ connectionState: RTCPeerConnectionState;
24
+ iceConnectionState: RTCIceConnectionState;
25
+ _peerConnectionId: number;
26
+ _localStreams: Array<MediaStream>;
27
+ _remoteStreams: Array<MediaStream>;
28
+ _subscriptions: Array<any>;
29
+ constructor(configuration: any);
30
+ addStream(stream: MediaStream): void;
31
+ removeStream(stream: MediaStream): void;
32
+ createOffer(options: any): Promise<unknown>;
33
+ createAnswer(options?: {}): Promise<unknown>;
34
+ setConfiguration(configuration: any): void;
35
+ setLocalDescription(sessionDescription?: RTCSessionDescription): Promise<void>;
36
+ setRemoteDescription(sessionDescription: RTCSessionDescription): Promise<void>;
37
+ addIceCandidate(candidate: any): Promise<void>;
38
+ getStats(): any;
39
+ getLocalStreams(): MediaStream[];
40
+ getRemoteStreams(): MediaStream[];
41
+ close(): void;
42
+ restartIce(): void;
43
+ _unregisterEvents(): void;
44
+ _registerEvents(): void;
45
+ /**
46
+ * Creates a new RTCDataChannel object with the given label. The
47
+ * RTCDataChannelInit dictionary can be used to configure properties of the
48
+ * underlying channel such as data reliability.
49
+ *
50
+ * @param {string} label - the value with which the label attribute of the new
51
+ * instance is to be initialized
52
+ * @param {RTCDataChannelInit} dataChannelDict - an optional dictionary of
53
+ * values with which to initialize corresponding attributes of the new
54
+ * instance such as id
55
+ */
56
+ createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
57
+ }
58
+ export {};
@@ -0,0 +1,14 @@
1
+ export default class RTCSessionDescription {
2
+ _sdp: string;
3
+ _type: string | null;
4
+ constructor(info?: {
5
+ type: null;
6
+ sdp: string;
7
+ });
8
+ get sdp(): string;
9
+ get type(): string | null;
10
+ toJSON(): {
11
+ sdp: string;
12
+ type: string | null;
13
+ };
14
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Put together a random string in UUIDv4 format {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
3
+ *
4
+ * @return {String} uuidv4
5
+ */
6
+ export declare function uniqueID(): string;
7
+ /**
8
+ * Utility for deep cloning an object. Object.assign() only does a shallow copy.
9
+ *
10
+ * @param {Object} obj - object to be cloned
11
+ * @return {Object} cloned obj
12
+ */
13
+ export declare function deepClone(obj: any): any;
14
+ interface Constraints {
15
+ mandatory?: object;
16
+ }
17
+ /**
18
+ * Normalize options passed to createOffer() / createAnswer().
19
+ *
20
+ * @param {Object} options - user supplied options
21
+ * @return {Object} newOptions - normalized options
22
+ */
23
+ export declare function normalizeOfferAnswerOptions(options?: Constraints): {};
24
+ /**
25
+ * Normalize the given constraints in something we can work with.
26
+ */
27
+ export declare function normalizeConstraints(constraints: any): any;
28
+ export {};
@@ -0,0 +1,53 @@
1
+ declare const _default: import("react-native").HostComponent<unknown>;
2
+ /**
3
+ * Native prop validation was removed from RN in:
4
+ * https://github.com/facebook/react-native/commit/8dc3ba0444c94d9bbb66295b5af885bff9b9cd34
5
+ *
6
+ * So we list them here for documentation purposes.
7
+ */
8
+ /**
9
+ * Indicates whether the video specified by {@link #streamURL} should be
10
+ * mirrored during rendering. Commonly, applications choose to mirror the
11
+ * user-facing camera.
12
+ *
13
+ * mirror: boolean
14
+ */
15
+ /**
16
+ * In the fashion of
17
+ * https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth
18
+ * and https://www.w3.org/TR/html5/rendering.html#video-object-fit,
19
+ * resembles the CSS style object-fit.
20
+ *
21
+ * objectFit: 'contain' | 'cover'
22
+ */
23
+ /**
24
+ * URL / id of the stream that should be rendered.
25
+ *
26
+ * streamURL: string
27
+ */
28
+ /**
29
+ * Similarly to the CSS property z-index, specifies the z-order of this
30
+ * RTCView in the stacking space of all RTCViews. When RTCViews overlap,
31
+ * zOrder determines which one covers the other. An RTCView with a larger
32
+ * zOrder generally covers an RTCView with a lower one.
33
+ *
34
+ * Non-overlapping RTCViews may safely share a z-order (because one does not
35
+ * have to cover the other).
36
+ *
37
+ * The support for zOrder is platform-dependent and/or
38
+ * implementation-specific. Thus, specifying a value for zOrder is to be
39
+ * thought of as giving a hint rather than as imposing a requirement. For
40
+ * example, video renderers such as RTCView are commonly implemented using
41
+ * OpenGL and OpenGL views may have different numbers of layers in their
42
+ * stacking space. Android has three: a layer bellow the window (aka
43
+ * default), a layer bellow the window again but above the previous layer
44
+ * (aka media overlay), and above the window. Consequently, it is advisable
45
+ * to limit the number of utilized layers in the stacking space to the
46
+ * minimum sufficient for the desired display. For example, a video call
47
+ * application usually needs a maximum of two zOrder values: 0 for the
48
+ * remote video(s) which appear in the background, and 1 for the local
49
+ * video(s) which appear above the remote video(s).
50
+ *
51
+ * zOrder: number
52
+ */
53
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("react-native").HostComponent<unknown>;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default function getDisplayMedia(): Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ interface Constraints {
2
+ audio?: boolean | object;
3
+ video?: boolean | object;
4
+ }
5
+ export default function getUserMedia(constraints?: Constraints): Promise<unknown>;
6
+ export {};
@@ -0,0 +1,11 @@
1
+ import ScreenCapturePickerView from './ScreenCapturePickerView';
2
+ import RTCPeerConnection from './RTCPeerConnection';
3
+ import RTCIceCandidate from './RTCIceCandidate';
4
+ import RTCSessionDescription from './RTCSessionDescription';
5
+ import RTCView from './RTCView';
6
+ import MediaStream from './MediaStream';
7
+ import MediaStreamTrack from './MediaStreamTrack';
8
+ import mediaDevices from './MediaDevices';
9
+ import permissions from './Permissions';
10
+ export { ScreenCapturePickerView, RTCPeerConnection, RTCIceCandidate, RTCSessionDescription, RTCView, MediaStream, MediaStreamTrack, mediaDevices, permissions, registerGlobals };
11
+ declare function registerGlobals(): void;
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "react-native-webrtc",
3
- "version": "1.94.2",
3
+ "version": "1.100.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git"
7
7
  },
8
- "nativePackage": true,
9
8
  "description": "WebRTC for React Native",
10
9
  "license": "MIT",
11
10
  "homepage": "https://github.com/react-native-webrtc/react-native-webrtc",
@@ -16,7 +15,10 @@
16
15
  "android",
17
16
  "webrtc"
18
17
  ],
19
- "main": "src/index.js",
18
+ "react-native": "src/index.ts",
19
+ "types": "lib/typescript/index.d.ts",
20
+ "main": "lib/commonjs/index.js",
21
+ "module": "lib/module/index.js",
20
22
  "dependencies": {
21
23
  "base64-js": "1.5.1",
22
24
  "event-target-shim": "6.0.2",
@@ -26,23 +28,37 @@
26
28
  "react-native": ">=0.60.0"
27
29
  },
28
30
  "scripts": {
31
+ "check": "tsc --noEmit",
29
32
  "postinstall": "node tools/downloadWebRTC.js",
30
- "prepare": "husky install"
33
+ "prepare": "husky install && bob build"
31
34
  },
32
35
  "bugs": {
33
36
  "url": "https://github.com/react-native-webrtc/react-native-webrtc/issues"
34
37
  },
35
38
  "devDependencies": {
39
+ "@types/react": "17.0.40",
40
+ "@types/react-native": "0.67.3",
36
41
  "husky": "7.0.2",
37
42
  "lint-staged": "11.2.3",
38
- "prettier": "2.4.1"
43
+ "prettier": "2.4.1",
44
+ "react-native-builder-bob": "0.18.2",
45
+ "typescript": "4.6.2"
39
46
  },
40
47
  "lint-staged": {
41
48
  "**/*": "prettier --write --ignore-unknown"
42
49
  },
50
+ "react-native-builder-bob": {
51
+ "source": "src",
52
+ "output": "lib",
53
+ "targets": [
54
+ "commonjs",
55
+ "module",
56
+ "typescript"
57
+ ]
58
+ },
43
59
  "webrtc-builds": {
44
- "android": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/android-webrtc.tgz",
45
- "ios": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/WebRTC.xcframework.tgz",
46
- "ios-bitcode": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/WebRTC.xcframework-bitcode.tgz"
60
+ "android": "https://github.com/jitsi/webrtc/releases/download/v100.0.0/android-webrtc.tgz",
61
+ "ios": "https://github.com/jitsi/webrtc/releases/download/v100.0.0/WebRTC.xcframework.tgz",
62
+ "ios-bitcode": "https://github.com/jitsi/webrtc/releases/download/v100.0.0/WebRTC.xcframework-bitcode.tgz"
47
63
  }
48
64
  }
File without changes
@@ -22,11 +22,10 @@ class MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {
22
22
  * W3C "Screen Capture" compatible {@code getDisplayMedia} implementation.
23
23
  * See: https://w3c.github.io/mediacapture-screen-share/
24
24
  *
25
- * @param {*} constraints
26
25
  * @returns {Promise}
27
26
  */
28
- getDisplayMedia(constraints) {
29
- return getDisplayMedia(constraints);
27
+ getDisplayMedia() {
28
+ return getDisplayMedia();
30
29
  }
31
30
 
32
31
  /**
@@ -94,7 +94,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
94
94
  return this._tracks.slice();
95
95
  }
96
96
 
97
- getTrackById(trackId): ?MediaStreamTrack {
97
+ getTrackById(trackId): MediaStreamTrack | undefined {
98
98
  return this._tracks.find(track => track.id === trackId);
99
99
  }
100
100
 
@@ -1,8 +1,8 @@
1
1
 
2
2
  export default class MediaStreamError {
3
3
  name: string;
4
- message: ?string;
5
- constraintName: ?string;
4
+ message?: string;
5
+ constraintName?: string;
6
6
 
7
7
  constructor(error) {
8
8
  this.name = error.name;
@@ -3,7 +3,7 @@ import type MediaStreamError from './MediaStreamError';
3
3
 
4
4
  export default class MediaStreamErrorEvent {
5
5
  type: string;
6
- error: ?MediaStreamError;
6
+ error?: MediaStreamError;
7
7
  constructor(type, eventInitDict) {
8
8
  this.type = type.toString();
9
9
  Object.assign(this, eventInitDict);
@@ -4,8 +4,8 @@ import type MediaStream from './MediaStream';
4
4
  export default class MediaStreamEvent {
5
5
  type: string;
6
6
  stream: MediaStream;
7
- constructor(type, eventInitDict) {
7
+ constructor(type, eventInitDict: { stream: MediaStream }) {
8
8
  this.type = type.toString();
9
- Object.assign(this, eventInitDict);
9
+ this.stream = eventInitDict.stream;
10
10
  }
11
11
  }
@@ -11,15 +11,14 @@ const MEDIA_STREAM_TRACK_EVENTS = ['ended', 'mute', 'unmute'];
11
11
  type MediaStreamTrackState = 'live' | 'ended';
12
12
 
13
13
  class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVENTS) {
14
- _constraints: Object;
14
+ _constraints: object;
15
15
  _enabled: boolean;
16
- _settings: Object;
16
+ _settings: object;
17
+ _muted: boolean;
17
18
 
18
19
  id: string;
19
20
  kind: string;
20
21
  label: string;
21
- muted: boolean;
22
- // readyState in java: INITIALIZING, LIVE, ENDED, FAILED
23
22
  readyState: MediaStreamTrackState;
24
23
  remote: boolean;
25
24
 
@@ -29,11 +28,11 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
29
28
  this._constraints = info.constraints || {};
30
29
  this._enabled = info.enabled;
31
30
  this._settings = info.settings || {};
31
+ this._muted = false;
32
32
 
33
33
  this.id = info.id;
34
34
  this.kind = info.kind;
35
35
  this.label = info.label;
36
- this.muted = false;
37
36
  this.remote = info.remote;
38
37
 
39
38
  const _readyState = info.readyState.toLowerCase();
@@ -44,13 +43,16 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
44
43
  return this._enabled;
45
44
  }
46
45
 
47
- set enabled(enabled: boolean): void {
46
+ set enabled(enabled: boolean) {
48
47
  if (enabled === this._enabled) {
49
48
  return;
50
49
  }
51
50
  WebRTCModule.mediaStreamTrackSetEnabled(this.id, !this._enabled);
52
51
  this._enabled = !this._enabled;
53
- this.muted = !this._enabled;
52
+ }
53
+
54
+ get muted(): boolean {
55
+ return this._muted;
54
56
  }
55
57
 
56
58
  stop() {
@@ -4,8 +4,8 @@ import type MediaStreamTrack from './MediaStreamTrack';
4
4
  export default class MediaStreamTrackEvent {
5
5
  type: string;
6
6
  track: MediaStreamTrack;
7
- constructor(type, eventInitDict) {
7
+ constructor(type, eventInitDict: { track: MediaStreamTrack }) {
8
8
  this.type = type.toString();
9
- Object.assign(this, eventInitDict);
9
+ this.track = eventInitDict.track;
10
10
  }
11
11
  }
@@ -0,0 +1,11 @@
1
+
2
+ export type MessageEventData = string | ArrayBuffer | Blob;
3
+
4
+ export default class MessageEvent {
5
+ type: string;
6
+ data: MessageEventData;
7
+ constructor(type: string, eventInitDict: { data: MessageEventData }) {
8
+ this.type = type.toString();
9
+ this.data = eventInitDict.data;
10
+ }
11
+ }