mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
18 lines
617 B
TypeScript
18 lines
617 B
TypeScript
import { toASCII } from 'punycode';
|
|
import { createMemoizedPromise } from './memo-promise';
|
|
import { getPublicSuffixListTextPromise } from './download-publicsuffixlist';
|
|
|
|
const customFetch = (url: string | URL): Promise<Blob> => Promise.resolve(Bun.file(url));
|
|
|
|
export const getGorhillPublicSuffixPromise = createMemoizedPromise(async () => {
|
|
const [publicSuffixListDat, { default: gorhill }] = await Promise.all([
|
|
getPublicSuffixListTextPromise(),
|
|
import('@gorhill/publicsuffixlist')
|
|
]);
|
|
|
|
gorhill.parse(publicSuffixListDat, toASCII);
|
|
await gorhill.enableWASM({ customFetch });
|
|
|
|
return gorhill;
|
|
});
|