Converted a significant amount of files from js to ts.

This commit is contained in:
Jas Singh
2024-07-26 02:02:47 -07:00
parent b293d0b060
commit ca5dcc629b
70 changed files with 2838 additions and 1521 deletions

View File

@@ -1,58 +0,0 @@
const audio = await Service.import("audio");
const renderInputDevices = (inputDevices) => {
if (!inputDevices.length) {
return [
Widget.Box({
class_name: `menu-unfound-button input`,
child: Widget.Box({
children: [
Widget.Label({
class_name: "menu-button-name input",
label: "No input devices found...",
}),
],
}),
}),
];
}
return inputDevices.map((device) => {
return Widget.Button({
on_primary_click: () => (audio.microphone = device),
class_name: `menu-button audio input ${device}`,
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
children: [
Widget.Label({
class_name: audio.microphone
.bind("description")
.as((v) =>
device.description === v
? "menu-button-icon active input"
: "menu-button-icon input",
),
label: "",
}),
Widget.Label({
truncate: "end",
wrap: true,
class_name: audio.microphone
.bind("description")
.as((v) =>
device.description === v
? "menu-button-name active input"
: "menu-button-name input",
),
label: device.description,
}),
],
}),
],
}),
});
});
};
export { renderInputDevices };

View File

@@ -0,0 +1,65 @@
const audio = await Service.import("audio");
import { Stream } from "types/service/audio";
const renderInputDevices = (inputDevices: Stream[]) => {
if (inputDevices.length === 0) {
return [
Widget.Button({
class_name: `menu-unfound-button input`,
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
children: [
Widget.Label({
class_name: "menu-button-name input",
label: "No input devices found...",
}),
],
}),
],
}),
}),
];
}
return inputDevices.map((device) => {
return Widget.Button({
on_primary_click: () => (audio.microphone = device),
class_name: `menu-button audio input ${device}`,
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
children: [
Widget.Label({
wrap: true,
class_name: audio.microphone
.bind("description")
.as((v) =>
device.description === v
? "menu-button-icon active input"
: "menu-button-icon input",
),
label: "",
}),
Widget.Label({
truncate: "end",
wrap: true,
class_name: audio.microphone
.bind("description")
.as((v) =>
device.description === v
? "menu-button-name active input"
: "menu-button-name input",
),
label: device.description,
}),
],
}),
],
}),
});
});
};
export { renderInputDevices };

View File

@@ -1,58 +0,0 @@
const audio = await Service.import("audio");
const renderPlaybacks = (playbackDevices) => {
return playbackDevices.map((device) => {
if (device.description === "Dummy Output") {
return Widget.Box({
class_name: "menu-unfound-button playback",
child: Widget.Box({
children: [
Widget.Label({
class_name: "menu-button-name playback",
label: "No playback devices found...",
}),
],
}),
});
}
return Widget.Button({
class_name: `menu-button audio playback ${device}`,
on_primary_click: () => (audio.speaker = device),
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
children: [
Widget.Label({
truncate: "end",
wrap: true,
class_name: audio.speaker
.bind("description")
.as((v) =>
device.description === v
? "menu-button-icon active playback"
: "menu-button-icon playback",
),
label: "",
}),
Widget.Label({
class_name: audio.speaker
.bind("description")
.as((v) =>
device.description === v
? "menu-button-name active playback"
: "menu-button-name playback",
),
truncate: "end",
wrap: true,
label: device.description,
}),
],
}),
],
}),
});
});
};
export { renderPlaybacks };

View File

@@ -0,0 +1,59 @@
const audio = await Service.import("audio");
import { Stream } from "types/service/audio";
const renderPlaybacks = (playbackDevices: Stream[]) => {
return playbackDevices.map((device) => {
if (device.description === "Dummy Output") {
return Widget.Box({
class_name: "menu-unfound-button playback",
child: Widget.Box({
children: [
Widget.Label({
class_name: "menu-button-name playback",
label: "No playback devices found...",
}),
],
}),
});
}
return Widget.Button({
class_name: `menu-button audio playback ${device}`,
on_primary_click: () => (audio.speaker = device),
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
children: [
Widget.Label({
truncate: "end",
wrap: true,
class_name: audio.speaker
.bind("description")
.as((v) =>
device.description === v
? "menu-button-icon active playback"
: "menu-button-icon playback",
),
label: "",
}),
Widget.Label({
truncate: "end",
wrap: true,
class_name: audio.speaker
.bind("description")
.as((v) =>
device.description === v
? "menu-button-name active playback"
: "menu-button-name playback",
),
label: device.description,
}),
],
}),
],
}),
});
});
};
export { renderPlaybacks };

View File

@@ -1,75 +0,0 @@
const audio = await Service.import("audio");
import { renderInputDevices } from "./InputDevices.js";
import { renderPlaybacks } from "./PlaybackDevices.js";
const availableDevices = () => {
return Widget.Box({
vertical: true,
children: [
Widget.Box({
class_name: "menu-section-container playback",
vertical: true,
children: [
Widget.Box({
class_name: "menu-label-container playback",
hpack: "fill",
child: Widget.Label({
class_name: "menu-label audio playback",
hexpand: true,
hpack: "start",
label: "Playback Devices",
}),
}),
Widget.Box({
class_name: "menu-items-section playback",
vertical: true,
children: [
Widget.Box({
class_name: "menu-container playback",
vertical: true,
children: [
Widget.Box({
vertical: true,
children: audio
.bind("speakers")
.as((v) => renderPlaybacks(v)),
}),
],
}),
],
}),
Widget.Box({
class_name: "menu-label-container input",
hpack: "fill",
child: Widget.Label({
class_name: "menu-label audio input",
hexpand: true,
hpack: "start",
label: "Input Devices",
}),
}),
Widget.Box({
class_name: "menu-items-section input",
vertical: true,
children: [
Widget.Box({
class_name: "menu-container input",
vertical: true,
children: [
Widget.Box({
vertical: true,
children: audio
.bind("microphones")
.as((v) => renderInputDevices(v)),
}),
],
}),
],
}),
],
}),
],
});
};
export { availableDevices };

View File

@@ -0,0 +1,75 @@
const audio = await Service.import("audio");
import { renderInputDevices } from "./InputDevices.js";
import { renderPlaybacks } from "./PlaybackDevices.js";
const availableDevices = () => {
return Widget.Box({
vertical: true,
children: [
Widget.Box({
class_name: "menu-section-container playback",
vertical: true,
children: [
Widget.Box({
class_name: "menu-label-container playback",
hpack: "fill",
child: Widget.Label({
class_name: "menu-label audio playback",
hexpand: true,
hpack: "start",
label: "Playback Devices",
}),
}),
Widget.Box({
class_name: "menu-items-section playback",
vertical: true,
children: [
Widget.Box({
class_name: "menu-container playback",
vertical: true,
children: [
Widget.Box({
vertical: true,
children: audio
.bind("speakers")
.as((v) => renderPlaybacks(v)),
}),
],
}),
],
}),
Widget.Box({
class_name: "menu-label-container input",
hpack: "fill",
child: Widget.Label({
class_name: "menu-label audio input",
hexpand: true,
hpack: "start",
label: "Input Devices",
}),
}),
Widget.Box({
class_name: "menu-items-section input",
vertical: true,
children: [
Widget.Box({
class_name: "menu-container input",
vertical: true,
children: [
Widget.Box({
vertical: true,
children: audio
.bind("microphones")
.as((v) => renderInputDevices(v)),
}),
],
}),
],
}),
],
}),
],
});
};
export { availableDevices };