From 393d9df3759a3b6f35b55a6a0a4cab399ce4f5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 2 Jun 2023 00:47:22 +0200 Subject: [PATCH] extensions-tool: Adjust templates Extensions are now loaded as modules, so adjust the templates accordingly. Part-of: --- .eslintrc.yml | 1 + .../src/templates/indicator/extension.js | 16 +++++----------- .../src/templates/plain/extension.js | 8 +------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 4e857e0e0..9289caa25 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -7,5 +7,6 @@ overrides: - js/dbusServices/** - js/portalHelper/** - subprojects/extensions-app/** + - subprojects/extensions-tool/** parserOptions: sourceType: module diff --git a/subprojects/extensions-tool/src/templates/indicator/extension.js b/subprojects/extensions-tool/src/templates/indicator/extension.js index 2f6684be1..35784d846 100644 --- a/subprojects/extensions-tool/src/templates/indicator/extension.js +++ b/subprojects/extensions-tool/src/templates/indicator/extension.js @@ -16,12 +16,10 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -/* exported init */ - const GETTEXT_DOMAIN = 'my-indicator-extension'; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import GObject from 'gi://GObject'; +import St from 'gi://St'; const ExtensionUtils = imports.misc.extensionUtils; const Main = imports.ui.main; @@ -48,9 +46,9 @@ class Indicator extends PanelMenu.Button { } }); -class Extension { - constructor(uuid) { - this._uuid = uuid; +export default class Extension { + constructor(metadata) { + this._uuid = metadata.uuid; ExtensionUtils.initTranslations(GETTEXT_DOMAIN); } @@ -65,7 +63,3 @@ class Extension { this._indicator = null; } } - -function init(meta) { - return new Extension(meta.uuid); -} diff --git a/subprojects/extensions-tool/src/templates/plain/extension.js b/subprojects/extensions-tool/src/templates/plain/extension.js index 64857afb7..5abdf6792 100644 --- a/subprojects/extensions-tool/src/templates/plain/extension.js +++ b/subprojects/extensions-tool/src/templates/plain/extension.js @@ -16,9 +16,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -/* exported init */ - -class Extension { +export default class Extension { constructor() { } @@ -28,7 +26,3 @@ class Extension { disable() { } } - -function init() { - return new Extension(); -}