From effb7372c1e84a20679ab75e827dc2bd01ed90d2 Mon Sep 17 00:00:00 2001 From: Yi <32430186+yilozt@users.noreply.github.com> Date: Sun, 15 Oct 2023 03:17:30 +0800 Subject: [PATCH] Update alias of import modules extensionUtils.d.ts have been removed in gnome 45 --- @imports/extensions/extension.d.ts | 50 ++++++++++ @imports/extensions/prefs.d.ts | 35 +++++++ @imports/extensions/sharedInternals.d.ts | 119 +++++++++++++++++++++++ @imports/misc/extensionUtils.d.ts | 91 ----------------- @imports/ui/lookingGlass.d.ts | 5 +- @imports/ui/main.d.ts | 2 +- @imports/ui/windowManager.d.ts | 4 +- @imports/ui/windowPreview.d.ts | 7 +- @imports/ui/workspace.d.ts | 4 +- @imports/ui/workspaceAnimation.d.ts | 4 +- package.json | 2 +- tsconfig.json | 29 +++--- 12 files changed, 234 insertions(+), 118 deletions(-) create mode 100644 @imports/extensions/extension.d.ts create mode 100644 @imports/extensions/prefs.d.ts create mode 100644 @imports/extensions/sharedInternals.d.ts delete mode 100644 @imports/misc/extensionUtils.d.ts diff --git a/@imports/extensions/extension.d.ts b/@imports/extensions/extension.d.ts new file mode 100644 index 0000000..6ce49a9 --- /dev/null +++ b/@imports/extensions/extension.d.ts @@ -0,0 +1,50 @@ +// auto generate by tsc: +// tsc -d --allowJs /path/to/source/of/gnome-shell/js/extensions/* + +export class Extension extends ExtensionBase { + static lookupByUUID(uuid: any): any; + static defineTranslationFunctions(url: any): { + gettext: any; + ngettext: any; + pgettext: any; + }; + enable(): void; + disable(): void; + /** + * Open the extension's preferences window + */ + openPreferences(): void; +} +export const gettext: any; +export const ngettext: any; +export const pgettext: any; +export class InjectionManager { + /** + * @callback CreateOverrideFunc + * @param {Function?} originalMethod - the original method if it exists + * @returns {Function} - a function to be used as override + */ + /** + * Modify, replace or inject a method + * + * @param {object} prototype - the object (or prototype) that is modified + * @param {string} methodName - the name of the overwritten method + * @param {CreateOverrideFunc} createOverrideFunc - function to call to create the override + */ + overrideMethod(prototype: object, methodName: string, createOverrideFunc: (originalMethod: Function | null) => Function): void; + /** + * Restore the original method + * + * @param {object} prototype - the object (or prototype) that is modified + * @param {string} methodName - the name of the method to restore + */ + restoreMethod(prototype: object, methodName: string): void; + /** + * Restore all original methods and clear overrides + */ + clear(): void; + _saveMethod(prototype: any, methodName: any): any; + _installMethod(prototype: any, methodName: any, method: any): void; + #private; +} +import { ExtensionBase } from './sharedInternals.js'; diff --git a/@imports/extensions/prefs.d.ts b/@imports/extensions/prefs.d.ts new file mode 100644 index 0000000..f7e9231 --- /dev/null +++ b/@imports/extensions/prefs.d.ts @@ -0,0 +1,35 @@ +import * as Gtk from '@gi-types/gtk4' +import * as Adw from '@gi-types/adw1' + +// auto generate by tsc: +// tsc -d --allowJs /path/to/source/of/gnome-shell/js/extensions/* + +export class ExtensionPreferences extends ExtensionBase { + static lookupByUUID(uuid: any): any; + static defineTranslationFunctions(url: any): { + gettext: any; + ngettext: any; + pgettext: any; + }; + /** + * Get the single widget that implements + * the extension's preferences. + * + * @returns {Gtk.Widget} + */ + getPreferencesWidget(): Gtk.Widget; + /** + * Fill the preferences window with preferences. + * + * The default implementation adds the widget + * returned by getPreferencesWidget(). + * + * @param {Adw.PreferencesWindow} window - the preferences window + */ + fillPreferencesWindow(window: Adw.PreferencesWindow): void; + _wrapWidget(widget: any): any; +} +export const gettext: any; +export const ngettext: any; +export const pgettext: any; +import { ExtensionBase } from './sharedInternals.js'; diff --git a/@imports/extensions/sharedInternals.d.ts b/@imports/extensions/sharedInternals.d.ts new file mode 100644 index 0000000..77c8772 --- /dev/null +++ b/@imports/extensions/sharedInternals.d.ts @@ -0,0 +1,119 @@ +import * as Gio from '@gi-types/gio2' + +// auto generate by tsc: +// tsc -d --allowJs /path/to/source/of/gnome-shell/js/extensions/* + +export class ExtensionBase { + /** + * Look up an extension by URL (usually 'import.meta.url') + * + * @param {string} url - a file:// URL + */ + static lookupByURL(url: string): ExtensionBase; + /** + * Look up an extension by UUID + * + * @param {string} _uuid + */ + static lookupByUUID(_uuid: string): void; + /** + * @param {object} metadata - metadata passed in when loading the extension + */ + constructor(metadata: object); + metadata: any; + /** + * @type {string} + */ + get uuid(): string; + /** + * @type {Gio.File} + */ + get dir(): Gio.File; + /** + * @type {string} + */ + get path(): string; + /** + * Get a GSettings object for schema, using schema files in + * extensionsdir/schemas. If schema is omitted, it is taken + * from metadata['settings-schema']. + * + * @param {string=} schema - the GSettings schema id + * + * @returns {Gio.Settings} + */ + getSettings(schema?: string | undefined): Gio.Settings; + /** + * Initialize Gettext to load translations from extensionsdir/locale. If + * domain is not provided, it will be taken from metadata['gettext-domain'] + * if provided, or use the UUID + * + * @param {string=} domain - the gettext domain to use + */ + initTranslations(domain?: string | undefined): void; + /** + * Translate `str` using the extension's gettext domain + * + * @param {string} str - the string to translate + * + * @returns {string} the translated string + */ + gettext(str: string): string; + /** + * Translate `str` and choose plural form using the extension's + * gettext domain + * + * @param {string} str - the string to translate + * @param {string} strPlural - the plural form of the string + * @param {number} n - the quantity for which translation is needed + * + * @returns {string} the translated string + */ + ngettext(str: string, strPlural: string, n: number): string; + /** + * Translate `str` in the context of `context` using the extension's + * gettext domain + * + * @param {string} context - context to disambiguate `str` + * @param {string} str - the string to translate + * + * @returns {string} the translated string + */ + pgettext(context: string, str: string): string; + #private; +} +export class GettextWrapper { + constructor(extensionClass: any, url: any); + defineTranslationFunctions(): { + /** + * Translate `str` using the extension's gettext domain + * + * @param {string} str - the string to translate + * + * @returns {string} the translated string + */ + gettext: any; + /** + * Translate `str` and choose plural form using the extension's + * gettext domain + * + * @param {string} str - the string to translate + * @param {string} strPlural - the plural form of the string + * @param {number} n - the quantity for which translation is needed + * + * @returns {string} the translated string + */ + ngettext: any; + /** + * Translate `str` in the context of `context` using the extension's + * gettext domain + * + * @param {string} context - context to disambiguate `str` + * @param {string} str - the string to translate + * + * @returns {string} the translated string + */ + pgettext: any; + }; + #private; +} diff --git a/@imports/misc/extensionUtils.d.ts b/@imports/misc/extensionUtils.d.ts deleted file mode 100644 index 59272a9..0000000 --- a/@imports/misc/extensionUtils.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -import * as Gio from '@gi/Gio' - -/** - * getCurrentExtension: - * - * @returns {?object} - The current extension, or null if not called from - * an extension. - */ -declare function getCurrentExtension(): { uuid: string, path:string }; -/** - * initTranslations: - * @param {string=} domain - the gettext domain to use - * - * Initialize Gettext to load translations from extensionsdir/locale. - * If @domain is not provided, it will be taken from metadata['gettext-domain'] - */ -declare function initTranslations(domain?: string | undefined): void; -/** - * gettext: - * @param {string} str - the string to translate - * - * Translate @str using the extension's gettext domain - * - * @returns {string} - the translated string - * - */ -declare function gettext(str: string): string; -/** - * ngettext: - * @param {string} str - the string to translate - * @param {string} strPlural - the plural form of the string - * @param {number} n - the quantity for which translation is needed - * - * Translate @str and choose plural form using the extension's - * gettext domain - * - * @returns {string} - the translated string - * - */ -declare function ngettext(str: string, strPlural: string, n: number): string; -/** - * pgettext: - * @param {string} context - context to disambiguate @str - * @param {string} str - the string to translate - * - * Translate @str in the context of @context using the extension's - * gettext domain - * - * @returns {string} - the translated string - * - */ -declare function pgettext(context: string, str: string): string; -declare function callExtensionGettextFunc(func: any, ...args: any[]): any; -/** - * getSettings: - * @param {string=} schema - the GSettings schema id - * @returns {Gio.Settings} - a new settings object for @schema - * - * Builds and returns a GSettings schema for @schema, using schema files - * in extensionsdir/schemas. If @schema is omitted, it is taken from - * metadata['settings-schema']. - */ -declare function getSettings(schema?: string | undefined): Gio.Settings; -/** - * openPrefs: - * - * Open the preference dialog of the current extension - */ -declare function openPrefs(): Promise; -declare function isOutOfDate(extension: any): boolean; -declare function serializeExtension(extension: any): {}; -declare function deserializeExtension(variant: any): { - metadata: {}; -}; -declare function installImporter(extension: any): void; -declare const Gettext: any; -declare const Config: any; -declare namespace ExtensionType { - const SYSTEM: number; - const PER_USER: number; -} -declare namespace ExtensionState { - const ENABLED: number; - const DISABLED: number; - const ERROR: number; - const OUT_OF_DATE: number; - const DOWNLOADING: number; - const INITIALIZED: number; - const UNINSTALLED: number; -} -declare const SERIALIZED_PROPERTIES: string[]; diff --git a/@imports/ui/lookingGlass.d.ts b/@imports/ui/lookingGlass.d.ts index 19944d1..e820999 100644 --- a/@imports/ui/lookingGlass.d.ts +++ b/@imports/ui/lookingGlass.d.ts @@ -1,6 +1,7 @@ -import * as St from '@gi/St' -import * as Clutter from '@gi/Clutter' +import * as St from 'gi://St' +import * as Clutter from 'gi://Clutter' export class Inspector extends Clutter.Actor { + constructor(looking_glass: any) connect(signal: 'closed', cb: any); open(); connect(signal: 'target', cb: (me: Inspector, target: Clutter.Actor, stageX: number, stageY: number) => void); diff --git a/@imports/ui/main.d.ts b/@imports/ui/main.d.ts index aa91a3d..b738707 100644 --- a/@imports/ui/main.d.ts +++ b/@imports/ui/main.d.ts @@ -1,5 +1,5 @@ import { LookingGlass } from "./lookingGlass"; -import * as GObject from '@gi/GObject' +import * as GObject from 'gi://GObject' export const createLookingGlass: () => LookingGlass; diff --git a/@imports/ui/windowManager.d.ts b/@imports/ui/windowManager.d.ts index 5fb2400..e82bb95 100644 --- a/@imports/ui/windowManager.d.ts +++ b/@imports/ui/windowManager.d.ts @@ -1,5 +1,5 @@ -import { WindowActor } from '@gi/Meta'; -import { WM } from '@gi/Shell' +import { WindowActor } from 'gi://Meta'; +import { WM } from 'gi://Shell' declare function getWindowDimmer(actor: any): any; diff --git a/@imports/ui/windowPreview.d.ts b/@imports/ui/windowPreview.d.ts index a9fb67f..9d7fe69 100644 --- a/@imports/ui/windowPreview.d.ts +++ b/@imports/ui/windowPreview.d.ts @@ -1,7 +1,8 @@ -import * as Shell from '@gi/Shell' -import * as Meta from '@gi/Meta' +import * as Shell from 'gi://Shell' +import * as Meta from 'gi://Meta' -export class WindowPreview extends Shell.WindowPreview { +export class WindowPreview extends Shell.WindowPreview { + [x: string]: any _addWindow (_: Meta.Window): void; _windowActor: Meta.WindowActor } diff --git a/@imports/ui/workspace.d.ts b/@imports/ui/workspace.d.ts index 0f3ad25..7d5ddc6 100644 --- a/@imports/ui/workspace.d.ts +++ b/@imports/ui/workspace.d.ts @@ -1,6 +1,6 @@ -import { Window } from '@gi/Meta' +import { Window } from 'gi://Meta' import { WindowPreview } from './windowPreview' -import { Actor } from '@gi/Clutter'; +import { Actor } from 'gi://Clutter'; export class Workspace extends Actor { _addWindowClone(metaWindow: Window): WindowPreview; diff --git a/@imports/ui/workspaceAnimation.d.ts b/@imports/ui/workspaceAnimation.d.ts index c3ed334..5d853af 100644 --- a/@imports/ui/workspaceAnimation.d.ts +++ b/@imports/ui/workspaceAnimation.d.ts @@ -1,5 +1,5 @@ -import { Window, WindowActor } from '@gi/Meta' -import { Actor, Clone } from '@gi/Clutter' +import { Window, WindowActor } from 'gi://Meta' +import { Actor, Clone } from 'gi://Clutter' export class WorkspaceAnimationController { _movingWindow: Window; diff --git a/package.json b/package.json index b3906fb..1d981d4 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "license": "GPL-3.0-or-later", "main": "src/extension.ts", "devDependencies": { + "@gi-types/adw1": "^1.1.1", "@gi-types/gtk4": "^4.6.1", "@gi-types/meta10": "^10.0.1", "@gi-types/shell0": "^0.1.1", @@ -18,7 +19,6 @@ "gulp-cli": "^2.3.0", "gulp-eslint-new": "^1.5.1", "gulp-fill-pot-po": "^2.0.2", - "gulp-potomo": "^1.1.0", "gulp-preserve-typescript-whitespace": "^1.0.3", "gulp-prettier": "^4.0.0", "gulp-rename": "^2.0.0", diff --git a/tsconfig.json b/tsconfig.json index 106c7f9..bc46c19 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compileOnSave": true, "compilerOptions": { "target": "ES2020", - "module": "es2020", + "module": "ES2020", "sourceMap": false, "strict": true, "pretty": false, @@ -11,20 +11,21 @@ "baseUrl": ".", "moduleResolution": "node", "paths": { - "@imports/*": ["@imports/*"], + "resource:///org/gnome/shell/*": ["@imports/*"], + "resource:///org/gnome/Shell/Extensions/js/*": ["@imports/*"], "@global": ["src/global.d.ts"], - "@me/*": ["src/*"], - "@gi/Gio": ["node_modules/@gi-types/gio2"], - "@gi/Gtk": ["node_modules/@gi-types/gtk4"], - "@gi/Gdk": ["node_modules/@gi-types/gdk4"], - "@gi/GLib": ["node_modules/@gi-types/glib2"], - "@gi/Meta": ["node_modules/@gi-types/meta10"], - "@gi/Clutter":["node_modules/@gi-types/clutter10"], - "@gi/Cogl": ["node_modules/@gi-types/cogl10"], - "@gi/GObject":["node_modules/@gi-types/gobject2"], - "@gi/Shell": ["node_modules/@gi-types/shell0"], - "@gi/St": ["node_modules/@gi-types/st1"], - "@gi/Graphene": ["node_modules/@gi-types/graphene1"] + "gi://Adw": ["node_modules/@gi-types/adw1"], + "gi://Gio": ["node_modules/@gi-types/gio2"], + "gi://Gtk": ["node_modules/@gi-types/gtk4"], + "gi://Gdk": ["node_modules/@gi-types/gdk4"], + "gi://GLib": ["node_modules/@gi-types/glib2"], + "gi://Meta": ["node_modules/@gi-types/meta10"], + "gi://Clutter":["node_modules/@gi-types/clutter10"], + "gi://Cogl": ["node_modules/@gi-types/cogl10"], + "gi://GObject":["node_modules/@gi-types/gobject2"], + "gi://Shell": ["node_modules/@gi-types/shell0"], + "gi://St": ["node_modules/@gi-types/st1"], + "gi://Graphene": ["node_modules/@gi-types/graphene1"] }, "outDir": "./_build/" },