Skip to content

Commit e53e7c0

Browse files
committed
Fix dynamic import troubles, daemon init
1 parent b32bf54 commit e53e7c0

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
lines changed

src/service/components/contacts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ let EBookContacts = null;
1414
let EDataServer = null;
1515

1616
try {
17-
EBook = await import('gi://EBook');
18-
EBookContacts = await import('gi://EBookContacts');
19-
EDataServer = await import('gi://EDataServer');
17+
EBook = (await import('gi://EBook')).default;
18+
EBookContacts = (await import('gi://EBookContacts')).default;
19+
EDataServer = (await import('gi://EDataServer')).default;
2020
} catch (e) {
2121
HAVE_EDS = false;
2222
}

src/service/components/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ const Default = new Map();
1313
// Load all components using dynamic import
1414
const components = {};
1515

16-
const dir = Gio.File.new_for_uri(import.meta.url).get_parent().resolve_relative_path('components');
16+
// Promisify because prefs also imports this file
17+
Gio._promisify(Gio.File.prototype, 'enumerate_children_async');
18+
Gio._promisify(Gio.FileEnumerator.prototype, 'next_files_async');
19+
20+
const dir = Gio.File.new_for_uri(import.meta.url).get_parent();
1721
const iter = await dir.enumerate_children_async(
1822
Gio.FILE_ATTRIBUTE_STANDARD_NAME,
1923
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
@@ -24,8 +28,10 @@ iter.close_async(GLib.PRIORITY_DEFAULT, null, null);
2428

2529
for (let i = 0; i < infos.length; i++) {
2630
const info = infos[i];
27-
const name = info.get_name();
28-
components[name] = await import(`./components/${name}.js`);
31+
const name = info.get_name().replace(/\.js$/, '');
32+
if (name === 'index')
33+
continue;
34+
components[name] = await import(`./${name}.js`);
2935
}
3036

3137
/**

src/service/components/pulseaudio.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import GIRepository from 'gi://GIRepository';
66
import GLib from 'gi://GLib';
77
import GObject from 'gi://GObject';
8-
import Gvc from 'gi://Gvc';
98

109
import Config from '../../config.js';
1110

@@ -17,6 +16,8 @@ const typelibDir = GLib.build_filenamev([Config.GNOME_SHELL_LIBDIR, 'gnome-shell
1716
GIRepository.Repository.prepend_search_path(typelibDir);
1817
GIRepository.Repository.prepend_library_path(typelibDir);
1918

19+
const Gvc = (await import('gi://Gvc')).default;
20+
2021

2122
/**
2223
* Extend Gvc.MixerStream with a property for returning a user-visible name

src/service/daemon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import 'gi://Pango?version=1.0';
1515

1616
import system from 'system';
1717

18+
import './utils/setup.js';
1819
import Config from '../config.js';
1920
import Manager from './manager.js';
20-
import ServiceUI from './ui/service.js';
21-
import './utils/setup.js';
21+
import * as ServiceUI from './ui/service.js';
2222

2323

2424
/**

src/service/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ iter.close_async(GLib.PRIORITY_DEFAULT, null, null);
2929

3030
for (let i = 0; i < infos.length; i++) {
3131
const info = infos[i];
32-
const name = info.get_name();
32+
const name = info.get_name().replace(/\.js$/, '');
3333
backends[name] = await import(`./backends/${name}.js`);
3434
}
3535

src/service/plugins/contacts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Contacts from '../components/contacts.js';
1414
let EBookContacts;
1515

1616
try {
17-
EBookContacts = await import('gi://EBookContacts');
17+
EBookContacts = (await import('gi://EBookContacts')).default;
1818
} catch (e) {
1919
EBookContacts = null;
2020
}

src/service/plugins/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ iter.close_async(GLib.PRIORITY_DEFAULT, null, null);
2020

2121
for (let i = 0; i < infos.length; i++) {
2222
const info = infos[i];
23-
const name = info.get_name();
24-
if (name === 'index.js')
23+
const name = info.get_name().replace(/\.js$/, '');
24+
if (name === 'index')
2525
continue;
2626
plugins[name] = await import(`./${name}.js`);
2727
}

src/service/utils/setup.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import setup, {setupGettext} from '../../utils/setup.js';
1414

1515
// Promise Wrappers
1616
try {
17-
const EBook = await import('gi://EBook');
18-
const EDataServer = await import('gi://EDataServer');
17+
const EBook = (await import('gi://EBook')).default;
18+
const EDataServer = (await import('gi://EDataServer')).default;
1919

2020
Gio._promisify(EBook.BookClient, 'connect');
2121
Gio._promisify(EBook.BookClient.prototype, 'get_view');
@@ -60,7 +60,10 @@ Config.RUNTIMEDIR = GLib.build_filenamev([GLib.get_user_runtime_dir(), 'gsconnec
6060

6161

6262
// Bootstrap
63-
setup(Config.PACKAGE_DATADIR);
63+
const utilsFolder = GLib.path_get_dirname(GLib.filename_from_uri(import.meta.url)[0]);
64+
const serviceFolder = GLib.path_get_dirname(utilsFolder);
65+
const extensionFolder = GLib.path_get_dirname(serviceFolder);
66+
setup(extensionFolder);
6467
setupGettext();
6568

6669
if (Config.IS_USER) {

0 commit comments

Comments
 (0)