MCPcopy Index your code
hub / github.com/darkreader/darkreader / onChange

Function onChange

tasks/bundle-js.js:211–246  ·  view source on GitHub ↗
(changedFiles, watcher, initialPlatforms)

Source from the content-addressed store, hash-verified

209
210 /** @type {(changedFiles: string[], watcher: FSWatcher, platforms: any) => Promise<void>} */
211 const onChange = async (changedFiles, watcher, initialPlatforms) => {
212 /** @type {any} */
213 let platforms = {};
214 const connectedBrowsers = reload.getConnectedBrowsers();
215 if (connectedBrowsers.includes('chrome')) {
216 platforms.chrome = initialPlatforms.chrome;
217 platforms['chrome-mv3'] = initialPlatforms['chrome-mv3'];
218 platforms['chrome-plus'] = initialPlatforms['chrome-plus'];
219 }
220 if (connectedBrowsers.includes('firefox')) {
221 platforms.firefox = true;
222 }
223 if (connectedBrowsers.length === 0) {
224 platforms = initialPlatforms;
225 }
226
227 const entries = jsEntries.filter((entry) => {
228 return changedFiles.some((changed) => {
229 return entry.watchFiles?.includes(changed);
230 });
231 });
232 await bundleEachPlatform({platforms, debug: true, watch: true}, entries);
233
234 const newWatchFiles = getRelevantWatchFiles();
235 watcher.unwatch(
236 currentWatchFiles.filter((oldFile) => !newWatchFiles.includes(oldFile))
237 );
238 watcher.add(
239 newWatchFiles.filter((newFile) => currentWatchFiles.includes(newFile))
240 );
241
242 const isUIOnly = entries.every((entry) => entry.reloadType === reload.UI);
243 reload.reload({
244 type: isUIOnly ? reload.UI : reload.FULL,
245 });
246 };
247
248 return createTask(
249 'bundle-js',

Callers

nothing calls this directly

Calls 3

bundleEachPlatformFunction · 0.85
getRelevantWatchFilesFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected