npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ags-ts

v1.0.6

Published

A package containing definition and import that makes writing configuration for [ags](https://github.com/Aylur/ags) in typescript easier.

Readme

Ags

This package helps those who want to write a configuration file for ags in typescript.

Installation

npm install ags-ts

Usage

Widgets

Built-in widgets are exported in named export Widget. Some types are also exported for convenience, such as AgsBox.

Utils

All utils functions are directly imported, as shown in the example.

Variables

Exported in named export Variables, along with three helper types VariableOptions, VariablePoll and VariableListen;

Services

Each built-in service is directly exported, along with the base Service type.

App

Exported in named export App.

Gjs Related

These gjs related model are also exported just in case: Cairo, DbusmenuGtk3, Gdk, GdkPixbuf, Gio, GnomeBluetooth, GObject, Gtk, Gvc, NM.

Example

Below is an example of the official simple bar written in typescript with this package:

// importing
import { exec, execAsync } from 'ags';
import {
	Hyprland,
	Notifications,
	Mpris,
	Audio,
	Battery,
	SystemTray,
	App,
	Widget,
} from 'ags';

const Workspaces = () =>
	Widget.Box({
		className: 'workspaces',
		connections: [
			[
				Hyprland.active.workspace,
				(self) => {
					// generate an array [1..10] then make buttons from the index
					const arr = Array.from({ length: 10 }, (_, i) => i + 1);
					self.children = arr.map((i) =>
						Widget.Button({
							onClicked: () =>
								execAsync(`hyprctl dispatch workspace ${i}`),
							child: Widget.Label(`${i}`),
							className:
								Hyprland.active.workspace.id == i
									? 'focused'
									: '',
						}),
					);
				},
			],
		],
	});

const ClientTitle = () =>
	Widget.Label({
		className: 'client-title',
		binds: [['label', Hyprland.active.client, 'title']],
	});

const Clock = () =>
	Widget.Label({
		className: 'clock',
		connections: [
			// this is bad practice, since exec() will block the main event loop
			// in the case of a simple date its not really a problem
			[1000, (self) => (self.label = exec('date "+%H:%M:%S %b %e."'))],

			// this is what you should do
			[
				1000,
				(self) =>
					execAsync(['date', '+%H:%M:%S %b %e.'])
						.then((date) => (self.label = date))
						.catch(console.error),
			],
		],
	});

// we don't need dunst or any other notification daemon
// because the Notifications module is a notification daemon itself
const Notification = () =>
	Widget.Box({
		className: 'notification',
		children: [
			Widget.Icon({
				icon: 'preferences-system-notifications-symbolic',
				connections: [
					[
						Notifications,
						(self) =>
							(self.visible = Notifications.popups.length > 0),
					],
				],
			}),
			Widget.Label({
				connections: [
					[
						Notifications,
						(self) => {
							self.label = Notifications.popups[0]?.summary || '';
						},
					],
				],
			}),
		],
	});

const Media = () =>
	Widget.Button({
		className: 'media',
		onPrimaryClick: () => Mpris.getPlayer('')?.playPause(),
		onScrollUp: () => Mpris.getPlayer('')?.next(),
		onScrollDown: () => Mpris.getPlayer('')?.previous(),
		child: Widget.Label({
			connections: [
				[
					Mpris,
					(self) => {
						const mpris = Mpris.getPlayer('');
						// mpris player can be undefined
						if (mpris)
							self.label = `${mpris.trackArtists.join(', ')} - ${
								mpris.trackTitle
							}`;
						else self.label = 'Nothing is playing';
					},
				],
			],
		}),
	});

const Volume = () =>
	Widget.Box({
		className: 'volume',
		style: 'min-width: 180px',
		children: [
			Widget.Stack({
				items: [
					// tuples of [string, Widget]
					['101', Widget.Icon('audio-volume-overamplified-symbolic')],
					['67', Widget.Icon('audio-volume-high-symbolic')],
					['34', Widget.Icon('audio-volume-medium-symbolic')],
					['1', Widget.Icon('audio-volume-low-symbolic')],
					['0', Widget.Icon('audio-volume-muted-symbolic')],
				],
				connections: [
					[
						Audio,
						(self) => {
							if (!Audio.speaker) return;

							if (Audio.speaker.is_muted) {
								self.shown = '0';
								return;
							}

							const show = [101, 67, 34, 1, 0].find(
								(threshold) =>
									threshold <= Audio.speaker.volume * 100,
							);

							self.shown = `${show}`;
						},
						'speaker-changed',
					],
				],
			}),
			Widget.Slider({
				hexpand: true,
				drawValue: false,
				onChange: ({ value }) => (Audio.speaker.volume = value),
				connections: [
					[
						Audio,
						(self) => {
							self.value = Audio.speaker?.volume || 0;
						},
						'speaker-changed',
					],
				],
			}),
		],
	});

const BatteryLabel = () =>
	Widget.Box({
		className: 'battery',
		children: [
			Widget.Icon({
				connections: [
					[
						Battery,
						(self) => {
							self.icon = `battery-level-${
								Math.floor(Battery.percent / 10) * 10
							}-symbolic`;
						},
					],
				],
			}),
			Widget.ProgressBar({
				valign: 'center',
				connections: [
					[
						Battery,
						(self) => {
							if (Battery.percent < 0) return;

							self.fraction = Battery.percent / 100;
						},
					],
				],
			}),
		],
	});

const SysTray = () =>
	Widget.Box({
		connections: [
			[
				SystemTray,
				(self) => {
					self.children = SystemTray.items.map((item) =>
						Widget.Button({
							child: Widget.Icon({
								binds: [['icon', item, 'icon']],
							}),
							onPrimaryClick: (_, event) => item.activate(event),
							onSecondaryClick: (_, event) =>
								item.openMenu(event),
							binds: [['tooltip-markup', item, 'tooltip-markup']],
						}),
					);
				},
			],
		],
	});

// layout of the bar
const Left = () =>
	Widget.Box({
		children: [Workspaces(), ClientTitle()],
	});

const Center = () =>
	Widget.Box({
		children: [Media(), Notification()],
	});

const Right = () =>
	Widget.Box({
		halign: 'end',
		children: [Volume(), BatteryLabel(), Clock(), SysTray()],
	});

const Bar = ({ monitor }: { monitor?: number } = {}) =>
	Widget.Window({
		name: `bar-${monitor}`, // name has to be unique
		className: 'bar',
		monitor,
		anchor: ['top', 'left', 'right'],
		exclusive: true,
		child: Widget.CenterBox({
			startWidget: Left(),
			centerWidget: Center(),
			endWidget: Right(),
		}),
	});

// exporting the config so ags can manage the windows
export default {
	style: App.configDir + '/style.css',
	windows: [
		Bar(),

		// you can call it, for each monitor
		// Bar({ monitor: 0 }),
		// Bar({ monitor: 1 })
	],
};