extensions-app: Port to ESM

The extensions app is another part of the code base that is largely
separate from the main code base, and can therefore be ported to
ESM before the big switch.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2786>
This commit is contained in:
Florian Müllner 2023-05-25 21:23:24 +02:00
parent 612e04165e
commit 80ac32a268
4 changed files with 20 additions and 9 deletions

View File

@ -5,5 +5,6 @@ overrides:
- files:
- js/ui/init.js
- js/dbusServices/**
- subprojects/extensions-app/**
parserOptions:
sourceType: module

View File

@ -1,2 +1,2 @@
#!/bin/sh
@gjs@ @pkgdatadir@/@app_id@ "$@"
@gjs@ -m @pkgdatadir@/@app_id@ "$@"

View File

@ -1,10 +1,12 @@
/* exported main */
imports.gi.versions.Adw = '1';
imports.gi.versions.Gtk = '4.0';
import Adw from 'gi://Adw?version=1';
import GLib from 'gi://GLib';
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk?version=4.0';
import Shew from 'gi://Shew';
const Gettext = imports.gettext;
import * as Gettext from 'gettext';
const Package = imports.package;
const { Adw, GLib, Gio, GObject, Gtk, Shew } = imports.gi;
Package.initFormat();
@ -540,9 +542,13 @@ function initEnvironment() {
};
}
function main(argv) {
/**
* @param {string[]} argv - command line arguments
* @returns {void}
*/
export async function main(argv) {
initEnvironment();
Package.initGettext();
new Application().run(argv);
await new Application().runAsync(argv);
}

View File

@ -1,6 +1,10 @@
imports.package.start({
import {programInvocationName, programArgs} from 'system';
imports.package.init({
name: '@PACKAGE_NAME@',
version: '@PACKAGE_VERSION@',
prefix: '@prefix@',
libdir: '@libdir@',
});
const {main} = await import(`${imports.package.moduledir}/main.js`);
await main([programInvocationName, ...programArgs]);