|
@@ -4,11 +4,33 @@ import BinaryPack from "peerjs-js-binarypack";
|
|
|
import { Supports } from "./supports";
|
|
|
|
|
|
export interface UtilSupportsObj {
|
|
|
+ /**
|
|
|
+ * The current browser.
|
|
|
+ * This property can be useful in determining whether two peers can connect.
|
|
|
+ *
|
|
|
+ * ```ts
|
|
|
+ * if (util.browser === 'firefox') {
|
|
|
+ * // OK to peer with Firefox peers.
|
|
|
+ * }
|
|
|
+ * ```
|
|
|
+ *
|
|
|
+ * `util.browser` can currently have the values
|
|
|
+ * `'firefox', 'chrome', 'safari', 'edge', 'Not a supported browser.', 'Not a browser.' (unknown WebRTC-compatible agent).
|
|
|
+ */
|
|
|
browser: boolean;
|
|
|
webRTC: boolean;
|
|
|
+ /**
|
|
|
+ * True if the current browser supports media streams and PeerConnection.
|
|
|
+ */
|
|
|
audioVideo: boolean;
|
|
|
+ /**
|
|
|
+ * True if the current browser supports DataChannel and PeerConnection.
|
|
|
+ */
|
|
|
data: boolean;
|
|
|
binaryBlob: boolean;
|
|
|
+ /**
|
|
|
+ * True if the current browser supports reliable DataChannels.
|
|
|
+ */
|
|
|
reliable: boolean;
|
|
|
}
|
|
|
|
|
@@ -27,7 +49,7 @@ const DEFAULT_CONFIG = {
|
|
|
sdpSemantics: "unified-plan",
|
|
|
};
|
|
|
|
|
|
-class Util {
|
|
|
+export class Util {
|
|
|
noop(): void {}
|
|
|
|
|
|
readonly CLOUD_HOST = "0.peerjs.com";
|
|
@@ -43,7 +65,13 @@ class Util {
|
|
|
readonly browser = Supports.getBrowser();
|
|
|
readonly browserVersion = Supports.getVersion();
|
|
|
|
|
|
- // Lists which features are supported
|
|
|
+ /**
|
|
|
+ * A hash of WebRTC features mapped to booleans that correspond to whether the feature is supported by the current browser.
|
|
|
+ *
|
|
|
+ * :::caution
|
|
|
+ * Only the properties documented here are guaranteed to be present on `util.supports`
|
|
|
+ * :::
|
|
|
+ */
|
|
|
readonly supports = (function () {
|
|
|
const supported: UtilSupportsObj = {
|
|
|
browser: Supports.isBrowserSupported(),
|
|
@@ -171,4 +199,14 @@ class Util {
|
|
|
return location.protocol === "https:";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Provides a variety of helpful utilities.
|
|
|
+ *
|
|
|
+ * :::caution
|
|
|
+ * Only the utilities documented here are guaranteed to be present on `util`.
|
|
|
+ * Undocumented utilities can be removed without warning.
|
|
|
+ * We don't consider these to be breaking changes.
|
|
|
+ * :::
|
|
|
+ */
|
|
|
export const util = new Util();
|