[gnome-shell/ewlsh/console-domain-fix] Add init.js module for new GJS module-only APIs
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/ewlsh/console-domain-fix] Add init.js module for new GJS module-only APIs
- Date: Sat, 21 Aug 2021 22:39:38 +0000 (UTC)
commit c55e146164480be2f3a0cfd468d528b64a0b7c6c
Author: Evan Welsh <contact evanwelsh com>
Date: Fri Aug 20 20:42:27 2021 -0500
Add init.js module for new GJS module-only APIs
New GJS APIs are only fully accessible using ECMAScript Modules (ESM),
this commit adds an ES module, init.js, to set GNOME Shell's log domain
using the new GJS console module. In order to do this some CI changes
are necessary. ESLint now has overrides for module source types and
a new file .jscheckignore filters which files are run through
SpiderMonkey's JS check option. Future versions of SpiderMonkey should
allow for compile checks without validating module specifiers.
.eslintrc.yml | 5 +++++
.gitignore | 2 +-
.gitlab-ci.yml | 2 +-
.jscheckignore | 1 +
js/js-resources.gresource.xml | 1 +
js/ui/init.js | 6 ++++++
src/gnome-shell-plugin.c | 13 +++++--------
7 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 5e3347d3a8..c2f3e98d34 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,3 +1,8 @@
extends:
- ./lint/eslintrc-gjs.yml
- ./lint/eslintrc-shell.yml
+overrides:
+ - files:
+ - js/init.js
+ parserOptions:
+ sourceType: module
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 396a628e51..be4efbafe8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,4 +81,4 @@ tests/run-test.sh
*~
*.patch
*.sw?
-.vscode
+.vscode
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e8c08cc1b7..05e0446ac2 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 0000000000..7313eb4af6
--- /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 6dc01b9240..93d5932f52 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -64,6 +64,7 @@
<file>ui/ibusCandidatePopup.js</file>
<file>ui/iconGrid.js</file>
<file>ui/inhibitShortcutsDialog.js</file>
+ <file>ui/init.js</file>
<file>ui/kbdA11yDialog.js</file>
<file>ui/keyboard.js</file>
<file>ui/layout.js</file>
diff --git a/js/ui/init.js b/js/ui/init.js
new file mode 100644
index 0000000000..3da17d9886
--- /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();
\ No newline at end of file
diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c
index 39af545ace..5364f043a0 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,
- "<main>",
- &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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]