social-embeds 0.9.2 → 0.9.4
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/components/apple-embed.js +4 -4
- package/dist/components/bluesky-embed.js +2 -2
- package/dist/components/dailymotion-embed.js +2 -2
- package/dist/components/facebook-embed.js +2 -2
- package/dist/components/flickr-embed.js +2 -2
- package/dist/components/giphy-embed.js +2 -2
- package/dist/components/imgur-embed.js +2 -2
- package/dist/components/instagram-embed.js +2 -2
- package/dist/components/kick-embed.js +2 -2
- package/dist/components/linkedin-embed.js +2 -2
- package/dist/components/pinterest-embed.js +2 -2
- package/dist/components/reddit-embed.js +2 -2
- package/dist/components/rumble-embed.js +2 -2
- package/dist/components/snapchat-embed.js +2 -2
- package/dist/components/soundcloud-embed.js +2 -2
- package/dist/components/spotify-embed.js +2 -2
- package/dist/components/strava-embed.js +2 -2
- package/dist/components/streamable-embed.js +2 -2
- package/dist/components/telegram-embed.js +2 -2
- package/dist/components/tenor-embed.js +2 -2
- package/dist/components/threads-embed.js +2 -2
- package/dist/components/tiktok-embed.js +2 -2
- package/dist/components/truthsocial-embed.js +2 -2
- package/dist/components/tumblr-embed.js +2 -2
- package/dist/components/twitch-embed.js +2 -2
- package/dist/components/vimeo-embed.js +2 -2
- package/dist/components/x-embed.js +2 -2
- package/dist/components/youtube-embed.js +2 -2
- package/dist/element.js +1 -1
- package/dist/parser/iframe.js +2 -2
- package/dist/parser/matchers/applemusic.js +33 -0
- package/dist/parser/matchers/applepodcasts.js +32 -0
- package/dist/parser/matchers/bluesky.js +41 -0
- package/dist/parser/matchers/dailymotion.js +47 -0
- package/dist/parser/matchers/facebook.js +118 -0
- package/dist/parser/matchers/flickr.js +100 -0
- package/dist/parser/matchers/giphy.js +38 -0
- package/dist/parser/matchers/imgur.js +76 -0
- package/dist/parser/matchers/instagram.js +43 -0
- package/dist/parser/matchers/kick.js +48 -0
- package/dist/parser/matchers/linkedin.js +31 -0
- package/dist/parser/matchers/pinterest.js +32 -0
- package/dist/parser/matchers/reddit.js +43 -0
- package/dist/parser/matchers/rumble.js +32 -0
- package/dist/parser/matchers/snapchat.js +60 -0
- package/dist/parser/matchers/soundcloud.js +87 -0
- package/dist/parser/matchers/spotify.js +39 -0
- package/dist/parser/matchers/strava.js +31 -0
- package/dist/parser/matchers/streamable.js +59 -0
- package/dist/parser/matchers/telegram.js +34 -0
- package/dist/parser/matchers/tenor.js +34 -0
- package/dist/parser/matchers/threads.js +36 -0
- package/dist/parser/matchers/tiktok.js +25 -0
- package/dist/parser/matchers/truthsocial.js +34 -0
- package/dist/parser/matchers/tumblr.js +51 -0
- package/dist/parser/matchers/twitch.js +90 -0
- package/dist/parser/matchers/vimeo.js +71 -0
- package/dist/parser/matchers/x.js +50 -0
- package/dist/parser/matchers/youtube.js +123 -0
- package/dist/parser/platform.d.ts +13 -5
- package/dist/parser/platform.js +11 -1
- package/dist/parser/platforms/applemusic.js +6 -33
- package/dist/parser/platforms/applepodcasts.js +6 -32
- package/dist/parser/platforms/bluesky.js +7 -41
- package/dist/parser/platforms/dailymotion.js +6 -47
- package/dist/parser/platforms/facebook.js +7 -118
- package/dist/parser/platforms/flickr.js +7 -101
- package/dist/parser/platforms/giphy.js +6 -38
- package/dist/parser/platforms/imgur.js +7 -76
- package/dist/parser/platforms/instagram.js +6 -42
- package/dist/parser/platforms/kick.js +6 -48
- package/dist/parser/platforms/linkedin.js +7 -32
- package/dist/parser/platforms/pinterest.js +6 -32
- package/dist/parser/platforms/reddit.js +6 -44
- package/dist/parser/platforms/rumble.js +5 -32
- package/dist/parser/platforms/snapchat.js +5 -60
- package/dist/parser/platforms/soundcloud.js +6 -87
- package/dist/parser/platforms/spotify.js +6 -39
- package/dist/parser/platforms/strava.js +5 -30
- package/dist/parser/platforms/streamable.js +5 -59
- package/dist/parser/platforms/telegram.js +6 -35
- package/dist/parser/platforms/tenor.js +8 -36
- package/dist/parser/platforms/threads.js +6 -36
- package/dist/parser/platforms/tiktok.js +6 -25
- package/dist/parser/platforms/truthsocial.js +6 -35
- package/dist/parser/platforms/tumblr.js +7 -52
- package/dist/parser/platforms/twitch.js +6 -90
- package/dist/parser/platforms/vimeo.js +6 -71
- package/dist/parser/platforms/x.js +8 -49
- package/dist/parser/platforms/youtube.js +6 -122
- package/package.json +1 -1
|
@@ -1,30 +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
|
-
import { GIPHY_PAGE_HOSTS
|
|
3
|
+
import { GIPHY_PAGE_HOSTS } from "../frames.js";
|
|
4
|
+
import { EMBED_PATH, PAGE_PATH, gif, giphyMatcher } from "../matchers/giphy.js";
|
|
4
5
|
// src/parser/platforms/giphy.ts
|
|
5
|
-
const ID = "([A-Za-z0-9]{6,40})";
|
|
6
|
-
const PAGE_PATH = new RegExp(`^/(?:gifs|stickers)/(?:[A-Za-z0-9-]{0,200}-)?${ID}/?$`);
|
|
7
|
-
const EMBED_PATH = new RegExp(`^/embed/${ID}/?$`);
|
|
8
|
-
const MEDIA_HOST = /^(?:media\d?|i)\.giphy\.com$/;
|
|
9
|
-
const FILE_TYPE = "\\.(?:gif|webp|mp4)";
|
|
10
|
-
const MEDIA_PATH = new RegExp(`^/media/(?:v1\\.[A-Za-z0-9_-]{1,500}/)?${ID}/[A-Za-z0-9_-]{1,40}${FILE_TYPE}$`);
|
|
11
|
-
const SHORT_MEDIA_PATH = new RegExp(`^/${ID}${FILE_TYPE}$`);
|
|
12
6
|
const WRAPPER = /^width:\s*100%;\s*height:\s*0;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*position:\s*relative;?$/;
|
|
13
|
-
function gif(id) {
|
|
14
|
-
return {
|
|
15
|
-
platform: "giphy",
|
|
16
|
-
kind: "video",
|
|
17
|
-
url: `https://giphy.com/gifs/${id}`,
|
|
18
|
-
id,
|
|
19
|
-
variant: "iframe"
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function idOf(url) {
|
|
23
|
-
if (!url) return void 0;
|
|
24
|
-
if (GIPHY_PAGE_HOSTS.has(url.host)) return (PAGE_PATH.exec(url.path) ?? EMBED_PATH.exec(url.path))?.[1];
|
|
25
|
-
if (!MEDIA_HOST.test(url.host)) return void 0;
|
|
26
|
-
return (MEDIA_PATH.exec(url.path) ?? (url.host === "i.giphy.com" ? SHORT_MEDIA_PATH.exec(url.path) : null))?.[1];
|
|
27
|
-
}
|
|
28
7
|
function fromIframe(iframe) {
|
|
29
8
|
if (iframe.tag !== "iframe") return null;
|
|
30
9
|
const src = parseUrl(iframe.attrs.get("src") ?? "");
|
|
@@ -42,10 +21,7 @@ function isCredit(element, embed) {
|
|
|
42
21
|
const [text, ...more] = link.children;
|
|
43
22
|
return more.length === 0 && text?.type === "text" && text.raw.trim() === "via GIPHY";
|
|
44
23
|
}
|
|
45
|
-
const giphy = {
|
|
46
|
-
platform: "giphy",
|
|
47
|
-
name: "Giphy",
|
|
48
|
-
shapes: ["video iframe"],
|
|
24
|
+
const giphy = /* @__PURE__ */ parserOf(giphyMatcher, {
|
|
49
25
|
parse(root) {
|
|
50
26
|
const wrapped = unwrapRatio(root, WRAPPER);
|
|
51
27
|
const iframe = wrapped?.iframe ?? root;
|
|
@@ -57,14 +33,6 @@ const giphy = {
|
|
|
57
33
|
}, wrapped?.size ?? sizeOf(iframe));
|
|
58
34
|
},
|
|
59
35
|
isOwnScript: () => false,
|
|
60
|
-
isOwnExtra: isCredit
|
|
61
|
-
|
|
62
|
-
const id = idOf(url);
|
|
63
|
-
return id === void 0 ? null : {
|
|
64
|
-
...gif(id),
|
|
65
|
-
options: {}
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
ownsFrame: giphyFrame
|
|
69
|
-
};
|
|
36
|
+
isOwnExtra: isCredit
|
|
37
|
+
});
|
|
70
38
|
export { giphy };
|
|
@@ -1,67 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
2
|
+
import { hasClass, rebuild } from "../html.js";
|
|
3
|
+
import { FALLBACK, HASH, image, imgurMatcher, post } from "../matchers/imgur.js";
|
|
2
4
|
// src/parser/platforms/imgur.ts
|
|
3
|
-
const
|
|
4
|
-
"imgur.com",
|
|
5
|
-
"www.imgur.com",
|
|
6
|
-
"m.imgur.com"
|
|
7
|
-
]);
|
|
8
|
-
const HASH = "([A-Za-z0-9]{5,7})";
|
|
9
|
-
const DATA_ID = new RegExp(`^(a/)?${HASH}$`);
|
|
10
|
-
const ALBUM_PATH = new RegExp(`^/a/${HASH}/?$`);
|
|
11
|
-
const GALLERY_PATH = new RegExp(`^/gallery/(?:[A-Za-z0-9-]{1,200}-)?${HASH}/?$`);
|
|
12
|
-
const IMAGE_PATH = new RegExp(`^/${HASH}/?$`);
|
|
13
|
-
const FILE_PATH = new RegExp(`^/${HASH}\\.(?:jpe?g|png|gif|gifv|mp4|webp)$`);
|
|
5
|
+
const DATA_ID = /* @__PURE__ */ new RegExp(`^(a/)?${HASH}$`);
|
|
14
6
|
const SCRIPT = /^(?:https?:)?\/\/s\.imgur\.com\/min\/embed\.js$/;
|
|
15
|
-
const NOT_IMAGES = /* @__PURE__ */ new Set([
|
|
16
|
-
"about",
|
|
17
|
-
"apps",
|
|
18
|
-
"blog",
|
|
19
|
-
"help",
|
|
20
|
-
"jobs",
|
|
21
|
-
"login",
|
|
22
|
-
"press",
|
|
23
|
-
"privacy",
|
|
24
|
-
"random",
|
|
25
|
-
"search",
|
|
26
|
-
"signin",
|
|
27
|
-
"signup",
|
|
28
|
-
"terms",
|
|
29
|
-
"tools",
|
|
30
|
-
"upload",
|
|
31
|
-
"account",
|
|
32
|
-
"contact",
|
|
33
|
-
"emerald",
|
|
34
|
-
"explore",
|
|
35
|
-
"gallery",
|
|
36
|
-
"hot",
|
|
37
|
-
"new",
|
|
38
|
-
"rules",
|
|
39
|
-
"user"
|
|
40
|
-
]);
|
|
41
|
-
const FALLBACK = /* @__PURE__ */ new Map([["a", [{
|
|
42
|
-
name: "href",
|
|
43
|
-
value: /^https:\/\/(?:www\.)?imgur\.com\//
|
|
44
|
-
}]]]);
|
|
45
|
-
function post(id) {
|
|
46
|
-
return {
|
|
47
|
-
platform: "imgur",
|
|
48
|
-
kind: "post",
|
|
49
|
-
url: `https://imgur.com/${id}`,
|
|
50
|
-
id,
|
|
51
|
-
variant: "iframe"
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function image(hash) {
|
|
55
|
-
return hash === void 0 || NOT_IMAGES.has(hash.toLowerCase()) ? void 0 : hash;
|
|
56
|
-
}
|
|
57
|
-
function idOf(url) {
|
|
58
|
-
if (!url) return void 0;
|
|
59
|
-
if (url.host === "i.imgur.com") return image(FILE_PATH.exec(url.path)?.[1]);
|
|
60
|
-
if (!HOSTS.has(url.host)) return void 0;
|
|
61
|
-
const album = (ALBUM_PATH.exec(url.path) ?? GALLERY_PATH.exec(url.path))?.[1];
|
|
62
|
-
if (album !== void 0) return `a/${album}`;
|
|
63
|
-
return image(IMAGE_PATH.exec(url.path)?.[1]);
|
|
64
|
-
}
|
|
65
7
|
function withScheme(nodes) {
|
|
66
8
|
return nodes.map((node) => {
|
|
67
9
|
if (node.type !== "element") return node;
|
|
@@ -78,11 +20,7 @@ function withScheme(nodes) {
|
|
|
78
20
|
function falseOption(root, attribute) {
|
|
79
21
|
return root.attrs.get(attribute) === "false";
|
|
80
22
|
}
|
|
81
|
-
const imgur = {
|
|
82
|
-
platform: "imgur",
|
|
83
|
-
name: "Imgur",
|
|
84
|
-
shapes: ["post iframe"],
|
|
85
|
-
trustsFallback: (html) => rebuildsAs(html, FALLBACK),
|
|
23
|
+
const imgur = /* @__PURE__ */ parserOf(imgurMatcher, {
|
|
86
24
|
parse(root) {
|
|
87
25
|
if (root.tag !== "blockquote" || !hasClass(root, "imgur-embed-pub")) return null;
|
|
88
26
|
const id = root.attrs.get("data-id") ?? "";
|
|
@@ -97,13 +35,6 @@ const imgur = {
|
|
|
97
35
|
fallbackHtml: rebuild(withScheme(root.children), FALLBACK)
|
|
98
36
|
};
|
|
99
37
|
},
|
|
100
|
-
isOwnScript: (src) => SCRIPT.test(src)
|
|
101
|
-
|
|
102
|
-
const id = idOf(url);
|
|
103
|
-
return id === void 0 ? null : {
|
|
104
|
-
...post(id),
|
|
105
|
-
options: {}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
};
|
|
38
|
+
isOwnScript: (src) => SCRIPT.test(src)
|
|
39
|
+
});
|
|
109
40
|
export { imgur };
|
|
@@ -1,39 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
2
|
+
import { descendants, hasClass, rebuild } from "../html.js";
|
|
2
3
|
import { coerce, parseUrl } from "../url.js";
|
|
4
|
+
import { FALLBACK, instagramMatcher, post } from "../matchers/instagram.js";
|
|
3
5
|
// src/parser/platforms/instagram.ts
|
|
4
|
-
const HOSTS = /* @__PURE__ */ new Set(["instagram.com", "www.instagram.com"]);
|
|
5
|
-
const POST_PATH = /^\/(?:([A-Za-z0-9._]{1,30})\/)?(p|reel|reels|tv)\/([A-Za-z0-9_-]{1,64})\/?$/;
|
|
6
|
-
const TYPES = /* @__PURE__ */ new Set([
|
|
7
|
-
"p",
|
|
8
|
-
"reel",
|
|
9
|
-
"reels",
|
|
10
|
-
"tv"
|
|
11
|
-
]);
|
|
12
|
-
const USER_POST_TYPES = /* @__PURE__ */ new Set(["p", "reel"]);
|
|
13
6
|
const SCRIPT = /^(?:https?:)?\/\/www\.instagram\.com\/embed\.js$/;
|
|
14
|
-
const
|
|
15
|
-
["div", []],
|
|
16
|
-
["a", ["href"]],
|
|
17
|
-
["p", []]
|
|
18
|
-
]);
|
|
19
|
-
function post(url) {
|
|
20
|
-
if (!url || !HOSTS.has(url.host)) return null;
|
|
21
|
-
const [, user, type, code] = POST_PATH.exec(url.path) ?? [];
|
|
22
|
-
if (type === void 0 || code === void 0) return null;
|
|
23
|
-
if (user !== void 0 && (TYPES.has(user) || !USER_POST_TYPES.has(type))) return null;
|
|
24
|
-
return {
|
|
25
|
-
platform: "instagram",
|
|
26
|
-
kind: "post",
|
|
27
|
-
url: `https://www.instagram.com/${type === "reels" ? "reel" : type}/${code}/`,
|
|
28
|
-
id: code,
|
|
29
|
-
variant: "sdk"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const instagram = {
|
|
33
|
-
platform: "instagram",
|
|
34
|
-
name: "Instagram",
|
|
35
|
-
shapes: ["post sdk"],
|
|
36
|
-
trustsFallback: (html) => rebuildsAs(html, FALLBACK),
|
|
7
|
+
const instagram = /* @__PURE__ */ parserOf(instagramMatcher, {
|
|
37
8
|
parse(root) {
|
|
38
9
|
if (root.tag !== "blockquote" || !hasClass(root, "instagram-media")) return null;
|
|
39
10
|
const permalink = root.attrs.get("data-instgrm-permalink");
|
|
@@ -49,13 +20,6 @@ const instagram = {
|
|
|
49
20
|
fallbackHtml: rebuild(root.children, FALLBACK)
|
|
50
21
|
};
|
|
51
22
|
},
|
|
52
|
-
isOwnScript: (src) => SCRIPT.test(src)
|
|
53
|
-
|
|
54
|
-
const found = post(url);
|
|
55
|
-
return found && {
|
|
56
|
-
...found,
|
|
57
|
-
options: {}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
23
|
+
isOwnScript: (src) => SCRIPT.test(src)
|
|
24
|
+
});
|
|
61
25
|
export { instagram };
|
|
@@ -1,44 +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
|
-
import { KICK_PLAYER_HOSTS
|
|
3
|
+
import { KICK_PLAYER_HOSTS } from "../frames.js";
|
|
4
|
+
import { channel, kickMatcher } from "../matchers/kick.js";
|
|
4
5
|
// src/parser/platforms/kick.ts
|
|
5
|
-
const PAGE_HOSTS = /* @__PURE__ */ new Set(["kick.com", "www.kick.com"]);
|
|
6
|
-
const CHANNEL = /^\/([A-Za-z0-9_-]{1,32})\/?$/;
|
|
7
|
-
const NOT_CHANNELS = /* @__PURE__ */ new Set([
|
|
8
|
-
"browse",
|
|
9
|
-
"categories",
|
|
10
|
-
"category",
|
|
11
|
-
"clips",
|
|
12
|
-
"video",
|
|
13
|
-
"videos",
|
|
14
|
-
"following",
|
|
15
|
-
"search",
|
|
16
|
-
"settings",
|
|
17
|
-
"dashboard",
|
|
18
|
-
"subscriptions",
|
|
19
|
-
"privacy-policy",
|
|
20
|
-
"terms-of-service",
|
|
21
|
-
"community-guidelines",
|
|
22
|
-
"help"
|
|
23
|
-
]);
|
|
24
6
|
const KEPT = /* @__PURE__ */ new Set(["autoplay", "muted"]);
|
|
25
|
-
|
|
26
|
-
if (!url || !hosts.has(url.host)) return null;
|
|
27
|
-
const [, name] = CHANNEL.exec(url.path) ?? [];
|
|
28
|
-
if (name === void 0 || NOT_CHANNELS.has(name.toLowerCase())) return null;
|
|
29
|
-
const id = name.toLowerCase();
|
|
30
|
-
return {
|
|
31
|
-
platform: "kick",
|
|
32
|
-
kind: "video",
|
|
33
|
-
url: `https://kick.com/${id}`,
|
|
34
|
-
id,
|
|
35
|
-
variant: "iframe"
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const kick = {
|
|
39
|
-
platform: "kick",
|
|
40
|
-
name: "Kick",
|
|
41
|
-
shapes: ["video iframe"],
|
|
7
|
+
const kick = /* @__PURE__ */ parserOf(kickMatcher, {
|
|
42
8
|
parse(root) {
|
|
43
9
|
if (root.tag !== "iframe") return null;
|
|
44
10
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -50,14 +16,6 @@ const kick = {
|
|
|
50
16
|
options
|
|
51
17
|
}, sizeOf(root));
|
|
52
18
|
},
|
|
53
|
-
isOwnScript: () => false
|
|
54
|
-
|
|
55
|
-
const found = channel(url, PAGE_HOSTS) ?? channel(url, KICK_PLAYER_HOSTS);
|
|
56
|
-
return found && {
|
|
57
|
-
...found,
|
|
58
|
-
options: {}
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
ownsFrame: kickFrame
|
|
62
|
-
};
|
|
19
|
+
isOwnScript: () => false
|
|
20
|
+
});
|
|
63
21
|
export { kick };
|
|
@@ -1,28 +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
|
-
import
|
|
3
|
+
import "../frames.js";
|
|
4
|
+
import { URN, linkedinMatcher, post } from "../matchers/linkedin.js";
|
|
4
5
|
// src/parser/platforms/linkedin.ts
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const UPDATE_PATH = new RegExp(`^(?:/embed)?/feed/update/urn:li:${URN}/?$`);
|
|
8
|
-
const POSTS_PATH = new RegExp(`^/posts/[^/]{1,300}-(activity|share|ugcPost)-(\\d{19})-[A-Za-z0-9_-]{1,8}/?$`);
|
|
9
|
-
const EMBED_PATH = new RegExp(`^/embed/feed/update/urn:li:${URN}$`);
|
|
10
|
-
function post(type, id, options = {}) {
|
|
11
|
-
const urn = `urn:li:${type}:${id}`;
|
|
12
|
-
return {
|
|
13
|
-
platform: "linkedin",
|
|
14
|
-
kind: "post",
|
|
15
|
-
url: `https://www.linkedin.com/feed/update/${urn}/`,
|
|
16
|
-
id: urn,
|
|
17
|
-
variant: "iframe",
|
|
18
|
-
options
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const decodeColons = (path) => path.replace(/%3A/gi, ":");
|
|
22
|
-
const linkedin = {
|
|
23
|
-
platform: "linkedin",
|
|
24
|
-
name: "LinkedIn",
|
|
25
|
-
shapes: ["post iframe"],
|
|
6
|
+
const EMBED_PATH = /* @__PURE__ */ new RegExp(`^/embed/feed/update/urn:li:${URN}$`);
|
|
7
|
+
const linkedin = /* @__PURE__ */ parserOf(linkedinMatcher, {
|
|
26
8
|
parse(root) {
|
|
27
9
|
if (root.tag !== "iframe") return null;
|
|
28
10
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -32,13 +14,6 @@ const linkedin = {
|
|
|
32
14
|
const options = Object.fromEntries([...src.query].map(([key, value]) => [key, coerce(value)]));
|
|
33
15
|
return withSize(post(type, id, options), sizeOf(root));
|
|
34
16
|
},
|
|
35
|
-
isOwnScript: () => false
|
|
36
|
-
|
|
37
|
-
if (!HOST.test(url.host)) return null;
|
|
38
|
-
const path = decodeColons(url.path);
|
|
39
|
-
const [, type, id] = UPDATE_PATH.exec(path) ?? POSTS_PATH.exec(path) ?? [];
|
|
40
|
-
return type === void 0 || id === void 0 ? null : post(type, id);
|
|
41
|
-
},
|
|
42
|
-
ownsFrame: linkedinFrame
|
|
43
|
-
};
|
|
17
|
+
isOwnScript: () => false
|
|
18
|
+
});
|
|
44
19
|
export { linkedin };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { attributeOptions } from "../platform.js";
|
|
1
|
+
import { attributeOptions, parserOf } from "../platform.js";
|
|
2
2
|
import { coerce, parseUrl } from "../url.js";
|
|
3
|
-
import
|
|
3
|
+
import "../frames.js";
|
|
4
|
+
import { pin, pinOf, pinterestMatcher } from "../matchers/pinterest.js";
|
|
4
5
|
// src/parser/platforms/pinterest.ts
|
|
5
|
-
const HOST = /^(?:(?:www|[a-z]{2})\.)?pinterest\.(?:[a-z]{2,3}|co\.[a-z]{2}|com\.[a-z]{2})$/;
|
|
6
|
-
const PIN_PATH = /^\/pin\/(?:[A-Za-z0-9-]{0,200}--)?(\d{1,25})\/?$/;
|
|
7
6
|
const PIN_ID = /^\d{1,25}$/;
|
|
8
7
|
const SCRIPT = /^(?:https?:)?\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js$/;
|
|
9
8
|
const OPTION_ATTRIBUTES = [
|
|
@@ -11,24 +10,7 @@ const OPTION_ATTRIBUTES = [
|
|
|
11
10
|
["data-pin-lang", "lang"],
|
|
12
11
|
["data-pin-terse", "terse"]
|
|
13
12
|
];
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
platform: "pinterest",
|
|
17
|
-
kind: "post",
|
|
18
|
-
url: `https://www.pinterest.com/pin/${id}/`,
|
|
19
|
-
id,
|
|
20
|
-
variant: "sdk"
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function pinOf(url) {
|
|
24
|
-
if (!url || !HOST.test(url.host)) return null;
|
|
25
|
-
const [, id] = PIN_PATH.exec(url.path) ?? [];
|
|
26
|
-
return id === void 0 ? null : pin(id);
|
|
27
|
-
}
|
|
28
|
-
const pinterest = {
|
|
29
|
-
platform: "pinterest",
|
|
30
|
-
name: "Pinterest",
|
|
31
|
-
shapes: ["post sdk"],
|
|
13
|
+
const pinterest = /* @__PURE__ */ parserOf(pinterestMatcher, {
|
|
32
14
|
parse(root) {
|
|
33
15
|
if (root.tag === "a") {
|
|
34
16
|
if (root.attrs.get("data-pin-do") !== "embedPin") return null;
|
|
@@ -48,14 +30,6 @@ const pinterest = {
|
|
|
48
30
|
options: {}
|
|
49
31
|
} : null;
|
|
50
32
|
},
|
|
51
|
-
isOwnScript: (src) => SCRIPT.test(src)
|
|
52
|
-
|
|
53
|
-
const found = pinOf(url);
|
|
54
|
-
return found && {
|
|
55
|
-
...found,
|
|
56
|
-
options: {}
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
ownsFrame: pinterestFrame
|
|
60
|
-
};
|
|
33
|
+
isOwnScript: (src) => SCRIPT.test(src)
|
|
34
|
+
});
|
|
61
35
|
export { pinterest };
|
|
@@ -1,17 +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
|
+
import { post, redditMatcher } from "../matchers/reddit.js";
|
|
4
5
|
// src/parser/platforms/reddit.ts
|
|
5
|
-
const HOSTS = /* @__PURE__ */ new Set([
|
|
6
|
-
"reddit.com",
|
|
7
|
-
"www.reddit.com",
|
|
8
|
-
"old.reddit.com",
|
|
9
|
-
"new.reddit.com"
|
|
10
|
-
]);
|
|
11
|
-
const POST_PATH = /^\/r\/([A-Za-z0-9_]{2,21})\/comments\/([a-z0-9]{1,12})(?:\/([^/]{1,300}))?(?:\/([a-z0-9]{1,16}))?\/?$/;
|
|
12
6
|
const SCRIPT = /^(?:https?:)?\/\/embed\.reddit\.com\/widgets\.js$/;
|
|
13
7
|
const CARD_SCRIPT = /^(?:https?:)?\/\/embed\.redditmedia\.com\/widgets\/platform\.js$/;
|
|
14
|
-
const OPTION_ATTRIBUTES = [
|
|
8
|
+
const OPTION_ATTRIBUTES = /* @__PURE__ */ [
|
|
15
9
|
"depth",
|
|
16
10
|
"style",
|
|
17
11
|
"theme",
|
|
@@ -23,32 +17,7 @@ const OPTION_ATTRIBUTES = [
|
|
|
23
17
|
"showusername",
|
|
24
18
|
"snippet"
|
|
25
19
|
].map((name) => [`data-embed-${name}`, name]);
|
|
26
|
-
|
|
27
|
-
if (!url || !HOSTS.has(url.host)) return null;
|
|
28
|
-
const [, sub, postId, slug, commentId] = POST_PATH.exec(url.path) ?? [];
|
|
29
|
-
if (sub === void 0 || postId === void 0) return null;
|
|
30
|
-
const base = {
|
|
31
|
-
platform: "reddit",
|
|
32
|
-
kind: "post",
|
|
33
|
-
variant: "iframe"
|
|
34
|
-
};
|
|
35
|
-
const postUrl = `https://www.reddit.com/r/${sub}/comments/${postId}/`;
|
|
36
|
-
if (commentId === void 0) return {
|
|
37
|
-
...base,
|
|
38
|
-
url: postUrl,
|
|
39
|
-
id: postId
|
|
40
|
-
};
|
|
41
|
-
if (slug === void 0) return null;
|
|
42
|
-
return {
|
|
43
|
-
...base,
|
|
44
|
-
url: `${postUrl}comment/${commentId}/`,
|
|
45
|
-
id: commentId
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const reddit = {
|
|
49
|
-
platform: "reddit",
|
|
50
|
-
name: "Reddit",
|
|
51
|
-
shapes: ["post iframe"],
|
|
20
|
+
const reddit = /* @__PURE__ */ parserOf(redditMatcher, {
|
|
52
21
|
parse(root) {
|
|
53
22
|
if (root.tag !== "blockquote" || !(hasClass(root, "reddit-embed-bq") || hasClass(root, "reddit-card"))) return null;
|
|
54
23
|
const found = descendants(root.children).map((element) => element.tag === "a" ? post(parseUrl(element.attrs.get("href") ?? "")) : null).find((embed) => embed !== null);
|
|
@@ -59,13 +28,6 @@ const reddit = {
|
|
|
59
28
|
options: attributeOptions(root, OPTION_ATTRIBUTES, coerce)
|
|
60
29
|
}, height === void 0 ? void 0 : { height });
|
|
61
30
|
},
|
|
62
|
-
isOwnScript: (src) => SCRIPT.test(src) || CARD_SCRIPT.test(src)
|
|
63
|
-
|
|
64
|
-
const found = post(url);
|
|
65
|
-
return found && {
|
|
66
|
-
...found,
|
|
67
|
-
options: {}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
};
|
|
31
|
+
isOwnScript: (src) => SCRIPT.test(src) || CARD_SCRIPT.test(src)
|
|
32
|
+
});
|
|
71
33
|
export { reddit };
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
1
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
3
2
|
import { coerce, parseUrl } from "../url.js";
|
|
4
|
-
import {
|
|
3
|
+
import { idOf, rumbleMatcher, video } from "../matchers/rumble.js";
|
|
5
4
|
// src/parser/platforms/rumble.ts
|
|
6
|
-
const
|
|
7
|
-
const HOSTS = /* @__PURE__ */ new Set(["rumble.com", "www.rumble.com"]);
|
|
8
|
-
function video(id) {
|
|
9
|
-
return {
|
|
10
|
-
platform: "rumble",
|
|
11
|
-
kind: "video",
|
|
12
|
-
url: `https://rumble.com/embed/${id}/`,
|
|
13
|
-
id,
|
|
14
|
-
variant: "iframe"
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function idOf(url, hosts) {
|
|
18
|
-
return url && hosts.has(url.host) ? PATH.exec(url.path)?.[1] : void 0;
|
|
19
|
-
}
|
|
20
|
-
const rumble = {
|
|
21
|
-
platform: "rumble",
|
|
22
|
-
name: "Rumble",
|
|
23
|
-
shapes: ["video iframe"],
|
|
24
|
-
needsLookup: rumbleNeedsLookup,
|
|
5
|
+
const rumble = /* @__PURE__ */ parserOf(rumbleMatcher, {
|
|
25
6
|
parse(root) {
|
|
26
7
|
if (root.tag !== "iframe") return null;
|
|
27
8
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -35,14 +16,6 @@ const rumble = {
|
|
|
35
16
|
options
|
|
36
17
|
}, sizeOf(root));
|
|
37
18
|
},
|
|
38
|
-
isOwnScript: () => false
|
|
39
|
-
|
|
40
|
-
const id = idOf(url, HOSTS);
|
|
41
|
-
return id === void 0 ? null : {
|
|
42
|
-
...video(id),
|
|
43
|
-
options: {}
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
ownsFrame: rumbleFrame
|
|
47
|
-
};
|
|
19
|
+
isOwnScript: () => false
|
|
20
|
+
});
|
|
48
21
|
export { rumble };
|
|
@@ -1,58 +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
|
+
import { content, snapchatMatcher } from "../matchers/snapchat.js";
|
|
4
5
|
// src/parser/platforms/snapchat.ts
|
|
5
|
-
const HOSTS = /* @__PURE__ */ new Set(["snapchat.com", "www.snapchat.com"]);
|
|
6
|
-
const USER = "([A-Za-z][A-Za-z0-9._-]{1,29})";
|
|
7
|
-
const SPOTLIGHT = new RegExp(`^(?:/@${USER})?/spotlight/([A-Za-z0-9_-]{20,120})$`);
|
|
8
|
-
const PROFILE = new RegExp(`^/(?:@|add/)${USER}$`);
|
|
9
|
-
const LENS = /^\/lens\/([0-9a-f]{32}|\d{1,20})$/;
|
|
10
|
-
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})$`);
|
|
11
6
|
const SCRIPT = /^(?:https?:)?\/\/www\.snapchat\.com\/embed\.js$/;
|
|
12
|
-
|
|
13
|
-
if (!url || !HOSTS.has(url.host)) return null;
|
|
14
|
-
const path = url.path.replace(/\/$/, "");
|
|
15
|
-
const base = {
|
|
16
|
-
platform: "snapchat",
|
|
17
|
-
variant: "iframe"
|
|
18
|
-
};
|
|
19
|
-
const [, spotlightUser, spotlightId] = SPOTLIGHT.exec(path) ?? [];
|
|
20
|
-
if (spotlightId !== void 0) {
|
|
21
|
-
const prefix = spotlightUser === void 0 ? "" : `/@${spotlightUser}`;
|
|
22
|
-
return {
|
|
23
|
-
...base,
|
|
24
|
-
kind: "video",
|
|
25
|
-
url: `https://www.snapchat.com${prefix}/spotlight/${spotlightId}`,
|
|
26
|
-
id: spotlightId
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const [, user] = PROFILE.exec(path) ?? [];
|
|
30
|
-
if (user !== void 0) return {
|
|
31
|
-
...base,
|
|
32
|
-
kind: "post",
|
|
33
|
-
url: `https://www.snapchat.com/@${user}`,
|
|
34
|
-
id: user
|
|
35
|
-
};
|
|
36
|
-
const [, lens] = LENS.exec(path) ?? [];
|
|
37
|
-
if (lens !== void 0) return {
|
|
38
|
-
...base,
|
|
39
|
-
kind: "post",
|
|
40
|
-
url: `https://www.snapchat.com/lens/${lens}`,
|
|
41
|
-
id: lens
|
|
42
|
-
};
|
|
43
|
-
const [, owner, highlight] = HIGHLIGHT.exec(path) ?? [];
|
|
44
|
-
if (owner !== void 0 && highlight !== void 0) return {
|
|
45
|
-
...base,
|
|
46
|
-
kind: "post",
|
|
47
|
-
url: `https://www.snapchat.com/@${owner}/highlight/${highlight}`,
|
|
48
|
-
id: highlight
|
|
49
|
-
};
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const snapchat = {
|
|
53
|
-
platform: "snapchat",
|
|
54
|
-
name: "Snapchat",
|
|
55
|
-
shapes: ["post iframe", "video iframe"],
|
|
7
|
+
const snapchat = /* @__PURE__ */ parserOf(snapchatMatcher, {
|
|
56
8
|
parse(root) {
|
|
57
9
|
if (root.tag !== "blockquote" || !hasClass(root, "snapchat-embed")) return null;
|
|
58
10
|
const embedUrl = parseUrl(root.attrs.get("data-snapchat-embed-url") ?? "");
|
|
@@ -77,13 +29,6 @@ const snapchat = {
|
|
|
77
29
|
height
|
|
78
30
|
});
|
|
79
31
|
},
|
|
80
|
-
isOwnScript: (src) => SCRIPT.test(src)
|
|
81
|
-
|
|
82
|
-
const found = content(url);
|
|
83
|
-
return found && {
|
|
84
|
-
...found,
|
|
85
|
-
options: {}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
};
|
|
32
|
+
isOwnScript: (src) => SCRIPT.test(src)
|
|
33
|
+
});
|
|
89
34
|
export { snapchat };
|