<commit_before>/// <reference path="../../third_party/typings/tsd.d.ts" />

// TODO: rename once https://github.com/Microsoft/TypeScript/issues/52 is fixed
declare module freedom_UproxyPeerConnection {
  // Associates a channel label with a WebRtc.Data, for fromPeerData events.
  interface LabelledDataChannelMessage {
    channelLabel: string;
    message: WebRtc.Data
  }
}

// TODO: uncomment once https://github.com/Microsoft/TypeScript/issues/52 is fixed
// declare module freedom {
  // Thin wrapper over WebRtc.PeerConnection.
  // 
  // Some accomodations to Freedom message passing have had to be made:
  //  - The relatively complex WebRtc.SignallingMessage interface has been
  //    replaced with opaque strings (they can be decoded with JSON.parse).
  //  - As DataChannel objects cannot be returned by or passed as arguments,
  //    they must be accessed via this class, by label.
  //  - Some of the arguments to PeerConnection are too complex to
  //    be expressed in Freedom-ese, e.g. PeerConnectionConfig.
  //    
  // Additionally, note that while TypeScript interfaces cannot specify
  // arguments, the implementation of this class accepts a JSON-ified
  // PeerConnectionConfig instance.
  interface freedom_UproxyPeerConnection {

    negotiateConnection() : Promise<WebRtc.ConnectionAddresses>;

    handleSignalMessage(signal:string) : Promise<void>;

    // Fulfills once the data channel has been successfully opened,
    // i.e. this is equivalent to PeerConnection.openDataChannel().onceOpened().
    // TODO: add options argument<commit_msg>clarify for which freedom object this is an interface<commit_after>/// <reference path="../../third_party/typings/tsd.d.ts" />

// TODO: rename once https://github.com/Microsoft/TypeScript/issues/52 is fixed
declare module freedom_UproxyPeerConnection {
  // Associates a channel label with a WebRtc.Data, for fromPeerData events.
  interface LabelledDataChannelMessage {
    channelLabel: string;
    message: WebRtc.Data
  }
}

// TODO: uncomment once https://github.com/Microsoft/TypeScript/issues/52 is fixed
// declare module freedom {
  // This is the interface for the object returned by
  // freedom['WebRtc.PeerConnection'], which is a thin wrapper over 
  // WebRtc.PeerConnection.
  // 
  // Some accomodations to Freedom message passing have had to be made:
  //  - The relatively complex WebRtc.SignallingMessage interface has been
  //    replaced with opaque strings (they can be decoded with JSON.parse).
  //  - As DataChannel objects cannot be returned by or passed as arguments,
  //    they must be accessed via this class, by label.
  //  - Some of the arguments to PeerConnection are too complex to
  //    be expressed in Freedom-ese, e.g. PeerConnectionConfig.
  //    
  // Additionally, note that while TypeScript interfaces cannot specify
  // arguments, the implementation of this class accepts a JSON-ified
  // PeerConnectionConfig instance.
  interface freedom_UproxyPeerConnection {

    negotiateConnection() : Promise<WebRtc.ConnectionAddresses>;

    handleSignalMessage(signal:string) : Promise<void>;

    // Fulfills once the data channel has been successfully opened,
    // i.e. this is equivalent to PeerConnection.openDataChannel().onceOpened().
    // TODO: add options argument
{'fraction_non_alphanumeric': 0.08856536245071277, 'fraction_numerical': 0.002426448286320898, 'mean_word_length': 3.420911528150134, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5825035', 'n_tokens_mistral': 884, 'n_tokens_neox': 850, 'n_words': 322}