Feat: ImageRequestInit (#979)

* add ImageRequestInit & fix Hako

* remove multisrc fetchFile

* remove plugins fetchFile

* update docs and template file
This commit is contained in:
nyagami
2024-06-08 20:09:33 +07:00
committed by GitHub
parent 6062f51460
commit 60d95fb8d2
85 changed files with 441 additions and 692 deletions
+9 -2
View File
@@ -4,6 +4,7 @@ import path from 'path';
import { PluginList } from '@typings/types';
import { Plugin } from '@typings/plugin';
import { Filters } from '@libs/filterInputs';
import { fetchFile } from '@libs/fetch';
const root = path.dirname(require?.main?.filename || '');
export const fetchHeaders: Record<string, string> = {};
@@ -83,8 +84,14 @@ export const parseChapter = async (
chapterPath: string,
) => (await getPlugin(pluginRequirePath))?.parseChapter(chapterPath);
export const fetchImage = async (pluginRequirePath: string, url: string) =>
(await getPlugin(pluginRequirePath))?.fetchImage(url);
export const fetchImage = async (pluginRequirePath: string, url: string) => {
const plugin = await getPlugin(pluginRequirePath);
return fetchFile(url, {
method: plugin?.imageRequestInit?.method,
headers: plugin?.imageRequestInit?.headers,
body: plugin?.imageRequestInit?.body,
});
};
export const resolveUrl = async (
pluginRequirePath: string,