From 3d41f39ad9e0c165947d36bf6047cee923dfd7bd Mon Sep 17 00:00:00 2001 From: Eduard Tolosa Date: Thu, 25 Jun 2026 20:29:02 -0500 Subject: [PATCH] fix: bundle dbus.js in the pack and share logError via util.js extension.js imports ./dbus.js, but gnome-extensions pack never bundled it, so the packed extension (the EGO zip) was missing the module and would fail to load. Add dbus.js and the new util.js to the pack sources. util.js holds the shared logError helper, replacing the per-file copies in extension.js and panel.js and the raw console.error calls in clipboardItem.js. --- Makefile | 2 ++ strata@edu4rdshl.dev/extension.js | 8 +------- strata@edu4rdshl.dev/ui/clipboardItem.js | 8 +++++--- strata@edu4rdshl.dev/ui/panel.js | 8 +------- strata@edu4rdshl.dev/util.js | 11 +++++++++++ 5 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 strata@edu4rdshl.dev/util.js diff --git a/Makefile b/Makefile index 96bc59f..3ab6d3f 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,8 @@ install: schemas pack: schemas gnome-extensions pack $(EXTENSION_UUID) \ --extra-source=ui \ + --extra-source=dbus.js \ + --extra-source=util.js \ --extra-source=light.css \ --force @echo "Packed: $(EXTENSION_UUID).shell-extension.zip" diff --git a/strata@edu4rdshl.dev/extension.js b/strata@edu4rdshl.dev/extension.js index d115c12..4d4d571 100644 --- a/strata@edu4rdshl.dev/extension.js +++ b/strata@edu4rdshl.dev/extension.js @@ -13,13 +13,7 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import { StrataProxy, BUS_NAME, OBJECT_PATH } from './dbus.js'; import { StrataPanel } from './ui/panel.js'; - -function logError(label, err) { - if (err instanceof GLib.Error) - Gio.DBusError.strip_remote_error(err); - const tail = err !== undefined ? `: ${err?.message ?? err}` : ''; - console.error(`[Strata] ${label}${tail}`); -} +import { logError } from './util.js'; export default class StrataExtension extends Extension { /** @type {Gio.Subprocess | null} */ diff --git a/strata@edu4rdshl.dev/ui/clipboardItem.js b/strata@edu4rdshl.dev/ui/clipboardItem.js index 9b0fcec..76a8787 100644 --- a/strata@edu4rdshl.dev/ui/clipboardItem.js +++ b/strata@edu4rdshl.dev/ui/clipboardItem.js @@ -6,6 +6,8 @@ import St from 'gi://St'; import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; +import { logError } from '../util.js'; + const TEXT_PREVIEW_LEN = 140; const THUMB_SIZE = 48; @@ -155,18 +157,18 @@ export const ClipboardItem = GObject.registerClass({ this._thumbCache?.set(id, cachePath); applyStyle(); } catch (e) { - console.error('[Strata] Thumbnail write error:', e); + logError('Thumbnail write error', e); this._fallbackIcon(container); } } ); } catch (e) { - console.error('[Strata] Thumbnail fetch handler error:', e); + logError('Thumbnail fetch handler error', e); this._fallbackIcon(container); } }); } catch (e) { - console.error('[Strata] Thumbnail render error:', e); + logError('Thumbnail render error', e); this._fallbackIcon(container); } return container; diff --git a/strata@edu4rdshl.dev/ui/panel.js b/strata@edu4rdshl.dev/ui/panel.js index 21ffd86..dad7cc2 100644 --- a/strata@edu4rdshl.dev/ui/panel.js +++ b/strata@edu4rdshl.dev/ui/panel.js @@ -9,17 +9,11 @@ import Shell from 'gi://Shell'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import { ClipboardItem } from './clipboardItem.js'; +import { logError } from '../util.js'; const SEARCH_DEBOUNCE_MS = 150; const LOAD_MORE_THRESHOLD = 200; -function logError(label, err) { - if (err instanceof GLib.Error) - Gio.DBusError.strip_remote_error(err); - const tail = err !== undefined ? `: ${err?.message ?? err}` : ''; - console.error(`[Strata] ${label}${tail}`); -} - export class StrataPanel { constructor(proxy, settings) { this._proxy = proxy; diff --git a/strata@edu4rdshl.dev/util.js b/strata@edu4rdshl.dev/util.js new file mode 100644 index 0000000..6f85af1 --- /dev/null +++ b/strata@edu4rdshl.dev/util.js @@ -0,0 +1,11 @@ +/* util.js - shared helpers for the Strata extension. */ + +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; + +export function logError(label, err) { + if (err instanceof GLib.Error) + Gio.DBusError.strip_remote_error(err); + const tail = err !== undefined ? `: ${err?.message ?? err}` : ''; + console.error(`[Strata] ${label}${tail}`); +}