mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Chore: minor changes
This commit is contained in:
parent
d7f9961062
commit
9e9ee36292
@ -1,6 +1,5 @@
|
||||
import { task } from './trace';
|
||||
import { SHARED_DESCRIPTION } from './constants/description';
|
||||
import { once } from 'foxts/once';
|
||||
import { RulesetOutput } from './lib/rules/ruleset';
|
||||
import Worktank from 'worktank';
|
||||
import { RULES } from './constants/microsoft-cdn';
|
||||
@ -48,18 +47,13 @@ const pool = new Worktank({
|
||||
}
|
||||
});
|
||||
|
||||
export const getMicrosoftCdnRulesetPromise = once<Promise<[domains: string[], domainSuffixes: string[]]>>(async () => {
|
||||
const res = await pool.exec(
|
||||
'getMicrosoftCdnRuleset',
|
||||
[__filename]
|
||||
);
|
||||
pool.terminate();
|
||||
|
||||
return res;
|
||||
});
|
||||
export const getMicrosoftCdnRulesetPromise = pool.exec(
|
||||
'getMicrosoftCdnRuleset',
|
||||
[__filename]
|
||||
).finally(() => pool.terminate());
|
||||
|
||||
export const buildMicrosoftCdn = task(require.main === module, __filename)(async (span) => {
|
||||
const [domains, domainSuffixes] = await span.traceChildPromise('get microsoft cdn domains', getMicrosoftCdnRulesetPromise());
|
||||
const [domains, domainSuffixes] = await span.traceChildPromise('get microsoft cdn domains', getMicrosoftCdnRulesetPromise);
|
||||
|
||||
return new RulesetOutput(span, 'microsoft_cdn', 'non_ip')
|
||||
.withTitle('Sukka\'s Ruleset - Microsoft CDN')
|
||||
|
||||
@ -61,7 +61,7 @@ export const buildSSPanelUIMAppProfile = task(require.main === module, __filenam
|
||||
// domestic - domains
|
||||
getDomesticAndDirectDomainsRulesetPromise(),
|
||||
getAppleCdnDomainsPromise(),
|
||||
getMicrosoftCdnRulesetPromise(),
|
||||
getMicrosoftCdnRulesetPromise,
|
||||
readFileIntoProcessedArray(path.join(OUTPUT_SURGE_DIR, 'non_ip/apple_cn.conf')),
|
||||
readFileIntoProcessedArray(path.join(OUTPUT_SURGE_DIR, 'non_ip/neteasemusic.conf')),
|
||||
// microsoft & apple - domains
|
||||
|
||||
@ -29,8 +29,8 @@ export async function compareAndWriteFile(span: Span, linesA: string[], filePath
|
||||
|
||||
// The default highwater mark is normally 16384,
|
||||
// So we make sure direct write to file if the content is
|
||||
// most likely less than 500 lines
|
||||
if (linesALen < 500) {
|
||||
// most likely less than 250 lines
|
||||
if (linesALen < 250) {
|
||||
return writeFile(filePath, fastStringArrayJoin(linesA, '\n') + '\n');
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,9 @@ export async function fetchAssets(
|
||||
console.log(picocolors.gray('[fetch cancelled]'), picocolors.gray(url));
|
||||
throw reusedCustomAbortError;
|
||||
}
|
||||
if (index >= 0) {
|
||||
console.log(picocolors.yellowBright('[fetch fallback begin]'), picocolors.gray(url));
|
||||
}
|
||||
const res = await $$fetch(url, { signal: controller.signal, ...defaultRequestInit });
|
||||
|
||||
let stream = nullthrow(res.body, url + ' has an empty body')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user