social-embeds 0.8.1 → 0.9.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.
- package/README.md +36 -0
- package/dist/components/platforms.d.ts +32 -0
- package/dist/components/platforms.js +384 -0
- package/dist/components/social-embed.d.ts +31 -4
- package/dist/components/social-embed.js +48 -211
- package/dist/element.js +1 -1
- package/dist/index.d.ts +21 -20
- package/dist/index.js +3 -2
- package/dist/parser/html.d.ts +19 -0
- package/dist/parser/match-url.js +6 -2
- package/dist/parser/parse-embed.js +12 -8
- package/dist/parser/platform.d.ts +26 -0
- package/dist/parser/url.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,6 +81,42 @@ An unsupported URL never reaches `fallback`: nothing is rendered and `onError` n
|
|
|
81
81
|
|
|
82
82
|
Before 0.7.0, iframe code that no platform claimed reached `fallback`. It now renders as a generic iframe. Non-iframe code, and iframes that are rejected, still reach `fallback`.
|
|
83
83
|
|
|
84
|
+
#### Only the platforms you use
|
|
85
|
+
|
|
86
|
+
`<SocialEmbed>` recognises every platform, so it adds about 28 KB gzipped to an app. `createSocialEmbed` makes one that recognises only the platforms you list, and a bundler leaves the others out:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
// app/social-embed.tsx
|
|
90
|
+
'use client';
|
|
91
|
+
|
|
92
|
+
import {
|
|
93
|
+
createSocialEmbed,
|
|
94
|
+
genericIframe,
|
|
95
|
+
instagram,
|
|
96
|
+
x,
|
|
97
|
+
youtube,
|
|
98
|
+
} from 'social-embeds';
|
|
99
|
+
|
|
100
|
+
export const SocialEmbed = createSocialEmbed([
|
|
101
|
+
youtube,
|
|
102
|
+
x,
|
|
103
|
+
instagram,
|
|
104
|
+
genericIframe,
|
|
105
|
+
]);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| Platforms | Gzipped |
|
|
109
|
+
| ------------------------------------------------- | ------- |
|
|
110
|
+
| `youtube` | 7 KB |
|
|
111
|
+
| `youtube`, `x` | 10 KB |
|
|
112
|
+
| `youtube`, `x`, `instagram`, `facebook`, `tiktok` | 13 KB |
|
|
113
|
+
| the same five and `genericIframe` | 15 KB |
|
|
114
|
+
| every platform (`<SocialEmbed>`) | 28 KB |
|
|
115
|
+
|
|
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
|
+
- **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.
|
|
118
|
+
- **A client module:** call `createSocialEmbed` once, at the top of a module with `'use client'`, and import the component from there. In the Next.js App Router a Server Component cannot call it, because it comes from a client module; it can render the component it returns.
|
|
119
|
+
|
|
84
120
|
### Platform components
|
|
85
121
|
|
|
86
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.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EmbedPlatform } from "./social-embed.js";
|
|
2
|
+
export declare const x: EmbedPlatform;
|
|
3
|
+
export declare const instagram: EmbedPlatform;
|
|
4
|
+
export declare const facebook: EmbedPlatform;
|
|
5
|
+
export declare const threads: EmbedPlatform;
|
|
6
|
+
export declare const tiktok: EmbedPlatform;
|
|
7
|
+
export declare const youtube: EmbedPlatform;
|
|
8
|
+
export declare const telegram: EmbedPlatform;
|
|
9
|
+
export declare const snapchat: EmbedPlatform;
|
|
10
|
+
export declare const linkedin: EmbedPlatform;
|
|
11
|
+
export declare const reddit: EmbedPlatform;
|
|
12
|
+
export declare const pinterest: EmbedPlatform;
|
|
13
|
+
export declare const spotify: EmbedPlatform;
|
|
14
|
+
export declare const vimeo: EmbedPlatform;
|
|
15
|
+
export declare const twitch: EmbedPlatform;
|
|
16
|
+
export declare const dailymotion: EmbedPlatform;
|
|
17
|
+
export declare const soundcloud: EmbedPlatform;
|
|
18
|
+
export declare const applemusic: EmbedPlatform;
|
|
19
|
+
export declare const applepodcasts: EmbedPlatform;
|
|
20
|
+
export declare const kick: EmbedPlatform;
|
|
21
|
+
export declare const giphy: EmbedPlatform;
|
|
22
|
+
export declare const tenor: EmbedPlatform;
|
|
23
|
+
export declare const streamable: EmbedPlatform;
|
|
24
|
+
export declare const rumble: EmbedPlatform;
|
|
25
|
+
export declare const truthsocial: EmbedPlatform;
|
|
26
|
+
export declare const imgur: EmbedPlatform;
|
|
27
|
+
export declare const strava: EmbedPlatform;
|
|
28
|
+
export declare const flickr: EmbedPlatform;
|
|
29
|
+
export declare const bluesky: EmbedPlatform;
|
|
30
|
+
export declare const tumblr: EmbedPlatform;
|
|
31
|
+
/** Iframe embed code that no listed platform recognises, checked as `GenericIframeEmbed` does. */
|
|
32
|
+
export declare const genericIframe: EmbedPlatform;
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { parseIframe } from "../parser/iframe.js";
|
|
2
|
+
import { applemusic as applemusic$1 } from "../parser/platforms/applemusic.js";
|
|
3
|
+
import { applepodcasts as applepodcasts$1 } from "../parser/platforms/applepodcasts.js";
|
|
4
|
+
import { bluesky as bluesky$1 } from "../parser/platforms/bluesky.js";
|
|
5
|
+
import { dailymotion as dailymotion$1 } from "../parser/platforms/dailymotion.js";
|
|
6
|
+
import { facebook as facebook$1 } from "../parser/platforms/facebook.js";
|
|
7
|
+
import { flickr as flickr$1 } from "../parser/platforms/flickr.js";
|
|
8
|
+
import { giphy as giphy$1 } from "../parser/platforms/giphy.js";
|
|
9
|
+
import { imgur as imgur$1 } from "../parser/platforms/imgur.js";
|
|
10
|
+
import { instagram as instagram$1 } from "../parser/platforms/instagram.js";
|
|
11
|
+
import { kick as kick$1 } from "../parser/platforms/kick.js";
|
|
12
|
+
import { linkedin as linkedin$1 } from "../parser/platforms/linkedin.js";
|
|
13
|
+
import { pinterest as pinterest$1 } from "../parser/platforms/pinterest.js";
|
|
14
|
+
import { reddit as reddit$1 } from "../parser/platforms/reddit.js";
|
|
15
|
+
import { rumble as rumble$1 } from "../parser/platforms/rumble.js";
|
|
16
|
+
import { snapchat as snapchat$1 } from "../parser/platforms/snapchat.js";
|
|
17
|
+
import { soundcloud as soundcloud$1 } from "../parser/platforms/soundcloud.js";
|
|
18
|
+
import { spotify as spotify$1 } from "../parser/platforms/spotify.js";
|
|
19
|
+
import { strava as strava$1 } from "../parser/platforms/strava.js";
|
|
20
|
+
import { streamable as streamable$1 } from "../parser/platforms/streamable.js";
|
|
21
|
+
import { telegram as telegram$1 } from "../parser/platforms/telegram.js";
|
|
22
|
+
import { tenor as tenor$1 } from "../parser/platforms/tenor.js";
|
|
23
|
+
import { threads as threads$1 } from "../parser/platforms/threads.js";
|
|
24
|
+
import { tiktok as tiktok$1 } from "../parser/platforms/tiktok.js";
|
|
25
|
+
import { truthsocial as truthsocial$1 } from "../parser/platforms/truthsocial.js";
|
|
26
|
+
import { tumblr as tumblr$1 } from "../parser/platforms/tumblr.js";
|
|
27
|
+
import { twitch as twitch$1 } from "../parser/platforms/twitch.js";
|
|
28
|
+
import { vimeo as vimeo$1 } from "../parser/platforms/vimeo.js";
|
|
29
|
+
import { x as x$1 } from "../parser/platforms/x.js";
|
|
30
|
+
import { youtube as youtube$1 } from "../parser/platforms/youtube.js";
|
|
31
|
+
import { AppleMusicEmbed, ApplePodcastsEmbed } from "./apple-embed.js";
|
|
32
|
+
import { BlueskyEmbed } from "./bluesky-embed.js";
|
|
33
|
+
import { DailymotionEmbed } from "./dailymotion-embed.js";
|
|
34
|
+
import { FacebookEmbed } from "./facebook-embed.js";
|
|
35
|
+
import { FlickrEmbed } from "./flickr-embed.js";
|
|
36
|
+
import { GiphyEmbed } from "./giphy-embed.js";
|
|
37
|
+
import { ImgurEmbed } from "./imgur-embed.js";
|
|
38
|
+
import { InstagramEmbed } from "./instagram-embed.js";
|
|
39
|
+
import { KickEmbed } from "./kick-embed.js";
|
|
40
|
+
import { LinkedInEmbed } from "./linkedin-embed.js";
|
|
41
|
+
import { PinterestEmbed } from "./pinterest-embed.js";
|
|
42
|
+
import { RedditEmbed } from "./reddit-embed.js";
|
|
43
|
+
import { RumbleEmbed } from "./rumble-embed.js";
|
|
44
|
+
import { SnapchatEmbed } from "./snapchat-embed.js";
|
|
45
|
+
import { SoundCloudEmbed } from "./soundcloud-embed.js";
|
|
46
|
+
import { SpotifyEmbed } from "./spotify-embed.js";
|
|
47
|
+
import { StravaEmbed } from "./strava-embed.js";
|
|
48
|
+
import { StreamableEmbed } from "./streamable-embed.js";
|
|
49
|
+
import { TelegramEmbed } from "./telegram-embed.js";
|
|
50
|
+
import { TenorEmbed } from "./tenor-embed.js";
|
|
51
|
+
import { ThreadsEmbed } from "./threads-embed.js";
|
|
52
|
+
import { TikTokEmbed } from "./tiktok-embed.js";
|
|
53
|
+
import { TruthSocialEmbed } from "./truthsocial-embed.js";
|
|
54
|
+
import { TumblrEmbed } from "./tumblr-embed.js";
|
|
55
|
+
import { TwitchEmbed } from "./twitch-embed.js";
|
|
56
|
+
import { VimeoEmbed } from "./vimeo-embed.js";
|
|
57
|
+
import { XEmbed } from "./x-embed.js";
|
|
58
|
+
import { YouTubeEmbed } from "./youtube-embed.js";
|
|
59
|
+
import { GenericIframeEmbed } from "./generic-iframe-embed.js";
|
|
60
|
+
import { jsx } from "react/jsx-runtime";
|
|
61
|
+
// src/components/platforms.tsx
|
|
62
|
+
const x = {
|
|
63
|
+
kind: "platform",
|
|
64
|
+
parser: x$1,
|
|
65
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(XEmbed, {
|
|
66
|
+
...shared,
|
|
67
|
+
onError,
|
|
68
|
+
embed
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
const instagram = {
|
|
72
|
+
kind: "platform",
|
|
73
|
+
parser: instagram$1,
|
|
74
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(InstagramEmbed, {
|
|
75
|
+
...shared,
|
|
76
|
+
onError,
|
|
77
|
+
embed
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
const facebook = {
|
|
81
|
+
kind: "platform",
|
|
82
|
+
parser: facebook$1,
|
|
83
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(FacebookEmbed, {
|
|
84
|
+
...shared,
|
|
85
|
+
...frame,
|
|
86
|
+
onError,
|
|
87
|
+
embed
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
const threads = {
|
|
91
|
+
kind: "platform",
|
|
92
|
+
parser: threads$1,
|
|
93
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(ThreadsEmbed, {
|
|
94
|
+
...shared,
|
|
95
|
+
onError,
|
|
96
|
+
embed
|
|
97
|
+
})
|
|
98
|
+
};
|
|
99
|
+
const tiktok = {
|
|
100
|
+
kind: "platform",
|
|
101
|
+
parser: tiktok$1,
|
|
102
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(TikTokEmbed, {
|
|
103
|
+
...shared,
|
|
104
|
+
...frame,
|
|
105
|
+
onError,
|
|
106
|
+
embed
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
const youtube = {
|
|
110
|
+
kind: "platform",
|
|
111
|
+
parser: youtube$1,
|
|
112
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(YouTubeEmbed, {
|
|
113
|
+
...shared,
|
|
114
|
+
...frame,
|
|
115
|
+
onError,
|
|
116
|
+
embed
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
const telegram = {
|
|
120
|
+
kind: "platform",
|
|
121
|
+
parser: telegram$1,
|
|
122
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(TelegramEmbed, {
|
|
123
|
+
...shared,
|
|
124
|
+
onError,
|
|
125
|
+
embed
|
|
126
|
+
})
|
|
127
|
+
};
|
|
128
|
+
const snapchat = {
|
|
129
|
+
kind: "platform",
|
|
130
|
+
parser: snapchat$1,
|
|
131
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(SnapchatEmbed, {
|
|
132
|
+
...shared,
|
|
133
|
+
...frame,
|
|
134
|
+
onError,
|
|
135
|
+
embed
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
const linkedin = {
|
|
139
|
+
kind: "platform",
|
|
140
|
+
parser: linkedin$1,
|
|
141
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(LinkedInEmbed, {
|
|
142
|
+
...shared,
|
|
143
|
+
...frame,
|
|
144
|
+
onError,
|
|
145
|
+
embed
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
const reddit = {
|
|
149
|
+
kind: "platform",
|
|
150
|
+
parser: reddit$1,
|
|
151
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(RedditEmbed, {
|
|
152
|
+
...shared,
|
|
153
|
+
onError,
|
|
154
|
+
embed
|
|
155
|
+
})
|
|
156
|
+
};
|
|
157
|
+
const pinterest = {
|
|
158
|
+
kind: "platform",
|
|
159
|
+
parser: pinterest$1,
|
|
160
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(PinterestEmbed, {
|
|
161
|
+
...shared,
|
|
162
|
+
onError,
|
|
163
|
+
embed
|
|
164
|
+
})
|
|
165
|
+
};
|
|
166
|
+
const spotify = {
|
|
167
|
+
kind: "platform",
|
|
168
|
+
parser: spotify$1,
|
|
169
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(SpotifyEmbed, {
|
|
170
|
+
...shared,
|
|
171
|
+
...frame,
|
|
172
|
+
onError,
|
|
173
|
+
embed
|
|
174
|
+
})
|
|
175
|
+
};
|
|
176
|
+
const vimeo = {
|
|
177
|
+
kind: "platform",
|
|
178
|
+
parser: vimeo$1,
|
|
179
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(VimeoEmbed, {
|
|
180
|
+
...shared,
|
|
181
|
+
...frame,
|
|
182
|
+
onError,
|
|
183
|
+
embed
|
|
184
|
+
})
|
|
185
|
+
};
|
|
186
|
+
const twitch = {
|
|
187
|
+
kind: "platform",
|
|
188
|
+
parser: twitch$1,
|
|
189
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(TwitchEmbed, {
|
|
190
|
+
...shared,
|
|
191
|
+
...frame,
|
|
192
|
+
onError,
|
|
193
|
+
embed
|
|
194
|
+
})
|
|
195
|
+
};
|
|
196
|
+
const dailymotion = {
|
|
197
|
+
kind: "platform",
|
|
198
|
+
parser: dailymotion$1,
|
|
199
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(DailymotionEmbed, {
|
|
200
|
+
...shared,
|
|
201
|
+
...frame,
|
|
202
|
+
onError,
|
|
203
|
+
embed
|
|
204
|
+
})
|
|
205
|
+
};
|
|
206
|
+
const soundcloud = {
|
|
207
|
+
kind: "platform",
|
|
208
|
+
parser: soundcloud$1,
|
|
209
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(SoundCloudEmbed, {
|
|
210
|
+
...shared,
|
|
211
|
+
...frame,
|
|
212
|
+
onError,
|
|
213
|
+
embed
|
|
214
|
+
})
|
|
215
|
+
};
|
|
216
|
+
const applemusic = {
|
|
217
|
+
kind: "platform",
|
|
218
|
+
parser: applemusic$1,
|
|
219
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(AppleMusicEmbed, {
|
|
220
|
+
...shared,
|
|
221
|
+
...frame,
|
|
222
|
+
onError,
|
|
223
|
+
embed
|
|
224
|
+
})
|
|
225
|
+
};
|
|
226
|
+
const applepodcasts = {
|
|
227
|
+
kind: "platform",
|
|
228
|
+
parser: applepodcasts$1,
|
|
229
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(ApplePodcastsEmbed, {
|
|
230
|
+
...shared,
|
|
231
|
+
...frame,
|
|
232
|
+
onError,
|
|
233
|
+
embed
|
|
234
|
+
})
|
|
235
|
+
};
|
|
236
|
+
const kick = {
|
|
237
|
+
kind: "platform",
|
|
238
|
+
parser: kick$1,
|
|
239
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(KickEmbed, {
|
|
240
|
+
...shared,
|
|
241
|
+
...frame,
|
|
242
|
+
onError,
|
|
243
|
+
embed
|
|
244
|
+
})
|
|
245
|
+
};
|
|
246
|
+
const giphy = {
|
|
247
|
+
kind: "platform",
|
|
248
|
+
parser: giphy$1,
|
|
249
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(GiphyEmbed, {
|
|
250
|
+
...shared,
|
|
251
|
+
...frame,
|
|
252
|
+
onError,
|
|
253
|
+
embed
|
|
254
|
+
})
|
|
255
|
+
};
|
|
256
|
+
const tenor = {
|
|
257
|
+
kind: "platform",
|
|
258
|
+
parser: tenor$1,
|
|
259
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(TenorEmbed, {
|
|
260
|
+
...shared,
|
|
261
|
+
...frame,
|
|
262
|
+
onError,
|
|
263
|
+
embed
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
const streamable = {
|
|
267
|
+
kind: "platform",
|
|
268
|
+
parser: streamable$1,
|
|
269
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(StreamableEmbed, {
|
|
270
|
+
...shared,
|
|
271
|
+
...frame,
|
|
272
|
+
onError,
|
|
273
|
+
embed
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
const rumble = {
|
|
277
|
+
kind: "platform",
|
|
278
|
+
parser: rumble$1,
|
|
279
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(RumbleEmbed, {
|
|
280
|
+
...shared,
|
|
281
|
+
...frame,
|
|
282
|
+
onError,
|
|
283
|
+
embed
|
|
284
|
+
})
|
|
285
|
+
};
|
|
286
|
+
const truthsocial = {
|
|
287
|
+
kind: "platform",
|
|
288
|
+
parser: truthsocial$1,
|
|
289
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(TruthSocialEmbed, {
|
|
290
|
+
...shared,
|
|
291
|
+
onError,
|
|
292
|
+
embed
|
|
293
|
+
})
|
|
294
|
+
};
|
|
295
|
+
const imgur = {
|
|
296
|
+
kind: "platform",
|
|
297
|
+
parser: imgur$1,
|
|
298
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(ImgurEmbed, {
|
|
299
|
+
...shared,
|
|
300
|
+
onError,
|
|
301
|
+
embed
|
|
302
|
+
})
|
|
303
|
+
};
|
|
304
|
+
const strava = {
|
|
305
|
+
kind: "platform",
|
|
306
|
+
parser: strava$1,
|
|
307
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(StravaEmbed, {
|
|
308
|
+
...shared,
|
|
309
|
+
onError,
|
|
310
|
+
embed
|
|
311
|
+
})
|
|
312
|
+
};
|
|
313
|
+
const flickr = {
|
|
314
|
+
kind: "platform",
|
|
315
|
+
parser: flickr$1,
|
|
316
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(FlickrEmbed, {
|
|
317
|
+
...shared,
|
|
318
|
+
...frame,
|
|
319
|
+
onError,
|
|
320
|
+
embed
|
|
321
|
+
})
|
|
322
|
+
};
|
|
323
|
+
const bluesky = {
|
|
324
|
+
kind: "platform",
|
|
325
|
+
parser: bluesky$1,
|
|
326
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(BlueskyEmbed, {
|
|
327
|
+
...shared,
|
|
328
|
+
onError,
|
|
329
|
+
embed
|
|
330
|
+
})
|
|
331
|
+
};
|
|
332
|
+
const tumblr = {
|
|
333
|
+
kind: "platform",
|
|
334
|
+
parser: tumblr$1,
|
|
335
|
+
render: (embed, { shared, onError }) => /* @__PURE__ */ jsx(TumblrEmbed, {
|
|
336
|
+
...shared,
|
|
337
|
+
onError,
|
|
338
|
+
embed
|
|
339
|
+
})
|
|
340
|
+
};
|
|
341
|
+
/** Iframe embed code that no listed platform recognises, checked as `GenericIframeEmbed` does. */
|
|
342
|
+
const genericIframe = {
|
|
343
|
+
kind: "iframe",
|
|
344
|
+
parse: parseIframe,
|
|
345
|
+
render: (embed, { shared, frame, onError }) => /* @__PURE__ */ jsx(GenericIframeEmbed, {
|
|
346
|
+
...shared,
|
|
347
|
+
...frame,
|
|
348
|
+
onError,
|
|
349
|
+
embed
|
|
350
|
+
})
|
|
351
|
+
};
|
|
352
|
+
const EVERY_PLATFORM = [
|
|
353
|
+
genericIframe,
|
|
354
|
+
x,
|
|
355
|
+
instagram,
|
|
356
|
+
facebook,
|
|
357
|
+
threads,
|
|
358
|
+
tiktok,
|
|
359
|
+
youtube,
|
|
360
|
+
telegram,
|
|
361
|
+
snapchat,
|
|
362
|
+
linkedin,
|
|
363
|
+
reddit,
|
|
364
|
+
pinterest,
|
|
365
|
+
spotify,
|
|
366
|
+
vimeo,
|
|
367
|
+
twitch,
|
|
368
|
+
dailymotion,
|
|
369
|
+
soundcloud,
|
|
370
|
+
applemusic,
|
|
371
|
+
applepodcasts,
|
|
372
|
+
kick,
|
|
373
|
+
giphy,
|
|
374
|
+
tenor,
|
|
375
|
+
streamable,
|
|
376
|
+
rumble,
|
|
377
|
+
truthsocial,
|
|
378
|
+
imgur,
|
|
379
|
+
strava,
|
|
380
|
+
flickr,
|
|
381
|
+
bluesky,
|
|
382
|
+
tumblr
|
|
383
|
+
];
|
|
384
|
+
export { EVERY_PLATFORM, applemusic, applepodcasts, bluesky, dailymotion, facebook, flickr, genericIframe, giphy, imgur, instagram, kick, linkedin, pinterest, reddit, rumble, snapchat, soundcloud, spotify, strava, streamable, telegram, tenor, threads, tiktok, truthsocial, tumblr, twitch, vimeo, x, youtube };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { PlatformParser } from "../parser/platform.js";
|
|
2
|
+
import { ParsedEmbed } from "../parser/types.js";
|
|
1
3
|
import "./bluesky-embed.js";
|
|
2
|
-
import { BlueskyOptions } from "../core/plans/bluesky.js";
|
|
3
4
|
import "./dailymotion-embed.js";
|
|
4
|
-
import {
|
|
5
|
+
import { BlueskyOptions } from "../core/plans/bluesky.js";
|
|
5
6
|
import "./facebook-embed.js";
|
|
6
|
-
import {
|
|
7
|
+
import { DailymotionOptions } from "../core/plans/dailymotion.js";
|
|
7
8
|
import "./flickr-embed.js";
|
|
9
|
+
import { FacebookOptions } from "../core/plans/facebook.js";
|
|
10
|
+
import { ParsedIframe } from "../parser/iframe.js";
|
|
8
11
|
import { FlickrOptions } from "../core/plans/flickr.js";
|
|
9
12
|
import "./imgur-embed.js";
|
|
10
13
|
import { ImgurOptions } from "../core/plans/imgur.js";
|
|
@@ -55,6 +58,30 @@ export type SocialEmbedProps = SocialEmbedSource & Omit<FrameProps, PlatformOpti
|
|
|
55
58
|
*/
|
|
56
59
|
fallback?: (html: string) => ReactNode;
|
|
57
60
|
};
|
|
61
|
+
/** What `<SocialEmbed>` passes on to the platform it renders. */
|
|
62
|
+
export type RouteProps = {
|
|
63
|
+
shared: Omit<SocialEmbedProps, 'html' | 'url' | 'fallback' | 'height' | 'maxHeight' | 'onError'>;
|
|
64
|
+
frame: Pick<FrameProps, 'height' | 'maxHeight'>;
|
|
65
|
+
onError: FrameProps['onError'];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A platform for `createSocialEmbed`, such as `youtube` or `genericIframe`. Opaque: import the
|
|
69
|
+
* ones a page needs and pass them on.
|
|
70
|
+
*/
|
|
71
|
+
export type EmbedPlatform = {
|
|
72
|
+
readonly kind: 'platform';
|
|
73
|
+
readonly parser: PlatformParser;
|
|
74
|
+
readonly render: (embed: ParsedEmbed, props: RouteProps) => ReactNode;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: 'iframe';
|
|
77
|
+
readonly parse: (html: string) => ParsedIframe | null;
|
|
78
|
+
readonly render: (embed: ParsedIframe, props: RouteProps) => ReactNode;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* A `<SocialEmbed>` that recognises only the listed platforms, so a bundler leaves the others
|
|
82
|
+
* out. Call it in a client module: `createSocialEmbed([youtube, x, genericIframe])`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function createSocialEmbed(list: readonly EmbedPlatform[]): (props: SocialEmbedProps) => ReactNode;
|
|
58
85
|
/** `height` and `maxHeight` reach only the iframe-based embeds: the others size themselves. */
|
|
59
|
-
export declare function SocialEmbed(props: SocialEmbedProps):
|
|
86
|
+
export declare function SocialEmbed(props: SocialEmbedProps): ReactNode;
|
|
60
87
|
export {};
|