cleanup: Replace non-standard ByteArray module
gjs landed support for TextDecoder/TextEncoder. Use those instead of gjs' own ByteArray module. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1946>
This commit is contained in:
parent
b21b43e318
commit
ef70364e81
@ -31,7 +31,7 @@ variables:
|
||||
LINT_LOG: "eslint-report.xml"
|
||||
LINT_MR_LOG: "eslint-mr-report.xml"
|
||||
|
||||
image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-08-01.0
|
||||
image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-08-25.0
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
|
@ -86,7 +86,7 @@ function loadInterfaceXML(iface) {
|
||||
|
||||
try {
|
||||
let [ok_, bytes] = f.load_contents(null);
|
||||
return imports.byteArray.toString(bytes);
|
||||
return new TextDecoder().decode(bytes);
|
||||
} catch (e) {
|
||||
log(`Failed to load D-Bus interface ${iface}`);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
/* exported Component */
|
||||
|
||||
const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
|
||||
const ByteArray = imports.byteArray;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const Dialog = imports.ui.dialog;
|
||||
@ -498,7 +497,8 @@ var VPNRequestHandler = class {
|
||||
return;
|
||||
}
|
||||
|
||||
this._vpnChildProcessLineOldStyle(ByteArray.toString(line));
|
||||
const decoder = new TextDecoder();
|
||||
this._vpnChildProcessLineOldStyle(decoder.decode(line));
|
||||
|
||||
// try to read more!
|
||||
this._readStdoutOldStyle();
|
||||
@ -527,7 +527,7 @@ var VPNRequestHandler = class {
|
||||
let contentOverride;
|
||||
|
||||
try {
|
||||
data = ByteArray.toGBytes(this._dataStdout.peek_buffer());
|
||||
data = new GLib.Bytes(this._dataStdout.peek_buffer());
|
||||
keyfile.load_from_bytes(data, GLib.KeyFileFlags.NONE);
|
||||
|
||||
if (keyfile.get_integer(VPN_UI_GROUP, 'Version') != 2)
|
||||
|
@ -86,8 +86,6 @@ function _patchLayoutClass(layoutClass, styleProps) {
|
||||
* @returns {void}
|
||||
*/
|
||||
function _injectSoup3Compat(Soup) {
|
||||
const ByteArray = imports.byteArray;
|
||||
|
||||
Soup.StatusCode = Soup.KnownStatusCode;
|
||||
|
||||
Soup.Message.new_from_encoded_form =
|
||||
@ -101,7 +99,7 @@ function _injectSoup3Compat(Soup) {
|
||||
this.set_request(
|
||||
contentType,
|
||||
Soup.MemoryUse.COPY,
|
||||
ByteArray.toString(bytes.get_data()));
|
||||
new TextDecoder().decode(bytes.get_data()));
|
||||
};
|
||||
|
||||
Soup.Session.prototype.send_and_read_async =
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
const { Clutter, Gio, GLib, GObject, Soup } = imports.gi;
|
||||
|
||||
const ByteArray = imports.byteArray;
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const Dialog = imports.ui.dialog;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
@ -49,7 +47,8 @@ async function installExtension(uuid, invocation) {
|
||||
GLib.PRIORITY_DEFAULT,
|
||||
null);
|
||||
checkResponse(message);
|
||||
info = JSON.parse(ByteArray.toString(bytes.get_data()));
|
||||
const decoder = new TextDecoder();
|
||||
info = JSON.parse(decoder.decode(bytes.get_data()));
|
||||
} catch (e) {
|
||||
Main.extensionManager.logExtensionError(uuid, e);
|
||||
invocation.return_dbus_error(
|
||||
@ -181,8 +180,7 @@ async function checkForUpdates() {
|
||||
shell_version: Config.PACKAGE_VERSION,
|
||||
disable_version_validation: versionCheck.toString(),
|
||||
};
|
||||
const requestBody = new GLib.Bytes(
|
||||
ByteArray.fromString(JSON.stringify(metadatas)));
|
||||
const requestBody = new GLib.Bytes(JSON.stringify(metadatas));
|
||||
|
||||
const message = Soup.Message.new('POST',
|
||||
'%s?%s'.format(REPOSITORY_URL_UPDATE, Soup.form_encode_hash(params)));
|
||||
@ -195,7 +193,7 @@ async function checkForUpdates() {
|
||||
GLib.PRIORITY_DEFAULT,
|
||||
null);
|
||||
checkResponse(message);
|
||||
json = ByteArray.toString(bytes.get_data());
|
||||
json = new TextDecoder().decode(bytes.get_data());
|
||||
} catch (e) {
|
||||
log('Update check failed: %s'.format(e.message));
|
||||
return;
|
||||
|
@ -2,7 +2,6 @@
|
||||
/* exported init connect disconnect */
|
||||
|
||||
const { GLib, Gio, GObject, Shell, St } = imports.gi;
|
||||
const ByteArray = imports.byteArray;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const ExtensionDownloader = imports.ui.extensionDownloader;
|
||||
@ -285,7 +284,7 @@ var ExtensionManager = class {
|
||||
let metadataContents, success_;
|
||||
try {
|
||||
[success_, metadataContents] = metadataFile.load_contents(null);
|
||||
metadataContents = ByteArray.toString(metadataContents);
|
||||
metadataContents = new TextDecoder().decode(metadataContents);
|
||||
} catch (e) {
|
||||
throw new Error('Failed to load metadata.json: %s'.format(e.toString()));
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
/* exported KeyboardManager */
|
||||
|
||||
const { Clutter, Gio, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
|
||||
const ByteArray = imports.byteArray;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const EdgeDragAction = imports.ui.edgeDragAction;
|
||||
@ -536,9 +535,9 @@ var KeyboardModel = class {
|
||||
_loadModel(groupName) {
|
||||
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
|
||||
let [success_, contents] = file.load_contents(null);
|
||||
contents = ByteArray.toString(contents);
|
||||
|
||||
return JSON.parse(contents);
|
||||
const decoder = new TextDecoder();
|
||||
return JSON.parse(decoder.decode(contents));
|
||||
}
|
||||
|
||||
getLevels() {
|
||||
@ -1039,9 +1038,7 @@ var EmojiSelection = GObject.registerClass({
|
||||
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/emoji.json');
|
||||
let [success_, contents] = file.load_contents(null);
|
||||
|
||||
if (contents instanceof Uint8Array)
|
||||
contents = imports.byteArray.toString(contents);
|
||||
let emoji = JSON.parse(contents);
|
||||
let emoji = JSON.parse(new TextDecoder().decode(contents));
|
||||
|
||||
let variants = [];
|
||||
let currentKey = 0;
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
const { Atk, Clutter, GDesktopEnums, Gio,
|
||||
GLib, GObject, Gtk, Meta, Pango, Rsvg, St } = imports.gi;
|
||||
const ByteArray = imports.byteArray;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const Main = imports.ui.main;
|
||||
@ -298,10 +297,9 @@ var PadDiagram = GObject.registerClass({
|
||||
_init(params) {
|
||||
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
|
||||
let [success_, css] = file.load_contents(null);
|
||||
css = ByteArray.toString(css);
|
||||
this._curEdited = null;
|
||||
this._prevEdited = null;
|
||||
this._css = css;
|
||||
this._css = new TextDecoder().decode(css);
|
||||
this._labels = [];
|
||||
this._activeButtons = [];
|
||||
super._init(params);
|
||||
|
@ -1,7 +1,6 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported SessionMode, listModes */
|
||||
|
||||
const ByteArray = imports.byteArray;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Signals = imports.signals;
|
||||
|
||||
@ -110,8 +109,8 @@ function _loadMode(file, info) {
|
||||
let fileContent, success_, newMode;
|
||||
try {
|
||||
[success_, fileContent] = file.load_contents(null);
|
||||
fileContent = ByteArray.toString(fileContent);
|
||||
newMode = JSON.parse(fileContent);
|
||||
const decoder = new TextDecoder();
|
||||
newMode = JSON.parse(decoder.decode(fileContent));
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ eds_req = '>= 3.33.1'
|
||||
gcr_req = '>= 3.7.5'
|
||||
gio_req = '>= 2.56.0'
|
||||
gi_req = '>= 1.49.1'
|
||||
gjs_req = '>= 1.68.1'
|
||||
gjs_req = '>= 1.69.2'
|
||||
gtk_req = '>= 3.15.0'
|
||||
mutter_req = '>= 41.beta'
|
||||
polkit_req = '>= 0.100'
|
||||
|
@ -24,7 +24,7 @@ function loadInterfaceXML(iface) {
|
||||
|
||||
try {
|
||||
let [ok_, bytes] = f.load_contents(null);
|
||||
return imports.byteArray.toString(bytes);
|
||||
return new TextDecoder().decode(bytes);
|
||||
} catch (e) {
|
||||
log('Failed to load D-Bus interface %s'.format(iface));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user