social-embeds 0.9.1 → 0.9.3
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 +3 -3
- package/dist/components/apple-embed.d.ts +2 -2
- package/dist/components/apple-embed.js +8 -30
- package/dist/components/bluesky-embed.d.ts +1 -1
- package/dist/components/bluesky-embed.js +6 -17
- package/dist/components/dailymotion-embed.d.ts +1 -1
- package/dist/components/dailymotion-embed.js +11 -21
- package/dist/components/facebook-embed.d.ts +1 -1
- package/dist/components/facebook-embed.js +14 -35
- package/dist/components/flickr-embed.d.ts +1 -1
- package/dist/components/flickr-embed.js +10 -21
- package/dist/components/giphy-embed.d.ts +1 -1
- package/dist/components/giphy-embed.js +5 -16
- package/dist/components/iframe-embed.js +15 -1
- package/dist/components/imgur-embed.d.ts +1 -1
- package/dist/components/imgur-embed.js +6 -17
- package/dist/components/instagram-embed.d.ts +1 -1
- package/dist/components/instagram-embed.js +6 -20
- package/dist/components/kick-embed.d.ts +1 -1
- package/dist/components/kick-embed.js +6 -19
- package/dist/components/linkedin-embed.d.ts +1 -1
- package/dist/components/linkedin-embed.js +6 -17
- package/dist/components/pinterest-embed.d.ts +1 -1
- package/dist/components/pinterest-embed.js +6 -20
- package/dist/components/reddit-embed.d.ts +1 -1
- package/dist/components/reddit-embed.js +13 -23
- package/dist/components/rumble-embed.d.ts +1 -1
- package/dist/components/rumble-embed.js +5 -16
- package/dist/components/script-embed.js +14 -1
- package/dist/components/snapchat-embed.d.ts +1 -1
- package/dist/components/snapchat-embed.js +5 -16
- package/dist/components/soundcloud-embed.d.ts +1 -1
- package/dist/components/soundcloud-embed.js +16 -27
- package/dist/components/spotify-embed.d.ts +1 -1
- package/dist/components/spotify-embed.js +6 -16
- package/dist/components/strava-embed.d.ts +1 -1
- package/dist/components/strava-embed.js +10 -20
- package/dist/components/streamable-embed.d.ts +1 -1
- package/dist/components/streamable-embed.js +12 -22
- package/dist/components/telegram-embed.d.ts +1 -1
- package/dist/components/telegram-embed.js +11 -21
- package/dist/components/tenor-embed.d.ts +1 -1
- package/dist/components/tenor-embed.js +5 -16
- package/dist/components/threads-embed.d.ts +1 -1
- package/dist/components/threads-embed.js +6 -20
- package/dist/components/tiktok-embed.d.ts +1 -1
- package/dist/components/tiktok-embed.js +21 -31
- package/dist/components/truthsocial-embed.d.ts +1 -1
- package/dist/components/truthsocial-embed.js +5 -16
- package/dist/components/tumblr-embed.d.ts +1 -1
- package/dist/components/tumblr-embed.js +5 -16
- package/dist/components/twitch-embed.d.ts +1 -1
- package/dist/components/twitch-embed.js +10 -20
- package/dist/components/use-plan.js +20 -0
- package/dist/components/vimeo-embed.d.ts +1 -1
- package/dist/components/vimeo-embed.js +25 -35
- package/dist/components/x-embed.d.ts +1 -1
- package/dist/components/x-embed.js +13 -27
- package/dist/components/youtube-embed.d.ts +1 -1
- package/dist/components/youtube-embed.js +28 -38
- package/dist/element.js +1 -1
- package/dist/parser/matchers/applemusic.js +33 -0
- package/dist/parser/matchers/applepodcasts.js +32 -0
- package/dist/parser/matchers/bluesky.js +41 -0
- package/dist/parser/matchers/dailymotion.js +47 -0
- package/dist/parser/matchers/facebook.js +118 -0
- package/dist/parser/matchers/flickr.js +100 -0
- package/dist/parser/matchers/giphy.js +38 -0
- package/dist/parser/matchers/imgur.js +76 -0
- package/dist/parser/matchers/instagram.js +43 -0
- package/dist/parser/matchers/kick.js +48 -0
- package/dist/parser/matchers/linkedin.js +31 -0
- package/dist/parser/matchers/pinterest.js +32 -0
- package/dist/parser/matchers/reddit.js +43 -0
- package/dist/parser/matchers/rumble.js +32 -0
- package/dist/parser/matchers/snapchat.js +60 -0
- package/dist/parser/matchers/soundcloud.js +87 -0
- package/dist/parser/matchers/spotify.js +39 -0
- package/dist/parser/matchers/strava.js +31 -0
- package/dist/parser/matchers/streamable.js +59 -0
- package/dist/parser/matchers/telegram.js +34 -0
- package/dist/parser/matchers/tenor.js +34 -0
- package/dist/parser/matchers/threads.js +36 -0
- package/dist/parser/matchers/tiktok.js +25 -0
- package/dist/parser/matchers/truthsocial.js +34 -0
- package/dist/parser/matchers/tumblr.js +51 -0
- package/dist/parser/matchers/twitch.js +90 -0
- package/dist/parser/matchers/vimeo.js +71 -0
- package/dist/parser/matchers/x.js +50 -0
- package/dist/parser/matchers/youtube.js +123 -0
- package/dist/parser/platform.d.ts +10 -4
- package/dist/parser/platforms/applemusic.js +4 -30
- package/dist/parser/platforms/applepodcasts.js +4 -29
- package/dist/parser/platforms/bluesky.js +4 -38
- package/dist/parser/platforms/dailymotion.js +4 -44
- package/dist/parser/platforms/facebook.js +5 -115
- package/dist/parser/platforms/flickr.js +5 -98
- package/dist/parser/platforms/giphy.js +4 -35
- package/dist/parser/platforms/imgur.js +4 -73
- package/dist/parser/platforms/instagram.js +4 -40
- package/dist/parser/platforms/kick.js +4 -45
- package/dist/parser/platforms/linkedin.js +4 -28
- package/dist/parser/platforms/pinterest.js +4 -29
- package/dist/parser/platforms/reddit.js +3 -40
- package/dist/parser/platforms/rumble.js +3 -29
- package/dist/parser/platforms/snapchat.js +3 -57
- package/dist/parser/platforms/soundcloud.js +4 -84
- package/dist/parser/platforms/spotify.js +4 -36
- package/dist/parser/platforms/strava.js +3 -28
- package/dist/parser/platforms/streamable.js +3 -56
- package/dist/parser/platforms/telegram.js +3 -31
- package/dist/parser/platforms/tenor.js +5 -32
- package/dist/parser/platforms/threads.js +4 -33
- package/dist/parser/platforms/tiktok.js +4 -22
- package/dist/parser/platforms/truthsocial.js +3 -31
- package/dist/parser/platforms/tumblr.js +3 -48
- package/dist/parser/platforms/twitch.js +4 -87
- package/dist/parser/platforms/vimeo.js +4 -68
- package/dist/parser/platforms/x.js +6 -46
- package/dist/parser/platforms/youtube.js +5 -120
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ Before 0.7.0, iframe code that no platform claimed reached `fallback`. It now re
|
|
|
83
83
|
|
|
84
84
|
#### Only the platforms you use
|
|
85
85
|
|
|
86
|
-
`<SocialEmbed>` recognises every platform, so it adds about
|
|
86
|
+
`<SocialEmbed>` recognises every platform, so it adds about 27 KB gzipped to an app. `createSocialEmbed` makes one that recognises only the platforms you list, and a bundler leaves the others out:
|
|
87
87
|
|
|
88
88
|
```tsx
|
|
89
89
|
// app/social-embed.tsx
|
|
@@ -111,7 +111,7 @@ export const SocialEmbed = createSocialEmbed([
|
|
|
111
111
|
| `youtube`, `x` | 9 KB |
|
|
112
112
|
| `youtube`, `x`, `instagram`, `facebook`, `tiktok` | 12 KB |
|
|
113
113
|
| the same five and `genericIframe` | 14 KB |
|
|
114
|
-
| every platform (`<SocialEmbed>`) |
|
|
114
|
+
| every platform (`<SocialEmbed>`) | 27 KB |
|
|
115
115
|
|
|
116
116
|
- **Names:** each platform is exported under its id, as in `embed.platform`: `x`, `instagram`, `threads`, `facebook`, `tiktok`, `youtube`, `telegram`, `snapchat`, `linkedin`, `reddit`, `pinterest`, `spotify`, `vimeo`, `twitch`, `dailymotion`, `bluesky`, `soundcloud`, `applemusic`, `applepodcasts`, `tumblr`, `kick`, `giphy`, `truthsocial`, `imgur`, `tenor`, `streamable`, `strava`, `flickr` and `rumble`. `genericIframe` adds [generic iframe embeds](#generic-iframe-embeds). The order of the list does not matter.
|
|
117
117
|
- **The same component:** it takes the same props and renders exactly what `<SocialEmbed>` renders for the platforms it knows. Embed code of another platform goes to `fallback`, or to `onError` as `social-embeds: unrecognised embed code`; a URL of another platform is reported as `social-embeds: not a supported post URL: …`. A frame that a named platform serves never renders as a generic iframe, even when that platform is not in the list.
|
|
@@ -121,7 +121,7 @@ export const SocialEmbed = createSocialEmbed([
|
|
|
121
121
|
|
|
122
122
|
Each platform component takes a `url`, or an `embed` already parsed by [`social-embeds/parser`](#parser), plus the shared props and its own option props. Option props override options from the embed code.
|
|
123
123
|
|
|
124
|
-
A platform component bundles only its own platform's parser: one component adds about 3
|
|
124
|
+
A platform component bundles only its own platform's parser: one component adds about 3 to 5 KB gzipped to an app (`FacebookEmbed` about 7 KB), against about 27 KB for `<SocialEmbed>`, which recognises every platform. A URL of another platform is reported as `social-embeds: not a {Platform} post URL: …`, and an `embed` of another platform as `social-embeds: expected a {Platform} embed, got {id}`.
|
|
125
125
|
|
|
126
126
|
```tsx
|
|
127
127
|
import {
|
|
@@ -2,6 +2,6 @@ import { EmbedSource, FrameProps } from "./shared.js";
|
|
|
2
2
|
export type AppleMusicEmbedProps = EmbedSource & FrameProps;
|
|
3
3
|
export type ApplePodcastsEmbedProps = EmbedSource & FrameProps;
|
|
4
4
|
/** A fixed height: the `height` prop, else the embed code's, else 175px for a song and 450px for the rest. */
|
|
5
|
-
export declare function AppleMusicEmbed(props: AppleMusicEmbedProps): import("react").
|
|
5
|
+
export declare function AppleMusicEmbed(props: AppleMusicEmbedProps): import("react").ReactNode;
|
|
6
6
|
/** A fixed height: the `height` prop, else the embed code's, else 160px for an episode and 450px for a show. */
|
|
7
|
-
export declare function ApplePodcastsEmbed(props: ApplePodcastsEmbedProps): import("react").
|
|
7
|
+
export declare function ApplePodcastsEmbed(props: ApplePodcastsEmbedProps): import("react").ReactNode;
|
|
@@ -1,39 +1,17 @@
|
|
|
1
1
|
import { appleMusicPlan, applePodcastsPlan } from "../core/plans/apple.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { applemusicMatcher } from "../parser/matchers/applemusic.js";
|
|
3
|
+
import { applepodcastsMatcher } from "../parser/matchers/applepodcasts.js";
|
|
4
|
+
import { usePlan } from "./use-plan.js";
|
|
5
|
+
import { frameOf } from "./iframe-embed.js";
|
|
8
6
|
// src/components/apple-embed.tsx
|
|
9
7
|
/** A fixed height: the `height` prop, else the embed code's, else 175px for a song and 450px for the rest. */
|
|
10
8
|
function AppleMusicEmbed(props) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const plan = embed ? appleMusicPlan(embed) : void 0;
|
|
14
|
-
useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
|
|
15
|
-
if (plan?.kind !== "iframe") return null;
|
|
16
|
-
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
17
|
-
...frame,
|
|
18
|
-
...planProps(plan),
|
|
19
|
-
onError,
|
|
20
|
-
maxWidth: maxWidth ?? plan.maxWidth,
|
|
21
|
-
height: height ?? plan.height
|
|
22
|
-
});
|
|
9
|
+
const [plan, frame] = usePlan(props, applemusicMatcher, [], appleMusicPlan);
|
|
10
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
23
11
|
}
|
|
24
12
|
/** A fixed height: the `height` prop, else the embed code's, else 160px for an episode and 450px for a show. */
|
|
25
13
|
function ApplePodcastsEmbed(props) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const plan = embed ? applePodcastsPlan(embed) : void 0;
|
|
29
|
-
useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
|
|
30
|
-
if (plan?.kind !== "iframe") return null;
|
|
31
|
-
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
32
|
-
...frame,
|
|
33
|
-
...planProps(plan),
|
|
34
|
-
onError,
|
|
35
|
-
maxWidth: maxWidth ?? plan.maxWidth,
|
|
36
|
-
height: height ?? plan.height
|
|
37
|
-
});
|
|
14
|
+
const [plan, frame] = usePlan(props, applepodcastsMatcher, [], applePodcastsPlan);
|
|
15
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
38
16
|
}
|
|
39
17
|
export { AppleMusicEmbed, ApplePodcastsEmbed };
|
|
@@ -6,5 +6,5 @@ export type BlueskyEmbedProps = EmbedSource & Omit<SharedProps, keyof BlueskyOpt
|
|
|
6
6
|
* create, without the script (docs/decisions.md D77). Only embed code and URLs with a DID
|
|
7
7
|
* render: a handle URL needs a lookup, and `onError` says so.
|
|
8
8
|
*/
|
|
9
|
-
export declare function BlueskyEmbed(props: BlueskyEmbedProps): import("react").
|
|
9
|
+
export declare function BlueskyEmbed(props: BlueskyEmbedProps): import("react").ReactNode;
|
|
10
10
|
export type { BlueskyOptions };
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
import { blueskyPlan } from "../core/plans/bluesky.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { blueskyMatcher } from "../parser/matchers/bluesky.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { fallbackPlaceholder, frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/bluesky-embed.tsx
|
|
6
|
+
const BLUESKY_OPTIONS = ["colorMode"];
|
|
8
7
|
/**
|
|
9
8
|
* At most 600px wide by default, Bluesky's oEmbed width. Renders the frame `embed.js` would
|
|
10
9
|
* create, without the script (docs/decisions.md D77). Only embed code and URLs with a DID
|
|
11
10
|
* render: a handle URL needs a lookup, and `onError` says so.
|
|
12
11
|
*/
|
|
13
12
|
function BlueskyEmbed(props) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const plan = embed ? blueskyPlan(embed, { colorMode }) : 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
|
-
placeholder: placeholder ?? fallbackPlaceholder(plan)
|
|
25
|
-
});
|
|
13
|
+
const [plan, frame] = usePlan(props, blueskyMatcher, BLUESKY_OPTIONS, blueskyPlan);
|
|
14
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame, fallbackPlaceholder) : null;
|
|
26
15
|
}
|
|
27
16
|
export { BlueskyEmbed };
|
|
@@ -5,5 +5,5 @@ export type DailymotionEmbedProps = EmbedSource & Omit<FrameProps, keyof Dailymo
|
|
|
5
5
|
* Dailymotion refuses embeds without a Player ID: one from the embed code or the `playerId`
|
|
6
6
|
* prop, never another account's (docs/decisions.md D63).
|
|
7
7
|
*/
|
|
8
|
-
export declare function DailymotionEmbed(props: DailymotionEmbedProps): import("react").
|
|
8
|
+
export declare function DailymotionEmbed(props: DailymotionEmbedProps): import("react").ReactNode;
|
|
9
9
|
export type { DailymotionOptions };
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dailymotionMatcher } from "../parser/matchers/dailymotion.js";
|
|
2
2
|
import { dailymotionPlan } from "../core/plans/dailymotion.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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/dailymotion-embed.tsx
|
|
6
|
+
const DAILYMOTION_OPTIONS = [
|
|
7
|
+
"playerId",
|
|
8
|
+
"mute",
|
|
9
|
+
"startTime",
|
|
10
|
+
"loop"
|
|
11
|
+
];
|
|
8
12
|
/**
|
|
9
13
|
* Dailymotion refuses embeds without a Player ID: one from the embed code or the `playerId`
|
|
10
14
|
* prop, never another account's (docs/decisions.md D63).
|
|
11
15
|
*/
|
|
12
16
|
function DailymotionEmbed(props) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const plan = embed ? dailymotionPlan(embed, {
|
|
16
|
-
playerId,
|
|
17
|
-
mute,
|
|
18
|
-
startTime,
|
|
19
|
-
loop
|
|
20
|
-
}) : void 0;
|
|
21
|
-
useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
|
|
22
|
-
if (plan?.kind !== "iframe") return null;
|
|
23
|
-
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
24
|
-
...frame,
|
|
25
|
-
...planProps(plan),
|
|
26
|
-
onError,
|
|
27
|
-
maxWidth: maxWidth ?? plan.maxWidth
|
|
28
|
-
});
|
|
17
|
+
const [plan, frame] = usePlan(props, dailymotionMatcher, DAILYMOTION_OPTIONS, dailymotionPlan);
|
|
18
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
29
19
|
}
|
|
30
20
|
export { DailymotionEmbed };
|
|
@@ -2,5 +2,5 @@ import { FacebookOptions } from "../core/plans/facebook.js";
|
|
|
2
2
|
import { EmbedSource, FrameProps } from "./shared.js";
|
|
3
3
|
/** `height` and `maxHeight` apply only to a video that renders as an iframe. */
|
|
4
4
|
export type FacebookEmbedProps = EmbedSource & Omit<FrameProps, keyof FacebookOptions> & FacebookOptions;
|
|
5
|
-
export declare function FacebookEmbed(props: FacebookEmbedProps): import("react").
|
|
5
|
+
export declare function FacebookEmbed(props: FacebookEmbedProps): import("react").ReactNode;
|
|
6
6
|
export type { FacebookOptions };
|
|
@@ -1,40 +1,19 @@
|
|
|
1
1
|
import { facebookPlan } from "../core/plans/facebook.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { facebookMatcher } from "../parser/matchers/facebook.js";
|
|
3
|
+
import { frameOf } from "./iframe-embed.js";
|
|
4
|
+
import { scriptOf } from "./script-embed.js";
|
|
5
|
+
import { usePlan } from "./use-plan.js";
|
|
8
6
|
// src/components/facebook-embed.tsx
|
|
7
|
+
const FACEBOOK_OPTIONS = [
|
|
8
|
+
"locale",
|
|
9
|
+
"showText",
|
|
10
|
+
"allowfullscreen",
|
|
11
|
+
"autoplay",
|
|
12
|
+
"showCaptions"
|
|
13
|
+
];
|
|
9
14
|
function FacebookEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
locale,
|
|
14
|
-
showText,
|
|
15
|
-
allowfullscreen,
|
|
16
|
-
autoplay,
|
|
17
|
-
showCaptions
|
|
18
|
-
}) : void 0;
|
|
19
|
-
useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
|
|
20
|
-
if (plan?.kind === "iframe") return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
21
|
-
...shared,
|
|
22
|
-
...planProps(plan),
|
|
23
|
-
onError,
|
|
24
|
-
maxWidth: maxWidth ?? plan.maxWidth,
|
|
25
|
-
height,
|
|
26
|
-
maxHeight
|
|
27
|
-
});
|
|
28
|
-
if (plan?.kind !== "script") return null;
|
|
29
|
-
return /* @__PURE__ */ jsx(ScriptEmbed, {
|
|
30
|
-
...shared,
|
|
31
|
-
onError,
|
|
32
|
-
maxWidth: maxWidth ?? plan.maxWidth,
|
|
33
|
-
driver: plan.driver,
|
|
34
|
-
markup: plan.markup,
|
|
35
|
-
hasFallback: plan.hasFallback,
|
|
36
|
-
minHeight: plan.minHeight,
|
|
37
|
-
label: plan.label
|
|
38
|
-
}, plan.key);
|
|
15
|
+
const [plan, frame] = usePlan(props, facebookMatcher, FACEBOOK_OPTIONS, facebookPlan);
|
|
16
|
+
if (plan?.kind === "iframe") return frameOf(plan, frame);
|
|
17
|
+
return plan?.kind === "script" ? scriptOf(plan, frame) : null;
|
|
39
18
|
}
|
|
40
19
|
export { FacebookEmbed };
|
|
@@ -2,5 +2,5 @@ import { FlickrOptions } from "../core/plans/flickr.js";
|
|
|
2
2
|
import { EmbedSource, FrameProps } from "./shared.js";
|
|
3
3
|
export type FlickrEmbedProps = EmbedSource & Omit<FrameProps, keyof FlickrOptions> & FlickrOptions;
|
|
4
4
|
/** Embed code keeps its image's ratio and is at most as wide as the image; a URL renders at 4:3 (docs/decisions.md D98). */
|
|
5
|
-
export declare function FlickrEmbed(props: FlickrEmbedProps): import("react").
|
|
5
|
+
export declare function FlickrEmbed(props: FlickrEmbedProps): import("react").ReactNode;
|
|
6
6
|
export type { FlickrOptions };
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
import { flickrPlan } from "../core/plans/flickr.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { flickrMatcher } from "../parser/matchers/flickr.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { fallbackPlaceholder, frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/flickr-embed.tsx
|
|
6
|
+
const FLICKR_OPTIONS = [
|
|
7
|
+
"header",
|
|
8
|
+
"footer",
|
|
9
|
+
"context"
|
|
10
|
+
];
|
|
8
11
|
/** Embed code keeps its image's ratio and is at most as wide as the image; a URL renders at 4:3 (docs/decisions.md D98). */
|
|
9
12
|
function FlickrEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const plan = embed ? flickrPlan(embed, {
|
|
13
|
-
header,
|
|
14
|
-
footer,
|
|
15
|
-
context
|
|
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
|
-
placeholder: placeholder ?? fallbackPlaceholder(plan)
|
|
25
|
-
});
|
|
13
|
+
const [plan, frame] = usePlan(props, flickrMatcher, FLICKR_OPTIONS, flickrPlan);
|
|
14
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame, fallbackPlaceholder) : null;
|
|
26
15
|
}
|
|
27
16
|
export { FlickrEmbed };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { EmbedSource, FrameProps } from "./shared.js";
|
|
2
2
|
export type GiphyEmbedProps = EmbedSource & FrameProps;
|
|
3
3
|
/** The embed code's aspect ratio; a URL carries no size and renders square (docs/decisions.md D76). */
|
|
4
|
-
export declare function GiphyEmbed(props: GiphyEmbedProps): import("react").
|
|
4
|
+
export declare function GiphyEmbed(props: GiphyEmbedProps): import("react").ReactNode;
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { giphyPlan } from "../core/plans/giphy.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { giphyMatcher } from "../parser/matchers/giphy.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/giphy-embed.tsx
|
|
8
6
|
/** The embed code's aspect ratio; a URL carries no size and renders square (docs/decisions.md D76). */
|
|
9
7
|
function GiphyEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const plan = embed ? giphyPlan(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
|
-
});
|
|
8
|
+
const [plan, frame] = usePlan(props, giphyMatcher, [], giphyPlan);
|
|
9
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
21
10
|
}
|
|
22
11
|
export { GiphyEmbed };
|
|
@@ -18,6 +18,20 @@ function fallbackPlaceholder(plan) {
|
|
|
18
18
|
dangerouslySetInnerHTML: { __html: fallbackHtml }
|
|
19
19
|
}) : /* @__PURE__ */ jsx("blockquote", { dangerouslySetInnerHTML: { __html: fallbackHtml } });
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* A platform component's frame: the host's `maxWidth` and `height` win over the plan's.
|
|
23
|
+
* Platforms with fallback content pass `fallbackPlaceholder`, which the others never bundle.
|
|
24
|
+
*/
|
|
25
|
+
function frameOf(plan, props, fallback) {
|
|
26
|
+
const { maxWidth, height, placeholder, ...rest } = props;
|
|
27
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
28
|
+
...rest,
|
|
29
|
+
...planProps(plan),
|
|
30
|
+
maxWidth: maxWidth ?? plan.maxWidth,
|
|
31
|
+
height: height ?? plan.height,
|
|
32
|
+
placeholder: placeholder ?? fallback?.(plan)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
21
35
|
const FILL = {
|
|
22
36
|
position: "absolute",
|
|
23
37
|
inset: 0
|
|
@@ -150,4 +164,4 @@ function Skeleton({ minHeight }) {
|
|
|
150
164
|
}
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
|
-
export { IframeEmbed, Skeleton, fallbackPlaceholder, planProps };
|
|
167
|
+
export { IframeEmbed, Skeleton, fallbackPlaceholder, frameOf, planProps };
|
|
@@ -2,5 +2,5 @@ import { ImgurOptions } from "../core/plans/imgur.js";
|
|
|
2
2
|
import { EmbedSource, SharedProps } from "./shared.js";
|
|
3
3
|
export type ImgurEmbedProps = EmbedSource & Omit<SharedProps, keyof ImgurOptions> & ImgurOptions;
|
|
4
4
|
/** At most 540px wide by default, the widest `embed.js` makes the frame (docs/decisions.md D94). */
|
|
5
|
-
export declare function ImgurEmbed(props: ImgurEmbedProps): import("react").
|
|
5
|
+
export declare function ImgurEmbed(props: ImgurEmbedProps): import("react").ReactNode;
|
|
6
6
|
export type { ImgurOptions };
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { imgurPlan } from "../core/plans/imgur.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { imgurMatcher } from "../parser/matchers/imgur.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { fallbackPlaceholder, frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/imgur-embed.tsx
|
|
6
|
+
const IMGUR_OPTIONS = ["context"];
|
|
8
7
|
/** At most 540px wide by default, the widest `embed.js` makes the frame (docs/decisions.md D94). */
|
|
9
8
|
function ImgurEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const plan = embed ? imgurPlan(embed, { context }) : 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
|
-
placeholder: placeholder ?? fallbackPlaceholder(plan)
|
|
21
|
-
});
|
|
9
|
+
const [plan, frame] = usePlan(props, imgurMatcher, IMGUR_OPTIONS, imgurPlan);
|
|
10
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame, fallbackPlaceholder) : null;
|
|
22
11
|
}
|
|
23
12
|
export { ImgurEmbed };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstagramOptions } from "../core/plans/instagram.js";
|
|
2
2
|
import { EmbedSource, SharedProps } from "./shared.js";
|
|
3
3
|
export type InstagramEmbedProps = EmbedSource & Omit<SharedProps, keyof InstagramOptions> & InstagramOptions;
|
|
4
|
-
export declare function InstagramEmbed(props: InstagramEmbedProps): import("react").
|
|
4
|
+
export declare function InstagramEmbed(props: InstagramEmbedProps): import("react").ReactNode;
|
|
5
5
|
export type { InstagramOptions };
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { instagramPlan } from "../core/plans/instagram.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { instagramMatcher } from "../parser/matchers/instagram.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { scriptOf } from "./script-embed.js";
|
|
7
5
|
// src/components/instagram-embed.tsx
|
|
6
|
+
const INSTAGRAM_OPTIONS = ["captioned"];
|
|
8
7
|
function InstagramEmbed(props) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const plan = embed ? instagramPlan(embed, { captioned }) : 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);
|
|
8
|
+
const [plan, frame] = usePlan(props, instagramMatcher, INSTAGRAM_OPTIONS, instagramPlan);
|
|
9
|
+
return plan?.kind === "script" ? scriptOf(plan, frame) : null;
|
|
24
10
|
}
|
|
25
11
|
export { InstagramEmbed };
|
|
@@ -2,5 +2,5 @@ import { KickOptions } from "../core/plans/kick.js";
|
|
|
2
2
|
import { EmbedSource, FrameProps } from "./shared.js";
|
|
3
3
|
export type KickEmbedProps = EmbedSource & Omit<FrameProps, keyof KickOptions> & KickOptions;
|
|
4
4
|
/** A live channel at 16:9. */
|
|
5
|
-
export declare function KickEmbed(props: KickEmbedProps): import("react").
|
|
5
|
+
export declare function KickEmbed(props: KickEmbedProps): import("react").ReactNode;
|
|
6
6
|
export type { KickOptions };
|
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import { kickPlan } from "../core/plans/kick.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { kickMatcher } from "../parser/matchers/kick.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/kick-embed.tsx
|
|
6
|
+
const KICK_OPTIONS = ["autoplay", "muted"];
|
|
8
7
|
/** A live channel at 16:9. */
|
|
9
8
|
function KickEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const plan = embed ? kickPlan(embed, {
|
|
13
|
-
autoplay,
|
|
14
|
-
muted
|
|
15
|
-
}) : 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
|
-
maxWidth: maxWidth ?? plan.maxWidth
|
|
23
|
-
});
|
|
9
|
+
const [plan, frame] = usePlan(props, kickMatcher, KICK_OPTIONS, kickPlan);
|
|
10
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
24
11
|
}
|
|
25
12
|
export { KickEmbed };
|
|
@@ -2,5 +2,5 @@ import { LinkedInOptions } from "../core/plans/linkedin.js";
|
|
|
2
2
|
import { EmbedSource, FrameProps } from "./shared.js";
|
|
3
3
|
export type LinkedInEmbedProps = EmbedSource & Omit<FrameProps, keyof LinkedInOptions> & LinkedInOptions;
|
|
4
4
|
/** A fixed height: the `height` prop, else the embed code's, else 670px. */
|
|
5
|
-
export declare function LinkedInEmbed(props: LinkedInEmbedProps): import("react").
|
|
5
|
+
export declare function LinkedInEmbed(props: LinkedInEmbedProps): import("react").ReactNode;
|
|
6
6
|
export type { LinkedInOptions };
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import { linkedinPlan } from "../core/plans/linkedin.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { linkedinMatcher } from "../parser/matchers/linkedin.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/linkedin-embed.tsx
|
|
6
|
+
const LINKEDIN_OPTIONS = ["collapsed"];
|
|
8
7
|
/** A fixed height: the `height` prop, else the embed code's, else 670px. */
|
|
9
8
|
function LinkedInEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const plan = embed ? linkedinPlan(embed, { collapsed }) : 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
|
-
height: height ?? plan.height
|
|
21
|
-
});
|
|
9
|
+
const [plan, frame] = usePlan(props, linkedinMatcher, LINKEDIN_OPTIONS, linkedinPlan);
|
|
10
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
22
11
|
}
|
|
23
12
|
export { LinkedInEmbed };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PinterestOptions } from "../core/plans/pinterest.js";
|
|
2
2
|
import { EmbedSource, SharedProps } from "./shared.js";
|
|
3
3
|
export type PinterestEmbedProps = EmbedSource & Omit<SharedProps, keyof PinterestOptions> & PinterestOptions;
|
|
4
|
-
export declare function PinterestEmbed(props: PinterestEmbedProps): import("react").
|
|
4
|
+
export declare function PinterestEmbed(props: PinterestEmbedProps): import("react").ReactNode;
|
|
5
5
|
export type { PinterestOptions };
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { pinterestPlan } from "../core/plans/pinterest.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { pinterestMatcher } from "../parser/matchers/pinterest.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { scriptOf } from "./script-embed.js";
|
|
7
5
|
// src/components/pinterest-embed.tsx
|
|
6
|
+
const PINTEREST_OPTIONS = ["pinWidth"];
|
|
8
7
|
function PinterestEmbed(props) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const plan = embed ? pinterestPlan(embed, { pinWidth }) : 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);
|
|
8
|
+
const [plan, frame] = usePlan(props, pinterestMatcher, PINTEREST_OPTIONS, pinterestPlan);
|
|
9
|
+
return plan?.kind === "script" ? scriptOf(plan, frame) : null;
|
|
24
10
|
}
|
|
25
11
|
export { PinterestEmbed };
|
|
@@ -2,5 +2,5 @@ import { RedditOptions } from "../core/plans/reddit.js";
|
|
|
2
2
|
import { EmbedSource, SharedProps } from "./shared.js";
|
|
3
3
|
export type RedditEmbedProps = EmbedSource & Omit<SharedProps, keyof RedditOptions> & RedditOptions;
|
|
4
4
|
/** At most 640px wide by default, the width widgets.js gives the frame (docs/decisions.md D52). */
|
|
5
|
-
export declare function RedditEmbed(props: RedditEmbedProps): import("react").
|
|
5
|
+
export declare function RedditEmbed(props: RedditEmbedProps): import("react").ReactNode;
|
|
6
6
|
export type { RedditOptions };
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import { redditPlan } from "../core/plans/reddit.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { resolveEmbed } from "../core/resolve.js";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { redditMatcher } from "../parser/matchers/reddit.js";
|
|
3
|
+
import { usePlan } from "./use-plan.js";
|
|
4
|
+
import { frameOf } from "./iframe-embed.js";
|
|
7
5
|
// src/components/reddit-embed.tsx
|
|
6
|
+
const REDDIT_OPTIONS = [
|
|
7
|
+
"theme",
|
|
8
|
+
"showMedia",
|
|
9
|
+
"showTitle",
|
|
10
|
+
"showUsername",
|
|
11
|
+
"locale",
|
|
12
|
+
"depth"
|
|
13
|
+
];
|
|
8
14
|
/** At most 640px wide by default, the width widgets.js gives the frame (docs/decisions.md D52). */
|
|
9
15
|
function RedditEmbed(props) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const plan = embed ? redditPlan(embed, {
|
|
13
|
-
theme,
|
|
14
|
-
showMedia,
|
|
15
|
-
showTitle,
|
|
16
|
-
showUsername,
|
|
17
|
-
locale,
|
|
18
|
-
depth
|
|
19
|
-
}) : void 0;
|
|
20
|
-
useReportError(error ?? (plan?.kind === "error" ? plan.message : void 0), onError);
|
|
21
|
-
if (plan?.kind !== "iframe") return null;
|
|
22
|
-
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
23
|
-
...shared,
|
|
24
|
-
...planProps(plan),
|
|
25
|
-
onError,
|
|
26
|
-
maxWidth: maxWidth ?? plan.maxWidth
|
|
27
|
-
});
|
|
16
|
+
const [plan, frame] = usePlan(props, redditMatcher, REDDIT_OPTIONS, redditPlan);
|
|
17
|
+
return plan?.kind === "iframe" ? frameOf(plan, frame) : null;
|
|
28
18
|
}
|
|
29
19
|
export { RedditEmbed };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { EmbedSource, FrameProps } from "./shared.js";
|
|
2
2
|
export type RumbleEmbedProps = EmbedSource & FrameProps;
|
|
3
3
|
/** Embed code only: a page URL holds another id than the player (docs/decisions.md D99). */
|
|
4
|
-
export declare function RumbleEmbed(props: RumbleEmbedProps): import("react").
|
|
4
|
+
export declare function RumbleEmbed(props: RumbleEmbedProps): import("react").ReactNode;
|