social-embeds 0.7.1 → 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.
- package/README.md +63 -51
- 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 +38 -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 +108 -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 +125 -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 +59 -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.d.ts +1 -1
- 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 +116 -0
- package/dist/loader/platform-scripts.js +89 -0
- package/dist/parser/frames.js +70 -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 +57 -0
- package/dist/parser/platforms/facebook.js +181 -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 +69 -0
- package/dist/parser/platforms/rumble.js +44 -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 +95 -0
- package/dist/parser/platforms/telegram.js +61 -0
- package/dist/parser/platforms/tenor.js +79 -0
- package/dist/parser/platforms/threads.js +51 -0
- package/dist/parser/platforms/tiktok.js +48 -0
- package/dist/parser/platforms/truthsocial.js +50 -0
- package/dist/parser/platforms/tumblr.js +72 -0
- package/dist/parser/platforms/twitch.js +128 -0
- package/dist/parser/platforms/vimeo.js +95 -0
- package/dist/parser/platforms/x.js +65 -0
- package/dist/parser/platforms/youtube.js +140 -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,16 @@
|
|
|
1
|
+
// src/core/plans/giphy.ts
|
|
2
|
+
/** The embed code's aspect ratio; a URL carries no size and renders square (docs/decisions.md D76). */
|
|
3
|
+
function giphyPlan(embed) {
|
|
4
|
+
return {
|
|
5
|
+
kind: "iframe",
|
|
6
|
+
src: `https://giphy.com/embed/${embed.id}`,
|
|
7
|
+
title: "Giphy GIF",
|
|
8
|
+
allow: "fullscreen",
|
|
9
|
+
ratio: {
|
|
10
|
+
width: 1,
|
|
11
|
+
height: 1
|
|
12
|
+
},
|
|
13
|
+
size: embed.size
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { giphyPlan };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/core/plans/imgur.ts
|
|
2
|
+
/** The frame posts one JSON string at `load`, unasked (docs/decisions.md D94). */
|
|
3
|
+
const IMGUR_HEIGHT = {
|
|
4
|
+
origin: "https://imgur.com",
|
|
5
|
+
read(data) {
|
|
6
|
+
if (typeof data !== "string") return void 0;
|
|
7
|
+
const message = JSON.parse(data);
|
|
8
|
+
return message.message === "resize_imgur" && typeof message.height === "number" ? message.height : void 0;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
/** At most 540px wide by default, the widest `embed.js` makes the frame (docs/decisions.md D94). */
|
|
12
|
+
function imgurPlan(embed, options) {
|
|
13
|
+
const params = [
|
|
14
|
+
"pub=true",
|
|
15
|
+
...options.context ?? embed.options.context !== false ? [] : ["context=false"],
|
|
16
|
+
...embed.options.analytics === false ? ["analytics=false"] : []
|
|
17
|
+
];
|
|
18
|
+
return {
|
|
19
|
+
kind: "iframe",
|
|
20
|
+
src: `https://imgur.com/${embed.id}/embed?${params.join("&")}`,
|
|
21
|
+
title: "Imgur post",
|
|
22
|
+
allow: "",
|
|
23
|
+
scrolling: "no",
|
|
24
|
+
ratio: {
|
|
25
|
+
width: 1,
|
|
26
|
+
height: 1
|
|
27
|
+
},
|
|
28
|
+
messageHeight: IMGUR_HEIGHT,
|
|
29
|
+
startHeight: 500,
|
|
30
|
+
maxWidth: 540,
|
|
31
|
+
fallbackHtml: embed.fallbackHtml
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export { imgurPlan };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { instagramDriver } from "../drivers.js";
|
|
2
|
+
import { attributes, hasFallback, withProps } from "../markup.js";
|
|
3
|
+
// src/core/plans/instagram.ts
|
|
4
|
+
/** A photo post without caption at 375px, the smallest measured (docs/decisions.md D34). */
|
|
5
|
+
const MIN_HEIGHT = 680;
|
|
6
|
+
const FLUID_WIDTH = "width:calc(100% - 2px)";
|
|
7
|
+
function instagramPlan(embed, options) {
|
|
8
|
+
const merged = withProps(embed.options, { captioned: options.captioned });
|
|
9
|
+
const markup = `<blockquote${attributes({
|
|
10
|
+
"data-instgrm-permalink": embed.url,
|
|
11
|
+
"data-instgrm-version": merged.version,
|
|
12
|
+
"data-instgrm-captioned": merged.captioned === true ? true : void 0,
|
|
13
|
+
style: FLUID_WIDTH
|
|
14
|
+
})}>${embed.fallbackHtml ?? ""}</blockquote>`;
|
|
15
|
+
return {
|
|
16
|
+
kind: "script",
|
|
17
|
+
key: markup,
|
|
18
|
+
markup,
|
|
19
|
+
driver: instagramDriver,
|
|
20
|
+
minHeight: MIN_HEIGHT,
|
|
21
|
+
label: "Instagram",
|
|
22
|
+
hasFallback: hasFallback(embed.fallbackHtml),
|
|
23
|
+
maxWidth: 540
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { instagramPlan };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { query } from "../params.js";
|
|
2
|
+
// src/core/plans/kick.ts
|
|
3
|
+
const KEPT = /* @__PURE__ */ new Set(["autoplay", "muted"]);
|
|
4
|
+
/** A live channel at 16:9. */
|
|
5
|
+
function kickPlan(embed, options) {
|
|
6
|
+
const fromOptions = [];
|
|
7
|
+
if (options.autoplay !== void 0) fromOptions.push(["autoplay", options.autoplay]);
|
|
8
|
+
if (options.muted !== void 0) fromOptions.push(["muted", options.muted]);
|
|
9
|
+
return {
|
|
10
|
+
kind: "iframe",
|
|
11
|
+
src: `https://player.kick.com/${embed.id}${query(Object.entries(embed.options).filter(([key]) => KEPT.has(key)), fromOptions)}`,
|
|
12
|
+
title: "Kick player",
|
|
13
|
+
allow: "autoplay; fullscreen",
|
|
14
|
+
scrolling: "no",
|
|
15
|
+
ratio: {
|
|
16
|
+
width: 16,
|
|
17
|
+
height: 9
|
|
18
|
+
},
|
|
19
|
+
size: embed.size
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { kickPlan };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { query } from "../params.js";
|
|
2
|
+
// src/core/plans/linkedin.ts
|
|
3
|
+
const DEFAULT_HEIGHT = 670;
|
|
4
|
+
const DEFAULT_WIDTH = 504;
|
|
5
|
+
/** A fixed height: the embed code's, else 670px. */
|
|
6
|
+
function linkedinPlan(embed, options) {
|
|
7
|
+
const params = new Map(Object.entries(embed.options));
|
|
8
|
+
if (options.collapsed === true) params.set("collapsed", 1);
|
|
9
|
+
if (options.collapsed === false) params.delete("collapsed");
|
|
10
|
+
return {
|
|
11
|
+
kind: "iframe",
|
|
12
|
+
src: `https://www.linkedin.com/embed/feed/update/${embed.id}${query(params)}`,
|
|
13
|
+
title: "LinkedIn post",
|
|
14
|
+
allow: "",
|
|
15
|
+
ratio: {
|
|
16
|
+
width: DEFAULT_WIDTH,
|
|
17
|
+
height: DEFAULT_HEIGHT
|
|
18
|
+
},
|
|
19
|
+
height: embed.size?.height ?? DEFAULT_HEIGHT,
|
|
20
|
+
maxWidth: embed.size?.width ?? DEFAULT_WIDTH
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { linkedinPlan };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { escapeAttribute } from "../../parser/html.js";
|
|
2
|
+
import { pinterestDriver } from "../drivers.js";
|
|
3
|
+
import { dataAttributes, withProps } from "../markup.js";
|
|
4
|
+
// src/core/plans/pinterest.ts
|
|
5
|
+
const ATTRIBUTES = {
|
|
6
|
+
width: "data-pin-width",
|
|
7
|
+
lang: "data-pin-lang",
|
|
8
|
+
terse: "data-pin-terse"
|
|
9
|
+
};
|
|
10
|
+
const PIN_WIDTHS = {
|
|
11
|
+
small: 236,
|
|
12
|
+
medium: 345,
|
|
13
|
+
large: 600
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_PIN_WIDTH = 236;
|
|
16
|
+
const MIN_HEIGHT = 270;
|
|
17
|
+
function pinterestPlan(embed, options) {
|
|
18
|
+
const merged = withProps(embed.options, { width: options.pinWidth });
|
|
19
|
+
const markup = `<a href="${escapeAttribute(embed.url)}"${dataAttributes(ATTRIBUTES, merged)}></a>`;
|
|
20
|
+
return {
|
|
21
|
+
kind: "script",
|
|
22
|
+
key: markup,
|
|
23
|
+
markup,
|
|
24
|
+
driver: pinterestDriver,
|
|
25
|
+
minHeight: MIN_HEIGHT,
|
|
26
|
+
label: "Pinterest",
|
|
27
|
+
hasFallback: false,
|
|
28
|
+
maxWidth: PIN_WIDTHS[String(merged.width)] ?? DEFAULT_PIN_WIDTH
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export { pinterestPlan };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The `data-embed-*` options of Reddit's embed code that hosts set most. */
|
|
2
|
+
export type RedditOptions = {
|
|
3
|
+
theme?: 'light' | 'dark';
|
|
4
|
+
showMedia?: boolean;
|
|
5
|
+
showTitle?: boolean;
|
|
6
|
+
showUsername?: boolean;
|
|
7
|
+
/** Language of the post, which Reddit machine-translates (docs/decisions.md D52). */
|
|
8
|
+
locale?: string;
|
|
9
|
+
/** Replies shown under an embedded comment. */
|
|
10
|
+
depth?: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { query } from "../params.js";
|
|
2
|
+
// src/core/plans/reddit.ts
|
|
3
|
+
const PARAMS = {
|
|
4
|
+
theme: "theme",
|
|
5
|
+
showMedia: "showmedia",
|
|
6
|
+
showTitle: "showtitle",
|
|
7
|
+
showUsername: "showusername",
|
|
8
|
+
locale: "locale",
|
|
9
|
+
depth: "depth"
|
|
10
|
+
};
|
|
11
|
+
const SANDBOX = "allow-scripts allow-same-origin allow-popups";
|
|
12
|
+
const ALLOW = "clipboard-read; clipboard-write";
|
|
13
|
+
const START_HEIGHT = 316;
|
|
14
|
+
/** docs/decisions.md D52. */
|
|
15
|
+
const REDDIT_HEIGHT = {
|
|
16
|
+
origin: "https://embed.reddit.com",
|
|
17
|
+
read(data) {
|
|
18
|
+
if (typeof data !== "string") return void 0;
|
|
19
|
+
const message = JSON.parse(data);
|
|
20
|
+
return message.type === "resize.embed" && typeof message.data === "number" ? message.data : void 0;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/** At most 640px wide by default, the width widgets.js gives the frame (docs/decisions.md D52). */
|
|
24
|
+
function redditPlan(embed, options) {
|
|
25
|
+
const fromProps = [];
|
|
26
|
+
for (const [prop, name] of Object.entries(PARAMS)) {
|
|
27
|
+
const value = options[prop];
|
|
28
|
+
if (value !== void 0) fromProps.push([name, value]);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
kind: "iframe",
|
|
32
|
+
src: `https://embed.reddit.com${embed.url.slice(22)}${query([["embed", true]], Object.entries(embed.options), fromProps)}`,
|
|
33
|
+
title: "Reddit post",
|
|
34
|
+
allow: ALLOW,
|
|
35
|
+
sandbox: SANDBOX,
|
|
36
|
+
scrolling: "no",
|
|
37
|
+
ratio: {
|
|
38
|
+
width: 1,
|
|
39
|
+
height: 1
|
|
40
|
+
},
|
|
41
|
+
messageHeight: REDDIT_HEIGHT,
|
|
42
|
+
startHeight: embed.size?.height ?? START_HEIGHT,
|
|
43
|
+
maxWidth: 640
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export { redditPlan };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { optionsWithout, query } from "../params.js";
|
|
2
|
+
// src/core/plans/rumble.ts
|
|
3
|
+
/**
|
|
4
|
+
* Rumble documents no player parameters (docs/decisions.md D99), so there are no options.
|
|
5
|
+
* The embed code's `pub` is kept as given and never added.
|
|
6
|
+
*/
|
|
7
|
+
function rumblePlan(embed) {
|
|
8
|
+
const pub = optionsWithout(embed.options, []).filter(([key]) => key === "pub");
|
|
9
|
+
return {
|
|
10
|
+
kind: "iframe",
|
|
11
|
+
src: `https://rumble.com/embed/${embed.id}/${query(pub)}`,
|
|
12
|
+
title: "Rumble video",
|
|
13
|
+
allow: "fullscreen",
|
|
14
|
+
ratio: {
|
|
15
|
+
width: 16,
|
|
16
|
+
height: 9
|
|
17
|
+
},
|
|
18
|
+
size: embed.size
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export { rumblePlan };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/core/plans/snapchat.ts
|
|
2
|
+
const ALLOW = "autoplay; camera; microphone; clipboard-write;";
|
|
3
|
+
/** At most 416px wide by default, the size of Snapchat's own embed code (docs/decisions.md D50). */
|
|
4
|
+
function snapchatPlan(embed) {
|
|
5
|
+
const title = embed.options.title;
|
|
6
|
+
return {
|
|
7
|
+
kind: "iframe",
|
|
8
|
+
src: `${embed.url}/embed`,
|
|
9
|
+
title: typeof title === "string" && title !== "" ? title : "Snapchat",
|
|
10
|
+
allow: ALLOW,
|
|
11
|
+
scrolling: "no",
|
|
12
|
+
ratio: {
|
|
13
|
+
width: 416,
|
|
14
|
+
height: 692
|
|
15
|
+
},
|
|
16
|
+
size: embed.size,
|
|
17
|
+
maxWidth: 416
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export { snapchatPlan };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** SoundCloud's player parameters, in camelCase. */
|
|
2
|
+
export type SoundCloudOptions = {
|
|
3
|
+
/** The large-artwork player; `false` for the classic one. */
|
|
4
|
+
visual?: boolean;
|
|
5
|
+
/** Accent colour, such as `'#ff5500'`. */
|
|
6
|
+
color?: string;
|
|
7
|
+
autoPlay?: boolean;
|
|
8
|
+
hideRelated?: boolean;
|
|
9
|
+
showComments?: boolean;
|
|
10
|
+
showUser?: boolean;
|
|
11
|
+
showReposts?: boolean;
|
|
12
|
+
showTeaser?: boolean;
|
|
13
|
+
showArtwork?: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { optionsWithout, query } from "../params.js";
|
|
2
|
+
// src/core/plans/soundcloud.ts
|
|
3
|
+
const PARAMS = {
|
|
4
|
+
visual: "visual",
|
|
5
|
+
color: "color",
|
|
6
|
+
autoPlay: "auto_play",
|
|
7
|
+
hideRelated: "hide_related",
|
|
8
|
+
showComments: "show_comments",
|
|
9
|
+
showUser: "show_user",
|
|
10
|
+
showReposts: "show_reposts",
|
|
11
|
+
showTeaser: "show_teaser",
|
|
12
|
+
showArtwork: "show_artwork"
|
|
13
|
+
};
|
|
14
|
+
const ALLOW = "autoplay; encrypted-media";
|
|
15
|
+
const URL_HEIGHT = 400;
|
|
16
|
+
/** A fixed height: the embed code's, else 400px for the visual player. */
|
|
17
|
+
function soundcloudPlan(embed, options) {
|
|
18
|
+
const fromOptions = [];
|
|
19
|
+
for (const [option, name] of Object.entries(PARAMS)) {
|
|
20
|
+
const value = options[option];
|
|
21
|
+
if (value !== void 0) fromOptions.push([name, value]);
|
|
22
|
+
}
|
|
23
|
+
const fromUrl = embed.size === void 0;
|
|
24
|
+
return {
|
|
25
|
+
kind: "iframe",
|
|
26
|
+
src: `https://w.soundcloud.com/player/${query([["url", embed.url]], fromUrl ? [["visual", true]] : void 0, optionsWithout(embed.options, ["url", "secret_token"]), fromOptions)}`,
|
|
27
|
+
title: "SoundCloud player",
|
|
28
|
+
allow: ALLOW,
|
|
29
|
+
scrolling: "no",
|
|
30
|
+
ratio: {
|
|
31
|
+
width: 16,
|
|
32
|
+
height: 9
|
|
33
|
+
},
|
|
34
|
+
height: embed.size?.height ?? URL_HEIGHT
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export { soundcloudPlan };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { query } from "../params.js";
|
|
2
|
+
// src/core/plans/spotify.ts
|
|
3
|
+
const ALLOW = "autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture";
|
|
4
|
+
const COMPACT = /* @__PURE__ */ new Set(["track", "episode"]);
|
|
5
|
+
const COMPACT_HEIGHT = 152;
|
|
6
|
+
const FULL_HEIGHT = 352;
|
|
7
|
+
/**
|
|
8
|
+
* A fixed height: the embed code's, else 152px for a track or episode and 352px for the rest.
|
|
9
|
+
* A video show keeps its 16:9 aspect ratio instead.
|
|
10
|
+
*/
|
|
11
|
+
function spotifyPlan(embed, options) {
|
|
12
|
+
const type = new URL(embed.url).pathname.split("/")[1] ?? "";
|
|
13
|
+
const video = embed.kind === "video";
|
|
14
|
+
const params = query(Object.entries(embed.options), options.theme === void 0 ? void 0 : [["theme", options.theme]]);
|
|
15
|
+
return {
|
|
16
|
+
kind: "iframe",
|
|
17
|
+
src: `https://open.spotify.com/embed/${type}/${embed.id}${video ? "/video" : ""}${params}`,
|
|
18
|
+
title: "Spotify Embed",
|
|
19
|
+
allow: ALLOW,
|
|
20
|
+
ratio: {
|
|
21
|
+
width: 16,
|
|
22
|
+
height: 9
|
|
23
|
+
},
|
|
24
|
+
size: video ? embed.size : void 0,
|
|
25
|
+
borderRadius: 12,
|
|
26
|
+
height: video ? void 0 : embed.size?.height ?? (COMPACT.has(type) ? COMPACT_HEIGHT : FULL_HEIGHT)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export { spotifyPlan };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The display options of Strava's embed code (docs/decisions.md D97). */
|
|
2
|
+
export type StravaOptions = {
|
|
3
|
+
/** The embed's `data-style`. */
|
|
4
|
+
embedStyle?: 'standard' | 'minimal';
|
|
5
|
+
/** Routes only: the frame fills its container, with no maximum width. */
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
mapHash?: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/core/plans/strava.ts
|
|
2
|
+
const NS = "social-embeds";
|
|
3
|
+
/** The frame posts `[ns, 'BROADCAST_IFRAME_HEIGHT', height]` once, unasked (docs/decisions.md D97). */
|
|
4
|
+
const STRAVA_HEIGHT = {
|
|
5
|
+
origin: "https://strava-embeds.com",
|
|
6
|
+
read(data) {
|
|
7
|
+
if (!Array.isArray(data)) return void 0;
|
|
8
|
+
const [, type, height] = data;
|
|
9
|
+
return type === "BROADCAST_IFRAME_HEIGHT" && typeof height === "number" ? height : void 0;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function styleOf(value) {
|
|
13
|
+
return value === "minimal" ? "minimal" : "standard";
|
|
14
|
+
}
|
|
15
|
+
/** At most 554px wide by default, as `embed.js` makes the frame; a full-width route has no maximum (docs/decisions.md D97). */
|
|
16
|
+
function stravaPlan(embed, options) {
|
|
17
|
+
const route = embed.id.startsWith("route/");
|
|
18
|
+
const style = styleOf(options.embedStyle ?? embed.options.style);
|
|
19
|
+
const fullWidth = route && (options.fullWidth ?? embed.options.fullWidth === true);
|
|
20
|
+
const mapHash = options.mapHash ?? embed.options.mapHash;
|
|
21
|
+
const query = `?style=${style}${fullWidth ? "&fullWidth=true" : ""}`;
|
|
22
|
+
const fragment = `#ns=${NS}${typeof mapHash === "string" && mapHash !== "" ? `&mapHash=${encodeURIComponent(mapHash)}` : ""}`;
|
|
23
|
+
return {
|
|
24
|
+
kind: "iframe",
|
|
25
|
+
src: `https://strava-embeds.com/${embed.id}${query}${fragment}`,
|
|
26
|
+
title: route ? "Strava route" : "Strava activity",
|
|
27
|
+
allow: "",
|
|
28
|
+
scrolling: "no",
|
|
29
|
+
ratio: {
|
|
30
|
+
width: 1,
|
|
31
|
+
height: 1
|
|
32
|
+
},
|
|
33
|
+
messageHeight: STRAVA_HEIGHT,
|
|
34
|
+
startHeight: 650,
|
|
35
|
+
...fullWidth ? {} : { maxWidth: 554 }
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export { stravaPlan };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { playerParams, query } from "../params.js";
|
|
2
|
+
// src/core/plans/streamable.ts
|
|
3
|
+
const KEPT = /* @__PURE__ */ new Set([
|
|
4
|
+
"autoplay",
|
|
5
|
+
"hd",
|
|
6
|
+
"loop",
|
|
7
|
+
"muted",
|
|
8
|
+
"nocontrols"
|
|
9
|
+
]);
|
|
10
|
+
const PARAMS = {
|
|
11
|
+
autoplay: "autoplay",
|
|
12
|
+
hd: "hd",
|
|
13
|
+
loop: "loop",
|
|
14
|
+
muted: "muted",
|
|
15
|
+
nocontrols: "nocontrols"
|
|
16
|
+
};
|
|
17
|
+
function streamablePlan(embed, options) {
|
|
18
|
+
const parsed = Object.entries(embed.options).filter(([key]) => KEPT.has(key));
|
|
19
|
+
return {
|
|
20
|
+
kind: "iframe",
|
|
21
|
+
src: `https://streamable.com/e/${embed.id}${query(parsed, playerParams(options, PARAMS))}`,
|
|
22
|
+
title: "Streamable video",
|
|
23
|
+
allow: "autoplay; fullscreen",
|
|
24
|
+
ratio: {
|
|
25
|
+
width: 16,
|
|
26
|
+
height: 9
|
|
27
|
+
},
|
|
28
|
+
size: embed.size
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export { streamablePlan };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The options of Telegram's post widget configurator (core.telegram.org/widgets/post). */
|
|
2
|
+
export type TelegramOptions = {
|
|
3
|
+
/** Show the author's photo. */
|
|
4
|
+
userpic?: boolean;
|
|
5
|
+
/** Accent colour as hex, without `#`. */
|
|
6
|
+
color?: string;
|
|
7
|
+
dark?: boolean;
|
|
8
|
+
/** Accent colour in the dark theme, as hex without `#`. */
|
|
9
|
+
darkColor?: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { query } from "../params.js";
|
|
2
|
+
// src/core/plans/telegram.ts
|
|
3
|
+
const PARAMS = [
|
|
4
|
+
["comment", "comment"],
|
|
5
|
+
["userpic", "userpic"],
|
|
6
|
+
["mode", "mode"],
|
|
7
|
+
["single", "single"],
|
|
8
|
+
["color", "color"],
|
|
9
|
+
["dark", "dark"],
|
|
10
|
+
["darkColor", "dark_color"]
|
|
11
|
+
];
|
|
12
|
+
function param(name, value) {
|
|
13
|
+
if (typeof value === "boolean") {
|
|
14
|
+
if (name === "userpic") return String(value);
|
|
15
|
+
if (name === "single") return value ? 1 : void 0;
|
|
16
|
+
return value ? 1 : 0;
|
|
17
|
+
}
|
|
18
|
+
return typeof value === "string" || typeof value === "number" ? value : void 0;
|
|
19
|
+
}
|
|
20
|
+
/** docs/decisions.md D49. */
|
|
21
|
+
const TELEGRAM_HEIGHT = {
|
|
22
|
+
origin: "https://t.me",
|
|
23
|
+
read(data) {
|
|
24
|
+
if (typeof data !== "string") return void 0;
|
|
25
|
+
const message = JSON.parse(data);
|
|
26
|
+
return message.event === "resize" && typeof message.height === "number" ? message.height : void 0;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/** At most 500px wide by default, the widest the post renders (docs/decisions.md D49). */
|
|
30
|
+
function telegramPlan(embed, options) {
|
|
31
|
+
const { userpic, color, dark, darkColor } = options;
|
|
32
|
+
const values = {
|
|
33
|
+
...embed.options,
|
|
34
|
+
...userpic === void 0 ? {} : { userpic },
|
|
35
|
+
...color === void 0 ? {} : { color },
|
|
36
|
+
...dark === void 0 ? {} : { dark },
|
|
37
|
+
...darkColor === void 0 ? {} : { darkColor }
|
|
38
|
+
};
|
|
39
|
+
const params = [["embed", 1]];
|
|
40
|
+
for (const [option, name] of PARAMS) {
|
|
41
|
+
const value = param(name, values[option]);
|
|
42
|
+
if (value !== void 0) params.push([name, value]);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
kind: "iframe",
|
|
46
|
+
src: `${embed.url}${query(params)}`,
|
|
47
|
+
title: "Telegram post",
|
|
48
|
+
allow: "",
|
|
49
|
+
scrolling: "no",
|
|
50
|
+
ratio: {
|
|
51
|
+
width: 1,
|
|
52
|
+
height: 1
|
|
53
|
+
},
|
|
54
|
+
messageHeight: TELEGRAM_HEIGHT,
|
|
55
|
+
startHeight: 300,
|
|
56
|
+
maxWidth: 500
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { telegramPlan };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/core/plans/tenor.ts
|
|
2
|
+
/** The embed code's aspect ratio; a URL carries no size and renders at 1.33:1, as `embed.js` does (docs/decisions.md D95). */
|
|
3
|
+
function tenorPlan(embed) {
|
|
4
|
+
return {
|
|
5
|
+
kind: "iframe",
|
|
6
|
+
src: `https://tenor.com/embed/${embed.id}`,
|
|
7
|
+
title: "Tenor GIF",
|
|
8
|
+
allow: "fullscreen",
|
|
9
|
+
ratio: {
|
|
10
|
+
width: 133,
|
|
11
|
+
height: 100
|
|
12
|
+
},
|
|
13
|
+
size: embed.size
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { tenorPlan };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { threadsDriver } from "../drivers.js";
|
|
2
|
+
import { attributes, hasFallback, withProps } from "../markup.js";
|
|
3
|
+
// src/core/plans/threads.ts
|
|
4
|
+
/** A text-only post (docs/decisions.md D34). */
|
|
5
|
+
const MIN_HEIGHT = 240;
|
|
6
|
+
function threadsPlan(embed, options) {
|
|
7
|
+
const merged = withProps(embed.options, { theme: options.theme });
|
|
8
|
+
const markup = `<blockquote${attributes({
|
|
9
|
+
"data-text-post-permalink": embed.url,
|
|
10
|
+
"data-text-post-version": merged.version ?? 0,
|
|
11
|
+
id: `ig-tp-${embed.id}`,
|
|
12
|
+
"data-theme": merged.theme
|
|
13
|
+
})}>${embed.fallbackHtml ?? ""}</blockquote>`;
|
|
14
|
+
return {
|
|
15
|
+
kind: "script",
|
|
16
|
+
key: markup,
|
|
17
|
+
markup,
|
|
18
|
+
driver: threadsDriver,
|
|
19
|
+
minHeight: MIN_HEIGHT,
|
|
20
|
+
label: "Threads",
|
|
21
|
+
hasFallback: hasFallback(embed.fallbackHtml),
|
|
22
|
+
maxWidth: 658
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export { threadsPlan };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The Embed Player parameters TikTok documents (developers.tiktok.com/doc/embed-player). */
|
|
2
|
+
export type TikTokOptions = {
|
|
3
|
+
controls?: boolean;
|
|
4
|
+
progressBar?: boolean;
|
|
5
|
+
playButton?: boolean;
|
|
6
|
+
volumeControl?: boolean;
|
|
7
|
+
fullscreenButton?: boolean;
|
|
8
|
+
timestamp?: boolean;
|
|
9
|
+
loop?: boolean;
|
|
10
|
+
autoplay?: boolean;
|
|
11
|
+
musicInfo?: boolean;
|
|
12
|
+
description?: boolean;
|
|
13
|
+
rel?: boolean;
|
|
14
|
+
nativeContextMenu?: boolean;
|
|
15
|
+
closedCaption?: boolean;
|
|
16
|
+
forceMuted?: boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { playerParams, query } from "../params.js";
|
|
2
|
+
// src/core/plans/tiktok.ts
|
|
3
|
+
const PARAMS = {
|
|
4
|
+
controls: "controls",
|
|
5
|
+
progressBar: "progress_bar",
|
|
6
|
+
playButton: "play_button",
|
|
7
|
+
volumeControl: "volume_control",
|
|
8
|
+
fullscreenButton: "fullscreen_button",
|
|
9
|
+
timestamp: "timestamp",
|
|
10
|
+
loop: "loop",
|
|
11
|
+
autoplay: "autoplay",
|
|
12
|
+
musicInfo: "music_info",
|
|
13
|
+
description: "description",
|
|
14
|
+
rel: "rel",
|
|
15
|
+
nativeContextMenu: "native_context_menu",
|
|
16
|
+
closedCaption: "closed_caption",
|
|
17
|
+
forceMuted: "force_muted"
|
|
18
|
+
};
|
|
19
|
+
const ALLOW = "accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share";
|
|
20
|
+
/** At most 325px wide by default, the size of TikTok's own embed code (docs/decisions.md D40). */
|
|
21
|
+
function tiktokPlan(embed, options) {
|
|
22
|
+
const params = playerParams(options, PARAMS);
|
|
23
|
+
return {
|
|
24
|
+
kind: "iframe",
|
|
25
|
+
src: `https://www.tiktok.com/player/v1/${embed.id}${query(Object.entries(embed.options), params)}`,
|
|
26
|
+
title: "TikTok video player",
|
|
27
|
+
allow: ALLOW,
|
|
28
|
+
ratio: {
|
|
29
|
+
width: 9,
|
|
30
|
+
height: 16
|
|
31
|
+
},
|
|
32
|
+
size: embed.size,
|
|
33
|
+
maxWidth: 325
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export { tiktokPlan };
|