open-index/open-npm huggingface dataset:
npm package: @rtcbase/rtcbase
Description: The official JavaScript SDK for RtcBase.
Author: RtcBase
Latest version: 1.7.0-rc1

# RtcBase

The official JavaScript SDK for [RtcBase](https://rtcbase.com/).

## Installation

```bash
npm install --save @rtcbase/rtcbase
```

## Usage

```js
import RtcBase from "@rtcbase/rtcbase";

// Start data collection
RtcBase.init(YOUR_APP_ID);

// Identify the user with unique id and optional traits
RtcBase.identify(userId, {
    name: "Example User",
    email: "user@example.com",
});

// Add more traits later
RtcBase.identify({
    conferenceId: "9c563e15-cfdd-4966-96fc-b25c88b47ec6",
});

// Identify track received from other confrence participant
// trackId - id of MediaStreamTrack
// otherUserId - unique user id of conference participant who is the source of tracks' data
RtcBase.identifyTrack(trackId, otherUserId);

// Start a new RtcBase monitoring session
RtcBase.restartSession();
```
npm package: @rtcio/logger
Description: A P2P connection library aimed to make RTCPeerConnections easier to use
Author: Devin Bidwell
Latest version: 0.1.2

# @rtcio/logger

## Description

This is a thin wrapper around the [debug](https://www.npmjs.com/package/debug) library.
You may install if you wish, but it's mostly for
internal use with the @rtcio ecosystem

## Installation

```bash
npm i @rtcio/logger
```

## Usage

```ts
import Logger from "@rtcio/logger";

const logger = new Logger(
  "@npmnamespace:npmpackage",
  "SomeClass",
  "instanceIdOfClass",
);

logger.log("Something happened here");
logger.error("Oh no, what happened?");
logger.warn("I'm not sure, we should figure it out");
logger.verbose("Y'all talk too much.");
```
npm package: @rtcio/signal-local
Description: A local only rtcio signal 'server'.
Author: Devin Bidwell
Latest version: 0.1.4

# @rtcio/signal-local

A local-only rtcio signal "server" for testing and development.

## Features

- Implements the `@rtcio/signaling` ClientSignaler interface
- Uses `BroadcastChannel` for communication between peers in the same browser context

## Installation

```bash
npm i @rtcio/signal-local
```

## Use Cases

- You just want to try the library out
- You are learning WebRTC and don't want a whole remote signal server
- You are testing your code and don't want a remote signal server
  - `@rtcio/core` uses this package for all internal tests

## Usage

```ts
import { RTC } from "@rtcio/core";
import LocalSignal from "@rtcio/signal-local";

const ROOM_NAME = "TEST_ROOM";

// Remember that we are simulating 2 peers on different machines.
// We need 2 instances of the RTC class to do that.
const client1 = new RTC(new LocalSignalServer(), ROOM_NAME);
const client2 = new RTC(new LocalSignalServer(), ROOM_NAME);

const client2Id = (await client2.connectToRoom()).unwrap();
const client1Id = (await client1.connectToRoom()).unwrap();

client2.on("connectionRequest", async (req) => {
  if (req.remoteId === client1Id) {
    await req.accept();
  } else {
    req.reject();
  }
});

client2.on("connected", (peer1) => {
  console.log(`Peer1 connected with id ${peer1.id}`);
});

await client1.connectToPeer(client2Id);
```
npm package: @rtcio/signaling
Description: A types only package for use in creating custom signaling for use with the @rtcio ecosystem
Author: Devin Bidwell
Latest version: 0.3.0

# @rtcio/signaling

A types-only package for use in creating custom signaling for use with the
@rtcio ecosystem.

## Features

- Defines the `ClientSignaler` interface
- Provides types for signaling events

## Installation

```bash
npm i --save-dev @rtcio/signaling
```

## Implementation Examples

- [@rtcio/signal-local](https://github.com/dbidwell94/rtc.io/blob/master/packages/signalLocalBrowser/src/index.ts)
- [@rtcio/socket-io-client](https://github.com/dbidwell94/rtc.io/blob/master/packages/socket-io-client/src/index.ts)
npm package: @rtco/client
Description: artico client library
Author: Luis Tanica
Latest version: 0.3.6

# @rtco/client

Artico client library. Please refer to the [documentation](https://artico.dev) for more information.

## Installation

```bash
npm install @rtco/client
```

## Usage

The following example shows how to connect two peers and share audio/video or any data between them:

#### Peer 1

```ts
import type { Call } from "@rtco/client";
import { Artico } from "@rtco/client";

const rtco = new Artico();

rtco.on("open", (id: string) => {
  // We're now connected to the signaling server.
  // `id` refers to the unique ID that is currently assigned to this peer, so remote peers can connect to us.
  console.log("Connected to signaling server with peer ID:", id);
});

rtco.on("close", () => {
  console.log("Connection to signaling server is now closed.");
});

rtco.on("error", (err) => {
  console.log("Artico error:", err);
});

rtco.on("call", (call: Call) => {
  // The calling peer can link any metadata object to a call.
  const { metadata } = call;
  const remotePeerName = metadata.name;

  console.log(`Call from ${remotePeerName}...`);

  // Answer the call.
  call.answer();

  call.on("stream", (stream, metadata) => {
    // Stream was added by remote peer, so display it somehow.
    // `metadata` can be appended by the remote peer when adding the stream.
  });
});
```

#### Peer 2

```ts
import type { Call } from "@rtco/client";
import { Artico } from "@rtco/client";

const remotePeerId = "<ID of target remote peer>";

const rtco = new Artico();

const call = rtco.call(remotePeerId);

call.on("error", (err) => {
  console.log("Call error:", err);
});

call.on("close", () => {
  console.log("Call closed");
});

// ...

navigator.mediaDevices
  .getUserMedia({
    video: true,
    audio: true,
  })
  .then((stream) => {
    // send stream to Peer 1 with metadata indicating type of stream
    call.addStream(stream, {
      type: "camera",
    });
  })
  .catch(console.error);
```
npm package: @rtco/peer
Description: artico peer library
Author: Luis Tanica
Latest version: 0.3.6

# @rtco/peer

Artico peer library. Please refer to the [documentation](https://artico.dev) for more information.

## Installation

```bash
npm install @rtco/peer
```

## Usage

The following example show how to connect two peers and share audio/video or any data between them:

```js
import Peer from "@rtco/peer";

const p1 = new Peer({ initiator: true });
const p2 = new Peer();

p1.on("signal", (data) => {
  // signal p2 somehow
  p2.signal(data);
});

p2.on("signal", (data) => {
  // signal p1 somehow
  p1.signal(data);
});

p1.on("connect", () => {
  // data channel is connected and ready to be used
  p1.send("Hey Peer 2, this is Peer 1!");
});

p2.on("data", (data) => {
  console.log("Received a message from Peer 1:", data);
});

p2.on("stream", (stream) => {
  console.log("Received new stream from Peer 1:", stream);
});

p1.on("replacetrack", (oldTrack, newTrack) => {
  console.log("Track replaced:", oldTrack.id, "->", newTrack.id);
});

// ...

navigator.mediaDevices
  .getUserMedia({
    video: true,
    audio: true,
  })
  .then((stream) => {
    // send stream to Peer 2
    p1.addStream(stream);

    // Example: Replace video track (e.g., switch camera)
    navigator.mediaDevices
      .getUserMedia({ video: { facingMode: "environment" }, audio: false })
      .then((newStream) => {
        const oldVideoTrack = stream.getVideoTracks()[0];
        const newVideoTrack = newStream.getVideoTracks()[0];

        // Replace the track
        p1.replaceTrack(oldVideoTrack, newVideoTrack);

        // Stop the old track
        oldVideoTrack.stop();
      })
      .catch(console.error);
  })
  .catch(console.error);
```
npm package: @rtco/server
Description: Artico signaling server
Author: Luis Tanica
Latest version: 0.3.6

# @rtco/server

Artico signaling server library. Please refer to the [documentation](https://artico.dev) for more information.

## Installation

```bash
npm install @rtco/server
```

## Usage

```ts
import { ArticoServer } from "@rtco/server";

const server = new ArticoServer();
server.listen(3000);
```