Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
build: use types from npm. closes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
oae committed Sep 1, 2022
1 parent 5578efe commit 092983e
Show file tree
Hide file tree
Showing 21 changed files with 400 additions and 200 deletions.
16 changes: 0 additions & 16 deletions .vscode/tasks.json

This file was deleted.

99 changes: 0 additions & 99 deletions Vagrantfile

This file was deleted.

24 changes: 0 additions & 24 deletions docs.json

This file was deleted.

17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
"private": true,
"license": "MIT",
"scripts": {
"build": "yarn run lock:types && yarn run build:types && yarn run build:ts && yarn run build:extension",
"clean": "yarn run clean:ts && yarn run build:types",
"lock:types": "cross-env XDG_DATA_DIRS=$XDG_DATA_DIRS:/usr/share/gnome-shell:/usr/lib/mutter-10 yarn run gi-ts config --lock",
"build:types": "yarn run clean:types && gi-ts generate",
"clean:types": "rm -rf ./@types",
"build": "yarn run build:ts && yarn run build:extension",
"clean": "yarn run clean:ts",
"build:ts": "yarn run clean:ts && rollup -c",
"clean:ts": "rm -rf ./dist",
"build:extension": "yarn run build:schema",
Expand All @@ -34,6 +31,16 @@
"devDependencies": {
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"@gi-types/gdk4": "^4.0.1",
"@gi-types/gdkpixbuf2": "^2.0.2",
"@gi-types/gio2": "^2.72.1",
"@gi-types/glib2": "^2.72.1",
"@gi-types/gobject2": "^2.72.1",
"@gi-types/gtk4": "^4.6.1",
"@gi-types/meta10": "^10.0.1",
"@gi-types/shell0": "^0.1.1",
"@gi-types/soup2": "^2.74.1",
"@gi-types/st1": "^1.0.1",
"@gi.ts/cli": "^1.5.7",
"@gi.ts/lib": "^1.5.9",
"@gi.ts/parser": "^1.5.3",
Expand Down
20 changes: 10 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import cleanup from 'rollup-plugin-cleanup';
const buildPath = 'dist';

const globals = {
'@imports/gio2': 'imports.gi.Gio',
'@imports/gdk4': 'imports.gi.Gdk',
'@imports/gtk4': 'imports.gi.Gtk',
'@imports/gdkpixbuf2': 'imports.gi.GdkPixbuf',
'@imports/glib2': 'imports.gi.GLib',
'@imports/st1': 'imports.gi.St',
'@imports/shell0': 'imports.gi.Shell',
'@imports/meta10': 'imports.gi.Meta',
'@imports/soup2': 'imports.gi.Soup',
'@imports/gobject2': 'imports.gi.GObject',
'@gi-types/gio2': 'imports.gi.Gio',
'@gi-types/gdk4': 'imports.gi.Gdk',
'@gi-types/gtk4': 'imports.gi.Gtk',
'@gi-types/gdkpixbuf2': 'imports.gi.GdkPixbuf',
'@gi-types/glib2': 'imports.gi.GLib',
'@gi-types/st1': 'imports.gi.St',
'@gi-types/shell0': 'imports.gi.Shell',
'@gi-types/meta10': 'imports.gi.Meta',
'@gi-types/soup2': 'imports.gi.Soup',
'@gi-types/gobject2': 'imports.gi.GObject',
};

const external = Object.keys(globals);
Expand Down
6 changes: 3 additions & 3 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Gitlab } from '@esync/api/providers/gitlab';
import { Data, SyncData } from '@esync/data';
import { getCurrentExtensionSettings, notify } from '@esync/shell';
import { logger } from '@esync/utils';
import { Settings } from '@imports/gio2';
import { Settings } from '@gi-types/gio2';
import { EventEmitter } from 'events';
import { Local } from './providers/local';
import { SyncProvider, SyncEvent, SyncOperationStatus, SyncProviderType } from './types';
import { Local } from '@esync/api/providers/local';
import { SyncProvider, SyncEvent, SyncOperationStatus, SyncProviderType } from '@esync/api/types';

const debug = logger('api');

Expand Down
2 changes: 1 addition & 1 deletion src/api/providers/local.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SyncData } from '@esync/data';
import { File, FileCreateFlags } from '@imports/gio2';
import { File, FileCreateFlags } from '@gi-types/gio2';
import { SyncOperationStatus, SyncProvider } from '../types';

export class Local implements SyncProvider {
Expand Down
2 changes: 1 addition & 1 deletion src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { KeyBindingsData, KeyBindingsDataProvider } from '@esync/data/providers/
import { TweaksData, TweaksDataProvider } from '@esync/data/providers/tweaks';
import { getCurrentExtensionSettings } from '@esync/shell';
import { logger, settingsFlagsToEnumList } from '@esync/utils';
import { Settings } from '@imports/gio2';
import { Settings } from '@gi-types/gio2';

const debug = logger('data');

Expand Down
12 changes: 6 additions & 6 deletions src/data/providers/extensions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExtensionType, getCurrentExtension, readDconfData, ShellExtension } from '@esync/shell';
import { execute, logger } from '@esync/utils';
import { File } from '@imports/gio2';
import { File } from '@gi-types/gio2';
import {
build_filenamev,
ByteArray,
Expand All @@ -11,8 +11,8 @@ import {
SpawnFlags,
spawn_async,
spawn_close_pid,
} from '@imports/glib2';
import { form_encode_hash, Message, Session, Status, status_get_phrase, URI } from '@imports/soup2';
} from '@gi-types/glib2';
import { form_encode_hash, Message, Session, Status, status_get_phrase, URI } from '@gi-types/soup2';
import { parse } from 'fast-xml-parser';

const debug = logger('extension-utils');
Expand Down Expand Up @@ -145,7 +145,7 @@ export const extractExtensionArchive = (bytes: ByteArray, dir: File, callback: a

const [file, stream] = File.new_tmp('XXXXXX.shell-extension.zip');

stream.output_stream.write_bytes(bytes, null);
stream.output_stream.write_bytes(bytes as any, null);
stream.close(null);
const [success, pid] = spawn_async(
null,
Expand Down Expand Up @@ -174,7 +174,7 @@ export const extractExtensionArchive = (bytes: ByteArray, dir: File, callback: a
export const installExtension = async (extensionId: string): Promise<void> => {
return new Promise((resolve) => {
const params = { shell_version: imports.misc.config.PACKAGE_VERSION };
const soupUri = new URI(`https://extensions.gnome.org/download-extension/${extensionId}.shell-extension.zip`);
const soupUri = URI.new(`https://extensions.gnome.org/download-extension/${extensionId}.shell-extension.zip`);
soupUri.set_query(form_encode_hash(params));

const message = Message.new_from_uri('GET', soupUri);
Expand All @@ -190,7 +190,7 @@ export const installExtension = async (extensionId: string): Promise<void> => {
throw new Error(`Unexpected response: ${phrase}`);
}
const bytes = message.response_body.flatten().get_as_bytes();
extractExtensionArchive(bytes, dir, () => {
extractExtensionArchive(bytes as any, dir, () => {
const extension = getExtensionManager().createExtensionObject(extensionId, dir, ExtensionType.PER_USER);
getExtensionManager().loadExtension(extension);
if (!getExtensionManager().enableExtension(extensionId)) {
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { StatusMenu } from '@esync/panel/statusMenu';
import { loadInterfaceXML } from '@esync/shell';
import { Sync } from '@esync/sync';
import { logger } from '@esync/utils';
import { DBus, DBusExportedObject } from '@imports/gio2';
import { DBus, DBusExportedObject } from '@gi-types/gio2';
import { EventEmitter } from 'events';
import { SyncEvent } from './api/types';
import { SyncEvent } from '@esync/api/types';
import './styles/stylesheet.css';

const debug = logger('extension');
Expand Down
4 changes: 2 additions & 2 deletions src/panel/statusMenu.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SyncEvent } from '@esync/api/types';
import { getCurrentExtension, getCurrentExtensionSettings, ShellExtension } from '@esync/shell';
import { execute, logger } from '@esync/utils';
import { icon_new_for_string, Settings } from '@imports/gio2';
import { Icon } from '@imports/st1';
import { icon_new_for_string, Settings } from '@gi-types/gio2';
import { Icon } from '@gi-types/st1';
import { EventEmitter } from 'events';

const { Button } = imports.ui.panelMenu;
Expand Down
6 changes: 3 additions & 3 deletions src/prefs/otherPrefs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerClass } from '@imports/gobject2';
import { Align, Box, Label, ListBoxRow, Orientation, Switch } from '@imports/gtk4';
import { PrefsTab } from './prefsTab';
import { registerClass } from '@gi-types/gobject2';
import { Align, Box, Label, ListBoxRow, Orientation, Switch } from '@gi-types/gtk4';
import { PrefsTab } from '@esync/prefs/prefsTab';

export const OtherPrefs = registerClass(
{},
Expand Down
10 changes: 5 additions & 5 deletions src/prefs/prefs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { logger } from '@esync/utils';
import { registerClass } from '@imports/gobject2';
import { BaselinePosition, Box, Notebook, Orientation } from '@imports/gtk4';
import { OtherPrefs } from './otherPrefs';
import { ProviderPrefs } from './providerPrefs';
import { SyncedDataPrefs } from './syncedDataPrefs';
import { registerClass } from '@gi-types/gobject2';
import { BaselinePosition, Box, Notebook, Orientation } from '@gi-types/gtk4';
import { OtherPrefs } from '@esync/prefs/otherPrefs';
import { ProviderPrefs } from '@esync/prefs/providerPrefs';
import { SyncedDataPrefs } from '@esync/prefs/syncedDataPrefs';

const debug = logger('prefs');

Expand Down
6 changes: 3 additions & 3 deletions src/prefs/prefsTab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getCurrentExtension, getCurrentExtensionSettings, ShellExtension } from '@esync/shell';
import { Settings } from '@imports/gio2';
import { registerClass } from '@imports/gobject2';
import { Box, Label, Notebook } from '@imports/gtk4';
import { Settings } from '@gi-types/gio2';
import { registerClass } from '@gi-types/gobject2';
import { Box, Label, Notebook } from '@gi-types/gtk4';

export const PrefsTab = registerClass(
{},
Expand Down
22 changes: 12 additions & 10 deletions src/prefs/providerPrefs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SyncProviderType } from '@esync/api/types';
import { File, FileCreateFlags } from '@imports/gio2';
import { get_user_config_dir } from '@imports/glib2';
import { registerClass } from '@imports/gobject2';
import { File, FileCreateFlags, FilePrototype } from '@gi-types/gio2';
import { get_user_config_dir } from '@gi-types/glib2';
import { registerClass } from '@gi-types/gobject2';
import {
Align,
Box,
Expand All @@ -15,8 +15,8 @@ import {
Orientation,
ResponseType,
Window,
} from '@imports/gtk4';
import { PrefsTab } from './prefsTab';
} from '@gi-types/gtk4';
import { PrefsTab } from '@esync/prefs/prefsTab';

export const ProviderPrefs = registerClass(
{},
Expand Down Expand Up @@ -232,12 +232,14 @@ export const ProviderPrefs = registerClass(
dialog.set_transient_for(this.get_root() as any as Window);
dialog.connect('response', (_, response) => {
if (response === ResponseType.OK) {
const backupFile: File = dialog.get_file();
if (!backupFile.query_exists(null)) {
backupFile.create(FileCreateFlags.PRIVATE, null);
const backupFile: FilePrototype | null = dialog.get_file();
if (backupFile) {
if (!backupFile.query_exists(null)) {
backupFile.create(FileCreateFlags.PRIVATE, null);
}
locationButton.label = backupFile.get_uri();
this.settings.set_string('backup-file-location', backupFile.get_uri());
}
locationButton.label = backupFile.get_uri();
this.settings.set_string('backup-file-location', backupFile.get_uri());
}

dialog.destroy();
Expand Down
6 changes: 3 additions & 3 deletions src/prefs/syncedDataPrefs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DataProviderType } from '@esync/data';
import { settingsFlagsToEnumList } from '@esync/utils';
import { registerClass } from '@imports/gobject2';
import { Align, Box, Label, ListBoxRow, Orientation, Switch } from '@imports/gtk4';
import { PrefsTab } from './prefsTab';
import { registerClass } from '@gi-types/gobject2';
import { Align, Box, Label, ListBoxRow, Orientation, Switch } from '@gi-types/gtk4';
import { PrefsTab } from '@esync/prefs/prefsTab';

export const SyncedDataPrefs = registerClass(
{},
Expand Down
Loading

0 comments on commit 092983e

Please sign in to comment.