feedscout 1.8.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/blogrolls/extractors.d.ts +2 -2
- package/dist/blogrolls/extractors.js +2 -2
- package/dist/blogrolls/index.js +4 -5
- package/dist/blogrolls.d.ts +2 -2
- package/dist/blogrolls.js +2 -2
- package/dist/common/discover/defaults.d.ts +6 -0
- package/dist/common/discover/defaults.js +44 -0
- package/dist/common/discover/index.js +2 -2
- package/dist/common/discover/utils.d.ts +3 -6
- package/dist/common/discover/utils.js +1 -28
- package/dist/common/locales.js +214 -10
- package/dist/common/types.d.ts +3 -2
- package/dist/common/uris/feed/types.d.ts +2 -2
- package/dist/common/uris/html/types.d.ts +4 -4
- package/dist/common/utils.d.ts +6 -4
- package/dist/common/utils.js +13 -11
- package/dist/favicons/extractors.d.ts +2 -2
- package/dist/favicons/extractors.js +2 -2
- package/dist/favicons/index.js +4 -5
- package/dist/favicons.d.ts +2 -2
- package/dist/favicons.js +2 -2
- package/dist/feeds/defaults.d.ts +2 -1
- package/dist/feeds/defaults.js +116 -9
- package/dist/feeds/extractors.d.ts +2 -2
- package/dist/feeds/extractors.js +6 -6
- package/dist/feeds/index.js +4 -5
- package/dist/feeds/platform/handlers/acast.js +26 -0
- package/dist/feeds/platform/handlers/ameblo.js +36 -0
- package/dist/feeds/platform/handlers/applePodcasts.js +1 -1
- package/dist/feeds/platform/handlers/arena.js +42 -0
- package/dist/feeds/platform/handlers/artstation.js +52 -0
- package/dist/feeds/platform/handlers/audioboom.js +23 -0
- package/dist/feeds/platform/handlers/bearblog.js +45 -0
- package/dist/feeds/platform/handlers/behance.js +7 -0
- package/dist/feeds/platform/handlers/blogspot.js +38 -2
- package/dist/feeds/platform/handlers/bookwyrm.js +48 -0
- package/dist/feeds/platform/handlers/buttondown.js +43 -0
- package/dist/feeds/platform/handlers/buzzsprout.js +22 -0
- package/dist/feeds/platform/handlers/codeberg.js +5 -5
- package/dist/feeds/platform/handlers/dailymotion.js +16 -0
- package/dist/feeds/platform/handlers/deviantart.js +25 -6
- package/dist/feeds/platform/handlers/devto.js +8 -0
- package/dist/feeds/platform/handlers/discourse.js +70 -0
- package/dist/feeds/platform/handlers/dreamwidth.js +48 -0
- package/dist/feeds/platform/handlers/exblog.js +35 -0
- package/dist/feeds/platform/handlers/fireside.js +24 -0
- package/dist/feeds/platform/handlers/friendica.js +44 -0
- package/dist/feeds/platform/handlers/ghost.js +30 -0
- package/dist/feeds/platform/handlers/github.js +6 -0
- package/dist/feeds/platform/handlers/githubGist.js +16 -5
- package/dist/feeds/platform/handlers/gitlab.js +31 -13
- package/dist/feeds/platform/handlers/goodreads.js +18 -8
- package/dist/feeds/platform/handlers/hackernews.js +21 -0
- package/dist/feeds/platform/handlers/hashnode.js +1 -1
- package/dist/feeds/platform/handlers/hatenablog.js +4 -1
- package/dist/feeds/platform/handlers/hearthis.js +32 -0
- package/dist/feeds/platform/handlers/heyWorld.js +18 -0
- package/dist/feeds/platform/handlers/insanejournal.js +69 -0
- package/dist/feeds/platform/handlers/itchio.js +24 -1
- package/dist/feeds/platform/handlers/lemmy.js +46 -4
- package/dist/feeds/platform/handlers/letterboxd.js +4 -0
- package/dist/feeds/platform/handlers/libsyn.js +25 -0
- package/dist/feeds/platform/handlers/listed.js +20 -0
- package/dist/feeds/platform/handlers/livejournal.js +68 -0
- package/dist/feeds/platform/handlers/mastodon.js +32 -0
- package/dist/feeds/platform/handlers/mataroa.js +16 -0
- package/dist/feeds/platform/handlers/medium.js +2 -2
- package/dist/feeds/platform/handlers/microblog.js +55 -0
- package/dist/feeds/platform/handlers/misskey.js +40 -0
- package/dist/feeds/platform/handlers/myanimelist.js +43 -0
- package/dist/feeds/platform/handlers/naverBlog.js +21 -0
- package/dist/feeds/platform/handlers/nebula.js +68 -0
- package/dist/feeds/platform/handlers/note.js +53 -0
- package/dist/feeds/platform/handlers/observable.js +34 -0
- package/dist/feeds/platform/handlers/odysee.js +20 -0
- package/dist/feeds/platform/handlers/pagecord.js +16 -0
- package/dist/feeds/platform/handlers/paragraph.js +1 -2
- package/dist/feeds/platform/handlers/pika.js +35 -0
- package/dist/feeds/platform/handlers/pinterest.js +13 -0
- package/dist/feeds/platform/handlers/pixelfed.js +46 -0
- package/dist/feeds/platform/handlers/pleroma.js +34 -0
- package/dist/feeds/platform/handlers/podbean.js +29 -0
- package/dist/feeds/platform/handlers/podigee.js +29 -0
- package/dist/feeds/platform/handlers/posthaven.js +24 -0
- package/dist/feeds/platform/handlers/prose.js +26 -0
- package/dist/feeds/platform/handlers/qiita.js +58 -0
- package/dist/feeds/platform/handlers/reddit.js +83 -9
- package/dist/feeds/platform/handlers/rssCom.js +20 -0
- package/dist/feeds/platform/handlers/seesaa.js +22 -0
- package/dist/feeds/platform/handlers/sourceforge.js +37 -4
- package/dist/feeds/platform/handlers/spreaker.js +21 -0
- package/dist/feeds/platform/handlers/stackExchange.js +26 -2
- package/dist/feeds/platform/handlers/steam.js +7 -0
- package/dist/feeds/platform/handlers/tildes.js +41 -0
- package/dist/feeds/platform/handlers/tistory.js +16 -0
- package/dist/feeds/platform/handlers/transistor.js +29 -0
- package/dist/feeds/platform/handlers/velog.js +24 -0
- package/dist/feeds/platform/handlers/vimeo.js +6 -0
- package/dist/feeds/platform/handlers/weblogLol.js +26 -0
- package/dist/feeds/platform/handlers/weebly.js +25 -0
- package/dist/feeds/platform/handlers/wordpress.js +173 -28
- package/dist/feeds/platform/handlers/writeas.js +51 -0
- package/dist/feeds/platform/handlers/ximalaya.js +1 -1
- package/dist/feeds/platform/handlers/youtube.js +4 -1
- package/dist/feeds/platform/handlers/zenn.js +54 -0
- package/dist/feeds.d.ts +3 -3
- package/dist/feeds.js +3 -3
- package/dist/hubs/discover/index.js +3 -3
- package/dist/hubs/feed/index.js +2 -2
- package/dist/hubs/headers/index.js +2 -2
- package/dist/hubs/html/index.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/utils.d.ts +2 -1
- package/package.json +24 -64
- package/dist/blogrolls/defaults.cjs +0 -51
- package/dist/blogrolls/defaults.d.cts +0 -17
- package/dist/blogrolls/extractors.cjs +0 -21
- package/dist/blogrolls/extractors.d.cts +0 -7
- package/dist/blogrolls/index.cjs +0 -26
- package/dist/blogrolls/index.d.cts +0 -7
- package/dist/blogrolls/types.d.cts +0 -6
- package/dist/blogrolls.cjs +0 -13
- package/dist/blogrolls.d.cts +0 -4
- package/dist/common/discover/index.cjs +0 -105
- package/dist/common/discover/utils.cjs +0 -130
- package/dist/common/discover/utils.d.cts +0 -8
- package/dist/common/locales.cjs +0 -144
- package/dist/common/types.cjs +0 -10
- package/dist/common/types.d.cts +0 -89
- package/dist/common/uris/feed/index.cjs +0 -12
- package/dist/common/uris/feed/index.d.cts +0 -6
- package/dist/common/uris/feed/types.d.cts +0 -9
- package/dist/common/uris/guess/index.cjs +0 -8
- package/dist/common/uris/guess/index.d.cts +0 -7
- package/dist/common/uris/guess/types.d.cts +0 -10
- package/dist/common/uris/guess/utils.cjs +0 -42
- package/dist/common/uris/guess/utils.d.cts +0 -8
- package/dist/common/uris/headers/index.cjs +0 -26
- package/dist/common/uris/headers/index.d.cts +0 -6
- package/dist/common/uris/headers/types.d.cts +0 -9
- package/dist/common/uris/html/handlers.cjs +0 -45
- package/dist/common/uris/html/index.cjs +0 -19
- package/dist/common/uris/html/index.d.cts +0 -6
- package/dist/common/uris/html/types.d.cts +0 -12
- package/dist/common/uris/index.cjs +0 -32
- package/dist/common/uris/platform/index.cjs +0 -10
- package/dist/common/uris/platform/index.d.cts +0 -7
- package/dist/common/uris/platform/types.d.cts +0 -13
- package/dist/common/utils.cjs +0 -97
- package/dist/common/utils.d.cts +0 -10
- package/dist/favicons/defaults.cjs +0 -65
- package/dist/favicons/defaults.d.cts +0 -18
- package/dist/favicons/extractors.cjs +0 -25
- package/dist/favicons/extractors.d.cts +0 -7
- package/dist/favicons/index.cjs +0 -30
- package/dist/favicons/index.d.cts +0 -7
- package/dist/favicons/platform/handlers/bluesky.cjs +0 -27
- package/dist/favicons/platform/handlers/codeberg.cjs +0 -19
- package/dist/favicons/platform/handlers/deviantart.cjs +0 -29
- package/dist/favicons/platform/handlers/devto.cjs +0 -31
- package/dist/favicons/platform/handlers/github.cjs +0 -19
- package/dist/favicons/platform/handlers/githubGist.cjs +0 -19
- package/dist/favicons/platform/handlers/gitlab.cjs +0 -38
- package/dist/favicons/platform/handlers/lobsters.cjs +0 -21
- package/dist/favicons/platform/handlers/mastodon.cjs +0 -40
- package/dist/favicons/platform/handlers/reddit.cjs +0 -42
- package/dist/favicons/platform/handlers/sourceforge.cjs +0 -21
- package/dist/favicons/platform/handlers/tumblr.cjs +0 -16
- package/dist/favicons/types.d.cts +0 -4
- package/dist/favicons/utils.cjs +0 -10
- package/dist/favicons.cjs +0 -12
- package/dist/favicons.d.cts +0 -4
- package/dist/feeds/defaults.cjs +0 -178
- package/dist/feeds/defaults.d.cts +0 -20
- package/dist/feeds/extractors.cjs +0 -46
- package/dist/feeds/extractors.d.cts +0 -7
- package/dist/feeds/index.cjs +0 -27
- package/dist/feeds/index.d.cts +0 -7
- package/dist/feeds/platform/handlers/applePodcasts.cjs +0 -26
- package/dist/feeds/platform/handlers/behance.cjs +0 -49
- package/dist/feeds/platform/handlers/blogspot.cjs +0 -36
- package/dist/feeds/platform/handlers/bluesky.cjs +0 -20
- package/dist/feeds/platform/handlers/codeberg.cjs +0 -69
- package/dist/feeds/platform/handlers/csdn.cjs +0 -20
- package/dist/feeds/platform/handlers/dailymotion.cjs +0 -70
- package/dist/feeds/platform/handlers/deviantart.cjs +0 -66
- package/dist/feeds/platform/handlers/devto.cjs +0 -50
- package/dist/feeds/platform/handlers/douban.cjs +0 -56
- package/dist/feeds/platform/handlers/github.cjs +0 -116
- package/dist/feeds/platform/handlers/githubGist.cjs +0 -45
- package/dist/feeds/platform/handlers/gitlab.cjs +0 -80
- package/dist/feeds/platform/handlers/goodreads.cjs +0 -39
- package/dist/feeds/platform/handlers/hashnode.cjs +0 -16
- package/dist/feeds/platform/handlers/hatenablog.cjs +0 -53
- package/dist/feeds/platform/handlers/itchio.cjs +0 -88
- package/dist/feeds/platform/handlers/kickstarter.cjs +0 -22
- package/dist/feeds/platform/handlers/lemmy.cjs +0 -46
- package/dist/feeds/platform/handlers/letterboxd.cjs +0 -42
- package/dist/feeds/platform/handlers/lobsters.cjs +0 -57
- package/dist/feeds/platform/handlers/mastodon.cjs +0 -42
- package/dist/feeds/platform/handlers/medium.cjs +0 -68
- package/dist/feeds/platform/handlers/paragraph.cjs +0 -21
- package/dist/feeds/platform/handlers/pinterest.cjs +0 -44
- package/dist/feeds/platform/handlers/producthunt.cjs +0 -29
- package/dist/feeds/platform/handlers/reddit.cjs +0 -75
- package/dist/feeds/platform/handlers/soundcloud.cjs +0 -39
- package/dist/feeds/platform/handlers/sourceforge.cjs +0 -20
- package/dist/feeds/platform/handlers/stackExchange.cjs +0 -40
- package/dist/feeds/platform/handlers/steam.cjs +0 -28
- package/dist/feeds/platform/handlers/substack.cjs +0 -23
- package/dist/feeds/platform/handlers/tumblr.cjs +0 -24
- package/dist/feeds/platform/handlers/v2ex.cjs +0 -35
- package/dist/feeds/platform/handlers/vimeo.cjs +0 -69
- package/dist/feeds/platform/handlers/wordpress.cjs +0 -64
- package/dist/feeds/platform/handlers/wpengine.cjs +0 -10
- package/dist/feeds/platform/handlers/ximalaya.cjs +0 -20
- package/dist/feeds/platform/handlers/youtube.cjs +0 -94
- package/dist/feeds/types.d.cts +0 -9
- package/dist/feeds.cjs +0 -15
- package/dist/feeds.d.cts +0 -4
- package/dist/hubs/discover/index.cjs +0 -30
- package/dist/hubs/discover/index.d.cts +0 -7
- package/dist/hubs/discover/types.d.cts +0 -15
- package/dist/hubs/feed/index.cjs +0 -32
- package/dist/hubs/headers/index.cjs +0 -17
- package/dist/hubs/html/index.cjs +0 -28
- package/dist/hubs.cjs +0 -0
- package/dist/hubs.d.cts +0 -2
- package/dist/index.cjs +0 -12
- package/dist/index.d.cts +0 -7
- package/dist/methods.cjs +0 -15
- package/dist/methods.d.cts +0 -7
- package/dist/utils.cjs +0 -9
- package/dist/utils.d.cts +0 -2
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/common/uris/platform/index.ts
|
|
2
|
-
const discoverUrisFromPlatform = async (content, headers, options, fetchFn) => {
|
|
3
|
-
const { baseUrl, handlers } = options;
|
|
4
|
-
for (const handler of handlers) try {
|
|
5
|
-
if (handler.match(baseUrl, content, headers)) return await handler.resolve(baseUrl, content, headers, fetchFn);
|
|
6
|
-
} catch {}
|
|
7
|
-
return [];
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
10
|
-
exports.discoverUrisFromPlatform = discoverUrisFromPlatform;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PlatformMethodOptions } from "./types.cjs";
|
|
2
|
-
import { DiscoverFetchFn, DiscoverUriEntry } from "../../types.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/common/uris/platform/index.d.ts
|
|
5
|
-
declare const discoverUrisFromPlatform: (content: string | undefined, headers: Headers | undefined, options: PlatformMethodOptions, fetchFn?: DiscoverFetchFn) => Promise<Array<DiscoverUriEntry>>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { discoverUrisFromPlatform };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DiscoverFetchFn, DiscoverUriEntry, MaybePromise } from "../../types.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/common/uris/platform/types.d.ts
|
|
4
|
-
type PlatformHandler = {
|
|
5
|
-
match: (url: string, content?: string, headers?: Headers) => boolean;
|
|
6
|
-
resolve: (url: string, content?: string, headers?: Headers, fetchFn?: DiscoverFetchFn) => MaybePromise<Array<DiscoverUriEntry>>;
|
|
7
|
-
};
|
|
8
|
-
type PlatformMethodOptions = {
|
|
9
|
-
baseUrl: string;
|
|
10
|
-
handlers: Array<PlatformHandler>;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { PlatformMethodOptions };
|
package/dist/common/utils.cjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
const require_locales = require("./locales.cjs");
|
|
2
|
-
//#region src/common/utils.ts
|
|
3
|
-
const whitespaceRegex = /\s+/;
|
|
4
|
-
const composeHint = (key) => ({
|
|
5
|
-
key,
|
|
6
|
-
label: require_locales.hints[key]
|
|
7
|
-
});
|
|
8
|
-
const normalizeMimeType = (type) => {
|
|
9
|
-
return type.split(";")[0].trim().toLowerCase();
|
|
10
|
-
};
|
|
11
|
-
const isSubdomainOf = (url, domains) => {
|
|
12
|
-
try {
|
|
13
|
-
const hostname = new URL(url).hostname.toLowerCase();
|
|
14
|
-
return (Array.isArray(domains) ? domains : [domains]).some((domain) => hostname.endsWith(`.${domain}`));
|
|
15
|
-
} catch {}
|
|
16
|
-
return false;
|
|
17
|
-
};
|
|
18
|
-
const isHostOf = (url, hosts) => {
|
|
19
|
-
try {
|
|
20
|
-
const list = Array.isArray(hosts) ? hosts : [hosts];
|
|
21
|
-
return isAnyOf(new URL(url).hostname, list);
|
|
22
|
-
} catch {}
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
25
|
-
const includesAnyOf = (value, patterns, parser) => {
|
|
26
|
-
const parsedValue = parser ? parser(value) : value?.toLowerCase();
|
|
27
|
-
return patterns.some((pattern) => pattern && parsedValue?.includes(pattern.toLowerCase()));
|
|
28
|
-
};
|
|
29
|
-
const isAnyOf = (value, patterns, parser) => {
|
|
30
|
-
const parsedValue = parser ? parser(value) : value?.toLowerCase()?.trim();
|
|
31
|
-
return patterns.some((pattern) => parsedValue === pattern.toLowerCase().trim());
|
|
32
|
-
};
|
|
33
|
-
const anyWordMatchesAnyOf = (value, patterns) => {
|
|
34
|
-
return value.toLowerCase().split(whitespaceRegex).some((word) => isAnyOf(word, patterns));
|
|
35
|
-
};
|
|
36
|
-
const endsWithAnyOf = (value, patterns) => {
|
|
37
|
-
const lowerValue = value.toLowerCase();
|
|
38
|
-
return patterns.some((pattern) => pattern && lowerValue.endsWith(pattern.toLowerCase()));
|
|
39
|
-
};
|
|
40
|
-
const isOfAllowedMimeType = (type, allowedTypes) => {
|
|
41
|
-
if (allowedTypes.length === 0) return true;
|
|
42
|
-
if (!type) return false;
|
|
43
|
-
return isAnyOf(type, allowedTypes, normalizeMimeType);
|
|
44
|
-
};
|
|
45
|
-
const hasMetaContent = (content, name, value) => {
|
|
46
|
-
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
47
|
-
const escapedValue = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
48
|
-
return new RegExp(`<meta(?=[^>]*(?:name|property)=["']${escapedName}["'])(?=[^>]*content=["']${escapedValue})`, "i").test(content);
|
|
49
|
-
};
|
|
50
|
-
const omitEmpty = (array) => {
|
|
51
|
-
const result = [];
|
|
52
|
-
for (const item of array) if (item != null && item !== "") result.push(item);
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
55
|
-
const resolveUrl = (url, baseUrl) => {
|
|
56
|
-
try {
|
|
57
|
-
return new URL(url, baseUrl).href;
|
|
58
|
-
} catch {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const matchesAnyOfLinkSelectors = (rel, type, selectors) => {
|
|
63
|
-
return selectors.some((selector) => {
|
|
64
|
-
if (!anyWordMatchesAnyOf(rel, [selector.rel])) return false;
|
|
65
|
-
if (!selector.types) return true;
|
|
66
|
-
return isOfAllowedMimeType(type, selector.types);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
const processConcurrently = async (items, processFn, options) => {
|
|
70
|
-
if (options.concurrency < 1) return;
|
|
71
|
-
const active = /* @__PURE__ */ new Set();
|
|
72
|
-
let index = 0;
|
|
73
|
-
while (index < items.length || active.size > 0) {
|
|
74
|
-
if (options.shouldStop?.()) break;
|
|
75
|
-
while (active.size < options.concurrency && index < items.length) {
|
|
76
|
-
const item = items[index++];
|
|
77
|
-
const promise = processFn(item).catch(() => {}).finally(() => {
|
|
78
|
-
active.delete(promise);
|
|
79
|
-
});
|
|
80
|
-
active.add(promise);
|
|
81
|
-
}
|
|
82
|
-
if (active.size > 0) await Promise.race(active);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
//#endregion
|
|
86
|
-
exports.anyWordMatchesAnyOf = anyWordMatchesAnyOf;
|
|
87
|
-
exports.composeHint = composeHint;
|
|
88
|
-
exports.endsWithAnyOf = endsWithAnyOf;
|
|
89
|
-
exports.hasMetaContent = hasMetaContent;
|
|
90
|
-
exports.includesAnyOf = includesAnyOf;
|
|
91
|
-
exports.isAnyOf = isAnyOf;
|
|
92
|
-
exports.isHostOf = isHostOf;
|
|
93
|
-
exports.isSubdomainOf = isSubdomainOf;
|
|
94
|
-
exports.matchesAnyOfLinkSelectors = matchesAnyOfLinkSelectors;
|
|
95
|
-
exports.omitEmpty = omitEmpty;
|
|
96
|
-
exports.processConcurrently = processConcurrently;
|
|
97
|
-
exports.resolveUrl = resolveUrl;
|
package/dist/common/utils.d.cts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/common/utils.d.ts
|
|
2
|
-
declare const isSubdomainOf: (url: string, domains: string | Array<string>) => boolean;
|
|
3
|
-
declare const isHostOf: (url: string, hosts: string | Array<string>) => boolean;
|
|
4
|
-
declare const includesAnyOf: (value: string, patterns: Array<string>, parser?: (value: string) => string) => boolean;
|
|
5
|
-
declare const isAnyOf: (value: string, patterns: Array<string>, parser?: (value: string) => string) => boolean;
|
|
6
|
-
declare const anyWordMatchesAnyOf: (value: string, patterns: Array<string>) => boolean;
|
|
7
|
-
declare const endsWithAnyOf: (value: string, patterns: Array<string>) => boolean;
|
|
8
|
-
declare const omitEmpty: <T>(array: Array<T | null | undefined>) => Array<T>;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { anyWordMatchesAnyOf, endsWithAnyOf, includesAnyOf, isAnyOf, isHostOf, isSubdomainOf, omitEmpty };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../common/utils.cjs");
|
|
2
|
-
const require_bluesky = require("./platform/handlers/bluesky.cjs");
|
|
3
|
-
const require_codeberg = require("./platform/handlers/codeberg.cjs");
|
|
4
|
-
const require_deviantart = require("./platform/handlers/deviantart.cjs");
|
|
5
|
-
const require_devto = require("./platform/handlers/devto.cjs");
|
|
6
|
-
const require_github = require("./platform/handlers/github.cjs");
|
|
7
|
-
const require_githubGist = require("./platform/handlers/githubGist.cjs");
|
|
8
|
-
const require_gitlab = require("./platform/handlers/gitlab.cjs");
|
|
9
|
-
const require_lobsters = require("./platform/handlers/lobsters.cjs");
|
|
10
|
-
const require_mastodon = require("./platform/handlers/mastodon.cjs");
|
|
11
|
-
const require_reddit = require("./platform/handlers/reddit.cjs");
|
|
12
|
-
const require_sourceforge = require("./platform/handlers/sourceforge.cjs");
|
|
13
|
-
const require_tumblr = require("./platform/handlers/tumblr.cjs");
|
|
14
|
-
//#region src/favicons/defaults.ts
|
|
15
|
-
const defaultIconRels = [
|
|
16
|
-
"icon",
|
|
17
|
-
"shortcut",
|
|
18
|
-
"alternate icon",
|
|
19
|
-
"apple-touch-icon",
|
|
20
|
-
"apple-touch-icon-precomposed"
|
|
21
|
-
];
|
|
22
|
-
const defaultGuessPaths = [
|
|
23
|
-
"/favicon.ico",
|
|
24
|
-
"/apple-touch-icon.png",
|
|
25
|
-
"/apple-touch-icon-precomposed.png",
|
|
26
|
-
"/favicon.png",
|
|
27
|
-
"/favicon.svg"
|
|
28
|
-
];
|
|
29
|
-
const linkSelectors = defaultIconRels.map((rel) => ({ rel }));
|
|
30
|
-
const defaultFeedOptions = { extractUrls: ({ format, feed }) => {
|
|
31
|
-
if (format === "atom") return require_utils.omitEmpty([feed.icon]);
|
|
32
|
-
if (format === "json") return require_utils.omitEmpty([feed.favicon, feed.icon]);
|
|
33
|
-
return [];
|
|
34
|
-
} };
|
|
35
|
-
const defaultHtmlOptions = {
|
|
36
|
-
linkSelectors,
|
|
37
|
-
anchorUris: [],
|
|
38
|
-
anchorIgnoredUris: [],
|
|
39
|
-
anchorLabels: []
|
|
40
|
-
};
|
|
41
|
-
const defaultHeadersOptions = { linkSelectors };
|
|
42
|
-
const defaultGuessOptions = { uris: defaultGuessPaths };
|
|
43
|
-
const defaultPlatformOptions = { handlers: [
|
|
44
|
-
require_github.githubHandler,
|
|
45
|
-
require_githubGist.githubGistHandler,
|
|
46
|
-
require_gitlab.gitlabHandler,
|
|
47
|
-
require_mastodon.mastodonHandler,
|
|
48
|
-
require_bluesky.blueskyHandler,
|
|
49
|
-
require_reddit.redditHandler,
|
|
50
|
-
require_tumblr.tumblrHandler,
|
|
51
|
-
require_codeberg.codebergHandler,
|
|
52
|
-
require_lobsters.lobstersHandler,
|
|
53
|
-
require_sourceforge.sourceforgeHandler,
|
|
54
|
-
require_deviantart.deviantartHandler,
|
|
55
|
-
require_devto.devtoHandler
|
|
56
|
-
] };
|
|
57
|
-
//#endregion
|
|
58
|
-
exports.defaultFeedOptions = defaultFeedOptions;
|
|
59
|
-
exports.defaultGuessOptions = defaultGuessOptions;
|
|
60
|
-
exports.defaultGuessPaths = defaultGuessPaths;
|
|
61
|
-
exports.defaultHeadersOptions = defaultHeadersOptions;
|
|
62
|
-
exports.defaultHtmlOptions = defaultHtmlOptions;
|
|
63
|
-
exports.defaultIconRels = defaultIconRels;
|
|
64
|
-
exports.defaultPlatformOptions = defaultPlatformOptions;
|
|
65
|
-
exports.linkSelectors = linkSelectors;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FeedMethodOptions } from "../common/uris/feed/types.cjs";
|
|
2
|
-
import { GuessMethodOptions } from "../common/uris/guess/types.cjs";
|
|
3
|
-
import { HeadersMethodOptions } from "../common/uris/headers/types.cjs";
|
|
4
|
-
import { HtmlMethodOptions } from "../common/uris/html/types.cjs";
|
|
5
|
-
import { PlatformMethodOptions } from "../common/uris/platform/types.cjs";
|
|
6
|
-
import { LinkSelector } from "../common/types.cjs";
|
|
7
|
-
|
|
8
|
-
//#region src/favicons/defaults.d.ts
|
|
9
|
-
declare const defaultIconRels: string[];
|
|
10
|
-
declare const defaultGuessPaths: string[];
|
|
11
|
-
declare const linkSelectors: Array<LinkSelector>;
|
|
12
|
-
declare const defaultFeedOptions: FeedMethodOptions;
|
|
13
|
-
declare const defaultHtmlOptions: Omit<HtmlMethodOptions, 'baseUrl'>;
|
|
14
|
-
declare const defaultHeadersOptions: Omit<HeadersMethodOptions, 'baseUrl'>;
|
|
15
|
-
declare const defaultGuessOptions: Omit<GuessMethodOptions, 'baseUrl'>;
|
|
16
|
-
declare const defaultPlatformOptions: Omit<PlatformMethodOptions, 'baseUrl'>;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { defaultFeedOptions, defaultGuessOptions, defaultGuessPaths, defaultHeadersOptions, defaultHtmlOptions, defaultIconRels, defaultPlatformOptions, linkSelectors };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/favicons/extractors.ts
|
|
2
|
-
const isImageContentType = (headers) => {
|
|
3
|
-
return headers?.get("content-type")?.startsWith("image/") ?? false;
|
|
4
|
-
};
|
|
5
|
-
const isImageContent = (content) => {
|
|
6
|
-
if (content.includes("<html")) return false;
|
|
7
|
-
const trimmed = content.trimStart();
|
|
8
|
-
const head = trimmed.slice(0, 200);
|
|
9
|
-
return trimmed.startsWith("<svg") || trimmed.startsWith("<?xml") && head.includes("<svg") || content.slice(1, 4) === "PNG" || content.startsWith("GIF8") || content.startsWith("RIFF") && content.includes("WEBP");
|
|
10
|
-
};
|
|
11
|
-
const isSuccessStatus = (status) => {
|
|
12
|
-
return status !== void 0 && status >= 200 && status < 400;
|
|
13
|
-
};
|
|
14
|
-
const defaultExtractor = (input) => {
|
|
15
|
-
if (isImageContentType(input.headers) || isImageContent(input.content) || isSuccessStatus(input.status)) return {
|
|
16
|
-
url: input.url,
|
|
17
|
-
isValid: true
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
url: input.url,
|
|
21
|
-
isValid: false
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.defaultExtractor = defaultExtractor;
|
package/dist/favicons/index.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../common/utils.cjs");
|
|
2
|
-
const require_utils$1 = require("../common/discover/utils.cjs");
|
|
3
|
-
const require_index = require("../common/discover/index.cjs");
|
|
4
|
-
const require_defaults = require("./defaults.cjs");
|
|
5
|
-
const require_extractors = require("./extractors.cjs");
|
|
6
|
-
//#region src/favicons/index.ts
|
|
7
|
-
const discoverFavicons = (input, options = {}) => {
|
|
8
|
-
return require_index.discover(input, {
|
|
9
|
-
...options,
|
|
10
|
-
methods: options.methods ?? [
|
|
11
|
-
"platform",
|
|
12
|
-
"feed",
|
|
13
|
-
"html",
|
|
14
|
-
"headers",
|
|
15
|
-
"guess"
|
|
16
|
-
],
|
|
17
|
-
fetchFn: options.fetchFn ?? require_utils$1.defaultFetchFn,
|
|
18
|
-
extractFn: options.extractFn ?? require_extractors.defaultExtractor,
|
|
19
|
-
resolveUrlFn: options.resolveUrlFn ?? require_utils.resolveUrl,
|
|
20
|
-
resolveSiteUrlFn: options.resolveSiteUrlFn ?? require_utils$1.defaultResolveSiteUrlFn
|
|
21
|
-
}, {
|
|
22
|
-
platform: require_defaults.defaultPlatformOptions,
|
|
23
|
-
feed: require_defaults.defaultFeedOptions,
|
|
24
|
-
html: require_defaults.defaultHtmlOptions,
|
|
25
|
-
headers: require_defaults.defaultHeadersOptions,
|
|
26
|
-
guess: require_defaults.defaultGuessOptions
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
exports.discoverFavicons = discoverFavicons;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DiscoverInput, DiscoverOptions, DiscoverResult } from "../common/types.cjs";
|
|
2
|
-
import { FaviconResult } from "./types.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/favicons/index.d.ts
|
|
5
|
-
declare const discoverFavicons: <TValid extends FaviconResult = FaviconResult>(input: DiscoverInput, options?: DiscoverOptions<TValid>) => Promise<Array<DiscoverResult<TValid>>>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { discoverFavicons };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_utils$1 = require("../../utils.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/bluesky.ts
|
|
4
|
-
const hosts = ["bsky.app", "www.bsky.app"];
|
|
5
|
-
const isProfilePath = (pathname) => {
|
|
6
|
-
const segments = pathname.split("/").filter(Boolean);
|
|
7
|
-
return segments.length >= 2 && segments[0] === "profile";
|
|
8
|
-
};
|
|
9
|
-
const blueskyHandler = {
|
|
10
|
-
match: (url) => {
|
|
11
|
-
try {
|
|
12
|
-
return isProfilePath(new URL(url).pathname) && require_utils.isHostOf(url, hosts);
|
|
13
|
-
} catch {}
|
|
14
|
-
return false;
|
|
15
|
-
},
|
|
16
|
-
resolve: async (url, _content, _headers, fetchFn) => {
|
|
17
|
-
if (!fetchFn) return [];
|
|
18
|
-
try {
|
|
19
|
-
const { pathname } = new URL(url);
|
|
20
|
-
const data = require_utils$1.parseBodyJson((await fetchFn(`https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${pathname.split("/").filter(Boolean)[1]}`)).body);
|
|
21
|
-
if (require_utils$1.isNonEmptyString(data.avatar)) return [{ uri: data.avatar }];
|
|
22
|
-
} catch {}
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.blueskyHandler = blueskyHandler;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_codeberg = require("../../../feeds/platform/handlers/codeberg.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/codeberg.ts
|
|
4
|
-
const userRegex = /^\/([^/.]+)/;
|
|
5
|
-
const codebergHandler = {
|
|
6
|
-
match: (url) => {
|
|
7
|
-
return require_utils.isHostOf(url, require_codeberg.hosts);
|
|
8
|
-
},
|
|
9
|
-
resolve: (url) => {
|
|
10
|
-
const { origin, pathname } = new URL(url);
|
|
11
|
-
const match = pathname.match(userRegex);
|
|
12
|
-
if (!match?.[1]) return [];
|
|
13
|
-
const username = match[1];
|
|
14
|
-
if (require_utils.isAnyOf(username, require_codeberg.excludedPaths)) return [];
|
|
15
|
-
return [{ uri: `${origin}/user/avatar/${username}/512` }];
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.codebergHandler = codebergHandler;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_deviantart = require("../../../feeds/platform/handlers/deviantart.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/deviantart.ts
|
|
4
|
-
const deviantartHandler = {
|
|
5
|
-
match: (url) => {
|
|
6
|
-
try {
|
|
7
|
-
const { pathname } = new URL(url);
|
|
8
|
-
const segments = pathname.split("/").filter(Boolean);
|
|
9
|
-
if (!require_utils.isHostOf(url, require_deviantart.hosts) || segments.length === 0) return false;
|
|
10
|
-
if (segments[0] === "tag") return false;
|
|
11
|
-
return !require_utils.isAnyOf(segments[0], require_deviantart.excludedPaths);
|
|
12
|
-
} catch {}
|
|
13
|
-
return false;
|
|
14
|
-
},
|
|
15
|
-
resolve: (url) => {
|
|
16
|
-
const { pathname } = new URL(url);
|
|
17
|
-
const segments = pathname.split("/").filter(Boolean);
|
|
18
|
-
if (segments.length === 0 || segments[0] === "tag") return [];
|
|
19
|
-
const username = segments[0].toLowerCase();
|
|
20
|
-
if (require_utils.isAnyOf(username, require_deviantart.excludedPaths) || username.length < 2) return [];
|
|
21
|
-
return [
|
|
22
|
-
`https://a.deviantart.net/avatars-big/${username[0]}/${username[1]}/${username}.jpg`,
|
|
23
|
-
`https://a.deviantart.net/avatars-big/${username[0]}/${username[1]}/${username}.gif`,
|
|
24
|
-
`https://a.deviantart.net/avatars-big/${username[0]}/${username[1]}/${username}.png`
|
|
25
|
-
].map((value) => ({ uri: value }));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
exports.deviantartHandler = deviantartHandler;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_utils$1 = require("../../utils.cjs");
|
|
3
|
-
const require_devto = require("../../../feeds/platform/handlers/devto.cjs");
|
|
4
|
-
//#region src/favicons/platform/handlers/devto.ts
|
|
5
|
-
const userRegex = /^\/([^/.]+)/;
|
|
6
|
-
const devtoHandler = {
|
|
7
|
-
match: (url) => {
|
|
8
|
-
try {
|
|
9
|
-
const { pathname } = new URL(url);
|
|
10
|
-
const match = pathname.match(userRegex);
|
|
11
|
-
if (!require_utils.isHostOf(url, require_devto.hosts) || !match?.[1]) return false;
|
|
12
|
-
if (match[1] === "t") return false;
|
|
13
|
-
return !require_utils.isAnyOf(match[1], require_devto.excludedPaths);
|
|
14
|
-
} catch {}
|
|
15
|
-
return false;
|
|
16
|
-
},
|
|
17
|
-
resolve: async (url, _content, _headers, fetchFn) => {
|
|
18
|
-
if (!fetchFn) return [];
|
|
19
|
-
try {
|
|
20
|
-
const { pathname } = new URL(url);
|
|
21
|
-
const match = pathname.match(userRegex);
|
|
22
|
-
if (!match?.[1] || match[1] === "t") return [];
|
|
23
|
-
const username = match[1];
|
|
24
|
-
const profileImage = require_utils$1.parseBodyJson((await fetchFn(`https://dev.to/api/users/by_username?url=${encodeURIComponent(username)}`)).body)?.profile_image;
|
|
25
|
-
if (require_utils$1.isNonEmptyString(profileImage)) return [{ uri: profileImage }];
|
|
26
|
-
} catch {}
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
exports.devtoHandler = devtoHandler;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_github = require("../../../feeds/platform/handlers/github.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/github.ts
|
|
4
|
-
const userRegex = /^\/([^/.]+)/;
|
|
5
|
-
const githubHandler = {
|
|
6
|
-
match: (url) => {
|
|
7
|
-
return require_utils.isHostOf(url, require_github.hosts);
|
|
8
|
-
},
|
|
9
|
-
resolve: (url) => {
|
|
10
|
-
const { pathname } = new URL(url);
|
|
11
|
-
const match = pathname.match(userRegex);
|
|
12
|
-
if (!match?.[1]) return [];
|
|
13
|
-
const user = match[1];
|
|
14
|
-
if (require_utils.isAnyOf(user, require_github.excludedPaths)) return [];
|
|
15
|
-
return [{ uri: `https://github.com/${user}.png` }];
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.githubHandler = githubHandler;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_githubGist = require("../../../feeds/platform/handlers/githubGist.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/githubGist.ts
|
|
4
|
-
const userRegex = /^\/([^/.]+)/;
|
|
5
|
-
const githubGistHandler = {
|
|
6
|
-
match: (url) => {
|
|
7
|
-
return require_utils.isHostOf(url, require_githubGist.hosts);
|
|
8
|
-
},
|
|
9
|
-
resolve: (url) => {
|
|
10
|
-
const { pathname } = new URL(url);
|
|
11
|
-
const match = pathname.match(userRegex);
|
|
12
|
-
if (!match?.[1]) return [];
|
|
13
|
-
const user = match[1];
|
|
14
|
-
if (require_utils.isAnyOf(user, require_githubGist.excludedPaths)) return [];
|
|
15
|
-
return [{ uri: `https://github.com/${user}.png` }];
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.githubGistHandler = githubGistHandler;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_utils$1 = require("../../utils.cjs");
|
|
3
|
-
const require_gitlab = require("../../../feeds/platform/handlers/gitlab.cjs");
|
|
4
|
-
//#region src/favicons/platform/handlers/gitlab.ts
|
|
5
|
-
const userRegex = /^\/([^/]+?)(?:\.atom)?(?:\/|$)/;
|
|
6
|
-
const fetchAvatarUrl = async (apiUrl, fetchFn) => {
|
|
7
|
-
const data = require_utils$1.parseBodyJson((await fetchFn(apiUrl)).body);
|
|
8
|
-
const entry = Array.isArray(data) ? data[0] : data;
|
|
9
|
-
if (require_utils$1.isNonEmptyString(entry?.avatar_url)) return entry.avatar_url;
|
|
10
|
-
};
|
|
11
|
-
const gitlabHandler = {
|
|
12
|
-
match: (url, content, headers) => {
|
|
13
|
-
try {
|
|
14
|
-
if (require_utils.isHostOf(url, require_gitlab.hosts)) return true;
|
|
15
|
-
const { pathname } = new URL(url);
|
|
16
|
-
if (!userRegex.test(pathname)) return false;
|
|
17
|
-
if (content && require_gitlab.isGitlabHtml(content)) return true;
|
|
18
|
-
if (headers && require_gitlab.isGitlabHeaders(headers)) return true;
|
|
19
|
-
} catch {}
|
|
20
|
-
return false;
|
|
21
|
-
},
|
|
22
|
-
resolve: async (url, _content, _headers, fetchFn) => {
|
|
23
|
-
if (!fetchFn) return [];
|
|
24
|
-
try {
|
|
25
|
-
const { origin, pathname } = new URL(url);
|
|
26
|
-
const match = pathname.match(userRegex);
|
|
27
|
-
if (!match?.[1]) return [];
|
|
28
|
-
const username = match[1];
|
|
29
|
-
if (require_utils.isAnyOf(username, require_gitlab.excludedPaths)) return [];
|
|
30
|
-
const encodedName = encodeURIComponent(username);
|
|
31
|
-
const avatarUrl = await fetchAvatarUrl(`${origin}/api/v4/users?username=${encodedName}`, fetchFn) ?? await fetchAvatarUrl(`${origin}/api/v4/groups/${encodedName}`, fetchFn);
|
|
32
|
-
if (avatarUrl) return [{ uri: avatarUrl }];
|
|
33
|
-
} catch {}
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.gitlabHandler = gitlabHandler;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_lobsters = require("../../../feeds/platform/handlers/lobsters.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/lobsters.ts
|
|
4
|
-
const userRegex = /^\/~([a-zA-Z0-9_-]+)/;
|
|
5
|
-
const lobstersHandler = {
|
|
6
|
-
match: (url) => {
|
|
7
|
-
try {
|
|
8
|
-
const { pathname } = new URL(url);
|
|
9
|
-
return require_utils.isHostOf(url, require_lobsters.hosts) && userRegex.test(pathname);
|
|
10
|
-
} catch {}
|
|
11
|
-
return false;
|
|
12
|
-
},
|
|
13
|
-
resolve: (url) => {
|
|
14
|
-
const { pathname } = new URL(url);
|
|
15
|
-
const match = pathname.match(userRegex);
|
|
16
|
-
if (!match?.[1]) return [];
|
|
17
|
-
return [{ uri: `https://lobste.rs/avatars/${match[1]}-100.png` }];
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
exports.lobstersHandler = lobstersHandler;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_utils$1 = require("../../utils.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/mastodon.ts
|
|
4
|
-
const mastodonRegex = /mastodon/i;
|
|
5
|
-
const profileRegex = /^\/@([^/.]+(?:@[^/.]+\.[^/.]+)?)(?:\.rss)?\/?$/;
|
|
6
|
-
const isProfilePath = (pathname) => {
|
|
7
|
-
return profileRegex.test(pathname);
|
|
8
|
-
};
|
|
9
|
-
const isMastodonHtml = (content) => {
|
|
10
|
-
return require_utils.hasMetaContent(content, "generator", "Mastodon");
|
|
11
|
-
};
|
|
12
|
-
const isMastodonHeaders = (headers) => {
|
|
13
|
-
return mastodonRegex.test(headers.get("server") ?? "");
|
|
14
|
-
};
|
|
15
|
-
const mastodonHandler = {
|
|
16
|
-
match: (url, content, headers) => {
|
|
17
|
-
try {
|
|
18
|
-
const { pathname } = new URL(url);
|
|
19
|
-
if (!isProfilePath(pathname)) return false;
|
|
20
|
-
if (content && isMastodonHtml(content)) return true;
|
|
21
|
-
if (headers && isMastodonHeaders(headers)) return true;
|
|
22
|
-
} catch {}
|
|
23
|
-
return false;
|
|
24
|
-
},
|
|
25
|
-
resolve: async (url, _content, _headers, fetchFn) => {
|
|
26
|
-
if (!fetchFn) return [];
|
|
27
|
-
try {
|
|
28
|
-
const { hostname, pathname } = new URL(url);
|
|
29
|
-
const match = pathname.match(profileRegex);
|
|
30
|
-
if (!match?.[1]) return [];
|
|
31
|
-
const data = require_utils$1.parseBodyJson((await fetchFn(`https://${hostname}/api/v1/accounts/lookup?acct=${match[1]}`)).body);
|
|
32
|
-
if (require_utils$1.isNonEmptyString(data.avatar)) return [{ uri: data.avatar }];
|
|
33
|
-
} catch {}
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.isMastodonHeaders = isMastodonHeaders;
|
|
39
|
-
exports.isMastodonHtml = isMastodonHtml;
|
|
40
|
-
exports.mastodonHandler = mastodonHandler;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_utils$1 = require("../../utils.cjs");
|
|
3
|
-
const require_reddit = require("../../../feeds/platform/handlers/reddit.cjs");
|
|
4
|
-
//#region src/favicons/platform/handlers/reddit.ts
|
|
5
|
-
const subredditRegex = /^\/r\/([^/.]+)/;
|
|
6
|
-
const userRegex = /^\/(u|user)\/([^/.]+)/;
|
|
7
|
-
const isSubredditPath = (pathname) => {
|
|
8
|
-
return subredditRegex.test(pathname);
|
|
9
|
-
};
|
|
10
|
-
const isUserPath = (pathname) => {
|
|
11
|
-
return userRegex.test(pathname);
|
|
12
|
-
};
|
|
13
|
-
const redditHandler = {
|
|
14
|
-
match: (url) => {
|
|
15
|
-
try {
|
|
16
|
-
const { pathname } = new URL(url);
|
|
17
|
-
return require_utils.isHostOf(url, require_reddit.hosts) && (isSubredditPath(pathname) || isUserPath(pathname));
|
|
18
|
-
} catch {}
|
|
19
|
-
return false;
|
|
20
|
-
},
|
|
21
|
-
resolve: async (url, _content, _headers, fetchFn) => {
|
|
22
|
-
if (!fetchFn) return [];
|
|
23
|
-
try {
|
|
24
|
-
const { pathname } = new URL(url);
|
|
25
|
-
const subredditMatch = pathname.match(subredditRegex);
|
|
26
|
-
if (subredditMatch?.[1]) {
|
|
27
|
-
const data = require_utils$1.parseBodyJson((await fetchFn(`https://www.reddit.com/r/${subredditMatch[1]}/about.json`)).body);
|
|
28
|
-
const icon = data?.data?.community_icon?.split("?")[0] || data?.data?.icon_img;
|
|
29
|
-
if (require_utils$1.isNonEmptyString(icon)) return [{ uri: icon }];
|
|
30
|
-
}
|
|
31
|
-
const userMatch = pathname.match(userRegex);
|
|
32
|
-
if (userMatch?.[2]) {
|
|
33
|
-
const data = require_utils$1.parseBodyJson((await fetchFn(`https://www.reddit.com/user/${userMatch[2]}/about.json`)).body);
|
|
34
|
-
const icon = data?.data?.icon_img || data?.data?.snoovatar_img;
|
|
35
|
-
if (require_utils$1.isNonEmptyString(icon)) return [{ uri: icon }];
|
|
36
|
-
}
|
|
37
|
-
} catch {}
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
exports.redditHandler = redditHandler;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_sourceforge = require("../../../feeds/platform/handlers/sourceforge.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/sourceforge.ts
|
|
4
|
-
const sourceforgeHandler = {
|
|
5
|
-
match: (url) => {
|
|
6
|
-
try {
|
|
7
|
-
const { pathname } = new URL(url);
|
|
8
|
-
const segments = pathname.split("/").filter(Boolean);
|
|
9
|
-
return require_utils.isHostOf(url, require_sourceforge.hosts) && segments[0] === "projects" && !!segments[1];
|
|
10
|
-
} catch {}
|
|
11
|
-
return false;
|
|
12
|
-
},
|
|
13
|
-
resolve: (url) => {
|
|
14
|
-
const { pathname } = new URL(url);
|
|
15
|
-
const segments = pathname.split("/").filter(Boolean);
|
|
16
|
-
if (segments[0] !== "projects" || !segments[1]) return [];
|
|
17
|
-
return [{ uri: `https://a.fsdn.com/allura/p/${segments[1]}/icon` }];
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
exports.sourceforgeHandler = sourceforgeHandler;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const require_utils = require("../../../common/utils.cjs");
|
|
2
|
-
const require_tumblr = require("../../../feeds/platform/handlers/tumblr.cjs");
|
|
3
|
-
//#region src/favicons/platform/handlers/tumblr.ts
|
|
4
|
-
const tumblrHandler = {
|
|
5
|
-
match: (url) => {
|
|
6
|
-
return require_utils.isSubdomainOf(url, require_tumblr.domains);
|
|
7
|
-
},
|
|
8
|
-
resolve: (url) => {
|
|
9
|
-
const { hostname } = new URL(url);
|
|
10
|
-
const blog = hostname.split(".")[0];
|
|
11
|
-
if (!blog || blog === "www") return [];
|
|
12
|
-
return [{ uri: `https://api.tumblr.com/v2/blog/${blog}/avatar/512` }];
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
exports.tumblrHandler = tumblrHandler;
|
package/dist/favicons/utils.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/favicons/utils.ts
|
|
2
|
-
const parseBodyJson = (body) => {
|
|
3
|
-
return JSON.parse(typeof body === "string" ? body : "");
|
|
4
|
-
};
|
|
5
|
-
const isNonEmptyString = (value) => {
|
|
6
|
-
return typeof value === "string" && value.length > 0;
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
9
|
-
exports.isNonEmptyString = isNonEmptyString;
|
|
10
|
-
exports.parseBodyJson = parseBodyJson;
|