From a507af3188cc2539119de9fc69509f4bc0e94a4e Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 25 Feb 2024 12:36:49 +0100 Subject: [PATCH] stop relying on AddonManager.jsm for retrieving homepageURL this was always brittle (e.g. restarting the browser with the options page open would try to access homepageURL before it was available/loaded from async). --- extension/bootstrap.coffee | 3 ++- extension/install.rdf.tmpl | 2 +- extension/lib/main.coffee | 3 --- extension/lib/options.coffee | 2 +- gulpfile.coffee | 2 ++ package.json | 1 + 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extension/bootstrap.coffee b/extension/bootstrap.coffee index 34090d0..1ca9dc6 100644 --- a/extension/bootstrap.coffee +++ b/extension/bootstrap.coffee @@ -12,6 +12,7 @@ do (global = this) -> {classes: Cc, interfaces: Ci, utils: Cu} = Components ADDON_PATH = do -> # @echo ADDON_PATH + HOMEPAGE = do -> # @echo HOMEPAGE IS_FRAME_SCRIPT = (typeof content != 'undefined') BUILD_TIME = do -> # @echo BUILD_TIME REQUIRE_DATA = do -> # @echo REQUIRE_DATA @@ -47,7 +48,7 @@ do (global = this) -> require: (path) -> require.call(null, path, moduleRoot, currentDir) module, exports: module.exports Cc, Ci, Cu, Services - ADDON_PATH, BUILD_TIME + ADDON_PATH, BUILD_TIME, HOMEPAGE IS_FRAME_SCRIPT FRAME_SCRIPT_ENVIRONMENT: if IS_FRAME_SCRIPT then global else null } diff --git a/extension/install.rdf.tmpl b/extension/install.rdf.tmpl index 5ea67c7..45e0f5f 100644 --- a/extension/install.rdf.tmpl +++ b/extension/install.rdf.tmpl @@ -6,7 +6,7 @@ VimFx VimFx{{idSuffix}}@akhodakivskiy.github.com - https://github.com/akhodakivskiy/VimFx + {{homepage}} {{version}} true true diff --git a/extension/lib/main.coffee b/extension/lib/main.coffee index 7fa9bbe..1c227cc 100644 --- a/extension/lib/main.coffee +++ b/extension/lib/main.coffee @@ -20,8 +20,6 @@ VimFx = require('./vimfx') test = require('../test/index') # @endif -{AddonManager} = ChromeUtils.import('resource://gre/modules/AddonManager.jsm') - module.exports = (data, reason) -> # Set default prefs and apply migrations as early as possible. prefs.default.init() @@ -33,7 +31,6 @@ module.exports = (data, reason) -> vimfx = new VimFx(modes, parsedOptions) vimfx.id = data.id vimfx.version = data.version - AddonManager.getAddonByID(vimfx.id).then( (info) -> vimfx.info = info ) utils.loadCss("#{ADDON_PATH}/skin/style.css") diff --git a/extension/lib/options.coffee b/extension/lib/options.coffee index e3e1de7..ae40d84 100644 --- a/extension/lib/options.coffee +++ b/extension/lib/options.coffee @@ -151,7 +151,7 @@ class Observer extends BaseObserver }) setting.id = 'header' - href = "#{@vimfx.info?.homepageURL}/tree/master/documentation#contents" + href = "#{HOMEPAGE}/tree/master/documentation#contents" docsLink = @document.createElement('a') docsLink.innerText = translate('prefs.documentation') utils.setAttributes(docsLink, { diff --git a/gulpfile.coffee b/gulpfile.coffee index d1c93c7..5b480e2 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -66,6 +66,7 @@ gulp.task('coffee', -> .pipe(preprocess({context: { BUILD_TIME ADDON_PATH: JSON.stringify(ADDON_PATH) + HOMEPAGE: JSON.stringify(pkg.homepage) REQUIRE_DATA: JSON.stringify(precompute('.'), null, 2) TESTS: if test @@ -110,6 +111,7 @@ gulp.task('install.rdf', -> .pipe(template({ idSuffix: if '--unlisted' in argv or '-u' in argv then '-unlisted' else '' version: pkg.version + homepage: pkg.homepage minVersion: pkg.firefoxVersions.min maxVersion: pkg.firefoxVersions.max creator, developers, contributors, translators diff --git a/package.json b/package.json index c1928aa..5fabbff 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "min": "68.0", "max": "*" }, + "homepage": "https://github.com/akhodakivskiy/VimFx", "license": "MIT", "private": true, "scripts": { -- 2.39.3