Housekeeping

This commit is contained in:
SukkaW
2026-08-20 22:54:47 +08:00
parent 53634aab1d
commit b1d0f4bcc2
6 changed files with 66 additions and 65 deletions

View File

@@ -18,7 +18,7 @@ const fileEqual = createCompareSource(fileEqualWithCommentComparator);
*/
async function isPreviousOutputEqual(span: Span, linesA: string[], filePath: string, contentHash: string | null) {
// readFileByLine will not include last empty line. So we always pop the linesA for comparison purpose
if (linesA.length > 0 && linesA[linesA.length - 1] === '') {
if (linesA.length > 0 && linesA.at(-1) === '') {
linesA.pop();
}

View File

@@ -154,7 +154,7 @@ const agent = new Agent({
console.log('[fetch retry]', 'schedule retry', { statusCode, retryTimeout, errorCode, url: opts.origin });
// eslint-disable-next-line sukka/prefer-timer-id -- won't leak
setTimeout(() => cb(null), retryTimeout);
setTimeout(cb, retryTimeout, null);
}
// errorCodes: ['UND_ERR_HEADERS_TIMEOUT', 'ECONNRESET', 'ECONNREFUSED', 'ENOTFOUND', 'ENETDOWN', 'ENETUNREACH', 'EHOSTDOWN', 'EHOSTUNREACH', 'EPIPE', 'ETIMEDOUT']
}),

View File

@@ -56,7 +56,7 @@ export function writeDataToStrategies(data: StrategyWriteData, strategies: BaseW
const domainEntries: Array<[domain: string, subdomain: boolean]> = [];
for (let j = 0, len = data.domains.length; j < len; j++) {
const line = data.domains[j];
const includeSubdomain = line.codePointAt(0) === 46; /* '.' */
const includeSubdomain = line.charCodeAt(0) === 46; /* '.' */
const d = domainToASCII(includeSubdomain ? line.slice(1) : line);
if (d) domainEntries.push([d, includeSubdomain]);
}

View File

@@ -4,6 +4,7 @@ import { OUTPUT_SURGE_DIR } from './constants/dir';
import path from 'node:path';
import { readFileIntoProcessedArray } from './lib/fetch-text-by-line';
import { xxhash3 } from 'hash-wasm';
import { split1st } from 'foxts/split-nth';
(async () => {
const hashMap = new Map<string, Set<string>>();
@@ -30,7 +31,7 @@ import { xxhash3 } from 'hash-wasm';
if (file.startsWith('domainset' + path.sep)) {
await runHash((await readFileIntoProcessedArray(fullpath)).map(i => (i[0] === '.' ? i.slice(1) : i)));
} else if (file.startsWith('non_ip' + path.sep)) {
await runHash((await readFileIntoProcessedArray(fullpath)).map(i => i.split(',', 2)[1]));
await runHash((await readFileIntoProcessedArray(fullpath)).map(i => split1st(i, ',')));
}
}

View File

@@ -52,7 +52,7 @@
"devDependencies": {
"@eslint-sukka/node": "^9.0.1",
"@swc-node/register": "^1.12.1",
"@swc/core": "1.15.47",
"@swc/core": "1.16.1",
"@types/cli-progress": "^3.11.6",
"@types/mocha": "^10.0.10",
"@types/node": "^26.2.0",
@@ -68,5 +68,5 @@
"mocha": "^11.8.0",
"typescript": "^6.0.3"
},
"packageManager": "pnpm@11.20.0"
"packageManager": "pnpm@11.22.0"
}

118
pnpm-lock.yaml generated
View File

@@ -104,10 +104,10 @@ importers:
version: 9.0.1(eslint@10.8.1(supports-color@8.1.1))(supports-color@8.1.1)(typescript@6.0.3)
'@swc-node/register':
specifier: ^1.12.1
version: 1.12.1(@swc/core@1.15.47)(@swc/types@0.1.28)(supports-color@8.1.1)(typescript@6.0.3)
version: 1.12.1(@swc/core@1.16.1)(@swc/types@0.1.28)(supports-color@8.1.1)(typescript@6.0.3)
'@swc/core':
specifier: 1.15.47
version: 1.15.47
specifier: 1.16.1
version: 1.16.1
'@types/cli-progress':
specifier: ^3.11.6
version: 3.11.6
@@ -643,86 +643,86 @@ packages:
'@swc-node/sourcemap-support@0.6.1':
resolution: {integrity: sha512-ovltDVH5QpdHXZkW138vG4+dgcNsxfwxHVoV6BtmTbz2KKl1A8ZSlbdtxzzfNjCjbpayda8Us9eMtcHobm38dA==}
'@swc/core-darwin-arm64@1.15.47':
resolution: {integrity: sha512-GsoMtan3ojGGMGFbl31mmRu5ctZ56re8grGE8mO/OHJ8O+JRkzod02fe7X6ZQ8JvamA3imkEkx/h3u+vsOgPgA==}
'@swc/core-darwin-arm64@1.16.1':
resolution: {integrity: sha512-zlJblJ8ncErD43lKdxjbUaUskJQf+LxiPXYcWXD8/8ZMV+7uuAT+CwjciLXpyZBd5Pq/S726bMpeeAwSeL1hhg==}
engines: {node: '>=10'}
cpu: [arm64]
os: [darwin]
'@swc/core-darwin-x64@1.15.47':
resolution: {integrity: sha512-leTi7Rx3KF4zcC637iqWgk9SoV8VXAD8ppQYXsep63px5A/UftOcxLN1pmr8Z1si/YvX90ompP/rHgpYkgwXWg==}
'@swc/core-darwin-x64@1.16.1':
resolution: {integrity: sha512-IN0BmPWb0YAh/17mmlWB/HDBtTw2MfuW4hulf/tQAgTQBRH17l+z499bNJLK6LizSjqs0P7V+jU38Zj+vJC1DA==}
engines: {node: '>=10'}
cpu: [x64]
os: [darwin]
'@swc/core-linux-arm-gnueabihf@1.15.47':
resolution: {integrity: sha512-hBqHuoWKKIsKmDBn9qVeWqj5GWZhtlcczVaqQmNRXsDfq+voR5CxKRfamA367QjJXtceYuliLFfEL8QsskRM2g==}
'@swc/core-linux-arm-gnueabihf@1.16.1':
resolution: {integrity: sha512-EYgrx2YOCQ2Twz2S793kqNjPkpvYVUPzzR95bIb7by+VQcyaai4lZZ2iz/tZvcFVKSNcN3/JTKwx+aBn2ZL52A==}
engines: {node: '>=10'}
cpu: [arm]
os: [linux]
'@swc/core-linux-arm64-gnu@1.15.47':
resolution: {integrity: sha512-TBxvRz+B4K205TWHHZxWVxkC2RFNP/Mz3PNcECBos5PsKwxjg3QSJzdoebr0VCf0Bfh8HOPldKxAP/8XkFe9gA==}
'@swc/core-linux-arm64-gnu@1.16.1':
resolution: {integrity: sha512-moyKm0YZlHdHohzm1YwgAyesqnE853rO0REMfJLFAova51wF9BNi+3ZW2PeS7Vqvn6HeJuepLpAHbBdZctxpHA==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@swc/core-linux-arm64-musl@1.15.47':
resolution: {integrity: sha512-3Yu3Uq/VgytqsPjTMbkPU1ExADytbdWbruJYhA584E9jrpE2Ki+R6VVPoZCeAVk1Cb7QxcRTgblw6bSa6a/R+w==}
'@swc/core-linux-arm64-musl@1.16.1':
resolution: {integrity: sha512-kKGBO9wdapiSzuf5ZzZ2fYtlu1BNSYtIIUxvH1ir/gcelTOREEHGDCLTDFx/2Knf878nU11A40z7LxwasEFxqA==}
engines: {node: '>=10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@swc/core-linux-ppc64-gnu@1.15.47':
resolution: {integrity: sha512-wfdMi5IaOaNtmh2/6geRoxIdNfqylUZFdtzTKS655y1axWfIWyx7As74vv0wVdjeCIZ3WmCI9odDd4rUttXOSQ==}
'@swc/core-linux-ppc64-gnu@1.16.1':
resolution: {integrity: sha512-nZ6qahtLxC3PM54cWOQZHxt4lTCF/3J4LIoWWzz6v7A+rLs8Dx54anYQf7mH3eIi8KlNpgKci/ie8ZSqFN8O7A==}
engines: {node: '>=10'}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@swc/core-linux-s390x-gnu@1.15.47':
resolution: {integrity: sha512-3hHYBY0yx8Ez7GMRrkhXHQzMdR5IZA6Wq5Ee4svlgwvSECLpnAJ9+0AimEGUFDvuLwE7nV/2+PYe8+Nm4rvNcQ==}
'@swc/core-linux-s390x-gnu@1.16.1':
resolution: {integrity: sha512-4ji5PNzhYq193Z4/4xUaSoNJza6iCkDJSzhetrbB6KOYxsr+kxtQr8ePWhMJUiMt6JUWtXaZ1PYT8FhtED+nGA==}
engines: {node: '>=10'}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@swc/core-linux-x64-gnu@1.15.47':
resolution: {integrity: sha512-TjfhjgP/jGCfFHYC3JQPhJA1HwErbIJ9JfREDc1KNkvY6P0LodCgKVIlQ5deeTbkG7ih3bF5PHJLuLpaZjdRyQ==}
'@swc/core-linux-x64-gnu@1.16.1':
resolution: {integrity: sha512-VJQxqrisHV+B394IgrOu8YsIIXZgffnf5tO+yc9Z/hoUpuZEvuQTjWwlnpZdpyD+0nx6LTD1/3k646JYm43yJA==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@swc/core-linux-x64-musl@1.15.47':
resolution: {integrity: sha512-CQpS8Ge/avfjZd0UEwG/sds83Uu32deQXcV1Jo3jD0mmvQQqtYAjpsDZXugmheeAwmt+YIuoVtVHro8LMYHqsQ==}
'@swc/core-linux-x64-musl@1.16.1':
resolution: {integrity: sha512-r9oV1mwxxsIGcLV1IQ/tw76MW3doatKze1QFWuC+a7QqJUkhY/bKTSVk6NpKKUGm2LDsE33Va8VqSClfA7vSiQ==}
engines: {node: '>=10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@swc/core-win32-arm64-msvc@1.15.47':
resolution: {integrity: sha512-0W8IKHsUTYiT7G2RqtOoVWk+89yzZikIiDUb/sCK6BmQDBhN91hQSfyUtW12jhEWLzYgcfmisfsZrmZE+84U1A==}
'@swc/core-win32-arm64-msvc@1.16.1':
resolution: {integrity: sha512-6huNRessoBLxWEqBm5zJXyCQ27TO7anvkdiuQ5MDO4CJni0nOXEqKtV9RllQ2TdyENKKsUMXVnIfW2hIXx/R5Q==}
engines: {node: '>=10'}
cpu: [arm64]
os: [win32]
'@swc/core-win32-ia32-msvc@1.15.47':
resolution: {integrity: sha512-ZIp49d2Z4/ka2jO9otOg4hDvTdPmp86kVOgS2M5FCPI7eKKZ1W0boxWn+8XeZrfERtFGW0AlMRm4JhlJa7l3NA==}
'@swc/core-win32-ia32-msvc@1.16.1':
resolution: {integrity: sha512-OVKJFUzphrGmsh+BGtcZDesx0YryV7/Yvy5XGgTqnrZfjnyfcr5uaqYQugCckdIlupc5Vs3XtDjRAj12z4ZPlw==}
engines: {node: '>=10'}
cpu: [ia32]
os: [win32]
'@swc/core-win32-x64-msvc@1.15.47':
resolution: {integrity: sha512-2h8Iek95vnixkBRCo+H8p09+Q5ll2NgSMFrWTy0iKt7+/t+8/T5mBpiT6c0ZxSS7wcWjwZ9sGZkK70tTSYHdDw==}
'@swc/core-win32-x64-msvc@1.16.1':
resolution: {integrity: sha512-Bt+VIhWYCGk4urklnkkteLUOeLv1VxigwTCeB/xC6rBZxY6IIKdDwCJf6on3E3SUGsIqmQS6QqtuJQc1VxF4Aw==}
engines: {node: '>=10'}
cpu: [x64]
os: [win32]
'@swc/core@1.15.47':
resolution: {integrity: sha512-FbsO5JcfOjfH38W/rohBRBweJeERsAuIP4f377lmkmxTcq9exjtx4SkRuZY5CdfhR2CBVwDIJegBpJDffwNsOg==}
'@swc/core@1.16.1':
resolution: {integrity: sha512-nUaeu91O5QZKrQdaDCHd402ogUIoNOOjpkZNq0UomWK0G6gDaGmLhvddF1/3BXf5O8aLyo6ZPY/aMDWvaJQ/hg==}
engines: {node: '>=10'}
peerDependencies:
'@swc/helpers': '>=0.5.17'
@@ -2485,17 +2485,17 @@ snapshots:
'@sinclair/typebox@0.34.49': {}
'@swc-node/core@1.15.0(@swc/core@1.15.47)(@swc/types@0.1.28)':
'@swc-node/core@1.15.0(@swc/core@1.16.1)(@swc/types@0.1.28)':
dependencies:
'@swc/core': 1.15.47
'@swc/core': 1.16.1
'@swc/types': 0.1.28
'@swc-node/register@1.12.1(@swc/core@1.15.47)(@swc/types@0.1.28)(supports-color@8.1.1)(typescript@6.0.3)':
'@swc-node/register@1.12.1(@swc/core@1.16.1)(@swc/types@0.1.28)(supports-color@8.1.1)(typescript@6.0.3)':
dependencies:
'@node-rs/xxhash': 1.7.6
'@swc-node/core': 1.15.0(@swc/core@1.15.47)(@swc/types@0.1.28)
'@swc-node/core': 1.15.0(@swc/core@1.16.1)(@swc/types@0.1.28)
'@swc-node/sourcemap-support': 0.6.1
'@swc/core': 1.15.47
'@swc/core': 1.16.1
colorette: 2.0.20
debug: 4.4.3(supports-color@8.1.1)
fast-json-stable-stringify: 2.1.0
@@ -2512,59 +2512,59 @@ snapshots:
source-map-support: 0.5.21
tslib: 2.8.1
'@swc/core-darwin-arm64@1.15.47':
'@swc/core-darwin-arm64@1.16.1':
optional: true
'@swc/core-darwin-x64@1.15.47':
'@swc/core-darwin-x64@1.16.1':
optional: true
'@swc/core-linux-arm-gnueabihf@1.15.47':
'@swc/core-linux-arm-gnueabihf@1.16.1':
optional: true
'@swc/core-linux-arm64-gnu@1.15.47':
'@swc/core-linux-arm64-gnu@1.16.1':
optional: true
'@swc/core-linux-arm64-musl@1.15.47':
'@swc/core-linux-arm64-musl@1.16.1':
optional: true
'@swc/core-linux-ppc64-gnu@1.15.47':
'@swc/core-linux-ppc64-gnu@1.16.1':
optional: true
'@swc/core-linux-s390x-gnu@1.15.47':
'@swc/core-linux-s390x-gnu@1.16.1':
optional: true
'@swc/core-linux-x64-gnu@1.15.47':
'@swc/core-linux-x64-gnu@1.16.1':
optional: true
'@swc/core-linux-x64-musl@1.15.47':
'@swc/core-linux-x64-musl@1.16.1':
optional: true
'@swc/core-win32-arm64-msvc@1.15.47':
'@swc/core-win32-arm64-msvc@1.16.1':
optional: true
'@swc/core-win32-ia32-msvc@1.15.47':
'@swc/core-win32-ia32-msvc@1.16.1':
optional: true
'@swc/core-win32-x64-msvc@1.15.47':
'@swc/core-win32-x64-msvc@1.16.1':
optional: true
'@swc/core@1.15.47':
'@swc/core@1.16.1':
dependencies:
'@swc/counter': 0.1.3
'@swc/types': 0.1.28
optionalDependencies:
'@swc/core-darwin-arm64': 1.15.47
'@swc/core-darwin-x64': 1.15.47
'@swc/core-linux-arm-gnueabihf': 1.15.47
'@swc/core-linux-arm64-gnu': 1.15.47
'@swc/core-linux-arm64-musl': 1.15.47
'@swc/core-linux-ppc64-gnu': 1.15.47
'@swc/core-linux-s390x-gnu': 1.15.47
'@swc/core-linux-x64-gnu': 1.15.47
'@swc/core-linux-x64-musl': 1.15.47
'@swc/core-win32-arm64-msvc': 1.15.47
'@swc/core-win32-ia32-msvc': 1.15.47
'@swc/core-win32-x64-msvc': 1.15.47
'@swc/core-darwin-arm64': 1.16.1
'@swc/core-darwin-x64': 1.16.1
'@swc/core-linux-arm-gnueabihf': 1.16.1
'@swc/core-linux-arm64-gnu': 1.16.1
'@swc/core-linux-arm64-musl': 1.16.1
'@swc/core-linux-ppc64-gnu': 1.16.1
'@swc/core-linux-s390x-gnu': 1.16.1
'@swc/core-linux-x64-gnu': 1.16.1
'@swc/core-linux-x64-musl': 1.16.1
'@swc/core-win32-arm64-msvc': 1.16.1
'@swc/core-win32-ia32-msvc': 1.16.1
'@swc/core-win32-x64-msvc': 1.16.1
'@swc/counter@0.1.3': {}