Socket
Socket
Sign inDemoInstall

aitum.js

Package Overview
Dependencies
100
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-beta.2 to 2.0.0-beta.3

lib/ElgatoColourMode-4dbac3ec.d.ts

6

lib/classes.d.ts

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

export { A as AitumDevice, E as ElgatoDevice, H as Host, M as MIDIDevice, O as OBSV5Device, a as OSCDevice, R as Rule, T as TwitchDevice } from './Host-bc63f2c8.js';
export { A as AitumDevice, E as ElgatoDevice, H as Host, M as MIDIDevice, O as OBSV5Device, a as OSCDevice, R as Rule, T as TwitchDevice } from './Host-8fafa822.js';
import './DeviceType-946fad6b.js';
import './HostType-4402526b.js';
import './IDeviceSearchParams-ebd54889.js';
import './ElgatoColourMode-4dbac3ec.js';
import './IDeviceSearchParams-ed14ada9.js';

@@ -62,5 +62,39 @@ var __create = Object.create;

var ElgatoDevice = class extends BaseDevice {
constructor(name, host) {
constructor(name, host, colourMode) {
super(name, "ELGATO" /* ELGATO */, host);
this.colourMode = colourMode;
}
async setState(on) {
await AitumJS.get().aitum.triggerAction(this, {
type: 0,
on
});
}
async setColour(colour) {
if (this.colourMode !== "HSB" /* HSB */)
return;
if (colour.length !== 6)
return;
let r = parseInt(colour.substr(0, 2), 16) / 255;
let g = parseInt(colour.substr(2, 2), 16) / 255;
let b = parseInt(colour.substr(4, 2), 16) / 255;
const v = Math.max(r, g, b);
const n = v - Math.min(r, g, b);
const h = n === 0 ? 0 : n && v === r ? (g - b) / n : v === g ? 2 + (b - r) / n : 4 + (r - g) / n;
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
hue: 60 * (h < 0 ? h + 6 : h),
saturation: v && n / v * 100,
brightness: v * 100
});
}
async setColourTemperature(temperature, brightness) {
if (this.colourMode !== "CT" /* CT */)
return;
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
temperature,
brightness
});
}
};

@@ -73,2 +107,101 @@

}
async noteOn(channel, note, velocity) {
await AitumJS.get().aitum.triggerAction(this, {
type: 0,
channel,
note,
velocity
});
}
async noteOff(channel, note, velocity) {
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
channel,
note,
velocity
});
}
async noteOnOff(channel, note, velocity, hold) {
await AitumJS.get().aitum.triggerAction(this, {
type: 16,
channel,
note,
velocity,
hold
});
}
async controlChange(channel, value, controller) {
await AitumJS.get().aitum.triggerAction(this, {
type: 2,
channel,
value,
controller
});
}
async program(channel, number) {
await AitumJS.get().aitum.triggerAction(this, {
type: 3,
channel,
number
});
}
async polyAftertouch(channel, note, velocity) {
await AitumJS.get().aitum.triggerAction(this, {
type: 4,
channel,
note,
velocity
});
}
async channelAftertouch(channel, pressure) {
await AitumJS.get().aitum.triggerAction(this, {
type: 5,
channel,
pressure
});
}
async pitch(channel, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 6,
channel,
value
});
}
async position(value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 7,
value
});
}
async select(song) {
await AitumJS.get().aitum.triggerAction(this, {
type: 9,
song
});
}
async start() {
await AitumJS.get().aitum.triggerAction(this, {
type: 11
});
}
async continue() {
await AitumJS.get().aitum.triggerAction(this, {
type: 12
});
}
async stop() {
await AitumJS.get().aitum.triggerAction(this, {
type: 13
});
}
async activeSense() {
await AitumJS.get().aitum.triggerAction(this, {
type: 14
});
}
async reset() {
await AitumJS.get().aitum.triggerAction(this, {
type: 15
});
}
};

@@ -247,2 +380,36 @@

}
async float(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 0,
address,
value
});
}
async integer(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
address,
value
});
}
async string(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 2,
address,
value
});
}
async boolean(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 4,
address,
value
});
}
async null(address) {
await AitumJS.get().aitum.triggerAction(this, {
type: 3,
address
});
}
};

@@ -255,2 +422,127 @@

}
async startCommercial(length) {
const allowedValues = [30, 60, 90, 120, 150, 180];
if (!allowedValues.includes(length))
throw new Error("Commercial length must be between 30-180 seconds in steps of 30");
await AitumJS.get().aitum.triggerAction(this, {
type: 9,
length
});
}
async createStreamMarker() {
await AitumJS.get().aitum.triggerAction(this, {
type: 10
});
}
async startPoll(title, duration, choices, pointsVoting = false, pointsPerVote) {
if (choices.length < 2 || choices.length > 5)
throw new Error("Polls require 2-5 choices");
if (pointsVoting === true && typeof pointsPerVote !== "number")
throw new Error("Points voting requires an integer amount for pointsPerVote");
await AitumJS.get().aitum.triggerAction(this, {
type: 11,
title,
duration,
pointsVoting,
pointsPerVote,
choiceOne: choices[0],
choiceTwo: choices[1],
choiceThree: choices.length > 2 ? choices[2] : void 0,
choiceFour: choices.length > 3 ? choices[3] : void 0,
choiceFive: choices.length > 4 ? choices[4] : void 0
});
}
async endPoll() {
await AitumJS.get().aitum.triggerAction(this, {
type: 12
});
}
async getPoll() {
return AitumJS.get().twitch.getPoll();
}
async announcement(message, colour) {
await AitumJS.get().aitum.triggerAction(this, {
type: 17,
message,
announceType: null
});
}
async setBanStatus(ban, username, reason) {
await AitumJS.get().aitum.triggerAction(this, {
type: ban ? 18 : 19,
username,
reason: ban && reason ? reason : void 0
});
}
async emoteOnly(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 20,
enabled
});
}
async followerOnly(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 21,
enabled
});
}
async setVIP(vip, username) {
await AitumJS.get().aitum.triggerAction(this, {
type: 24,
username,
enabled: vip
});
}
async raid(username) {
await AitumJS.get().aitum.triggerAction(this, {
type: 26,
username
});
}
async subOnlyMode(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 31,
enabled
});
}
async setTimeoutStatus(timeout, username, reason) {
await AitumJS.get().aitum.triggerAction(this, {
type: timeout ? 32 : 33,
username,
reason: timeout && reason ? reason : void 0
});
}
async clearChat() {
await AitumJS.get().aitum.triggerAction(this, {
type: 34
});
}
async setModStatus(mod, username) {
await AitumJS.get().aitum.triggerAction(this, {
type: 35,
username
});
}
async uniqueChat(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 36,
enabled
});
}
async sendMessage(message) {
if (message.length === 0 || message.length > 500)
throw new Error("Messages for Twitch chats need to be between 1-500 characters");
await AitumJS.get().aitum.triggerAction(this, {
type: 37,
message
});
}
async setTitle(title) {
if (title.length === 0 || title.length > 140)
throw new Error("Titles for Twitch streams need to be between 1-140 characters");
await AitumJS.get().aitum.triggerAction(this, {
type: 37,
title
});
}
};

@@ -269,3 +561,3 @@

}
function deviceCreator(name, type, host) {
function deviceCreator(name, type, host, fullDevice) {
switch (type) {

@@ -281,3 +573,3 @@ case "OBSV5" /* OBSV5 */:

case "ELGATO" /* ELGATO */:
return new ElgatoDevice(name, host);
return new ElgatoDevice(name, host, fullDevice["colourMode"]);
case "OSC" /* OSC */:

@@ -366,2 +658,3 @@ return new OSCDevice(name, host);

const call = await this.base.get("devices");
filters = filters ? { ...filters, type } : { type };
let devices = [];

@@ -383,3 +676,3 @@ for (const device of call.data.data) {

}
const parsed = deviceCreator(device.name, device.type, device.host);
const parsed = deviceCreator(device.name, device.type, device.host, device);
if (parsed)

@@ -386,0 +679,0 @@ devices.push(parsed);

export { D as DeviceType } from './DeviceType-946fad6b.js';
export { H as HostType } from './HostType-4402526b.js';
export { E as ElgatoColourMode, H as HostType } from './ElgatoColourMode-4dbac3ec.js';
export { I as InputType } from './InputType-43d9f3bb.js';

@@ -23,2 +23,3 @@ var __defProp = Object.defineProperty;

DeviceType: () => DeviceType,
ElgatoColourMode: () => ElgatoColourMode,
HostType: () => HostType,

@@ -56,7 +57,15 @@ InputType: () => InputType

})(InputType || {});
// src/enums/ElgatoColourMode.ts
var ElgatoColourMode = /* @__PURE__ */ ((ElgatoColourMode2) => {
ElgatoColourMode2["HSB"] = "HSB";
ElgatoColourMode2["CT"] = "CT";
return ElgatoColourMode2;
})(ElgatoColourMode || {});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DeviceType,
ElgatoColourMode,
HostType,
InputType
});
import { AxiosInstance } from 'axios';
import { B as BaseDevice, H as Host, D as DeviceEnumToClassReturnType, R as Rule } from './Host-bc63f2c8.js';
import { B as BaseDevice, H as Host, D as DeviceEnumToClassReturnType, R as Rule } from './Host-8fafa822.js';
import { D as DeviceType } from './DeviceType-946fad6b.js';
import { I as IDeviceSearchParams } from './IDeviceSearchParams-ebd54889.js';
import { I as IRule, a as IGlobalVariable, b as IHypeTrainInfo, c as IPollInfo, d as ICustomCode } from './ICustomCode-98c2166d.js';
import './HostType-4402526b.js';
import { I as IRule, a as IGlobalVariable, b as IHypeTrainInfo, c as ICustomCode } from './ICustomCode-399deefc.js';
import { I as IDeviceSearchParams, a as IPollInfo } from './IDeviceSearchParams-ed14ada9.js';
import './ElgatoColourMode-4dbac3ec.js';
import './InputType-43d9f3bb.js';

@@ -8,0 +8,0 @@

@@ -97,5 +97,39 @@ var __create = Object.create;

var ElgatoDevice = class extends BaseDevice {
constructor(name, host) {
constructor(name, host, colourMode) {
super(name, "ELGATO" /* ELGATO */, host);
this.colourMode = colourMode;
}
async setState(on) {
await AitumJS.get().aitum.triggerAction(this, {
type: 0,
on
});
}
async setColour(colour) {
if (this.colourMode !== "HSB" /* HSB */)
return;
if (colour.length !== 6)
return;
let r = parseInt(colour.substr(0, 2), 16) / 255;
let g = parseInt(colour.substr(2, 2), 16) / 255;
let b = parseInt(colour.substr(4, 2), 16) / 255;
const v = Math.max(r, g, b);
const n = v - Math.min(r, g, b);
const h = n === 0 ? 0 : n && v === r ? (g - b) / n : v === g ? 2 + (b - r) / n : 4 + (r - g) / n;
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
hue: 60 * (h < 0 ? h + 6 : h),
saturation: v && n / v * 100,
brightness: v * 100
});
}
async setColourTemperature(temperature, brightness) {
if (this.colourMode !== "CT" /* CT */)
return;
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
temperature,
brightness
});
}
};

@@ -108,2 +142,101 @@

}
async noteOn(channel, note, velocity) {
await AitumJS.get().aitum.triggerAction(this, {
type: 0,
channel,
note,
velocity
});
}
async noteOff(channel, note, velocity) {
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
channel,
note,
velocity
});
}
async noteOnOff(channel, note, velocity, hold) {
await AitumJS.get().aitum.triggerAction(this, {
type: 16,
channel,
note,
velocity,
hold
});
}
async controlChange(channel, value, controller) {
await AitumJS.get().aitum.triggerAction(this, {
type: 2,
channel,
value,
controller
});
}
async program(channel, number) {
await AitumJS.get().aitum.triggerAction(this, {
type: 3,
channel,
number
});
}
async polyAftertouch(channel, note, velocity) {
await AitumJS.get().aitum.triggerAction(this, {
type: 4,
channel,
note,
velocity
});
}
async channelAftertouch(channel, pressure) {
await AitumJS.get().aitum.triggerAction(this, {
type: 5,
channel,
pressure
});
}
async pitch(channel, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 6,
channel,
value
});
}
async position(value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 7,
value
});
}
async select(song) {
await AitumJS.get().aitum.triggerAction(this, {
type: 9,
song
});
}
async start() {
await AitumJS.get().aitum.triggerAction(this, {
type: 11
});
}
async continue() {
await AitumJS.get().aitum.triggerAction(this, {
type: 12
});
}
async stop() {
await AitumJS.get().aitum.triggerAction(this, {
type: 13
});
}
async activeSense() {
await AitumJS.get().aitum.triggerAction(this, {
type: 14
});
}
async reset() {
await AitumJS.get().aitum.triggerAction(this, {
type: 15
});
}
};

@@ -282,2 +415,36 @@

}
async float(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 0,
address,
value
});
}
async integer(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 1,
address,
value
});
}
async string(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 2,
address,
value
});
}
async boolean(address, value) {
await AitumJS.get().aitum.triggerAction(this, {
type: 4,
address,
value
});
}
async null(address) {
await AitumJS.get().aitum.triggerAction(this, {
type: 3,
address
});
}
};

@@ -290,2 +457,127 @@

}
async startCommercial(length) {
const allowedValues = [30, 60, 90, 120, 150, 180];
if (!allowedValues.includes(length))
throw new Error("Commercial length must be between 30-180 seconds in steps of 30");
await AitumJS.get().aitum.triggerAction(this, {
type: 9,
length
});
}
async createStreamMarker() {
await AitumJS.get().aitum.triggerAction(this, {
type: 10
});
}
async startPoll(title, duration, choices, pointsVoting = false, pointsPerVote) {
if (choices.length < 2 || choices.length > 5)
throw new Error("Polls require 2-5 choices");
if (pointsVoting === true && typeof pointsPerVote !== "number")
throw new Error("Points voting requires an integer amount for pointsPerVote");
await AitumJS.get().aitum.triggerAction(this, {
type: 11,
title,
duration,
pointsVoting,
pointsPerVote,
choiceOne: choices[0],
choiceTwo: choices[1],
choiceThree: choices.length > 2 ? choices[2] : void 0,
choiceFour: choices.length > 3 ? choices[3] : void 0,
choiceFive: choices.length > 4 ? choices[4] : void 0
});
}
async endPoll() {
await AitumJS.get().aitum.triggerAction(this, {
type: 12
});
}
async getPoll() {
return AitumJS.get().twitch.getPoll();
}
async announcement(message, colour) {
await AitumJS.get().aitum.triggerAction(this, {
type: 17,
message,
announceType: null
});
}
async setBanStatus(ban, username, reason) {
await AitumJS.get().aitum.triggerAction(this, {
type: ban ? 18 : 19,
username,
reason: ban && reason ? reason : void 0
});
}
async emoteOnly(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 20,
enabled
});
}
async followerOnly(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 21,
enabled
});
}
async setVIP(vip, username) {
await AitumJS.get().aitum.triggerAction(this, {
type: 24,
username,
enabled: vip
});
}
async raid(username) {
await AitumJS.get().aitum.triggerAction(this, {
type: 26,
username
});
}
async subOnlyMode(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 31,
enabled
});
}
async setTimeoutStatus(timeout, username, reason) {
await AitumJS.get().aitum.triggerAction(this, {
type: timeout ? 32 : 33,
username,
reason: timeout && reason ? reason : void 0
});
}
async clearChat() {
await AitumJS.get().aitum.triggerAction(this, {
type: 34
});
}
async setModStatus(mod, username) {
await AitumJS.get().aitum.triggerAction(this, {
type: 35,
username
});
}
async uniqueChat(enabled) {
await AitumJS.get().aitum.triggerAction(this, {
type: 36,
enabled
});
}
async sendMessage(message) {
if (message.length === 0 || message.length > 500)
throw new Error("Messages for Twitch chats need to be between 1-500 characters");
await AitumJS.get().aitum.triggerAction(this, {
type: 37,
message
});
}
async setTitle(title) {
if (title.length === 0 || title.length > 140)
throw new Error("Titles for Twitch streams need to be between 1-140 characters");
await AitumJS.get().aitum.triggerAction(this, {
type: 37,
title
});
}
};

@@ -316,3 +608,3 @@

}
function deviceCreator(name, type, host) {
function deviceCreator(name, type, host, fullDevice) {
switch (type) {

@@ -328,3 +620,3 @@ case "OBSV5" /* OBSV5 */:

case "ELGATO" /* ELGATO */:
return new ElgatoDevice(name, host);
return new ElgatoDevice(name, host, fullDevice["colourMode"]);
case "OSC" /* OSC */:

@@ -413,2 +705,3 @@ return new OSCDevice(name, host);

const call = await this.base.get("devices");
filters = filters ? { ...filters, type } : { type };
let devices = [];

@@ -430,3 +723,3 @@ for (const device of call.data.data) {

}
const parsed = deviceCreator(device.name, device.type, device.host);
const parsed = deviceCreator(device.name, device.type, device.host, device);
if (parsed)

@@ -433,0 +726,0 @@ devices.push(parsed);

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

import { e as ICCActionInputs } from './ICustomCode-98c2166d.js';
export { e as ICCActionInputs, d as ICustomCode, a as IGlobalVariable, b as IHypeTrainInfo, f as IInputValidation, c as IPollInfo, I as IRule } from './ICustomCode-98c2166d.js';
export { I as IDeviceSearchParams } from './IDeviceSearchParams-ebd54889.js';
import { d as ICCActionInputs } from './ICustomCode-399deefc.js';
export { d as ICCActionInputs, c as ICustomCode, a as IGlobalVariable, b as IHypeTrainInfo, e as IInputValidation, I as IRule } from './ICustomCode-399deefc.js';
export { I as IDeviceSearchParams, a as IPollInfo } from './IDeviceSearchParams-ed14ada9.js';
export { I as INumberInputValidation, a as ISimpleInputValidation, b as IStringInputValidation } from './IStringInputValidation-718d2cd4.js';

@@ -5,0 +5,0 @@ import './InputType-43d9f3bb.js';

{
"name": "aitum.js",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"keywords": [

@@ -19,2 +19,6 @@ "aitum",

{
"name": "Jayden Bailey",
"url": "https://github.com/jayktaylor"
},
{
"name": "Nuro",

@@ -21,0 +25,0 @@ "url": "https://github.com/NuroDev"

@@ -41,3 +41,3 @@ # aitum.js

// You can optionally provide an IP address to the machine running Aitum. It will default to 127.0.0.1
const lib = AitumJS().get();
const lib = AitumJS.get();

@@ -76,3 +76,3 @@ // Example: Trigger an Aitum rule using its ID

// You can optionally provide an IP address to the machine running Aitum. It will default to 127.0.0.1
const lib = AitumJS().get();
const lib = AitumJS.get();

@@ -112,6 +112,38 @@ // Filter all devices by the type we want to find

#### MIDI
TODO
* `noteOn(channel: number, note: number, velocity: number)` - Send a Note On
* `noteOff(channel: number, note: number, velocity: number)` - Send a Note Off
* `noteOnOff(channel: number, note: number, velocity: number, hold: number)` - Send a Note On followed by a Note Off
* `controlChange(channel: number, value: number, controller: number)` - Send a Control Change
* `program(channel: number, number: number)` - Send a Program
* `polyAftertouch(channel: number, note: number, velocity: number)` - Send a Poly Aftertouch
* `channelAftertouch(channel: number, pressure: number)` - Send a Channel Aftertouch
* `pitch(channel: number, value: number)` - Send a Pitch
* `position(value: number)` - Send a Position
* `select(song: number)` - Send a Select
* `start()` - Send a Start
* `continue()` - Send a Continue
* `stop()` - Send a Stop
* `activeSense()` - Send an Active Sense
* `reset()` - Send a Reset
#### TWITCH
TODO
* `startCommercial(length: number)` - Start a Commercial
* `createStreamMarker()` - Create a Stream Marker
* `startPoll(title: string, duration: number, choices: string[], pointsVoting = false, pointsPerVote?: number)` - Starts a new Poll
* `endPoll()` - Ends a poll if one is active
* `getPoll()` - Gets the active poll if one is running
* `announcement(message: string, colour?: TwitchChatAnnounceColour)` - Sends an announcement
* `setBanStatus(ban: boolean, username: string, reason?: string)` - Ban/unbans a user
* `emoteOnly(enabled: boolean)` - Sets emote only mode
* `followerOnly(enabled: boolean)` - Sets follower only mode
* `setVIP(vip: boolean, username: string)` - VIPs/unVIPs a user
* `raid(username: string)` - Starts a raid
* `subOnlyMode(enabled: boolean)` - Sets subscriber only mode
* `setTimeoutStatus(timeout: boolean, username: string, reason?: string)` - Timeouts/untimeouts a user
* `clearChat()` - Clear chat
* `setModStatus(mod: boolean, username: string)` - Mod/unmod a user
* `uniqueChat(enabled: boolean)` - Sets unique chat mode
* `sendMessage(message: string)` - Sends a message as the broadcaster
* `setTitle(title: string)` - Sets the stream title

@@ -124,8 +156,13 @@ #### AITUM

#### ELGATO
TODO
* `setState(on: boolean)` - Set the light state
* `setColour(colour: string)` - Set the light colour
* `setColourTemperature(temperature: number, brightness: number)` - Set the light colour temperature
#### OSC
TODO
* `float(address: string, value: number)` - Send a Float
* `integer(address: string, value: number)` - Send a Integer
* `string(address: string, value: string)` - Send a String
* `boolean(address: string, value: boolean)` - Send a Boolean
* `null(address: string)` - Send a Null
### Rules

@@ -132,0 +169,0 @@ TODO

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc