@@ -6,14 +6,14 @@ import {CachedFunction} from 'webext-storage-cache';
66import type { RghOptions } from '../options-storage.js' ;
77import { getNewFeatureName } from '../feature-data.js' ;
88import isDevelopmentVersion from './is-development-version.js' ;
9- import { isomorphicFetchText } from './isomorphic-fetch.js' ;
9+ import { webextFetch } from './isomorphic-fetch.js' ;
1010import { type BrokenFeatureEntry , parseBrokenFeaturesCsv } from './hotfix-parse.js' ;
1111
1212const { version : currentVersion } = chrome . runtime . getManifest ( ) ;
1313
1414async function fetchHotfix ( path : string ) : Promise < string > {
1515 // Use GitHub Pages host because the API is rate-limited
16- return isomorphicFetchText ( `https://refined-github.github.io/yolo/${ path } ` , {
16+ return webextFetch ( `https://refined-github.github.io/yolo/${ path } ` , {
1717 cache : 'no-store' , // Disable caching altogether
1818 } ) ;
1919}
@@ -22,6 +22,12 @@ type HotfixStorage = BrokenFeatureEntry[];
2222
2323export const brokenFeatures = new CachedFunction ( 'broken-features' , {
2424 async updater ( ) : Promise < HotfixStorage > {
25+ // To facilitate debugging, ignore hotfixes during development.
26+ // Change the version in manifest.json to test hotfixes
27+ if ( isDevelopmentVersion ( ) ) {
28+ return [ ] ;
29+ }
30+
2531 const content = await fetchHotfix ( 'broken-features.csv' ) ;
2632 return parseBrokenFeaturesCsv ( content , currentVersion ) ;
2733 } ,
@@ -30,26 +36,19 @@ export const brokenFeatures = new CachedFunction('broken-features', {
3036} ) ;
3137
3238export const styleHotfixes = new CachedFunction ( 'style-hotfixes' , {
33- updater : async ( version : string ) : Promise < string > => fetchHotfix ( `style/${ version } .css` ) ,
39+ // To facilitate debugging, ignore hotfixes during development.
40+ // Change the version in manifest.json to test hotfixes
41+ updater : async ( version : string ) : Promise < string > =>
42+ isDevelopmentVersion ( ) ? '' : fetchHotfix ( `style/${ version } .css` ) ,
3443
3544 maxAge : { hours : 6 } ,
3645 staleWhileRevalidate : { days : 300 } ,
3746 cacheKey : ( ) => '' ,
3847} ) ;
3948
40- export async function getLocalHotfixes ( ) : Promise < HotfixStorage > {
41- // To facilitate debugging, ignore hotfixes during development.
42- // Change the version in manifest.json to test hotfixes
43- if ( isDevelopmentVersion ( ) ) {
44- return [ ] ;
45- }
46-
47- return await brokenFeatures . get ( ) ?? [ ] ;
48- }
49-
50- export async function getLocalHotfixesAsOptions ( ) : Promise < Partial < RghOptions > > {
49+ export function brokenFeaturesAsOptions ( brokenFeaturesStorage : HotfixStorage = [ ] ) : Partial < RghOptions > {
5150 const options : Partial < RghOptions > = { } ;
52- for ( const [ feature ] of await getLocalHotfixes ( ) ) {
51+ for ( const [ feature ] of brokenFeaturesStorage ) {
5352 const currentFeature = getNewFeatureName ( feature ) ;
5453 if ( currentFeature ) {
5554 options [ `feature:${ currentFeature } ` ] = false ;
@@ -60,7 +59,7 @@ export async function getLocalHotfixesAsOptions(): Promise<Partial<RghOptions>>
6059}
6160
6261export async function applyStyleHotfixes ( style : string ) : Promise < void > {
63- if ( ! style || isDevelopmentVersion ( ) || isEnterprise ( ) ) {
62+ if ( ! style || isEnterprise ( ) ) {
6463 return ;
6564 }
6665
0 commit comments