aboutsummaryrefslogtreecommitdiff
path: root/modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-06-06 18:50:40 +0530
committerAkshay Nair <phenax5@gmail.com>2026-06-06 18:50:40 +0530
commita7214b76e3f3a01f8ec6a6f8a9fe49e67765a3c5 (patch)
treef6f26a429d8a27b5623024963fbebdcc8d0881f6 /modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs
parent210d4bf063d10a723f66029c2a12610e479d172c (diff)
downloadnixos-config-main.tar.gz
nixos-config-main.zip
Changes to firefox configHEADmain
Diffstat (limited to 'modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs')
-rw-r--r--modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs99
1 files changed, 0 insertions, 99 deletions
diff --git a/modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs b/modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs
deleted file mode 100644
index 25cae7e..0000000
--- a/modules/firefox.home/chrome/utils/RDFManifestConverter.sys.mjs
+++ /dev/null
@@ -1,99 +0,0 @@
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-import { RDFDataSource } from "chrome://userchromejs/content/RDFDataSource.sys.mjs";
-
-const RDFURI_INSTALL_MANIFEST_ROOT = "urn:mozilla:install-manifest";
-
-function EM_R(aProperty) {
- return `http://www.mozilla.org/2004/em-rdf#${aProperty}`;
-}
-
-function getValue(literal) {
- return literal && literal.getValue();
-}
-
-function getProperty(resource, property) {
- return getValue(resource.getProperty(EM_R(property)));
-}
-
-class Manifest {
- constructor(ds) {
- this.ds = ds;
- }
-
- static loadFromString(text) {
- return new this(RDFDataSource.loadFromString(text));
- }
-}
-
-export class InstallRDF extends Manifest {
- _readProps(source, obj, props) {
- for (let prop of props) {
- let val = getProperty(source, prop);
- if (val != null) {
- obj[prop] = val;
- }
- }
- }
-
- _readArrayProp(source, obj, prop, target, decode = getValue) {
- let result = Array.from(source.getObjects(EM_R(prop)),
- target => decode(target));
- if (result.length) {
- obj[target] = result;
- }
- }
-
- _readArrayProps(source, obj, props, decode = getValue) {
- for (let [prop, target] of Object.entries(props)) {
- this._readArrayProp(source, obj, prop, target, decode);
- }
- }
-
- _readLocaleStrings(source, obj) {
- this._readProps(source, obj, ["name", "description", "creator", "homepageURL"]);
- this._readArrayProps(source, obj, {
- locale: "locales",
- developer: "developers",
- translator: "translators",
- contributor: "contributors",
- });
- }
-
- decode() {
- let root = this.ds.getResource(RDFURI_INSTALL_MANIFEST_ROOT);
- let result = {};
-
- let props = ["id", "version", "type", "updateURL", "optionsURL",
- "optionsType", "aboutURL", "iconURL",
- "bootstrap", "unpack", "strictCompatibility"];
- this._readProps(root, result, props);
-
- let decodeTargetApplication = source => {
- let app = {};
- this._readProps(source, app, ["id", "minVersion", "maxVersion"]);
- return app;
- };
-
- let decodeLocale = source => {
- let localized = {};
- this._readLocaleStrings(source, localized);
- return localized;
- };
-
- this._readLocaleStrings(root, result);
-
- this._readArrayProps(root, result, {"targetPlatform": "targetPlatforms"});
- this._readArrayProps(root, result, {"targetApplication": "targetApplications"},
- decodeTargetApplication);
- this._readArrayProps(root, result, {"localized": "localized"},
- decodeLocale);
- this._readArrayProps(root, result, {"dependency": "dependencies"},
- source => getProperty(source, "id"));
-
- return result;
- }
-} \ No newline at end of file