fix: replace imports.byteArray with TextDecoder (broken on GNOME 48+)#525
Open
mayconrcmello wants to merge 1 commit intoforge-ext:mainfrom
Open
fix: replace imports.byteArray with TextDecoder (broken on GNOME 48+)#525mayconrcmello wants to merge 1 commit intoforge-ext:mainfrom
mayconrcmello wants to merge 1 commit intoforge-ext:mainfrom
Conversation
GJS removed `imports.byteArray` in 1.86 (GNOME 48). Calling
`imports.byteArray.toString(...)` from an ESM extension throws
`ReferenceError: imports is not defined` — `imports` only exists in
the legacy non-ESM module system, and Forge has been ESM since the
GNOME 45 port.
This had no immediate impact for users without a custom window
floating list (the default `config/windows.json` is shipped inside
the extension and the read path was apparently never hit during
testing), but it breaks `addFloatOverride` / `removeFloatOverride`
the moment the user toggles `Super+Shift+C` ("toggle always float")
on any window — `windowProps` reads the JSON config and then writes
it back with the new entry.
Replace both call sites with `new TextDecoder().decode(contents)`,
which is the modern equivalent. `Gio.File.load_contents()` returns a
Uint8Array on GNOME 45+, so TextDecoder accepts it directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/shared/settings.jsreads window-floating config via:GJS removed
imports.byteArrayin 1.86 (shipped with GNOME 48). Forge has been ESM since the GNOME 45 port, where the legacyimportsglobal is gone — callingimports.byteArray.toString(...)throwsReferenceError: imports is not defined.When it bites users
The default
config/windows.jsonships inside the extension dir, so the read path is rarely hit on a clean install. But everySuper+Shift+C("Toggle always float for this class") goes throughwindowPropsgetter / setter, which reads + writes that JSON. On GNOME 48+, the first toggle throws and the always-float entry never persists.Fix
Both call sites switch to
new TextDecoder().decode(contents):Gio.File.load_contents()returns aUint8Arrayon GJS 1.74+, whichTextDecoderaccepts directly.Test plan
node --check lib/shared/settings.jsSuper+Shift+Con a window persists the class to~/.config/forge/config/windows.json; subsequent windows of that class open floating.JS ERROR: ReferenceError: imports is not definedin the journal under the patched extension.