Socket
Socket
Sign inDemoInstall

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.0.1 to 1.0.2

2

lib/commands/index.d.ts

@@ -17,3 +17,5 @@ import { Connectable } from "../connection";

export declare type CommandOptions = Omit<SendCommandOptions, "command" | "data">;
/** Returns a command name based on the given command code. */
export declare const getCommandName: (command: Command) => string;
/** Sends a message to the given output and waits for a response. */
export declare const sendCommand: ({ device, command, productId, serialNumber, transactionId, data, }: SendCommandOptions) => Promise<import("../util/data").Data>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendCommand = void 0;
exports.sendCommand = exports.getCommandName = void 0;
const message_1 = require("../util/message");
const number_1 = require("../util/number");
const advanced_midi_processor_1 = require("./advanced-midi-processor");
const audio_1 = require("./audio");
const audio_mixer_1 = require("./audio-mixer");
const automation_control_1 = require("./automation-control");
const device_1 = require("./device");
const hardware_interface_1 = require("./hardware-interface");
const midi_1 = require("./midi");
const snapshot_1 = require("./snapshot");
/** Returns a command name based on the given command code. */
const getCommandName = (command) => device_1.DeviceCommand[command] ??
midi_1.MidiCommand[command] ??
audio_1.AudioCommand[command] ??
audio_mixer_1.AudioMixerCommand[command] ??
automation_control_1.AutomationControlCommand[command] ??
advanced_midi_processor_1.AdvancedMidiProcessorCommand[command] ??
snapshot_1.SnapshotCommand[command] ??
hardware_interface_1.HardwareInterfaceCommand[command] ??
`Unknown command 0x${command.toString(16)}`;
exports.getCommandName = getCommandName;
/** The current transaction ID, increases with every sent command. */

@@ -18,2 +37,5 @@ let transactionId = 0;

const sendCommand = async ({ device, command, productId, serialNumber, transactionId = getNextTransactionId(), data, }) => {
if (device.supportsCommand && !device.supportsCommand(command)) {
throw new Error(`Device does not support command ${(0, exports.getCommandName)(command)}`);
}
const body = (0, message_1.buildBody)({

@@ -20,0 +42,0 @@ command,

export declare enum SnapshotCommand {
GetSnapshotGlobalParm = 102,
RetSnapshotGlobalParm = 103,

@@ -3,0 +4,0 @@ GetSnapshotParm = 104,

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

(function (SnapshotCommand) {
SnapshotCommand[SnapshotCommand["GetSnapshotGlobalParm"] = 102] = "GetSnapshotGlobalParm";
SnapshotCommand[SnapshotCommand["RetSnapshotGlobalParm"] = 103] = "RetSnapshotGlobalParm";

@@ -8,0 +9,0 @@ SnapshotCommand[SnapshotCommand["GetSnapshotParm"] = 104] = "GetSnapshotParm";

@@ -0,4 +1,6 @@

import { Command } from "./commands";
import { Data } from "./util/data";
export interface Connectable {
sendMessage: (message: Data) => Promise<Data>;
supportsCommand?: (command: Command) => boolean;
}

@@ -5,0 +7,0 @@ export declare class Connection implements Connectable {

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

import { Command } from "./commands";
import { DeviceInfoType } from "./commands/device";

@@ -9,5 +10,8 @@ import { DeviceInfo } from "./commands/device/get-device";

readonly info: DeviceInfo;
constructor(input: MIDIInput, output: MIDIOutput, info: DeviceInfo);
readonly supportedCommands: Command[];
constructor(input: MIDIInput, output: MIDIOutput, info: DeviceInfo, supportedCommands: Command[]);
get serialNumber(): string;
supportsCommand(command: Command): boolean;
getSupportedCommandNames(): string[];
getAllInfo(): Promise<Record<DeviceInfoType, string> | null>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Device = void 0;
const commands_1 = require("./commands");
const device_1 = require("./commands/device");
const get_info_1 = require("./commands/device/get-info");

@@ -10,3 +12,3 @@ const get_info_list_1 = require("./commands/device/get-info-list");

class Device extends connection_1.Connection {
constructor(input, output, info) {
constructor(input, output, info, supportedCommands) {
super(input, output);

@@ -16,2 +18,3 @@ this.input = input;

this.info = info;
this.supportedCommands = supportedCommands;
}

@@ -21,2 +24,12 @@ get serialNumber() {

}
supportsCommand(command) {
if (command === device_1.DeviceCommand.GetDevice ||
command === device_1.DeviceCommand.GetCommandList) {
return true;
}
return this.supportedCommands.includes(command);
}
getSupportedCommandNames() {
return this.supportedCommands.map((c) => (0, commands_1.getCommandName)(c));
}
async getAllInfo() {

@@ -23,0 +36,0 @@ const supportedInfo = await (0, get_info_list_1.getInfoList)({ device: this });

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

const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
const get_command_list_1 = require("./commands/device/get-command-list");
const get_device_1 = require("./commands/device/get-device");

@@ -59,3 +60,9 @@ const connection_1 = require("./connection");

if (deviceInfo) {
return new device_1.Device(input, output, deviceInfo);
const supportedCommands = await (0, get_command_list_1.getCommandList)({
device,
serialNumber: deviceInfo.serialNumber,
});
if (supportedCommands) {
return new device_1.Device(input, output, deviceInfo, supportedCommands);
}
}

@@ -62,0 +69,0 @@ }

2

package.json
{
"name": "iconnectivity-js",
"version": "1.0.1",
"version": "1.0.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