From 0d8e0025d6688d845a8631f6bff3964b968d7c3b Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Fri, 20 Aug 2021 20:42:27 -0500 Subject: [PATCH] init: Set console log domain GJS added a console module that extensions may start using. To ensure that extensions using console.log() and similar functions don't show up as 'Gjs-Console' in users' system logs, we should call setConsoleLogdomain() with 'GNOME Shell'. This GJS API addition is only accessible using ECMAScript Modules (ESM), this commit moves shell startup to a small init.js module and adapts CI jobs to either handle or ignore it. We can drop the .jscheckignore file when future versions of SpiderMonkey allow for compile checks without validating module specifiers. Part-of: --- .eslintrc.yml | 5 +++++ .gitlab-ci.yml | 2 +- .jscheckignore | 1 + js/js-resources.gresource.xml | 1 + js/ui/init.js | 6 ++++++ po/POTFILES.skip | 1 + src/gnome-shell-plugin.c | 13 +++++-------- 7 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .jscheckignore create mode 100644 js/ui/init.js diff --git a/.eslintrc.yml b/.eslintrc.yml index 5e3347d3a..018e857f7 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,3 +1,8 @@ extends: - ./lint/eslintrc-gjs.yml - ./lint/eslintrc-shell.yml +overrides: + - files: + - js/ui/init.js + parserOptions: + sourceType: module \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97aff4027..38c3df836 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,7 +123,7 @@ js_check: - .gnome-shell.fedora:34 stage: review script: - - find js -name '*.js' -exec js78 -c '{}' ';' 2>&1 | tee $JS_LOG + - find js -name '*.js' $(printf "! -wholename %s " $(cat .jscheckignore)) -exec js78 -c '{}' ';' 2>&1 | tee $JS_LOG - (! grep -q . $JS_LOG) artifacts: paths: diff --git a/.jscheckignore b/.jscheckignore new file mode 100644 index 000000000..7313eb4af --- /dev/null +++ b/.jscheckignore @@ -0,0 +1 @@ +js/ui/init.js \ No newline at end of file diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml index 6dc01b924..93d5932f5 100644 --- a/js/js-resources.gresource.xml +++ b/js/js-resources.gresource.xml @@ -64,6 +64,7 @@ ui/ibusCandidatePopup.js ui/iconGrid.js ui/inhibitShortcutsDialog.js + ui/init.js ui/kbdA11yDialog.js ui/keyboard.js ui/layout.js diff --git a/js/ui/init.js b/js/ui/init.js new file mode 100644 index 000000000..a0fe63343 --- /dev/null +++ b/js/ui/init.js @@ -0,0 +1,6 @@ +import { setConsoleLogDomain } from 'console'; + +setConsoleLogDomain('GNOME Shell'); + +imports.ui.environment.init(); +imports.ui.main.start(); diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 4bc89ab49..0c8451d64 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,3 +1,4 @@ data/org.gnome.Shell@wayland.service.in data/org.gnome.Shell@x11.service.in +js/ui/init.js subprojects/extensions-tool/src/templates/indicator/extension.js diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c index 39af545ac..5364f043a 100644 --- a/src/gnome-shell-plugin.c +++ b/src/gnome-shell-plugin.c @@ -106,7 +106,7 @@ gnome_shell_plugin_start (MetaPlugin *plugin) { GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin); GError *error = NULL; - int status; + uint8_t status; GjsContext *gjs_context; ClutterBackend *backend; @@ -126,13 +126,10 @@ gnome_shell_plugin_start (MetaPlugin *plugin) gjs_context = _shell_global_get_gjs_context (shell_plugin->global); - if (!gjs_context_eval (gjs_context, - "imports.ui.environment.init();" - "imports.ui.main.start();", - -1, - "
", - &status, - &error)) + if (!gjs_context_eval_module_file (gjs_context, + "resource:///org/gnome/shell/ui/init.js", + &status, + &error)) { g_message ("Execution of main.js threw exception: %s", error->message); g_error_free (error);