social-embeds 0.7.0 → 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.
Files changed (174) hide show
  1. package/README.md +14 -9
  2. package/dist/components/apple-embed.d.ts +7 -0
  3. package/dist/components/apple-embed.js +39 -0
  4. package/dist/components/bluesky-embed.d.ts +10 -0
  5. package/dist/components/bluesky-embed.js +27 -0
  6. package/dist/components/dailymotion-embed.d.ts +9 -0
  7. package/dist/components/dailymotion-embed.js +30 -0
  8. package/dist/components/facebook-embed.d.ts +6 -0
  9. package/dist/components/facebook-embed.js +40 -0
  10. package/dist/components/flickr-embed.d.ts +6 -0
  11. package/dist/components/flickr-embed.js +27 -0
  12. package/dist/components/generic-iframe-embed.d.ts +11 -0
  13. package/dist/components/generic-iframe-embed.js +26 -0
  14. package/dist/components/giphy-embed.d.ts +4 -0
  15. package/dist/components/giphy-embed.js +22 -0
  16. package/dist/components/hooks.js +36 -0
  17. package/dist/components/iframe-embed.js +169 -0
  18. package/dist/components/imgur-embed.d.ts +6 -0
  19. package/dist/components/imgur-embed.js +23 -0
  20. package/dist/components/instagram-embed.d.ts +5 -0
  21. package/dist/components/instagram-embed.js +25 -0
  22. package/dist/components/kick-embed.d.ts +6 -0
  23. package/dist/components/kick-embed.js +25 -0
  24. package/dist/components/linkedin-embed.d.ts +6 -0
  25. package/dist/components/linkedin-embed.js +23 -0
  26. package/dist/components/pinterest-embed.d.ts +5 -0
  27. package/dist/components/pinterest-embed.js +25 -0
  28. package/dist/components/reddit-embed.d.ts +6 -0
  29. package/dist/components/reddit-embed.js +29 -0
  30. package/dist/components/rumble-embed.d.ts +4 -0
  31. package/dist/components/rumble-embed.js +22 -0
  32. package/dist/components/script-embed.js +107 -0
  33. package/dist/components/shared.d.ts +29 -0
  34. package/dist/components/snapchat-embed.d.ts +4 -0
  35. package/dist/components/snapchat-embed.js +22 -0
  36. package/dist/components/social-embed.d.ts +60 -0
  37. package/dist/components/social-embed.js +221 -0
  38. package/dist/components/soundcloud-embed.d.ts +6 -0
  39. package/dist/components/soundcloud-embed.js +33 -0
  40. package/dist/components/spotify-embed.d.ts +9 -0
  41. package/dist/components/spotify-embed.js +25 -0
  42. package/dist/components/strava-embed.d.ts +6 -0
  43. package/dist/components/strava-embed.js +26 -0
  44. package/dist/components/streamable-embed.d.ts +6 -0
  45. package/dist/components/streamable-embed.js +28 -0
  46. package/dist/components/telegram-embed.d.ts +6 -0
  47. package/dist/components/telegram-embed.js +27 -0
  48. package/dist/components/tenor-embed.d.ts +4 -0
  49. package/dist/components/tenor-embed.js +22 -0
  50. package/dist/components/threads-embed.d.ts +5 -0
  51. package/dist/components/threads-embed.js +25 -0
  52. package/dist/components/tiktok-embed.d.ts +6 -0
  53. package/dist/components/tiktok-embed.js +37 -0
  54. package/dist/components/truthsocial-embed.d.ts +4 -0
  55. package/dist/components/truthsocial-embed.js +22 -0
  56. package/dist/components/tumblr-embed.d.ts +4 -0
  57. package/dist/components/tumblr-embed.js +22 -0
  58. package/dist/components/twitch-embed.d.ts +6 -0
  59. package/dist/components/twitch-embed.js +26 -0
  60. package/dist/components/vimeo-embed.d.ts +5 -0
  61. package/dist/components/vimeo-embed.js +40 -0
  62. package/dist/components/x-embed.d.ts +5 -0
  63. package/dist/components/x-embed.js +32 -0
  64. package/dist/components/youtube-embed.d.ts +5 -0
  65. package/dist/components/youtube-embed.js +43 -0
  66. package/dist/core/drivers.js +118 -0
  67. package/dist/core/layout.js +73 -0
  68. package/dist/core/markup.js +30 -0
  69. package/dist/core/params.js +26 -0
  70. package/dist/core/plans/apple.js +44 -0
  71. package/dist/core/plans/bluesky.d.ts +3 -0
  72. package/dist/core/plans/bluesky.js +34 -0
  73. package/dist/core/plans/dailymotion.d.ts +8 -0
  74. package/dist/core/plans/dailymotion.js +37 -0
  75. package/dist/core/plans/facebook.d.ts +15 -0
  76. package/dist/core/plans/facebook.js +79 -0
  77. package/dist/core/plans/flickr.d.ts +7 -0
  78. package/dist/core/plans/flickr.js +37 -0
  79. package/dist/core/plans/generic.js +44 -0
  80. package/dist/core/plans/giphy.js +16 -0
  81. package/dist/core/plans/imgur.d.ts +4 -0
  82. package/dist/core/plans/imgur.js +34 -0
  83. package/dist/core/plans/instagram.d.ts +4 -0
  84. package/dist/core/plans/instagram.js +26 -0
  85. package/dist/core/plans/kick.d.ts +5 -0
  86. package/dist/core/plans/kick.js +22 -0
  87. package/dist/core/plans/linkedin.d.ts +4 -0
  88. package/dist/core/plans/linkedin.js +23 -0
  89. package/dist/core/plans/pinterest.d.ts +4 -0
  90. package/dist/core/plans/pinterest.js +31 -0
  91. package/dist/core/plans/reddit.d.ts +11 -0
  92. package/dist/core/plans/reddit.js +46 -0
  93. package/dist/core/plans/rumble.js +21 -0
  94. package/dist/core/plans/snapchat.js +20 -0
  95. package/dist/core/plans/soundcloud.d.ts +14 -0
  96. package/dist/core/plans/soundcloud.js +37 -0
  97. package/dist/core/plans/spotify.d.ts +4 -0
  98. package/dist/core/plans/spotify.js +29 -0
  99. package/dist/core/plans/strava.d.ts +8 -0
  100. package/dist/core/plans/strava.js +38 -0
  101. package/dist/core/plans/streamable.d.ts +8 -0
  102. package/dist/core/plans/streamable.js +31 -0
  103. package/dist/core/plans/telegram.d.ts +10 -0
  104. package/dist/core/plans/telegram.js +59 -0
  105. package/dist/core/plans/tenor.js +16 -0
  106. package/dist/core/plans/threads.d.ts +4 -0
  107. package/dist/core/plans/threads.js +25 -0
  108. package/dist/core/plans/tiktok.d.ts +17 -0
  109. package/dist/core/plans/tiktok.js +36 -0
  110. package/dist/core/plans/truthsocial.js +43 -0
  111. package/dist/core/plans/tumblr.js +29 -0
  112. package/dist/core/plans/twitch.d.ts +7 -0
  113. package/dist/core/plans/twitch.js +38 -0
  114. package/dist/core/plans/vimeo.d.ts +23 -0
  115. package/dist/core/plans/vimeo.js +42 -0
  116. package/dist/core/plans/x.d.ts +12 -0
  117. package/dist/core/plans/x.js +31 -0
  118. package/dist/core/plans/youtube.d.ts +25 -0
  119. package/dist/core/plans/youtube.js +47 -0
  120. package/dist/core/post-link.js +19 -0
  121. package/dist/core/resolve.js +57 -0
  122. package/dist/core/timing.js +7 -0
  123. package/dist/element.js +1 -1
  124. package/dist/index.d.ts +53 -344
  125. package/dist/index.js +30 -2575
  126. package/dist/loader/load-script.js +114 -0
  127. package/dist/loader/platform-scripts.js +89 -0
  128. package/dist/parser/html.js +172 -0
  129. package/dist/parser/iframe.d.ts +24 -0
  130. package/dist/parser/iframe.js +151 -0
  131. package/dist/parser/lookup.js +20 -0
  132. package/dist/parser/match-url.d.ts +3 -0
  133. package/dist/parser/match-url.js +22 -0
  134. package/dist/parser/parse-embed.d.ts +7 -0
  135. package/dist/parser/parse-embed.js +69 -0
  136. package/dist/parser/platform.js +60 -0
  137. package/dist/parser/platforms/applemusic.js +45 -0
  138. package/dist/parser/platforms/applepodcasts.js +41 -0
  139. package/dist/parser/platforms/bluesky.js +64 -0
  140. package/dist/parser/platforms/dailymotion.js +59 -0
  141. package/dist/parser/platforms/facebook.js +185 -0
  142. package/dist/parser/platforms/flickr.js +134 -0
  143. package/dist/parser/platforms/giphy.js +68 -0
  144. package/dist/parser/platforms/imgur.js +107 -0
  145. package/dist/parser/platforms/index.js +62 -0
  146. package/dist/parser/platforms/instagram.js +59 -0
  147. package/dist/parser/platforms/kick.js +61 -0
  148. package/dist/parser/platforms/linkedin.js +42 -0
  149. package/dist/parser/platforms/pinterest.js +59 -0
  150. package/dist/parser/platforms/reddit.js +68 -0
  151. package/dist/parser/platforms/rumble.js +43 -0
  152. package/dist/parser/platforms/snapchat.js +87 -0
  153. package/dist/parser/platforms/soundcloud.js +128 -0
  154. package/dist/parser/platforms/spotify.js +51 -0
  155. package/dist/parser/platforms/strava.js +55 -0
  156. package/dist/parser/platforms/streamable.js +94 -0
  157. package/dist/parser/platforms/telegram.js +61 -0
  158. package/dist/parser/platforms/tenor.js +78 -0
  159. package/dist/parser/platforms/threads.js +51 -0
  160. package/dist/parser/platforms/tiktok.js +48 -0
  161. package/dist/parser/platforms/truthsocial.js +49 -0
  162. package/dist/parser/platforms/tumblr.js +70 -0
  163. package/dist/parser/platforms/twitch.js +129 -0
  164. package/dist/parser/platforms/vimeo.js +76 -0
  165. package/dist/parser/platforms/x.js +65 -0
  166. package/dist/parser/platforms/youtube.js +90 -0
  167. package/dist/parser/types.d.ts +14 -0
  168. package/dist/parser/url.js +41 -0
  169. package/dist/parser/verify.js +63 -0
  170. package/dist/parser.d.ts +4 -1
  171. package/dist/parser.js +4 -1
  172. package/package.json +1 -1
  173. package/dist/index-DrMHAkyG.d.ts +0 -46
  174. package/dist/parser-CovaPg5T.js +0 -2585
@@ -0,0 +1,33 @@
1
+ import { soundcloud } from "../parser/platforms/soundcloud.js";
2
+ import { soundcloudPlan } from "../core/plans/soundcloud.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/soundcloud-embed.tsx
8
+ /** A fixed height: the `height` prop, else the embed code's, else 400px for the visual player. */
9
+ function SoundCloudEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, height, visual, color, autoPlay, hideRelated, showComments, showUser, showReposts, showTeaser, showArtwork, ...frame } = props;
11
+ const { embed, error } = resolveEmbed(url, given, soundcloud);
12
+ const plan = embed ? soundcloudPlan(embed, {
13
+ visual,
14
+ color,
15
+ autoPlay,
16
+ hideRelated,
17
+ showComments,
18
+ showUser,
19
+ showReposts,
20
+ showTeaser,
21
+ showArtwork
22
+ }) : void 0;
23
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
24
+ if (plan?.kind !== "iframe") return null;
25
+ return /* @__PURE__ */ jsx(IframeEmbed, {
26
+ ...frame,
27
+ ...planProps(plan),
28
+ onError,
29
+ maxWidth: maxWidth ?? plan.maxWidth,
30
+ height: height ?? plan.height
31
+ });
32
+ }
33
+ export { SoundCloudEmbed };
@@ -0,0 +1,9 @@
1
+ import { SpotifyOptions } from "../core/plans/spotify.js";
2
+ import { EmbedSource, FrameProps } from "./shared.js";
3
+ export type SpotifyEmbedProps = EmbedSource & Omit<FrameProps, keyof SpotifyOptions> & SpotifyOptions;
4
+ /**
5
+ * A fixed height: the `height` prop, else the embed code's, else 152px for a track or episode
6
+ * and 352px for the rest. A video show keeps its 16:9 aspect ratio instead.
7
+ */
8
+ export declare function SpotifyEmbed(props: SpotifyEmbedProps): import("react").JSX.Element | null;
9
+ export type { SpotifyOptions };
@@ -0,0 +1,25 @@
1
+ import { spotifyPlan } from "../core/plans/spotify.js";
2
+ import { spotify } from "../parser/platforms/spotify.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/spotify-embed.tsx
8
+ /**
9
+ * A fixed height: the `height` prop, else the embed code's, else 152px for a track or episode
10
+ * and 352px for the rest. A video show keeps its 16:9 aspect ratio instead.
11
+ */
12
+ function SpotifyEmbed(props) {
13
+ const { url, embed: given, onError, height, theme, ...frame } = props;
14
+ const { embed, error } = resolveEmbed(url, given, spotify);
15
+ const plan = embed ? spotifyPlan(embed, { theme }) : void 0;
16
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
17
+ if (plan?.kind !== "iframe") return null;
18
+ return /* @__PURE__ */ jsx(IframeEmbed, {
19
+ ...frame,
20
+ ...planProps(plan),
21
+ onError,
22
+ height: height ?? plan.height
23
+ });
24
+ }
25
+ export { SpotifyEmbed };
@@ -0,0 +1,6 @@
1
+ import { StravaOptions } from "../core/plans/strava.js";
2
+ import { EmbedSource, SharedProps } from "./shared.js";
3
+ export type StravaEmbedProps = EmbedSource & Omit<SharedProps, keyof StravaOptions> & StravaOptions;
4
+ /** At most 554px wide by default, as `embed.js` makes the frame; a full-width route has no maximum (docs/decisions.md D97). */
5
+ export declare function StravaEmbed(props: StravaEmbedProps): import("react").JSX.Element | null;
6
+ export type { StravaOptions };
@@ -0,0 +1,26 @@
1
+ import { stravaPlan } from "../core/plans/strava.js";
2
+ import { strava } from "../parser/platforms/strava.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/strava-embed.tsx
8
+ /** At most 554px wide by default, as `embed.js` makes the frame; a full-width route has no maximum (docs/decisions.md D97). */
9
+ function StravaEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, embedStyle, fullWidth, mapHash, ...shared } = props;
11
+ const { embed, error } = resolveEmbed(url, given, strava);
12
+ const plan = embed ? stravaPlan(embed, {
13
+ embedStyle,
14
+ fullWidth,
15
+ mapHash
16
+ }) : void 0;
17
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
18
+ if (plan?.kind !== "iframe") return null;
19
+ return /* @__PURE__ */ jsx(IframeEmbed, {
20
+ ...shared,
21
+ ...planProps(plan),
22
+ onError,
23
+ maxWidth: maxWidth ?? plan.maxWidth
24
+ });
25
+ }
26
+ export { StravaEmbed };
@@ -0,0 +1,6 @@
1
+ import { StreamableOptions } from "../core/plans/streamable.js";
2
+ import { EmbedSource, FrameProps } from "./shared.js";
3
+ export type StreamableEmbedProps = EmbedSource & Omit<FrameProps, keyof StreamableOptions> & StreamableOptions;
4
+ /** The embed code's aspect ratio, else 16:9. */
5
+ export declare function StreamableEmbed(props: StreamableEmbedProps): import("react").JSX.Element | null;
6
+ export type { StreamableOptions };
@@ -0,0 +1,28 @@
1
+ import { streamable } from "../parser/platforms/streamable.js";
2
+ import { streamablePlan } from "../core/plans/streamable.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/streamable-embed.tsx
8
+ /** The embed code's aspect ratio, else 16:9. */
9
+ function StreamableEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, autoplay, hd, loop, muted, nocontrols, ...frame } = props;
11
+ const { embed, error } = resolveEmbed(url, given, streamable);
12
+ const plan = embed ? streamablePlan(embed, {
13
+ autoplay,
14
+ hd,
15
+ loop,
16
+ muted,
17
+ nocontrols
18
+ }) : void 0;
19
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
20
+ if (plan?.kind !== "iframe") return null;
21
+ return /* @__PURE__ */ jsx(IframeEmbed, {
22
+ ...frame,
23
+ ...planProps(plan),
24
+ onError,
25
+ maxWidth: maxWidth ?? plan.maxWidth
26
+ });
27
+ }
28
+ export { StreamableEmbed };
@@ -0,0 +1,6 @@
1
+ import { TelegramOptions } from "../core/plans/telegram.js";
2
+ import { EmbedSource, SharedProps } from "./shared.js";
3
+ export type TelegramEmbedProps = EmbedSource & Omit<SharedProps, keyof TelegramOptions> & TelegramOptions;
4
+ /** At most 500px wide by default, the widest the post renders (docs/decisions.md D49). */
5
+ export declare function TelegramEmbed(props: TelegramEmbedProps): import("react").JSX.Element | null;
6
+ export type { TelegramOptions };
@@ -0,0 +1,27 @@
1
+ import { telegramPlan } from "../core/plans/telegram.js";
2
+ import { telegram } from "../parser/platforms/telegram.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/telegram-embed.tsx
8
+ /** At most 500px wide by default, the widest the post renders (docs/decisions.md D49). */
9
+ function TelegramEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, userpic, color, dark, darkColor, ...shared } = props;
11
+ const { embed, error } = resolveEmbed(url, given, telegram);
12
+ const plan = embed ? telegramPlan(embed, {
13
+ userpic,
14
+ color,
15
+ dark,
16
+ darkColor
17
+ }) : void 0;
18
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
19
+ if (plan?.kind !== "iframe") return null;
20
+ return /* @__PURE__ */ jsx(IframeEmbed, {
21
+ ...shared,
22
+ ...planProps(plan),
23
+ onError,
24
+ maxWidth: maxWidth ?? plan.maxWidth
25
+ });
26
+ }
27
+ export { TelegramEmbed };
@@ -0,0 +1,4 @@
1
+ import { EmbedSource, FrameProps } from "./shared.js";
2
+ export type TenorEmbedProps = EmbedSource & FrameProps;
3
+ /** The embed code's aspect ratio; a URL carries no size and renders at 1.33:1 (docs/decisions.md D95). */
4
+ export declare function TenorEmbed(props: TenorEmbedProps): import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ import { tenorPlan } from "../core/plans/tenor.js";
2
+ import { tenor } from "../parser/platforms/tenor.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/tenor-embed.tsx
8
+ /** The embed code's aspect ratio; a URL carries no size and renders at 1.33:1 (docs/decisions.md D95). */
9
+ function TenorEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, ...frame } = props;
11
+ const { embed, error } = resolveEmbed(url, given, tenor);
12
+ const plan = embed ? tenorPlan(embed) : void 0;
13
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
14
+ if (plan?.kind !== "iframe") return null;
15
+ return /* @__PURE__ */ jsx(IframeEmbed, {
16
+ ...frame,
17
+ ...planProps(plan),
18
+ onError,
19
+ maxWidth: maxWidth ?? plan.maxWidth
20
+ });
21
+ }
22
+ export { TenorEmbed };
@@ -0,0 +1,5 @@
1
+ import { ThreadsOptions } from "../core/plans/threads.js";
2
+ import { EmbedSource, SharedProps } from "./shared.js";
3
+ export type ThreadsEmbedProps = EmbedSource & Omit<SharedProps, keyof ThreadsOptions> & ThreadsOptions;
4
+ export declare function ThreadsEmbed(props: ThreadsEmbedProps): import("react").JSX.Element | null;
5
+ export type { ThreadsOptions };
@@ -0,0 +1,25 @@
1
+ import { threadsPlan } from "../core/plans/threads.js";
2
+ import { threads } from "../parser/platforms/threads.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { ScriptEmbed } from "./script-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/threads-embed.tsx
8
+ function ThreadsEmbed(props) {
9
+ const { url, embed: given, onError, maxWidth, theme, ...shared } = props;
10
+ const { embed, error } = resolveEmbed(url, given, threads);
11
+ const plan = embed ? threadsPlan(embed, { theme }) : void 0;
12
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
13
+ if (plan?.kind !== "script") return null;
14
+ return /* @__PURE__ */ jsx(ScriptEmbed, {
15
+ ...shared,
16
+ onError,
17
+ maxWidth: maxWidth ?? plan.maxWidth,
18
+ driver: plan.driver,
19
+ markup: plan.markup,
20
+ hasFallback: plan.hasFallback,
21
+ minHeight: plan.minHeight,
22
+ label: plan.label
23
+ }, plan.key);
24
+ }
25
+ export { ThreadsEmbed };
@@ -0,0 +1,6 @@
1
+ import { TikTokOptions } from "../core/plans/tiktok.js";
2
+ import { EmbedSource, FrameProps } from "./shared.js";
3
+ export type TikTokEmbedProps = EmbedSource & Omit<FrameProps, keyof TikTokOptions> & TikTokOptions;
4
+ /** At most 325px wide by default, the size of TikTok's own embed code (docs/decisions.md D40). */
5
+ export declare function TikTokEmbed(props: TikTokEmbedProps): import("react").JSX.Element | null;
6
+ export type { TikTokOptions };
@@ -0,0 +1,37 @@
1
+ import { tiktokPlan } from "../core/plans/tiktok.js";
2
+ import { tiktok } from "../parser/platforms/tiktok.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/tiktok-embed.tsx
8
+ /** At most 325px wide by default, the size of TikTok's own embed code (docs/decisions.md D40). */
9
+ function TikTokEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, controls, progressBar, playButton, volumeControl, fullscreenButton, timestamp, loop, autoplay, musicInfo, description, rel, nativeContextMenu, closedCaption, forceMuted, ...frame } = props;
11
+ const { embed, error } = resolveEmbed(url, given, tiktok);
12
+ const plan = embed ? tiktokPlan(embed, {
13
+ controls,
14
+ progressBar,
15
+ playButton,
16
+ volumeControl,
17
+ fullscreenButton,
18
+ timestamp,
19
+ loop,
20
+ autoplay,
21
+ musicInfo,
22
+ description,
23
+ rel,
24
+ nativeContextMenu,
25
+ closedCaption,
26
+ forceMuted
27
+ }) : void 0;
28
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
29
+ if (plan?.kind !== "iframe") return null;
30
+ return /* @__PURE__ */ jsx(IframeEmbed, {
31
+ ...frame,
32
+ ...planProps(plan),
33
+ onError,
34
+ maxWidth: maxWidth ?? plan.maxWidth
35
+ });
36
+ }
37
+ export { TikTokEmbed };
@@ -0,0 +1,4 @@
1
+ import { EmbedSource, SharedProps } from "./shared.js";
2
+ export type TruthSocialEmbedProps = EmbedSource & SharedProps;
3
+ /** At most 600px wide by default, the width of Truth Social's embed code (docs/decisions.md D93). */
4
+ export declare function TruthSocialEmbed(props: TruthSocialEmbedProps): import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ import { truthSocialPlan } from "../core/plans/truthsocial.js";
2
+ import { truthsocial } from "../parser/platforms/truthsocial.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/truthsocial-embed.tsx
8
+ /** At most 600px wide by default, the width of Truth Social's embed code (docs/decisions.md D93). */
9
+ function TruthSocialEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, ...shared } = props;
11
+ const { embed, error } = resolveEmbed(url, given, truthsocial);
12
+ const plan = embed ? truthSocialPlan(embed) : void 0;
13
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
14
+ if (plan?.kind !== "iframe") return null;
15
+ return /* @__PURE__ */ jsx(IframeEmbed, {
16
+ ...shared,
17
+ ...planProps(plan),
18
+ onError,
19
+ maxWidth: maxWidth ?? plan.maxWidth
20
+ });
21
+ }
22
+ export { TruthSocialEmbed };
@@ -0,0 +1,4 @@
1
+ import { EmbedSource, SharedProps } from "./shared.js";
2
+ export type TumblrEmbedProps = EmbedSource & SharedProps;
3
+ /** At most 540px wide by default, Tumblr's oEmbed width. Renders the frame `post.js` would create (docs/decisions.md D77). */
4
+ export declare function TumblrEmbed(props: TumblrEmbedProps): import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ import { tumblrPlan } from "../core/plans/tumblr.js";
2
+ import { tumblr } from "../parser/platforms/tumblr.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/tumblr-embed.tsx
8
+ /** At most 540px wide by default, Tumblr's oEmbed width. Renders the frame `post.js` would create (docs/decisions.md D77). */
9
+ function TumblrEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, ...shared } = props;
11
+ const { embed, error } = resolveEmbed(url, given, tumblr);
12
+ const plan = embed ? tumblrPlan(embed) : void 0;
13
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
14
+ if (plan?.kind !== "iframe") return null;
15
+ return /* @__PURE__ */ jsx(IframeEmbed, {
16
+ ...shared,
17
+ ...planProps(plan),
18
+ onError,
19
+ maxWidth: maxWidth ?? plan.maxWidth
20
+ });
21
+ }
22
+ export { TumblrEmbed };
@@ -0,0 +1,6 @@
1
+ import { TwitchOptions } from "../core/plans/twitch.js";
2
+ import { EmbedSource, FrameProps } from "./shared.js";
3
+ export type TwitchEmbedProps = EmbedSource & Omit<FrameProps, keyof TwitchOptions> & TwitchOptions;
4
+ /** `parent` is the page's own host, added on the client (docs/decisions.md D62, D65). */
5
+ export declare function TwitchEmbed(props: TwitchEmbedProps): import("react").JSX.Element | null;
6
+ export type { TwitchOptions };
@@ -0,0 +1,26 @@
1
+ import { twitchPlan } from "../core/plans/twitch.js";
2
+ import { twitch } from "../parser/platforms/twitch.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/twitch-embed.tsx
8
+ /** `parent` is the page's own host, added on the client (docs/decisions.md D62, D65). */
9
+ function TwitchEmbed(props) {
10
+ const { url, embed: given, onError, maxWidth, autoplay, muted, time, ...frame } = props;
11
+ const { embed, error } = resolveEmbed(url, given, twitch);
12
+ const plan = embed ? twitchPlan(embed, {
13
+ autoplay,
14
+ muted,
15
+ time
16
+ }) : void 0;
17
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
18
+ if (plan?.kind !== "iframe") return null;
19
+ return /* @__PURE__ */ jsx(IframeEmbed, {
20
+ ...frame,
21
+ ...planProps(plan),
22
+ onError,
23
+ maxWidth: maxWidth ?? plan.maxWidth
24
+ });
25
+ }
26
+ export { TwitchEmbed };
@@ -0,0 +1,5 @@
1
+ import { VimeoOptions } from "../core/plans/vimeo.js";
2
+ import { EmbedSource, FrameProps } from "./shared.js";
3
+ export type VimeoEmbedProps = EmbedSource & Omit<FrameProps, keyof VimeoOptions> & VimeoOptions;
4
+ export declare function VimeoEmbed(props: VimeoEmbedProps): import("react").JSX.Element | null;
5
+ export type { VimeoOptions };
@@ -0,0 +1,40 @@
1
+ import { vimeoPlan } from "../core/plans/vimeo.js";
2
+ import { vimeo } from "../parser/platforms/vimeo.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/vimeo-embed.tsx
8
+ function VimeoEmbed(props) {
9
+ const { url, embed: given, onError, maxWidth, autopause, autoplay, background, byline, color, controls, dnt, keyboard, loop, muted, pip, playsinline, portrait, quality, speed, title, transparent, t, ...frame } = props;
10
+ const { embed, error } = resolveEmbed(url, given, vimeo);
11
+ const plan = embed ? vimeoPlan(embed, {
12
+ autopause,
13
+ autoplay,
14
+ background,
15
+ byline,
16
+ color,
17
+ controls,
18
+ dnt,
19
+ keyboard,
20
+ loop,
21
+ muted,
22
+ pip,
23
+ playsinline,
24
+ portrait,
25
+ quality,
26
+ speed,
27
+ title,
28
+ transparent,
29
+ t
30
+ }) : void 0;
31
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
32
+ if (plan?.kind !== "iframe") return null;
33
+ return /* @__PURE__ */ jsx(IframeEmbed, {
34
+ ...frame,
35
+ ...planProps(plan),
36
+ onError,
37
+ maxWidth: maxWidth ?? plan.maxWidth
38
+ });
39
+ }
40
+ export { VimeoEmbed };
@@ -0,0 +1,5 @@
1
+ import { XOptions } from "../core/plans/x.js";
2
+ import { EmbedSource, SharedProps } from "./shared.js";
3
+ export type XEmbedProps = EmbedSource & Omit<SharedProps, keyof XOptions> & XOptions;
4
+ export declare function XEmbed(props: XEmbedProps): import("react").JSX.Element | null;
5
+ export type { XOptions };
@@ -0,0 +1,32 @@
1
+ import { xPlan } from "../core/plans/x.js";
2
+ import { x } from "../parser/platforms/x.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { ScriptEmbed } from "./script-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/x-embed.tsx
8
+ function XEmbed(props) {
9
+ const { url, embed: given, onError, maxWidth, theme, conversation, cards, align, lang, dnt, ...shared } = props;
10
+ const { embed, error } = resolveEmbed(url, given, x);
11
+ const plan = embed ? xPlan(embed, {
12
+ theme,
13
+ conversation,
14
+ cards,
15
+ align,
16
+ lang,
17
+ dnt
18
+ }) : void 0;
19
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
20
+ if (plan?.kind !== "script") return null;
21
+ return /* @__PURE__ */ jsx(ScriptEmbed, {
22
+ ...shared,
23
+ onError,
24
+ maxWidth: maxWidth ?? plan.maxWidth,
25
+ driver: plan.driver,
26
+ markup: plan.markup,
27
+ hasFallback: plan.hasFallback,
28
+ minHeight: plan.minHeight,
29
+ label: plan.label
30
+ }, plan.key);
31
+ }
32
+ export { XEmbed };
@@ -0,0 +1,5 @@
1
+ import { YouTubeOptions } from "../core/plans/youtube.js";
2
+ import { EmbedSource, FrameProps } from "./shared.js";
3
+ export type YouTubeEmbedProps = EmbedSource & Omit<FrameProps, keyof YouTubeOptions> & YouTubeOptions;
4
+ export declare function YouTubeEmbed(props: YouTubeEmbedProps): import("react").JSX.Element | null;
5
+ export type { YouTubeOptions };
@@ -0,0 +1,43 @@
1
+ import { youtubePlan } from "../core/plans/youtube.js";
2
+ import { youtube } from "../parser/platforms/youtube.js";
3
+ import { useReportError } from "./hooks.js";
4
+ import { IframeEmbed, planProps } from "./iframe-embed.js";
5
+ import { resolveEmbed } from "../core/resolve.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/youtube-embed.tsx
8
+ function YouTubeEmbed(props) {
9
+ const { url, embed: given, onError, maxWidth, autoplay, ccLangPref, ccLoadPolicy, color, controls, disablekb, enablejsapi, end, fs, hl, ivLoadPolicy, list, listType, loop, origin, playlist, playsinline, rel, start, widgetReferrer, nocookie, ...frame } = props;
10
+ const { embed, error } = resolveEmbed(url, given, youtube);
11
+ const plan = embed ? youtubePlan(embed, {
12
+ autoplay,
13
+ ccLangPref,
14
+ ccLoadPolicy,
15
+ color,
16
+ controls,
17
+ disablekb,
18
+ enablejsapi,
19
+ end,
20
+ fs,
21
+ hl,
22
+ ivLoadPolicy,
23
+ list,
24
+ listType,
25
+ loop,
26
+ origin,
27
+ playlist,
28
+ playsinline,
29
+ rel,
30
+ start,
31
+ widgetReferrer,
32
+ nocookie
33
+ }) : void 0;
34
+ useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
35
+ if (plan?.kind !== "iframe") return null;
36
+ return /* @__PURE__ */ jsx(IframeEmbed, {
37
+ ...frame,
38
+ ...planProps(plan),
39
+ onError,
40
+ maxWidth: maxWidth ?? plan.maxWidth
41
+ });
42
+ }
43
+ export { YouTubeEmbed };
@@ -0,0 +1,118 @@
1
+ import { FACEBOOK_SDK_VERSION, loadPlatformScript } from "../loader/platform-scripts.js";
2
+ // src/core/drivers.ts
3
+ const globals = () => window;
4
+ function watch(container, rendered, done) {
5
+ if (rendered(container)) {
6
+ done();
7
+ return () => {};
8
+ }
9
+ const observer = new MutationObserver(() => {
10
+ if (!rendered(container)) return;
11
+ observer.disconnect();
12
+ done();
13
+ });
14
+ observer.observe(container, {
15
+ subtree: true,
16
+ childList: true,
17
+ attributes: true,
18
+ attributeFilter: [
19
+ "class",
20
+ "style",
21
+ "height"
22
+ ]
23
+ });
24
+ return () => {
25
+ observer.disconnect();
26
+ };
27
+ }
28
+ function reveal(container, className) {
29
+ const blockquote = container.querySelector("blockquote");
30
+ if (blockquote && !blockquote.hasAttribute("class")) blockquote.classList.add(className);
31
+ }
32
+ function hasSizedIframe(container) {
33
+ return [...container.querySelectorAll("iframe")].some((iframe) => Number.parseFloat(iframe.style.height) > 0);
34
+ }
35
+ const xDriver = {
36
+ load: () => loadPlatformScript("x"),
37
+ render(container, done) {
38
+ const twttr = globals().twttr;
39
+ const onRendered = (event) => {
40
+ if (event.target instanceof Node && container.contains(event.target)) done();
41
+ };
42
+ twttr?.events?.bind?.("rendered", onRendered);
43
+ const stop = watch(container, hasSizedIframe, done);
44
+ reveal(container, "twitter-tweet");
45
+ twttr?.widgets?.load?.(container);
46
+ return () => {
47
+ twttr?.events?.unbind?.("rendered", onRendered);
48
+ stop();
49
+ };
50
+ }
51
+ };
52
+ /** Instagram and Threads share `instgrm.Embeds.process()`, which renders both. */
53
+ function processEmbeds() {
54
+ const process = globals().instgrm?.Embeds?.process;
55
+ if (!process) throw new Error("social-embeds: instgrm.Embeds.process is missing");
56
+ process();
57
+ }
58
+ const instagramDriver = {
59
+ load: () => loadPlatformScript("instagram"),
60
+ render(container, done) {
61
+ const stop = watch(container, (element) => element.querySelector("iframe.instagram-media-rendered") !== null, done);
62
+ reveal(container, "instagram-media");
63
+ processEmbeds();
64
+ return stop;
65
+ }
66
+ };
67
+ const threadsDriver = {
68
+ load: () => loadPlatformScript("threads"),
69
+ render(container, done) {
70
+ const stop = watch(container, (element) => element.querySelector("iframe") !== null && element.querySelector("blockquote") === null, done);
71
+ reveal(container, "text-post-media");
72
+ processEmbeds();
73
+ return stop;
74
+ }
75
+ };
76
+ const facebookDrivers = /* @__PURE__ */ new Map();
77
+ function facebookDriver(locale) {
78
+ let driver = facebookDrivers.get(locale);
79
+ if (!driver) {
80
+ driver = {
81
+ load: () => loadPlatformScript("facebook", { locale }),
82
+ render(container, done) {
83
+ const fb = globals().FB;
84
+ const parse = fb?.XFBML?.parse;
85
+ if (!fb || !parse) throw new Error("social-embeds: FB.XFBML.parse is missing");
86
+ const run = () => {
87
+ parse(container, done);
88
+ };
89
+ try {
90
+ run();
91
+ } catch (error) {
92
+ if (!(error instanceof Error) || !/init not called/.test(error.message)) throw error;
93
+ fb.init?.({
94
+ xfbml: false,
95
+ version: FACEBOOK_SDK_VERSION
96
+ });
97
+ run();
98
+ }
99
+ return () => {};
100
+ }
101
+ };
102
+ facebookDrivers.set(locale, driver);
103
+ }
104
+ return driver;
105
+ }
106
+ const pinterestDriver = {
107
+ load: () => loadPlatformScript("pinterest"),
108
+ render(container, done) {
109
+ const build = globals().PinUtils?.build;
110
+ if (!build) throw new Error("social-embeds: PinUtils.build is missing");
111
+ const stop = watch(container, (element) => element.querySelector("span[data-pin-id]") !== null, done);
112
+ const link = container.querySelector("a");
113
+ if (link && !link.hasAttribute("data-pin-do")) link.setAttribute("data-pin-do", "embedPin");
114
+ build(container);
115
+ return stop;
116
+ }
117
+ };
118
+ export { facebookDriver, instagramDriver, pinterestDriver, threadsDriver, xDriver };