diff options
author | girst <girst@users.noreply.github.com> | 2024-03-03 12:59:18 +0100 |
---|---|---|
committer | girst <girst@users.noreply.github.com> | 2024-03-03 13:18:04 +0100 |
commit | 88413358677fd59dc360076e0a62c2c559f50e38 (patch) | |
tree | 376d89eebbd27b452bc30ff7201b46047b32612a /legacy | |
parent | 25664f0b2c3238704c7509cc661d52b6b5763599 (diff) | |
download | legacywolf-88413358677fd59dc360076e0a62c2c559f50e38.tar.gz legacywolf-88413358677fd59dc360076e0a62c2c559f50e38.zip |
port legacyfox to ecmascript modules
mozilla calls this 'esm-ification'. the last relevant to us modules were
ported in mozilla124[1], so this is our new minimum version. the old
version will likely be compatible with firefox up to version 128esr[2].
static imports are not supported in autoconfig scripts. i tried to keep
the diff as small as possible w.r.t comm-central's final JSMs. because
of this, we don't lazy-load any modules any more, nor provide any lazy
getters, as they would need to be loaded into a `lazy` object instead
the global (`this`) namespace, causing more churn. other than that, the
largest change was removing the now-useless Services.jsm workaround as
well as removing globalGetters for objects already loaded automatically.
[1]: https://hg.mozilla.org/mozilla-central/rev/68ba071ff6fb9978937496f9adc48e378957f594
[2]: bugzil.la/1881890
Diffstat (limited to 'legacy')
-rw-r--r-- | legacy/BootstrapLoader.sys.mjs (renamed from legacy/BootstrapLoader.jsm) | 21 | ||||
-rw-r--r-- | legacy/RDFDataSource.sys.mjs (renamed from legacy/RDFDataSource.jsm) | 8 | ||||
-rw-r--r-- | legacy/RDFManifestConverter.sys.mjs (renamed from legacy/RDFManifestConverter.jsm) | 5 |
3 files changed, 10 insertions, 24 deletions
diff --git a/legacy/BootstrapLoader.jsm b/legacy/BootstrapLoader.sys.mjs index a4010b3..80fc61d 100644 --- a/legacy/BootstrapLoader.jsm +++ b/legacy/BootstrapLoader.sys.mjs @@ -6,19 +6,12 @@ var EXPORTED_SYMBOLS = ["BootstrapLoader"]; -const {AddonManager} = ChromeUtils.import("resource://gre/modules/AddonManager.jsm"); -const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +import {AddonManager} from "resource://gre/modules/AddonManager.sys.mjs"; +import {AddonInternal} from "resource://gre/modules/addons/XPIDatabase.sys.mjs"; +import {InstallRDF} from "resource://legacy/RDFManifestConverter.sys.mjs"; +import {XPIProvider} from "resource://gre/modules/addons/XPIProvider.sys.mjs"; -XPCOMUtils.defineLazyModuleGetters(this, { - AddonInternal: "resource://gre/modules/addons/XPIDatabase.jsm", - InstallRDF: "resource://legacy/RDFManifestConverter.jsm", -}); -const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services; - -(ChromeUtils.defineLazyGetter||XPCOMUtils.defineLazyGetter)(this, "BOOTSTRAP_REASONS", () => { - const {XPIProvider} = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm"); - return XPIProvider.BOOTSTRAP_REASONS; -}); +const BOOTSTRAP_REASONS = XPIProvider.BOOTSTRAP_REASONS; var logger = console.createInstance({ prefix: "addons.bootstrap" }); @@ -99,7 +92,7 @@ function buildJarURI(aJarfile, aPath) { return Services.io.newURI(uri); } -var BootstrapLoader = { +export var BootstrapLoader = { name: "bootstrap", manifestFile: "install.rdf", async loadManifest(pkg) { @@ -306,7 +299,7 @@ var BootstrapLoader = { try { Object.assign(sandbox, BOOTSTRAP_REASONS); - (ChromeUtils.defineLazyGetter||XPCOMUtils.defineLazyGetter)(sandbox, "console", () => + ChromeUtils.defineLazyGetter(sandbox, "console", () => console.createInstance({ consoleID: `addon/${addon.id}` })); Services.scriptloader.loadSubScript(uri, sandbox); diff --git a/legacy/RDFDataSource.jsm b/legacy/RDFDataSource.sys.mjs index 579d075..27687ba 100644 --- a/legacy/RDFDataSource.jsm +++ b/legacy/RDFDataSource.sys.mjs @@ -134,12 +134,6 @@ const USE_RDFNS_ATTR = false; var EXPORTED_SYMBOLS = ["RDFLiteral", "RDFIntLiteral", "RDFDateLiteral", "RDFBlankNode", "RDFResource", "RDFDataSource"]; -const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser", "Element", "XMLSerializer", "fetch"]); - -const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services; - function isAttr(obj) { return obj && typeof obj == "object" && ChromeUtils.getClassName(obj) == "Attr"; } @@ -1113,7 +1107,7 @@ class RDFBlankNode extends RDFSubject { * changed as assertions are added and removed to the RDF. Pass a null document * to start with an empty graph. */ -class RDFDataSource { +export class RDFDataSource { constructor(document) { // All known resources, indexed on URI this._resources = {}; diff --git a/legacy/RDFManifestConverter.jsm b/legacy/RDFManifestConverter.sys.mjs index cb01f6a..12abd27 100644 --- a/legacy/RDFManifestConverter.jsm +++ b/legacy/RDFManifestConverter.sys.mjs @@ -5,8 +5,7 @@ var EXPORTED_SYMBOLS = ["InstallRDF"]; -ChromeUtils.defineModuleGetter(this, "RDFDataSource", - "resource://legacy/RDFDataSource.jsm"); +import {RDFDataSource} from "resource://legacy/RDFDataSource.sys.mjs"; const RDFURI_INSTALL_MANIFEST_ROOT = "urn:mozilla:install-manifest"; @@ -40,7 +39,7 @@ class Manifest { } } -class InstallRDF extends Manifest { +export class InstallRDF extends Manifest { _readProps(source, obj, props) { for (let prop of props) { let val = getProperty(source, prop); |