0.1.6 • Published 12 months ago

@ceil-dev/webrtc-portal v0.1.6

Weekly downloads
-
License
-
Repository
github
Last release
12 months ago

Microenv

WebRTC Portal
Create WebRTC portals and ether


Table of Contents

  1. Overview
  2. Installation
  3. Usage
  4. Example
  5. License

Overview

Creates configurable WebRTC portals and ether.


Installation

# Clone the repository
npm install @ceil-dev/webrtc-portal

Usage

import { createWebRTCPortal, createWebRTCEther } from '@ceil-dev/webrtc-portal';

Example

Run this example in an environment with built-in RTCPeerConnection class or use a library. Also for signalling install @ceil-dev/web-point-portal or use other available or custom Ethers.

import { createWebPointEther } from '@ceil-dev/web-point-portal';
import { createWebRTCPortal, createWebRTCEther } from '@ceil-dev/webrtc-portal';

const run = async () => {
  const portalB = createPortal(
    microEnv(
      // the object to expose
      { 
        foo: 'not bar',
        sayHi: (msg: string) => console.log(msg)
      },
      { id: 'INSERT_YOUR_UNIQUE_ID' },
    ),
    [
      createWebRTCEther({
        signallingEther: createWebPointEther({ fetchMethod: fetch }),
        createRTCPeerConnection: (conf) => new RTCPeerConnection(conf),
      }),
      {
        guest: async ({ payload: { id }, portal }) => {
          console.log(portalB.descriptor.id, 'visited by', id);
        },
      },
    ]
  );

  await portalB('open');

  // Enter this portal using other WebRTC portal or Portals App (https://ceil.dev/apps#portals)
};

run().catch(console.warn);

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.0

12 months ago