From 1e634b0968efb28c7ec9fdf28002ae7cc4cd9807 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Sun, 31 Dec 2023 18:59:22 +0100 Subject: [PATCH] Use gnome-shell types from @girs --- @types/gnome-shell/ambient.d.ts | 4 +- @types/gnome-shell/extensions/extension.d.ts | 58 ------- @types/gnome-shell/extensions/prefs.d.ts | 35 ----- package.json | 1 + src/prefs.ts | 7 +- tsconfig.json | 6 - yarn.lock | 152 +++++++++++++++++++ 7 files changed, 157 insertions(+), 106 deletions(-) delete mode 100644 @types/gnome-shell/extensions/extension.d.ts delete mode 100644 @types/gnome-shell/extensions/prefs.d.ts diff --git a/@types/gnome-shell/ambient.d.ts b/@types/gnome-shell/ambient.d.ts index 4ecc49e..8e4d936 100644 --- a/@types/gnome-shell/ambient.d.ts +++ b/@types/gnome-shell/ambient.d.ts @@ -19,6 +19,4 @@ import "@girs/gjs"; import "@girs/gjs/dom"; -import "@girs/shell-13/ambient"; -import "@girs/gtk-4.0/ambient"; -import "@girs/adw-1/ambient"; +import "@girs/gnome-shell/ambient"; diff --git a/@types/gnome-shell/extensions/extension.d.ts b/@types/gnome-shell/extensions/extension.d.ts deleted file mode 100644 index 31b5db1..0000000 --- a/@types/gnome-shell/extensions/extension.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright Sebastian Wiesner -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0.If a copy of the MPL was not distributed with this -// file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// Alternatively, the contents of this file may be used under the terms -// of the GNU General Public License Version 2 or later, as described below: -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -import type Gio from "@girs/gio-2.0"; - -// See https://gjs.guide/extensions/topics/extension.html#gettext -export declare function gettext(str: string): string; -export declare function ngettext( - str: string, - strPlural: string, - n: number, -): string; -export declare function pgettext(context: string, str: string): string; - -// See https://gjs.guide/extensions/topics/extension.html#types -export declare interface ExtensionMetadata { - readonly uuid: string; - readonly name: string; - readonly description: string; - readonly "version-name": string; - readonly "shell-version": readonly string[]; - readonly dir: Gio.File; - readonly path: string; - readonly url: string; -} - -declare class ExtensionBase { - constructor(metadata: ExtensionMetadata); - - get metadata(): ExtensionMetadata; - getSettings(schema?: string): Gio.Settings; -} - -export declare class Extension extends ExtensionBase { - constructor(metadata: ExtensionMetadata); - - enable(): void; - - disable(): void; - - openPreferences(): void; -} diff --git a/@types/gnome-shell/extensions/prefs.d.ts b/@types/gnome-shell/extensions/prefs.d.ts deleted file mode 100644 index a286748..0000000 --- a/@types/gnome-shell/extensions/prefs.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Sebastian Wiesner -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0.If a copy of the MPL was not distributed with this -// file, You can obtain one at https://mozilla.org/MPL/2.0/. -// -// Alternatively, the contents of this file may be used under the terms -// of the GNU General Public License Version 2 or later, as described below: -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -import type Gtk from "gi://Gtk"; -import type Adw from "gi://Adw"; -import { ExtensionBase } from "resource:///org/gnome/shell/extensions/extension.js"; - -export declare class ExtensionPreferences extends ExtensionBase { - getPreferencesWidget(): Gtk.Widget; - - fillPreferencesWindow(window: Adw.PreferencesWindow): void; -} - -export { - gettext, - ngettext, - pgettext, - ExtensionMetadata, -} from "resource:///org/gnome/shell/extensions/extension.js"; diff --git a/package.json b/package.json index 4794d4a..42e5ae7 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@girs/gio-2.0": "^2.78.0-3.2.6", "@girs/gjs": "^3.2.6", "@girs/glib-2.0": "^2.78.0-3.2.6", + "@girs/gnome-shell": "^45.0.0-beta5", "@girs/gtk-4.0": "^4.12.3-3.2.6", "@girs/shell-13": "^13.0.0-3.2.6", "@girs/st-13": "^13.0.0-3.2.6", diff --git a/src/prefs.ts b/src/prefs.ts index 509691f..66042df 100644 --- a/src/prefs.ts +++ b/src/prefs.ts @@ -23,10 +23,9 @@ import Gio from "gi://Gio"; import Gtk from "gi://Gtk"; import Adw from "gi://Adw"; -import { - ExtensionMetadata, - ExtensionPreferences, -} from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js"; +import { ExtensionPreferences } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js"; + +import type { ExtensionMetadata } from "@girs/gnome-shell/extensions/extension"; const LICENSE = `Copyright Sebastian Wiesner diff --git a/tsconfig.json b/tsconfig.json index dfb2a31..6d47daa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,12 +7,6 @@ "moduleResolution": "NodeNext", "lib": ["ES2022"], "removeComments": false, - "paths": { - // Our own types. First as they are seen in GNOME shell extensions, - // and then how they're seen by prefs.js. - "resource:///org/gnome/shell/*": ["./@types/gnome-shell/*"], - "resource:///org/gnome/Shell/Extensions/js/*": ["./@types/gnome-shell/*"] - }, "skipLibCheck": true }, "include": [ diff --git a/yarn.lock b/yarn.lock index 9443220..31af0f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,6 +54,18 @@ __metadata: languageName: node linkType: hard +"@girs/accountsservice-1.0@npm:^1.0.0-3.2.6": + version: 1.0.0-3.2.6 + resolution: "@girs/accountsservice-1.0@npm:1.0.0-3.2.6" + dependencies: + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + checksum: cf15248793691a7672135aff220841b303bd0060b07326d85d289e08f4fd15f44185f93a2e4c38f06898ba6973ab0e3ce336d4d1f3de1be2c7dfa541fe3f6a77 + languageName: node + linkType: hard + "@girs/adw-1@npm:^1.4.0-3.2.6": version: 1.4.0-3.2.6 resolution: "@girs/adw-1@npm:1.4.0-3.2.6" @@ -162,6 +174,18 @@ __metadata: languageName: node linkType: hard +"@girs/cogl-2.0@npm:^2.0.0-3.2.6": + version: 2.0.0-3.2.6 + resolution: "@girs/cogl-2.0@npm:2.0.0-3.2.6" + dependencies: + "@girs/gjs": "npm:^3.2.6" + "@girs/gl-1.0": "npm:^1.0.0-3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + checksum: 121962d6f4971a2aad09c885c6b48ebba3355af5c57ed086b240d97847d3c26a55b25d1e62ddda7f1204a4049586cb843761afe291426ab2bc4788236d8c1e6c + languageName: node + linkType: hard + "@girs/coglpango-13@npm:^13.0.0-3.2.6": version: 13.0.0-3.2.6 resolution: "@girs/coglpango-13@npm:13.0.0-3.2.6" @@ -259,6 +283,18 @@ __metadata: languageName: node linkType: hard +"@girs/gdm-1.0@npm:^1.0.0-3.2.6": + version: 1.0.0-3.2.6 + resolution: "@girs/gdm-1.0@npm:1.0.0-3.2.6" + dependencies: + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + checksum: 5bfd8b66808d6998d4a76859c8131799a8ecc6812efd38e9b168a431d30e50229ffc855c46b38b1299ee04bf2e4ff4135581bedc0695310facc29fae3b8f8677 + languageName: node + linkType: hard + "@girs/gio-2.0@npm:^2.78.0-3.2.6": version: 2.78.0-3.2.6 resolution: "@girs/gio-2.0@npm:2.78.0-3.2.6" @@ -311,6 +347,86 @@ __metadata: languageName: node linkType: hard +"@girs/gnome-shell@npm:^45.0.0-beta5": + version: 45.0.0-beta5 + resolution: "@girs/gnome-shell@npm:45.0.0-beta5" + dependencies: + "@girs/accountsservice-1.0": "npm:^1.0.0-3.2.6" + "@girs/adw-1": "npm:^1.4.0-3.2.6" + "@girs/atk-1.0": "npm:^2.50.0-3.2.6" + "@girs/cally-13": "npm:^13.0.0-3.2.6" + "@girs/clutter-13": "npm:^13.0.0-3.2.6" + "@girs/cogl-2.0": "npm:^2.0.0-3.2.6" + "@girs/gcr-4": "npm:^4.1.0-3.2.6" + "@girs/gdm-1.0": "npm:^1.0.0-3.2.6" + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gnomebg-4.0": "npm:^4.0.0-3.2.6" + "@girs/gnomebluetooth-3.0": "npm:^3.0.0-3.2.6" + "@girs/gnomedesktop-4.0": "npm:^4.0.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + "@girs/gtk-4.0": "npm:^4.12.3-3.2.6" + "@girs/gvc-1.0": "npm:^1.0.0-3.2.6" + "@girs/meta-13": "npm:^13.0.0-3.2.6" + "@girs/polkit-1.0": "npm:^1.0.0-3.2.6" + "@girs/shell-13": "npm:^13.0.0-3.2.6" + "@girs/shew-0": "npm:^0.0.0-3.2.6" + "@girs/st-13": "npm:^13.0.0-3.2.6" + "@girs/upowerglib-1.0": "npm:^0.99.1-3.2.6" + checksum: 81699023a1033457ceb78369f4e89361a4ae861cbc62059724ace1b8784ebbcda44c8378f50f5e40b3a0a8c275fa2eb4ae10b3dc4affd37976f8a45e8f0045c5 + languageName: node + linkType: hard + +"@girs/gnomebg-4.0@npm:^4.0.0-3.2.6": + version: 4.0.0-3.2.6 + resolution: "@girs/gnomebg-4.0@npm:4.0.0-3.2.6" + dependencies: + "@girs/cairo-1.0": "npm:^1.0.0-3.2.6" + "@girs/freetype2-2.0": "npm:^2.0.0-3.2.6" + "@girs/gdesktopenums-3.0": "npm:^3.0.0-3.2.6" + "@girs/gdk-4.0": "npm:^4.0.0-3.2.6" + "@girs/gdkpixbuf-2.0": "npm:^2.0.0-3.2.6" + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gmodule-2.0": "npm:^2.0.0-3.2.6" + "@girs/gnomedesktop-4.0": "npm:^4.0.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + "@girs/harfbuzz-0.0": "npm:^8.2.1-3.2.6" + "@girs/pango-1.0": "npm:^1.51.0-3.2.6" + "@girs/pangocairo-1.0": "npm:^1.0.0-3.2.6" + checksum: f761ec0d99ba96146952a9002d62f25e48be994e6d03138ce143e7e7d2d9894a6c4b1ce04e707f58c27c318bb7d161eb96da0078473aff2854d31b81cf273f74 + languageName: node + linkType: hard + +"@girs/gnomebluetooth-3.0@npm:^3.0.0-3.2.6": + version: 3.0.0-3.2.6 + resolution: "@girs/gnomebluetooth-3.0@npm:3.0.0-3.2.6" + dependencies: + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + checksum: 9c90d38c368c5e12d37096dfcf90937fcc1655ddbe9cb366b46862adb660b69b2214138d453493bc6cb086965e33e2be2f3b624e1a39e2caae3f8dde73c42e6c + languageName: node + linkType: hard + +"@girs/gnomedesktop-4.0@npm:^4.0.0-3.2.6": + version: 4.0.0-3.2.6 + resolution: "@girs/gnomedesktop-4.0@npm:4.0.0-3.2.6" + dependencies: + "@girs/gdesktopenums-3.0": "npm:^3.0.0-3.2.6" + "@girs/gdkpixbuf-2.0": "npm:^2.0.0-3.2.6" + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gmodule-2.0": "npm:^2.0.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + checksum: 3f02c08332ca319b20d26be0b8abfa6fa89d75005f9d29bb618c9fe7caa6f092a1a7c20a5055adb48a75a069ae6843fd9294945e8f0aa98abb677c619a020f08 + languageName: node + linkType: hard + "@girs/gobject-2.0@npm:^2.78.0-3.2.6": version: 2.78.0-3.2.6 resolution: "@girs/gobject-2.0@npm:2.78.0-3.2.6" @@ -559,6 +675,29 @@ __metadata: languageName: node linkType: hard +"@girs/shew-0@npm:^0.0.0-3.2.6": + version: 0.0.0-3.2.6 + resolution: "@girs/shew-0@npm:0.0.0-3.2.6" + dependencies: + "@girs/cairo-1.0": "npm:^1.0.0-3.2.6" + "@girs/freetype2-2.0": "npm:^2.0.0-3.2.6" + "@girs/gdk-4.0": "npm:^4.0.0-3.2.6" + "@girs/gdkpixbuf-2.0": "npm:^2.0.0-3.2.6" + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gmodule-2.0": "npm:^2.0.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + "@girs/graphene-1.0": "npm:^1.0.0-3.2.6" + "@girs/gsk-4.0": "npm:^4.0.0-3.2.6" + "@girs/gtk-4.0": "npm:^4.12.3-3.2.6" + "@girs/harfbuzz-0.0": "npm:^8.2.1-3.2.6" + "@girs/pango-1.0": "npm:^1.51.0-3.2.6" + "@girs/pangocairo-1.0": "npm:^1.0.0-3.2.6" + checksum: 5ccfdb4fc5bf1c1335522f6f27dbd73f11ef31f5f9b0ed41d7a292dd49f60a4c648a50f76de7e0fac7e1e8722c2e17570af2005f18c3ba1e60d66e893d4fd3aa + languageName: node + linkType: hard + "@girs/st-13@npm:^13.0.0-3.2.6": version: 13.0.0-3.2.6 resolution: "@girs/st-13@npm:13.0.0-3.2.6" @@ -591,6 +730,18 @@ __metadata: languageName: node linkType: hard +"@girs/upowerglib-1.0@npm:^0.99.1-3.2.6": + version: 0.99.1-3.2.6 + resolution: "@girs/upowerglib-1.0@npm:0.99.1-3.2.6" + dependencies: + "@girs/gio-2.0": "npm:^2.78.0-3.2.6" + "@girs/gjs": "npm:^3.2.6" + "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gobject-2.0": "npm:^2.78.0-3.2.6" + checksum: 67c80a5ed78fe8123fa29e66d2982a59f851762559f3d7c688328ae82076c08232c058d36169c29fc2f69ebaf991360a094253fceb18fe7b106f13e1d1c07221 + languageName: node + linkType: hard + "@girs/xfixes-4.0@npm:^4.0.0-3.2.6": version: 4.0.0-3.2.6 resolution: "@girs/xfixes-4.0@npm:4.0.0-3.2.6" @@ -1648,6 +1799,7 @@ __metadata: "@girs/gio-2.0": "npm:^2.78.0-3.2.6" "@girs/gjs": "npm:^3.2.6" "@girs/glib-2.0": "npm:^2.78.0-3.2.6" + "@girs/gnome-shell": "npm:^45.0.0-beta5" "@girs/gtk-4.0": "npm:^4.12.3-3.2.6" "@girs/shell-13": "npm:^13.0.0-3.2.6" "@girs/st-13": "npm:^13.0.0-3.2.6"