peer-data
Advanced tools
Comparing version 1.0.26 to 1.0.27
@@ -1,14 +0,10 @@ | ||
import { EventType } from './data-channel/event-type'; | ||
import { Signaling } from './signaling/signaling'; | ||
import { EventType } from './channel/event-type'; | ||
import { EventHandler } from './dispatcher/handler'; | ||
export declare class App { | ||
private bridge; | ||
private _signaling; | ||
constructor(servers?: RTCConfiguration, dataConstraints?: RTCDataChannelInit); | ||
on(event: EventType, callback: EventHandler): void; | ||
send(data: any): void; | ||
connect(): void; | ||
disconnect(): void; | ||
servers: RTCConfiguration; | ||
dataConstraints: RTCDataChannelInit; | ||
signaling: Signaling; | ||
send(data: any, id?: string): void; | ||
connect(roomId?: string): void; | ||
disconnect(roomId?: string): void; | ||
} |
"use strict"; | ||
const dispatcher_1 = require('./data-channel/dispatcher'); | ||
const event_type_1 = require('./signaling/event-type'); | ||
const connection_1 = require('./connection/connection'); | ||
const bridge_1 = require('./bridge'); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dispatcher_1 = require("./dispatcher/dispatcher"); | ||
const event_type_1 = require("./connection/event-type"); | ||
const connection_1 = require("./connection/connection"); | ||
const bridge_1 = require("./bridge"); | ||
class App { | ||
constructor(servers = {}, dataConstraints = null) { | ||
this._signaling = null; | ||
const connection = new connection_1.Connection(servers, dataConstraints); | ||
@@ -15,46 +15,43 @@ this.bridge = new bridge_1.Bridge(connection); | ||
} | ||
send(data) { | ||
Object.entries(this.bridge.connection.channels) | ||
.forEach(([key, value]) => value.send(data)); | ||
send(data, id) { | ||
if (id) { | ||
const channel = this.bridge.connection.channels[id]; | ||
if (channel) { | ||
channel.send(data); | ||
} | ||
} | ||
else { | ||
Object | ||
.entries(this.bridge.connection.channels) | ||
.forEach(([key, value]) => value.send(data)); | ||
} | ||
} | ||
connect() { | ||
let event = { | ||
type: event_type_1.SignalingEventType.CONNECT, | ||
connect(roomId) { | ||
const event = { | ||
type: event_type_1.EventType.CONNECT, | ||
caller: null, | ||
callee: null, | ||
data: null | ||
room: { id: roomId }, | ||
data: null, | ||
}; | ||
this._signaling.send(event); | ||
dispatcher_1.EventDispatcher.dispatch('send', event); | ||
} | ||
disconnect() { | ||
Object.entries(this.bridge.connection.channels).forEach(([key, value]) => value.close()); | ||
Object.entries(this.bridge.connection.peers).forEach(([key, value]) => value.close()); | ||
disconnect(roomId) { | ||
Object | ||
.entries(this.bridge.connection.channels) | ||
.forEach(([key, value]) => value.close()); | ||
Object | ||
.entries(this.bridge.connection.peers) | ||
.forEach(([key, value]) => value.close()); | ||
const event = { | ||
type: event_type_1.SignalingEventType.DISCONNECT, | ||
type: event_type_1.EventType.DISCONNECT, | ||
caller: null, | ||
callee: null, | ||
data: null | ||
room: { id: roomId }, | ||
data: null, | ||
}; | ||
this._signaling.send(event); | ||
dispatcher_1.EventDispatcher.dispatch('send', event); | ||
} | ||
get servers() { | ||
return this.bridge.connection.servers; | ||
} | ||
set servers(value) { | ||
this.bridge.connection.servers = value; | ||
} | ||
get dataConstraints() { | ||
return this.bridge.connection.dataConstraints; | ||
} | ||
set dataConstraints(value) { | ||
this.bridge.connection.dataConstraints = value; | ||
} | ||
get signaling() { | ||
return this._signaling; | ||
} | ||
set signaling(value) { | ||
this._signaling = value; | ||
} | ||
} | ||
exports.App = App; | ||
//# sourceMappingURL=app.js.map |
@@ -1,2 +0,2 @@ | ||
import { SignalingEvent } from './signaling/event'; | ||
import { Event } from './connection/event'; | ||
import { Signaling } from './signaling/signaling'; | ||
@@ -7,9 +7,10 @@ import { Connection } from './connection/connection'; | ||
constructor(connection: Connection); | ||
onConnect(event: SignalingEvent, signaling: Signaling): void; | ||
onCandidate(event: SignalingEvent): void; | ||
onOffer(event: SignalingEvent, signaling: Signaling): void; | ||
onAnswer(event: SignalingEvent): void; | ||
onDisconnect(event: SignalingEvent): void; | ||
connection: Connection; | ||
onConnect(event: Event): void; | ||
onDisconnect(event: Event): void; | ||
onOffer(event: Event, signaling: Signaling): void; | ||
onAnswer(event: Event): void; | ||
onCandidate(event: Event): void; | ||
private dispatchEvent(event); | ||
private dispatchError(event); | ||
} |
"use strict"; | ||
const event_type_1 = require('./signaling/event-type'); | ||
const factory_1 = require('./peer/factory'); | ||
const factory_2 = require('./data-channel/factory'); | ||
const dispatcher_1 = require('./data-channel/dispatcher'); | ||
const event_type_2 = require('./data-channel/event-type'); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const event_type_1 = require("./connection/event-type"); | ||
const factory_1 = require("./peer/factory"); | ||
const factory_2 = require("./channel/factory"); | ||
const dispatcher_1 = require("./dispatcher/dispatcher"); | ||
const event_type_2 = require("./channel/event-type"); | ||
const LABEL = 'chunks'; | ||
@@ -11,57 +12,65 @@ class Bridge { | ||
this._connection = connection; | ||
dispatcher_1.EventDispatcher.register(event_type_1.EventType.CONNECT, this.onConnect.bind(this)); | ||
dispatcher_1.EventDispatcher.register(event_type_1.EventType.DISCONNECT, this.onDisconnect.bind(this)); | ||
dispatcher_1.EventDispatcher.register(event_type_1.EventType.OFFER, this.onOffer.bind(this)); | ||
dispatcher_1.EventDispatcher.register(event_type_1.EventType.ANSWER, this.onAnswer.bind(this)); | ||
dispatcher_1.EventDispatcher.register(event_type_1.EventType.CANDIDATE, this.onCandidate.bind(this)); | ||
} | ||
onConnect(event, signaling) { | ||
let peer = this._connection.peers[event.caller.id] = factory_1.PeerFactory.get(this._connection.servers, signaling); | ||
let channel = peer.createDataChannel(LABEL, this._connection.dataConstraints); | ||
get connection() { | ||
return this._connection; | ||
} | ||
set connection(value) { | ||
this._connection = value; | ||
} | ||
onConnect(event) { | ||
const peer = this._connection.peers[event.caller.id] = factory_1.PeerFactory.get(this._connection.servers, event); | ||
const channel = peer.createDataChannel(LABEL, this._connection.dataConstraints); | ||
this._connection.channels[event.caller.id] = factory_2.DataChannelFactory.get(channel); | ||
peer.createOffer((desc) => { | ||
let message = { | ||
type: event_type_1.SignalingEventType.OFFER, | ||
const message = { | ||
type: event_type_1.EventType.OFFER, | ||
caller: null, | ||
callee: event.caller, | ||
data: desc | ||
room: event.room, | ||
data: desc, | ||
}; | ||
peer.setLocalDescription(desc, () => signaling.send(message), this.dispatchError); | ||
peer.setLocalDescription(desc, () => this.dispatchEvent(message), this.dispatchError); | ||
}, this.dispatchError); | ||
} | ||
onCandidate(event) { | ||
if (event.data) { | ||
let peer = this._connection.peers[event.caller.id]; | ||
peer.addIceCandidate(new RTCIceCandidate(event.data)); | ||
} | ||
onDisconnect(event) { | ||
const channel = this._connection.channels[event.caller.id]; | ||
channel.close(); | ||
const peer = this._connection.peers[event.caller.id]; | ||
peer.close(); | ||
} | ||
onOffer(event, signaling) { | ||
let peer = this._connection.peers[event.caller.id] = factory_1.PeerFactory.get(this._connection.servers, signaling); | ||
const peer = this._connection.peers[event.caller.id] = factory_1.PeerFactory.get(this._connection.servers, event); | ||
peer.ondatachannel = (dataChannelEvent) => { | ||
this._connection.addChannel(event.caller.id, factory_2.DataChannelFactory.get(dataChannelEvent.channel)); | ||
}; | ||
peer.setRemoteDescription(new RTCSessionDescription(event.data), () => { | ||
}, this.dispatchError); | ||
peer.setRemoteDescription(new RTCSessionDescription(event.data), () => { }, this.dispatchError); | ||
peer.createAnswer((desc) => { | ||
let message = { | ||
type: event_type_1.SignalingEventType.ANSWER, | ||
const message = { | ||
type: event_type_1.EventType.ANSWER, | ||
caller: null, | ||
callee: event.caller, | ||
data: desc | ||
room: event.room, | ||
data: desc, | ||
}; | ||
peer.setLocalDescription(desc, () => signaling.send(message), this.dispatchError); | ||
peer.setLocalDescription(desc, () => this.dispatchEvent(message), this.dispatchError); | ||
}, this.dispatchError); | ||
} | ||
onAnswer(event) { | ||
let peer = this._connection.peers[event.caller.id]; | ||
peer.setRemoteDescription(new RTCSessionDescription(event.data), () => { | ||
}, this.dispatchError); | ||
const peer = this._connection.peers[event.caller.id]; | ||
peer.setRemoteDescription(new RTCSessionDescription(event.data), () => { }, this.dispatchError); | ||
} | ||
onDisconnect(event) { | ||
let channel = this._connection.channels[event.caller.id]; | ||
channel.close(); | ||
let peer = this._connection.peers[event.caller.id]; | ||
peer.close(); | ||
onCandidate(event) { | ||
if (event.data) { | ||
const peer = this._connection.peers[event.caller.id]; | ||
peer.addIceCandidate(new RTCIceCandidate(event.data)); | ||
} | ||
} | ||
get connection() { | ||
return this._connection; | ||
dispatchEvent(event) { | ||
dispatcher_1.EventDispatcher.dispatch('send', event); | ||
} | ||
set connection(value) { | ||
this._connection = value; | ||
} | ||
dispatchError(event) { | ||
@@ -68,0 +77,0 @@ dispatcher_1.EventDispatcher.dispatch(event_type_2.EventType.ERROR, event); |
import { PeerCollection } from '../peer/collection'; | ||
import { DataChannelCollection } from '../data-channel/collection'; | ||
import { DataChannelCollection } from '../channel/collection'; | ||
export declare class Connection { | ||
@@ -4,0 +4,0 @@ private _servers; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Connection { | ||
@@ -3,0 +4,0 @@ constructor(servers = {}, dataConstraints = null) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=collection.js.map |
@@ -1,4 +0,4 @@ | ||
import { Signaling } from '../signaling/signaling'; | ||
import { Event } from './../connection/event'; | ||
export declare class PeerFactory { | ||
static get(servers: RTCConfiguration, signaling: Signaling): RTCPeerConnection; | ||
static get(servers: RTCConfiguration, event: Event): RTCPeerConnection; | ||
} |
"use strict"; | ||
const event_type_1 = require('../signaling/event-type'); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dispatcher_1 = require("./../dispatcher/dispatcher"); | ||
const event_type_1 = require("./../connection/event-type"); | ||
class PeerFactory { | ||
static get(servers, signaling) { | ||
let peer = new RTCPeerConnection(servers); | ||
peer.onicecandidate = (event) => { | ||
let message = { | ||
type: event_type_1.SignalingEventType.CANDIDATE, | ||
static get(servers, event) { | ||
const peer = new RTCPeerConnection(servers); | ||
peer.onicecandidate = (ideEvent) => { | ||
const message = { | ||
type: event_type_1.EventType.CANDIDATE, | ||
caller: null, | ||
callee: null, | ||
data: event.candidate | ||
callee: event.caller, | ||
room: event.room, | ||
data: ideEvent.candidate, | ||
}; | ||
signaling.send(message); | ||
dispatcher_1.EventDispatcher.dispatch('send', message); | ||
}; | ||
@@ -15,0 +18,0 @@ return peer; |
@@ -1,4 +0,4 @@ | ||
import { SignalingEvent } from './event'; | ||
import { Event } from './../connection/event'; | ||
export interface Signaling { | ||
send(message: SignalingEvent): void; | ||
onSend(message: Event): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=signaling.js.map |
import { App as PeerData } from './app/app'; | ||
export default PeerData; | ||
export { Event } from './app/connection/event'; | ||
export { EventDispatcher } from './app/dispatcher/dispatcher'; | ||
export { EventType as ConnectionEventType } from './app/connection/event-type'; | ||
export { EventType as DataEventType } from './app/channel/event-type'; | ||
export { Signaling } from './app/signaling/signaling'; | ||
export { SignalingEvent } from './app/signaling/event'; | ||
export { SignalingEventType } from './app/signaling/event-type'; | ||
export { EventType } from './app/data-channel/event-type'; | ||
export { SocketChannel } from './app/socket-channel'; | ||
export { SocketChannel } from './app/signaling/socket-channel'; |
"use strict"; | ||
const app_1 = require('./app/app'); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const app_1 = require("./app/app"); | ||
exports.default = app_1.App; | ||
var event_type_1 = require('./app/signaling/event-type'); | ||
exports.SignalingEventType = event_type_1.SignalingEventType; | ||
var event_type_2 = require('./app/data-channel/event-type'); | ||
exports.EventType = event_type_2.EventType; | ||
var socket_channel_1 = require('./app/socket-channel'); | ||
var dispatcher_1 = require("./app/dispatcher/dispatcher"); | ||
exports.EventDispatcher = dispatcher_1.EventDispatcher; | ||
var event_type_1 = require("./app/connection/event-type"); | ||
exports.ConnectionEventType = event_type_1.EventType; | ||
var event_type_2 = require("./app/channel/event-type"); | ||
exports.DataEventType = event_type_2.EventType; | ||
var socket_channel_1 = require("./app/signaling/socket-channel"); | ||
exports.SocketChannel = socket_channel_1.SocketChannel; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "peer-data", | ||
"version": "1.0.26", | ||
"version": "1.0.27", | ||
"description": "PeerData - library for files, media streaming/sharing using WebRTC", | ||
"scripts": { | ||
"watch": "tsc -p src -w", | ||
"build": "rm -rf lib && tsc", | ||
"test": "karma start", | ||
"test-watch": "karma start --no-single-run --auto-watch", | ||
"lint": "npm run tslint \"src/**/*.ts\"", | ||
"tslint": "tslint", | ||
"ci": "npm run lint && npm test" | ||
"build": "npm run build:lib & npm run build:umd", | ||
"build:lib": "tsc --outDir lib --module commonjs", | ||
"build:es": "tsc --outDir es --module es6", | ||
"build:umd": "npm run build:es && rollup --config && dts-bundle --name dist/bundle --main es --outputAsModuleFolder", | ||
"clean": "rimraf dist es lib coverage", | ||
"typecheck": "tsc --noEmit", | ||
"lint": "tslint --project tsconfig.json --type-check --format stylish", | ||
"test": "jest --no-cache --config $(node jest.config.js)", | ||
"test:watch": "jest --watch --updateSnapshot --config $(node jest.config.js)", | ||
"prepare": "npm run build", | ||
"prebuild": "npm run clean", | ||
"postbuild": "rimraf {lib,es}/**/__tests__", | ||
"posttest": "npm run typecheck && npm run lint", | ||
"preversion": "npm test", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
"browser": "dist/peer-data.js", | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"jsnext:main": "es/index.js", | ||
"typings": "lib/index.d.ts", | ||
@@ -45,31 +56,27 @@ "repository": { | ||
"devDependencies": { | ||
"@types/core-js": "^0.9.34", | ||
"@types/jasmine": "^2.5.38", | ||
"@types/jest": "^19.2.2", | ||
"@types/node": "^6.0.49", | ||
"@types/socket.io-client": "^1.4.28", | ||
"@types/webrtc": "0.0.21", | ||
"awesome-typescript-loader": "^3.0.0-beta.3", | ||
"enhanced-resolve": "^2.3.0", | ||
"istanbul-instrumenter-loader": "^1.0.0", | ||
"jasmine-core": "^2.5.2", | ||
"jasmine-spec-reporter": "^2.7.0", | ||
"karma": "^1.3.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-jasmine": "^1.0.2", | ||
"karma-mocha-reporter": "^2.2.1", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-remap-istanbul": "^0.2.1", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^1.8.0", | ||
"phantomjs-prebuilt": "^2.1.13", | ||
"remap-istanbul": "^0.7.0", | ||
"tslint": "^4.1.0", | ||
"typescript": "^2.0.10", | ||
"webpack": "2.1.0-beta.25", | ||
"zone.js": "^0.7.1" | ||
"dts-bundle": "^0.7.2", | ||
"jest": "^19.0.2", | ||
"jest-environment-node-debug": "^2.0.0", | ||
"pascal-case": "^2.0.1", | ||
"rimraf": "^2.6.1", | ||
"rollup": "^0.41.6", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-node-builtins": "^2.1.0", | ||
"rollup-plugin-node-globals": "^1.1.0", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-sourcemaps": "^0.4.1", | ||
"rollup-plugin-uglify": "^1.0.1", | ||
"semver": "^5.3.0", | ||
"ts-jest": "^19.0.2", | ||
"tslib": "^1.6.0", | ||
"tslint": "^5.0.0", | ||
"typescript": "^2.2.1" | ||
}, | ||
"dependencies": { | ||
"core-js": "^2.4.1", | ||
"webrtc-adapter": "^2.0.8" | ||
} | ||
} |
# PeerData | ||
[![Build Status](https://travis-ci.org/Vardius/peer-data.svg?branch=master)](https://travis-ci.org/Vardius/peer-data) | ||
[![Build Status](https://travis-ci.org/vardius/peer-data.svg?branch=master)](https://travis-ci.org/Vardius/peer-data) | ||
[![npm version](https://img.shields.io/npm/v/peer-data.svg)](https://www.npmjs.com/package/peer-data) | ||
[![npm downloads](https://img.shields.io/npm/dm/peer-data.svg)](https://www.npmjs.com/package/peer-data) | ||
@@ -18,5 +20,3 @@ PeerData is a library for bidirectional peer-to-peer transfers of arbitrary data using [RTCDataChannel](https://developer.mozilla.org/pl/docs/Web/API/RTCDataChannel). Simple *WebRTC* wrapper providing data channel abstraction. | ||
## Usage | ||
[**Docs**](doc) | ||
- [Usage](doc/usage.md) | ||
## [Documentation](https://github.com/vardius/peer-data/wiki) | ||
@@ -32,2 +32,2 @@ ABOUT | ||
Have problems, bugs, feature ideas? | ||
We are using the github [issue tracker](https://github.com/vardius/peer-data/issues) to manage them. | ||
We are using the github [issue tracker](https://github.com/vardius/peer-data/issues) to manage them. |
{ | ||
"compilerOptions": { | ||
"outDir": "./lib/", | ||
"target": "es6", | ||
"module": "commonjs", | ||
"rootDir": "src", | ||
"outDir": ".code", | ||
"newLine": "LF", | ||
"lib": ["es2017", "dom", "scripthost"], | ||
"moduleResolution": "node", | ||
"lib": ["es5", "dom", "scripthost"], | ||
"importHelpers": true, | ||
"declaration": true, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"noEmitOnError": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
"inlineSources": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true | ||
}, | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"include": [ | ||
"src/**/*.ts", | ||
"./node_modules/@types/**/*.d.ts" | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
"index.d.ts", | ||
"src/**/*.spec.ts", | ||
"node_modules", | ||
"examples", | ||
"**/*.spec.ts", | ||
"dist", | ||
"es", | ||
"lib" | ||
] | ||
} |
{ | ||
"extends": ["tslint:recommended"], | ||
"rules": { | ||
"class-name": true, | ||
"curly": true, | ||
"eofline": true, | ||
"indent": [true, "spaces"], | ||
"max-line-length": [true, 140], | ||
"member-ordering": [true, | ||
"public-before-private", | ||
"static-before-instance", | ||
"variables-before-functions" | ||
], | ||
"no-arg": true, | ||
"no-construct": true, | ||
"no-duplicate-variable": true, | ||
"no-empty": false, | ||
"no-eval": true, | ||
"no-trailing-whitespace": true, | ||
"no-unused-expression": true, | ||
"no-use-before-declare": true, | ||
"one-line": [true, | ||
"check-open-brace", | ||
"check-catch", | ||
"check-else", | ||
"check-whitespace" | ||
], | ||
"quotemark": [true, "single"], | ||
"semicolon": [true, "always"], | ||
"trailing-comma": true, | ||
"triple-equals": true, | ||
"variable-name": false | ||
"arrow-parens": false, | ||
"arrow-return-shorthand": [true], | ||
"import-spacing": true, | ||
"interface-name": [false], | ||
"interface-over-type-literal": false, | ||
"linebreak-style": [true, "LF"], | ||
"max-classes-per-file": [false], | ||
"member-access": [false], | ||
"no-require-imports": true, | ||
"object-literal-sort-keys": false, | ||
"ordered-imports": [false], | ||
"prefer-const": true, | ||
"quotemark": [true, "single", "jsx-double"], | ||
"space-before-function-paren": [true, { | ||
"anonymous": "always", | ||
"asyncArrow": "always", | ||
"constructor": "never", | ||
"method": "never", | ||
"named": "never" | ||
}], | ||
"variable-name": [ | ||
true, | ||
"ban-keywords", | ||
"check-format", | ||
"allow-pascal-case", | ||
"allow-leading-underscore" | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227401
1
21
122
1307
32
1
- Removedcore-js@^2.4.1
- Removedcore-js@2.6.12(transitive)