Move out react-peer package to its own repo (#308)

This commit is contained in:
Nabarun Gogoi 2023-02-01 09:54:52 +05:30 committed by GitHub
parent ff64dcb43c
commit dfc3f5a63e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 344 additions and 4334 deletions

View File

@ -15,6 +15,7 @@
"@types/node": "^16.18.10", "@types/node": "^16.18.10",
"@types/react": "^18.0.26", "@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9", "@types/react-dom": "^18.0.9",
"assert": "^2.0.0",
"it-pushable": "^3.1.2", "it-pushable": "^3.1.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",

View File

@ -1,7 +0,0 @@
/coverage
/demo/dist
/es
/lib
/node_modules
/umd
npm-debug.log*

View File

@ -1,16 +0,0 @@
sudo: false
language: node_js
node_js:
- 10
before_install:
- npm install codecov.io coveralls
after_success:
- cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
branches:
only:
- master

View File

@ -1,25 +0,0 @@
## Prerequisites
[Node.js](http://nodejs.org/) >= 10 must be installed.
## Installation
- Running `npm install` in the component's root directory will install everything you need for development.
## Demo Development Server
- `npm start` will run a development server with the component's demo app at [http://localhost:3000](http://localhost:3000) with hot module reloading.
## Running Tests
- `npm test` will run the tests once.
- `npm run test:coverage` will run the tests and produce a coverage report in `coverage/`.
- `npm run test:watch` will run the tests on every change.
## Building
- `npm run build` will build the component for publishing to npm and also bundle the demo app.
- `npm run clean` will delete built resources.

View File

@ -1,16 +0,0 @@
# react-peer
[![Travis][build-badge]][build]
[![npm package][npm-badge]][npm]
[![Coveralls][coveralls-badge]][coveralls]
Describe react-peer here.
[build-badge]: https://img.shields.io/travis/user/repo/master.png?style=flat-square
[build]: https://travis-ci.org/user/repo
[npm-badge]: https://img.shields.io/npm/v/npm-package.png?style=flat-square
[npm]: https://www.npmjs.org/package/npm-package
[coveralls-badge]: https://img.shields.io/coveralls/user/repo/master.png?style=flat-square
[coveralls]: https://coveralls.io/github/user/repo

View File

@ -1,16 +0,0 @@
import React, {Component} from 'react'
import {render} from 'react-dom'
import { PeerProvider } from '../../src'
export default class Demo extends Component {
render() {
return <PeerProvider>
<div>
<h1>react-peer Demo</h1>
</div>
</PeerProvider>
}
}
render(<Demo/>, document.querySelector('#demo'))

View File

@ -1,7 +0,0 @@
module.exports = {
type: 'react-component',
npm: {
esModules: false,
umd: false
}
}

View File

@ -1,37 +0,0 @@
{
"name": "@cerc-io/react-peer",
"version": "0.2.24",
"description": "react-peer React component",
"main": "lib/index.js",
"files": [
"css",
"es",
"lib",
"umd"
],
"scripts": {
"build": "nwb build-react-component --no-demo",
"clean": "nwb clean-module && nwb clean-demo",
"prepublishOnly": "yarn build",
"start": "nwb serve-react-demo",
"test:coverage": "nwb test-react --coverage",
"test:watch": "nwb test-react --server"
},
"dependencies": {
"@cerc-io/peer": "^0.2.24"
},
"peerDependencies": {
"react": "^18.2.0"
},
"devDependencies": {
"nwb": "0.25.x",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"author": "",
"homepage": "",
"license": "AGPL-version-3.0",
"keywords": [
"react-component"
]
}

View File

@ -1,3 +0,0 @@
import React from "react";
export const PeerContext = React.createContext({});

View File

@ -1,36 +0,0 @@
import React from 'react';
import { Peer } from '@cerc-io/peer';
import { PeerContext } from './PeerContext';
export const PeerProvider = ({ signalServer, relayNode, children }) => {
const [peer, setPeer] = React.useState(null);
React.useEffect(() => {
const init = async () => {
const peer = new Peer()
await peer.init(signalServer, relayNode);
// Debug
console.log(`Peer ID: ${peer.peerId.toString()}`);
setPeer(peer);
};
init();
return () => {
if (peer.node) {
// TODO: Await for peer close
peer.close()
}
}
}, []);
return (
<PeerContext.Provider value={peer}>
{children}
</PeerContext.Provider>
);
};

View File

@ -1,2 +0,0 @@
export { PeerContext } from './context/PeerContext'
export { PeerProvider } from './context/PeerProvider'

4512
yarn.lock

File diff suppressed because it is too large Load Diff