mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-06 19:38:05 +00:00
Move out react-peer package to its own repo (#308)
This commit is contained in:
parent
ff64dcb43c
commit
dfc3f5a63e
@ -15,6 +15,7 @@
|
||||
"@types/node": "^16.18.10",
|
||||
"@types/react": "^18.0.26",
|
||||
"@types/react-dom": "^18.0.9",
|
||||
"assert": "^2.0.0",
|
||||
"it-pushable": "^3.1.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
|
7
packages/react-peer/.gitignore
vendored
7
packages/react-peer/.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
/coverage
|
||||
/demo/dist
|
||||
/es
|
||||
/lib
|
||||
/node_modules
|
||||
/umd
|
||||
npm-debug.log*
|
@ -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
|
@ -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.
|
@ -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
|
16
packages/react-peer/demo/src/index.js
vendored
16
packages/react-peer/demo/src/index.js
vendored
@ -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'))
|
@ -1,7 +0,0 @@
|
||||
module.exports = {
|
||||
type: 'react-component',
|
||||
npm: {
|
||||
esModules: false,
|
||||
umd: false
|
||||
}
|
||||
}
|
@ -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"
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
import React from "react";
|
||||
|
||||
export const PeerContext = React.createContext({});
|
36
packages/react-peer/src/context/PeerProvider.js
vendored
36
packages/react-peer/src/context/PeerProvider.js
vendored
@ -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>
|
||||
);
|
||||
};
|
2
packages/react-peer/src/index.js
vendored
2
packages/react-peer/src/index.js
vendored
@ -1,2 +0,0 @@
|
||||
export { PeerContext } from './context/PeerContext'
|
||||
export { PeerProvider } from './context/PeerProvider'
|
Loading…
Reference in New Issue
Block a user