1
- import { resolve , dirname } from 'path' ;
2
- import { readFileSync , writeFileSync } from 'fs' ;
1
+ import { resolve , dirname , join } from 'path' ;
2
+ import { readFileSync , writeFileSync , readdirSync } from 'fs' ;
3
3
import { exec , execSync } from 'child_process' ;
4
4
import { build } from 'vite' ;
5
5
import shelljs from 'shelljs' ;
@@ -67,14 +67,16 @@ if (argv.target === 'safari') {
67
67
options . assets . push ( 'background/safari' ) ;
68
68
}
69
69
70
+ // Download adblocker engines
70
71
if ( argv . staging ) {
71
- execSync ( 'npm run download.staging' , { stdio : 'inherit' } ) ;
72
-
72
+ execSync ( 'npm run download-engines -- --staging' , { stdio : 'inherit' } ) ;
73
73
manifest . debug = true ;
74
74
} else {
75
- execSync ( 'npm run download' , { stdio : 'inherit' } ) ;
75
+ execSync ( 'npm run download-engines ' , { stdio : 'inherit' } ) ;
76
76
}
77
77
78
+ execSync ( 'npm run download-whotracksme-bloomfilter' , { stdio : 'inherit' } ) ;
79
+
78
80
const config = {
79
81
logLevel : argv . silent ? 'silent' : undefined ,
80
82
configFile : false ,
@@ -114,7 +116,7 @@ options.assets.forEach((path) => {
114
116
// copy adblocker engines
115
117
shelljs . mkdir ( '-p' , resolve ( options . outDir , 'rule_resources' ) ) ;
116
118
117
- const engines = [ 'ads' , 'tracking' , 'annoyances' ] ;
119
+ const engines = [ 'ads' , 'tracking' , 'annoyances' , 'fixes' ] ;
118
120
const engineType = argv . target === 'firefox' ? '' : '-cosmetics' ;
119
121
120
122
engines . forEach ( ( engine ) => {
@@ -173,6 +175,10 @@ execSync('npm run licenses', { stdio: 'inherit' });
173
175
// set manifest version from package.json
174
176
manifest . version = pkg . version ;
175
177
178
+ if ( manifest . permissions . includes ( 'declarativeNetRequest' ) && argv . watch ) {
179
+ manifest . permissions . push ( 'declarativeNetRequestFeedback' ) ;
180
+ }
181
+
176
182
writeFileSync (
177
183
resolve ( options . outDir , 'manifest.json' ) ,
178
184
JSON . stringify ( manifest , null , 2 ) ,
@@ -191,6 +197,20 @@ if (manifest.browser_action?.default_popup) {
191
197
source . push ( manifest . browser_action . default_popup ) ;
192
198
}
193
199
200
+ // offscreen documents
201
+ if (
202
+ manifest . permissions . includes ( 'offscreen' ) ||
203
+ manifest . optional_permissions ?. includes ( 'offscreen' )
204
+ ) {
205
+ readdirSync ( join ( options . srcDir , 'pages' , 'offscreen' ) , {
206
+ withFileTypes : true ,
207
+ } )
208
+ . filter ( ( dirent ) => dirent . isDirectory ( ) && ! dirent . name . startsWith ( '.' ) )
209
+ . forEach ( ( dirent ) =>
210
+ source . push ( join ( 'pages' , 'offscreen' , dirent . name , 'index.html' ) ) ,
211
+ ) ;
212
+ }
213
+
194
214
// options page
195
215
if ( manifest . options_ui ?. page ) {
196
216
source . push ( manifest . options_ui ?. page ) ;
0 commit comments