social-embeds 0.4.0 → 0.5.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 +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 +316 -17
- package/dist/{parser-D7a5KPhN.js → parser-CJccut4h.js} +517 -72
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +1 -1
- package/package.json +32 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as DID, c as rebuild, i as x$1, l as parseUrl, n as matchUrl, o as escapeAttribute, r as platforms, s as parseHtml, t as parseEmbed } from "./parser-CJccut4h.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 IS_DID = new RegExp(`^${DID}$`);
|
|
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 && !IS_DID.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,18 @@ 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
|
};
|
|
224
252
|
function resolveEmbed(url, given, platform) {
|
|
225
253
|
const embed = given ?? (url === void 0 ? null : matchUrl(url));
|
|
254
|
+
if (!embed && url !== void 0 && needsLookup(url) === platform) return { error: `social-embeds: a ${NAMES[platform]} URL needs a lookup: use the embed code` };
|
|
226
255
|
if (!embed) return { error: `social-embeds: not a ${NAMES[platform]} post URL: ${String(url)}` };
|
|
227
256
|
if (embed.platform !== platform) return { error: `social-embeds: expected a ${NAMES[platform]} embed, got ${NAMES[embed.platform]}` };
|
|
228
257
|
const verified = verifyEmbed(embed);
|
|
@@ -253,9 +282,108 @@ function playerParams(props, names) {
|
|
|
253
282
|
}
|
|
254
283
|
return params;
|
|
255
284
|
}
|
|
285
|
+
// src/components/apple-embed.tsx
|
|
286
|
+
const ALLOW$9 = "autoplay *; encrypted-media *; fullscreen *; clipboard-write";
|
|
287
|
+
const SANDBOX$1 = "allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation";
|
|
288
|
+
const SINGLE_HEIGHT = 175;
|
|
289
|
+
const EPISODE_HEIGHT = 160;
|
|
290
|
+
const FULL_HEIGHT$1 = 450;
|
|
291
|
+
/** A fixed height: the `height` prop, else the embed code's, else 175px for a song and 450px for the rest. */
|
|
292
|
+
function AppleMusicEmbed(props) {
|
|
293
|
+
const { url, embed: given, onError, height, maxWidth = 660, style, ...frame } = props;
|
|
294
|
+
const { embed, error } = resolveEmbed(url, given, "applemusic");
|
|
295
|
+
useReportError(error, onError);
|
|
296
|
+
if (!embed) return null;
|
|
297
|
+
const path = embed.url.slice(23);
|
|
298
|
+
const single = path.includes("/song/") || path.includes("?i=");
|
|
299
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
300
|
+
...frame,
|
|
301
|
+
onError,
|
|
302
|
+
maxWidth,
|
|
303
|
+
style: {
|
|
304
|
+
borderRadius: 10,
|
|
305
|
+
overflow: "hidden",
|
|
306
|
+
...style
|
|
307
|
+
},
|
|
308
|
+
height: height ?? embed.size?.height ?? (single ? SINGLE_HEIGHT : FULL_HEIGHT$1),
|
|
309
|
+
src: `https://embed.music.apple.com${path}`,
|
|
310
|
+
title: "Apple Music player",
|
|
311
|
+
allow: ALLOW$9,
|
|
312
|
+
sandbox: SANDBOX$1,
|
|
313
|
+
ratio: {
|
|
314
|
+
width: 16,
|
|
315
|
+
height: 9
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/** A fixed height: the `height` prop, else the embed code's, else 160px for an episode and 450px for a show. */
|
|
320
|
+
function ApplePodcastsEmbed(props) {
|
|
321
|
+
const { url, embed: given, onError, height, maxWidth = 640, style, ...frame } = props;
|
|
322
|
+
const { embed, error } = resolveEmbed(url, given, "applepodcasts");
|
|
323
|
+
useReportError(error, onError);
|
|
324
|
+
if (!embed) return null;
|
|
325
|
+
const path = embed.url.slice(26);
|
|
326
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
327
|
+
...frame,
|
|
328
|
+
onError,
|
|
329
|
+
maxWidth,
|
|
330
|
+
style: {
|
|
331
|
+
borderRadius: 12,
|
|
332
|
+
overflow: "hidden",
|
|
333
|
+
...style
|
|
334
|
+
},
|
|
335
|
+
height: height ?? embed.size?.height ?? (path.includes("?i=") ? EPISODE_HEIGHT : FULL_HEIGHT$1),
|
|
336
|
+
src: `https://embed.podcasts.apple.com${path}`,
|
|
337
|
+
title: "Apple Podcasts player",
|
|
338
|
+
allow: ALLOW$9,
|
|
339
|
+
sandbox: SANDBOX$1,
|
|
340
|
+
ratio: {
|
|
341
|
+
width: 16,
|
|
342
|
+
height: 9
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
// src/components/bluesky-embed.tsx
|
|
347
|
+
/** The frame posts `{ height }` once it has painted (docs/decisions.md D70). */
|
|
348
|
+
const BLUESKY_HEIGHT = {
|
|
349
|
+
origin: "https://embed.bsky.app",
|
|
350
|
+
read(data) {
|
|
351
|
+
const height = data?.height;
|
|
352
|
+
return typeof height === "number" ? height : void 0;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const START_HEIGHT$2 = 300;
|
|
356
|
+
/**
|
|
357
|
+
* At most 600px wide by default, Bluesky's oEmbed width. Renders the frame `embed.js` would
|
|
358
|
+
* create, without the script (docs/decisions.md D77). Only embed code and URLs with a DID
|
|
359
|
+
* render: a handle URL needs a lookup, and `onError` says so.
|
|
360
|
+
*/
|
|
361
|
+
function BlueskyEmbed(props) {
|
|
362
|
+
const { url, embed: given, onError, maxWidth = 600, colorMode, placeholder, ...shared } = props;
|
|
363
|
+
const { embed, error } = resolveEmbed(url, given, "bluesky");
|
|
364
|
+
useReportError(error, onError);
|
|
365
|
+
if (!embed) return null;
|
|
366
|
+
const mode = colorMode ?? embed.options.colorMode;
|
|
367
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
368
|
+
...shared,
|
|
369
|
+
onError,
|
|
370
|
+
maxWidth,
|
|
371
|
+
placeholder: placeholder ?? (embed.fallbackHtml === void 0 ? void 0 : /* @__PURE__ */ jsx("blockquote", { dangerouslySetInnerHTML: { __html: embed.fallbackHtml } })),
|
|
372
|
+
src: `https://embed.bsky.app/embed/${embed.id}${query(typeof mode === "string" ? [["colorMode", mode]] : void 0)}`,
|
|
373
|
+
title: "Bluesky post",
|
|
374
|
+
allow: "",
|
|
375
|
+
scrolling: "no",
|
|
376
|
+
ratio: {
|
|
377
|
+
width: 1,
|
|
378
|
+
height: 1
|
|
379
|
+
},
|
|
380
|
+
messageHeight: BLUESKY_HEIGHT,
|
|
381
|
+
startHeight: START_HEIGHT$2
|
|
382
|
+
});
|
|
383
|
+
}
|
|
256
384
|
// src/components/dailymotion-embed.tsx
|
|
257
385
|
const PLAYER_ID = /^x[a-z0-9]{3,12}$/;
|
|
258
|
-
const ALLOW$
|
|
386
|
+
const ALLOW$8 = "autoplay; fullscreen; picture-in-picture; web-share";
|
|
259
387
|
/**
|
|
260
388
|
* Dailymotion refuses embeds without a Player ID: one from the embed code or the `playerId`
|
|
261
389
|
* prop, never another account's (docs/decisions.md D63).
|
|
@@ -277,7 +405,7 @@ function DailymotionEmbed(props) {
|
|
|
277
405
|
...frame,
|
|
278
406
|
src: `https://geo.dailymotion.com/player/${String(player)}.html${query([["video", embed.id]], optionsWithout(parsed, ["video", "playlist"]), params)}`,
|
|
279
407
|
title: "Dailymotion video player",
|
|
280
|
-
allow: ALLOW$
|
|
408
|
+
allow: ALLOW$8,
|
|
281
409
|
ratio: {
|
|
282
410
|
width: 16,
|
|
283
411
|
height: 9
|
|
@@ -576,14 +704,14 @@ const pinterestDriver = {
|
|
|
576
704
|
}
|
|
577
705
|
};
|
|
578
706
|
// src/components/facebook-video-iframe.tsx
|
|
579
|
-
const ALLOW$
|
|
707
|
+
const ALLOW$7 = "autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share";
|
|
580
708
|
function FacebookVideoIframe({ embed, ...frame }) {
|
|
581
709
|
const params = Object.entries(embed.options).filter(([key]) => key !== "href");
|
|
582
710
|
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
583
711
|
...frame,
|
|
584
712
|
src: `https://www.facebook.com/plugins/video.php${query([["href", embed.url]], params)}`,
|
|
585
713
|
title: "Facebook video player",
|
|
586
|
-
allow: ALLOW$
|
|
714
|
+
allow: ALLOW$7,
|
|
587
715
|
scrolling: "no",
|
|
588
716
|
ratio: {
|
|
589
717
|
width: 16,
|
|
@@ -783,6 +911,26 @@ function FacebookEmbed(props) {
|
|
|
783
911
|
label: "Facebook"
|
|
784
912
|
}, `${sdkLocale} ${markup}`);
|
|
785
913
|
}
|
|
914
|
+
// src/components/giphy-embed.tsx
|
|
915
|
+
/** The embed code's aspect ratio; a URL carries no size and renders square (docs/decisions.md D76). */
|
|
916
|
+
function GiphyEmbed(props) {
|
|
917
|
+
const { url, embed: given, onError, ...frame } = props;
|
|
918
|
+
const { embed, error } = resolveEmbed(url, given, "giphy");
|
|
919
|
+
useReportError(error, onError);
|
|
920
|
+
if (!embed) return null;
|
|
921
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
922
|
+
...frame,
|
|
923
|
+
onError,
|
|
924
|
+
src: `https://giphy.com/embed/${embed.id}`,
|
|
925
|
+
title: "Giphy GIF",
|
|
926
|
+
allow: "fullscreen",
|
|
927
|
+
ratio: {
|
|
928
|
+
width: 1,
|
|
929
|
+
height: 1
|
|
930
|
+
},
|
|
931
|
+
size: embed.size
|
|
932
|
+
});
|
|
933
|
+
}
|
|
786
934
|
// src/components/instagram-embed.tsx
|
|
787
935
|
/** A photo post without caption at 375px, the smallest measured (docs/decisions.md D34). */
|
|
788
936
|
const MIN_HEIGHT$3 = 680;
|
|
@@ -810,6 +958,31 @@ function InstagramEmbed(props) {
|
|
|
810
958
|
label: "Instagram"
|
|
811
959
|
}, markup);
|
|
812
960
|
}
|
|
961
|
+
// src/components/kick-embed.tsx
|
|
962
|
+
const KEPT = /* @__PURE__ */ new Set(["autoplay", "muted"]);
|
|
963
|
+
/** A live channel at 16:9. */
|
|
964
|
+
function KickEmbed(props) {
|
|
965
|
+
const { url, embed: given, onError, autoplay, muted, ...frame } = props;
|
|
966
|
+
const { embed, error } = resolveEmbed(url, given, "kick");
|
|
967
|
+
useReportError(error, onError);
|
|
968
|
+
if (!embed) return null;
|
|
969
|
+
const fromProps = [];
|
|
970
|
+
if (autoplay !== void 0) fromProps.push(["autoplay", autoplay]);
|
|
971
|
+
if (muted !== void 0) fromProps.push(["muted", muted]);
|
|
972
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
973
|
+
...frame,
|
|
974
|
+
onError,
|
|
975
|
+
src: `https://player.kick.com/${embed.id}${query(Object.entries(embed.options).filter(([key]) => KEPT.has(key)), fromProps)}`,
|
|
976
|
+
title: "Kick player",
|
|
977
|
+
allow: "autoplay; fullscreen",
|
|
978
|
+
scrolling: "no",
|
|
979
|
+
ratio: {
|
|
980
|
+
width: 16,
|
|
981
|
+
height: 9
|
|
982
|
+
},
|
|
983
|
+
size: embed.size
|
|
984
|
+
});
|
|
985
|
+
}
|
|
813
986
|
// src/components/linkedin-embed.tsx
|
|
814
987
|
const DEFAULT_HEIGHT = 670;
|
|
815
988
|
const DEFAULT_WIDTH = 504;
|
|
@@ -868,7 +1041,7 @@ function PinterestEmbed(props) {
|
|
|
868
1041
|
}, markup);
|
|
869
1042
|
}
|
|
870
1043
|
// src/components/reddit-embed.tsx
|
|
871
|
-
const PARAMS$
|
|
1044
|
+
const PARAMS$5 = {
|
|
872
1045
|
theme: "theme",
|
|
873
1046
|
showMedia: "showmedia",
|
|
874
1047
|
showTitle: "showtitle",
|
|
@@ -877,8 +1050,8 @@ const PARAMS$4 = {
|
|
|
877
1050
|
depth: "depth"
|
|
878
1051
|
};
|
|
879
1052
|
const SANDBOX = "allow-scripts allow-same-origin allow-popups";
|
|
880
|
-
const ALLOW$
|
|
881
|
-
const START_HEIGHT = 316;
|
|
1053
|
+
const ALLOW$6 = "clipboard-read; clipboard-write";
|
|
1054
|
+
const START_HEIGHT$1 = 316;
|
|
882
1055
|
/** docs/decisions.md D52. */
|
|
883
1056
|
const REDDIT_HEIGHT = {
|
|
884
1057
|
origin: "https://embed.reddit.com",
|
|
@@ -903,7 +1076,7 @@ function RedditEmbed(props) {
|
|
|
903
1076
|
locale,
|
|
904
1077
|
depth
|
|
905
1078
|
};
|
|
906
|
-
for (const [prop, name] of Object.entries(PARAMS$
|
|
1079
|
+
for (const [prop, name] of Object.entries(PARAMS$5)) {
|
|
907
1080
|
const value = values[prop];
|
|
908
1081
|
if (value !== void 0) fromProps.push([name, value]);
|
|
909
1082
|
}
|
|
@@ -914,7 +1087,7 @@ function RedditEmbed(props) {
|
|
|
914
1087
|
maxWidth,
|
|
915
1088
|
src: `https://embed.reddit.com${path}${query([["embed", true]], Object.entries(embed.options), fromProps)}`,
|
|
916
1089
|
title: "Reddit post",
|
|
917
|
-
allow: ALLOW$
|
|
1090
|
+
allow: ALLOW$6,
|
|
918
1091
|
sandbox: SANDBOX,
|
|
919
1092
|
scrolling: "no",
|
|
920
1093
|
ratio: {
|
|
@@ -922,11 +1095,11 @@ function RedditEmbed(props) {
|
|
|
922
1095
|
height: 1
|
|
923
1096
|
},
|
|
924
1097
|
messageHeight: REDDIT_HEIGHT,
|
|
925
|
-
startHeight: embed.size?.height ?? START_HEIGHT
|
|
1098
|
+
startHeight: embed.size?.height ?? START_HEIGHT$1
|
|
926
1099
|
});
|
|
927
1100
|
}
|
|
928
1101
|
// src/components/snapchat-embed.tsx
|
|
929
|
-
const ALLOW$
|
|
1102
|
+
const ALLOW$5 = "autoplay; camera; microphone; clipboard-write;";
|
|
930
1103
|
/** At most 416px wide by default, the size of Snapchat's own embed code (docs/decisions.md D50). */
|
|
931
1104
|
function SnapchatEmbed(props) {
|
|
932
1105
|
const { url, embed: given, onError, maxWidth = 416, ...frame } = props;
|
|
@@ -939,7 +1112,7 @@ function SnapchatEmbed(props) {
|
|
|
939
1112
|
maxWidth,
|
|
940
1113
|
src: `${embed.url}/embed`,
|
|
941
1114
|
title: typeof title === "string" && title !== "" ? title : "Snapchat",
|
|
942
|
-
allow: ALLOW$
|
|
1115
|
+
allow: ALLOW$5,
|
|
943
1116
|
scrolling: "no",
|
|
944
1117
|
ratio: {
|
|
945
1118
|
width: 416,
|
|
@@ -948,6 +1121,57 @@ function SnapchatEmbed(props) {
|
|
|
948
1121
|
size: embed.size
|
|
949
1122
|
});
|
|
950
1123
|
}
|
|
1124
|
+
// src/components/soundcloud-embed.tsx
|
|
1125
|
+
const PARAMS$4 = {
|
|
1126
|
+
visual: "visual",
|
|
1127
|
+
color: "color",
|
|
1128
|
+
autoPlay: "auto_play",
|
|
1129
|
+
hideRelated: "hide_related",
|
|
1130
|
+
showComments: "show_comments",
|
|
1131
|
+
showUser: "show_user",
|
|
1132
|
+
showReposts: "show_reposts",
|
|
1133
|
+
showTeaser: "show_teaser",
|
|
1134
|
+
showArtwork: "show_artwork"
|
|
1135
|
+
};
|
|
1136
|
+
const ALLOW$4 = "autoplay; encrypted-media";
|
|
1137
|
+
const URL_HEIGHT = 400;
|
|
1138
|
+
/** A fixed height: the `height` prop, else the embed code's, else 400px for the visual player. */
|
|
1139
|
+
function SoundCloudEmbed(props) {
|
|
1140
|
+
const { url, embed: given, onError, height, visual, color, autoPlay, hideRelated, showComments, showUser, showReposts, showTeaser, showArtwork, ...frame } = props;
|
|
1141
|
+
const { embed, error } = resolveEmbed(url, given, "soundcloud");
|
|
1142
|
+
useReportError(error, onError);
|
|
1143
|
+
if (!embed) return null;
|
|
1144
|
+
const values = {
|
|
1145
|
+
visual,
|
|
1146
|
+
color,
|
|
1147
|
+
autoPlay,
|
|
1148
|
+
hideRelated,
|
|
1149
|
+
showComments,
|
|
1150
|
+
showUser,
|
|
1151
|
+
showReposts,
|
|
1152
|
+
showTeaser,
|
|
1153
|
+
showArtwork
|
|
1154
|
+
};
|
|
1155
|
+
const fromProps = [];
|
|
1156
|
+
for (const [prop, name] of Object.entries(PARAMS$4)) {
|
|
1157
|
+
const value = values[prop];
|
|
1158
|
+
if (value !== void 0) fromProps.push([name, value]);
|
|
1159
|
+
}
|
|
1160
|
+
const fromUrl = embed.size === void 0;
|
|
1161
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
1162
|
+
...frame,
|
|
1163
|
+
onError,
|
|
1164
|
+
height: height ?? embed.size?.height ?? URL_HEIGHT,
|
|
1165
|
+
src: `https://w.soundcloud.com/player/${query([["url", embed.url]], fromUrl ? [["visual", true]] : void 0, optionsWithout(embed.options, ["url", "secret_token"]), fromProps)}`,
|
|
1166
|
+
title: "SoundCloud player",
|
|
1167
|
+
allow: ALLOW$4,
|
|
1168
|
+
scrolling: "no",
|
|
1169
|
+
ratio: {
|
|
1170
|
+
width: 16,
|
|
1171
|
+
height: 9
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
951
1175
|
// src/components/spotify-embed.tsx
|
|
952
1176
|
const ALLOW$3 = "autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture";
|
|
953
1177
|
const COMPACT = /* @__PURE__ */ new Set(["track", "episode"]);
|
|
@@ -1123,6 +1347,41 @@ function TikTokEmbed(props) {
|
|
|
1123
1347
|
size: embed.size
|
|
1124
1348
|
});
|
|
1125
1349
|
}
|
|
1350
|
+
// src/components/tumblr-embed.tsx
|
|
1351
|
+
/** The frame posts a JSON string once it has painted (docs/decisions.md D74). */
|
|
1352
|
+
const TUMBLR_HEIGHT = {
|
|
1353
|
+
origin: "https://embed.tumblr.com",
|
|
1354
|
+
read(data) {
|
|
1355
|
+
if (typeof data !== "string") return void 0;
|
|
1356
|
+
const message = JSON.parse(data);
|
|
1357
|
+
const [height] = Array.isArray(message.args) ? message.args : [];
|
|
1358
|
+
return message.method === "tumblr-post:sizeChange" && typeof height === "number" ? height : void 0;
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
const START_HEIGHT = 400;
|
|
1362
|
+
/** At most 540px wide by default, Tumblr's oEmbed width. Renders the frame `post.js` would create (docs/decisions.md D77). */
|
|
1363
|
+
function TumblrEmbed(props) {
|
|
1364
|
+
const { url, embed: given, onError, maxWidth = 540, ...shared } = props;
|
|
1365
|
+
const { embed, error } = resolveEmbed(url, given, "tumblr");
|
|
1366
|
+
useReportError(error, onError);
|
|
1367
|
+
if (!embed) return null;
|
|
1368
|
+
const blog = embed.url.slice(23).split("/")[0] ?? "";
|
|
1369
|
+
return /* @__PURE__ */ jsx(IframeEmbed, {
|
|
1370
|
+
...shared,
|
|
1371
|
+
onError,
|
|
1372
|
+
maxWidth,
|
|
1373
|
+
src: `https://embed.tumblr.com/embed/post/${blog}/${embed.id}/v2`,
|
|
1374
|
+
title: "Tumblr post",
|
|
1375
|
+
allow: "",
|
|
1376
|
+
scrolling: "no",
|
|
1377
|
+
ratio: {
|
|
1378
|
+
width: 1,
|
|
1379
|
+
height: 1
|
|
1380
|
+
},
|
|
1381
|
+
messageHeight: TUMBLR_HEIGHT,
|
|
1382
|
+
startHeight: START_HEIGHT
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1126
1385
|
// src/components/twitch-embed.tsx
|
|
1127
1386
|
const RESERVED = [
|
|
1128
1387
|
"channel",
|
|
@@ -1339,7 +1598,7 @@ function SocialEmbed(props) {
|
|
|
1339
1598
|
maxHeight
|
|
1340
1599
|
};
|
|
1341
1600
|
const embed = useMemo(() => html !== void 0 ? parseEmbed(html) : matchUrl(url), [html, url]);
|
|
1342
|
-
useReportError(embed === null && !(html !== void 0 && fallback) ? html !== void 0 ? "social-embeds: unrecognised embed code" : `social-embeds: not a supported post URL: ${url}` : void 0, onError);
|
|
1601
|
+
useReportError(embed === null && !(html !== void 0 && fallback) ? html !== void 0 ? "social-embeds: unrecognised embed code" : needsLookup(url) === "bluesky" ? "social-embeds: a Bluesky URL needs a lookup: use the embed code" : `social-embeds: not a supported post URL: ${url}` : void 0, onError);
|
|
1343
1602
|
if (!embed) return html !== void 0 && fallback ? fallback(html) : null;
|
|
1344
1603
|
switch (embed.platform) {
|
|
1345
1604
|
case "x": return /* @__PURE__ */ jsx(XEmbed, {
|
|
@@ -1426,6 +1685,46 @@ function SocialEmbed(props) {
|
|
|
1426
1685
|
onError,
|
|
1427
1686
|
embed
|
|
1428
1687
|
});
|
|
1688
|
+
case "bluesky": return /* @__PURE__ */ jsx(BlueskyEmbed, {
|
|
1689
|
+
...shared,
|
|
1690
|
+
onError,
|
|
1691
|
+
embed
|
|
1692
|
+
});
|
|
1693
|
+
case "soundcloud": return /* @__PURE__ */ jsx(SoundCloudEmbed, {
|
|
1694
|
+
...shared,
|
|
1695
|
+
...frame,
|
|
1696
|
+
onError,
|
|
1697
|
+
embed
|
|
1698
|
+
});
|
|
1699
|
+
case "applemusic": return /* @__PURE__ */ jsx(AppleMusicEmbed, {
|
|
1700
|
+
...shared,
|
|
1701
|
+
...frame,
|
|
1702
|
+
onError,
|
|
1703
|
+
embed
|
|
1704
|
+
});
|
|
1705
|
+
case "applepodcasts": return /* @__PURE__ */ jsx(ApplePodcastsEmbed, {
|
|
1706
|
+
...shared,
|
|
1707
|
+
...frame,
|
|
1708
|
+
onError,
|
|
1709
|
+
embed
|
|
1710
|
+
});
|
|
1711
|
+
case "tumblr": return /* @__PURE__ */ jsx(TumblrEmbed, {
|
|
1712
|
+
...shared,
|
|
1713
|
+
onError,
|
|
1714
|
+
embed
|
|
1715
|
+
});
|
|
1716
|
+
case "kick": return /* @__PURE__ */ jsx(KickEmbed, {
|
|
1717
|
+
...shared,
|
|
1718
|
+
...frame,
|
|
1719
|
+
onError,
|
|
1720
|
+
embed
|
|
1721
|
+
});
|
|
1722
|
+
case "giphy": return /* @__PURE__ */ jsx(GiphyEmbed, {
|
|
1723
|
+
...shared,
|
|
1724
|
+
...frame,
|
|
1725
|
+
onError,
|
|
1726
|
+
embed
|
|
1727
|
+
});
|
|
1429
1728
|
}
|
|
1430
1729
|
}
|
|
1431
|
-
export { DailymotionEmbed, FacebookEmbed, InstagramEmbed, LinkedInEmbed, PinterestEmbed, RedditEmbed, SnapchatEmbed, SocialEmbed, SpotifyEmbed, TelegramEmbed, ThreadsEmbed, TikTokEmbed, TwitchEmbed, VimeoEmbed, XEmbed, YouTubeEmbed };
|
|
1730
|
+
export { AppleMusicEmbed, ApplePodcastsEmbed, BlueskyEmbed, DailymotionEmbed, FacebookEmbed, GiphyEmbed, InstagramEmbed, KickEmbed, LinkedInEmbed, PinterestEmbed, RedditEmbed, SnapchatEmbed, SocialEmbed, SoundCloudEmbed, SpotifyEmbed, TelegramEmbed, ThreadsEmbed, TikTokEmbed, TumblrEmbed, TwitchEmbed, VimeoEmbed, XEmbed, YouTubeEmbed };
|