Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iconnectivity-js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iconnectivity-js - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

32

lib/commands/index.js

@@ -76,26 +76,14 @@ "use strict";

const message = (0, message_1.buildMessage)(body);
try {
const result = await device.sendMessage(message, {
command,
debug,
transactionId,
});
if (result[15] === device_1.DeviceCommand.ACK) {
const code = result[20];
if (code !== ack_1.ErrorCode.NoError) {
throw new Error(`Command failed with error code ${(0, data_1.formatData)([code])} (${ack_1.ErrorCode[code]})`);
}
const result = await device.sendMessage(message, {
command,
debug,
transactionId,
});
if (result[15] === device_1.DeviceCommand.ACK) {
const code = result[20];
if (code !== ack_1.ErrorCode.NoError) {
throw new Error(`Command failed with error code ${(0, data_1.formatData)([code])} (${ack_1.ErrorCode[code]})`);
}
return result;
}
catch (e) {
console.error("Sending command failed:", {
error: e,
command: (0, exports.getCommandName)(command),
data: (0, data_1.formatData)(data ?? []),
transactionId,
message: (0, data_1.formatData)(message),
});
throw e;
}
return result;
};

@@ -102,0 +90,0 @@ exports.sendCommand = sendCommand;

@@ -14,2 +14,9 @@ import { Command } from "./commands";

}
/** Thrown when a message doesn't receive a response within the timeout threshold */
export declare class TimeoutError extends Error {
readonly commandName: string;
readonly transactionId: number;
readonly request: string;
constructor(message: string, commandName: string, transactionId: number, request: string);
}
export declare class Connection implements Connectable {

@@ -16,0 +23,0 @@ readonly input: MIDIInput;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Connection = void 0;
exports.Connection = exports.TimeoutError = void 0;
const commands_1 = require("./commands");

@@ -8,2 +8,13 @@ const data_1 = require("./util/data");

const number_1 = require("./util/number");
/** Thrown when a message doesn't receive a response within the timeout threshold */
class TimeoutError extends Error {
constructor(message, commandName, transactionId, request) {
super(message);
this.commandName = commandName;
this.transactionId = transactionId;
this.request = request;
this.name = "TimeoutError";
}
}
exports.TimeoutError = TimeoutError;
class Connection {

@@ -16,3 +27,6 @@ constructor(input, output) {

return await new Promise((res, rej) => {
const timeout = setTimeout(() => rej(new Error("Timeout")), 500);
const timeout = setTimeout(() => {
const commandName = (0, commands_1.getCommandName)(options.command);
rej(new TimeoutError(`Command ${commandName} timed out`, commandName, options.transactionId, (0, data_1.formatData)(message)));
}, 500);
const handler = (m) => {

@@ -19,0 +33,0 @@ if (!m.data.slice(0, 5).every((e, i) => message_1.MESSAGE_HEADER[i] === e)) {

@@ -0,1 +1,2 @@

/// <reference types="lodash" />
import { Device } from "./device";

@@ -19,5 +20,6 @@ import { Product } from "./types/product";

constructor(midiAccess: MIDIAccess, product?: Product);
destroy(): void;
get product(): Product | undefined;
set product(product: Product | undefined);
handleMidiStateChange: () => Promise<void>;
handleMidiStateChange: import("lodash").DebouncedFunc<() => Promise<void>>;
/** Requests MIDI access and scans all ports for iConnectivity devices */

@@ -24,0 +26,0 @@ getDevices(): Promise<Device[]>;

@@ -21,2 +21,3 @@ "use strict";

exports.DeviceManager = void 0;
const debounce_1 = __importDefault(require("lodash/debounce"));
const isEqual_1 = __importDefault(require("lodash/isEqual"));

@@ -41,3 +42,3 @@ const uniqBy_1 = __importDefault(require("lodash/uniqBy"));

this.devicesChanged = (0, event_source_1.createEventSource)();
this.handleMidiStateChange = async () => {
this.handleMidiStateChange = (0, debounce_1.default)(async () => {
const devices = await this.getDevices();

@@ -48,3 +49,3 @@ if (!(0, isEqual_1.default)(devices.map((d) => d.serialNumber), this.devices.map((d) => d.serialNumber))) {

}
};
}, 100);
this._product = product;

@@ -54,2 +55,5 @@ midiAccess.addEventListener("statechange", this.handleMidiStateChange);

}
destroy() {
this.midiAccess.removeEventListener("statechange", this.handleMidiStateChange);
}
get product() {

@@ -56,0 +60,0 @@ return this._product;

{
"name": "iconnectivity-js",
"version": "1.1.1",
"version": "1.1.2",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc