@geckos.io/common
Advanced tools
Comparing version 2.0.0-dev.2 to 2.0.0-dev.3
@@ -1,11 +0,14 @@ | ||
import EventEmitter from 'eventemitter3'; | ||
import { Data, ChannelId, EventName, RoomId } from './types'; | ||
import { Events } from '@yandeu/events'; | ||
import { Data, EventOptions, ChannelId, EventName, RoomId } from './types'; | ||
interface BridgeEventMap { | ||
[key: string]: (data?: Data, options?: EventOptions) => void; | ||
} | ||
export declare class Bridge { | ||
eventEmitter: EventEmitter<string | symbol, any>; | ||
eventEmitter: Events<BridgeEventMap>; | ||
emit(eventName: EventName, data?: Data, connection?: { | ||
senderId?: ChannelId; | ||
id?: ChannelId; | ||
roomId?: RoomId; | ||
senderId?: ChannelId; | ||
}): void; | ||
on(eventName: EventName, cb: Function): EventEmitter<string | symbol, any>; | ||
on(eventName: EventName, cb: Function): Events<any>; | ||
removeAllListeners(): void; | ||
@@ -12,0 +15,0 @@ } |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Bridge = void 0; | ||
var eventemitter3_1 = __importDefault(require("eventemitter3")); | ||
var events_1 = require("@yandeu/events"); | ||
var Bridge = /** @class */ (function () { | ||
function Bridge() { | ||
this.eventEmitter = new eventemitter3_1.default(); | ||
this.eventEmitter = new events_1.Events(); | ||
} | ||
@@ -12,0 +9,0 @@ Bridge.prototype.emit = function (eventName, data, connection) { |
declare const EVENTS: { | ||
SEND_OVER_DATA_CHANNEL: string; | ||
RECEIVED_FROM_DATA_CHANNEL: string; | ||
CONNECT: string; | ||
CONNECTION: string; | ||
DATA_CHANNEL_IS_OPEN: string; | ||
DISCONNECT: string; | ||
DISCONNECTED: string; | ||
DISCONNECT: string; | ||
CONNECTION: string; | ||
CONNECT: string; | ||
DROP: string; | ||
ERROR: string; | ||
DATA_CHANNEL_IS_OPEN: string; | ||
RAW_MESSAGE: string; | ||
DROP: string; | ||
RECEIVED_FROM_DATA_CHANNEL: string; | ||
SEND_OVER_DATA_CHANNEL: string; | ||
}; | ||
@@ -13,0 +13,0 @@ declare const ERRORS: { |
@@ -5,12 +5,12 @@ "use strict"; | ||
var EVENTS = { | ||
SEND_OVER_DATA_CHANNEL: 'sendOverDataChannel', | ||
RECEIVED_FROM_DATA_CHANNEL: 'receiveFromDataChannel', | ||
CONNECT: 'connect', | ||
CONNECTION: 'connection', | ||
DATA_CHANNEL_IS_OPEN: 'dataChannelIsOpen', | ||
DISCONNECT: 'disconnect', | ||
DISCONNECTED: 'disconnected', | ||
DISCONNECT: 'disconnect', | ||
CONNECTION: 'connection', | ||
CONNECT: 'connect', | ||
DROP: 'dropped', | ||
ERROR: 'error', | ||
DATA_CHANNEL_IS_OPEN: 'dataChannelIsOpen', | ||
RAW_MESSAGE: 'rawMessage', | ||
DROP: 'dropped' | ||
RECEIVED_FROM_DATA_CHANNEL: 'receiveFromDataChannel', | ||
SEND_OVER_DATA_CHANNEL: 'sendOverDataChannel' | ||
}; | ||
@@ -17,0 +17,0 @@ exports.EVENTS = EVENTS; |
@@ -0,0 +0,0 @@ import { Data } from './types'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
declare const makeRandomId: (length?: number) => string; | ||
export default makeRandomId; | ||
//# sourceMappingURL=makeRandomId.d.ts.map |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ declare const ParseMessage: (ev: MessageEvent) => { |
@@ -9,11 +9,6 @@ "use strict"; | ||
data = ev; | ||
// console.log('data', data) | ||
var isBuffer = helpers_1.isBufferMessage(data); | ||
// console.log('isBuffer', isBuffer) | ||
var isJson = helpers_1.isJSONMessage(data); | ||
// console.log('isJson', isJson) | ||
var isString = helpers_1.isStringMessage(data); | ||
// console.log('isString', isString) | ||
// if (!data && isRaw) return { key: EVENTS.RAW_MESSAGE, data } | ||
// console.log('here?') | ||
// // probably server-side | ||
@@ -20,0 +15,0 @@ // if (!data) { |
declare const makeReliable: (options: any, cb: Function) => void; | ||
export { makeReliable }; | ||
//# sourceMappingURL=reliableMessage.d.ts.map |
@@ -0,0 +0,0 @@ "use strict"; |
declare const runInterval: (interval: number | undefined, runs: number | undefined, cb: Function) => void; | ||
export default runInterval; | ||
//# sourceMappingURL=runInterval.d.ts.map |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { Data, RawMessage, EventName } from './types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var constants_1 = require("./constants"); | ||
var helpers_1 = require("./helpers"); | ||
var constants_1 = require("./constants"); | ||
var SendMessage = function (dataChannel, maxMessageSize, eventName, data) { | ||
@@ -19,3 +19,2 @@ var _a; | ||
// server-side (send() does not exist on the server side) | ||
// console.log('data', data) | ||
if (dataChannel.send) | ||
@@ -22,0 +21,0 @@ dataChannel.send(data); |
@@ -5,7 +5,5 @@ /// <reference types="node" /> | ||
export { ArrayBufferView }; | ||
export declare type USVString = string; | ||
export declare type ChannelId = string | undefined; | ||
export declare type Data = string | number | Object; | ||
export declare type EventName = string; | ||
export declare type RoomId = ChannelId; | ||
export declare type Data = string | number | Object; | ||
export declare type Payload = { | ||
@@ -15,11 +13,20 @@ [eventName: string]: Data; | ||
export declare type RawMessage = USVString | ArrayBuffer | ArrayBufferView; | ||
export declare type RoomId = ChannelId; | ||
export declare type USVString = string; | ||
export interface ServerOptions { | ||
/** | ||
* A async function to authenticate and authorize a user. | ||
* @param auth The authentication token | ||
* @param request The incoming http request | ||
* @param response The outgoing http response | ||
*/ | ||
authorization?: (auth: string | undefined, request: IncomingMessage, response: OutgoingMessage) => Promise<boolean | any>; | ||
autoManageBuffering?: boolean; | ||
cors?: CorsOptions; | ||
iceServers?: RTCIceServer[]; | ||
iceTransportPolicy?: RTCIceTransportPolicy; | ||
label?: string; | ||
maxPacketLifeTime?: number; | ||
maxRetransmits?: number; | ||
ordered?: boolean; | ||
maxRetransmits?: number; | ||
maxPacketLifeTime?: number; | ||
cors?: CorsOptions; | ||
autoManageBuffering?: boolean; | ||
/** Set a custom port range for the WebRTC connection. */ | ||
@@ -32,21 +39,14 @@ portRange?: { | ||
}; | ||
/** | ||
* A async function to authenticate and authorize a user. | ||
* @param auth The authentication token | ||
* @param request The incoming http request | ||
* @param response The outgoing http response | ||
*/ | ||
authorization?: (auth: string | undefined, request: IncomingMessage, response: OutgoingMessage) => Promise<boolean | any>; | ||
} | ||
export interface ClientOptions { | ||
authorization?: string | undefined; | ||
iceServers?: RTCIceServer[]; | ||
iceTransportPolicy?: RTCIceTransportPolicy; | ||
label?: string; | ||
port?: number; | ||
url?: string; | ||
authorization?: string | undefined; | ||
port?: number; | ||
label?: string; | ||
} | ||
export interface EmitOptions { | ||
interval?: number; | ||
reliable?: boolean; | ||
interval?: number; | ||
runs?: number; | ||
@@ -56,4 +56,4 @@ } | ||
export interface CorsOptions { | ||
allowAuthorization?: boolean; | ||
origin: string | CorsOptionsOriginFunction; | ||
allowAuthorization?: boolean; | ||
} | ||
@@ -73,9 +73,9 @@ export interface EventCallbackClient { | ||
export interface DisconnectEventCallbackServer { | ||
(connectionState: 'disconnected' | 'failed' | 'closed'): void; | ||
(connectionState: 'closed' | 'disconnected' | 'failed'): void; | ||
} | ||
export interface EventOptions { | ||
id?: ChannelId; | ||
roomId?: RoomId; | ||
senderId?: ChannelId; | ||
id?: ChannelId; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "@geckos.io/common", | ||
"version": "2.0.0-dev.2", | ||
"version": "2.0.0-dev.3", | ||
"description": "The common module for @geckos.io/server and @geckos.io/client.", | ||
@@ -28,3 +28,3 @@ "main": "lib", | ||
"dependencies": { | ||
"eventemitter3": "^4.0.7" | ||
"@yandeu/events": "0.0.5" | ||
}, | ||
@@ -31,0 +31,0 @@ "funding": { |
@@ -0,0 +0,0 @@ # @geckos.io/common |
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
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
26134
373
+ Added@yandeu/events@0.0.5
+ Added@yandeu/events@0.0.5(transitive)
- Removedeventemitter3@^4.0.7
- Removedeventemitter3@4.0.7(transitive)