social-embeds 0.9.3 → 0.9.5
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 +15 -8
- package/dist/element.js +1 -1
- package/dist/parser/iframe.js +2 -2
- package/dist/parser/matchers/bluesky.js +1 -1
- package/dist/parser/matchers/facebook.js +4 -4
- package/dist/parser/matchers/flickr.js +2 -2
- package/dist/parser/matchers/giphy.js +4 -4
- package/dist/parser/matchers/imgur.js +4 -4
- package/dist/parser/matchers/linkedin.js +2 -2
- package/dist/parser/matchers/snapchat.js +3 -3
- package/dist/parser/matchers/soundcloud.js +2 -2
- package/dist/parser/matchers/spotify.js +1 -1
- package/dist/parser/matchers/streamable.js +2 -2
- package/dist/parser/matchers/telegram.js +1 -1
- package/dist/parser/matchers/tenor.js +1 -1
- package/dist/parser/matchers/truthsocial.js +1 -1
- package/dist/parser/matchers/tumblr.js +3 -3
- package/dist/parser/matchers/vimeo.js +1 -1
- package/dist/parser/platform.d.ts +4 -2
- package/dist/parser/platform.js +11 -1
- package/dist/parser/platforms/applemusic.js +3 -4
- package/dist/parser/platforms/applepodcasts.js +3 -4
- package/dist/parser/platforms/bluesky.js +4 -4
- package/dist/parser/platforms/dailymotion.js +3 -4
- package/dist/parser/platforms/facebook.js +3 -4
- package/dist/parser/platforms/flickr.js +3 -4
- package/dist/parser/platforms/giphy.js +3 -4
- package/dist/parser/platforms/imgur.js +4 -4
- package/dist/parser/platforms/instagram.js +3 -3
- package/dist/parser/platforms/kick.js +3 -4
- package/dist/parser/platforms/linkedin.js +4 -5
- package/dist/parser/platforms/pinterest.js +3 -4
- package/dist/parser/platforms/reddit.js +4 -5
- package/dist/parser/platforms/rumble.js +3 -4
- package/dist/parser/platforms/snapchat.js +3 -4
- package/dist/parser/platforms/soundcloud.js +3 -4
- package/dist/parser/platforms/spotify.js +3 -4
- package/dist/parser/platforms/strava.js +3 -3
- package/dist/parser/platforms/streamable.js +3 -4
- package/dist/parser/platforms/telegram.js +4 -5
- package/dist/parser/platforms/tenor.js +4 -5
- package/dist/parser/platforms/threads.js +3 -4
- package/dist/parser/platforms/tiktok.js +3 -4
- package/dist/parser/platforms/truthsocial.js +4 -5
- package/dist/parser/platforms/tumblr.js +5 -5
- package/dist/parser/platforms/twitch.js +3 -4
- package/dist/parser/platforms/vimeo.js +3 -4
- package/dist/parser/platforms/x.js +3 -4
- package/dist/parser/platforms/youtube.js +3 -4
- package/package.json +4 -4
|
@@ -2,8 +2,8 @@ import { linkedinFrame } from "../frames.js";
|
|
|
2
2
|
// src/parser/matchers/linkedin.ts
|
|
3
3
|
const HOST = /^(?:www\.|[a-z]{2}\.)?linkedin\.com$/;
|
|
4
4
|
const URN = "(activity|share|ugcPost):(\\d{19})";
|
|
5
|
-
const UPDATE_PATH = new RegExp(`^(?:/embed)?/feed/update/urn:li:${URN}/?$`);
|
|
6
|
-
const POSTS_PATH = new RegExp(`^/posts/[^/]{1,300}-(activity|share|ugcPost)-(\\d{19})-[A-Za-z0-9_-]{1,8}/?$`);
|
|
5
|
+
const UPDATE_PATH = /* @__PURE__ */ new RegExp(`^(?:/embed)?/feed/update/urn:li:${URN}/?$`);
|
|
6
|
+
const POSTS_PATH = /* @__PURE__ */ new RegExp(`^/posts/[^/]{1,300}-(activity|share|ugcPost)-(\\d{19})-[A-Za-z0-9_-]{1,8}/?$`);
|
|
7
7
|
function post(type, id, options = {}) {
|
|
8
8
|
const urn = `urn:li:${type}:${id}`;
|
|
9
9
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/parser/matchers/snapchat.ts
|
|
2
2
|
const HOSTS = /* @__PURE__ */ new Set(["snapchat.com", "www.snapchat.com"]);
|
|
3
3
|
const USER = "([A-Za-z][A-Za-z0-9._-]{1,29})";
|
|
4
|
-
const SPOTLIGHT = new RegExp(`^(?:/@${USER})?/spotlight/([A-Za-z0-9_-]{20,120})$`);
|
|
5
|
-
const PROFILE = new RegExp(`^/(?:@|add/)${USER}$`);
|
|
4
|
+
const SPOTLIGHT = /* @__PURE__ */ new RegExp(`^(?:/@${USER})?/spotlight/([A-Za-z0-9_-]{20,120})$`);
|
|
5
|
+
const PROFILE = /* @__PURE__ */ new RegExp(`^/(?:@|add/)${USER}$`);
|
|
6
6
|
const LENS = /^\/lens\/([0-9a-f]{32}|\d{1,20})$/;
|
|
7
|
-
const HIGHLIGHT = new RegExp(`^/@${USER}/highlight/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$`);
|
|
7
|
+
const HIGHLIGHT = /* @__PURE__ */ new RegExp(`^/@${USER}/highlight/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$`);
|
|
8
8
|
function content(url) {
|
|
9
9
|
if (!url || !HOSTS.has(url.host)) return null;
|
|
10
10
|
const path = url.path.replace(/\/$/, "");
|
|
@@ -8,7 +8,7 @@ const PAGE_HOSTS = /* @__PURE__ */ new Set([
|
|
|
8
8
|
const API_PATH = /^\/(tracks|playlists|users)\/(?:soundcloud%3A(?:tracks|playlists|users)%3A)?(\d{1,15})\/?$/i;
|
|
9
9
|
const NAME = "[a-z0-9_-]{1,64}";
|
|
10
10
|
const SECRET = "s-[A-Za-z0-9]{1,32}";
|
|
11
|
-
const PERMALINK = new RegExp(`^/(${NAME})(?:/(sets/${NAME}|${NAME})(?:/(${SECRET}))?)?/?$`, "i");
|
|
11
|
+
const PERMALINK = /* @__PURE__ */ new RegExp(`^/(${NAME})(?:/(sets/${NAME}|${NAME})(?:/(${SECRET}))?)?/?$`, "i");
|
|
12
12
|
const NOT_USERS = /* @__PURE__ */ new Set([
|
|
13
13
|
"discover",
|
|
14
14
|
"search",
|
|
@@ -40,7 +40,7 @@ const NOT_SOUNDS = /* @__PURE__ */ new Set([
|
|
|
40
40
|
"spotlight",
|
|
41
41
|
"toptracks"
|
|
42
42
|
]);
|
|
43
|
-
const SECRET_TOKEN = new RegExp(`^${SECRET}$`);
|
|
43
|
+
const SECRET_TOKEN = /* @__PURE__ */ new RegExp(`^${SECRET}$`);
|
|
44
44
|
function sound(url, id) {
|
|
45
45
|
return {
|
|
46
46
|
platform: "soundcloud",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { coerce } from "../url.js";
|
|
2
2
|
import { spotifyFrame } from "../frames.js";
|
|
3
3
|
// src/parser/matchers/spotify.ts
|
|
4
|
-
const CONTENT_PATH = new RegExp(`^(?:/intl-[a-z]{2}(?:-[A-Za-z]{2})?)?(?:/embed)?/(track|album|playlist|artist|episode|show|audiobook|chapter)/([A-Za-z0-9]{22})(/video)?/?$`);
|
|
4
|
+
const CONTENT_PATH = /* @__PURE__ */ new RegExp(`^(?:/intl-[a-z]{2}(?:-[A-Za-z]{2})?)?(?:/embed)?/(track|album|playlist|artist|episode|show|audiobook|chapter)/([A-Za-z0-9]{22})(/video)?/?$`);
|
|
5
5
|
const DROPPED = /* @__PURE__ */ new Set(["utm_source", "si"]);
|
|
6
6
|
function content(url) {
|
|
7
7
|
if (url?.host !== "open.spotify.com") return null;
|
|
@@ -2,8 +2,8 @@ import { streamableFrame } from "../frames.js";
|
|
|
2
2
|
// src/parser/matchers/streamable.ts
|
|
3
3
|
const ID = "([a-z0-9]{4,8})";
|
|
4
4
|
const PAGE_HOSTS = /* @__PURE__ */ new Set(["streamable.com", "www.streamable.com"]);
|
|
5
|
-
const PLAYER_PATH = new RegExp(`^/[eo]/${ID}$`);
|
|
6
|
-
const PAGE_PATH = new RegExp(`^/${ID}/?$`);
|
|
5
|
+
const PLAYER_PATH = /* @__PURE__ */ new RegExp(`^/[eo]/${ID}$`);
|
|
6
|
+
const PAGE_PATH = /* @__PURE__ */ new RegExp(`^/${ID}/?$`);
|
|
7
7
|
const NOT_VIDEOS = /* @__PURE__ */ new Set([
|
|
8
8
|
"about",
|
|
9
9
|
"login",
|
|
@@ -5,7 +5,7 @@ const HOSTS = /* @__PURE__ */ new Set([
|
|
|
5
5
|
"www.telegram.me"
|
|
6
6
|
]);
|
|
7
7
|
const CHANNEL = "[A-Za-z][A-Za-z0-9_]{2,31}";
|
|
8
|
-
const POST_PATH = new RegExp(`^/(?:s/)?(${CHANNEL})/(\\d{1,10})/?$`);
|
|
8
|
+
const POST_PATH = /* @__PURE__ */ new RegExp(`^/(?:s/)?(${CHANNEL})/(\\d{1,10})/?$`);
|
|
9
9
|
function post(channel, id, options) {
|
|
10
10
|
return {
|
|
11
11
|
platform: "telegram",
|
|
@@ -3,7 +3,7 @@ import { tenorFrame } from "../frames.js";
|
|
|
3
3
|
// src/parser/matchers/tenor.ts
|
|
4
4
|
const HOSTS = /* @__PURE__ */ new Set(["tenor.com", "www.tenor.com"]);
|
|
5
5
|
const ID = "(\\d{1,20})";
|
|
6
|
-
const PAGE_PATH = new RegExp(`^/(?:[a-z]{2}(?:-[A-Za-z]{2,4})?/)?view/(?:[A-Za-z0-9%_.~-]{1,300}-gif-)?${ID}/?$`);
|
|
6
|
+
const PAGE_PATH = /* @__PURE__ */ new RegExp(`^/(?:[a-z]{2}(?:-[A-Za-z]{2,4})?/)?view/(?:[A-Za-z0-9%_.~-]{1,300}-gif-)?${ID}/?$`);
|
|
7
7
|
const FALLBACK = /* @__PURE__ */ new Map([["a", ["href"]]]);
|
|
8
8
|
function gif(id) {
|
|
9
9
|
return {
|
|
@@ -3,7 +3,7 @@ import { truthsocialFrame } from "../frames.js";
|
|
|
3
3
|
const HOSTS = /* @__PURE__ */ new Set(["truthsocial.com", "www.truthsocial.com"]);
|
|
4
4
|
const USER = "(@[A-Za-z0-9_.-]{1,64})";
|
|
5
5
|
const ID = "(\\d{1,25})";
|
|
6
|
-
const POST_PATH = new RegExp(`^/${USER}/(?:posts/)?${ID}/?$`);
|
|
6
|
+
const POST_PATH = /* @__PURE__ */ new RegExp(`^/${USER}/(?:posts/)?${ID}/?$`);
|
|
7
7
|
function post(user, id) {
|
|
8
8
|
return {
|
|
9
9
|
platform: "truthsocial",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
const BLOG = "([a-z0-9-]{1,32})";
|
|
3
3
|
const POST = "(\\d{1,20})";
|
|
4
4
|
const WWW_HOSTS = /* @__PURE__ */ new Set(["www.tumblr.com", "tumblr.com"]);
|
|
5
|
-
const WWW_PATH = new RegExp(`^/${BLOG}/${POST}(?:/[^/]{1,200})?/?$`);
|
|
6
|
-
const BLOG_HOST = new RegExp(`^${BLOG}\\.tumblr\\.com$`);
|
|
7
|
-
const BLOG_PATH = new RegExp(`^/post/${POST}(?:/[^/]{1,200})?/?$`);
|
|
5
|
+
const WWW_PATH = /* @__PURE__ */ new RegExp(`^/${BLOG}/${POST}(?:/[^/]{1,200})?/?$`);
|
|
6
|
+
const BLOG_HOST = /* @__PURE__ */ new RegExp(`^${BLOG}\\.tumblr\\.com$`);
|
|
7
|
+
const BLOG_PATH = /* @__PURE__ */ new RegExp(`^/post/${POST}(?:/[^/]{1,200})?/?$`);
|
|
8
8
|
const NOT_BLOGS = /* @__PURE__ */ new Set([
|
|
9
9
|
"dashboard",
|
|
10
10
|
"explore",
|
|
@@ -10,7 +10,7 @@ const PAGE_PATHS = [
|
|
|
10
10
|
new RegExp(`^/groups/[A-Za-z0-9_-]{1,64}/videos/${VIDEO}/?$`),
|
|
11
11
|
new RegExp(`^/showcase/\\d{1,12}/video/${VIDEO}/?$`)
|
|
12
12
|
];
|
|
13
|
-
const PLAYER_PATH = new RegExp(`^/video/${VIDEO}/?$`);
|
|
13
|
+
const PLAYER_PATH = /* @__PURE__ */ new RegExp(`^/video/${VIDEO}/?$`);
|
|
14
14
|
const DROPPED = /* @__PURE__ */ new Set([
|
|
15
15
|
"h",
|
|
16
16
|
"app_id",
|
|
@@ -20,7 +20,8 @@ export type PlatformMatcher = {
|
|
|
20
20
|
/** True also for frames `parse` rejects, so generic iframe code never bypasses the platform's checks. */
|
|
21
21
|
ownsFrame?: (src: ParsedUrl) => boolean;
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
/** A parser's embed-code half: what it adds to its `PlatformMatcher`. */
|
|
24
|
+
export type EmbedCode = {
|
|
24
25
|
/** The embed element (blockquote, div or iframe) of the platform's own embed code. */
|
|
25
26
|
parse: (root: HtmlElement) => ParsedEmbed | null;
|
|
26
27
|
/** Embed code that is a single `<script>` tag, as Telegram's is. */
|
|
@@ -35,4 +36,5 @@ export type PlatformParser = PlatformMatcher & {
|
|
|
35
36
|
allowsFbRoot?: boolean;
|
|
36
37
|
/** A sibling element after the embed that is the platform's own markup, such as a credit; it is dropped. */
|
|
37
38
|
isOwnExtra?: (element: HtmlElement, embed: ParsedEmbed) => boolean;
|
|
38
|
-
};
|
|
39
|
+
};
|
|
40
|
+
export type PlatformParser = PlatformMatcher & EmbedCode;
|
package/dist/parser/platform.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { pixels } from "./url.js";
|
|
2
2
|
// src/parser/platform.ts
|
|
3
|
+
/**
|
|
4
|
+
* Call it as `/* @__PURE__ *\/ parserOf(…)`. A minifier keeps an unused object literal that
|
|
5
|
+
* spreads another object, and with it every parser a scope-hoisted bundle holds (docs/decisions.md D118).
|
|
6
|
+
*/
|
|
7
|
+
function parserOf(matcher, code) {
|
|
8
|
+
return {
|
|
9
|
+
...matcher,
|
|
10
|
+
...code
|
|
11
|
+
};
|
|
12
|
+
}
|
|
3
13
|
/** `/embed` holds `/embed` and `/embed/…`, never `/embedded`. */
|
|
4
14
|
function underPath(path, folder) {
|
|
5
15
|
return path === folder || path.startsWith(`${folder}/`);
|
|
@@ -57,4 +67,4 @@ function unwrapRatio(root, pattern) {
|
|
|
57
67
|
function gcd(a, b) {
|
|
58
68
|
return b === 0 ? a : gcd(b, a % b);
|
|
59
69
|
}
|
|
60
|
-
export { attributeOptions, sizeOf, underPath, unwrapRatio, withSize };
|
|
70
|
+
export { attributeOptions, parserOf, sizeOf, underPath, unwrapRatio, withSize };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { parseUrl } from "../url.js";
|
|
3
3
|
import { APPLE_MUSIC_FRAME_HOST } from "../frames.js";
|
|
4
4
|
import { appleContent, applemusicMatcher } from "../matchers/applemusic.js";
|
|
5
5
|
// src/parser/platforms/applemusic.ts
|
|
6
|
-
const applemusic = {
|
|
7
|
-
...applemusicMatcher,
|
|
6
|
+
const applemusic = /* @__PURE__ */ parserOf(applemusicMatcher, {
|
|
8
7
|
parse(root) {
|
|
9
8
|
if (root.tag !== "iframe") return null;
|
|
10
9
|
const found = appleContent(parseUrl(root.attrs.get("src") ?? ""), APPLE_MUSIC_FRAME_HOST);
|
|
@@ -17,5 +16,5 @@ const applemusic = {
|
|
|
17
16
|
}, height === void 0 ? void 0 : { height });
|
|
18
17
|
},
|
|
19
18
|
isOwnScript: () => false
|
|
20
|
-
};
|
|
19
|
+
});
|
|
21
20
|
export { applemusic };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { parseUrl } from "../url.js";
|
|
3
3
|
import { APPLE_PODCASTS_FRAME_HOST } from "../frames.js";
|
|
4
4
|
import { applepodcastsMatcher, content } from "../matchers/applepodcasts.js";
|
|
5
5
|
// src/parser/platforms/applepodcasts.ts
|
|
6
|
-
const applepodcasts = {
|
|
7
|
-
...applepodcastsMatcher,
|
|
6
|
+
const applepodcasts = /* @__PURE__ */ parserOf(applepodcastsMatcher, {
|
|
8
7
|
parse(root) {
|
|
9
8
|
if (root.tag !== "iframe") return null;
|
|
10
9
|
const found = content(parseUrl(root.attrs.get("src") ?? ""), APPLE_PODCASTS_FRAME_HOST);
|
|
@@ -14,5 +13,5 @@ const applepodcasts = {
|
|
|
14
13
|
}, sizeOf(root));
|
|
15
14
|
},
|
|
16
15
|
isOwnScript: () => false
|
|
17
|
-
};
|
|
16
|
+
});
|
|
18
17
|
export { applepodcasts };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
1
2
|
import { descendants, hasClass, rebuild } from "../html.js";
|
|
2
3
|
import { parseUrl } from "../url.js";
|
|
3
4
|
import { DID, FALLBACK, RKEY, blueskyMatcher, fromUrl, post } from "../matchers/bluesky.js";
|
|
4
5
|
// src/parser/platforms/bluesky.ts
|
|
5
|
-
const AT_URI = new RegExp(`^at://${DID}/app\\.bsky\\.feed\\.post/${RKEY}$`);
|
|
6
|
+
const AT_URI = /* @__PURE__ */ new RegExp(`^at://${DID}/app\\.bsky\\.feed\\.post/${RKEY}$`);
|
|
6
7
|
const CID = /^[a-z2-7]{20,100}$/;
|
|
7
8
|
const COLOR_MODES = /* @__PURE__ */ new Set([
|
|
8
9
|
"light",
|
|
@@ -10,8 +11,7 @@ const COLOR_MODES = /* @__PURE__ */ new Set([
|
|
|
10
11
|
"system"
|
|
11
12
|
]);
|
|
12
13
|
const SCRIPT = /^(?:https?:)?\/\/embed\.bsky\.app\/static\/embed\.js$/;
|
|
13
|
-
const bluesky = {
|
|
14
|
-
...blueskyMatcher,
|
|
14
|
+
const bluesky = /* @__PURE__ */ parserOf(blueskyMatcher, {
|
|
15
15
|
parse(root) {
|
|
16
16
|
if (root.tag !== "blockquote" || !hasClass(root, "bluesky-embed")) return null;
|
|
17
17
|
const [, did, rkey] = AT_URI.exec(root.attrs.get("data-bluesky-uri") ?? "") ?? [];
|
|
@@ -30,5 +30,5 @@ const bluesky = {
|
|
|
30
30
|
};
|
|
31
31
|
},
|
|
32
32
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
33
|
-
};
|
|
33
|
+
});
|
|
34
34
|
export { bluesky };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { sizeOf, unwrapRatio, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, unwrapRatio, withSize } from "../platform.js";
|
|
2
2
|
import { parseUrl } from "../url.js";
|
|
3
3
|
import { dailymotionMatcher, fromPage, fromPlayer } from "../matchers/dailymotion.js";
|
|
4
4
|
// src/parser/platforms/dailymotion.ts
|
|
5
5
|
const WRAPPER = /^position:\s*relative;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*height:\s*0;\s*overflow:\s*hidden;?$/;
|
|
6
|
-
const dailymotion = {
|
|
7
|
-
...dailymotionMatcher,
|
|
6
|
+
const dailymotion = /* @__PURE__ */ parserOf(dailymotionMatcher, {
|
|
8
7
|
parse(root) {
|
|
9
8
|
const wrapped = unwrapRatio(root, WRAPPER);
|
|
10
9
|
const iframe = wrapped?.iframe ?? root;
|
|
@@ -15,5 +14,5 @@ const dailymotion = {
|
|
|
15
14
|
return embed && withSize(embed, wrapped?.size ?? sizeOf(iframe));
|
|
16
15
|
},
|
|
17
16
|
isOwnScript: () => false
|
|
18
|
-
};
|
|
17
|
+
});
|
|
19
18
|
export { dailymotion };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasClass, rebuild } from "../html.js";
|
|
2
|
-
import { attributeOptions, sizeOf, withSize } from "../platform.js";
|
|
2
|
+
import { attributeOptions, parserOf, sizeOf, withSize } from "../platform.js";
|
|
3
3
|
import { coerce, parseUrl, pixels } from "../url.js";
|
|
4
4
|
import { FACEBOOK_PLUGIN_HOSTS } from "../frames.js";
|
|
5
5
|
import { FALLBACK, embed, facebookMatcher, target } from "../matchers/facebook.js";
|
|
@@ -19,8 +19,7 @@ const VIDEO_SDK_PARAMETERS = [
|
|
|
19
19
|
["autoplay", "autoplay"],
|
|
20
20
|
["show_captions", "showCaptions"]
|
|
21
21
|
];
|
|
22
|
-
const facebook = {
|
|
23
|
-
...facebookMatcher,
|
|
22
|
+
const facebook = /* @__PURE__ */ parserOf(facebookMatcher, {
|
|
24
23
|
parse(root) {
|
|
25
24
|
if (root.tag === "div") {
|
|
26
25
|
const kind = hasClass(root, "fb-post") ? "post" : hasClass(root, "fb-video") ? "video" : null;
|
|
@@ -73,5 +72,5 @@ const facebook = {
|
|
|
73
72
|
return locale === void 0 ? {} : { locale };
|
|
74
73
|
},
|
|
75
74
|
allowsFbRoot: true
|
|
76
|
-
};
|
|
75
|
+
});
|
|
77
76
|
export { facebook };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { rebuild } from "../html.js";
|
|
2
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
2
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
3
3
|
import { parseUrl } from "../url.js";
|
|
4
4
|
import { FALLBACK, IMAGE_SRC, flickrMatcher, fromLongUrl } from "../matchers/flickr.js";
|
|
5
5
|
// src/parser/platforms/flickr.ts
|
|
@@ -18,8 +18,7 @@ function onlyImage(root) {
|
|
|
18
18
|
}
|
|
19
19
|
return image;
|
|
20
20
|
}
|
|
21
|
-
const flickr = {
|
|
22
|
-
...flickrMatcher,
|
|
21
|
+
const flickr = /* @__PURE__ */ parserOf(flickrMatcher, {
|
|
23
22
|
parse(root) {
|
|
24
23
|
if (root.tag !== "a" || root.attrs.get("data-flickr-embed") !== "true") return null;
|
|
25
24
|
const found = fromLongUrl(parseUrl(root.attrs.get("href") ?? ""));
|
|
@@ -39,5 +38,5 @@ const flickr = {
|
|
|
39
38
|
}, size?.width !== void 0 && size.height !== void 0 ? size : void 0);
|
|
40
39
|
},
|
|
41
40
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
42
|
-
};
|
|
41
|
+
});
|
|
43
42
|
export { flickr };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sizeOf, unwrapRatio, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, unwrapRatio, withSize } from "../platform.js";
|
|
2
2
|
import { parseUrl } from "../url.js";
|
|
3
3
|
import { GIPHY_PAGE_HOSTS } from "../frames.js";
|
|
4
4
|
import { EMBED_PATH, PAGE_PATH, gif, giphyMatcher } from "../matchers/giphy.js";
|
|
@@ -21,8 +21,7 @@ function isCredit(element, embed) {
|
|
|
21
21
|
const [text, ...more] = link.children;
|
|
22
22
|
return more.length === 0 && text?.type === "text" && text.raw.trim() === "via GIPHY";
|
|
23
23
|
}
|
|
24
|
-
const giphy = {
|
|
25
|
-
...giphyMatcher,
|
|
24
|
+
const giphy = /* @__PURE__ */ parserOf(giphyMatcher, {
|
|
26
25
|
parse(root) {
|
|
27
26
|
const wrapped = unwrapRatio(root, WRAPPER);
|
|
28
27
|
const iframe = wrapped?.iframe ?? root;
|
|
@@ -35,5 +34,5 @@ const giphy = {
|
|
|
35
34
|
},
|
|
36
35
|
isOwnScript: () => false,
|
|
37
36
|
isOwnExtra: isCredit
|
|
38
|
-
};
|
|
37
|
+
});
|
|
39
38
|
export { giphy };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
1
2
|
import { hasClass, rebuild } from "../html.js";
|
|
2
3
|
import { FALLBACK, HASH, image, imgurMatcher, post } from "../matchers/imgur.js";
|
|
3
4
|
// src/parser/platforms/imgur.ts
|
|
4
|
-
const DATA_ID = new RegExp(`^(a/)?${HASH}$`);
|
|
5
|
+
const DATA_ID = /* @__PURE__ */ new RegExp(`^(a/)?${HASH}$`);
|
|
5
6
|
const SCRIPT = /^(?:https?:)?\/\/s\.imgur\.com\/min\/embed\.js$/;
|
|
6
7
|
function withScheme(nodes) {
|
|
7
8
|
return nodes.map((node) => {
|
|
@@ -19,8 +20,7 @@ function withScheme(nodes) {
|
|
|
19
20
|
function falseOption(root, attribute) {
|
|
20
21
|
return root.attrs.get(attribute) === "false";
|
|
21
22
|
}
|
|
22
|
-
const imgur = {
|
|
23
|
-
...imgurMatcher,
|
|
23
|
+
const imgur = /* @__PURE__ */ parserOf(imgurMatcher, {
|
|
24
24
|
parse(root) {
|
|
25
25
|
if (root.tag !== "blockquote" || !hasClass(root, "imgur-embed-pub")) return null;
|
|
26
26
|
const id = root.attrs.get("data-id") ?? "";
|
|
@@ -36,5 +36,5 @@ const imgur = {
|
|
|
36
36
|
};
|
|
37
37
|
},
|
|
38
38
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
39
|
-
};
|
|
39
|
+
});
|
|
40
40
|
export { imgur };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
1
2
|
import { descendants, hasClass, rebuild } from "../html.js";
|
|
2
3
|
import { coerce, parseUrl } from "../url.js";
|
|
3
4
|
import { FALLBACK, instagramMatcher, post } from "../matchers/instagram.js";
|
|
4
5
|
// src/parser/platforms/instagram.ts
|
|
5
6
|
const SCRIPT = /^(?:https?:)?\/\/www\.instagram\.com\/embed\.js$/;
|
|
6
|
-
const instagram = {
|
|
7
|
-
...instagramMatcher,
|
|
7
|
+
const instagram = /* @__PURE__ */ parserOf(instagramMatcher, {
|
|
8
8
|
parse(root) {
|
|
9
9
|
if (root.tag !== "blockquote" || !hasClass(root, "instagram-media")) return null;
|
|
10
10
|
const permalink = root.attrs.get("data-instgrm-permalink");
|
|
@@ -21,5 +21,5 @@ const instagram = {
|
|
|
21
21
|
};
|
|
22
22
|
},
|
|
23
23
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
24
|
-
};
|
|
24
|
+
});
|
|
25
25
|
export { instagram };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
3
|
import { KICK_PLAYER_HOSTS } from "../frames.js";
|
|
4
4
|
import { channel, kickMatcher } from "../matchers/kick.js";
|
|
5
5
|
// src/parser/platforms/kick.ts
|
|
6
6
|
const KEPT = /* @__PURE__ */ new Set(["autoplay", "muted"]);
|
|
7
|
-
const kick = {
|
|
8
|
-
...kickMatcher,
|
|
7
|
+
const kick = /* @__PURE__ */ parserOf(kickMatcher, {
|
|
9
8
|
parse(root) {
|
|
10
9
|
if (root.tag !== "iframe") return null;
|
|
11
10
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -18,5 +17,5 @@ const kick = {
|
|
|
18
17
|
}, sizeOf(root));
|
|
19
18
|
},
|
|
20
19
|
isOwnScript: () => false
|
|
21
|
-
};
|
|
20
|
+
});
|
|
22
21
|
export { kick };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
3
|
import "../frames.js";
|
|
4
4
|
import { URN, linkedinMatcher, post } from "../matchers/linkedin.js";
|
|
5
5
|
// src/parser/platforms/linkedin.ts
|
|
6
|
-
const EMBED_PATH = new RegExp(`^/embed/feed/update/urn:li:${URN}$`);
|
|
7
|
-
const linkedin = {
|
|
8
|
-
...linkedinMatcher,
|
|
6
|
+
const EMBED_PATH = /* @__PURE__ */ new RegExp(`^/embed/feed/update/urn:li:${URN}$`);
|
|
7
|
+
const linkedin = /* @__PURE__ */ parserOf(linkedinMatcher, {
|
|
9
8
|
parse(root) {
|
|
10
9
|
if (root.tag !== "iframe") return null;
|
|
11
10
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -16,5 +15,5 @@ const linkedin = {
|
|
|
16
15
|
return withSize(post(type, id, options), sizeOf(root));
|
|
17
16
|
},
|
|
18
17
|
isOwnScript: () => false
|
|
19
|
-
};
|
|
18
|
+
});
|
|
20
19
|
export { linkedin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attributeOptions } from "../platform.js";
|
|
1
|
+
import { attributeOptions, parserOf } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
3
|
import "../frames.js";
|
|
4
4
|
import { pin, pinOf, pinterestMatcher } from "../matchers/pinterest.js";
|
|
@@ -10,8 +10,7 @@ const OPTION_ATTRIBUTES = [
|
|
|
10
10
|
["data-pin-lang", "lang"],
|
|
11
11
|
["data-pin-terse", "terse"]
|
|
12
12
|
];
|
|
13
|
-
const pinterest = {
|
|
14
|
-
...pinterestMatcher,
|
|
13
|
+
const pinterest = /* @__PURE__ */ parserOf(pinterestMatcher, {
|
|
15
14
|
parse(root) {
|
|
16
15
|
if (root.tag === "a") {
|
|
17
16
|
if (root.attrs.get("data-pin-do") !== "embedPin") return null;
|
|
@@ -32,5 +31,5 @@ const pinterest = {
|
|
|
32
31
|
} : null;
|
|
33
32
|
},
|
|
34
33
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
35
|
-
};
|
|
34
|
+
});
|
|
36
35
|
export { pinterest };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { descendants, hasClass } from "../html.js";
|
|
2
|
-
import { attributeOptions, withSize } from "../platform.js";
|
|
2
|
+
import { attributeOptions, parserOf, withSize } from "../platform.js";
|
|
3
3
|
import { coerce, parseUrl, pixels } from "../url.js";
|
|
4
4
|
import { post, redditMatcher } from "../matchers/reddit.js";
|
|
5
5
|
// src/parser/platforms/reddit.ts
|
|
6
6
|
const SCRIPT = /^(?:https?:)?\/\/embed\.reddit\.com\/widgets\.js$/;
|
|
7
7
|
const CARD_SCRIPT = /^(?:https?:)?\/\/embed\.redditmedia\.com\/widgets\/platform\.js$/;
|
|
8
|
-
const OPTION_ATTRIBUTES = [
|
|
8
|
+
const OPTION_ATTRIBUTES = /* @__PURE__ */ [
|
|
9
9
|
"depth",
|
|
10
10
|
"style",
|
|
11
11
|
"theme",
|
|
@@ -17,8 +17,7 @@ const OPTION_ATTRIBUTES = [
|
|
|
17
17
|
"showusername",
|
|
18
18
|
"snippet"
|
|
19
19
|
].map((name) => [`data-embed-${name}`, name]);
|
|
20
|
-
const reddit = {
|
|
21
|
-
...redditMatcher,
|
|
20
|
+
const reddit = /* @__PURE__ */ parserOf(redditMatcher, {
|
|
22
21
|
parse(root) {
|
|
23
22
|
if (root.tag !== "blockquote" || !(hasClass(root, "reddit-embed-bq") || hasClass(root, "reddit-card"))) return null;
|
|
24
23
|
const found = descendants(root.children).map((element) => element.tag === "a" ? post(parseUrl(element.attrs.get("href") ?? "")) : null).find((embed) => embed !== null);
|
|
@@ -30,5 +29,5 @@ const reddit = {
|
|
|
30
29
|
}, height === void 0 ? void 0 : { height });
|
|
31
30
|
},
|
|
32
31
|
isOwnScript: (src) => SCRIPT.test(src) || CARD_SCRIPT.test(src)
|
|
33
|
-
};
|
|
32
|
+
});
|
|
34
33
|
export { reddit };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
3
|
import { idOf, rumbleMatcher, video } from "../matchers/rumble.js";
|
|
4
4
|
// src/parser/platforms/rumble.ts
|
|
5
|
-
const rumble = {
|
|
6
|
-
...rumbleMatcher,
|
|
5
|
+
const rumble = /* @__PURE__ */ parserOf(rumbleMatcher, {
|
|
7
6
|
parse(root) {
|
|
8
7
|
if (root.tag !== "iframe") return null;
|
|
9
8
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -18,5 +17,5 @@ const rumble = {
|
|
|
18
17
|
}, sizeOf(root));
|
|
19
18
|
},
|
|
20
19
|
isOwnScript: () => false
|
|
21
|
-
};
|
|
20
|
+
});
|
|
22
21
|
export { rumble };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { descendants, hasClass } from "../html.js";
|
|
2
|
-
import { withSize } from "../platform.js";
|
|
2
|
+
import { parserOf, withSize } from "../platform.js";
|
|
3
3
|
import { parseUrl, pixels } from "../url.js";
|
|
4
4
|
import { content, snapchatMatcher } from "../matchers/snapchat.js";
|
|
5
5
|
// src/parser/platforms/snapchat.ts
|
|
6
6
|
const SCRIPT = /^(?:https?:)?\/\/www\.snapchat\.com\/embed\.js$/;
|
|
7
|
-
const snapchat = {
|
|
8
|
-
...snapchatMatcher,
|
|
7
|
+
const snapchat = /* @__PURE__ */ parserOf(snapchatMatcher, {
|
|
9
8
|
parse(root) {
|
|
10
9
|
if (root.tag !== "blockquote" || !hasClass(root, "snapchat-embed")) return null;
|
|
11
10
|
const embedUrl = parseUrl(root.attrs.get("data-snapchat-embed-url") ?? "");
|
|
@@ -31,5 +30,5 @@ const snapchat = {
|
|
|
31
30
|
});
|
|
32
31
|
},
|
|
33
32
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
34
|
-
};
|
|
33
|
+
});
|
|
35
34
|
export { snapchat };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
3
|
import "../frames.js";
|
|
4
4
|
import { PAGE_HOSTS, SECRET_TOKEN, fromApi, soundcloudMatcher } from "../matchers/soundcloud.js";
|
|
@@ -21,8 +21,7 @@ function isCredit(element) {
|
|
|
21
21
|
const [artist, separator, sound, ...rest] = element.children;
|
|
22
22
|
return rest.length === 0 && isCreditLink(artist) && separator?.type === "text" && /^\s*·\s*$/.test(separator.raw) && isCreditLink(sound);
|
|
23
23
|
}
|
|
24
|
-
const soundcloud = {
|
|
25
|
-
...soundcloudMatcher,
|
|
24
|
+
const soundcloud = /* @__PURE__ */ parserOf(soundcloudMatcher, {
|
|
26
25
|
parse(root) {
|
|
27
26
|
if (root.tag !== "iframe") return null;
|
|
28
27
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -46,5 +45,5 @@ const soundcloud = {
|
|
|
46
45
|
},
|
|
47
46
|
isOwnScript: () => false,
|
|
48
47
|
isOwnExtra: isCredit
|
|
49
|
-
};
|
|
48
|
+
});
|
|
50
49
|
export { soundcloud };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
2
2
|
import { parseUrl } from "../url.js";
|
|
3
3
|
import { content, options, spotifyMatcher } from "../matchers/spotify.js";
|
|
4
4
|
// src/parser/platforms/spotify.ts
|
|
5
|
-
const spotify = {
|
|
6
|
-
...spotifyMatcher,
|
|
5
|
+
const spotify = /* @__PURE__ */ parserOf(spotifyMatcher, {
|
|
7
6
|
parse(root) {
|
|
8
7
|
if (root.tag !== "iframe") return null;
|
|
9
8
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -17,5 +16,5 @@ const spotify = {
|
|
|
17
16
|
}, sizeOf(root));
|
|
18
17
|
},
|
|
19
18
|
isOwnScript: () => false
|
|
20
|
-
};
|
|
19
|
+
});
|
|
21
20
|
export { spotify };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
1
2
|
import { hasClass } from "../html.js";
|
|
2
3
|
import { item, stravaMatcher } from "../matchers/strava.js";
|
|
3
4
|
// src/parser/platforms/strava.ts
|
|
@@ -8,8 +9,7 @@ const MAP_HASH = /^[A-Za-z0-9_-]{1,100}$/;
|
|
|
8
9
|
function isType(value) {
|
|
9
10
|
return value === "activity" || value === "route";
|
|
10
11
|
}
|
|
11
|
-
const strava = {
|
|
12
|
-
...stravaMatcher,
|
|
12
|
+
const strava = /* @__PURE__ */ parserOf(stravaMatcher, {
|
|
13
13
|
parse(root) {
|
|
14
14
|
if (root.tag !== "div" || !hasClass(root, "strava-embed-placeholder")) return null;
|
|
15
15
|
if (!root.children.every((child) => child.type === "comment" || child.type === "text" && /^\s*$/.test(child.raw))) return null;
|
|
@@ -28,5 +28,5 @@ const strava = {
|
|
|
28
28
|
};
|
|
29
29
|
},
|
|
30
30
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
31
|
-
};
|
|
31
|
+
});
|
|
32
32
|
export { strava };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sizeOf, unwrapRatio, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, unwrapRatio, withSize } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
3
|
import { PLAYER_PATH, streamableMatcher, validId, video } from "../matchers/streamable.js";
|
|
4
4
|
// src/parser/platforms/streamable.ts
|
|
@@ -23,8 +23,7 @@ function fromIframe(iframe) {
|
|
|
23
23
|
options
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
const streamable = {
|
|
27
|
-
...streamableMatcher,
|
|
26
|
+
const streamable = /* @__PURE__ */ parserOf(streamableMatcher, {
|
|
28
27
|
parse(root) {
|
|
29
28
|
const wrapped = unwrapRatio(root, WRAPPER);
|
|
30
29
|
const iframe = wrapped?.iframe ?? root;
|
|
@@ -40,5 +39,5 @@ const streamable = {
|
|
|
40
39
|
const trimmed = code.slice(0, end.index).trimEnd();
|
|
41
40
|
return /^\s*<iframe[\s>]/i.test(trimmed) ? trimmed : null;
|
|
42
41
|
}
|
|
43
|
-
};
|
|
42
|
+
});
|
|
44
43
|
export { streamable };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { attributeOptions } from "../platform.js";
|
|
1
|
+
import { attributeOptions, parserOf } from "../platform.js";
|
|
2
2
|
import { coerce } from "../url.js";
|
|
3
3
|
import { CHANNEL, post, telegramMatcher } from "../matchers/telegram.js";
|
|
4
4
|
// src/parser/platforms/telegram.ts
|
|
5
|
-
const POST = new RegExp(`^(${CHANNEL})/(\\d{1,10})$`);
|
|
5
|
+
const POST = /* @__PURE__ */ new RegExp(`^(${CHANNEL})/(\\d{1,10})$`);
|
|
6
6
|
const SCRIPT = /^(?:https?:)?\/\/telegram\.org\/js\/telegram-widget\.js(?:\?\d{1,3})?$/;
|
|
7
7
|
const OTHER_WIDGETS = [
|
|
8
8
|
"data-telegram-login",
|
|
@@ -18,8 +18,7 @@ const OPTION_ATTRIBUTES = [
|
|
|
18
18
|
["data-dark", "dark"],
|
|
19
19
|
["data-dark-color", "darkColor"]
|
|
20
20
|
];
|
|
21
|
-
const telegram = {
|
|
22
|
-
...telegramMatcher,
|
|
21
|
+
const telegram = /* @__PURE__ */ parserOf(telegramMatcher, {
|
|
23
22
|
parse: () => null,
|
|
24
23
|
parseScript(script) {
|
|
25
24
|
if (!SCRIPT.test(script.attrs.get("src") ?? "")) return null;
|
|
@@ -31,5 +30,5 @@ const telegram = {
|
|
|
31
30
|
return post(channel, id, options);
|
|
32
31
|
},
|
|
33
32
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
34
|
-
};
|
|
33
|
+
});
|
|
35
34
|
export { telegram };
|