import { type Stats } from 'node:fs'; import type { OutgoingHttpHeaders } from 'node:http'; import { NLogger, Request } from '@lzwme/fe-utils'; import type { M3u8ByteRange } from '../types/m3u8.js'; export declare const request: Request; /** 判断 HTTP 状态码是否成功。使用 Range 请求(byte-range 分片)时服务端通常返回 206 */ export declare function isOkStatus(statusCode?: number): boolean; /** * 追加 Range 请求头,用于支持 `EXT-X-BYTERANGE` 字节区间寻址的分片 */ export declare function withRangeHeader(headers: OutgoingHttpHeaders | string | undefined, byterange?: M3u8ByteRange): string | OutgoingHttpHeaders; /** * 按字节区间截取数据。 * 部分服务端会忽略 Range 请求并返回完整文件,此时需要按偏移量截取 */ export declare function sliceByterange(buffer: T, byterange?: M3u8ByteRange): Buffer; /** * 补全缺失的协议头,如 `www.example.com/a` → `https://www.example.com/a` */ export declare function ensureProtocol(url: string): string; /** * 规范化重定向地址。 * * 服务端返回的 `Location` 可能是相对路径(如 B 站 301 到 `/video/BVxxx/`), * 直接使用会丢失协议与域名,必须按当前地址解析后再请求。 */ export declare function resolveRedirectUrl(location: string, base: string): string; export declare const getRetry: (url: string, headers?: OutgoingHttpHeaders | string, retries?: number) => Promise<{ data: T; buffer: Buffer; headers: import("node:http").IncomingHttpHeaders; response: import("node:http").IncomingMessage; }>; export declare const logger: NLogger; export declare function isSupportFfmpeg(ffmpegBin: string): boolean; export declare function findFiles(apidir?: string, validate?: (filepath: string, stat: Stats) => boolean): string[]; /** 获取重定向后的 URL */ export declare function getLocation(url: string, method?: string, depth?: number): Promise; /** * 将传入的 headers 转换为统一的小写键对象格式 * 如果 headers 是字符串,会先将其解析为对象;如果 headers 为空,则返回空对象。 */ export declare function formatHeaders(headers: string | OutgoingHttpHeaders): Record; /** * 解析最终生效的请求头 * * 任务显式提供了 headers(含空串)时以任务为准,否则回退到全局默认请求头。 * 这样任务清空请求头即表示「不使用默认请求头」,与「未填写时回退默认」区分开。 * 空值请求头会被过滤,避免下发无意义的空串。 */ export declare function resolveHeaders(taskHeaders?: OutgoingHttpHeaders | string | null, defaultHeaders?: OutgoingHttpHeaders | string): { [k: string]: string; }; /** * 将请求头转换为 `Key: Value` 换行分隔的文本 * * 用于配置的持久化与前端展示,避免同一份请求头出现对象/字符串两种形态 */ export declare function headersToText(headers?: OutgoingHttpHeaders | string): string; /** 异步检查文件是否存在 */ export declare function checkFileExists(filepath: string): Promise;