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 64 additions and 1778 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;

View file

@ -10,7 +10,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",
@ -327,15 +326,6 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"license": "MIT"
},
"node_modules/@types/node": {
"version": "22.10.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
"integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.20.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.0.tgz",
@ -1615,9 +1605,9 @@
}
},
"node_modules/typescript": {
"version": "5.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
"license": "Apache-2.0",
"peer": true,
"bin": {
@ -1650,12 +1640,6 @@
"typescript": ">=4.8.4 <5.8.0"
}
},
"node_modules/undici-types": {
"version": "6.20.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
"license": "MIT"
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",

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;
}

File diff suppressed because it is too large Load diff

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;