Implemented strict linting standards and prettier formatting config. (#248)

* Implemented strict linting standards and prettier formatting config.

* More linter fixes and type updates.

* More linter updates and type fixes

* Remove noisy comments

* Linter and type updates

* Linter, formatting and type updates.

* Linter updates

* Type updates

* Type updates

* fixed all linter errors

* Fixed all linting, formatting and type issues.

* Resolve merge conflicts.
This commit is contained in:
Jas Singh
2024-09-14 16:20:05 -07:00
committed by GitHub
parent ff13e3dd3c
commit 2c72cc66d8
222 changed files with 13141 additions and 8433 deletions

View File

@@ -1,31 +1,36 @@
const audio = await Service.import("audio");
const audio = await Service.import('audio');
import { BarBoxChild } from 'lib/types/bar.js';
import { getIcon } from '../utils.js';
const renderActiveInput = () => {
const renderActiveInput = (): BarBoxChild => {
return [
Widget.Box({
class_name: "menu-slider-container input",
class_name: 'menu-slider-container input',
children: [
Widget.Button({
vexpand: false,
vpack: "end",
vpack: 'end',
setup: (self) => {
self.hook(audio, () => {
const mic = audio.microphone;
const className = `menu-active-button input ${mic.is_muted ? "muted" : ""}`;
const className = `menu-active-button input ${mic.is_muted ? 'muted' : ''}`;
return (self.class_name = className);
});
},
on_primary_click: () =>
(audio.microphone.is_muted = !audio.microphone.is_muted),
on_primary_click: () => (audio.microphone.is_muted = !audio.microphone.is_muted),
child: Widget.Icon({
class_name: "menu-active-icon input",
class_name: 'menu-active-icon input',
setup: (self) => {
self.hook(audio, () => {
self.icon = getIcon(
audio.microphone.volume,
audio.microphone.is_muted,
)["mic"];
const isMicMuted =
audio.microphone.is_muted !== null ? audio.microphone.is_muted : true;
if (audio.microphone.volume > 0) {
self.icon = getIcon(audio.microphone.volume, isMicMuted)['mic'];
return;
}
self.icon = getIcon(100, false)['mic'];
});
},
}),
@@ -34,15 +39,17 @@ const renderActiveInput = () => {
vertical: true,
children: [
Widget.Label({
class_name: "menu-active input",
hpack: "start",
truncate: "end",
class_name: 'menu-active input',
hpack: 'start',
truncate: 'end',
wrap: true,
label: audio.bind("microphone").as((v) => v.description === null ? "No input device found..." : v.description),
label: audio
.bind('microphone')
.as((v) => (v.description === null ? 'No input device found...' : v.description)),
}),
Widget.Slider({
value: audio.microphone.bind("volume").as((v) => v),
class_name: "menu-active-slider menu-slider inputs",
value: audio.microphone.bind('volume').as((v) => v),
class_name: 'menu-active-slider menu-slider inputs',
draw_value: false,
hexpand: true,
min: 0,
@@ -52,11 +59,9 @@ const renderActiveInput = () => {
],
}),
Widget.Label({
class_name: "menu-active-percentage input",
vpack: "end",
label: audio.microphone
.bind("volume")
.as((v) => `${Math.round(v * 100)}%`),
class_name: 'menu-active-percentage input',
vpack: 'end',
label: audio.microphone.bind('volume').as((v) => `${Math.round(v * 100)}%`),
}),
],
}),

View File

@@ -1,31 +1,29 @@
const audio = await Service.import("audio");
import { getIcon } from "../utils.js";
const audio = await Service.import('audio');
import { BarBoxChild } from 'lib/types/bar.js';
import { getIcon } from '../utils.js';
const renderActivePlayback = () => {
const renderActivePlayback = (): BarBoxChild => {
return [
Widget.Box({
class_name: "menu-slider-container playback",
class_name: 'menu-slider-container playback',
children: [
Widget.Button({
vexpand: false,
vpack: "end",
vpack: 'end',
setup: (self) => {
self.hook(audio, () => {
const spkr = audio.speaker;
const className = `menu-active-button playback ${spkr.is_muted ? "muted" : ""}`;
const className = `menu-active-button playback ${spkr.is_muted ? 'muted' : ''}`;
return (self.class_name = className);
});
},
on_primary_click: () =>
(audio.speaker.is_muted = !audio.speaker.is_muted),
on_primary_click: () => (audio.speaker.is_muted = !audio.speaker.is_muted),
child: Widget.Icon({
class_name: "menu-active-icon playback",
class_name: 'menu-active-icon playback',
setup: (self) => {
self.hook(audio, () => {
self.icon = getIcon(
audio.speaker.volume,
audio.speaker.is_muted,
)["spkr"];
const isSpeakerMuted = audio.speaker.is_muted !== null ? audio.speaker.is_muted : true;
self.icon = getIcon(audio.speaker.volume, isSpeakerMuted)['spkr'];
});
},
}),
@@ -34,16 +32,16 @@ const renderActivePlayback = () => {
vertical: true,
children: [
Widget.Label({
class_name: "menu-active playback",
hpack: "start",
truncate: "end",
class_name: 'menu-active playback',
hpack: 'start',
truncate: 'end',
expand: true,
wrap: true,
label: audio.bind("speaker").as((v) => v.description || ""),
label: audio.bind('speaker').as((v) => v.description || ''),
}),
Widget.Slider({
value: audio["speaker"].bind("volume"),
class_name: "menu-active-slider menu-slider playback",
value: audio['speaker'].bind('volume'),
class_name: 'menu-active-slider menu-slider playback',
draw_value: false,
hexpand: true,
min: 0,
@@ -53,11 +51,9 @@ const renderActivePlayback = () => {
],
}),
Widget.Label({
vpack: "end",
class_name: "menu-active-percentage playback",
label: audio.speaker
.bind("volume")
.as((v) => `${Math.round(v * 100)}%`),
vpack: 'end',
class_name: 'menu-active-percentage playback',
label: audio.speaker.bind('volume').as((v) => `${Math.round(v * 100)}%`),
}),
],
}),

View File

@@ -1,39 +1,40 @@
import { renderActiveInput } from "./SelectedInput.js";
import { renderActivePlayback } from "./SelectedPlayback.js";
import { BarBoxChild } from 'lib/types/bar.js';
import { renderActiveInput } from './SelectedInput.js';
import { renderActivePlayback } from './SelectedPlayback.js';
const activeDevices = () => {
return Widget.Box({
class_name: "menu-section-container volume",
vertical: true,
children: [
Widget.Box({
class_name: "menu-label-container volume selected",
hpack: "fill",
child: Widget.Label({
class_name: "menu-label audio volume",
hexpand: true,
hpack: "start",
label: "Volume",
}),
}),
Widget.Box({
class_name: "menu-items-section selected",
const activeDevices = (): BarBoxChild => {
return Widget.Box({
class_name: 'menu-section-container volume',
vertical: true,
children: [
Widget.Box({
class_name: "menu-active-container playback",
vertical: true,
children: renderActivePlayback(),
}),
Widget.Box({
class_name: "menu-active-container input",
vertical: true,
children: renderActiveInput(),
}),
Widget.Box({
class_name: 'menu-label-container volume selected',
hpack: 'fill',
child: Widget.Label({
class_name: 'menu-label audio volume',
hexpand: true,
hpack: 'start',
label: 'Volume',
}),
}),
Widget.Box({
class_name: 'menu-items-section selected',
vertical: true,
children: [
Widget.Box({
class_name: 'menu-active-container playback',
vertical: true,
children: renderActivePlayback(),
}),
Widget.Box({
class_name: 'menu-active-container input',
vertical: true,
children: renderActiveInput(),
}),
],
}),
],
}),
],
});
});
};
export { activeDevices };

View File

@@ -1,7 +1,8 @@
const audio = await Service.import("audio");
import { Stream } from "types/service/audio";
const audio = await Service.import('audio');
import { InputDevices } from 'lib/types/audio';
import { Stream } from 'types/service/audio';
const renderInputDevices = (inputDevices: Stream[]) => {
const renderInputDevices = (inputDevices: Stream[]): InputDevices => {
if (inputDevices.length === 0) {
return [
Widget.Button({
@@ -9,11 +10,11 @@ const renderInputDevices = (inputDevices: Stream[]) => {
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
hpack: 'start',
children: [
Widget.Label({
class_name: "menu-button-name input",
label: "No input devices found...",
class_name: 'menu-button-name input',
label: 'No input devices found...',
}),
],
}),
@@ -29,28 +30,28 @@ const renderInputDevices = (inputDevices: Stream[]) => {
child: Widget.Box({
children: [
Widget.Box({
hpack: "start",
hpack: 'start',
children: [
Widget.Label({
wrap: true,
class_name: audio.microphone
.bind("description")
.bind('description')
.as((v) =>
device.description === v
? "menu-button-icon active input txt-icon"
: "menu-button-icon input txt-icon",
? 'menu-button-icon active input txt-icon'
: 'menu-button-icon input txt-icon',
),
label: "",
label: '',
}),
Widget.Label({
truncate: "end",
truncate: 'end',
wrap: true,
class_name: audio.microphone
.bind("description")
.bind('description')
.as((v) =>
device.description === v
? "menu-button-name active input"
: "menu-button-name input",
? 'menu-button-name active input'
: 'menu-button-name input',
),
label: device.description,
}),

View File

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

View File

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

View File

@@ -1,24 +1,23 @@
import DropdownMenu from "../DropdownMenu.js";
import { activeDevices } from "./active/index.js";
import { availableDevices } from "./available/index.js";
import Window from 'types/widgets/window.js';
import DropdownMenu from '../DropdownMenu.js';
import { activeDevices } from './active/index.js';
import { availableDevices } from './available/index.js';
import { Attribute, Child } from 'lib/types/widget.js';
export default () => {
export default (): Window<Child, Attribute> => {
return DropdownMenu({
name: "audiomenu",
transition: "crossfade",
name: 'audiomenu',
transition: 'crossfade',
child: Widget.Box({
class_name: "menu-items audio",
hpack: "fill",
class_name: 'menu-items audio',
hpack: 'fill',
hexpand: true,
child: Widget.Box({
vertical: true,
hpack: "fill",
hpack: 'fill',
hexpand: true,
class_name: "menu-items-container audio",
children: [
activeDevices(),
availableDevices(),
],
class_name: 'menu-items-container audio',
children: [activeDevices(), availableDevices()],
}),
}),
});

View File

@@ -1,26 +1,24 @@
const speakerIcons = {
101: "audio-volume-overamplified-symbolic",
66: "audio-volume-high-symbolic",
34: "audio-volume-medium-symbolic",
1: "audio-volume-low-symbolic",
0: "audio-volume-muted-symbolic",
101: 'audio-volume-overamplified-symbolic',
66: 'audio-volume-high-symbolic',
34: 'audio-volume-medium-symbolic',
1: 'audio-volume-low-symbolic',
0: 'audio-volume-muted-symbolic',
} as const;
const inputIcons = {
101: "microphone-sensitivity-high-symbolic",
66: "microphone-sensitivity-high-symbolic",
34: "microphone-sensitivity-medium-symbolic",
1: "microphone-sensitivity-low-symbolic",
0: "microphone-disabled-symbolic",
101: 'microphone-sensitivity-high-symbolic',
66: 'microphone-sensitivity-high-symbolic',
34: 'microphone-sensitivity-medium-symbolic',
1: 'microphone-sensitivity-low-symbolic',
0: 'microphone-disabled-symbolic',
};
type IconVolumes = keyof typeof speakerIcons;
const getIcon = (audioVol: IconVolumes, isMuted: boolean) => {
const getIcon = (audioVol: number, isMuted: boolean): Record<string, string> => {
const thresholds: IconVolumes[] = [101, 66, 34, 1, 0];
const icon = isMuted
? 0
: thresholds.find((threshold) => threshold <= audioVol * 100) || 0;
const icon = isMuted ? 0 : thresholds.find((threshold) => threshold <= audioVol * 100) || 0;
return {
spkr: speakerIcons[icon],