Skip to content

Commit

Permalink
Add typings
Browse files Browse the repository at this point in the history
- Add support for using this package from TypeScript.
  • Loading branch information
Daniel Bradley committed Nov 13, 2019
1 parent d2b7d96 commit 4cd890b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# but not these files...
!DetectRTC.js
!DetectRTC.min.js
!DetectRTC.d.ts
!index.html
!package.json
!npm-test.js
Expand Down
77 changes: 77 additions & 0 deletions DetectRTC.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
interface Device {
deviceId: string;
groupId: string;
id: string;
isCustomLabel?: boolean;
kind: string;
label: string;
}

namespace DetectRTC {
export function load(callback: () => void): void;
export const version: string;
export const osName: string;
export const osVersion: string;

export const hasWebcam: boolean;
export const hasMicrophone: boolean; // (has microphone device!)
export const hasSpeakers: boolean; // (has speakers!)

export const isApplyConstraintsSupported: boolean;
export const isAudioContextSupported: boolean;
export const isCanvasSupportsStreamCapturing: boolean;
export const isCreateMediaStreamSourceSupported: boolean;
export const isGetUserMediaSupported: boolean;
export const isMobileDevice: boolean;
export const isMultiMonitorScreenCapturingSupported: boolean;
export const isORTCSupported: boolean;
export const isPromisesSupported: boolean;
export const isRTPSenderReplaceTracksSupported: boolean;
export const isRemoteStreamProcessingSupported: boolean;
export const isRtpDataChannelsSupported: boolean;
export const isScreenCapturingSupported: boolean; // Chrome, Firefox, Opera, Edge and Android
export const isSctpDataChannelsSupported: boolean;
export const isSetSinkIdSupported: boolean;
export const isVideoSupportsStreamCapturing: boolean;
export const isWebRTCSupported: boolean;
export const isWebSocketsBlocked: boolean;
export const isWebSocketsSupported: boolean;

export const isWebsiteHasMicrophonePermissions: boolean; // getUserMedia allowed for HTTPs domain in Chrome?
export const isWebsiteHasWebcamPermissions: boolean; // getUserMedia allowed for HTTPs domain in Chrome?

export const isDesktopCapturingSupported: boolean;

export function checkWebSocketsSupport(callback: () => void);

export const audioInputDevices: Device[]; // microphones
export const audioOutputDevices: Device[]; // speakers
export const videoInputDevices: Device[]; // cameras

export const displayAspectRatio: string;
export const displayResolution: string;

export const browser: {
name: "Edge" | "Chrome" | "Firefox" | string;
version: string | number;
fullVersion: string;
isChrome?: boolean;
isFirefox?: boolean;
isOpera?: boolean;
isIE?: boolean;
isSafari?: boolean;
isEdge?: boolean;

isPrivateBrowsing?: boolean; // incognito or private modes
};

export function DetectLocalIPAddress(
callback: (localIpAddress: string) => void
);

export const MediaDevices: Device[];
export const MediaStream: string[];
export const MediaStreamTrack: string[];
export const RTCPeerConnection: string[];
}
export = DetectRTC;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"test": "./node_modules/.bin/protractor test/browserstack.config.js"
},
"main": "DetectRTC.js",
"types": "DetectRTC.d.ts",
"keywords": [
"webrtc",
"detectrtc",
Expand Down

0 comments on commit 4cd890b

Please sign in to comment.