Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define extension system types #15

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/gnome-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@
}
},
"./ui/dnd/ambient": "./dist/ui/dnd-ambient.d.ts",
"./ui/extensionSystem": {
"import": {
"types": "./dist/ui/extensionSystem.d.ts",
"default": "./dist/ui/extensionSystem.js"
},
"require": {
"types": "./dist/ui/extensionSystem.d.ts",
"default": "./dist/ui/extensionSystem.cjs"
}
},
"./ui/extensionSystem/ambient": "./dist/ui/extensionSystem-ambient.d.ts",
"./ui/iconGrid": {
"import": {
"types": "./dist/ui/iconGrid.d.ts",
Expand Down
77 changes: 77 additions & 0 deletions packages/gnome-shell/src/ui/extensionSystem.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/extensionSystem.js

import type Gio from "@girs/gio-2.0";

import * as Signals from "../misc/signals.js";
import type { ExtensionState, ExtensionType } from "../misc/extensionUtils.js";
import type { Extension } from "../extensions/extension.js";

// This is different from the one in extension.js because it encodes the raw
// metadata loaded directly from metadata.json
interface ExtensionMetadata extends Record<string, any> {
// GNOME Shell checks these properties
readonly uuid: string;
readonly name: string;
readonly description: string;
readonly "shell-version": readonly string[];
}

export interface ExtensionObject {
readonly metadata: ExtensionMetadata;
readonly uuid: string;
readonly type: ExtensionType;
readonly dir: Gio.File;
readonly path: string | null;
readonly error: string;
readonly hasPrefs: boolean;
readonly hasUpdate: boolean;
readonly canChange: boolean;
readonly sessionModes: readonly string[];
readonly state?: ExtensionState;
readonly stateObj?: Extension;
}

export namespace ExtensionManager {
interface SignalMap {
readonly "extension-state-changed": [extension: ExtensionObject];
}

// See "OpenExtensionPrefs" in https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/data/dbus-interfaces/org.gnome.Shell.Extensions.xml
interface OpenExtensionPrefsOptions {
modal?: boolean;
}
}

export class ExtensionManager<
S extends Signals.SignalMap<S> = ExtensionManager.SignalMap
> extends Signals.EventEmitter<S> {
init(): void;

get updatesSupported(): boolean;

lookup(uuid: string): ExtensionObject;

getUuids(): readonly string[];

enableExtension(uuid: string): boolean;

disableExtension(uuid: string): boolean;

openExtensionPrefs(
uuid: string,
parentWindow: string,
options: ExtensionManager.OpenExtensionPrefsOptions
): boolean;

notifyExtensionUpdate(uuid: string): void;

logExtensionError(uuid: string, error: unknown): void;

createExtensionObject(uuid: string, dir: Gio.File, type: ExtensionType);

loadExtension(extension: ExtensionObject): Promise<void>;

unloadExtension(extension: ExtensionObject): Promise<boolean>;

reloadExtension(oldExtension: ExtensionObject): Promise<void>;
}
4 changes: 2 additions & 2 deletions packages/gnome-shell/src/ui/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AccessDialogDBus } from './accessDialog.js';
import { AudioDeviceSelectionDBus } from './audioDeviceSelection.js';
// import * as CtrlAltTab from './ctrlAltTab.js';
// import * as EndSessionDialog from './endSessionDialog.js';
// import { ExtensionManager } from './extensionSystem.js';
import { ExtensionManager } from './extensionSystem.js';
// import * as ExtensionSystem from './extensionSystem.js';
// import * as ExtensionDownloader from './extensionDownloader.js';
// import * as InputMethod from '../misc/inputMethod.js'
Expand Down Expand Up @@ -51,7 +51,7 @@ import { WindowManager } from './windowManager.js';

export declare const componentManager: ComponentManager;

export declare const extensionManager: any;
export declare const extensionManager: ExtensionManager;

export declare const panel: Panel;

Expand Down