social-embeds 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -54
- package/dist/{index-CSSlJIJU.d.ts → index-BOBhkTW6.d.ts} +3 -2
- package/dist/index.d.ts +50 -3
- package/dist/index.js +323 -18
- package/dist/{parser-D7a5KPhN.js → parser-BSz1rCrV.js} +528 -71
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +1 -1
- package/package.json +9 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as escapeAttribute, i as x$1, n as matchUrl, o as parseHtml, r as platforms, s as rebuild, t as parseEmbed } from "./parser-
|
|
2
|
+
import { a as escapeAttribute, c as parseUrl, i as x$1, n as matchUrl, o as parseHtml, r as platforms, s as rebuild, t as parseEmbed } from "./parser-BSz1rCrV.js";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/parser/lookup.ts
|
|
6
|
+
const BLUESKY_HOSTS = /* @__PURE__ */ new Set(["bsky.app", "www.bsky.app"]);
|
|
7
|
+
const HANDLE_POST = /^\/profile\/([^/]{1,253})\/post\/[A-Za-z0-9._~:-]{1,512}\/?$/;
|
|
8
|
+
const HANDLE = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
|
|
9
|
+
/**
|
|
10
|
+
* The platform of a post URL that only a network lookup could turn into an embed: a Bluesky
|
|
11
|
+
* URL with a handle instead of a DID. Internal; the parser entry does not export it.
|
|
12
|
+
*/
|
|
13
|
+
function needsLookup(url) {
|
|
14
|
+
const parsed = typeof url === "string" ? parseUrl(url) : null;
|
|
15
|
+
if (!parsed || !BLUESKY_HOSTS.has(parsed.host)) return null;
|
|
16
|
+
const [, profile] = HANDLE_POST.exec(parsed.path) ?? [];
|
|
17
|
+
return profile !== void 0 && HANDLE.test(profile) ? "bluesky" : null;
|
|
18
|
+
}
|
|
5
19
|
// src/components/hooks.ts
|
|
6
20
|
const ROOT_MARGIN = "200px 0px";
|
|
7
21
|
/** False on the server and in the first client render, so the markup matches on hydration. */
|
|
@@ -178,7 +192,14 @@ const SHAPES = {
|
|
|
178
192
|
spotify: ["post iframe", "video iframe"],
|
|
179
193
|
vimeo: ["video iframe"],
|
|
180
194
|
twitch: ["video iframe"],
|
|
181
|
-
dailymotion: ["video iframe"]
|
|
195
|
+
dailymotion: ["video iframe"],
|
|
196
|
+
bluesky: ["post iframe"],
|
|
197
|
+
soundcloud: ["post iframe"],
|
|
198
|
+
applemusic: ["post iframe"],
|
|
199
|
+
applepodcasts: ["post iframe"],
|
|
200
|
+
tumblr: ["post iframe"],
|
|
201
|
+
kick: ["video iframe"],
|
|
202
|
+
giphy: ["video iframe"]
|
|
182
203
|
};
|
|
183
204
|
/**
|
|
184
205
|
* Security: the embed may be host-built, and its url, id and `fallbackHtml` are written
|
|
@@ -219,10 +240,22 @@ const NAMES = {
|
|
|
219
240
|
spotify: "Spotify",
|
|
220
241
|
vimeo: "Vimeo",
|
|
221
242
|
twitch: "Twitch",
|
|
222
|
-
dailymotion: "Dailymotion"
|
|
243
|
+
dailymotion: "Dailymotion",
|
|
244
|
+
bluesky: "Bluesky",
|
|
245
|
+
soundcloud: "SoundCloud",
|
|
246
|
+
applemusic: "Apple Music",
|
|
247
|
+
applepodcasts: "Apple Podcasts",
|
|
248
|
+
tumblr: "Tumblr",
|
|
249
|
+
kick: "Kick",
|
|
250
|
+
giphy: "Giphy"
|
|
223
251
|
};
|
|
252
|
+
/** For a post URL that only a network lookup could resolve (docs/decisions.md D70). */
|
|
253
|
+
function lookupMessage(platform) {
|
|
254
|
+
return `social-embeds: a ${NAMES[platform]} URL needs a lookup: use the embed code`;
|
|
255
|
+
}
|
|
224
256
|
function resolveEmbed(url, given, platform) {
|
|
225
257
|
const embed = given ?? (url === void 0 ? null : matchUrl(url));
|
|
258
|
+
if (!embed && url !== void 0 && needsLookup(url) === platform) return { error: lookupMessage(platform) };
|
|
226
259
|
if (!embed) return { error: `social-embeds: not a ${NAMES[platform]} post URL: ${String(url)}` };
|
|
227
260
|
if (embed.platform !== platform) return { error: `social-embeds: expected a ${NAMES[platform]} embed, got ${NAMES[embed.platform]}` };
|
|
228
261
|
const verified = verifyEmbed(embed);
|
|
@@ -234,7 +267,7 @@ function resolveEmbed(url, given, platform) {
|
|
|
234
267
|
* come only from the verified url and id.
|
|
235
268
|
*/
|
|
236
269
|
function optionsWithout(options, reserved) {
|
|
237
|
-
return Object.entries(options).filter(([key]) => !reserved.includes(key));
|
|
270
|
+
return Object.entries(options).filter(([key]) => !reserved.includes(key.toLowerCase()));
|
|
238
271
|
}
|
|
239
272
|
/** Later entries replace earlier ones with the same name. */
|
|
240
273
|
function query(...sources) {
|
|
@@ -253,9 +286,108 @@ function playerParams(props, names) {
|
|
|
253
286
|
}
|
|
254
287
|
return params;
|
|
255
288
|
}
|
|
289
|
+
// src/components/apple-embed.tsx
|
|
290
|
+
const ALLOW$9 = "autoplay *; encrypted-media *; fullscreen *; clipboard-write";
|
|
291
|
+
const SANDBOX$1 = "allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation";
|
|
292
|
+
const SINGLE_HEIGHT = 175;
|
|
293
|
+
const EPISODE_HEIGHT = 160;
|
|
294
|
+
const FULL_HEIGHT$1 = 450;
|
|
295
|
+
/** A fixed height: the `height` prop, else the embed code's, else 175px for a song and 450px for the rest. */
|
|
296
|
+
function AppleMusicEmbed(props) {
|
|
297
|
+
const { url, embed: given, onError, height, maxWidth = 660, style, ...frame } = props;
|
|
298
|
+
const { embed, error } = resolveEmbed(url, given, "applemusic");
|
|
299
|
+
useReportError(error, onError);
|
|
300
|
+
if (!embed) return null;
|
|
301
|
+
const path = embed.url.slice(23);
|
|
302
|
+
const single = path.includes("/song/") || path.includes("?i=");
|
|
303
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
304
|
+
...frame,
|
|
305
|
+
onError,
|
|
306
|
+
maxWidth,
|
|
307
|
+
style: {
|
|
308
|
+
borderRadius: 10,
|
|
309
|
+
overflow: "hidden",
|
|
310
|
+
...style
|
|
311
|
+
},
|
|
312
|
+
height: height ?? embed.size?.height ?? (single ? SINGLE_HEIGHT : FULL_HEIGHT$1),
|
|
313
|
+
src: `https://embed.music.apple.com${path}`,
|
|
314
|
+
title: "Apple Music player",
|
|
315
|
+
allow: ALLOW$9,
|
|
316
|
+
sandbox: SANDBOX$1,
|
|
317
|
+
ratio: {
|
|
318
|
+
width: 16,
|
|
319
|
+
height: 9
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/** A fixed height: the `height` prop, else the embed code's, else 160px for an episode and 450px for a show. */
|
|
324
|
+
function ApplePodcastsEmbed(props) {
|
|
325
|
+
const { url, embed: given, onError, height, maxWidth = 640, style, ...frame } = props;
|
|
326
|
+
const { embed, error } = resolveEmbed(url, given, "applepodcasts");
|
|
327
|
+
useReportError(error, onError);
|
|
328
|
+
if (!embed) return null;
|
|
329
|
+
const path = embed.url.slice(26);
|
|
330
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
331
|
+
...frame,
|
|
332
|
+
onError,
|
|
333
|
+
maxWidth,
|
|
334
|
+
style: {
|
|
335
|
+
borderRadius: 12,
|
|
336
|
+
overflow: "hidden",
|
|
337
|
+
...style
|
|
338
|
+
},
|
|
339
|
+
height: height ?? embed.size?.height ?? (path.includes("?i=") ? EPISODE_HEIGHT : FULL_HEIGHT$1),
|
|
340
|
+
src: `https://embed.podcasts.apple.com${path}`,
|
|
341
|
+
title: "Apple Podcasts player",
|
|
342
|
+
allow: ALLOW$9,
|
|
343
|
+
sandbox: SANDBOX$1,
|
|
344
|
+
ratio: {
|
|
345
|
+
width: 16,
|
|
346
|
+
height: 9
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
// src/components/bluesky-embed.tsx
|
|
351
|
+
/** The frame posts `{ height }` once it has painted (docs/decisions.md D70). */
|
|
352
|
+
const BLUESKY_HEIGHT = {
|
|
353
|
+
origin: "https://embed.bsky.app",
|
|
354
|
+
read(data) {
|
|
355
|
+
const height = data?.height;
|
|
356
|
+
return typeof height === "number" ? height : void 0;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const START_HEIGHT$2 = 300;
|
|
360
|
+
/**
|
|
361
|
+
* At most 600px wide by default, Bluesky's oEmbed width. Renders the frame `embed.js` would
|
|
362
|
+
* create, without the script (docs/decisions.md D77). Only embed code and URLs with a DID
|
|
363
|
+
* render: a handle URL needs a lookup, and `onError` says so.
|
|
364
|
+
*/
|
|
365
|
+
function BlueskyEmbed(props) {
|
|
366
|
+
const { url, embed: given, onError, maxWidth = 600, colorMode, placeholder, ...shared } = props;
|
|
367
|
+
const { embed, error } = resolveEmbed(url, given, "bluesky");
|
|
368
|
+
useReportError(error, onError);
|
|
369
|
+
if (!embed) return null;
|
|
370
|
+
const mode = colorMode ?? embed.options.colorMode;
|
|
371
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
372
|
+
...shared,
|
|
373
|
+
onError,
|
|
374
|
+
maxWidth,
|
|
375
|
+
placeholder: placeholder ?? (embed.fallbackHtml === void 0 ? void 0 : /* @__PURE__ */ jsx("blockquote", { dangerouslySetInnerHTML: { __html: embed.fallbackHtml } })),
|
|
376
|
+
src: `https://embed.bsky.app/embed/${embed.id}${query(typeof mode === "string" ? [["colorMode", mode]] : void 0)}`,
|
|
377
|
+
title: "Bluesky post",
|
|
378
|
+
allow: "",
|
|
379
|
+
scrolling: "no",
|
|
380
|
+
ratio: {
|
|
381
|
+
width: 1,
|
|
382
|
+
height: 1
|
|
383
|
+
},
|
|
384
|
+
messageHeight: BLUESKY_HEIGHT,
|
|
385
|
+
startHeight: START_HEIGHT$2
|
|
386
|
+
});
|
|
387
|
+
}
|
|
256
388
|
// src/components/dailymotion-embed.tsx
|
|
257
389
|
const PLAYER_ID = /^x[a-z0-9]{3,12}$/;
|
|
258
|
-
const ALLOW$
|
|
390
|
+
const ALLOW$8 = "autoplay; fullscreen; picture-in-picture; web-share";
|
|
259
391
|
/**
|
|
260
392
|
* Dailymotion refuses embeds without a Player ID: one from the embed code or the `playerId`
|
|
261
393
|
* prop, never another account's (docs/decisions.md D63).
|
|
@@ -277,7 +409,7 @@ function DailymotionEmbed(props) {
|
|
|
277
409
|
...frame,
|
|
278
410
|
src: `https://geo.dailymotion.com/player/${String(player)}.html${query([["video", embed.id]], optionsWithout(parsed, ["video", "playlist"]), params)}`,
|
|
279
411
|
title: "Dailymotion video player",
|
|
280
|
-
allow: ALLOW$
|
|
412
|
+
allow: ALLOW$8,
|
|
281
413
|
ratio: {
|
|
282
414
|
width: 16,
|
|
283
415
|
height: 9
|
|
@@ -576,14 +708,14 @@ const pinterestDriver = {
|
|
|
576
708
|
}
|
|
577
709
|
};
|
|
578
710
|
// src/components/facebook-video-iframe.tsx
|
|
579
|
-
const ALLOW$
|
|
711
|
+
const ALLOW$7 = "autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share";
|
|
580
712
|
function FacebookVideoIframe({ embed, ...frame }) {
|
|
581
713
|
const params = Object.entries(embed.options).filter(([key]) => key !== "href");
|
|
582
714
|
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
583
715
|
...frame,
|
|
584
716
|
src: `https://www.facebook.com/plugins/video.php${query([["href", embed.url]], params)}`,
|
|
585
717
|
title: "Facebook video player",
|
|
586
|
-
allow: ALLOW$
|
|
718
|
+
allow: ALLOW$7,
|
|
587
719
|
scrolling: "no",
|
|
588
720
|
ratio: {
|
|
589
721
|
width: 16,
|
|
@@ -783,6 +915,26 @@ function FacebookEmbed(props) {
|
|
|
783
915
|
label: "Facebook"
|
|
784
916
|
}, `${sdkLocale} ${markup}`);
|
|
785
917
|
}
|
|
918
|
+
// src/components/giphy-embed.tsx
|
|
919
|
+
/** The embed code's aspect ratio; a URL carries no size and renders square (docs/decisions.md D76). */
|
|
920
|
+
function GiphyEmbed(props) {
|
|
921
|
+
const { url, embed: given, onError, ...frame } = props;
|
|
922
|
+
const { embed, error } = resolveEmbed(url, given, "giphy");
|
|
923
|
+
useReportError(error, onError);
|
|
924
|
+
if (!embed) return null;
|
|
925
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
926
|
+
...frame,
|
|
927
|
+
onError,
|
|
928
|
+
src: `https://giphy.com/embed/${embed.id}`,
|
|
929
|
+
title: "Giphy GIF",
|
|
930
|
+
allow: "fullscreen",
|
|
931
|
+
ratio: {
|
|
932
|
+
width: 1,
|
|
933
|
+
height: 1
|
|
934
|
+
},
|
|
935
|
+
size: embed.size
|
|
936
|
+
});
|
|
937
|
+
}
|
|
786
938
|
// src/components/instagram-embed.tsx
|
|
787
939
|
/** A photo post without caption at 375px, the smallest measured (docs/decisions.md D34). */
|
|
788
940
|
const MIN_HEIGHT$3 = 680;
|
|
@@ -810,6 +962,31 @@ function InstagramEmbed(props) {
|
|
|
810
962
|
label: "Instagram"
|
|
811
963
|
}, markup);
|
|
812
964
|
}
|
|
965
|
+
// src/components/kick-embed.tsx
|
|
966
|
+
const KEPT = /* @__PURE__ */ new Set(["autoplay", "muted"]);
|
|
967
|
+
/** A live channel at 16:9. */
|
|
968
|
+
function KickEmbed(props) {
|
|
969
|
+
const { url, embed: given, onError, autoplay, muted, ...frame } = props;
|
|
970
|
+
const { embed, error } = resolveEmbed(url, given, "kick");
|
|
971
|
+
useReportError(error, onError);
|
|
972
|
+
if (!embed) return null;
|
|
973
|
+
const fromProps = [];
|
|
974
|
+
if (autoplay !== void 0) fromProps.push(["autoplay", autoplay]);
|
|
975
|
+
if (muted !== void 0) fromProps.push(["muted", muted]);
|
|
976
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
977
|
+
...frame,
|
|
978
|
+
onError,
|
|
979
|
+
src: `https://player.kick.com/${embed.id}${query(Object.entries(embed.options).filter(([key]) => KEPT.has(key)), fromProps)}`,
|
|
980
|
+
title: "Kick player",
|
|
981
|
+
allow: "autoplay; fullscreen",
|
|
982
|
+
scrolling: "no",
|
|
983
|
+
ratio: {
|
|
984
|
+
width: 16,
|
|
985
|
+
height: 9
|
|
986
|
+
},
|
|
987
|
+
size: embed.size
|
|
988
|
+
});
|
|
989
|
+
}
|
|
813
990
|
// src/components/linkedin-embed.tsx
|
|
814
991
|
const DEFAULT_HEIGHT = 670;
|
|
815
992
|
const DEFAULT_WIDTH = 504;
|
|
@@ -868,7 +1045,7 @@ function PinterestEmbed(props) {
|
|
|
868
1045
|
}, markup);
|
|
869
1046
|
}
|
|
870
1047
|
// src/components/reddit-embed.tsx
|
|
871
|
-
const PARAMS$
|
|
1048
|
+
const PARAMS$5 = {
|
|
872
1049
|
theme: "theme",
|
|
873
1050
|
showMedia: "showmedia",
|
|
874
1051
|
showTitle: "showtitle",
|
|
@@ -877,8 +1054,8 @@ const PARAMS$4 = {
|
|
|
877
1054
|
depth: "depth"
|
|
878
1055
|
};
|
|
879
1056
|
const SANDBOX = "allow-scripts allow-same-origin allow-popups";
|
|
880
|
-
const ALLOW$
|
|
881
|
-
const START_HEIGHT = 316;
|
|
1057
|
+
const ALLOW$6 = "clipboard-read; clipboard-write";
|
|
1058
|
+
const START_HEIGHT$1 = 316;
|
|
882
1059
|
/** docs/decisions.md D52. */
|
|
883
1060
|
const REDDIT_HEIGHT = {
|
|
884
1061
|
origin: "https://embed.reddit.com",
|
|
@@ -903,7 +1080,7 @@ function RedditEmbed(props) {
|
|
|
903
1080
|
locale,
|
|
904
1081
|
depth
|
|
905
1082
|
};
|
|
906
|
-
for (const [prop, name] of Object.entries(PARAMS$
|
|
1083
|
+
for (const [prop, name] of Object.entries(PARAMS$5)) {
|
|
907
1084
|
const value = values[prop];
|
|
908
1085
|
if (value !== void 0) fromProps.push([name, value]);
|
|
909
1086
|
}
|
|
@@ -914,7 +1091,7 @@ function RedditEmbed(props) {
|
|
|
914
1091
|
maxWidth,
|
|
915
1092
|
src: `https://embed.reddit.com${path}${query([["embed", true]], Object.entries(embed.options), fromProps)}`,
|
|
916
1093
|
title: "Reddit post",
|
|
917
|
-
allow: ALLOW$
|
|
1094
|
+
allow: ALLOW$6,
|
|
918
1095
|
sandbox: SANDBOX,
|
|
919
1096
|
scrolling: "no",
|
|
920
1097
|
ratio: {
|
|
@@ -922,11 +1099,11 @@ function RedditEmbed(props) {
|
|
|
922
1099
|
height: 1
|
|
923
1100
|
},
|
|
924
1101
|
messageHeight: REDDIT_HEIGHT,
|
|
925
|
-
startHeight: embed.size?.height ?? START_HEIGHT
|
|
1102
|
+
startHeight: embed.size?.height ?? START_HEIGHT$1
|
|
926
1103
|
});
|
|
927
1104
|
}
|
|
928
1105
|
// src/components/snapchat-embed.tsx
|
|
929
|
-
const ALLOW$
|
|
1106
|
+
const ALLOW$5 = "autoplay; camera; microphone; clipboard-write;";
|
|
930
1107
|
/** At most 416px wide by default, the size of Snapchat's own embed code (docs/decisions.md D50). */
|
|
931
1108
|
function SnapchatEmbed(props) {
|
|
932
1109
|
const { url, embed: given, onError, maxWidth = 416, ...frame } = props;
|
|
@@ -939,7 +1116,7 @@ function SnapchatEmbed(props) {
|
|
|
939
1116
|
maxWidth,
|
|
940
1117
|
src: `${embed.url}/embed`,
|
|
941
1118
|
title: typeof title === "string" && title !== "" ? title : "Snapchat",
|
|
942
|
-
allow: ALLOW$
|
|
1119
|
+
allow: ALLOW$5,
|
|
943
1120
|
scrolling: "no",
|
|
944
1121
|
ratio: {
|
|
945
1122
|
width: 416,
|
|
@@ -948,6 +1125,57 @@ function SnapchatEmbed(props) {
|
|
|
948
1125
|
size: embed.size
|
|
949
1126
|
});
|
|
950
1127
|
}
|
|
1128
|
+
// src/components/soundcloud-embed.tsx
|
|
1129
|
+
const PARAMS$4 = {
|
|
1130
|
+
visual: "visual",
|
|
1131
|
+
color: "color",
|
|
1132
|
+
autoPlay: "auto_play",
|
|
1133
|
+
hideRelated: "hide_related",
|
|
1134
|
+
showComments: "show_comments",
|
|
1135
|
+
showUser: "show_user",
|
|
1136
|
+
showReposts: "show_reposts",
|
|
1137
|
+
showTeaser: "show_teaser",
|
|
1138
|
+
showArtwork: "show_artwork"
|
|
1139
|
+
};
|
|
1140
|
+
const ALLOW$4 = "autoplay; encrypted-media";
|
|
1141
|
+
const URL_HEIGHT = 400;
|
|
1142
|
+
/** A fixed height: the `height` prop, else the embed code's, else 400px for the visual player. */
|
|
1143
|
+
function SoundCloudEmbed(props) {
|
|
1144
|
+
const { url, embed: given, onError, height, visual, color, autoPlay, hideRelated, showComments, showUser, showReposts, showTeaser, showArtwork, ...frame } = props;
|
|
1145
|
+
const { embed, error } = resolveEmbed(url, given, "soundcloud");
|
|
1146
|
+
useReportError(error, onError);
|
|
1147
|
+
if (!embed) return null;
|
|
1148
|
+
const values = {
|
|
1149
|
+
visual,
|
|
1150
|
+
color,
|
|
1151
|
+
autoPlay,
|
|
1152
|
+
hideRelated,
|
|
1153
|
+
showComments,
|
|
1154
|
+
showUser,
|
|
1155
|
+
showReposts,
|
|
1156
|
+
showTeaser,
|
|
1157
|
+
showArtwork
|
|
1158
|
+
};
|
|
1159
|
+
const fromProps = [];
|
|
1160
|
+
for (const [prop, name] of Object.entries(PARAMS$4)) {
|
|
1161
|
+
const value = values[prop];
|
|
1162
|
+
if (value !== void 0) fromProps.push([name, value]);
|
|
1163
|
+
}
|
|
1164
|
+
const fromUrl = embed.size === void 0;
|
|
1165
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
1166
|
+
...frame,
|
|
1167
|
+
onError,
|
|
1168
|
+
height: height ?? embed.size?.height ?? URL_HEIGHT,
|
|
1169
|
+
src: `https://w.soundcloud.com/player/${query([["url", embed.url]], fromUrl ? [["visual", true]] : void 0, optionsWithout(embed.options, ["url", "secret_token"]), fromProps)}`,
|
|
1170
|
+
title: "SoundCloud player",
|
|
1171
|
+
allow: ALLOW$4,
|
|
1172
|
+
scrolling: "no",
|
|
1173
|
+
ratio: {
|
|
1174
|
+
width: 16,
|
|
1175
|
+
height: 9
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
951
1179
|
// src/components/spotify-embed.tsx
|
|
952
1180
|
const ALLOW$3 = "autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture";
|
|
953
1181
|
const COMPACT = /* @__PURE__ */ new Set(["track", "episode"]);
|
|
@@ -1123,6 +1351,41 @@ function TikTokEmbed(props) {
|
|
|
1123
1351
|
size: embed.size
|
|
1124
1352
|
});
|
|
1125
1353
|
}
|
|
1354
|
+
// src/components/tumblr-embed.tsx
|
|
1355
|
+
/** The frame posts a JSON string once it has painted (docs/decisions.md D74). */
|
|
1356
|
+
const TUMBLR_HEIGHT = {
|
|
1357
|
+
origin: "https://embed.tumblr.com",
|
|
1358
|
+
read(data) {
|
|
1359
|
+
if (typeof data !== "string") return void 0;
|
|
1360
|
+
const message = JSON.parse(data);
|
|
1361
|
+
const [height] = Array.isArray(message.args) ? message.args : [];
|
|
1362
|
+
return message.method === "tumblr-post:sizeChange" && typeof height === "number" ? height : void 0;
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
const START_HEIGHT = 400;
|
|
1366
|
+
/** At most 540px wide by default, Tumblr's oEmbed width. Renders the frame `post.js` would create (docs/decisions.md D77). */
|
|
1367
|
+
function TumblrEmbed(props) {
|
|
1368
|
+
const { url, embed: given, onError, maxWidth = 540, ...shared } = props;
|
|
1369
|
+
const { embed, error } = resolveEmbed(url, given, "tumblr");
|
|
1370
|
+
useReportError(error, onError);
|
|
1371
|
+
if (!embed) return null;
|
|
1372
|
+
const blog = embed.url.slice(23).split("/")[0] ?? "";
|
|
1373
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
1374
|
+
...shared,
|
|
1375
|
+
onError,
|
|
1376
|
+
maxWidth,
|
|
1377
|
+
src: `https://embed.tumblr.com/embed/post/${blog}/${embed.id}/v2`,
|
|
1378
|
+
title: "Tumblr post",
|
|
1379
|
+
allow: "",
|
|
1380
|
+
scrolling: "no",
|
|
1381
|
+
ratio: {
|
|
1382
|
+
width: 1,
|
|
1383
|
+
height: 1
|
|
1384
|
+
},
|
|
1385
|
+
messageHeight: TUMBLR_HEIGHT,
|
|
1386
|
+
startHeight: START_HEIGHT
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1126
1389
|
// src/components/twitch-embed.tsx
|
|
1127
1390
|
const RESERVED = [
|
|
1128
1391
|
"channel",
|
|
@@ -1339,7 +1602,9 @@ function SocialEmbed(props) {
|
|
|
1339
1602
|
maxHeight
|
|
1340
1603
|
};
|
|
1341
1604
|
const embed = useMemo(() => html !== void 0 ? parseEmbed(html) : matchUrl(url), [html, url]);
|
|
1342
|
-
|
|
1605
|
+
const unrecognised = embed === null && !(html !== void 0 && fallback);
|
|
1606
|
+
const lookup = html === void 0 ? needsLookup(url) : null;
|
|
1607
|
+
useReportError(unrecognised ? html !== void 0 ? "social-embeds: unrecognised embed code" : lookup ? lookupMessage(lookup) : `social-embeds: not a supported post URL: ${url}` : void 0, onError);
|
|
1343
1608
|
if (!embed) return html !== void 0 && fallback ? fallback(html) : null;
|
|
1344
1609
|
switch (embed.platform) {
|
|
1345
1610
|
case "x": return /* @__PURE__ */ jsx(XEmbed, {
|
|
@@ -1426,6 +1691,46 @@ function SocialEmbed(props) {
|
|
|
1426
1691
|
onError,
|
|
1427
1692
|
embed
|
|
1428
1693
|
});
|
|
1694
|
+
case "bluesky": return /* @__PURE__ */ jsx(BlueskyEmbed, {
|
|
1695
|
+
...shared,
|
|
1696
|
+
onError,
|
|
1697
|
+
embed
|
|
1698
|
+
});
|
|
1699
|
+
case "soundcloud": return /* @__PURE__ */ jsx(SoundCloudEmbed, {
|
|
1700
|
+
...shared,
|
|
1701
|
+
...frame,
|
|
1702
|
+
onError,
|
|
1703
|
+
embed
|
|
1704
|
+
});
|
|
1705
|
+
case "applemusic": return /* @__PURE__ */ jsx(AppleMusicEmbed, {
|
|
1706
|
+
...shared,
|
|
1707
|
+
...frame,
|
|
1708
|
+
onError,
|
|
1709
|
+
embed
|
|
1710
|
+
});
|
|
1711
|
+
case "applepodcasts": return /* @__PURE__ */ jsx(ApplePodcastsEmbed, {
|
|
1712
|
+
...shared,
|
|
1713
|
+
...frame,
|
|
1714
|
+
onError,
|
|
1715
|
+
embed
|
|
1716
|
+
});
|
|
1717
|
+
case "tumblr": return /* @__PURE__ */ jsx(TumblrEmbed, {
|
|
1718
|
+
...shared,
|
|
1719
|
+
onError,
|
|
1720
|
+
embed
|
|
1721
|
+
});
|
|
1722
|
+
case "kick": return /* @__PURE__ */ jsx(KickEmbed, {
|
|
1723
|
+
...shared,
|
|
1724
|
+
...frame,
|
|
1725
|
+
onError,
|
|
1726
|
+
embed
|
|
1727
|
+
});
|
|
1728
|
+
case "giphy": return /* @__PURE__ */ jsx(GiphyEmbed, {
|
|
1729
|
+
...shared,
|
|
1730
|
+
...frame,
|
|
1731
|
+
onError,
|
|
1732
|
+
embed
|
|
1733
|
+
});
|
|
1429
1734
|
}
|
|
1430
1735
|
}
|
|
1431
|
-
export { DailymotionEmbed, FacebookEmbed, InstagramEmbed, LinkedInEmbed, PinterestEmbed, RedditEmbed, SnapchatEmbed, SocialEmbed, SpotifyEmbed, TelegramEmbed, ThreadsEmbed, TikTokEmbed, TwitchEmbed, VimeoEmbed, XEmbed, YouTubeEmbed };
|
|
1736
|
+
export { AppleMusicEmbed, ApplePodcastsEmbed, BlueskyEmbed, DailymotionEmbed, FacebookEmbed, GiphyEmbed, InstagramEmbed, KickEmbed, LinkedInEmbed, PinterestEmbed, RedditEmbed, SnapchatEmbed, SocialEmbed, SoundCloudEmbed, SpotifyEmbed, TelegramEmbed, ThreadsEmbed, TikTokEmbed, TumblrEmbed, TwitchEmbed, VimeoEmbed, XEmbed, YouTubeEmbed };
|