Skip to content

Commit

Permalink
Bridge ES/legacy modules with .mjs re-export files
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Sep 17, 2023
1 parent daa4960 commit 728e137
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
12 changes: 12 additions & 0 deletions src/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: GSConnect Developers https://github.com/GSConnect
//
// SPDX-License-Identifier: GPL-2.0-or-later

import GLib from 'gi://GLib';

const [filename] = GLib.filename_from_uri(import.meta.url);
const dirname = GLib.path_get_dirname(filename);
imports.searchPath.unshift(dirname);

const Config = imports.config;
export default Config;
10 changes: 2 additions & 8 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later

import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';

import * as Main from 'resource:///org/gnome/shell/ui/main.js';
Expand All @@ -19,18 +18,13 @@ import {
import * as Utils from './shell/utils.js';

// eslint-disable-next-line no-redeclare
import Config from './config.mjs';
import * as Clipboard from './shell/clipboard.js';
import * as Device from './shell/device.js';
import * as Keybindings from './shell/keybindings.js';
import * as Notification from './shell/notification.js';
import * as Input from './shell/input.js';

// Enable legacy import support
const [filename] = GLib.filename_from_uri(import.meta.url);
const dirname = GLib.path_get_dirname(filename);
imports.searchPath.unshift(dirname);
const Config = imports.config;
const Remote = imports.utils.remote;
import Remote from './utils/remote.mjs';

const QuickSettingsMenu = Main.panel.statusArea.quickSettings;

Expand Down
7 changes: 1 addition & 6 deletions src/shell/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later

import Gio from 'gi://Gio';
import GLib from 'gi://GLib';

// Enable legacy import support
const [filename] = GLib.filename_from_uri(import.meta.url);
const dirname = GLib.path_get_dirname(GLib.path_get_dirname(filename));
imports.searchPath.unshift(dirname);
const Config = imports.config;
import Config from '../config.mjs';

export class LockscreenRemoteAccess {

Expand Down
8 changes: 2 additions & 6 deletions src/shell/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Gtk from 'gi://Gtk';

import Config from '../config.mjs';

let St = null; // St is not available for prefs.js importing this file.
try {
St = (await import('gi://St')).default;
} catch (e) { }

// Enable legacy import support
const [filename] = GLib.filename_from_uri(import.meta.url);
const dirname = GLib.path_get_dirname(GLib.path_get_dirname(filename));
imports.searchPath.unshift(dirname);
const Config = imports.config;


/**
* Initialise and setup Config, GResources and GSchema.
Expand Down
12 changes: 12 additions & 0 deletions src/utils/remote.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: GSConnect Developers https://github.com/GSConnect
//
// SPDX-License-Identifier: GPL-2.0-or-later

import GLib from 'gi://GLib';

const [filename] = GLib.filename_from_uri(import.meta.url);
const dirname = GLib.path_get_dirname(filename);
imports.searchPath.unshift(dirname);

const Remote = imports.remote;
export default Remote;

0 comments on commit 728e137

Please sign in to comment.