Comparing version 0.2.2 to 0.3.0
@@ -1,3 +0,8 @@ | ||
# Version 0.2.2 - 2017/10/18 | ||
# Version 0.3.0 - 2017/10/29 | ||
- Remove all default exports, require verbose include | ||
- Prepare library for use with node servers as well as web browser servers | ||
# Version 0.2.2 - 2017/10/28 | ||
- Fix emission of "scanningfinished" event and message in client/server | ||
@@ -4,0 +9,0 @@ |
@@ -59,3 +59,3 @@ "use strict"; | ||
this._connected = true; | ||
this._server = new ButtplugServer_1.default(); | ||
this._server = new ButtplugServer_1.ButtplugServer(); | ||
this._server.addListener("message", this.OnMessageReceived); | ||
@@ -62,0 +62,0 @@ return [2 /*return*/, Promise.resolve()]; |
export * from "./client/Client"; | ||
export * from "./core/Messages"; | ||
export * from "./core/MessageUtils"; | ||
export * from "./core/Device"; | ||
export * from "./server/ButtplugServer"; | ||
export * from "./server/ButtplugDevice"; | ||
export * from "./server/IDeviceSubtypeManager"; | ||
export * from "./server/bluetooth/ButtplugBluetoothDevice"; | ||
export * from "./server/bluetooth/BluetoothDeviceInfo"; | ||
export * from "./server/bluetooth/BluetoothDevices"; | ||
export * from "./server/bluetooth/IBluetoothDeviceImpl"; |
@@ -8,4 +8,9 @@ "use strict"; | ||
__export(require("./core/Messages")); | ||
__export(require("./core/MessageUtils")); | ||
__export(require("./core/Device")); | ||
__export(require("./server/ButtplugServer")); | ||
__export(require("./server/ButtplugDevice")); | ||
__export(require("./server/bluetooth/ButtplugBluetoothDevice")); | ||
__export(require("./server/bluetooth/BluetoothDeviceInfo")); | ||
__export(require("./server/bluetooth/BluetoothDevices")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,4 @@ | ||
import IBluetoothDeviceImpl from "./IBluetoothDeviceImpl"; | ||
import ButtplugBluetoothDevice from "./ButtplugBluetoothDevice"; | ||
export default class BluetoothDeviceInfo { | ||
import { IBluetoothDeviceImpl } from "./IBluetoothDeviceImpl"; | ||
import { ButtplugBluetoothDevice } from "./ButtplugBluetoothDevice"; | ||
export declare class BluetoothDeviceInfo { | ||
private _names; | ||
@@ -5,0 +5,0 @@ private _services; |
@@ -40,3 +40,3 @@ "use strict"; | ||
}()); | ||
exports.default = BluetoothDeviceInfo; | ||
exports.BluetoothDeviceInfo = BluetoothDeviceInfo; | ||
//# sourceMappingURL=BluetoothDeviceInfo.js.map |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "./BluetoothDeviceInfo"; | ||
export default class BluetoothDevices { | ||
import { BluetoothDeviceInfo } from "./BluetoothDeviceInfo"; | ||
export declare class BluetoothDevices { | ||
static GetDeviceInfo(): BluetoothDeviceInfo[]; | ||
} |
@@ -21,3 +21,3 @@ "use strict"; | ||
}()); | ||
exports.default = BluetoothDevices; | ||
exports.BluetoothDevices = BluetoothDevices; | ||
//# sourceMappingURL=BluetoothDevices.js.map |
@@ -1,4 +0,4 @@ | ||
import ButtplugDevice from "../ButtplugDevice"; | ||
import IBluetoothDeviceImpl from "./IBluetoothDeviceImpl"; | ||
export default class ButtplugBluetoothDevice extends ButtplugDevice { | ||
import { ButtplugDevice } from "../ButtplugDevice"; | ||
import { IBluetoothDeviceImpl } from "./IBluetoothDeviceImpl"; | ||
export declare class ButtplugBluetoothDevice extends ButtplugDevice { | ||
protected _deviceImpl: IBluetoothDeviceImpl; | ||
@@ -5,0 +5,0 @@ constructor(aName: string, _deviceImpl: IBluetoothDeviceImpl); |
@@ -25,4 +25,4 @@ "use strict"; | ||
return ButtplugBluetoothDevice; | ||
}(ButtplugDevice_1.default)); | ||
exports.default = ButtplugBluetoothDevice; | ||
}(ButtplugDevice_1.ButtplugDevice)); | ||
exports.ButtplugBluetoothDevice = ButtplugBluetoothDevice; | ||
//# sourceMappingURL=ButtplugBluetoothDevice.js.map |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
export declare class FleshlightLaunch extends ButtplugBluetoothDevice { | ||
@@ -5,0 +5,0 @@ static readonly DeviceInfo: BluetoothDeviceInfo; |
@@ -80,14 +80,20 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
// Send initializer byte | ||
aDeviceImpl.WriteValue("cmd", new Uint8Array([0x00])); | ||
return [2 /*return*/, new FleshlightLaunch(aDeviceImpl)]; | ||
switch (_a.label) { | ||
case 0: | ||
// Send initializer byte | ||
return [4 /*yield*/, aDeviceImpl.WriteValue("cmd", new Uint8Array([0x00]))]; | ||
case 1: | ||
// Send initializer byte | ||
_a.sent(); | ||
return [2 /*return*/, new FleshlightLaunch(aDeviceImpl)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
FleshlightLaunch.DeviceInfo = new BluetoothDeviceInfo_1.default(["Launch"], ["88f80580-0000-01e6-aace-0002a5d5c51b"], { cmd: "88f80583-0000-01e6-aace-0002a5d5c51b", | ||
FleshlightLaunch.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["Launch"], ["88f80580-0000-01e6-aace-0002a5d5c51b"], { cmd: "88f80583-0000-01e6-aace-0002a5d5c51b", | ||
// rx: "88f80582-0000-01e6-aace-0002a5d5c51b", | ||
tx: "88f80581-0000-01e6-aace-0002a5d5c51b" }, FleshlightLaunch.CreateInstance); | ||
return FleshlightLaunch; | ||
}(ButtplugBluetoothDevice_1.default)); | ||
}(ButtplugBluetoothDevice_1.ButtplugBluetoothDevice)); | ||
exports.FleshlightLaunch = FleshlightLaunch; | ||
//# sourceMappingURL=FleshlightLaunch.js.map |
@@ -1,5 +0,5 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
export default class Lovense extends ButtplugBluetoothDevice { | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
export declare class Lovense extends ButtplugBluetoothDevice { | ||
static CreateInstance(aDeviceImpl: IBluetoothDeviceImpl): Promise<ButtplugBluetoothDevice>; | ||
@@ -6,0 +6,0 @@ private static _deviceNames; |
@@ -51,2 +51,3 @@ "use strict"; | ||
var Messages = require("../../../core/Messages"); | ||
var text_encoding_1 = require("text-encoding"); | ||
var Lovense = /** @class */ (function (_super) { | ||
@@ -70,3 +71,3 @@ __extends(Lovense, _super); | ||
speed = Math.floor(20 * aMsg.Speed); | ||
return [4 /*yield*/, this._deviceImpl.WriteValue("tx", new TextEncoder().encode("Vibrate:" + speed + ";"))]; | ||
return [4 /*yield*/, this._deviceImpl.WriteValue("tx", new text_encoding_1.TextEncoder().encode("Vibrate:" + speed + ";"))]; | ||
case 1: | ||
@@ -93,8 +94,8 @@ _a.sent(); | ||
return Lovense; | ||
}(ButtplugBluetoothDevice_1.default)); | ||
exports.default = Lovense; | ||
}(ButtplugBluetoothDevice_1.ButtplugBluetoothDevice)); | ||
exports.Lovense = Lovense; | ||
var LovenseRev1 = /** @class */ (function () { | ||
function LovenseRev1() { | ||
} | ||
LovenseRev1.DeviceInfo = new BluetoothDeviceInfo_1.default(["LVS-A011", "LVS-C011", "LVS-B011", "LVS-L009"], ["0000fff0-0000-1000-8000-00805f9b34fb"], { tx: "0000fff2-0000-1000-8000-00805f9b34fb", | ||
LovenseRev1.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["LVS-A011", "LVS-C011", "LVS-B011", "LVS-L009"], ["0000fff0-0000-1000-8000-00805f9b34fb"], { tx: "0000fff2-0000-1000-8000-00805f9b34fb", | ||
}, Lovense.CreateInstance); | ||
@@ -107,3 +108,3 @@ return LovenseRev1; | ||
} | ||
LovenseRev2.DeviceInfo = new BluetoothDeviceInfo_1.default(["LVS-S001", "LVS-Z001"], ["6e400001-b5a3-f393-e0a9-e50e24dcca9e"], { tx: "6e400002-b5a3-f393-e0a9-e50e24dcca9e", | ||
LovenseRev2.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["LVS-S001", "LVS-Z001"], ["6e400001-b5a3-f393-e0a9-e50e24dcca9e"], { tx: "6e400002-b5a3-f393-e0a9-e50e24dcca9e", | ||
}, Lovense.CreateInstance); | ||
@@ -116,3 +117,3 @@ return LovenseRev2; | ||
} | ||
LovenseRev3.DeviceInfo = new BluetoothDeviceInfo_1.default(["LVS-P36"], ["50300001-0024-4bd4-bbd5-a6920e4c5653"], { tx: "50300002-0024-4bd4-bbd5-a6920e4c5653", | ||
LovenseRev3.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["LVS-P36"], ["50300001-0024-4bd4-bbd5-a6920e4c5653"], { tx: "50300002-0024-4bd4-bbd5-a6920e4c5653", | ||
}, Lovense.CreateInstance); | ||
@@ -125,3 +126,3 @@ return LovenseRev3; | ||
} | ||
LovenseRev4.DeviceInfo = new BluetoothDeviceInfo_1.default(["LVS-Domi37"], ["57300001-0023-4bd4-bbd5-a6920e4c5653"], { tx: "57300002-0023-4bd4-bbd5-a6920e4c5653", | ||
LovenseRev4.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["LVS-Domi37"], ["57300001-0023-4bd4-bbd5-a6920e4c5653"], { tx: "57300002-0023-4bd4-bbd5-a6920e4c5653", | ||
}, Lovense.CreateInstance); | ||
@@ -128,0 +129,0 @@ return LovenseRev4; |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
export declare class VorzeA10Cyclone extends ButtplugBluetoothDevice { | ||
@@ -5,0 +5,0 @@ static readonly DeviceInfo: BluetoothDeviceInfo; |
@@ -89,6 +89,6 @@ "use strict"; | ||
}; | ||
VorzeA10Cyclone.DeviceInfo = new BluetoothDeviceInfo_1.default(["CycSA"], ["40ee1111-63ec-4b7f-8ce7-712efd55b90e"], { tx: "40ee2222-63ec-4b7f-8ce7-712efd55b90e" }, VorzeA10Cyclone.CreateInstance); | ||
VorzeA10Cyclone.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["CycSA"], ["40ee1111-63ec-4b7f-8ce7-712efd55b90e"], { tx: "40ee2222-63ec-4b7f-8ce7-712efd55b90e" }, VorzeA10Cyclone.CreateInstance); | ||
return VorzeA10Cyclone; | ||
}(ButtplugBluetoothDevice_1.default)); | ||
}(ButtplugBluetoothDevice_1.ButtplugBluetoothDevice)); | ||
exports.VorzeA10Cyclone = VorzeA10Cyclone; | ||
//# sourceMappingURL=VorzeA10Cyclone.js.map |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
export declare class WeVibe extends ButtplugBluetoothDevice { | ||
@@ -5,0 +5,0 @@ static readonly DeviceInfo: BluetoothDeviceInfo; |
@@ -88,7 +88,7 @@ "use strict"; | ||
}; | ||
WeVibe.DeviceInfo = new BluetoothDeviceInfo_1.default(["4 Plus", "Ditto", "Nova", "Wish", "Pivot", "Verge"], ["f000bb03-0451-4000-b000-000000000000"], { tx: "f000c000-0451-4000-b000-000000000000", | ||
WeVibe.DeviceInfo = new BluetoothDeviceInfo_1.BluetoothDeviceInfo(["4 Plus", "Ditto", "Nova", "Wish", "Pivot", "Verge"], ["f000bb03-0451-4000-b000-000000000000"], { tx: "f000c000-0451-4000-b000-000000000000", | ||
rx: "f000b000-0451-4000-b000-000000000000" }, WeVibe.CreateInstance); | ||
return WeVibe; | ||
}(ButtplugBluetoothDevice_1.default)); | ||
}(ButtplugBluetoothDevice_1.ButtplugBluetoothDevice)); | ||
exports.WeVibe = WeVibe; | ||
//# sourceMappingURL=WeVibe.js.map |
@@ -1,2 +0,2 @@ | ||
export default interface IBluetoothDeviceImpl { | ||
export interface IBluetoothDeviceImpl { | ||
Name: string; | ||
@@ -3,0 +3,0 @@ WriteValue: (aCharacteristic: string, aValue: Uint8Array) => Promise<void>; |
/// <reference types="node" /> | ||
/// <reference types="web-bluetooth" /> | ||
import IBluetoothDeviceImpl from "./IBluetoothDeviceImpl"; | ||
import BluetoothDeviceInfo from "./BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "./ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "./IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "./BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "./ButtplugBluetoothDevice"; | ||
import { EventEmitter } from "events"; | ||
export default class WebBluetoothDevice extends EventEmitter implements IBluetoothDeviceImpl { | ||
export declare class WebBluetoothDevice extends EventEmitter implements IBluetoothDeviceImpl { | ||
private _deviceInfo; | ||
@@ -9,0 +9,0 @@ private _device; |
@@ -155,3 +155,3 @@ "use strict"; | ||
}(events_1.EventEmitter)); | ||
exports.default = WebBluetoothDevice; | ||
exports.WebBluetoothDevice = WebBluetoothDevice; | ||
//# sourceMappingURL=WebBluetoothDevice.js.map |
/// <reference types="node" /> | ||
import IDeviceSubtypeManager from "../IDeviceSubtypeManager"; | ||
import { IDeviceSubtypeManager } from "../IDeviceSubtypeManager"; | ||
import { EventEmitter } from "events"; | ||
export default class WebBluetoothDeviceManager extends EventEmitter implements IDeviceSubtypeManager { | ||
export declare class WebBluetoothDeviceManager extends EventEmitter implements IDeviceSubtypeManager { | ||
StartScanning(): boolean; | ||
@@ -6,0 +6,0 @@ StopScanning(): boolean; |
@@ -64,3 +64,3 @@ "use strict"; | ||
} | ||
info = BluetoothDevices_1.default.GetDeviceInfo(); | ||
info = BluetoothDevices_1.BluetoothDevices.GetDeviceInfo(); | ||
deviceInfo = null; | ||
@@ -79,3 +79,3 @@ for (_i = 0, info_1 = info; _i < info_1.length; _i++) { | ||
} | ||
return [4 /*yield*/, WebBluetoothDevice_1.default.CreateDevice(deviceInfo, aDevice)]; | ||
return [4 /*yield*/, WebBluetoothDevice_1.WebBluetoothDevice.CreateDevice(deviceInfo, aDevice)]; | ||
case 1: | ||
@@ -93,3 +93,3 @@ device = _a.sent(); | ||
// Form scanning filters | ||
var info = BluetoothDevices_1.default.GetDeviceInfo(); | ||
var info = BluetoothDevices_1.BluetoothDevices.GetDeviceInfo(); | ||
var filters = { | ||
@@ -130,3 +130,3 @@ filters: new Array(), | ||
}(events_1.EventEmitter)); | ||
exports.default = WebBluetoothDeviceManager; | ||
exports.WebBluetoothDeviceManager = WebBluetoothDeviceManager; | ||
//# sourceMappingURL=WebBluetoothDeviceManager.js.map |
/// <reference types="node" /> | ||
import * as Messages from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
import IButtplugDevice from "./IButtplugDevice"; | ||
export default class ButtplugDevice extends EventEmitter implements IButtplugDevice { | ||
import { IButtplugDevice } from "./IButtplugDevice"; | ||
export declare class ButtplugDevice extends EventEmitter implements IButtplugDevice { | ||
protected _name: string; | ||
@@ -7,0 +7,0 @@ protected readonly MsgFuncs: Map<string, (aMsg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>>; |
@@ -79,3 +79,3 @@ "use strict"; | ||
}(events_1.EventEmitter)); | ||
exports.default = ButtplugDevice; | ||
exports.ButtplugDevice = ButtplugDevice; | ||
//# sourceMappingURL=ButtplugDevice.js.map |
/// <reference types="node" /> | ||
import * as Messages from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
export default class ButtplugServer extends EventEmitter { | ||
import { IDeviceSubtypeManager } from "./IDeviceSubtypeManager"; | ||
export declare class ButtplugServer extends EventEmitter { | ||
private _serverName; | ||
@@ -14,2 +15,3 @@ private _maxPingTime; | ||
constructor(_serverName?: string, _maxPingTime?: number); | ||
AddDeviceManager: (aManager: IDeviceSubtypeManager) => void; | ||
SendMessage: (aMessage: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>; | ||
@@ -16,0 +18,0 @@ Shutdown: () => Promise<void>; |
@@ -66,2 +66,5 @@ "use strict"; | ||
_this._outgoingLogLevel = Logging_1.LogLevel.Off; | ||
_this.AddDeviceManager = function (aManager) { | ||
_this._deviceManager.AddDeviceManager(aManager); | ||
}; | ||
_this.SendMessage = function (aMessage) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -124,4 +127,4 @@ var id, logmsg, testmsg; | ||
_this._logger.Info("Starting Buttplug Server: " + _this._serverName); | ||
_this._deviceManager = new DeviceManager_1.default(); | ||
ServerMessageHub_1.default.Instance.addListener("message", _this.OnOutgoingMessage); | ||
_this._deviceManager = new DeviceManager_1.DeviceManager(); | ||
ServerMessageHub_1.ServerMessageHub.Instance.addListener("message", _this.OnOutgoingMessage); | ||
return _this; | ||
@@ -143,3 +146,3 @@ } | ||
}(events_1.EventEmitter)); | ||
exports.default = ButtplugServer; | ||
exports.ButtplugServer = ButtplugServer; | ||
//# sourceMappingURL=ButtplugServer.js.map |
/// <reference types="node" /> | ||
import * as Messages from "../core/Messages"; | ||
import { IDeviceSubtypeManager } from "./IDeviceSubtypeManager"; | ||
import { EventEmitter } from "events"; | ||
export default class DeviceManager extends EventEmitter { | ||
export declare class DeviceManager extends EventEmitter { | ||
private _subtypeManagers; | ||
@@ -10,2 +11,3 @@ private _devices; | ||
constructor(); | ||
AddDeviceManager: (aManager: IDeviceSubtypeManager) => void; | ||
SendMessage: (aMessage: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>; | ||
@@ -12,0 +14,0 @@ private OnDeviceAdded; |
@@ -61,2 +61,8 @@ "use strict"; | ||
_this._logger = Logging_1.ButtplugLogger.Logger; | ||
_this.AddDeviceManager = function (aManager) { | ||
_this._subtypeManagers.push(aManager); | ||
aManager.addListener("deviceadded", _this.OnDeviceAdded); | ||
aManager.addListener("deviceremoved", _this.OnDeviceRemoved); | ||
aManager.addListener("scanningfinished", _this.OnScanningFinished); | ||
}; | ||
_this.SendMessage = function (aMessage) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -115,3 +121,3 @@ var id, _i, _a, manager, _b, _c, manager, deviceMsg, device; | ||
device.addListener("deviceremoved", _this.OnDeviceRemoved); | ||
ServerMessageHub_1.default.Instance.emitMessage(new Messages.DeviceAdded(deviceIndex, device.Name, device.GetAllowedMessageTypes())); | ||
ServerMessageHub_1.ServerMessageHub.Instance.emitMessage(new Messages.DeviceAdded(deviceIndex, device.Name, device.GetAllowedMessageTypes())); | ||
}; | ||
@@ -132,3 +138,3 @@ _this.OnDeviceRemoved = function (device) { | ||
_this._devices.delete(deviceIndex); | ||
ServerMessageHub_1.default.Instance.emitMessage(new Messages.DeviceRemoved(deviceIndex)); | ||
ServerMessageHub_1.ServerMessageHub.Instance.emitMessage(new Messages.DeviceRemoved(deviceIndex)); | ||
}; | ||
@@ -142,8 +148,10 @@ _this.OnScanningFinished = function () { | ||
} | ||
ServerMessageHub_1.default.Instance.emitMessage(new Messages.ScanningFinished()); | ||
ServerMessageHub_1.ServerMessageHub.Instance.emitMessage(new Messages.ScanningFinished()); | ||
}; | ||
_this._logger.Debug("Starting Device Manager"); | ||
// If we have a bluetooth object on navigator, load the device manager | ||
if (navigator && navigator.bluetooth) { | ||
var manager = new WebBluetoothDeviceManager_1.default(); | ||
if (typeof (window) !== "undefined" && | ||
typeof (window.navigator) !== "undefined" && | ||
navigator.bluetooth) { | ||
var manager = new WebBluetoothDeviceManager_1.WebBluetoothDeviceManager(); | ||
manager.addListener("deviceadded", _this.OnDeviceAdded); | ||
@@ -162,3 +170,3 @@ manager.addListener("deviceremoved", _this.OnDeviceRemoved); | ||
}(events_1.EventEmitter)); | ||
exports.default = DeviceManager; | ||
exports.DeviceManager = DeviceManager; | ||
//# sourceMappingURL=DeviceManager.js.map |
/// <reference types="node" /> | ||
import * as Messages from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
export default interface IButtplugDevice extends EventEmitter { | ||
export interface IButtplugDevice extends EventEmitter { | ||
Name: string; | ||
@@ -6,0 +6,0 @@ GetAllowedMessageTypes(): string[]; |
/// <reference types="node" /> | ||
import { EventEmitter } from "events"; | ||
export default interface IDeviceSubtypeManager extends EventEmitter { | ||
export interface IDeviceSubtypeManager extends EventEmitter { | ||
StartScanning(): void; | ||
@@ -5,0 +5,0 @@ StopScanning(): void; |
/// <reference types="node" /> | ||
import { ButtplugMessage } from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
export default class ServerMessageHub extends EventEmitter { | ||
export declare class ServerMessageHub extends EventEmitter { | ||
private static sInstance; | ||
@@ -6,0 +6,0 @@ static readonly Instance: ServerMessageHub; |
@@ -32,3 +32,3 @@ "use strict"; | ||
}(events_1.EventEmitter)); | ||
exports.default = ServerMessageHub; | ||
exports.ServerMessageHub = ServerMessageHub; | ||
//# sourceMappingURL=ServerMessageHub.js.map |
@@ -19,5 +19,4 @@ "use strict"; | ||
var jsonStr = '[{"DeviceList":{"Id":2,"Devices": [{"DeviceIndex":0,"DeviceName":"Test","DeviceMessages":["Ok","Ping"]},{"DeviceIndex":1,"DeviceName":"Test1","DeviceMessages":["Ok","Ping"]}]}}]'; | ||
// tslint:disable-next-line:max-line-length | ||
chai_1.expect(MessageUtils_1.FromJSON(jsonStr)).to.deep.equal([new Messages.DeviceList([new Messages.DeviceInfo(0, "Test", ["Ok", "Ping"]), | ||
new Messages.DeviceInfo(1, "Test1", ["Ok", "Ping"])], 2)]); | ||
// tslint:disable:max-line-length | ||
chai_1.expect(MessageUtils_1.FromJSON(jsonStr)).to.deep.equal([new Messages.DeviceList([new Messages.DeviceInfo(0, "Test", ["Ok", "Ping"]), new Messages.DeviceInfo(1, "Test1", ["Ok", "Ping"])], 2)]); | ||
}); | ||
@@ -24,0 +23,0 @@ it("Converts DeviceAdded message from json correctly", function () { |
{ | ||
"name": "buttplug", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Javascript library for accessing buttplug servers via node.js or web sockets", | ||
"main": "./dist/main/src/index.js", | ||
"types": "./dist/main/src/index.d.ts", | ||
"scripts": { | ||
"build": "trash dist dist-bundle && yarn build:main", | ||
"build:copy-schema": "copyfiles ./dependencies/buttplug-schema/schema/buttplug-schema.json ./dist/main/", | ||
"build:main": "tsc -p tsconfig.json && yarn build:copy-schema", | ||
"tslint": "tslint -c tslint.json \"src/**/*.ts\" \"tests/**/*.ts\"", | ||
"tslint:fix": "tslint -c tslint.json --fix semicolon,comma,no-var-keyword,ordered-imports \"src/**/*.ts\" \"tests/**/*.ts\"", | ||
"pretest": "yarn build:main", | ||
"test": "nyc mocha \"tests/**/*.ts\"", | ||
"posttest": "nyc report && codecov -f coverage/*.json" | ||
}, | ||
"repository": { | ||
@@ -31,25 +19,37 @@ "type": "git", | ||
"homepage": "https://github.com/metafetish/buttplug-js#readme", | ||
"main": "./dist/main/src/index.js", | ||
"types": "./dist/main/src/index.d.ts", | ||
"scripts": { | ||
"build": "trash dist dist-bundle && yarn build:main", | ||
"build:copy-schema": "copyfiles ./dependencies/buttplug-schema/schema/buttplug-schema.json ./dist/main/", | ||
"build:main": "tsc -p tsconfig.json && yarn build:copy-schema", | ||
"tslint": "tslint -c tslint.json \"src/**/*.ts\" \"tests/**/*.ts\"", | ||
"tslint:fix": "tslint -c tslint.json --fix semicolon,comma,no-var-keyword,ordered-imports \"src/**/*.ts\" \"tests/**/*.ts\"", | ||
"pretest": "yarn build:main", | ||
"test": "nyc mocha \"tests/**/*.ts\"", | ||
"posttest": "nyc report && codecov -f coverage/*.json" | ||
}, | ||
"dependencies": { | ||
"ajv": "^5.2.3", | ||
"ajv": "^5.3.0", | ||
"class-transformer": "^0.1.8", | ||
"reflect-metadata": "^0.1.10", | ||
"ws": "^3.2.0" | ||
"text-encoding": "^0.6.4" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^3.5.2", | ||
"@types/mocha": "^2.2.43", | ||
"@types/node": "^7.0.43", | ||
"@types/text-encoding": "^0.0.31", | ||
"@types/web-bluetooth": "^0.0.2", | ||
"chai": "^3.5.0", | ||
"codecov": "^2.2.0", | ||
"@types/chai": "^4.0.4", | ||
"@types/mocha": "^2.2.44", | ||
"@types/node": "^8.0.47", | ||
"@types/text-encoding": "^0.0.32", | ||
"@types/web-bluetooth": "^0.0.3", | ||
"chai": "^4.1.2", | ||
"codecov": "^3.0.0", | ||
"copyfiles": "^1.2.0", | ||
"mocha": "^3.5.3", | ||
"mock-socket": "^6.1.0", | ||
"nyc": "^10.3.2", | ||
"mocha": "^4.0.1", | ||
"mock-socket": "^7.0.0", | ||
"nyc": "^11.2.1", | ||
"trash-cli": "^1.4.0", | ||
"ts-node": "^3.2.0", | ||
"tslint": "^5.7.0", | ||
"ts-node": "^3.3.0", | ||
"tslint": "^5.8.0", | ||
"typescript": "^2.5.3", | ||
"yarn": "^1.1.0" | ||
"yarn": "^1.2.1" | ||
}, | ||
@@ -56,0 +56,0 @@ "nyc": { |
@@ -6,3 +6,3 @@ "use strict"; | ||
import { IButtplugConnector } from "./IButtplugConnector"; | ||
import ButtplugServer from "../server/ButtplugServer"; | ||
import { ButtplugServer } from "../server/ButtplugServer"; | ||
@@ -9,0 +9,0 @@ export class ButtplugBrowserConnector extends EventEmitter implements IButtplugConnector { |
export * from "./client/Client"; | ||
export * from "./core/Messages"; | ||
export * from "./core/MessageUtils"; | ||
export * from "./core/Device"; | ||
export * from "./server/ButtplugServer"; | ||
export * from "./server/ButtplugDevice"; | ||
export * from "./server/IDeviceSubtypeManager"; | ||
export * from "./server/bluetooth/ButtplugBluetoothDevice"; | ||
export * from "./server/bluetooth/BluetoothDeviceInfo"; | ||
export * from "./server/bluetooth/BluetoothDevices"; | ||
export * from "./server/bluetooth/IBluetoothDeviceImpl"; |
@@ -1,5 +0,5 @@ | ||
import IBluetoothDeviceImpl from "./IBluetoothDeviceImpl"; | ||
import ButtplugBluetoothDevice from "./ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "./IBluetoothDeviceImpl"; | ||
import { ButtplugBluetoothDevice } from "./ButtplugBluetoothDevice"; | ||
export default class BluetoothDeviceInfo { | ||
export class BluetoothDeviceInfo { | ||
constructor(private _names: string[], | ||
@@ -6,0 +6,0 @@ private _services: string[], |
@@ -1,2 +0,2 @@ | ||
import BluetoothDeviceInfo from "./BluetoothDeviceInfo"; | ||
import { BluetoothDeviceInfo } from "./BluetoothDeviceInfo"; | ||
import { FleshlightLaunch } from "./devices/FleshlightLaunch"; | ||
@@ -7,3 +7,3 @@ import { LovenseRev1, LovenseRev2, LovenseRev3, LovenseRev4 } from "./devices/Lovense"; | ||
export default class BluetoothDevices { | ||
export class BluetoothDevices { | ||
public static GetDeviceInfo(): BluetoothDeviceInfo[] { | ||
@@ -10,0 +10,0 @@ return [FleshlightLaunch.DeviceInfo, |
@@ -1,5 +0,5 @@ | ||
import ButtplugDevice from "../ButtplugDevice"; | ||
import IBluetoothDeviceImpl from "./IBluetoothDeviceImpl"; | ||
import { ButtplugDevice } from "../ButtplugDevice"; | ||
import { IBluetoothDeviceImpl } from "./IBluetoothDeviceImpl"; | ||
export default class ButtplugBluetoothDevice extends ButtplugDevice { | ||
export class ButtplugBluetoothDevice extends ButtplugDevice { | ||
public constructor(aName: string, protected _deviceImpl: IBluetoothDeviceImpl) { | ||
@@ -6,0 +6,0 @@ super(aName); |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
import * as Messages from "../../../core/Messages"; | ||
@@ -16,3 +16,3 @@ | ||
// Send initializer byte | ||
aDeviceImpl.WriteValue("cmd", new Uint8Array([0x00])); | ||
await aDeviceImpl.WriteValue("cmd", new Uint8Array([0x00])); | ||
return new FleshlightLaunch(aDeviceImpl); | ||
@@ -19,0 +19,0 @@ } |
@@ -1,7 +0,8 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
import * as Messages from "../../../core/Messages"; | ||
import { TextEncoder } from "text-encoding"; | ||
export default class Lovense extends ButtplugBluetoothDevice { | ||
export class Lovense extends ButtplugBluetoothDevice { | ||
public static CreateInstance(aDeviceImpl: IBluetoothDeviceImpl): Promise<ButtplugBluetoothDevice> { | ||
@@ -8,0 +9,0 @@ return Promise.resolve(new Lovense(aDeviceImpl)); |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
import * as Messages from "../../../core/Messages"; | ||
@@ -5,0 +5,0 @@ |
@@ -1,4 +0,4 @@ | ||
import BluetoothDeviceInfo from "../BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "../ButtplugBluetoothDevice"; | ||
import IBluetoothDeviceImpl from "../IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "../BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "../ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "../IBluetoothDeviceImpl"; | ||
import * as Messages from "../../../core/Messages"; | ||
@@ -5,0 +5,0 @@ |
@@ -1,2 +0,2 @@ | ||
export default interface IBluetoothDeviceImpl { | ||
export interface IBluetoothDeviceImpl { | ||
Name: string; | ||
@@ -3,0 +3,0 @@ WriteValue: (aCharacteristic: string, aValue: Uint8Array) => Promise<void>; |
@@ -1,7 +0,7 @@ | ||
import IBluetoothDeviceImpl from "./IBluetoothDeviceImpl"; | ||
import BluetoothDeviceInfo from "./BluetoothDeviceInfo"; | ||
import ButtplugBluetoothDevice from "./ButtplugBluetoothDevice"; | ||
import { IBluetoothDeviceImpl } from "./IBluetoothDeviceImpl"; | ||
import { BluetoothDeviceInfo } from "./BluetoothDeviceInfo"; | ||
import { ButtplugBluetoothDevice } from "./ButtplugBluetoothDevice"; | ||
import { EventEmitter } from "events"; | ||
export default class WebBluetoothDevice extends EventEmitter implements IBluetoothDeviceImpl { | ||
export class WebBluetoothDevice extends EventEmitter implements IBluetoothDeviceImpl { | ||
@@ -8,0 +8,0 @@ public static async CreateDevice(aDeviceInfo: BluetoothDeviceInfo, |
import { DeviceAdded } from "../../core/Messages"; | ||
import IDeviceSubtypeManager from "../IDeviceSubtypeManager"; | ||
import BluetoothDevices from "./BluetoothDevices"; | ||
import BluetoothDeviceInfo from "./BluetoothDeviceInfo"; | ||
import { IDeviceSubtypeManager } from "../IDeviceSubtypeManager"; | ||
import { BluetoothDevices } from "./BluetoothDevices"; | ||
import { BluetoothDeviceInfo } from "./BluetoothDeviceInfo"; | ||
import { EventEmitter } from "events"; | ||
import WebBluetoothDevice from "./WebBluetoothDevice"; | ||
import { WebBluetoothDevice } from "./WebBluetoothDevice"; | ||
export default class WebBluetoothDeviceManager extends EventEmitter implements IDeviceSubtypeManager { | ||
export class WebBluetoothDeviceManager extends EventEmitter implements IDeviceSubtypeManager { | ||
public StartScanning() { | ||
@@ -10,0 +10,0 @@ // Form scanning filters |
import * as Messages from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
import IButtplugDevice from "./IButtplugDevice"; | ||
import { IButtplugDevice } from "./IButtplugDevice"; | ||
export default class ButtplugDevice extends EventEmitter implements IButtplugDevice { | ||
export class ButtplugDevice extends EventEmitter implements IButtplugDevice { | ||
protected readonly MsgFuncs: Map<string, (aMsg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>> = | ||
@@ -7,0 +7,0 @@ new Map<string, (aMsg: Messages.ButtplugMessage) => Promise<Messages.ButtplugMessage>>(); |
import * as Messages from "../core/Messages"; | ||
import DeviceManager from "./DeviceManager"; | ||
import { DeviceManager } from "./DeviceManager"; | ||
import { EventEmitter } from "events"; | ||
import ServerMessageHub from "./ServerMessageHub"; | ||
import { ServerMessageHub } from "./ServerMessageHub"; | ||
import { IDeviceSubtypeManager } from "./IDeviceSubtypeManager"; | ||
import { ButtplugLogger, LogLevel, LogMessage } from "../core/Logging"; | ||
export default class ButtplugServer extends EventEmitter { | ||
export class ButtplugServer extends EventEmitter { | ||
@@ -33,2 +34,6 @@ public static CanUseBluetooth = async (): Promise<boolean> => { | ||
public AddDeviceManager = (aManager: IDeviceSubtypeManager) => { | ||
this._deviceManager.AddDeviceManager(aManager); | ||
} | ||
public SendMessage = async (aMessage: Messages.ButtplugMessage): Promise<Messages.ButtplugMessage> => { | ||
@@ -35,0 +40,0 @@ const id = aMessage.Id; |
import * as Messages from "../core/Messages"; | ||
import IButtplugDevice from "./IButtplugDevice"; | ||
import IDeviceSubtypeManager from "./IDeviceSubtypeManager"; | ||
import WebBluetoothDeviceManager from "./bluetooth/WebBluetoothDeviceManager"; | ||
import { IButtplugDevice } from "./IButtplugDevice"; | ||
import { IDeviceSubtypeManager } from "./IDeviceSubtypeManager"; | ||
import { WebBluetoothDeviceManager } from "./bluetooth/WebBluetoothDeviceManager"; | ||
import { EventEmitter } from "events"; | ||
import ServerMessageHub from "./ServerMessageHub"; | ||
import { ServerMessageHub } from "./ServerMessageHub"; | ||
import { ButtplugLogger } from "../core/Logging"; | ||
export default class DeviceManager extends EventEmitter { | ||
export class DeviceManager extends EventEmitter { | ||
private _subtypeManagers: IDeviceSubtypeManager[] = []; | ||
@@ -19,3 +19,5 @@ private _devices: Map<number, IButtplugDevice> = new Map<number, IButtplugDevice>(); | ||
// If we have a bluetooth object on navigator, load the device manager | ||
if (navigator && (navigator as any).bluetooth) { | ||
if (typeof(window) !== "undefined" && | ||
typeof(window.navigator) !== "undefined" && | ||
(navigator as any).bluetooth) { | ||
const manager = new WebBluetoothDeviceManager(); | ||
@@ -32,2 +34,9 @@ manager.addListener("deviceadded", this.OnDeviceAdded); | ||
public AddDeviceManager = (aManager: IDeviceSubtypeManager) => { | ||
this._subtypeManagers.push(aManager); | ||
aManager.addListener("deviceadded", this.OnDeviceAdded); | ||
aManager.addListener("deviceremoved", this.OnDeviceRemoved); | ||
aManager.addListener("scanningfinished", this.OnScanningFinished); | ||
} | ||
public SendMessage = async (aMessage: Messages.ButtplugMessage): Promise<Messages.ButtplugMessage> => { | ||
@@ -34,0 +43,0 @@ const id = aMessage.Id; |
import * as Messages from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
export default interface IButtplugDevice extends EventEmitter { | ||
export interface IButtplugDevice extends EventEmitter { | ||
Name: string; | ||
@@ -6,0 +6,0 @@ GetAllowedMessageTypes(): string[]; |
import {EventEmitter} from "events"; | ||
export default interface IDeviceSubtypeManager extends EventEmitter { | ||
export interface IDeviceSubtypeManager extends EventEmitter { | ||
StartScanning(): void; | ||
@@ -5,0 +5,0 @@ StopScanning(): void; |
import { ButtplugMessage } from "../core/Messages"; | ||
import { EventEmitter } from "events"; | ||
export default class ServerMessageHub extends EventEmitter { | ||
export class ServerMessageHub extends EventEmitter { | ||
private static sInstance: ServerMessageHub = new ServerMessageHub(); | ||
@@ -6,0 +6,0 @@ |
@@ -21,6 +21,4 @@ import { expect } from "chai"; | ||
const jsonStr = '[{"DeviceList":{"Id":2,"Devices": [{"DeviceIndex":0,"DeviceName":"Test","DeviceMessages":["Ok","Ping"]},{"DeviceIndex":1,"DeviceName":"Test1","DeviceMessages":["Ok","Ping"]}]}}]'; | ||
// tslint:disable-next-line:max-line-length | ||
expect(FromJSON(jsonStr)).to.deep.equal([new Messages.DeviceList([new Messages.DeviceInfo(0, "Test", ["Ok", "Ping"]), | ||
new Messages.DeviceInfo(1, "Test1", ["Ok", "Ping"])], | ||
2)]); | ||
// tslint:disable:max-line-length | ||
expect(FromJSON(jsonStr)).to.deep.equal([new Messages.DeviceList([new Messages.DeviceInfo(0, "Test", ["Ok", "Ping"]), new Messages.DeviceInfo(1, "Test1", ["Ok", "Ping"])], 2)]); | ||
}); | ||
@@ -27,0 +25,0 @@ it("Converts DeviceAdded message from json correctly", |
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
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
406279
132
5780
+ Addedtext-encoding@^0.6.4
+ Addedtext-encoding@0.6.4(transitive)
- Removedws@^3.2.0
- Removedasync-limiter@1.0.1(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedultron@1.1.1(transitive)
- Removedws@3.3.3(transitive)
Updatedajv@^5.3.0