From 84e4f347f16e5d10ea94cdf2f677a20f307a1ae9 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 22 Dec 2024 12:16:50 +0800 Subject: [PATCH] Chore: some minor changes --- Build/build-cdn-download-conf.ts | 7 ++++--- Build/build-public.ts | 3 +-- Build/build-reject-domainset.ts | 2 +- Build/lib/rules/ip.ts | 2 +- Build/lib/rules/ruleset.ts | 12 ++++++------ package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Build/build-cdn-download-conf.ts b/Build/build-cdn-download-conf.ts index d65b7b448..5853984d2 100644 --- a/Build/build-cdn-download-conf.ts +++ b/Build/build-cdn-download-conf.ts @@ -7,8 +7,9 @@ import { appendArrayInPlace } from './lib/append-array-in-place'; import { SOURCE_DIR } from './constants/dir'; import { DomainsetOutput } from './lib/create-file'; import { CRASHLYTICS_WHITELIST } from './constants/reject-data-source'; +import { appendSetElementsToArray } from 'foxts/append-set-elements-to-array'; -const getS3OSSDomainsPromise = (async (): Promise => { +const getS3OSSDomainsPromise = (async (): Promise> => { const trie = new HostnameTrie(); for await (const line of await fetchRemoteTextByLine('https://publicsuffix.org/list/public_suffix_list.dat', true)) { @@ -44,7 +45,7 @@ const getS3OSSDomainsPromise = (async (): Promise => { } }); - return Array.from(S3OSSDomains); + return S3OSSDomains; })(); export const buildCdnDownloadConf = task(require.main === module, __filename)(async (span) => { @@ -62,7 +63,7 @@ export const buildCdnDownloadConf = task(require.main === module, __filename)(as ]); // Move S3 domains to download domain set, since S3 files may be large - appendArrayInPlace(downloadDomainSet, S3OSSDomains); + appendSetElementsToArray(downloadDomainSet, S3OSSDomains); appendArrayInPlace(downloadDomainSet, steamDomainSet); // we have whitelisted the crashlytics domain, and we also want to put it in CDN policy diff --git a/Build/build-public.ts b/Build/build-public.ts index e93b6fe60..68e21dc83 100644 --- a/Build/build-public.ts +++ b/Build/build-public.ts @@ -9,6 +9,7 @@ import type { TreeType, TreeTypeArray } from './lib/tree-dir'; import { OUTPUT_MOCK_DIR, OUTPUT_MODULES_DIR, PUBLIC_DIR, ROOT_DIR } from './constants/dir'; import { fastStringCompare, mkdirp, writeFile } from './lib/misc'; import picocolors from 'picocolors'; +import { tagged as html } from 'foxts/tagged'; import { compareAndWriteFile } from './lib/create-file'; const mockDir = path.join(ROOT_DIR, 'Mock'); @@ -94,8 +95,6 @@ const priorityOrder: Record<'default' | string & {}, number> = { }; const prioritySorter = (a: TreeType, b: TreeType) => ((priorityOrder[a.name] || priorityOrder.default) - (priorityOrder[b.name] || priorityOrder.default)) || fastStringCompare(a.name, b.name); -const html = (string: TemplateStringsArray, ...values: any[]) => string.reduce((acc, str, i) => acc + str + (values[i] ?? ''), ''); - function walk(tree: TreeTypeArray) { let result = ''; tree.sort(prioritySorter); diff --git a/Build/build-reject-domainset.ts b/Build/build-reject-domainset.ts index a156aafe9..35b7f910b 100644 --- a/Build/build-reject-domainset.ts +++ b/Build/build-reject-domainset.ts @@ -164,7 +164,7 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as '! Description: The domainset supports AD blocking, tracking protection, privacy protection, anti-phishing, anti-mining', '!' ], - rejectOutput.adguardhome(/* filterRuleWhitelistDomainSets */) + rejectOutput.adguardhome() ), path.join(OUTPUT_INTERNAL_DIR, 'reject-adguardhome.txt') ) diff --git a/Build/lib/rules/ip.ts b/Build/lib/rules/ip.ts index e0b1082b6..7577ec80f 100644 --- a/Build/lib/rules/ip.ts +++ b/Build/lib/rules/ip.ts @@ -22,7 +22,7 @@ export class IPListOutput extends RuleOutput { appendArrayInPlace( results, merge( - appendArrayInPlace(Array.from(this.ipcidrNoResolve), Array.from(this.ipcidr)), + appendSetElementsToArray(Array.from(this.ipcidrNoResolve), this.ipcidr), true ) ); diff --git a/Build/lib/rules/ruleset.ts b/Build/lib/rules/ruleset.ts index df50df5c0..bc5c2a940 100644 --- a/Build/lib/rules/ruleset.ts +++ b/Build/lib/rules/ruleset.ts @@ -61,7 +61,7 @@ export class RulesetOutput extends RuleOutput { appendArrayInPlace( results, - merge(Array.from(this.ipcidrNoResolve)).map(i => `IP-CIDR,${i},no-resolve`, true) + merge(Array.from(this.ipcidrNoResolve), true).map(i => `IP-CIDR,${i},no-resolve`) ); appendSetElementsToArray(results, this.ipcidr6NoResolve, i => `IP-CIDR6,${i},no-resolve`); appendSetElementsToArray(results, this.ipasnNoResolve, i => `IP-ASN,${i},no-resolve`); @@ -69,7 +69,7 @@ export class RulesetOutput extends RuleOutput { appendArrayInPlace( results, - merge(Array.from(this.ipcidr)).map(i => `IP-CIDR,${i}`, true) + merge(Array.from(this.ipcidr), true).map(i => `IP-CIDR,${i}`) ); appendSetElementsToArray(results, this.ipcidr6, i => `IP-CIDR6,${i}`); appendSetElementsToArray(results, this.ipasn, i => `IP-ASN,${i}`); @@ -108,7 +108,7 @@ export class RulesetOutput extends RuleOutput { appendArrayInPlace( results, - merge(Array.from(this.ipcidrNoResolve)).map(i => `IP-CIDR,${i},no-resolve`, true) + merge(Array.from(this.ipcidrNoResolve), true).map(i => `IP-CIDR,${i},no-resolve`) ); appendSetElementsToArray(results, this.ipcidr6NoResolve, i => `IP-CIDR6,${i},no-resolve`); appendSetElementsToArray(results, this.ipasnNoResolve, i => `IP-ASN,${i},no-resolve`); @@ -116,7 +116,7 @@ export class RulesetOutput extends RuleOutput { appendArrayInPlace( results, - merge(Array.from(this.ipcidr)).map(i => `IP-CIDR,${i}`, true) + merge(Array.from(this.ipcidr), true).map(i => `IP-CIDR,${i}`) ); appendSetElementsToArray(results, this.ipcidr6, i => `IP-CIDR6,${i}`); appendSetElementsToArray(results, this.ipasn, i => `IP-ASN,${i}`); @@ -130,7 +130,7 @@ export class RulesetOutput extends RuleOutput { appendArrayInPlace( ip_cidr, merge( - appendArrayInPlace(Array.from(this.ipcidrNoResolve), Array.from(this.ipcidr)), + appendSetElementsToArray(Array.from(this.ipcidrNoResolve), this.ipcidr), true ) ); @@ -143,7 +143,7 @@ export class RulesetOutput extends RuleOutput { domain: appendArrayInPlace(['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'], this.$preprocessed[0]), domain_suffix: this.$preprocessed[1], domain_keyword: Array.from(this.domainKeywords), - domain_regex: Array.from(this.domainWildcard).map(RuleOutput.domainWildCardToRegex), + domain_regex: Array.from(this.domainWildcard, RuleOutput.domainWildCardToRegex), ip_cidr, source_ip_cidr: [...this.sourceIpOrCidr].reduce((acc, cur) => { if (cur.includes('/')) { diff --git a/package.json b/package.json index a9099c255..87e3cbaa5 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "fast-cidr-tools": "^0.3.1", "fast-fifo": "^1.3.2", "fdir": "^6.4.2", - "foxts": "^1.0.10", + "foxts": "^1.0.11", "hash-wasm": "^4.12.0", "json-stringify-pretty-compact": "^3.0.0", "make-fetch-happen": "^14.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38c0734ab..7f205bbbe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,8 +45,8 @@ importers: specifier: ^6.4.2 version: 6.4.2(picomatch@4.0.2) foxts: - specifier: ^1.0.10 - version: 1.0.10 + specifier: ^1.0.11 + version: 1.0.11 hash-wasm: specifier: ^4.12.0 version: 4.12.0 @@ -1145,8 +1145,8 @@ packages: resolution: {integrity: sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==} engines: {node: '>= 6'} - foxts@1.0.10: - resolution: {integrity: sha512-yuZH9YLqXXB3QGYBEywnJs69Jl4E8xDPxNEy4vkSr/nqeKD4t2VCsqeTqPZKT3ZVZSpPmBa7y/0VLyUBMj8P/g==} + foxts@1.0.11: + resolution: {integrity: sha512-yO5eV+OuORNzmRzxBjXRyLPRyac1mR5zog7+EhpTVDfV3mfP7JYLJjCRNJpLudCbCG6mmVM4b8z0AfgWRKKfYA==} fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} @@ -3030,7 +3030,7 @@ snapshots: combined-stream: 1.0.8 mime-types: 2.1.35 - foxts@1.0.10: {} + foxts@1.0.11: {} fs-constants@1.0.0: {}