Migrate Firefox version to Manifest V3. close #201

This commit is contained in:
Folyd 2024-06-01 16:38:32 -07:00
parent 77454c042e
commit 49949736da
3 changed files with 21 additions and 28 deletions

2
core

@ -1 +1 @@
Subproject commit 5ec44508727b008c4803b9e079ce22a13b96a622
Subproject commit abb055c76fa312adda1c94f7d6b0ec3838ac5b68

View file

@ -0,0 +1 @@
<script src="service-worker.js" type="module"></script>

View file

@ -1,5 +1,6 @@
// Format: jsonnetfmt -i manifest.jsonnet
local manifest_v3 = import 'core/manifest_v3.libsonnet';
local utils = import 'core/utils.libsonnet';
local icons() = {
@ -17,8 +18,13 @@ local browser = std.extVar('browser');
local host_permissions = ['*://crates.io/api/v1/crates/*', 'https://rust.extension.sh/*'];
local optional_host_permissions = ['file:///*'];
local json = if std.member(['chrome', 'edge'], browser) then
local manifest_v3 = import 'core/manifest_v3.libsonnet';
manifest_v3.new(name, keyword, description, version, service_worker='service-worker.js', module_type=true)
manifest_v3.new(name, keyword, description, version, service_worker='service-worker.js')
else
# Firefox does not support service worker yet.
manifest_v3.new(name, keyword, description, version, background_page='firefox-bg.html')
;
json
.addWebAccessibleResources(
resources=['script/*.js', 'wasm/*.wasm', 'assets/*.svg'],
matches=[
@ -32,21 +38,7 @@ local json = if std.member(['chrome', 'edge'], browser) then
}
.addHostPermissions(host_permissions)
.addOptionalHostPermissions(optional_host_permissions)
else
local manifest_v2 = import 'core/manifest.libsonnet';
manifest_v2.new(name, keyword, description, version)
.addWebAccessibleResources(utils.js_files('script', ['lib', 'add-search-index']))
.addWebAccessibleResources(['wasm/*.wasm', 'assets/*.svg'])
.addBackgroundScripts(['settings.js', 'deminifier.js'])
.addBackgroundScripts(utils.js_files('search', ['algorithm', 'book', 'crate', 'attribute', 'caniuse', 'lint']))
.addBackgroundScripts(utils.js_files('search/docs', ['base', 'crate-doc', 'rustc']))
.addBackgroundScripts(utils.js_files('index', ['attributes', 'books', 'caniuse', 'crates', 'std-docs', 'lints', 'labels', 'rfcs', 'commands', 'rustc', 'targets']))
.addBackgroundScripts(utils.js_files('command', ['label', 'help', 'stable', 'rfc', 'rustc', 'target']))
.addBackgroundScripts(['statistics.js', 'rust-version.js', 'crate-manager.js', 'index-manager.js', 'main.js'])
.addPermissions(host_permissions)
;
json.addIcons(icons())
.addIcons(icons())
.addPermissions(['storage', 'unlimitedStorage'])
.setOptionsUi('manage/index.html')
.addContentScript(