mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Add ts-check to build script
This commit is contained in:
parent
a1cccf9c88
commit
9a307709a5
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
const { fetch } = require('undici');
|
const { fetch } = require('undici');
|
||||||
const fetchWithRetry = require('@vercel/fetch-retry')(fetch);
|
const fetchWithRetry = require('@vercel/fetch-retry')(fetch);
|
||||||
module.exports.fetchWithRetry = fetchWithRetry;
|
module.exports.fetchWithRetry = fetchWithRetry;
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
|
// @ts-check
|
||||||
const { parse } = require('tldts');
|
const { parse } = require('tldts');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} domain
|
||||||
|
*/
|
||||||
module.exports.isDomainLoose = (domain) => {
|
module.exports.isDomainLoose = (domain) => {
|
||||||
const { isIcann, isPrivate, isIp } = parse(domain, { allowPrivateDomains: true });
|
const { isIcann, isPrivate, isIp } = parse(domain, { allowPrivateDomains: true });
|
||||||
return !!(!isIp && (isIcann || isPrivate));
|
return !!(!isIp && (isIcann || isPrivate));
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @param {string} domain
|
||||||
|
*/
|
||||||
module.exports.normalizeDomain = (domain) => {
|
module.exports.normalizeDomain = (domain) => {
|
||||||
if (domain == null) {
|
if (domain == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
const { fetchWithRetry } = require('./fetch-retry');
|
const { fetchWithRetry } = require('./fetch-retry');
|
||||||
const { NetworkFilter } = require('@cliqz/adblocker');
|
const { NetworkFilter } = require('@cliqz/adblocker');
|
||||||
const { normalizeDomain } = require('./is-domain-loose');
|
const { normalizeDomain } = require('./is-domain-loose');
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
/** @type {[string, boolean][]} */
|
/** @type {[string, boolean][]} */
|
||||||
const HOSTS = [
|
const HOSTS = [
|
||||||
['https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext', true],
|
['https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext', true],
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
|
// @ts-check
|
||||||
const { promises: fsPromises } = require('fs');
|
const { promises: fsPromises } = require('fs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string[]} linesA
|
||||||
|
* @param {string} filePath
|
||||||
|
*/
|
||||||
async function compareAndWriteFile(linesA, filePath) {
|
async function compareAndWriteFile(linesA, filePath) {
|
||||||
const linesB = (await fsPromises.readFile(filePath, { encoding: 'utf-8' })).split('\n');
|
const linesB = (await fsPromises.readFile(filePath, { encoding: 'utf-8' })).split('\n');
|
||||||
|
|
||||||
@ -14,6 +19,10 @@ async function compareAndWriteFile(linesA, filePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string[]} linesA
|
||||||
|
* @param {string[]} linesB
|
||||||
|
*/
|
||||||
function stringArrayCompare (linesA, linesB) {
|
function stringArrayCompare (linesA, linesB) {
|
||||||
if (linesA.length !== linesB.length) return false;
|
if (linesA.length !== linesB.length) return false;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} title
|
* @param {string} title
|
||||||
* @param {string[]} description
|
* @param {string[]} description
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-check
|
||||||
const Piscina = require('piscina');
|
const Piscina = require('piscina');
|
||||||
// const { isCI } = require('ci-info');
|
// const { isCI } = require('ci-info');
|
||||||
|
|
||||||
@ -5,7 +6,9 @@ const fullsetDomainStartsWithADot = Piscina.workerData
|
|||||||
const totalLen = fullsetDomainStartsWithADot.length;
|
const totalLen = fullsetDomainStartsWithADot.length;
|
||||||
|
|
||||||
// const log = isCI ? () => { } : console.log.bind(console);
|
// const log = isCI ? () => { } : console.log.bind(console);
|
||||||
|
/**
|
||||||
|
* @param {{ chunk: string[] }} param0
|
||||||
|
*/
|
||||||
module.exports = ({ chunk }) => {
|
module.exports = ({ chunk }) => {
|
||||||
const chunkLength = chunk.length;
|
const chunkLength = chunk.length;
|
||||||
const outputToBeRemoved = new Int8Array(chunkLength);
|
const outputToBeRemoved = new Int8Array(chunkLength);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user