diff --git a/Build/build-cdn-download-conf.ts b/Build/build-cdn-download-conf.ts index f930a0ba..6771dcc9 100644 --- a/Build/build-cdn-download-conf.ts +++ b/Build/build-cdn-download-conf.ts @@ -9,7 +9,7 @@ import { domainDeduper } from './lib/domain-deduper'; import { appendArrayInPlace } from './lib/append-array-in-place'; import { sortDomains } from './lib/stable-sort-domain'; -const getS3OSSDomainsPromise = (async (): Promise> => { +const getS3OSSDomainsPromise = (async (): Promise => { const trie = createTrie( (await getPublicSuffixListTextPromise()).split('\n'), true, @@ -45,7 +45,7 @@ const getS3OSSDomainsPromise = (async (): Promise> => { } }); - return S3OSSDomains; + return Array.from(S3OSSDomains); })(); export const buildCdnDownloadConf = task(import.meta.main, import.meta.path)(async (span) => { @@ -62,7 +62,7 @@ export const buildCdnDownloadConf = task(import.meta.main, import.meta.path)(asy readFileIntoProcessedArray(path.resolve(import.meta.dir, '../Source/domainset/steam.conf')) ]); - appendArrayInPlace(downloadDomainSet, Array.from(S3OSSDomains).map((domain) => `.${domain}`)); + appendArrayInPlace(downloadDomainSet, S3OSSDomains.map(domain => `.${domain}`)); appendArrayInPlace(downloadDomainSet, steamDomainSet); return Promise.all([ diff --git a/Build/build-speedtest-domainset.ts b/Build/build-speedtest-domainset.ts index d92ca573..c82714e9 100644 --- a/Build/build-speedtest-domainset.ts +++ b/Build/build-speedtest-domainset.ts @@ -20,8 +20,8 @@ const s = new Sema(2); const latestTopUserAgentsPromise = fsFetchCache.apply( 'https://cdn.jsdelivr.net/npm/top-user-agents@latest/src/desktop.json', () => fetchWithRetry('https://cdn.jsdelivr.net/npm/top-user-agents@latest/src/desktop.json') - .then(res => res.json() as any) - .then((userAgents: string[]) => userAgents.filter(ua => ua.startsWith('Mozilla/5.0 '))), + .then(res => res.json() as Promise) + .then((userAgents) => userAgents.filter(ua => ua.startsWith('Mozilla/5.0 '))), { serializer: serializeArray, deserializer: deserializeArray, diff --git a/Build/lib/aho-corasick.ts b/Build/lib/aho-corasick.ts index ad7675ef..c1ab6984 100644 --- a/Build/lib/aho-corasick.ts +++ b/Build/lib/aho-corasick.ts @@ -13,35 +13,6 @@ const createNode = (): Node => { return node; }; -const deepNodeToJSON = (node: Node, wset: WeakSet) => { - if (wset.has(node)) { - return 'circular'; - } - wset.add(node); - - const obj: Record = {}; - if (node[WORDEND]) { - obj['[end]'] = node[WORDEND]; - } - - node.forEach((value, key) => { - obj[key] = deepNodeToJSON(value, wset); - }); - return obj; -}; - -function createNodeInspectCustom(node: Node) { - const wset = new WeakSet(); - return () => { - try { - return JSON.stringify(deepNodeToJSON(node, wset), null, 2); - } catch (e) { - console.error(e); - return ''; - } - }; -} - const createKeywordFilter = (keys: string[] | Set) => { const root = createNode(); @@ -92,7 +63,7 @@ const createKeywordFilter = (keys: string[] | Set) => { // }; // build(); - const tester = (text: string) => { + return (text: string) => { let node: Node | undefined = root; for (let i = 0, textLen = text.length; i < textLen; i++) { @@ -111,10 +82,6 @@ const createKeywordFilter = (keys: string[] | Set) => { return false; }; - - tester[Bun.inspect.custom] = createNodeInspectCustom(root); - - return tester; }; export default createKeywordFilter; diff --git a/Build/lib/create-file.ts b/Build/lib/create-file.ts index e8d911a1..07f32cbe 100644 --- a/Build/lib/create-file.ts +++ b/Build/lib/create-file.ts @@ -159,7 +159,7 @@ const MARK = 'this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'; export const createRuleset = ( parentSpan: Span, title: string, description: string[] | readonly string[], date: Date, content: string[], - type: 'ruleset' | 'domainset', surgePath: string, clashPath: string + type: ('ruleset' | 'domainset' | string & {}), surgePath: string, clashPath: string ) => parentSpan.traceChild(`create ruleset: ${path.basename(surgePath, path.extname(surgePath))}`).traceAsyncFn((childSpan) => { const surgeContent = withBannerArray( title, description, date, @@ -177,7 +177,7 @@ export const createRuleset = ( _clashContent = [`DOMAIN,${MARK}`, ...surgeRulesetToClashClassicalTextRuleset(content)]; break; default: - throw new TypeError(`Unknown type: ${type as any}`); + throw new TypeError(`Unknown type: ${type}`); } return withBannerArray(title, description, date, _clashContent); }); diff --git a/Build/lib/timsort.ts b/Build/lib/timsort.ts index 9ff4d0e3..a1be8a1b 100644 --- a/Build/lib/timsort.ts +++ b/Build/lib/timsort.ts @@ -426,15 +426,15 @@ class TimSort { this.tmp = new Array(this.tmpStorageLength); - this.stackLength = ( - this.length < 120 - ? 5 - : this.length < 1542 - ? 10 - : this.length < 119151 - ? 19 - : 40 - ); + if (this.length < 120) { + this.stackLength = 5; + } else if (this.length < 1542) { + this.stackLength = 10; + } else if (this.length < 119151) { + this.stackLength = 19; + } else { + this.stackLength = 40; + } this.runStart = new Array(this.stackLength); this.runLength = new Array(this.stackLength); diff --git a/Build/trace/index.ts b/Build/trace/index.ts index 298b30e0..48f71d11 100644 --- a/Build/trace/index.ts +++ b/Build/trace/index.ts @@ -166,19 +166,19 @@ function printTree(initialTree: TraceResult, printNode: (node: TraceResult, bran } function printStats(stats: TraceResult[]): void { - stats.sort((a, b) => a.start - b.start); - const longestTaskName = Math.max(...stats.map(i => i.name.length)); const realStart = Math.min(...stats.map(i => i.start)); const realEnd = Math.max(...stats.map(i => i.end)); const statsStep = ((realEnd - realStart) / 120) | 0; - stats.forEach(stat => { - console.log( - `[${stat.name}]${' '.repeat(longestTaskName - stat.name.length)}`, - ' '.repeat(((stat.start - realStart) / statsStep) | 0), - '='.repeat(Math.max(((stat.end - stat.start) / statsStep) | 0, 1)) - ); - }); + stats + .sort((a, b) => a.start - b.start) + .forEach(stat => { + console.log( + `[${stat.name}]${' '.repeat(longestTaskName - stat.name.length)}`, + ' '.repeat(((stat.start - realStart) / statsStep) | 0), + '='.repeat(Math.max(((stat.end - stat.start) / statsStep) | 0, 1)) + ); + }); } diff --git a/bun.lockb b/bun.lockb index f4ad9b57..d3c93e0e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 63ce8403..3d6c6db3 100644 --- a/package.json +++ b/package.json @@ -29,21 +29,21 @@ "punycode": "^2.3.1", "table": "^6.8.2", "tar-stream": "^3.1.7", - "tldts": "^6.1.29", - "tldts-experimental": "^6.1.29", + "tldts": "^6.1.30", + "tldts-experimental": "^6.1.30", "yaml": "^2.4.5" }, "devDependencies": { - "@eslint-sukka/node": "^6.0.0-beta.29", + "@eslint-sukka/node": "^6.0.0", "@types/async-retry": "^1.4.8", - "@types/bun": "^1.1.5", + "@types/bun": "^1.1.6", "@types/tar-stream": "^3.1.3", "bun-types": "^1.1.17", - "eslint": "^9.5.0", - "eslint-config-sukka": "^6.0.0-beta.29", - "eslint-formatter-sukka": "^6.0.0-beta.29", + "eslint": "^9.6.0", + "eslint-config-sukka": "^6.0.0", + "eslint-formatter-sukka": "^6.0.0", "mitata": "^0.1.11", - "typescript": "^5.5.2" + "typescript": "^5.5.3" }, "resolutions": { "has": "npm:@nolyfill/has@latest"