feat(ags): improve types
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-01-02 01:26:38 -05:00
parent 8871cc8f01
commit ccd437a275
10 changed files with 60 additions and 54 deletions

View file

@ -31,6 +31,7 @@ in {
configPath, configPath,
packages, packages,
pname, pname,
delete ? [],
}: let }: let
withGirNames = withGirNames =
map (package: { map (package: {
@ -48,15 +49,18 @@ in {
then "AstalPowerProfiles-0.1" then "AstalPowerProfiles-0.1"
else if package.pname == "gtk4" else if package.pname == "gtk4"
then "Gtk-4.0" then "Gtk-4.0"
else if package.pname == "libadwaita"
then "Adw-1"
else (concatMapStrings capitalise (splitString "-" package.pname)) + "-0.1"; else (concatMapStrings capitalise (splitString "-" package.pname)) + "-0.1";
}) })
packages; packages;
in { in {
"${configPath}${optionalString (length packages == 1) "/${toLower (elemAt withGirNames 0).girName}"}".source = "${configPath}${optionalString (length packages == 1) "/${toLower (elemAt withGirNames 0).girName}"}" = {
pkgs.callPackage force = true;
./mk-types { source = pkgs.callPackage ./mk-types {
inherit (self.inputs) ts-for-gir-src; inherit (self.inputs) ts-for-gir-src;
inherit pname withGirNames; inherit delete pname withGirNames;
};
}; };
}; };
} }

View file

@ -4,9 +4,10 @@
withGirNames, withGirNames,
buildNpmPackage, buildNpmPackage,
ts-for-gir-src, ts-for-gir-src,
delete ? [],
... ...
}: let }: let
inherit (lib) concatMapStringsSep; inherit (lib) concatMapStringsSep optionalString;
buildPhase = '' buildPhase = ''
npx @ts-for-gir/cli generate ${concatMapStringsSep " " (p: p.girName) withGirNames} \ npx @ts-for-gir/cli generate ${concatMapStringsSep " " (p: p.girName) withGirNames} \
@ -31,6 +32,9 @@ in
''; '';
installPhase = '' installPhase = ''
${optionalString (delete != []) (
"rm -f " + concatMapStringsSep " " (file: "./types/${file}.d.ts") delete
)}
cp -r ./types $out cp -r ./types $out
''; '';
} }

View file

@ -1,3 +1,3 @@
{ {
npmDepsHash = "sha256-FzWSWDEqsJxhYOhfSvmZU+/hqw44wm60nM7l32ut1+Y="; npmDepsHash = "sha256-qn1+dIo7p1+PYlR2qAmnCrR8xE93mYbwNCjDYISgnqU=";
} }

View file

@ -1,6 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */ declare const SRC: string;
const SRC: string;
declare module 'inline:*' { declare module 'inline:*' {
const content: string; const content: string;
@ -8,18 +6,18 @@ declare module 'inline:*' {
export default content; export default content;
} }
declare module '*.sass' {
const content: string;
export default content;
}
declare module '*.scss' { declare module '*.scss' {
const content: string; const content: string;
export default content; export default content;
} }
declare module '*.blp' {
const content: string;
export default content;
}
declare module '*.css' { declare module '*.css' {
const content: string; const content: string;

Binary file not shown.

View file

@ -5,7 +5,6 @@
"dependencies": { "dependencies": {
"@eslint/js": "9.17.0", "@eslint/js": "9.17.0",
"@stylistic/eslint-plugin": "2.12.1", "@stylistic/eslint-plugin": "2.12.1",
"@types/node": "22.10.2",
"eslint": "9.17.0", "eslint": "9.17.0",
"eslint-plugin-jsdoc": "50.6.1", "eslint-plugin-jsdoc": "50.6.1",
"fzf": "0.5.2", "fzf": "0.5.2",

View file

@ -1,21 +1,25 @@
declare const SRC: string declare const SRC: string;
declare module "inline:*" { declare module 'inline:*' {
const content: string const content: string;
export default content
export default content;
} }
declare module "*.scss" { declare module '*.scss' {
const content: string const content: string;
export default content
export default content;
} }
declare module "*.blp" { declare module '*.blp' {
const content: string const content: string;
export default content
export default content;
} }
declare module "*.css" { declare module '*.css' {
const content: string const content: string;
export default content
export default content;
} }

Binary file not shown.

1
modules/ags/gtk4/package-lock.json generated Symbolic link
View file

@ -0,0 +1 @@
../config/package-lock.json

View file

@ -1,15 +0,0 @@
{
"name": "ags",
"version": "0.0.0",
"main": "app.ts",
"dependencies": {
"@eslint/js": "9.17.0",
"@stylistic/eslint-plugin": "2.12.1",
"@types/node": "22.10.2",
"eslint": "9.17.0",
"eslint-plugin-jsdoc": "50.6.1",
"fzf": "0.5.2",
"jiti": "2.4.2",
"typescript-eslint": "8.19.0"
}
}

View file

@ -0,0 +1 @@
../config/package.json

View file

@ -5,11 +5,11 @@ self: {
pkgs, pkgs,
... ...
}: let }: let
inherit (self.inputs) ags gtk-session-lock; inherit (self.inputs) ags astal gtk-session-lock;
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default; gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
inherit (lib) attrValues boolToString getExe optionalAttrs optionals; inherit (lib) attrValues boolToString filter getExe optionalAttrs optionals;
inherit (osConfig.networking) hostName; inherit (osConfig.networking) hostName;
@ -37,7 +37,7 @@ in {
}; };
astalLibs = attrValues { astalLibs = attrValues {
inherit inherit
(ags.inputs.astal.packages.${pkgs.system}) (astal.packages.${pkgs.system})
io io
astal3 astal3
astal4 astal4
@ -59,6 +59,7 @@ in {
inherit inherit
(pkgs) (pkgs)
libadwaita
gtk4 # Needed to build types gtk4 # Needed to build types
; ;
}; };
@ -118,7 +119,7 @@ in {
; ;
mkTsConf = gtkVer: let mkTsConf = gtkVer: let
inherit (ags.packages.${pkgs.system}) gjs; inherit (astal.packages.${pkgs.system}) gjs;
in in
pkgs.writers.writeJSON "tsconfig.json" { pkgs.writers.writeJSON "tsconfig.json" {
"$schema" = "https://json.schemastore.org/tsconfig"; "$schema" = "https://json.schemastore.org/tsconfig";
@ -127,6 +128,7 @@ in {
"strict" = true; "strict" = true;
"target" = "ES2022"; "target" = "ES2022";
"module" = "ES2022"; "module" = "ES2022";
"lib" = ["ES2022"];
"moduleResolution" = "Bundler"; "moduleResolution" = "Bundler";
"noEmit" = true; "noEmit" = true;
"jsx" = "react-jsx"; "jsx" = "react-jsx";
@ -141,19 +143,28 @@ in {
(buildGirTypes { (buildGirTypes {
pname = "ags"; pname = "ags";
configPath = "${cfg.configDir}/@girs"; configPath = "${cfg.configDir}/@girs";
packages = cfg.astalLibs; packages = filter (x:
x.pname != "astal4" && x.pname != "libadwaita")
cfg.astalLibs;
delete = ["gdk-4.0" "gtk-4.0" "gsk-4.0"];
}) })
// (buildGirTypes { // (buildGirTypes {
pname = "ags"; pname = "ags";
configPath = "${gtk4ConfigDir}/@girs"; configPath = "${gtk4ConfigDir}/@girs";
packages = cfg.astalLibs; packages = filter (x:
x.pname != "astal3" && x.pname != "gtk-session-lock")
cfg.astalLibs;
}) })
// { // {
"${cfg.configDir}/node_modules".source = "${cfg.configDir}/node_modules" = {
buildNodeModules ./config (import ./config).npmDepsHash; force = true;
source = buildNodeModules ./config (import ./config).npmDepsHash;
};
"${gtk4ConfigDir}/node_modules".source = "${gtk4ConfigDir}/node_modules" = {
buildNodeModules ./config (import ./config).npmDepsHash; force = true;
source = buildNodeModules ./config (import ./config).npmDepsHash;
};
"${cfg.configDir}/tsconfig.json".source = mkTsConf 3; "${cfg.configDir}/tsconfig.json".source = mkTsConf 3;