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

View file

@ -4,9 +4,10 @@
withGirNames,
buildNpmPackage,
ts-for-gir-src,
delete ? [],
...
}: let
inherit (lib) concatMapStringsSep;
inherit (lib) concatMapStringsSep optionalString;
buildPhase = ''
npx @ts-for-gir/cli generate ${concatMapStringsSep " " (p: p.girName) withGirNames} \
@ -31,6 +32,9 @@ in
'';
installPhase = ''
${optionalString (delete != []) (
"rm -f " + concatMapStringsSep " " (file: "./types/${file}.d.ts") delete
)}
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 */
const SRC: string;
declare const SRC: string;
declare module 'inline:*' {
const content: string;
@ -8,18 +6,18 @@ declare module 'inline:*' {
export default content;
}
declare module '*.sass' {
const content: string;
export default content;
}
declare module '*.scss' {
const content: string;
export default content;
}
declare module '*.blp' {
const content: string;
export default content;
}
declare module '*.css' {
const content: string;

Binary file not shown.

View file

@ -5,7 +5,6 @@
"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",

View file

@ -1,21 +1,25 @@
declare const SRC: string
declare const SRC: string;
declare module "inline:*" {
const content: string
export default content
declare module 'inline:*' {
const content: string;
export default content;
}
declare module "*.scss" {
const content: string
export default content
declare module '*.scss' {
const content: string;
export default content;
}
declare module "*.blp" {
const content: string
export default content
declare module '*.blp' {
const content: string;
export default content;
}
declare module "*.css" {
const content: string
export default content
declare module '*.css' {
const content: string;
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,
...
}: let
inherit (self.inputs) ags gtk-session-lock;
inherit (self.inputs) ags astal gtk-session-lock;
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;
@ -37,7 +37,7 @@ in {
};
astalLibs = attrValues {
inherit
(ags.inputs.astal.packages.${pkgs.system})
(astal.packages.${pkgs.system})
io
astal3
astal4
@ -59,6 +59,7 @@ in {
inherit
(pkgs)
libadwaita
gtk4 # Needed to build types
;
};
@ -118,7 +119,7 @@ in {
;
mkTsConf = gtkVer: let
inherit (ags.packages.${pkgs.system}) gjs;
inherit (astal.packages.${pkgs.system}) gjs;
in
pkgs.writers.writeJSON "tsconfig.json" {
"$schema" = "https://json.schemastore.org/tsconfig";
@ -127,6 +128,7 @@ in {
"strict" = true;
"target" = "ES2022";
"module" = "ES2022";
"lib" = ["ES2022"];
"moduleResolution" = "Bundler";
"noEmit" = true;
"jsx" = "react-jsx";
@ -141,19 +143,28 @@ in {
(buildGirTypes {
pname = "ags";
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 {
pname = "ags";
configPath = "${gtk4ConfigDir}/@girs";
packages = cfg.astalLibs;
packages = filter (x:
x.pname != "astal3" && x.pname != "gtk-session-lock")
cfg.astalLibs;
})
// {
"${cfg.configDir}/node_modules".source =
buildNodeModules ./config (import ./config).npmDepsHash;
"${cfg.configDir}/node_modules" = {
force = true;
source = buildNodeModules ./config (import ./config).npmDepsHash;
};
"${gtk4ConfigDir}/node_modules".source =
buildNodeModules ./config (import ./config).npmDepsHash;
"${gtk4ConfigDir}/node_modules" = {
force = true;
source = buildNodeModules ./config (import ./config).npmDepsHash;
};
"${cfg.configDir}/tsconfig.json".source = mkTsConf 3;