social-embeds 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import { sizeOf, withSize } from "../platform.js";
2
2
  import { parseUrl } from "../url.js";
3
+ import { APPLE_PODCASTS_FRAME_HOST, applePodcastsFrame } from "../frames.js";
3
4
  // src/parser/platforms/applepodcasts.ts
4
5
  const PATH = /^\/([a-z]{2})\/podcast\/(?:[^/]{1,200}\/)?(?:id)?(\d{1,15})\/?$/;
5
6
  const EPISODE = /^\d{1,15}$/;
6
- const FRAME_HOST = "embed.podcasts.apple.com";
7
7
  function content(url, host) {
8
8
  if (url?.host !== host) return null;
9
9
  const [, country, show] = PATH.exec(url.path) ?? [];
@@ -22,7 +22,7 @@ const applepodcasts = {
22
22
  platform: "applepodcasts",
23
23
  parse(root) {
24
24
  if (root.tag !== "iframe") return null;
25
- const found = content(parseUrl(root.attrs.get("src") ?? ""), FRAME_HOST);
25
+ const found = content(parseUrl(root.attrs.get("src") ?? ""), APPLE_PODCASTS_FRAME_HOST);
26
26
  return found && withSize({
27
27
  ...found,
28
28
  options: {}
@@ -36,6 +36,6 @@ const applepodcasts = {
36
36
  options: {}
37
37
  };
38
38
  },
39
- ownsFrame: (src) => src.host === FRAME_HOST
39
+ ownsFrame: applePodcastsFrame
40
40
  };
41
41
  export { applepodcasts };
@@ -1,12 +1,10 @@
1
- import { sizeOf, underPath, unwrapRatio, withSize } from "../platform.js";
1
+ import { sizeOf, unwrapRatio, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { DAILYMOTION_HOSTS, dailymotionFrame } from "../frames.js";
3
4
  // src/parser/platforms/dailymotion.ts
4
5
  const VIDEO_ID = /^x[a-z0-9]{4,12}$/;
5
6
  const PLAYER_ID = /^x[a-z0-9]{3,12}$/;
6
7
  const WRAPPER = /^position:\s*relative;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*height:\s*0;\s*overflow:\s*hidden;?$/;
7
- const HOSTS = /* @__PURE__ */ new Set(["dailymotion.com", "www.dailymotion.com"]);
8
- const PLAYER_HOST = "geo.dailymotion.com";
9
- const SHORT_HOST = "dai.ly";
10
8
  function video(id, options) {
11
9
  return {
12
10
  platform: "dailymotion",
@@ -19,7 +17,7 @@ function video(id, options) {
19
17
  }
20
18
  /** A geo.dailymotion.com player, with or without a Player ID. Playlists are left out. */
21
19
  function fromPlayer(url) {
22
- if (url.host !== PLAYER_HOST || url.query.has("playlist")) return null;
20
+ if (url.host !== "geo.dailymotion.com" || url.query.has("playlist")) return null;
23
21
  const match = /^\/player(?:\/([a-z0-9]+))?\.html$/.exec(url.path);
24
22
  if (!match) return null;
25
23
  const [, playerId] = match;
@@ -31,11 +29,11 @@ function fromPlayer(url) {
31
29
  return video(id, options);
32
30
  }
33
31
  function fromPage(url) {
34
- if (url.host === SHORT_HOST) {
32
+ if (url.host === "dai.ly") {
35
33
  const id = url.path.replace(/^\/|\/$/g, "");
36
34
  return VIDEO_ID.test(id) ? video(id, {}) : null;
37
35
  }
38
- if (!HOSTS.has(url.host)) return null;
36
+ if (!DAILYMOTION_HOSTS.has(url.host)) return null;
39
37
  const [, id] = /^(?:\/embed)?\/video\/([a-z0-9]+)\/?$/.exec(url.path) ?? [];
40
38
  return id !== void 0 && VIDEO_ID.test(id) ? video(id, {}) : null;
41
39
  }
@@ -54,6 +52,6 @@ const dailymotion = {
54
52
  match(url) {
55
53
  return fromPlayer(url) ?? fromPage(url);
56
54
  },
57
- ownsFrame: (src) => src.host === PLAYER_HOST || src.host === SHORT_HOST || HOSTS.has(src.host) && (underPath(src.path, "/embed") || underPath(src.path, "/video"))
55
+ ownsFrame: dailymotionFrame
58
56
  };
59
57
  export { dailymotion };
@@ -1,6 +1,7 @@
1
1
  import { hasClass, rebuild } from "../html.js";
2
- import { attributeOptions, sizeOf, underPath, withSize } from "../platform.js";
2
+ import { attributeOptions, sizeOf, withSize } from "../platform.js";
3
3
  import { coerce, parseUrl, pixels } from "../url.js";
4
+ import { FACEBOOK_PLUGIN_HOSTS, facebookFrame } from "../frames.js";
4
5
  // src/parser/platforms/facebook.ts
5
6
  const HOSTS = /* @__PURE__ */ new Set([
6
7
  "facebook.com",
@@ -8,16 +9,11 @@ const HOSTS = /* @__PURE__ */ new Set([
8
9
  "web.facebook.com",
9
10
  "m.facebook.com"
10
11
  ]);
11
- const PLUGIN_HOSTS = /* @__PURE__ */ new Set([
12
- "facebook.com",
13
- "www.facebook.com",
14
- "web.facebook.com"
15
- ]);
16
12
  const BASE = "https://www.facebook.com";
17
13
  const NAME = "[A-Za-z0-9.\\-]{1,80}";
18
14
  const POST_ID = "(?:\\d{1,25}|pfbid[A-Za-z0-9]{10,120})";
19
15
  const POSTS_PATH = new RegExp(`^/(${NAME})/posts/(${POST_ID})/?$`);
20
- const PHOTOS_PATH = new RegExp(`^/(${NAME})/photos/([A-Za-z0-9.]{1,40})/(\\d{1,25})/?$`);
16
+ const PHOTOS_PATH = new RegExp(`^/(${NAME})/photos/([A-Za-z0-9.\\-]{1,80})/(\\d{1,25})/?$`);
21
17
  const VIDEOS_PATH = new RegExp(`^/(${NAME})/videos/(?:[^/]{1,200}/)?(\\d{1,25})/?$`);
22
18
  const REEL_PATH = /^\/reel\/(\d{1,25})\/?$/;
23
19
  const STORY_PATHS = /* @__PURE__ */ new Set(["/permalink.php", "/story.php"]);
@@ -136,7 +132,7 @@ const facebook = {
136
132
  }
137
133
  if (root.tag !== "iframe") return null;
138
134
  const src = parseUrl(root.attrs.get("src") ?? "");
139
- if (!src || !PLUGIN_HOSTS.has(src.host)) return null;
135
+ if (!src || !FACEBOOK_PLUGIN_HOSTS.has(src.host)) return null;
140
136
  const found = target(parseUrl(src.query.get("href") ?? ""));
141
137
  if (!found) return null;
142
138
  if (src.path === "/plugins/post.php") {
@@ -180,6 +176,6 @@ const facebook = {
180
176
  const found = target(url);
181
177
  return found && embed(found, found.kind, "sdk", {});
182
178
  },
183
- ownsFrame: (src) => PLUGIN_HOSTS.has(src.host) && underPath(src.path, "/plugins")
179
+ ownsFrame: facebookFrame
184
180
  };
185
181
  export { facebook };
@@ -1,8 +1,8 @@
1
- import { sizeOf, underPath, unwrapRatio, withSize } from "../platform.js";
1
+ import { sizeOf, unwrapRatio, withSize } from "../platform.js";
2
2
  import { parseUrl } from "../url.js";
3
+ import { GIPHY_PAGE_HOSTS, giphyFrame } from "../frames.js";
3
4
  // src/parser/platforms/giphy.ts
4
5
  const ID = "([A-Za-z0-9]{6,40})";
5
- const PAGE_HOSTS = /* @__PURE__ */ new Set(["giphy.com", "www.giphy.com"]);
6
6
  const PAGE_PATH = new RegExp(`^/(?:gifs|stickers)/(?:[A-Za-z0-9-]{0,200}-)?${ID}/?$`);
7
7
  const EMBED_PATH = new RegExp(`^/embed/${ID}/?$`);
8
8
  const MEDIA_HOST = /^(?:media\d?|i)\.giphy\.com$/;
@@ -21,14 +21,14 @@ function gif(id) {
21
21
  }
22
22
  function idOf(url) {
23
23
  if (!url) return void 0;
24
- if (PAGE_HOSTS.has(url.host)) return (PAGE_PATH.exec(url.path) ?? EMBED_PATH.exec(url.path))?.[1];
24
+ if (GIPHY_PAGE_HOSTS.has(url.host)) return (PAGE_PATH.exec(url.path) ?? EMBED_PATH.exec(url.path))?.[1];
25
25
  if (!MEDIA_HOST.test(url.host)) return void 0;
26
26
  return (MEDIA_PATH.exec(url.path) ?? (url.host === "i.giphy.com" ? SHORT_MEDIA_PATH.exec(url.path) : null))?.[1];
27
27
  }
28
28
  function fromIframe(iframe) {
29
29
  if (iframe.tag !== "iframe") return null;
30
30
  const src = parseUrl(iframe.attrs.get("src") ?? "");
31
- if (!src || !PAGE_HOSTS.has(src.host)) return null;
31
+ if (!src || !GIPHY_PAGE_HOSTS.has(src.host)) return null;
32
32
  const [, id] = EMBED_PATH.exec(src.path) ?? [];
33
33
  return id === void 0 ? null : gif(id);
34
34
  }
@@ -38,7 +38,7 @@ function isCredit(element, embed) {
38
38
  if (rest.length > 0 || link?.type !== "element" || link.tag !== "a") return false;
39
39
  if (link.attrs.size !== 1) return false;
40
40
  const href = parseUrl(link.attrs.get("href") ?? "");
41
- if (!href || !PAGE_HOSTS.has(href.host) || PAGE_PATH.exec(href.path)?.[1] !== embed.id) return false;
41
+ if (!href || !GIPHY_PAGE_HOSTS.has(href.host) || PAGE_PATH.exec(href.path)?.[1] !== embed.id) return false;
42
42
  const [text, ...more] = link.children;
43
43
  return more.length === 0 && text?.type === "text" && text.raw.trim() === "via GIPHY";
44
44
  }
@@ -63,6 +63,6 @@ const giphy = {
63
63
  options: {}
64
64
  };
65
65
  },
66
- ownsFrame: (src) => PAGE_HOSTS.has(src.host) && underPath(src.path, "/embed")
66
+ ownsFrame: giphyFrame
67
67
  };
68
68
  export { giphy };
@@ -1,5 +1,6 @@
1
1
  import { sizeOf, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { KICK_PLAYER_HOSTS, kickFrame } from "../frames.js";
3
4
  // src/parser/platforms/kick.ts
4
5
  const PAGE_HOSTS = /* @__PURE__ */ new Set(["kick.com", "www.kick.com"]);
5
6
  const CHANNEL = /^\/([A-Za-z0-9_-]{1,32})\/?$/;
@@ -34,13 +35,12 @@ function channel(url, hosts) {
34
35
  variant: "iframe"
35
36
  };
36
37
  }
37
- const PLAYER = /* @__PURE__ */ new Set(["player.kick.com"]);
38
38
  const kick = {
39
39
  platform: "kick",
40
40
  parse(root) {
41
41
  if (root.tag !== "iframe") return null;
42
42
  const src = parseUrl(root.attrs.get("src") ?? "");
43
- const found = channel(src, PLAYER);
43
+ const found = channel(src, KICK_PLAYER_HOSTS);
44
44
  if (!found || !src) return null;
45
45
  const options = Object.fromEntries([...src.query].filter(([key]) => KEPT.has(key)).map(([key, value]) => [key, coerce(value)]));
46
46
  return withSize({
@@ -50,12 +50,12 @@ const kick = {
50
50
  },
51
51
  isOwnScript: () => false,
52
52
  match(url) {
53
- const found = channel(url, PAGE_HOSTS) ?? channel(url, PLAYER);
53
+ const found = channel(url, PAGE_HOSTS) ?? channel(url, KICK_PLAYER_HOSTS);
54
54
  return found && {
55
55
  ...found,
56
56
  options: {}
57
57
  };
58
58
  },
59
- ownsFrame: (src) => PLAYER.has(src.host)
59
+ ownsFrame: kickFrame
60
60
  };
61
61
  export { kick };
@@ -1,8 +1,8 @@
1
- import { sizeOf, underPath, withSize } from "../platform.js";
1
+ import { sizeOf, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { linkedinFrame } from "../frames.js";
3
4
  // src/parser/platforms/linkedin.ts
4
5
  const HOST = /^(?:www\.|[a-z]{2}\.)?linkedin\.com$/;
5
- const FRAME_HOST = "www.linkedin.com";
6
6
  const URN = "(activity|share|ugcPost):(\\d{19})";
7
7
  const UPDATE_PATH = new RegExp(`^(?:/embed)?/feed/update/urn:li:${URN}/?$`);
8
8
  const POSTS_PATH = new RegExp(`^/posts/[^/]{1,300}-(activity|share|ugcPost)-(\\d{19})-[A-Za-z0-9_-]{1,8}/?$`);
@@ -24,7 +24,7 @@ const linkedin = {
24
24
  parse(root) {
25
25
  if (root.tag !== "iframe") return null;
26
26
  const src = parseUrl(root.attrs.get("src") ?? "");
27
- if (src?.host !== FRAME_HOST) return null;
27
+ if (src?.host !== "www.linkedin.com") return null;
28
28
  const [, type, id] = EMBED_PATH.exec(src.path) ?? [];
29
29
  if (type === void 0 || id === void 0) return null;
30
30
  const options = Object.fromEntries([...src.query].map(([key, value]) => [key, coerce(value)]));
@@ -37,6 +37,6 @@ const linkedin = {
37
37
  const [, type, id] = UPDATE_PATH.exec(path) ?? POSTS_PATH.exec(path) ?? [];
38
38
  return type === void 0 || id === void 0 ? null : post(type, id);
39
39
  },
40
- ownsFrame: (src) => src.host === FRAME_HOST && underPath(src.path, "/embed")
40
+ ownsFrame: linkedinFrame
41
41
  };
42
42
  export { linkedin };
@@ -1,10 +1,10 @@
1
1
  import { attributeOptions } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { pinterestFrame } from "../frames.js";
3
4
  // src/parser/platforms/pinterest.ts
4
5
  const HOST = /^(?:(?:www|[a-z]{2})\.)?pinterest\.(?:[a-z]{2,3}|co\.[a-z]{2}|com\.[a-z]{2})$/;
5
6
  const PIN_PATH = /^\/pin\/(?:[A-Za-z0-9-]{0,200}--)?(\d{1,25})\/?$/;
6
7
  const PIN_ID = /^\d{1,25}$/;
7
- const FRAME_HOST = "assets.pinterest.com";
8
8
  const SCRIPT = /^(?:https?:)?\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js$/;
9
9
  const OPTION_ATTRIBUTES = [
10
10
  ["data-pin-width", "width"],
@@ -39,7 +39,7 @@ const pinterest = {
39
39
  }
40
40
  if (root.tag !== "iframe") return null;
41
41
  const src = parseUrl(root.attrs.get("src") ?? "");
42
- if (src?.host !== FRAME_HOST || src.path !== "/ext/embed.html") return null;
42
+ if (src?.host !== "assets.pinterest.com" || src.path !== "/ext/embed.html") return null;
43
43
  const id = src.query.get("id");
44
44
  return id !== void 0 && PIN_ID.test(id) ? {
45
45
  ...pin(id),
@@ -54,6 +54,6 @@ const pinterest = {
54
54
  options: {}
55
55
  };
56
56
  },
57
- ownsFrame: (src) => src.host === FRAME_HOST
57
+ ownsFrame: pinterestFrame
58
58
  };
59
59
  export { pinterest };
@@ -10,6 +10,7 @@ const HOSTS = /* @__PURE__ */ new Set([
10
10
  ]);
11
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
12
  const SCRIPT = /^(?:https?:)?\/\/embed\.reddit\.com\/widgets\.js$/;
13
+ const CARD_SCRIPT = /^(?:https?:)?\/\/embed\.redditmedia\.com\/widgets\/platform\.js$/;
13
14
  const OPTION_ATTRIBUTES = [
14
15
  "depth",
15
16
  "style",
@@ -47,7 +48,7 @@ function post(url) {
47
48
  const reddit = {
48
49
  platform: "reddit",
49
50
  parse(root) {
50
- if (root.tag !== "blockquote" || !hasClass(root, "reddit-embed-bq")) return null;
51
+ if (root.tag !== "blockquote" || !(hasClass(root, "reddit-embed-bq") || hasClass(root, "reddit-card"))) return null;
51
52
  const found = descendants(root.children).map((element) => element.tag === "a" ? post(parseUrl(element.attrs.get("href") ?? "")) : null).find((embed) => embed !== null);
52
53
  if (!found) return null;
53
54
  const height = pixels(root.attrs.get("data-embed-height"));
@@ -56,7 +57,7 @@ const reddit = {
56
57
  options: attributeOptions(root, OPTION_ATTRIBUTES, coerce)
57
58
  }, height === void 0 ? void 0 : { height });
58
59
  },
59
- isOwnScript: (src) => SCRIPT.test(src),
60
+ isOwnScript: (src) => SCRIPT.test(src) || CARD_SCRIPT.test(src),
60
61
  match(url) {
61
62
  const found = post(url);
62
63
  return found && {
@@ -1,5 +1,6 @@
1
- import { sizeOf, underPath, withSize } from "../platform.js";
1
+ import { sizeOf, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { rumbleFrame } from "../frames.js";
3
4
  // src/parser/platforms/rumble.ts
4
5
  const PATH = /^\/embed\/(v[a-z0-9]{1,12})\/?$/;
5
6
  const HOSTS = /* @__PURE__ */ new Set(["rumble.com", "www.rumble.com"]);
@@ -38,6 +39,6 @@ const rumble = {
38
39
  options: {}
39
40
  };
40
41
  },
41
- ownsFrame: (src) => src.host === "rumble.com" && underPath(src.path, "/embed")
42
+ ownsFrame: rumbleFrame
42
43
  };
43
44
  export { rumble };
@@ -1,5 +1,6 @@
1
1
  import { sizeOf, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { soundcloudFrame } from "../frames.js";
3
4
  // src/parser/platforms/soundcloud.ts
4
5
  const PAGE_HOSTS = /* @__PURE__ */ new Set([
5
6
  "soundcloud.com",
@@ -42,7 +43,6 @@ const NOT_SOUNDS = /* @__PURE__ */ new Set([
42
43
  "toptracks"
43
44
  ]);
44
45
  const SECRET_TOKEN = new RegExp(`^${SECRET}$`);
45
- const WIDGET_HOST = "w.soundcloud.com";
46
46
  function sound(url, id) {
47
47
  return {
48
48
  platform: "soundcloud",
@@ -96,7 +96,7 @@ const soundcloud = {
96
96
  parse(root) {
97
97
  if (root.tag !== "iframe") return null;
98
98
  const src = parseUrl(root.attrs.get("src") ?? "");
99
- if (src?.host !== WIDGET_HOST || !/^\/player\/?$/.test(src.path)) return null;
99
+ if (src?.host !== "w.soundcloud.com" || !/^\/player\/?$/.test(src.path)) return null;
100
100
  let found = fromApi(parseUrl(src.query.get("url") ?? ""));
101
101
  if (!found) return null;
102
102
  const outer = src.query.get("secret_token");
@@ -123,6 +123,6 @@ const soundcloud = {
123
123
  options: {}
124
124
  };
125
125
  },
126
- ownsFrame: (src) => src.host === WIDGET_HOST
126
+ ownsFrame: soundcloudFrame
127
127
  };
128
128
  export { soundcloud };
@@ -1,11 +1,11 @@
1
- import { sizeOf, underPath, withSize } from "../platform.js";
1
+ import { sizeOf, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { spotifyFrame } from "../frames.js";
3
4
  // src/parser/platforms/spotify.ts
4
5
  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)?/?$`);
5
6
  const DROPPED = /* @__PURE__ */ new Set(["utm_source", "si"]);
6
- const HOST = "open.spotify.com";
7
7
  function content(url) {
8
- if (url?.host !== HOST) return null;
8
+ if (url?.host !== "open.spotify.com") return null;
9
9
  const [, type, id, video] = CONTENT_PATH.exec(url.path) ?? [];
10
10
  if (type === void 0 || id === void 0) return null;
11
11
  return {
@@ -46,6 +46,6 @@ const spotify = {
46
46
  options: {}
47
47
  };
48
48
  },
49
- ownsFrame: (src) => src.host === HOST && underPath(src.path, "/embed")
49
+ ownsFrame: spotifyFrame
50
50
  };
51
51
  export { spotify };
@@ -1,5 +1,6 @@
1
- import { sizeOf, underPath, unwrapRatio, withSize } from "../platform.js";
1
+ import { sizeOf, unwrapRatio, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { streamableFrame } from "../frames.js";
3
4
  // src/parser/platforms/streamable.ts
4
5
  const ID = "([a-z0-9]{4,8})";
5
6
  const PAGE_HOSTS = /* @__PURE__ */ new Set(["streamable.com", "www.streamable.com"]);
@@ -89,6 +90,6 @@ const streamable = {
89
90
  options: {}
90
91
  };
91
92
  },
92
- ownsFrame: (src) => src.host === "streamable.com" && (underPath(src.path, "/e") || underPath(src.path, "/o"))
93
+ ownsFrame: streamableFrame
93
94
  };
94
95
  export { streamable };
@@ -1,6 +1,7 @@
1
1
  import { hasClass, rebuild } from "../html.js";
2
- import { sizeOf, underPath, withSize } from "../platform.js";
2
+ import { sizeOf, withSize } from "../platform.js";
3
3
  import { parseUrl } from "../url.js";
4
+ import { tenorFrame } from "../frames.js";
4
5
  // src/parser/platforms/tenor.ts
5
6
  const HOSTS = /* @__PURE__ */ new Set(["tenor.com", "www.tenor.com"]);
6
7
  const ID = "(\\d{1,20})";
@@ -73,6 +74,6 @@ const tenor = {
73
74
  options: {}
74
75
  };
75
76
  },
76
- ownsFrame: (src) => src.host === "tenor.com" && underPath(src.path, "/embed")
77
+ ownsFrame: tenorFrame
77
78
  };
78
79
  export { tenor };
@@ -1,8 +1,8 @@
1
1
  import { hasClass } from "../html.js";
2
- import { sizeOf, underPath, withSize } from "../platform.js";
2
+ import { sizeOf, withSize } from "../platform.js";
3
3
  import { coerce, parseUrl } from "../url.js";
4
+ import { TIKTOK_HOSTS, tiktokFrame } from "../frames.js";
4
5
  // src/parser/platforms/tiktok.ts
5
- const HOSTS = /* @__PURE__ */ new Set(["tiktok.com", "www.tiktok.com"]);
6
6
  const VIDEO_PATH = /^\/@([A-Za-z0-9._]{0,64})\/video\/(\d{1,25})\/?$/;
7
7
  const PLAYER_PATH = /^\/player\/v1\/(\d{1,25})\/?$/;
8
8
  const VIDEO_ID = /^\d{1,25}$/;
@@ -22,7 +22,7 @@ const tiktok = {
22
22
  parse(root) {
23
23
  if (root.tag === "blockquote" && hasClass(root, "tiktok-embed")) {
24
24
  const cite = parseUrl(root.attrs.get("cite") ?? "");
25
- const [, user, citeId] = cite && HOSTS.has(cite.host) ? VIDEO_PATH.exec(cite.path) ?? [] : [];
25
+ const [, user, citeId] = cite && TIKTOK_HOSTS.has(cite.host) ? VIDEO_PATH.exec(cite.path) ?? [] : [];
26
26
  const dataId = root.attrs.get("data-video-id");
27
27
  if (dataId !== void 0 && !VIDEO_ID.test(dataId)) return null;
28
28
  if (dataId !== void 0 && citeId !== void 0 && dataId !== citeId) return null;
@@ -31,7 +31,7 @@ const tiktok = {
31
31
  }
32
32
  if (root.tag !== "iframe") return null;
33
33
  const src = parseUrl(root.attrs.get("src") ?? "");
34
- if (!src || !HOSTS.has(src.host)) return null;
34
+ if (!src || !TIKTOK_HOSTS.has(src.host)) return null;
35
35
  const [, id] = PLAYER_PATH.exec(src.path) ?? [];
36
36
  if (id === void 0) return null;
37
37
  const options = Object.fromEntries([...src.query].map(([key, value]) => [key, coerce(value)]));
@@ -39,10 +39,10 @@ const tiktok = {
39
39
  },
40
40
  isOwnScript: (src) => SCRIPT.test(src),
41
41
  match(url) {
42
- if (!HOSTS.has(url.host)) return null;
42
+ if (!TIKTOK_HOSTS.has(url.host)) return null;
43
43
  const [, user, id] = VIDEO_PATH.exec(url.path) ?? [];
44
44
  return user === void 0 || id === void 0 ? null : video(id, user);
45
45
  },
46
- ownsFrame: (src) => HOSTS.has(src.host) && underPath(src.path, "/player")
46
+ ownsFrame: tiktokFrame
47
47
  };
48
48
  export { tiktok };
@@ -1,6 +1,7 @@
1
1
  import { hasClass } from "../html.js";
2
2
  import { sizeOf, withSize } from "../platform.js";
3
3
  import { parseUrl } from "../url.js";
4
+ import { truthsocialFrame } from "../frames.js";
4
5
  // src/parser/platforms/truthsocial.ts
5
6
  const HOSTS = /* @__PURE__ */ new Set(["truthsocial.com", "www.truthsocial.com"]);
6
7
  const USER = "(@[A-Za-z0-9_.-]{1,64})";
@@ -44,6 +45,6 @@ const truthsocial = {
44
45
  options: {}
45
46
  };
46
47
  },
47
- ownsFrame: (src) => src.host === "truthsocial.com" && src.path.startsWith("/@")
48
+ ownsFrame: truthsocialFrame
48
49
  };
49
50
  export { truthsocial };
@@ -8,6 +8,7 @@ const WWW_PATH = new RegExp(`^/${BLOG}/${POST}(?:/[^/]{1,200})?/?$`);
8
8
  const BLOG_HOST = new RegExp(`^${BLOG}\\.tumblr\\.com$`);
9
9
  const BLOG_PATH = new RegExp(`^/post/${POST}(?:/[^/]{1,200})?/?$`);
10
10
  const FRAME_PATH = new RegExp(`^/embed/post/(?:t:[A-Za-z0-9_-]{1,64}|${BLOG})/${POST}/v2$`);
11
+ const OLD_FRAME_PATH = new RegExp(`^/embed/post/(?:t:)?[A-Za-z0-9_-]{1,64}/${POST}$`);
11
12
  const NOT_BLOGS = /* @__PURE__ */ new Set([
12
13
  "dashboard",
13
14
  "explore",
@@ -21,7 +22,7 @@ const NOT_BLOGS = /* @__PURE__ */ new Set([
21
22
  "api",
22
23
  "help"
23
24
  ]);
24
- const SCRIPT = /^(?:https?:)?\/\/assets\.tumblr\.com\/post\.js(?:\?[^#]*)?$/;
25
+ const SCRIPT = /^(?:https?:)?\/\/(?:secure\.)?assets\.tumblr\.com\/post\.js(?:\?[^#]*)?$/;
25
26
  function fromUrl(url) {
26
27
  if (!url) return null;
27
28
  let blog;
@@ -46,7 +47,8 @@ const tumblr = {
46
47
  if (root.tag !== "div" || !hasClass(root, "tumblr-post")) return null;
47
48
  const frame = parseUrl(root.attrs.get("data-href") ?? "");
48
49
  if (frame?.host !== "embed.tumblr.com") return null;
49
- const [, frameBlog, framePost] = FRAME_PATH.exec(frame.path) ?? [];
50
+ const [, frameBlog, v2Post] = FRAME_PATH.exec(frame.path) ?? [];
51
+ const framePost = v2Post ?? OLD_FRAME_PATH.exec(frame.path)?.[1];
50
52
  if (framePost === void 0) return null;
51
53
  const [link, ...rest] = root.children.filter((node) => node.type !== "text" || node.raw.trim() !== "");
52
54
  if (rest.length > 0 || link?.type !== "element" || link.tag !== "a") return null;
@@ -1,13 +1,12 @@
1
- import { sizeOf, underPath, withSize } from "../platform.js";
1
+ import { sizeOf, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { twitchFrame } from "../frames.js";
3
4
  // src/parser/platforms/twitch.ts
4
5
  const HOSTS = /* @__PURE__ */ new Set([
5
6
  "twitch.tv",
6
7
  "www.twitch.tv",
7
8
  "m.twitch.tv"
8
9
  ]);
9
- const PLAYER_HOST = "player.twitch.tv";
10
- const CLIPS_HOST = "clips.twitch.tv";
11
10
  const CHANNEL = /^[A-Za-z0-9_]{3,25}$/;
12
11
  const VIDEO = /^v?(\d{1,12})$/;
13
12
  const COLLECTION = /^[A-Za-z0-9_-]{6,30}$/;
@@ -66,7 +65,7 @@ function fromPlayer(url) {
66
65
  return list !== void 0 && COLLECTION.test(list) ? collection(list) : null;
67
66
  }
68
67
  function fromPage(url) {
69
- if (url.host === CLIPS_HOST) {
68
+ if (url.host === "clips.twitch.tv") {
70
69
  const slug = url.path.replace(/^\/|\/$/g, "");
71
70
  return CLIP.test(slug) ? {
72
71
  found: clip(slug),
@@ -106,8 +105,8 @@ const twitch = {
106
105
  const src = parseUrl(root.attrs.get("src") ?? "");
107
106
  if (!src) return null;
108
107
  let found = null;
109
- if (src.host === PLAYER_HOST && /^\/?$/.test(src.path)) found = fromPlayer(src);
110
- if (src.host === CLIPS_HOST && src.path === "/embed") {
108
+ if (src.host === "player.twitch.tv" && /^\/?$/.test(src.path)) found = fromPlayer(src);
109
+ if (src.host === "clips.twitch.tv" && src.path === "/embed") {
111
110
  const slug = src.query.get("clip") ?? "";
112
111
  found = CLIP.test(slug) ? clip(slug) : null;
113
112
  }
@@ -124,6 +123,6 @@ const twitch = {
124
123
  options: page.options
125
124
  };
126
125
  },
127
- ownsFrame: (src) => src.host === PLAYER_HOST || src.host === CLIPS_HOST && underPath(src.path, "/embed")
126
+ ownsFrame: twitchFrame
128
127
  };
129
128
  export { twitch };
@@ -1,5 +1,6 @@
1
1
  import { sizeOf, unwrapRatio, withSize } from "../platform.js";
2
2
  import { coerce, parseUrl } from "../url.js";
3
+ import { vimeoFrame } from "../frames.js";
3
4
  // src/parser/platforms/vimeo.ts
4
5
  const HOSTS = /* @__PURE__ */ new Set(["vimeo.com", "www.vimeo.com"]);
5
6
  const VIDEO = "(\\d{1,12})";
@@ -19,7 +20,6 @@ const DROPPED = /* @__PURE__ */ new Set([
19
20
  "player_id"
20
21
  ]);
21
22
  const START = /^t=(\d+(?:\.\d+)?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;
22
- const PLAYER_HOST = "player.vimeo.com";
23
23
  function video(id, hash) {
24
24
  return {
25
25
  platform: "vimeo",
@@ -33,8 +33,30 @@ function start(url) {
33
33
  const [, time] = START.exec(url.fragment ?? "") ?? [];
34
34
  return time ? { t: time } : {};
35
35
  }
36
+ function fromPage(url) {
37
+ if (!url || !HOSTS.has(url.host)) return null;
38
+ for (const path of PAGE_PATHS) {
39
+ const [, id, hash] = path.exec(url.path) ?? [];
40
+ if (id !== void 0) return video(id, hash);
41
+ }
42
+ return null;
43
+ }
44
+ function isLink(node, test) {
45
+ if (node?.type !== "element" || node.tag !== "a" || node.attrs.size !== 1) return false;
46
+ const href = parseUrl(node.attrs.get("href") ?? "");
47
+ return href !== null && HOSTS.has(href.host) && test(href) && node.children.every((child) => child.type === "text");
48
+ }
49
+ function isText(node, text) {
50
+ return node?.type === "text" && node.raw.trim() === text;
51
+ }
52
+ /** Older embed code's credit: the video, its author and Vimeo, linked; it is dropped. */
53
+ function isCredit(element, embed) {
54
+ if (element.tag !== "p" || element.attrs.size !== 0) return false;
55
+ const [title, from, author, on, home, stop, ...rest] = element.children;
56
+ return rest.length === 0 && isLink(title, (url) => fromPage(url)?.id === embed.id) && isText(from, "from") && isLink(author, () => true) && isText(on, "on") && isLink(home, (url) => url.path === "" || url.path === "/") && isText(stop, ".");
57
+ }
36
58
  function fromPlayer(url) {
37
- if (url?.host !== PLAYER_HOST) return null;
59
+ if (url?.host !== "player.vimeo.com") return null;
38
60
  const [, id] = PLAYER_PATH.exec(url.path) ?? [];
39
61
  if (id === void 0) return null;
40
62
  const hash = url.query.get("h");
@@ -58,19 +80,16 @@ const vimeo = {
58
80
  return embed && withSize(embed, wrapped?.size ?? sizeOf(iframe));
59
81
  },
60
82
  isOwnScript: (src) => SCRIPT.test(src),
83
+ isOwnExtra: isCredit,
61
84
  match(url) {
62
85
  const player = fromPlayer(url);
63
86
  if (player) return player;
64
- if (!HOSTS.has(url.host)) return null;
65
- for (const path of PAGE_PATHS) {
66
- const [, id, hash] = path.exec(url.path) ?? [];
67
- if (id !== void 0) return {
68
- ...video(id, hash),
69
- options: start(url)
70
- };
71
- }
72
- return null;
87
+ const page = fromPage(url);
88
+ return page && {
89
+ ...page,
90
+ options: start(url)
91
+ };
73
92
  },
74
- ownsFrame: (src) => src.host === PLAYER_HOST
93
+ ownsFrame: vimeoFrame
75
94
  };
76
95
  export { vimeo };
@@ -44,7 +44,7 @@ const x = {
44
44
  platform: "x",
45
45
  fallback: FALLBACK,
46
46
  parse(root) {
47
- if (root.tag !== "blockquote" || !hasClass(root, "twitter-tweet")) return null;
47
+ if (root.tag !== "blockquote" || !(hasClass(root, "twitter-tweet") || hasClass(root, "twitter-video"))) return null;
48
48
  const status = descendants(root.children).reverse().map((element) => element.tag === "a" ? post(parseUrl(element.attrs.get("href") ?? "")) : null).find((found) => found !== null);
49
49
  if (!status) return null;
50
50
  return {