diff --git a/devices/wim/config/ags/js/applauncher/app-item.js b/devices/wim/config/ags/js/applauncher/app-item.js index 8f14659..cb4b80b 100644 --- a/devices/wim/config/ags/js/applauncher/app-item.js +++ b/devices/wim/config/ags/js/applauncher/app-item.js @@ -7,9 +7,7 @@ import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js'; import CursorBox from '../misc/cursorbox.js'; -/** - * @param {import('types/service/applications.js').Application} app - */ +/** @param {import('types/service/applications.js').Application} app */ export default (app) => { const icon = Icon({ size: 42 }); const iconString = app.app.get_string('Icon'); diff --git a/devices/wim/config/ags/js/applauncher/main.js b/devices/wim/config/ags/js/applauncher/main.js index 46f3f97..33feb0d 100644 --- a/devices/wim/config/ags/js/applauncher/main.js +++ b/devices/wim/config/ags/js/applauncher/main.js @@ -23,10 +23,9 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => { }); fzfResults = fzf.find(text); + // @ts-expect-error list.set_sort_func((a, b) => { - // @ts-expect-error const row1 = a.get_children()[0]?.attribute.app.name; - // @ts-expect-error const row2 = b.get_children()[0]?.attribute.app.name; if (!row1 || !row2) { @@ -39,7 +38,8 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => { }; const makeNewChildren = () => { - list.get_children().forEach((ch) => { + // @ts-expect-error + Array.from(list.get_children()).forEach((ch) => { ch.destroy(); }); @@ -47,6 +47,7 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => { .flatMap((app) => AppItem(app)); children.forEach((ch) => { + // @ts-expect-error list.add(ch); }); list.show_all(); @@ -84,11 +85,10 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => { setSort(text); let visibleApps = 0; - list.get_children().forEach((row) => { - // @ts-expect-error + // @ts-expect-error + Array.from(list.get_children()).forEach((row) => { row.changed(); - // @ts-expect-error const item = row.get_children()[0]; if (item?.attribute.app) { diff --git a/devices/wim/config/ags/js/bar/buttons/battery.js b/devices/wim/config/ags/js/bar/buttons/battery.js index a0da5f2..90d84e3 100644 --- a/devices/wim/config/ags/js/bar/buttons/battery.js +++ b/devices/wim/config/ags/js/bar/buttons/battery.js @@ -14,7 +14,6 @@ export default () => Box({ children: [ Icon({ class_name: 'battery-indicator', - // @ts-expect-error icon: Battery.bind('icon_name'), }).hook(Battery, (self) => { self.toggleClassName('charging', Battery.charging); diff --git a/devices/wim/config/ags/js/bar/buttons/brightness.js b/devices/wim/config/ags/js/bar/buttons/brightness.js index 5a4568e..bee5c41 100644 --- a/devices/wim/config/ags/js/bar/buttons/brightness.js +++ b/devices/wim/config/ags/js/bar/buttons/brightness.js @@ -8,7 +8,6 @@ const SPACING = 5; export default () => { const icon = Icon({ - // @ts-expect-error icon: Brightness.bind('screenIcon'), }); diff --git a/devices/wim/config/ags/js/bar/buttons/current-window.js b/devices/wim/config/ags/js/bar/buttons/current-window.js index 0f641db..cf466f3 100644 --- a/devices/wim/config/ags/js/bar/buttons/current-window.js +++ b/devices/wim/config/ags/js/bar/buttons/current-window.js @@ -17,7 +17,7 @@ export default () => Box({ .query(Hyprland.active.client.class)[0]; if (app) { - self.icon = app.icon_name; + self.icon = app.icon_name || ''; self.visible = Hyprland.active.client.title !== ''; } }), diff --git a/devices/wim/config/ags/js/bar/buttons/keyboard-layout.js b/devices/wim/config/ags/js/bar/buttons/keyboard-layout.js index a26a11f..fdec893 100644 --- a/devices/wim/config/ags/js/bar/buttons/keyboard-layout.js +++ b/devices/wim/config/ags/js/bar/buttons/keyboard-layout.js @@ -9,7 +9,7 @@ const SPACING = 4; /** - * @param {Label} self + * @param {import('types/widgets/label').default} self * @param {string} layout * @param {string} _ */ @@ -21,7 +21,6 @@ const getKbdLayout = (self, _, layout) => { const shortName = layout.match(/\(([A-Za-z]+)\)/); - // @ts-expect-error self.label = shortName ? shortName[1] : layout; } else { @@ -35,7 +34,6 @@ const getKbdLayout = (self, _, layout) => { const shortName = layout .match(/\(([A-Za-z]+)\)/); - // @ts-expect-error self.label = shortName ? shortName[1] : layout; }).catch(print); } diff --git a/devices/wim/config/ags/js/bar/buttons/network.js b/devices/wim/config/ags/js/bar/buttons/network.js index f5214e8..0ba9b5c 100644 --- a/devices/wim/config/ags/js/bar/buttons/network.js +++ b/devices/wim/config/ags/js/bar/buttons/network.js @@ -25,7 +25,7 @@ export default () => { const label = Label().hook(Network, (self) => { if (Network.wifi.internet === 'connected' || Network.wifi.internet === 'connecting') { - self.label = Network.wifi.ssid; + self.label = Network.wifi.ssid || 'Unknown'; } else if (Network.wired.internet === 'connected' || Network.wired.internet === 'connecting') { diff --git a/devices/wim/config/ags/js/bar/buttons/systray.js b/devices/wim/config/ags/js/bar/buttons/systray.js index 9602107..1e7c221 100644 --- a/devices/wim/config/ags/js/bar/buttons/systray.js +++ b/devices/wim/config/ags/js/bar/buttons/systray.js @@ -26,6 +26,7 @@ const SysTrayItem = (item) => { child: Icon({ size: 24, + // @ts-expect-error icon: item.bind('icon'), }), }), @@ -38,50 +39,39 @@ const SysTray = () => MenuBar({ }, setup: (self) => { - /** - * @param {import('types/widget').default} _ - * @param {string} id - */ - const addTray = (_, id) => { - const item = SystemTray.getItem(id); - - if (self.attribute.items.has(id) || !item) { - return; - } - - const w = SysTrayItem(item); - - // Early return if item is in blocklist - if (!w) { - return; - } - - self.attribute.items.set(id, w); - self.child = w; - self.show_all(); - // @ts-expect-error - w.child.reveal_child = true; - }; - - /** - * @param {import('types/widget').default} _ - * @param {string} id - */ - const removeTray = (_, id) => { - if (!self.attribute.items.has(id)) { - return; - } - - self.attribute.items.get(id).child.reveal_child = false; - timeout(REVEAL_DURATION, () => { - self.attribute.items.get(id).destroy(); - self.attribute.items.delete(id); - }); - }; - self - .hook(SystemTray, addTray, 'added') - .hook(SystemTray, removeTray, 'removed'); + .hook(SystemTray, (_, id) => { + const item = SystemTray.getItem(id); + + if (self.attribute.items.has(id) || !item) { + return; + } + + const w = SysTrayItem(item); + + // Early return if item is in blocklist + if (!w) { + return; + } + + self.attribute.items.set(id, w); + self.child = w; + self.show_all(); + // @ts-expect-error + w.child.reveal_child = true; + }, 'added') + + .hook(SystemTray, (_, id) => { + if (!self.attribute.items.has(id)) { + return; + } + + self.attribute.items.get(id).child.reveal_child = false; + timeout(REVEAL_DURATION, () => { + self.attribute.items.get(id).destroy(); + self.attribute.items.delete(id); + }); + }, 'removed'); }, }); @@ -102,6 +92,7 @@ export default () => { ], }), }).hook(SystemTray, (self) => { + // @ts-expect-error self.reveal_child = systray.get_children().length > 0; }); }; diff --git a/devices/wim/config/ags/js/bar/fullscreen.js b/devices/wim/config/ags/js/bar/fullscreen.js index 00e2020..1114fb1 100644 --- a/devices/wim/config/ags/js/bar/fullscreen.js +++ b/devices/wim/config/ags/js/bar/fullscreen.js @@ -14,8 +14,11 @@ const BarCloser = (variable) => Window({ child: EventBox({ on_hover: (self) => { variable.value = false; - // @ts-expect-error - self.get_parent().visible = false; + const parent = self.get_parent(); + + if (parent) { + parent.visible = false; + } }, child: Box({ @@ -64,11 +67,11 @@ export default (props) => { transition: 'slide_down', reveal_child: true, - binds: [['revealChild', Revealed, 'value']], - }), + }).bind('reveal_child', Revealed), Revealer({ - binds: [['revealChild', Revealed, 'value', (v) => !v]], + reveal_child: Revealed.bind() + .transform((v) => !v), child: EventBox({ on_hover: () => { diff --git a/devices/wim/config/ags/js/media-player/player.js b/devices/wim/config/ags/js/media-player/player.js index f269c9f..71c1e0f 100644 --- a/devices/wim/config/ags/js/media-player/player.js +++ b/devices/wim/config/ags/js/media-player/player.js @@ -126,86 +126,100 @@ export default () => { setup: false, }, - setup: (self) => { + setup: /** @param {any} self */ (self) => { self - .hook(Mpris, (overlay, bus_name) => { - const players = overlay.attribute.players; + .hook(Mpris, + /** + * @param {Overlay} overlay + * @param {string} bus_name + */ + (overlay, bus_name) => { + const players = overlay.attribute.players; - if (players.has(bus_name)) { - return; - } - - // Sometimes the signal doesn't give the bus_name - if (!bus_name) { - const player = Mpris.players.find((p) => { - return !players.has(p.bus_name); - }); - - if (player) { - bus_name = player.bus_name; - } - else { + if (players.has(bus_name)) { return; } - } - // Get the one on top so we can move it up later - const previousFirst = overlay.attribute.list().at(-1); + // Sometimes the signal doesn't give the bus_name + if (!bus_name) { + const player = Mpris.players.find((p) => { + return !players.has(p.bus_name); + }); - // Make the new player - const player = Mpris.getPlayer(bus_name); - const Colors = Variable(null); + if (player) { + bus_name = player.bus_name; + } + else { + return; + } + } - if (!player) { - return; - } + // Get the one on top so we can move it up later + const previousFirst = overlay.attribute.list().at(-1); - players.set( - bus_name, - // @ts-expect-error - PlayerBox(player, Colors, content.child), - ); - overlay.overlays = Array.from(players.values()) - .map((widget) => widget); + // Make the new player + const player = Mpris.getPlayer(bus_name); + const Colors = Variable(null); - const includes = overlay.attribute - .includesWidget(previousFirst); + if (!player) { + return; + } - // Select favorite player at startup - if (!overlay.attribute.setup && players.has(FAVE_PLAYER)) { - overlay.attribute.moveToTop(players.get(FAVE_PLAYER)); - overlay.attribute.setup = true; - } + players.set( + bus_name, + // @ts-expect-error + PlayerBox(player, Colors, content.child), + ); + overlay.overlays = Array.from(players.values()) + .map((widget) => widget); - // Move previousFirst on top again - else if (includes) { - overlay.attribute.moveToTop(previousFirst); - } - }, 'player-added') + const includes = overlay.attribute + .includesWidget(previousFirst); - .hook(Mpris, (overlay, bus_name) => { - const players = overlay.attribute.players; + // Select favorite player at startup + const attrs = overlay.attribute; - if (!bus_name || !players.has(bus_name)) { - return; - } + if (!attrs.setup && players.has(FAVE_PLAYER)) { + attrs.moveToTop(players.get(FAVE_PLAYER)); + attrs.setup = true; + } - // Get the one on top so we can move it up later - const previousFirst = overlay.attribute.list().at(-1); + // Move previousFirst on top again + else if (includes) { + attrs.moveToTop(previousFirst); + } + }, + 'player-added') - // Remake overlays without deleted one - players.delete(bus_name); - overlay.overlays = Array.from(players.values()) - .map((widget) => widget); + .hook(Mpris, + /** + * @param {Overlay} overlay + * @param {string} bus_name + */ + (overlay, bus_name) => { + const players = overlay.attribute.players; - // Move previousFirst on top again - const includes = overlay.attribute - .includesWidget(previousFirst); + if (!bus_name || !players.has(bus_name)) { + return; + } - if (includes) { - overlay.attribute.moveToTop(previousFirst); - } - }, 'player-closed'); + // Get the one on top so we can move it up later + const previousFirst = overlay.attribute.list().at(-1); + + // Remake overlays without deleted one + players.delete(bus_name); + overlay.overlays = Array.from(players.values()) + .map((widget) => widget); + + // Move previousFirst on top again + const includes = overlay.attribute + .includesWidget(previousFirst); + + if (includes) { + overlay.attribute.moveToTop(previousFirst); + } + }, + 'player-closed'); }, }); diff --git a/devices/wim/config/ags/js/misc/cursorbox.js b/devices/wim/config/ags/js/misc/cursorbox.js index 1067ac5..daf6ba7 100644 --- a/devices/wim/config/ags/js/misc/cursorbox.js +++ b/devices/wim/config/ags/js/misc/cursorbox.js @@ -35,6 +35,7 @@ export default ({ get_child: () => widget.child, + /** @param {import('types/widget').Widget} new_child */ set_child: (new_child) => { widget.child = new_child; }, diff --git a/devices/wim/config/ags/js/misc/persist.js b/devices/wim/config/ags/js/misc/persist.js index 23ca918..9a6580c 100644 --- a/devices/wim/config/ags/js/misc/persist.js +++ b/devices/wim/config/ags/js/misc/persist.js @@ -3,16 +3,15 @@ const { get_home_dir } = imports.gi.GLib; /** - * @typedef {Object} Persist - * @property {string} name - * @property {typeof imports.gi.GObject} gobject - * @property {string} prop - * @property {boolean|string=} condition - if string, compare following props to this - * @property {boolean|string=} whenTrue - * @property {boolean|string=} whenFalse - * @property {string=} signal - * - * @param {Persist} props + * @param {{ + * name: string + * gobject: typeof imports.gi.GObject + * prop: string + * condition?: boolean|string // if string, compare following props to this + * whenTrue?: boolean|string + * whenFalse?: boolean|string + * signal?: string + * }} o */ export default ({ name, diff --git a/devices/wim/config/ags/js/misc/popup.js b/devices/wim/config/ags/js/misc/popup.js index c2a5f48..f8f0fe6 100644 --- a/devices/wim/config/ags/js/misc/popup.js +++ b/devices/wim/config/ags/js/misc/popup.js @@ -68,9 +68,10 @@ export default ({ // @ts-expect-error get_child: () => window.child.children[0].child, - set_child: (newChild) => { + /** @param {import('types/widget').Widget} new_child */ + set_child: (new_child) => { // @ts-expect-error - window.child.children[0].child = newChild; + window.child.children[0].child = new_child; // @ts-expect-error window.child.children[0].show_all(); },