social-embeds 0.9.1 → 0.9.2

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 (61) hide show
  1. package/README.md +3 -3
  2. package/dist/components/apple-embed.d.ts +2 -2
  3. package/dist/components/apple-embed.js +6 -28
  4. package/dist/components/bluesky-embed.d.ts +1 -1
  5. package/dist/components/bluesky-embed.js +5 -16
  6. package/dist/components/dailymotion-embed.d.ts +1 -1
  7. package/dist/components/dailymotion-embed.js +10 -20
  8. package/dist/components/facebook-embed.d.ts +1 -1
  9. package/dist/components/facebook-embed.js +13 -34
  10. package/dist/components/flickr-embed.d.ts +1 -1
  11. package/dist/components/flickr-embed.js +9 -20
  12. package/dist/components/giphy-embed.d.ts +1 -1
  13. package/dist/components/giphy-embed.js +4 -15
  14. package/dist/components/iframe-embed.js +15 -1
  15. package/dist/components/imgur-embed.d.ts +1 -1
  16. package/dist/components/imgur-embed.js +5 -16
  17. package/dist/components/instagram-embed.d.ts +1 -1
  18. package/dist/components/instagram-embed.js +5 -19
  19. package/dist/components/kick-embed.d.ts +1 -1
  20. package/dist/components/kick-embed.js +5 -18
  21. package/dist/components/linkedin-embed.d.ts +1 -1
  22. package/dist/components/linkedin-embed.js +5 -16
  23. package/dist/components/pinterest-embed.d.ts +1 -1
  24. package/dist/components/pinterest-embed.js +5 -19
  25. package/dist/components/reddit-embed.d.ts +1 -1
  26. package/dist/components/reddit-embed.js +12 -22
  27. package/dist/components/rumble-embed.d.ts +1 -1
  28. package/dist/components/rumble-embed.js +4 -15
  29. package/dist/components/script-embed.js +14 -1
  30. package/dist/components/snapchat-embed.d.ts +1 -1
  31. package/dist/components/snapchat-embed.js +4 -15
  32. package/dist/components/soundcloud-embed.d.ts +1 -1
  33. package/dist/components/soundcloud-embed.js +15 -26
  34. package/dist/components/spotify-embed.d.ts +1 -1
  35. package/dist/components/spotify-embed.js +5 -15
  36. package/dist/components/strava-embed.d.ts +1 -1
  37. package/dist/components/strava-embed.js +9 -19
  38. package/dist/components/streamable-embed.d.ts +1 -1
  39. package/dist/components/streamable-embed.js +11 -21
  40. package/dist/components/telegram-embed.d.ts +1 -1
  41. package/dist/components/telegram-embed.js +10 -20
  42. package/dist/components/tenor-embed.d.ts +1 -1
  43. package/dist/components/tenor-embed.js +4 -15
  44. package/dist/components/threads-embed.d.ts +1 -1
  45. package/dist/components/threads-embed.js +5 -19
  46. package/dist/components/tiktok-embed.d.ts +1 -1
  47. package/dist/components/tiktok-embed.js +20 -30
  48. package/dist/components/truthsocial-embed.d.ts +1 -1
  49. package/dist/components/truthsocial-embed.js +4 -15
  50. package/dist/components/tumblr-embed.d.ts +1 -1
  51. package/dist/components/tumblr-embed.js +4 -15
  52. package/dist/components/twitch-embed.d.ts +1 -1
  53. package/dist/components/twitch-embed.js +9 -19
  54. package/dist/components/use-plan.js +20 -0
  55. package/dist/components/vimeo-embed.d.ts +1 -1
  56. package/dist/components/vimeo-embed.js +24 -34
  57. package/dist/components/x-embed.d.ts +1 -1
  58. package/dist/components/x-embed.js +12 -26
  59. package/dist/components/youtube-embed.d.ts +1 -1
  60. package/dist/components/youtube-embed.js +27 -37
  61. package/package.json +1 -1
@@ -1,40 +1,30 @@
1
1
  import { vimeoPlan } from "../core/plans/vimeo.js";
2
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";
3
+ import { usePlan } from "./use-plan.js";
4
+ import { frameOf } from "./iframe-embed.js";
7
5
  // src/components/vimeo-embed.tsx
6
+ const VIMEO_OPTIONS = [
7
+ "autopause",
8
+ "autoplay",
9
+ "background",
10
+ "byline",
11
+ "color",
12
+ "controls",
13
+ "dnt",
14
+ "keyboard",
15
+ "loop",
16
+ "muted",
17
+ "pip",
18
+ "playsinline",
19
+ "portrait",
20
+ "quality",
21
+ "speed",
22
+ "title",
23
+ "transparent",
24
+ "t"
25
+ ];
8
26
  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
- });
27
+ const [plan, frame] = usePlan(props, vimeo, VIMEO_OPTIONS, vimeoPlan);
28
+ return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
39
29
  }
40
30
  export { VimeoEmbed };
@@ -1,5 +1,5 @@
1
1
  import { XOptions } from "../core/plans/x.js";
2
2
  import { EmbedSource, SharedProps } from "./shared.js";
3
3
  export type XEmbedProps = EmbedSource & Omit<SharedProps, keyof XOptions> & XOptions;
4
- export declare function XEmbed(props: XEmbedProps): import("react").JSX.Element | null;
4
+ export declare function XEmbed(props: XEmbedProps): import("react").ReactNode;
5
5
  export type { XOptions };
@@ -1,32 +1,18 @@
1
1
  import { xPlan } from "../core/plans/x.js";
2
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";
3
+ import { usePlan } from "./use-plan.js";
4
+ import { scriptOf } from "./script-embed.js";
7
5
  // src/components/x-embed.tsx
6
+ const X_OPTIONS = [
7
+ "theme",
8
+ "conversation",
9
+ "cards",
10
+ "align",
11
+ "lang",
12
+ "dnt"
13
+ ];
8
14
  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);
15
+ const [plan, frame] = usePlan(props, x, X_OPTIONS, xPlan);
16
+ return plan?.kind === "script" ? scriptOf(plan, frame) : null;
31
17
  }
32
18
  export { XEmbed };
@@ -1,5 +1,5 @@
1
1
  import { YouTubeOptions } from "../core/plans/youtube.js";
2
2
  import { EmbedSource, FrameProps } from "./shared.js";
3
3
  export type YouTubeEmbedProps = EmbedSource & Omit<FrameProps, keyof YouTubeOptions> & YouTubeOptions;
4
- export declare function YouTubeEmbed(props: YouTubeEmbedProps): import("react").JSX.Element | null;
4
+ export declare function YouTubeEmbed(props: YouTubeEmbedProps): import("react").ReactNode;
5
5
  export type { YouTubeOptions };
@@ -1,43 +1,33 @@
1
1
  import { youtubePlan } from "../core/plans/youtube.js";
2
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";
3
+ import { usePlan } from "./use-plan.js";
4
+ import { frameOf } from "./iframe-embed.js";
7
5
  // src/components/youtube-embed.tsx
6
+ const YOUTUBE_OPTIONS = [
7
+ "autoplay",
8
+ "ccLangPref",
9
+ "ccLoadPolicy",
10
+ "color",
11
+ "controls",
12
+ "disablekb",
13
+ "enablejsapi",
14
+ "end",
15
+ "fs",
16
+ "hl",
17
+ "ivLoadPolicy",
18
+ "list",
19
+ "listType",
20
+ "loop",
21
+ "origin",
22
+ "playlist",
23
+ "playsinline",
24
+ "rel",
25
+ "start",
26
+ "widgetReferrer",
27
+ "nocookie"
28
+ ];
8
29
  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
- });
30
+ const [plan, frame] = usePlan(props, youtube, YOUTUBE_OPTIONS, youtubePlan);
31
+ return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
42
32
  }
43
33
  export { YouTubeEmbed };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "social-embeds",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Turn social media embed code or post URLs into working React components.",
5
5
  "keywords": [
6
6
  "react",