mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Use undici fetch
This commit is contained in:
@@ -7,7 +7,7 @@ import process from 'node:process';
|
||||
|
||||
import { exec } from 'tinyexec';
|
||||
import { mkdirp } from './misc';
|
||||
import { $fetch } from './make-fetch-happen';
|
||||
import { $$fetch } from './fetch-retry';
|
||||
|
||||
const mihomoBinaryDir = path.join(__dirname, '../../node_modules/.cache/mihomo');
|
||||
const mihomoBinaryPath = path.join(mihomoBinaryDir, 'mihomo');
|
||||
@@ -32,7 +32,7 @@ async function ensureMihomoBinary() {
|
||||
throw new Error(`Unsupported platform: ${process.platform} ${process.arch}`);
|
||||
}
|
||||
|
||||
const res = await $fetch(downloadUrl);
|
||||
const res = await $$fetch(downloadUrl);
|
||||
|
||||
if (!res.ok || !res.body) {
|
||||
throw new Error(`Failed to download mihomo binary: ${res.statusText}`);
|
||||
|
||||
@@ -8,8 +8,8 @@ import { TextLineStream } from './text-line-transform-stream';
|
||||
import type { ReadableStream } from 'node:stream/web';
|
||||
import { TextDecoderStream } from 'node:stream/web';
|
||||
import { processLine, ProcessLineStream } from './process-line';
|
||||
import { $fetch } from './make-fetch-happen';
|
||||
import type { NodeFetchResponse } from './make-fetch-happen';
|
||||
import { $$fetch } from './fetch-retry';
|
||||
import type { UndiciResponseData } from './fetch-retry';
|
||||
import type { Response as UnidiciWebResponse } from 'undici';
|
||||
|
||||
@@ -70,7 +70,7 @@ export const createReadlineInterfaceFromResponse: ((resp: NodeFetchResponse | Un
|
||||
};
|
||||
|
||||
export function fetchRemoteTextByLine(url: string, processLine = false): Promise<AsyncIterable<string>> {
|
||||
return $fetch(url).then(resp => createReadlineInterfaceFromResponse(resp, processLine));
|
||||
return $$fetch(url).then(resp => createReadlineInterfaceFromResponse(resp, processLine));
|
||||
}
|
||||
|
||||
export async function readFileIntoProcessedArray(file: string /* | FileHandle */) {
|
||||
|
||||
Reference in New Issue
Block a user