social-embeds 0.7.1 → 0.8.0
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 +13 -8
- package/dist/components/apple-embed.d.ts +7 -0
- package/dist/components/apple-embed.js +39 -0
- package/dist/components/bluesky-embed.d.ts +10 -0
- package/dist/components/bluesky-embed.js +27 -0
- package/dist/components/dailymotion-embed.d.ts +9 -0
- package/dist/components/dailymotion-embed.js +30 -0
- package/dist/components/facebook-embed.d.ts +6 -0
- package/dist/components/facebook-embed.js +40 -0
- package/dist/components/flickr-embed.d.ts +6 -0
- package/dist/components/flickr-embed.js +27 -0
- package/dist/components/generic-iframe-embed.d.ts +11 -0
- package/dist/components/generic-iframe-embed.js +26 -0
- package/dist/components/giphy-embed.d.ts +4 -0
- package/dist/components/giphy-embed.js +22 -0
- package/dist/components/hooks.js +36 -0
- package/dist/components/iframe-embed.js +169 -0
- package/dist/components/imgur-embed.d.ts +6 -0
- package/dist/components/imgur-embed.js +23 -0
- package/dist/components/instagram-embed.d.ts +5 -0
- package/dist/components/instagram-embed.js +25 -0
- package/dist/components/kick-embed.d.ts +6 -0
- package/dist/components/kick-embed.js +25 -0
- package/dist/components/linkedin-embed.d.ts +6 -0
- package/dist/components/linkedin-embed.js +23 -0
- package/dist/components/pinterest-embed.d.ts +5 -0
- package/dist/components/pinterest-embed.js +25 -0
- package/dist/components/reddit-embed.d.ts +6 -0
- package/dist/components/reddit-embed.js +29 -0
- package/dist/components/rumble-embed.d.ts +4 -0
- package/dist/components/rumble-embed.js +22 -0
- package/dist/components/script-embed.js +107 -0
- package/dist/components/shared.d.ts +29 -0
- package/dist/components/snapchat-embed.d.ts +4 -0
- package/dist/components/snapchat-embed.js +22 -0
- package/dist/components/social-embed.d.ts +60 -0
- package/dist/components/social-embed.js +221 -0
- package/dist/components/soundcloud-embed.d.ts +6 -0
- package/dist/components/soundcloud-embed.js +33 -0
- package/dist/components/spotify-embed.d.ts +9 -0
- package/dist/components/spotify-embed.js +25 -0
- package/dist/components/strava-embed.d.ts +6 -0
- package/dist/components/strava-embed.js +26 -0
- package/dist/components/streamable-embed.d.ts +6 -0
- package/dist/components/streamable-embed.js +28 -0
- package/dist/components/telegram-embed.d.ts +6 -0
- package/dist/components/telegram-embed.js +27 -0
- package/dist/components/tenor-embed.d.ts +4 -0
- package/dist/components/tenor-embed.js +22 -0
- package/dist/components/threads-embed.d.ts +5 -0
- package/dist/components/threads-embed.js +25 -0
- package/dist/components/tiktok-embed.d.ts +6 -0
- package/dist/components/tiktok-embed.js +37 -0
- package/dist/components/truthsocial-embed.d.ts +4 -0
- package/dist/components/truthsocial-embed.js +22 -0
- package/dist/components/tumblr-embed.d.ts +4 -0
- package/dist/components/tumblr-embed.js +22 -0
- package/dist/components/twitch-embed.d.ts +6 -0
- package/dist/components/twitch-embed.js +26 -0
- package/dist/components/vimeo-embed.d.ts +5 -0
- package/dist/components/vimeo-embed.js +40 -0
- package/dist/components/x-embed.d.ts +5 -0
- package/dist/components/x-embed.js +32 -0
- package/dist/components/youtube-embed.d.ts +5 -0
- package/dist/components/youtube-embed.js +43 -0
- package/dist/core/drivers.js +118 -0
- package/dist/core/layout.js +73 -0
- package/dist/core/markup.js +30 -0
- package/dist/core/params.js +26 -0
- package/dist/core/plans/apple.js +44 -0
- package/dist/core/plans/bluesky.d.ts +3 -0
- package/dist/core/plans/bluesky.js +34 -0
- package/dist/core/plans/dailymotion.d.ts +8 -0
- package/dist/core/plans/dailymotion.js +37 -0
- package/dist/core/plans/facebook.d.ts +15 -0
- package/dist/core/plans/facebook.js +79 -0
- package/dist/core/plans/flickr.d.ts +7 -0
- package/dist/core/plans/flickr.js +37 -0
- package/dist/core/plans/generic.js +44 -0
- package/dist/core/plans/giphy.js +16 -0
- package/dist/core/plans/imgur.d.ts +4 -0
- package/dist/core/plans/imgur.js +34 -0
- package/dist/core/plans/instagram.d.ts +4 -0
- package/dist/core/plans/instagram.js +26 -0
- package/dist/core/plans/kick.d.ts +5 -0
- package/dist/core/plans/kick.js +22 -0
- package/dist/core/plans/linkedin.d.ts +4 -0
- package/dist/core/plans/linkedin.js +23 -0
- package/dist/core/plans/pinterest.d.ts +4 -0
- package/dist/core/plans/pinterest.js +31 -0
- package/dist/core/plans/reddit.d.ts +11 -0
- package/dist/core/plans/reddit.js +46 -0
- package/dist/core/plans/rumble.js +21 -0
- package/dist/core/plans/snapchat.js +20 -0
- package/dist/core/plans/soundcloud.d.ts +14 -0
- package/dist/core/plans/soundcloud.js +37 -0
- package/dist/core/plans/spotify.d.ts +4 -0
- package/dist/core/plans/spotify.js +29 -0
- package/dist/core/plans/strava.d.ts +8 -0
- package/dist/core/plans/strava.js +38 -0
- package/dist/core/plans/streamable.d.ts +8 -0
- package/dist/core/plans/streamable.js +31 -0
- package/dist/core/plans/telegram.d.ts +10 -0
- package/dist/core/plans/telegram.js +59 -0
- package/dist/core/plans/tenor.js +16 -0
- package/dist/core/plans/threads.d.ts +4 -0
- package/dist/core/plans/threads.js +25 -0
- package/dist/core/plans/tiktok.d.ts +17 -0
- package/dist/core/plans/tiktok.js +36 -0
- package/dist/core/plans/truthsocial.js +43 -0
- package/dist/core/plans/tumblr.js +29 -0
- package/dist/core/plans/twitch.d.ts +7 -0
- package/dist/core/plans/twitch.js +38 -0
- package/dist/core/plans/vimeo.d.ts +23 -0
- package/dist/core/plans/vimeo.js +42 -0
- package/dist/core/plans/x.d.ts +12 -0
- package/dist/core/plans/x.js +31 -0
- package/dist/core/plans/youtube.d.ts +25 -0
- package/dist/core/plans/youtube.js +47 -0
- package/dist/core/post-link.js +19 -0
- package/dist/core/resolve.js +57 -0
- package/dist/core/timing.js +7 -0
- package/dist/element.js +1 -1
- package/dist/index.d.ts +53 -344
- package/dist/index.js +30 -2575
- package/dist/loader/load-script.js +114 -0
- package/dist/loader/platform-scripts.js +89 -0
- package/dist/parser/html.js +172 -0
- package/dist/parser/iframe.d.ts +24 -0
- package/dist/parser/iframe.js +151 -0
- package/dist/parser/lookup.js +20 -0
- package/dist/parser/match-url.d.ts +3 -0
- package/dist/parser/match-url.js +22 -0
- package/dist/parser/parse-embed.d.ts +7 -0
- package/dist/parser/parse-embed.js +69 -0
- package/dist/parser/platform.js +60 -0
- package/dist/parser/platforms/applemusic.js +45 -0
- package/dist/parser/platforms/applepodcasts.js +41 -0
- package/dist/parser/platforms/bluesky.js +64 -0
- package/dist/parser/platforms/dailymotion.js +59 -0
- package/dist/parser/platforms/facebook.js +185 -0
- package/dist/parser/platforms/flickr.js +134 -0
- package/dist/parser/platforms/giphy.js +68 -0
- package/dist/parser/platforms/imgur.js +107 -0
- package/dist/parser/platforms/index.js +62 -0
- package/dist/parser/platforms/instagram.js +59 -0
- package/dist/parser/platforms/kick.js +61 -0
- package/dist/parser/platforms/linkedin.js +42 -0
- package/dist/parser/platforms/pinterest.js +59 -0
- package/dist/parser/platforms/reddit.js +68 -0
- package/dist/parser/platforms/rumble.js +43 -0
- package/dist/parser/platforms/snapchat.js +87 -0
- package/dist/parser/platforms/soundcloud.js +128 -0
- package/dist/parser/platforms/spotify.js +51 -0
- package/dist/parser/platforms/strava.js +55 -0
- package/dist/parser/platforms/streamable.js +94 -0
- package/dist/parser/platforms/telegram.js +61 -0
- package/dist/parser/platforms/tenor.js +78 -0
- package/dist/parser/platforms/threads.js +51 -0
- package/dist/parser/platforms/tiktok.js +48 -0
- package/dist/parser/platforms/truthsocial.js +49 -0
- package/dist/parser/platforms/tumblr.js +70 -0
- package/dist/parser/platforms/twitch.js +129 -0
- package/dist/parser/platforms/vimeo.js +76 -0
- package/dist/parser/platforms/x.js +65 -0
- package/dist/parser/platforms/youtube.js +90 -0
- package/dist/parser/types.d.ts +14 -0
- package/dist/parser/url.js +41 -0
- package/dist/parser/verify.js +63 -0
- package/dist/parser.d.ts +4 -1
- package/dist/parser.js +4 -1
- package/package.json +1 -1
- package/dist/index-DrMHAkyG.d.ts +0 -46
- package/dist/parser-CovaPg5T.js +0 -2585
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { hasClass, rebuild } from "../html.js";
|
|
2
|
+
// src/parser/platforms/imgur.ts
|
|
3
|
+
const HOSTS = /* @__PURE__ */ new Set([
|
|
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)$`);
|
|
14
|
+
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
|
+
function withScheme(nodes) {
|
|
66
|
+
return nodes.map((node) => {
|
|
67
|
+
if (node.type !== "element") return node;
|
|
68
|
+
const href = node.attrs.get("href");
|
|
69
|
+
const attrs = new Map(node.attrs);
|
|
70
|
+
if (node.tag === "a" && href?.startsWith("//")) attrs.set("href", `https:${href}`);
|
|
71
|
+
return {
|
|
72
|
+
...node,
|
|
73
|
+
attrs,
|
|
74
|
+
children: withScheme(node.children)
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function falseOption(root, attribute) {
|
|
79
|
+
return root.attrs.get(attribute) === "false";
|
|
80
|
+
}
|
|
81
|
+
const imgur = {
|
|
82
|
+
platform: "imgur",
|
|
83
|
+
fallback: FALLBACK,
|
|
84
|
+
parse(root) {
|
|
85
|
+
if (root.tag !== "blockquote" || !hasClass(root, "imgur-embed-pub")) return null;
|
|
86
|
+
const id = root.attrs.get("data-id") ?? "";
|
|
87
|
+
const [, album, hash] = DATA_ID.exec(id) ?? [];
|
|
88
|
+
if (hash === void 0 || album === void 0 && !image(hash)) return null;
|
|
89
|
+
const options = {};
|
|
90
|
+
if (falseOption(root, "data-context")) options.context = false;
|
|
91
|
+
if (falseOption(root, "data-analytics")) options.analytics = false;
|
|
92
|
+
return {
|
|
93
|
+
...post(id),
|
|
94
|
+
options,
|
|
95
|
+
fallbackHtml: rebuild(withScheme(root.children), FALLBACK)
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
isOwnScript: (src) => SCRIPT.test(src),
|
|
99
|
+
match(url) {
|
|
100
|
+
const id = idOf(url);
|
|
101
|
+
return id === void 0 ? null : {
|
|
102
|
+
...post(id),
|
|
103
|
+
options: {}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
export { imgur };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { applemusic } from "./applemusic.js";
|
|
2
|
+
import { applepodcasts } from "./applepodcasts.js";
|
|
3
|
+
import { bluesky } from "./bluesky.js";
|
|
4
|
+
import { dailymotion } from "./dailymotion.js";
|
|
5
|
+
import { facebook } from "./facebook.js";
|
|
6
|
+
import { flickr } from "./flickr.js";
|
|
7
|
+
import { giphy } from "./giphy.js";
|
|
8
|
+
import { imgur } from "./imgur.js";
|
|
9
|
+
import { instagram } from "./instagram.js";
|
|
10
|
+
import { kick } from "./kick.js";
|
|
11
|
+
import { linkedin } from "./linkedin.js";
|
|
12
|
+
import { pinterest } from "./pinterest.js";
|
|
13
|
+
import { reddit } from "./reddit.js";
|
|
14
|
+
import { snapchat } from "./snapchat.js";
|
|
15
|
+
import { soundcloud } from "./soundcloud.js";
|
|
16
|
+
import { rumble } from "./rumble.js";
|
|
17
|
+
import { spotify } from "./spotify.js";
|
|
18
|
+
import { strava } from "./strava.js";
|
|
19
|
+
import { streamable } from "./streamable.js";
|
|
20
|
+
import { telegram } from "./telegram.js";
|
|
21
|
+
import { tenor } from "./tenor.js";
|
|
22
|
+
import { threads } from "./threads.js";
|
|
23
|
+
import { tiktok } from "./tiktok.js";
|
|
24
|
+
import { truthsocial } from "./truthsocial.js";
|
|
25
|
+
import { tumblr } from "./tumblr.js";
|
|
26
|
+
import { twitch } from "./twitch.js";
|
|
27
|
+
import { vimeo } from "./vimeo.js";
|
|
28
|
+
import { x } from "./x.js";
|
|
29
|
+
import { youtube } from "./youtube.js";
|
|
30
|
+
// src/parser/platforms/index.ts
|
|
31
|
+
const platforms = [
|
|
32
|
+
x,
|
|
33
|
+
instagram,
|
|
34
|
+
facebook,
|
|
35
|
+
threads,
|
|
36
|
+
tiktok,
|
|
37
|
+
youtube,
|
|
38
|
+
telegram,
|
|
39
|
+
snapchat,
|
|
40
|
+
linkedin,
|
|
41
|
+
reddit,
|
|
42
|
+
pinterest,
|
|
43
|
+
spotify,
|
|
44
|
+
vimeo,
|
|
45
|
+
twitch,
|
|
46
|
+
dailymotion,
|
|
47
|
+
soundcloud,
|
|
48
|
+
applemusic,
|
|
49
|
+
applepodcasts,
|
|
50
|
+
kick,
|
|
51
|
+
giphy,
|
|
52
|
+
tenor,
|
|
53
|
+
streamable,
|
|
54
|
+
rumble,
|
|
55
|
+
truthsocial,
|
|
56
|
+
imgur,
|
|
57
|
+
strava,
|
|
58
|
+
flickr,
|
|
59
|
+
bluesky,
|
|
60
|
+
tumblr
|
|
61
|
+
];
|
|
62
|
+
export { platforms };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { descendants, hasClass, rebuild } from "../html.js";
|
|
2
|
+
import { coerce, parseUrl } from "../url.js";
|
|
3
|
+
// 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
|
+
const SCRIPT = /^(?:https?:)?\/\/www\.instagram\.com\/embed\.js$/;
|
|
14
|
+
const FALLBACK = /* @__PURE__ */ new Map([
|
|
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
|
+
fallback: FALLBACK,
|
|
35
|
+
parse(root) {
|
|
36
|
+
if (root.tag !== "blockquote" || !hasClass(root, "instagram-media")) return null;
|
|
37
|
+
const permalink = root.attrs.get("data-instgrm-permalink");
|
|
38
|
+
const found = permalink === void 0 ? descendants(root.children).reverse().map((element) => element.tag === "a" ? post(parseUrl(element.attrs.get("href") ?? "")) : null).find((candidate) => candidate !== null) : post(parseUrl(permalink));
|
|
39
|
+
if (!found) return null;
|
|
40
|
+
const options = {};
|
|
41
|
+
if (root.attrs.has("data-instgrm-captioned")) options.captioned = true;
|
|
42
|
+
const version = root.attrs.get("data-instgrm-version");
|
|
43
|
+
if (version !== void 0) options.version = coerce(version);
|
|
44
|
+
return {
|
|
45
|
+
...found,
|
|
46
|
+
options,
|
|
47
|
+
fallbackHtml: rebuild(root.children, FALLBACK)
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
isOwnScript: (src) => SCRIPT.test(src),
|
|
51
|
+
match(url) {
|
|
52
|
+
const found = post(url);
|
|
53
|
+
return found && {
|
|
54
|
+
...found,
|
|
55
|
+
options: {}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export { instagram };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { sizeOf, withSize } from "../platform.js";
|
|
2
|
+
import { coerce, parseUrl } from "../url.js";
|
|
3
|
+
// src/parser/platforms/kick.ts
|
|
4
|
+
const PAGE_HOSTS = /* @__PURE__ */ new Set(["kick.com", "www.kick.com"]);
|
|
5
|
+
const CHANNEL = /^\/([A-Za-z0-9_-]{1,32})\/?$/;
|
|
6
|
+
const NOT_CHANNELS = /* @__PURE__ */ new Set([
|
|
7
|
+
"browse",
|
|
8
|
+
"categories",
|
|
9
|
+
"category",
|
|
10
|
+
"clips",
|
|
11
|
+
"video",
|
|
12
|
+
"videos",
|
|
13
|
+
"following",
|
|
14
|
+
"search",
|
|
15
|
+
"settings",
|
|
16
|
+
"dashboard",
|
|
17
|
+
"subscriptions",
|
|
18
|
+
"privacy-policy",
|
|
19
|
+
"terms-of-service",
|
|
20
|
+
"community-guidelines",
|
|
21
|
+
"help"
|
|
22
|
+
]);
|
|
23
|
+
const KEPT = /* @__PURE__ */ new Set(["autoplay", "muted"]);
|
|
24
|
+
function channel(url, hosts) {
|
|
25
|
+
if (!url || !hosts.has(url.host)) return null;
|
|
26
|
+
const [, name] = CHANNEL.exec(url.path) ?? [];
|
|
27
|
+
if (name === void 0 || NOT_CHANNELS.has(name.toLowerCase())) return null;
|
|
28
|
+
const id = name.toLowerCase();
|
|
29
|
+
return {
|
|
30
|
+
platform: "kick",
|
|
31
|
+
kind: "video",
|
|
32
|
+
url: `https://kick.com/${id}`,
|
|
33
|
+
id,
|
|
34
|
+
variant: "iframe"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const PLAYER = /* @__PURE__ */ new Set(["player.kick.com"]);
|
|
38
|
+
const kick = {
|
|
39
|
+
platform: "kick",
|
|
40
|
+
parse(root) {
|
|
41
|
+
if (root.tag !== "iframe") return null;
|
|
42
|
+
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
43
|
+
const found = channel(src, PLAYER);
|
|
44
|
+
if (!found || !src) return null;
|
|
45
|
+
const options = Object.fromEntries([...src.query].filter(([key]) => KEPT.has(key)).map(([key, value]) => [key, coerce(value)]));
|
|
46
|
+
return withSize({
|
|
47
|
+
...found,
|
|
48
|
+
options
|
|
49
|
+
}, sizeOf(root));
|
|
50
|
+
},
|
|
51
|
+
isOwnScript: () => false,
|
|
52
|
+
match(url) {
|
|
53
|
+
const found = channel(url, PAGE_HOSTS) ?? channel(url, PLAYER);
|
|
54
|
+
return found && {
|
|
55
|
+
...found,
|
|
56
|
+
options: {}
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
ownsFrame: (src) => PLAYER.has(src.host)
|
|
60
|
+
};
|
|
61
|
+
export { kick };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { sizeOf, underPath, withSize } from "../platform.js";
|
|
2
|
+
import { coerce, parseUrl } from "../url.js";
|
|
3
|
+
// src/parser/platforms/linkedin.ts
|
|
4
|
+
const HOST = /^(?:www\.|[a-z]{2}\.)?linkedin\.com$/;
|
|
5
|
+
const FRAME_HOST = "www.linkedin.com";
|
|
6
|
+
const URN = "(activity|share|ugcPost):(\\d{19})";
|
|
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
|
+
parse(root) {
|
|
25
|
+
if (root.tag !== "iframe") return null;
|
|
26
|
+
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
27
|
+
if (src?.host !== FRAME_HOST) return null;
|
|
28
|
+
const [, type, id] = EMBED_PATH.exec(src.path) ?? [];
|
|
29
|
+
if (type === void 0 || id === void 0) return null;
|
|
30
|
+
const options = Object.fromEntries([...src.query].map(([key, value]) => [key, coerce(value)]));
|
|
31
|
+
return withSize(post(type, id, options), sizeOf(root));
|
|
32
|
+
},
|
|
33
|
+
isOwnScript: () => false,
|
|
34
|
+
match(url) {
|
|
35
|
+
if (!HOST.test(url.host)) return null;
|
|
36
|
+
const path = decodeColons(url.path);
|
|
37
|
+
const [, type, id] = UPDATE_PATH.exec(path) ?? POSTS_PATH.exec(path) ?? [];
|
|
38
|
+
return type === void 0 || id === void 0 ? null : post(type, id);
|
|
39
|
+
},
|
|
40
|
+
ownsFrame: (src) => src.host === FRAME_HOST && underPath(src.path, "/embed")
|
|
41
|
+
};
|
|
42
|
+
export { linkedin };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { attributeOptions } from "../platform.js";
|
|
2
|
+
import { coerce, parseUrl } from "../url.js";
|
|
3
|
+
// src/parser/platforms/pinterest.ts
|
|
4
|
+
const HOST = /^(?:(?:www|[a-z]{2})\.)?pinterest\.(?:[a-z]{2,3}|co\.[a-z]{2}|com\.[a-z]{2})$/;
|
|
5
|
+
const PIN_PATH = /^\/pin\/(?:[A-Za-z0-9-]{0,200}--)?(\d{1,25})\/?$/;
|
|
6
|
+
const PIN_ID = /^\d{1,25}$/;
|
|
7
|
+
const FRAME_HOST = "assets.pinterest.com";
|
|
8
|
+
const SCRIPT = /^(?:https?:)?\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js$/;
|
|
9
|
+
const OPTION_ATTRIBUTES = [
|
|
10
|
+
["data-pin-width", "width"],
|
|
11
|
+
["data-pin-lang", "lang"],
|
|
12
|
+
["data-pin-terse", "terse"]
|
|
13
|
+
];
|
|
14
|
+
function pin(id) {
|
|
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
|
+
parse(root) {
|
|
31
|
+
if (root.tag === "a") {
|
|
32
|
+
if (root.attrs.get("data-pin-do") !== "embedPin") return null;
|
|
33
|
+
if (root.children.some((child) => child.type === "element")) return null;
|
|
34
|
+
const found = pinOf(parseUrl(root.attrs.get("href") ?? ""));
|
|
35
|
+
return found && {
|
|
36
|
+
...found,
|
|
37
|
+
options: attributeOptions(root, OPTION_ATTRIBUTES, coerce)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (root.tag !== "iframe") return null;
|
|
41
|
+
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
42
|
+
if (src?.host !== FRAME_HOST || src.path !== "/ext/embed.html") return null;
|
|
43
|
+
const id = src.query.get("id");
|
|
44
|
+
return id !== void 0 && PIN_ID.test(id) ? {
|
|
45
|
+
...pin(id),
|
|
46
|
+
options: {}
|
|
47
|
+
} : null;
|
|
48
|
+
},
|
|
49
|
+
isOwnScript: (src) => SCRIPT.test(src),
|
|
50
|
+
match(url) {
|
|
51
|
+
const found = pinOf(url);
|
|
52
|
+
return found && {
|
|
53
|
+
...found,
|
|
54
|
+
options: {}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
ownsFrame: (src) => src.host === FRAME_HOST
|
|
58
|
+
};
|
|
59
|
+
export { pinterest };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { descendants, hasClass } from "../html.js";
|
|
2
|
+
import { attributeOptions, withSize } from "../platform.js";
|
|
3
|
+
import { coerce, parseUrl, pixels } from "../url.js";
|
|
4
|
+
// 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
|
+
const SCRIPT = /^(?:https?:)?\/\/embed\.reddit\.com\/widgets\.js$/;
|
|
13
|
+
const OPTION_ATTRIBUTES = [
|
|
14
|
+
"depth",
|
|
15
|
+
"style",
|
|
16
|
+
"theme",
|
|
17
|
+
"showmedia",
|
|
18
|
+
"showtitle",
|
|
19
|
+
"showedits",
|
|
20
|
+
"created",
|
|
21
|
+
"locale",
|
|
22
|
+
"showusername",
|
|
23
|
+
"snippet"
|
|
24
|
+
].map((name) => [`data-embed-${name}`, name]);
|
|
25
|
+
function post(url) {
|
|
26
|
+
if (!url || !HOSTS.has(url.host)) return null;
|
|
27
|
+
const [, sub, postId, slug, commentId] = POST_PATH.exec(url.path) ?? [];
|
|
28
|
+
if (sub === void 0 || postId === void 0) return null;
|
|
29
|
+
const base = {
|
|
30
|
+
platform: "reddit",
|
|
31
|
+
kind: "post",
|
|
32
|
+
variant: "iframe"
|
|
33
|
+
};
|
|
34
|
+
const postUrl = `https://www.reddit.com/r/${sub}/comments/${postId}/`;
|
|
35
|
+
if (commentId === void 0) return {
|
|
36
|
+
...base,
|
|
37
|
+
url: postUrl,
|
|
38
|
+
id: postId
|
|
39
|
+
};
|
|
40
|
+
if (slug === void 0) return null;
|
|
41
|
+
return {
|
|
42
|
+
...base,
|
|
43
|
+
url: `${postUrl}comment/${commentId}/`,
|
|
44
|
+
id: commentId
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const reddit = {
|
|
48
|
+
platform: "reddit",
|
|
49
|
+
parse(root) {
|
|
50
|
+
if (root.tag !== "blockquote" || !hasClass(root, "reddit-embed-bq")) return null;
|
|
51
|
+
const found = descendants(root.children).map((element) => element.tag === "a" ? post(parseUrl(element.attrs.get("href") ?? "")) : null).find((embed) => embed !== null);
|
|
52
|
+
if (!found) return null;
|
|
53
|
+
const height = pixels(root.attrs.get("data-embed-height"));
|
|
54
|
+
return withSize({
|
|
55
|
+
...found,
|
|
56
|
+
options: attributeOptions(root, OPTION_ATTRIBUTES, coerce)
|
|
57
|
+
}, height === void 0 ? void 0 : { height });
|
|
58
|
+
},
|
|
59
|
+
isOwnScript: (src) => SCRIPT.test(src),
|
|
60
|
+
match(url) {
|
|
61
|
+
const found = post(url);
|
|
62
|
+
return found && {
|
|
63
|
+
...found,
|
|
64
|
+
options: {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export { reddit };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { sizeOf, underPath, withSize } from "../platform.js";
|
|
2
|
+
import { coerce, parseUrl } from "../url.js";
|
|
3
|
+
// src/parser/platforms/rumble.ts
|
|
4
|
+
const PATH = /^\/embed\/(v[a-z0-9]{1,12})\/?$/;
|
|
5
|
+
const HOSTS = /* @__PURE__ */ new Set(["rumble.com", "www.rumble.com"]);
|
|
6
|
+
function video(id) {
|
|
7
|
+
return {
|
|
8
|
+
platform: "rumble",
|
|
9
|
+
kind: "video",
|
|
10
|
+
url: `https://rumble.com/embed/${id}/`,
|
|
11
|
+
id,
|
|
12
|
+
variant: "iframe"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function idOf(url, hosts) {
|
|
16
|
+
return url && hosts.has(url.host) ? PATH.exec(url.path)?.[1] : void 0;
|
|
17
|
+
}
|
|
18
|
+
const rumble = {
|
|
19
|
+
platform: "rumble",
|
|
20
|
+
parse(root) {
|
|
21
|
+
if (root.tag !== "iframe") return null;
|
|
22
|
+
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
23
|
+
const id = idOf(src, /* @__PURE__ */ new Set(["rumble.com"]));
|
|
24
|
+
if (id === void 0 || !src) return null;
|
|
25
|
+
const options = {};
|
|
26
|
+
const pub = src.query.get("pub");
|
|
27
|
+
if (pub) options.pub = coerce(pub);
|
|
28
|
+
return withSize({
|
|
29
|
+
...video(id),
|
|
30
|
+
options
|
|
31
|
+
}, sizeOf(root));
|
|
32
|
+
},
|
|
33
|
+
isOwnScript: () => false,
|
|
34
|
+
match(url) {
|
|
35
|
+
const id = idOf(url, HOSTS);
|
|
36
|
+
return id === void 0 ? null : {
|
|
37
|
+
...video(id),
|
|
38
|
+
options: {}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
ownsFrame: (src) => src.host === "rumble.com" && underPath(src.path, "/embed")
|
|
42
|
+
};
|
|
43
|
+
export { rumble };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { descendants, hasClass } from "../html.js";
|
|
2
|
+
import { withSize } from "../platform.js";
|
|
3
|
+
import { parseUrl, pixels } from "../url.js";
|
|
4
|
+
// 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
|
+
const SCRIPT = /^(?:https?:)?\/\/www\.snapchat\.com\/embed\.js$/;
|
|
12
|
+
function content(url) {
|
|
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
|
+
parse(root) {
|
|
55
|
+
if (root.tag !== "blockquote" || !hasClass(root, "snapchat-embed")) return null;
|
|
56
|
+
const embedUrl = parseUrl(root.attrs.get("data-snapchat-embed-url") ?? "");
|
|
57
|
+
if (!embedUrl?.path.endsWith("/embed")) return null;
|
|
58
|
+
const found = content({
|
|
59
|
+
...embedUrl,
|
|
60
|
+
path: embedUrl.path.slice(0, -6)
|
|
61
|
+
});
|
|
62
|
+
if (!found) return null;
|
|
63
|
+
if (!descendants(root.children).filter((el) => el.tag === "a").every((link) => {
|
|
64
|
+
const linked = content(parseUrl(link.attrs.get("href") ?? ""));
|
|
65
|
+
return linked?.kind === found.kind && linked.id === found.id;
|
|
66
|
+
})) return null;
|
|
67
|
+
const title = root.attrs.get("data-snapchat-embed-title");
|
|
68
|
+
const width = pixels(root.attrs.get("data-snapchat-embed-width"));
|
|
69
|
+
const height = pixels(root.attrs.get("data-snapchat-embed-height"));
|
|
70
|
+
return withSize({
|
|
71
|
+
...found,
|
|
72
|
+
options: title === void 0 ? {} : { title }
|
|
73
|
+
}, width === void 0 || height === void 0 ? void 0 : {
|
|
74
|
+
width,
|
|
75
|
+
height
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
isOwnScript: (src) => SCRIPT.test(src),
|
|
79
|
+
match(url) {
|
|
80
|
+
const found = content(url);
|
|
81
|
+
return found && {
|
|
82
|
+
...found,
|
|
83
|
+
options: {}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export { snapchat };
|