@automattic/social-previews 3.2.5 → 3.3.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.
@@ -0,0 +1,387 @@
1
+ //#region src/helpers.d.ts
2
+ /**
3
+ * An editor hyperlink: the visible anchor text and the URL it points to.
4
+ */
5
+ type Hyperlink = {
6
+ text: string;
7
+ href: string;
8
+ /**
9
+ * Zero-based index of this anchor among identical occurrences of `text` in
10
+ * the content, so repeated texts link the right duplicate. Defaults to 0.
11
+ */
12
+ occurrence?: number;
13
+ };
14
+ /**
15
+ * Extracts `(text, href)` pairs from `<a href="…">text</a>` in HTML, skipping
16
+ * autolinks (text already equals the URL) and non-http(s) hrefs. Mirrors the
17
+ * backend `ExtractorUtils::get_anchor_links_from_html` so the preview links the
18
+ * same anchors the published share will.
19
+ *
20
+ * @param html - Raw post content HTML.
21
+ * @return The editor hyperlinks found, in document order.
22
+ */
23
+ declare function parseHyperlinks(html: string): Hyperlink[];
24
+ //#endregion
25
+ //#region src/shared/section-heading/index.d.ts
26
+ declare const HEADING_LEVELS: readonly [2, 3, 4, 5, 6];
27
+ type SectionHeadingProps = {
28
+ className?: string;
29
+ level?: (typeof HEADING_LEVELS)[number];
30
+ children?: React.ReactNode;
31
+ };
32
+ //#endregion
33
+ //#region src/types.d.ts
34
+ interface SocialPreviewBaseProps {
35
+ /**
36
+ * The URL of the post/page to preview.
37
+ */
38
+ url: string;
39
+ /**
40
+ * Editor hyperlinks rendered over the matching body text on the networks
41
+ * that support inline links (Bluesky, Tumblr). Other networks ignore this.
42
+ */
43
+ hyperlinks?: Hyperlink[];
44
+ /**
45
+ * The title of the post/page to preview.
46
+ */
47
+ title: string;
48
+ /**
49
+ * The description of the post/page to preview.
50
+ */
51
+ description?: string;
52
+ /**
53
+ * The URL of the image to use in the post/page preview.
54
+ */
55
+ image?: string;
56
+ /**
57
+ * The focal point of the link-preview image (`image`/`customImage`), both
58
+ * axes 0-1. When set, the preview crops around this point via
59
+ * `object-position`. Omitted → centered, matching today's behavior.
60
+ */
61
+ imageFocalPoint?: FocalPoint;
62
+ /**
63
+ * The array of media items to use in the preview.
64
+ */
65
+ media?: Array<MediaItem>;
66
+ /**
67
+ * The caption.
68
+ */
69
+ caption?: string;
70
+ }
71
+ interface SocialPreviewsBaseProps {
72
+ /**
73
+ * The heading level to use for the preview section title
74
+ */
75
+ headingLevel?: SectionHeadingProps['level'];
76
+ /**
77
+ * Whether to hide the "Your post" section
78
+ */
79
+ hidePostPreview?: boolean;
80
+ /**
81
+ * Whether to hide the "Link preview" section
82
+ */
83
+ hideLinkPreview?: boolean;
84
+ }
85
+ /**
86
+ * A focal point on an image. Both axes are 0-1, where `{ x: 0, y: 0 }` is the
87
+ * top-left corner and `{ x: 1, y: 1 }` is the bottom-right.
88
+ */
89
+ type FocalPoint = {
90
+ x: number;
91
+ y: number;
92
+ };
93
+ type MediaItem = {
94
+ /**
95
+ * The alt text for the image.
96
+ */
97
+ alt?: string;
98
+ /**
99
+ * The mime type of the media
100
+ */
101
+ type: string;
102
+ /**
103
+ * The URL of the media.
104
+ */
105
+ url: string;
106
+ };
107
+ //#endregion
108
+ //#region src/google-search-preview/index.d.ts
109
+ type GoogleSearchPreviewProps = Omit<SocialPreviewBaseProps, 'image'> & {
110
+ siteIcon?: string;
111
+ siteTitle?: string;
112
+ };
113
+ declare const GoogleSearchPreview: React.FC<Partial<GoogleSearchPreviewProps>>;
114
+ //#endregion
115
+ //#region src/twitter-preview/types.d.ts
116
+ type TwitterPreviewsProps = SocialPreviewsBaseProps & {
117
+ tweets: Array<TwitterPreviewProps>;
118
+ };
119
+ type TwitterCardProps = SocialPreviewBaseProps & {
120
+ cardType: string;
121
+ };
122
+ type SidebarProps$1 = {
123
+ showThreadConnector?: boolean;
124
+ profileImage?: string;
125
+ };
126
+ type HeaderProps$1 = {
127
+ name?: string;
128
+ date?: Date | number;
129
+ screenName?: string;
130
+ };
131
+ type QuoteTweetProps = {
132
+ tweetUrl: string;
133
+ };
134
+ type TextProps = {
135
+ text: string;
136
+ };
137
+ type TwitterPreviewProps = SidebarProps$1 & HeaderProps$1 & Partial<QuoteTweetProps & TwitterCardProps & Pick<TextProps, 'text'>>;
138
+ //#endregion
139
+ //#region src/twitter-preview/link-preview.d.ts
140
+ declare const TwitterLinkPreview: React.FC<TwitterPreviewProps>;
141
+ //#endregion
142
+ //#region src/twitter-preview/post-preview.d.ts
143
+ declare const TwitterPostPreview: React.FC<TwitterPreviewProps>;
144
+ //#endregion
145
+ //#region src/twitter-preview/previews.d.ts
146
+ declare const TwitterPreviews: React.FC<TwitterPreviewsProps>;
147
+ //#endregion
148
+ //#region src/linkedin-preview/types.d.ts
149
+ type LinkedInPreviewProps = SocialPreviewBaseProps & {
150
+ jobTitle?: string;
151
+ name: string;
152
+ profileImage: string;
153
+ articleReadTime?: number;
154
+ };
155
+ type LinkedInPreviewsProps = LinkedInPreviewProps & SocialPreviewsBaseProps;
156
+ //#endregion
157
+ //#region src/linkedin-preview/link-preview.d.ts
158
+ type OptionalProps$1 = Partial<Pick<LinkedInPreviewProps, 'name' | 'profileImage'>>;
159
+ type LinkedInLinkPreviewProps = Omit<LinkedInPreviewProps, keyof OptionalProps$1> & OptionalProps$1;
160
+ /**
161
+ * LinkedIn Link Preview Component
162
+ * @param {LinkedInLinkPreviewProps} props - The props for the LinkedIn link preview.
163
+ * @return The LinkedIn link preview component.
164
+ */
165
+ declare function LinkedInLinkPreview(props: LinkedInLinkPreviewProps): import("react/jsx-runtime").JSX.Element;
166
+ //#endregion
167
+ //#region src/linkedin-preview/post-preview.d.ts
168
+ /**
169
+ * LinkedIn Post Preview Component
170
+ *
171
+ * @param {LinkedInPreviewProps} props - The props for the LinkedIn post preview.
172
+ *
173
+ * @return The LinkedIn post preview component.
174
+ */
175
+ declare function LinkedInPostPreview({
176
+ articleReadTime,
177
+ image,
178
+ imageFocalPoint,
179
+ jobTitle,
180
+ name,
181
+ profileImage,
182
+ description,
183
+ media,
184
+ title,
185
+ url
186
+ }: LinkedInPreviewProps): import("react/jsx-runtime").JSX.Element;
187
+ //#endregion
188
+ //#region src/linkedin-preview/previews.d.ts
189
+ declare const LinkedInPreviews: React.FC<LinkedInPreviewsProps>;
190
+ //#endregion
191
+ //#region src/tumblr-preview/types.d.ts
192
+ type TumblrUser = {
193
+ displayName: string;
194
+ avatarUrl?: string;
195
+ };
196
+ type TumblrPreviewProps = SocialPreviewBaseProps & {
197
+ user?: TumblrUser;
198
+ };
199
+ //#endregion
200
+ //#region src/tumblr-preview/link-preview.d.ts
201
+ declare const TumblrLinkPreview: React.FC<TumblrPreviewProps>;
202
+ //#endregion
203
+ //#region src/tumblr-preview/post-preview.d.ts
204
+ declare const TumblrPostPreview: React.FC<TumblrPreviewProps>;
205
+ //#endregion
206
+ //#region src/tumblr-preview/previews.d.ts
207
+ type TumblrPreviewsProps = TumblrPreviewProps & SocialPreviewsBaseProps;
208
+ declare const TumblrPreviews: React.FC<TumblrPreviewsProps>;
209
+ //#endregion
210
+ //#region src/constants.d.ts
211
+ declare const AUTO_SHARED_SOCIAL_POST_PREVIEW = "AUTO_SHARED_SOCIAL_POST_PREVIEW";
212
+ declare const AUTO_SHARED_LINK_PREVIEW = "AUTO_SHARED_LINK_PREVIEW";
213
+ declare const DEFAULT_LINK_PREVIEW = "DEFAULT_LINK_PREVIEW";
214
+ declare const TYPE_WEBSITE = "website";
215
+ declare const TYPE_ARTICLE = "article";
216
+ declare const LANDSCAPE_MODE = "landscape";
217
+ declare const PORTRAIT_MODE = "portrait";
218
+ //#endregion
219
+ //#region src/facebook-preview/types.d.ts
220
+ type ImageMode = typeof LANDSCAPE_MODE | typeof PORTRAIT_MODE;
221
+ type FacebookUser = {
222
+ displayName: string;
223
+ avatarUrl?: string;
224
+ };
225
+ type FacebookPreviewProps = SocialPreviewBaseProps & {
226
+ user?: FacebookUser;
227
+ type?: typeof TYPE_WEBSITE | typeof TYPE_ARTICLE;
228
+ customText?: string;
229
+ customImage?: string;
230
+ imageMode?: ImageMode;
231
+ };
232
+ //#endregion
233
+ //#region src/facebook-preview/previews.d.ts
234
+ type FacebookPreviewsProps = FacebookPreviewProps & SocialPreviewsBaseProps;
235
+ declare const FacebookPreviews: React.FC<FacebookPreviewsProps>;
236
+ //#endregion
237
+ //#region src/facebook-preview/link-preview.d.ts
238
+ type FacebookLinkPreviewProps = FacebookPreviewProps & {
239
+ compactDescription?: boolean;
240
+ };
241
+ declare const FacebookLinkPreview: React.FC<FacebookLinkPreviewProps>;
242
+ //#endregion
243
+ //#region src/facebook-preview/post-preview.d.ts
244
+ declare const FacebookPostPreview: React.FC<FacebookPreviewProps>;
245
+ //#endregion
246
+ //#region src/mastodon-preview/types.d.ts
247
+ type MastodonUser = {
248
+ displayName: string;
249
+ avatarUrl: string;
250
+ address: string;
251
+ };
252
+ type MastodonPreviewProps = SocialPreviewBaseProps & {
253
+ user?: MastodonUser;
254
+ customText?: string;
255
+ customImage?: string;
256
+ siteName?: string;
257
+ };
258
+ //#endregion
259
+ //#region src/mastodon-preview/link-preview.d.ts
260
+ declare const MastodonLinkPreview: React.FC<MastodonPreviewProps>;
261
+ //#endregion
262
+ //#region src/mastodon-preview/post-preview.d.ts
263
+ declare const MastodonPostPreview: React.FC<MastodonPreviewProps>;
264
+ //#endregion
265
+ //#region src/mastodon-preview/previews.d.ts
266
+ type MastodonPreviewsProps = MastodonPreviewProps & SocialPreviewsBaseProps;
267
+ declare const MastodonPreviews: React.FC<MastodonPreviewsProps>;
268
+ //#endregion
269
+ //#region src/nextdoor-preview/types.d.ts
270
+ type NextdoorPreviewProps = SocialPreviewBaseProps & {
271
+ neighborhood?: string;
272
+ name: string;
273
+ profileImage: string;
274
+ };
275
+ type NextdoorPreviewsProps = NextdoorPreviewProps & SocialPreviewsBaseProps;
276
+ //#endregion
277
+ //#region src/nextdoor-preview/link-preview.d.ts
278
+ type OptionalProps = Partial<Pick<NextdoorPreviewProps, 'name' | 'profileImage'>>;
279
+ type NextdoorLinkPreviewProps = Omit<NextdoorPreviewProps, keyof OptionalProps> & OptionalProps;
280
+ /**
281
+ * Nextdoor Link Preview Component
282
+ *
283
+ * @param {NextdoorLinkPreviewProps} props - The props for the Nextdoor link preview.
284
+ *
285
+ * @return The Nextdoor link preview component.
286
+ */
287
+ declare function NextdoorLinkPreview(props: NextdoorLinkPreviewProps): import("react/jsx-runtime").JSX.Element;
288
+ //#endregion
289
+ //#region src/nextdoor-preview/post-preview.d.ts
290
+ /**
291
+ * Nextdoor Post Preview Component.
292
+ *
293
+ * @param {NextdoorPreviewProps} props - The preview properties.
294
+ * @return The Nextdoor post preview component.
295
+ */
296
+ declare function NextdoorPostPreview({
297
+ image,
298
+ imageFocalPoint,
299
+ name,
300
+ profileImage,
301
+ description,
302
+ neighborhood,
303
+ media,
304
+ title,
305
+ url
306
+ }: NextdoorPreviewProps): import("react/jsx-runtime").JSX.Element;
307
+ //#endregion
308
+ //#region src/nextdoor-preview/previews.d.ts
309
+ declare const NextdoorPreviews: React.FC<NextdoorPreviewsProps>;
310
+ //#endregion
311
+ //#region src/bluesky-preview/types.d.ts
312
+ type BlueskyUser = {
313
+ displayName: string;
314
+ avatarUrl: string;
315
+ address: string;
316
+ };
317
+ type BlueskyPreviewProps = SocialPreviewBaseProps & {
318
+ appendUrl?: boolean;
319
+ user?: BlueskyUser;
320
+ customText?: string;
321
+ customImage?: string;
322
+ };
323
+ //#endregion
324
+ //#region src/bluesky-preview/link-preview.d.ts
325
+ declare const BlueskyLinkPreview: React.FC<BlueskyPreviewProps>;
326
+ //#endregion
327
+ //#region src/bluesky-preview/post-preview.d.ts
328
+ declare const BlueskyPostPreview: React.FC<BlueskyPreviewProps>;
329
+ //#endregion
330
+ //#region src/bluesky-preview/previews.d.ts
331
+ type BlueskyPreviewsProps = BlueskyPreviewProps & SocialPreviewsBaseProps;
332
+ declare const BlueskyPreviews: React.FC<BlueskyPreviewsProps>;
333
+ //#endregion
334
+ //#region src/threads-preview/types.d.ts
335
+ type ThreadsPreviewsProps = SocialPreviewsBaseProps & {
336
+ posts: Array<ThreadsPreviewProps>;
337
+ };
338
+ type ThreadsCardProps = Omit<SocialPreviewBaseProps, 'description'>;
339
+ type SidebarProps = {
340
+ showThreadConnector?: boolean;
341
+ profileImage?: string;
342
+ };
343
+ type HeaderProps = {
344
+ name?: string;
345
+ date?: Date;
346
+ };
347
+ type ThreadsPreviewProps = SidebarProps & HeaderProps & Partial<ThreadsCardProps>;
348
+ //#endregion
349
+ //#region src/threads-preview/link-preview.d.ts
350
+ declare const ThreadsLinkPreview: React.FC<ThreadsPreviewProps>;
351
+ //#endregion
352
+ //#region src/threads-preview/post-preview.d.ts
353
+ declare const ThreadsPostPreview: React.FC<ThreadsPreviewProps>;
354
+ //#endregion
355
+ //#region src/threads-preview/previews.d.ts
356
+ declare const ThreadsPreviews: React.FC<ThreadsPreviewsProps>;
357
+ //#endregion
358
+ //#region src/instagram-preview/types.d.ts
359
+ type InstagramPreviewProps = Pick<SocialPreviewBaseProps, 'image' | 'imageFocalPoint' | 'media' | 'url'> & {
360
+ name: string;
361
+ profileImage: string;
362
+ caption?: string;
363
+ };
364
+ type InstagramPreviewsProps = InstagramPreviewProps & SocialPreviewsBaseProps;
365
+ //#endregion
366
+ //#region src/instagram-preview/post-preview.d.ts
367
+ /**
368
+ * Instagram Post Preview Component
369
+ *
370
+ * @param {InstagramPreviewProps} props - The props for the Instagram post preview.
371
+ *
372
+ * @return The Instagram post preview component.
373
+ */
374
+ declare function InstagramPostPreview({
375
+ image,
376
+ imageFocalPoint,
377
+ media,
378
+ name,
379
+ profileImage,
380
+ caption
381
+ }: InstagramPreviewProps): import("react/jsx-runtime").JSX.Element;
382
+ //#endregion
383
+ //#region src/instagram-preview/previews.d.ts
384
+ declare const InstagramPreviews: React.FC<InstagramPreviewsProps>;
385
+ //#endregion
386
+ export { AUTO_SHARED_LINK_PREVIEW, AUTO_SHARED_SOCIAL_POST_PREVIEW, BlueskyLinkPreview, BlueskyPostPreview, BlueskyPreviews, BlueskyPreviewsProps, DEFAULT_LINK_PREVIEW, FacebookLinkPreview, FacebookLinkPreviewProps, FacebookPostPreview, FacebookPreviews, FacebookPreviewsProps, FocalPoint, GoogleSearchPreview, GoogleSearchPreviewProps, type Hyperlink, InstagramPostPreview, InstagramPreviews, LANDSCAPE_MODE, LinkedInLinkPreview, LinkedInLinkPreviewProps, LinkedInPostPreview, LinkedInPreviews, MastodonLinkPreview, MastodonPostPreview, MastodonPreviews, MastodonPreviewsProps, MediaItem, NextdoorLinkPreview, NextdoorLinkPreviewProps, NextdoorPostPreview, NextdoorPreviews, PORTRAIT_MODE, SocialPreviewBaseProps, SocialPreviewsBaseProps, TYPE_ARTICLE, TYPE_WEBSITE, ThreadsLinkPreview, ThreadsPostPreview, ThreadsPreviews, TumblrLinkPreview, TumblrPostPreview, TumblrPreviews, TumblrPreviewsProps, TwitterLinkPreview, TwitterPostPreview, TwitterPreviews, parseHyperlinks };
387
+ //# sourceMappingURL=index.d.cts.map