-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwxt.config.ts
More file actions
109 lines (104 loc) · 4.03 KB
/
Copy pathwxt.config.ts
File metadata and controls
109 lines (104 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { defineConfig } from "wxt"
const generatedSourcePackageExcludes = [
"bench-results/**",
"bench-opt-results/**",
"bench-live-results/**",
"bench-live-results-test/**",
"data/bench-results/**",
"data/bench-opt-results/**",
"data/bench-live-results/**",
"data/bench-live-results-test/**",
]
/**
* Build profiles:
* - chromium-full: Chrome/Edge full-feature build (default)
* - chromium-compat: Conservative build for 360/QQ/Sogou/2345/mobile Chromium
* - safari: Safari/iOS
* - firefox: Firefox/AMO
*
* Set ASTRA_BROWSER_CHANNEL=compat to produce a conservative Chromium build.
*/
const isCompatChannel = process.env.ASTRA_BROWSER_CHANNEL === "compat"
const CHROMIUM_EXTENSION_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxRUh12SsWFI/aepeIXfNLi7Co5E0xlfxgOcRRA2ehhX8TiM8OV3mgJT+BjBpNSHvtYpBVzBomOg9eCbb/Q3BxxNOThaJrByGK95ajL7KKLWTsMK4XMbQXjHyQZEeC+25tAEyWsbVsH/CmXSNGMoHABVwU05qBCzkudjsyGdJjVBE23GaZzkBRV91nZm61DB3ZR5wLicMQrrDNPApVsk0/ha2oFmqMHPTZYfNssNUzf6k/8AujOLpm1PZUNrS32W52AtKZVNVUUHqUoevrvyRP+yGgJnnhXPvINtslh2CCYb6BLWlzDNMtW3ii643q7r/CWCOboAn5+Wkz/66Yt0cVwIDAQAB"
// https://wxt.dev/api/config.html
export default defineConfig({
srcDir: "src",
imports: false,
modules: ["@wxt-dev/module-react"],
manifestVersion: 3,
zip: {
// Keep generated benchmark/browser profiles out of WXT source packages so
// local sockets under data/bench-live-results/_extension-profile-* cannot
// break store packaging.
excludeSources: generatedSourcePackageExcludes,
},
manifest: ({ browser }) => {
// Base permissions available in all builds
const permissions: string[] = ["storage", "tabs", "activeTab"]
// Full Chromium builds get additional API permissions
if (!isCompatChannel) {
permissions.push("webNavigation", "contextMenus", "alarms")
}
return {
name: "__MSG_extName__",
description: "__MSG_extDescription__",
default_locale: "zh_CN",
...(browser !== "firefox" && browser !== "safari" && {
key: CHROMIUM_EXTENSION_PUBLIC_KEY,
}),
// Use options_ui for broader Chromium-family compatibility
options_ui: {
page: "options.html",
open_in_tab: true,
},
permissions,
host_permissions: ["*://*/*"],
// Runtime controls can request/revoke narrower host grants where the browser supports
// optional host permissions. Broad host access remains declared for this build and is
// still disclosed truthfully in onboarding/popup copy.
optional_host_permissions: ["http://*/*", "https://*/*"],
// Omnibox integration only in full builds (compat builds may not support omnibox API)
...(!isCompatChannel && {
omnibox: { keyword: "astra" },
}),
// Keyboard shortcuts only in full builds (compat builds may not support commands API)
...(!isCompatChannel && {
commands: {
toggleTranslate: {
suggested_key: { default: "Alt+A", mac: "Alt+A" },
description: "Toggle page translation",
},
translatePage: {
suggested_key: { default: "Alt+W", mac: "Alt+W" },
description: "Translate entire page",
},
toggleHover: {
suggested_key: { default: "Alt+H", mac: "Alt+H" },
description: "Cycle hover translation mode",
},
},
}),
...(browser === "safari" && {
browser_specific_settings: {
safari: {
strict_min_version: "16.4",
},
},
}),
...(browser === "firefox" && {
browser_specific_settings: {
gecko: {
id: "astra@nicepkg.cn",
// Firefox requires data_collection_permissions for new submissions; addons-linter
// requires a min version that actually supports this manifest key (FF 140+ desktop,
// FF 142+ Android per mozilla/addons-linter).
strict_min_version: "142.0",
data_collection_permissions: {
required: ["none"],
},
},
},
}),
}
},
})