/* eslint-disable max-len */ import gi from "node-gtk" import proxy, { type ConstructProps, type Widget } from "../src/astalify.js" import type GtkT from "@girs/node-gtk-3.0/node-gtk-3.0" import type AstalT from "@girs/node-astal-0.1/node-astal-0.1" const Astal = gi.require("Astal", "0.1") const Gtk = gi.require("Gtk", "3.0") const proxify = proxy(Gtk, prop => `set${prop.charAt(0).toUpperCase() + prop.slice(1)}`, { cssGetter: Astal.widgetGetCss, cssSetter: Astal.widgetSetCss, classGetter: Astal.widgetGetClassNames, classSetter: Astal.widgetSetClassNames, cursorGetter: Astal.widgetGetCursor, cursorSetter: Astal.widgetSetCursor, }) export function astalify< C extends typeof Gtk.Widget, P extends Record, N extends string = "Widget", >(klass: C) { // eslint-disable-next-line @typescript-eslint/no-unused-vars type Astal = Omit & { new(props: P, ...children: GtkT.Widget[]): Widget (props: P, ...children: GtkT.Widget[]): Widget } return proxify(klass) as unknown as Astal } // Label export const Label = astalify(Gtk.Label) export type LabelProps = ConstructProps // Icon export const Icon = astalify(Astal.Icon) export type IconProps = ConstructProps // Button export const Button = astalify(Astal.Button) export type ButtonProps = ConstructProps) => void }> // Window export const Window = astalify(Astal.Window) export type WindowProps = ConstructProps // Box export const Box = astalify(Astal.Box) export type BoxProps = ConstructProps // CenterBox export const CenterBox = astalify(Astal.CenterBox) export type CenterBoxProps = ConstructProps // EventBox export const EventBox = astalify(Astal.EventBox) export type EventBoxProps = ConstructProps