social-embeds 0.9.3 → 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/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 +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasClass } from "../html.js";
|
|
2
|
-
import { sizeOf, withSize } from "../platform.js";
|
|
2
|
+
import { parserOf, sizeOf, withSize } from "../platform.js";
|
|
3
3
|
import { coerce, parseUrl } from "../url.js";
|
|
4
4
|
import { TIKTOK_HOSTS } from "../frames.js";
|
|
5
5
|
import { VIDEO_PATH, tiktokMatcher, video } from "../matchers/tiktok.js";
|
|
@@ -7,8 +7,7 @@ import { VIDEO_PATH, tiktokMatcher, video } from "../matchers/tiktok.js";
|
|
|
7
7
|
const PLAYER_PATH = /^\/player\/v1\/(\d{1,25})\/?$/;
|
|
8
8
|
const VIDEO_ID = /^\d{1,25}$/;
|
|
9
9
|
const SCRIPT = /^(?:https?:)?\/\/www\.tiktok\.com\/embed\.js$/;
|
|
10
|
-
const tiktok = {
|
|
11
|
-
...tiktokMatcher,
|
|
10
|
+
const tiktok = /* @__PURE__ */ parserOf(tiktokMatcher, {
|
|
12
11
|
parse(root) {
|
|
13
12
|
if (root.tag === "blockquote" && hasClass(root, "tiktok-embed")) {
|
|
14
13
|
const cite = parseUrl(root.attrs.get("cite") ?? "");
|
|
@@ -28,5 +27,5 @@ const tiktok = {
|
|
|
28
27
|
return withSize(video(id, "", options), sizeOf(root));
|
|
29
28
|
},
|
|
30
29
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
31
|
-
};
|
|
30
|
+
});
|
|
32
31
|
export { tiktok };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { hasClass } 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 { ID, USER, post, truthsocialMatcher } from "../matchers/truthsocial.js";
|
|
5
5
|
// src/parser/platforms/truthsocial.ts
|
|
6
|
-
const FRAME_PATH = new RegExp(`^/${USER}/${ID}/embed$`);
|
|
6
|
+
const FRAME_PATH = /* @__PURE__ */ new RegExp(`^/${USER}/${ID}/embed$`);
|
|
7
7
|
const SCRIPT = /^(?:https?:)?\/\/truthsocial\.com\/embed\.js$/;
|
|
8
|
-
const truthsocial = {
|
|
9
|
-
...truthsocialMatcher,
|
|
8
|
+
const truthsocial = /* @__PURE__ */ parserOf(truthsocialMatcher, {
|
|
10
9
|
parse(root) {
|
|
11
10
|
if (root.tag !== "iframe") return null;
|
|
12
11
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -20,5 +19,5 @@ const truthsocial = {
|
|
|
20
19
|
}, sizeOf(root));
|
|
21
20
|
},
|
|
22
21
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
23
|
-
};
|
|
22
|
+
});
|
|
24
23
|
export { truthsocial };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { parserOf } from "../platform.js";
|
|
1
2
|
import { hasClass } from "../html.js";
|
|
2
3
|
import { parseUrl } from "../url.js";
|
|
3
4
|
import { BLOG, POST, fromUrl, tumblrMatcher } from "../matchers/tumblr.js";
|
|
4
5
|
// src/parser/platforms/tumblr.ts
|
|
5
|
-
const FRAME_PATH = new RegExp(`^/embed/post/(?:t:[A-Za-z0-9_-]{1,64}|${BLOG})/${POST}/v2$`);
|
|
6
|
-
const OLD_FRAME_PATH = new RegExp(`^/embed/post/(?:t:)?[A-Za-z0-9_-]{1,64}/${POST}$`);
|
|
6
|
+
const FRAME_PATH = /* @__PURE__ */ new RegExp(`^/embed/post/(?:t:[A-Za-z0-9_-]{1,64}|${BLOG})/${POST}/v2$`);
|
|
7
|
+
const OLD_FRAME_PATH = /* @__PURE__ */ new RegExp(`^/embed/post/(?:t:)?[A-Za-z0-9_-]{1,64}/${POST}$`);
|
|
7
8
|
const SCRIPT = /^(?:https?:)?\/\/(?:secure\.)?assets\.tumblr\.com\/post\.js(?:\?[^#]*)?$/;
|
|
8
|
-
const tumblr = {
|
|
9
|
-
...tumblrMatcher,
|
|
9
|
+
const tumblr = /* @__PURE__ */ parserOf(tumblrMatcher, {
|
|
10
10
|
parse(root) {
|
|
11
11
|
if (root.tag !== "div" || !hasClass(root, "tumblr-post")) return null;
|
|
12
12
|
const frame = parseUrl(root.attrs.get("data-href") ?? "");
|
|
@@ -25,5 +25,5 @@ const tumblr = {
|
|
|
25
25
|
};
|
|
26
26
|
},
|
|
27
27
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
28
|
-
};
|
|
28
|
+
});
|
|
29
29
|
export { tumblr };
|
|
@@ -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 { CHANNEL, CLIP, COLLECTION, VIDEO, channel, clip, collection, twitchMatcher, vod } from "../matchers/twitch.js";
|
|
@@ -25,8 +25,7 @@ function fromPlayer(url) {
|
|
|
25
25
|
const list = url.query.get("collection");
|
|
26
26
|
return list !== void 0 && COLLECTION.test(list) ? collection(list) : null;
|
|
27
27
|
}
|
|
28
|
-
const twitch = {
|
|
29
|
-
...twitchMatcher,
|
|
28
|
+
const twitch = /* @__PURE__ */ parserOf(twitchMatcher, {
|
|
30
29
|
parse(root) {
|
|
31
30
|
if (root.tag !== "iframe") return null;
|
|
32
31
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -43,5 +42,5 @@ const twitch = {
|
|
|
43
42
|
}, sizeOf(root));
|
|
44
43
|
},
|
|
45
44
|
isOwnScript: () => false
|
|
46
|
-
};
|
|
45
|
+
});
|
|
47
46
|
export { twitch };
|
|
@@ -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 { HOSTS, fromPage, fromPlayer, vimeoMatcher } from "../matchers/vimeo.js";
|
|
4
4
|
// src/parser/platforms/vimeo.ts
|
|
@@ -18,8 +18,7 @@ function isCredit(element, embed) {
|
|
|
18
18
|
const [title, from, author, on, home, stop, ...rest] = element.children;
|
|
19
19
|
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, ".");
|
|
20
20
|
}
|
|
21
|
-
const vimeo = {
|
|
22
|
-
...vimeoMatcher,
|
|
21
|
+
const vimeo = /* @__PURE__ */ parserOf(vimeoMatcher, {
|
|
23
22
|
parse(root) {
|
|
24
23
|
const wrapped = unwrapRatio(root, WRAPPER);
|
|
25
24
|
const iframe = wrapped?.iframe ?? root;
|
|
@@ -29,5 +28,5 @@ const vimeo = {
|
|
|
29
28
|
},
|
|
30
29
|
isOwnScript: (src) => SCRIPT.test(src),
|
|
31
30
|
isOwnExtra: isCredit
|
|
32
|
-
};
|
|
31
|
+
});
|
|
33
32
|
export { vimeo };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasClass, rebuild } from "../html.js";
|
|
2
|
-
import { attributeOptions } from "../platform.js";
|
|
2
|
+
import { attributeOptions, parserOf } from "../platform.js";
|
|
3
3
|
import { coerce } from "../url.js";
|
|
4
4
|
import { FALLBACK, lastStatus, xMatcher } from "../matchers/x.js";
|
|
5
5
|
// src/parser/platforms/x.ts
|
|
@@ -14,8 +14,7 @@ const OPTION_ATTRIBUTES = [
|
|
|
14
14
|
["data-dnt", "dnt"],
|
|
15
15
|
["data-width", "width"]
|
|
16
16
|
];
|
|
17
|
-
const x = {
|
|
18
|
-
...xMatcher,
|
|
17
|
+
const x = /* @__PURE__ */ parserOf(xMatcher, {
|
|
19
18
|
parse(root) {
|
|
20
19
|
if (root.tag !== "blockquote" || !(hasClass(root, "twitter-tweet") || hasClass(root, "twitter-video"))) return null;
|
|
21
20
|
const status = lastStatus(root.children);
|
|
@@ -27,5 +26,5 @@ const x = {
|
|
|
27
26
|
};
|
|
28
27
|
},
|
|
29
28
|
isOwnScript: (src) => SCRIPT.test(src)
|
|
30
|
-
};
|
|
29
|
+
});
|
|
31
30
|
export { x };
|
|
@@ -1,10 +1,9 @@
|
|
|
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 { YOUTUBE_HOSTS, YOUTUBE_NOCOOKIE_HOSTS } from "../frames.js";
|
|
4
4
|
import { fromEmbed, startOf, youtubeMatcher } from "../matchers/youtube.js";
|
|
5
5
|
// src/parser/platforms/youtube.ts
|
|
6
|
-
const youtube = {
|
|
7
|
-
...youtubeMatcher,
|
|
6
|
+
const youtube = /* @__PURE__ */ parserOf(youtubeMatcher, {
|
|
8
7
|
parse(root) {
|
|
9
8
|
if (root.tag !== "iframe") return null;
|
|
10
9
|
const src = parseUrl(root.attrs.get("src") ?? "");
|
|
@@ -23,5 +22,5 @@ const youtube = {
|
|
|
23
22
|
}, sizeOf(root));
|
|
24
23
|
},
|
|
25
24
|
isOwnScript: () => false
|
|
26
|
-
};
|
|
25
|
+
});
|
|
27
26
|
export { youtube };
|