@automattic/social-previews 3.2.4 → 3.3.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/dist/index.d.mts CHANGED
@@ -1,110 +1,160 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
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
3
26
  declare const HEADING_LEVELS: readonly [2, 3, 4, 5, 6];
4
27
  type SectionHeadingProps = {
5
- className?: string;
6
- level?: (typeof HEADING_LEVELS)[number];
7
- children?: React.ReactNode;
28
+ className?: string;
29
+ level?: (typeof HEADING_LEVELS)[number];
30
+ children?: React.ReactNode;
8
31
  };
9
-
32
+ //#endregion
33
+ //#region src/types.d.ts
10
34
  interface SocialPreviewBaseProps {
11
- /**
12
- * The URL of the post/page to preview.
13
- */
14
- url: string;
15
- /**
16
- * The title of the post/page to preview.
17
- */
18
- title: string;
19
- /**
20
- * The description of the post/page to preview.
21
- */
22
- description?: string;
23
- /**
24
- * The URL of the image to use in the post/page preview.
25
- */
26
- image?: string;
27
- /**
28
- * The array of media items to use in the preview.
29
- */
30
- media?: Array<MediaItem>;
31
- /**
32
- * The caption.
33
- */
34
- caption?: string;
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;
35
70
  }
36
71
  interface SocialPreviewsBaseProps {
37
- /**
38
- * The heading level to use for the preview section title
39
- */
40
- headingLevel?: SectionHeadingProps['level'];
41
- /**
42
- * Whether to hide the "Your post" section
43
- */
44
- hidePostPreview?: boolean;
45
- /**
46
- * Whether to hide the "Link preview" section
47
- */
48
- hideLinkPreview?: boolean;
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;
49
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
+ };
50
93
  type MediaItem = {
51
- /**
52
- * The alt text for the image.
53
- */
54
- alt?: string;
55
- /**
56
- * The mime type of the media
57
- */
58
- type: string;
59
- /**
60
- * The URL of the media.
61
- */
62
- url: string;
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;
63
106
  };
64
-
107
+ //#endregion
108
+ //#region src/google-search-preview/index.d.ts
65
109
  type GoogleSearchPreviewProps = Omit<SocialPreviewBaseProps, 'image'> & {
66
- siteIcon?: string;
67
- siteTitle?: string;
110
+ siteIcon?: string;
111
+ siteTitle?: string;
68
112
  };
69
113
  declare const GoogleSearchPreview: React.FC<Partial<GoogleSearchPreviewProps>>;
70
-
114
+ //#endregion
115
+ //#region src/twitter-preview/types.d.ts
71
116
  type TwitterPreviewsProps = SocialPreviewsBaseProps & {
72
- tweets: Array<TwitterPreviewProps>;
117
+ tweets: Array<TwitterPreviewProps>;
73
118
  };
74
119
  type TwitterCardProps = SocialPreviewBaseProps & {
75
- cardType: string;
120
+ cardType: string;
76
121
  };
77
122
  type SidebarProps$1 = {
78
- showThreadConnector?: boolean;
79
- profileImage?: string;
123
+ showThreadConnector?: boolean;
124
+ profileImage?: string;
80
125
  };
81
126
  type HeaderProps$1 = {
82
- name?: string;
83
- date?: Date | number;
84
- screenName?: string;
127
+ name?: string;
128
+ date?: Date | number;
129
+ screenName?: string;
85
130
  };
86
131
  type QuoteTweetProps = {
87
- tweetUrl: string;
132
+ tweetUrl: string;
88
133
  };
89
134
  type TextProps = {
90
- text: string;
135
+ text: string;
91
136
  };
92
137
  type TwitterPreviewProps = SidebarProps$1 & HeaderProps$1 & Partial<QuoteTweetProps & TwitterCardProps & Pick<TextProps, 'text'>>;
93
-
138
+ //#endregion
139
+ //#region src/twitter-preview/link-preview.d.ts
94
140
  declare const TwitterLinkPreview: React.FC<TwitterPreviewProps>;
95
-
141
+ //#endregion
142
+ //#region src/twitter-preview/post-preview.d.ts
96
143
  declare const TwitterPostPreview: React.FC<TwitterPreviewProps>;
97
-
144
+ //#endregion
145
+ //#region src/twitter-preview/previews.d.ts
98
146
  declare const TwitterPreviews: React.FC<TwitterPreviewsProps>;
99
-
147
+ //#endregion
148
+ //#region src/linkedin-preview/types.d.ts
100
149
  type LinkedInPreviewProps = SocialPreviewBaseProps & {
101
- jobTitle?: string;
102
- name: string;
103
- profileImage: string;
104
- articleReadTime?: number;
150
+ jobTitle?: string;
151
+ name: string;
152
+ profileImage: string;
153
+ articleReadTime?: number;
105
154
  };
106
155
  type LinkedInPreviewsProps = LinkedInPreviewProps & SocialPreviewsBaseProps;
107
-
156
+ //#endregion
157
+ //#region src/linkedin-preview/link-preview.d.ts
108
158
  type OptionalProps$1 = Partial<Pick<LinkedInPreviewProps, 'name' | 'profileImage'>>;
109
159
  type LinkedInLinkPreviewProps = Omit<LinkedInPreviewProps, keyof OptionalProps$1> & OptionalProps$1;
110
160
  /**
@@ -112,8 +162,9 @@ type LinkedInLinkPreviewProps = Omit<LinkedInPreviewProps, keyof OptionalProps$1
112
162
  * @param {LinkedInLinkPreviewProps} props - The props for the LinkedIn link preview.
113
163
  * @return The LinkedIn link preview component.
114
164
  */
115
- declare function LinkedInLinkPreview(props: LinkedInLinkPreviewProps): react_jsx_runtime.JSX.Element;
116
-
165
+ declare function LinkedInLinkPreview(props: LinkedInLinkPreviewProps): import("react/jsx-runtime").JSX.Element;
166
+ //#endregion
167
+ //#region src/linkedin-preview/post-preview.d.ts
117
168
  /**
118
169
  * LinkedIn Post Preview Component
119
170
  *
@@ -121,25 +172,42 @@ declare function LinkedInLinkPreview(props: LinkedInLinkPreviewProps): react_jsx
121
172
  *
122
173
  * @return The LinkedIn post preview component.
123
174
  */
124
- declare function LinkedInPostPreview({ articleReadTime, image, jobTitle, name, profileImage, description, media, title, url, }: LinkedInPreviewProps): react_jsx_runtime.JSX.Element;
125
-
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
126
189
  declare const LinkedInPreviews: React.FC<LinkedInPreviewsProps>;
127
-
190
+ //#endregion
191
+ //#region src/tumblr-preview/types.d.ts
128
192
  type TumblrUser = {
129
- displayName: string;
130
- avatarUrl?: string;
193
+ displayName: string;
194
+ avatarUrl?: string;
131
195
  };
132
196
  type TumblrPreviewProps = SocialPreviewBaseProps & {
133
- user?: TumblrUser;
197
+ user?: TumblrUser;
134
198
  };
135
-
199
+ //#endregion
200
+ //#region src/tumblr-preview/link-preview.d.ts
136
201
  declare const TumblrLinkPreview: React.FC<TumblrPreviewProps>;
137
-
202
+ //#endregion
203
+ //#region src/tumblr-preview/post-preview.d.ts
138
204
  declare const TumblrPostPreview: React.FC<TumblrPreviewProps>;
139
-
205
+ //#endregion
206
+ //#region src/tumblr-preview/previews.d.ts
140
207
  type TumblrPreviewsProps = TumblrPreviewProps & SocialPreviewsBaseProps;
141
208
  declare const TumblrPreviews: React.FC<TumblrPreviewsProps>;
142
-
209
+ //#endregion
210
+ //#region src/constants.d.ts
143
211
  declare const AUTO_SHARED_SOCIAL_POST_PREVIEW = "AUTO_SHARED_SOCIAL_POST_PREVIEW";
144
212
  declare const AUTO_SHARED_LINK_PREVIEW = "AUTO_SHARED_LINK_PREVIEW";
145
213
  declare const DEFAULT_LINK_PREVIEW = "DEFAULT_LINK_PREVIEW";
@@ -147,56 +215,66 @@ declare const TYPE_WEBSITE = "website";
147
215
  declare const TYPE_ARTICLE = "article";
148
216
  declare const LANDSCAPE_MODE = "landscape";
149
217
  declare const PORTRAIT_MODE = "portrait";
150
-
218
+ //#endregion
219
+ //#region src/facebook-preview/types.d.ts
151
220
  type ImageMode = typeof LANDSCAPE_MODE | typeof PORTRAIT_MODE;
152
221
  type FacebookUser = {
153
- displayName: string;
154
- avatarUrl?: string;
222
+ displayName: string;
223
+ avatarUrl?: string;
155
224
  };
156
225
  type FacebookPreviewProps = SocialPreviewBaseProps & {
157
- user?: FacebookUser;
158
- type?: typeof TYPE_WEBSITE | typeof TYPE_ARTICLE;
159
- customText?: string;
160
- customImage?: string;
161
- imageMode?: ImageMode;
226
+ user?: FacebookUser;
227
+ type?: typeof TYPE_WEBSITE | typeof TYPE_ARTICLE;
228
+ customText?: string;
229
+ customImage?: string;
230
+ imageMode?: ImageMode;
162
231
  };
163
-
232
+ //#endregion
233
+ //#region src/facebook-preview/previews.d.ts
164
234
  type FacebookPreviewsProps = FacebookPreviewProps & SocialPreviewsBaseProps;
165
235
  declare const FacebookPreviews: React.FC<FacebookPreviewsProps>;
166
-
236
+ //#endregion
237
+ //#region src/facebook-preview/link-preview.d.ts
167
238
  type FacebookLinkPreviewProps = FacebookPreviewProps & {
168
- compactDescription?: boolean;
239
+ compactDescription?: boolean;
169
240
  };
170
241
  declare const FacebookLinkPreview: React.FC<FacebookLinkPreviewProps>;
171
-
242
+ //#endregion
243
+ //#region src/facebook-preview/post-preview.d.ts
172
244
  declare const FacebookPostPreview: React.FC<FacebookPreviewProps>;
173
-
245
+ //#endregion
246
+ //#region src/mastodon-preview/types.d.ts
174
247
  type MastodonUser = {
175
- displayName: string;
176
- avatarUrl: string;
177
- address: string;
248
+ displayName: string;
249
+ avatarUrl: string;
250
+ address: string;
178
251
  };
179
252
  type MastodonPreviewProps = SocialPreviewBaseProps & {
180
- user?: MastodonUser;
181
- customText?: string;
182
- customImage?: string;
183
- siteName?: string;
253
+ user?: MastodonUser;
254
+ customText?: string;
255
+ customImage?: string;
256
+ siteName?: string;
184
257
  };
185
-
258
+ //#endregion
259
+ //#region src/mastodon-preview/link-preview.d.ts
186
260
  declare const MastodonLinkPreview: React.FC<MastodonPreviewProps>;
187
-
261
+ //#endregion
262
+ //#region src/mastodon-preview/post-preview.d.ts
188
263
  declare const MastodonPostPreview: React.FC<MastodonPreviewProps>;
189
-
264
+ //#endregion
265
+ //#region src/mastodon-preview/previews.d.ts
190
266
  type MastodonPreviewsProps = MastodonPreviewProps & SocialPreviewsBaseProps;
191
267
  declare const MastodonPreviews: React.FC<MastodonPreviewsProps>;
192
-
268
+ //#endregion
269
+ //#region src/nextdoor-preview/types.d.ts
193
270
  type NextdoorPreviewProps = SocialPreviewBaseProps & {
194
- neighborhood?: string;
195
- name: string;
196
- profileImage: string;
271
+ neighborhood?: string;
272
+ name: string;
273
+ profileImage: string;
197
274
  };
198
275
  type NextdoorPreviewsProps = NextdoorPreviewProps & SocialPreviewsBaseProps;
199
-
276
+ //#endregion
277
+ //#region src/nextdoor-preview/link-preview.d.ts
200
278
  type OptionalProps = Partial<Pick<NextdoorPreviewProps, 'name' | 'profileImage'>>;
201
279
  type NextdoorLinkPreviewProps = Omit<NextdoorPreviewProps, keyof OptionalProps> & OptionalProps;
202
280
  /**
@@ -206,64 +284,86 @@ type NextdoorLinkPreviewProps = Omit<NextdoorPreviewProps, keyof OptionalProps>
206
284
  *
207
285
  * @return The Nextdoor link preview component.
208
286
  */
209
- declare function NextdoorLinkPreview(props: NextdoorLinkPreviewProps): react_jsx_runtime.JSX.Element;
210
-
287
+ declare function NextdoorLinkPreview(props: NextdoorLinkPreviewProps): import("react/jsx-runtime").JSX.Element;
288
+ //#endregion
289
+ //#region src/nextdoor-preview/post-preview.d.ts
211
290
  /**
212
291
  * Nextdoor Post Preview Component.
213
292
  *
214
293
  * @param {NextdoorPreviewProps} props - The preview properties.
215
294
  * @return The Nextdoor post preview component.
216
295
  */
217
- declare function NextdoorPostPreview({ image, name, profileImage, description, neighborhood, media, title, url, }: NextdoorPreviewProps): react_jsx_runtime.JSX.Element;
218
-
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
219
309
  declare const NextdoorPreviews: React.FC<NextdoorPreviewsProps>;
220
-
310
+ //#endregion
311
+ //#region src/bluesky-preview/types.d.ts
221
312
  type BlueskyUser = {
222
- displayName: string;
223
- avatarUrl: string;
224
- address: string;
313
+ displayName: string;
314
+ avatarUrl: string;
315
+ address: string;
225
316
  };
226
317
  type BlueskyPreviewProps = SocialPreviewBaseProps & {
227
- appendUrl?: boolean;
228
- user?: BlueskyUser;
229
- customText?: string;
230
- customImage?: string;
318
+ appendUrl?: boolean;
319
+ user?: BlueskyUser;
320
+ customText?: string;
321
+ customImage?: string;
231
322
  };
232
-
323
+ //#endregion
324
+ //#region src/bluesky-preview/link-preview.d.ts
233
325
  declare const BlueskyLinkPreview: React.FC<BlueskyPreviewProps>;
234
-
326
+ //#endregion
327
+ //#region src/bluesky-preview/post-preview.d.ts
235
328
  declare const BlueskyPostPreview: React.FC<BlueskyPreviewProps>;
236
-
329
+ //#endregion
330
+ //#region src/bluesky-preview/previews.d.ts
237
331
  type BlueskyPreviewsProps = BlueskyPreviewProps & SocialPreviewsBaseProps;
238
332
  declare const BlueskyPreviews: React.FC<BlueskyPreviewsProps>;
239
-
333
+ //#endregion
334
+ //#region src/threads-preview/types.d.ts
240
335
  type ThreadsPreviewsProps = SocialPreviewsBaseProps & {
241
- posts: Array<ThreadsPreviewProps>;
336
+ posts: Array<ThreadsPreviewProps>;
242
337
  };
243
338
  type ThreadsCardProps = Omit<SocialPreviewBaseProps, 'description'>;
244
339
  type SidebarProps = {
245
- showThreadConnector?: boolean;
246
- profileImage?: string;
340
+ showThreadConnector?: boolean;
341
+ profileImage?: string;
247
342
  };
248
343
  type HeaderProps = {
249
- name?: string;
250
- date?: Date;
344
+ name?: string;
345
+ date?: Date;
251
346
  };
252
347
  type ThreadsPreviewProps = SidebarProps & HeaderProps & Partial<ThreadsCardProps>;
253
-
348
+ //#endregion
349
+ //#region src/threads-preview/link-preview.d.ts
254
350
  declare const ThreadsLinkPreview: React.FC<ThreadsPreviewProps>;
255
-
351
+ //#endregion
352
+ //#region src/threads-preview/post-preview.d.ts
256
353
  declare const ThreadsPostPreview: React.FC<ThreadsPreviewProps>;
257
-
354
+ //#endregion
355
+ //#region src/threads-preview/previews.d.ts
258
356
  declare const ThreadsPreviews: React.FC<ThreadsPreviewsProps>;
259
-
260
- type InstagramPreviewProps = Pick<SocialPreviewBaseProps, 'image' | 'media' | 'url'> & {
261
- name: string;
262
- profileImage: string;
263
- caption?: string;
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;
264
363
  };
265
364
  type InstagramPreviewsProps = InstagramPreviewProps & SocialPreviewsBaseProps;
266
-
365
+ //#endregion
366
+ //#region src/instagram-preview/post-preview.d.ts
267
367
  /**
268
368
  * Instagram Post Preview Component
269
369
  *
@@ -271,8 +371,17 @@ type InstagramPreviewsProps = InstagramPreviewProps & SocialPreviewsBaseProps;
271
371
  *
272
372
  * @return The Instagram post preview component.
273
373
  */
274
- declare function InstagramPostPreview({ image, media, name, profileImage, caption, url, }: InstagramPreviewProps): react_jsx_runtime.JSX.Element;
275
-
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
276
384
  declare const InstagramPreviews: React.FC<InstagramPreviewsProps>;
277
-
278
- export { AUTO_SHARED_LINK_PREVIEW, AUTO_SHARED_SOCIAL_POST_PREVIEW, BlueskyLinkPreview, BlueskyPostPreview, BlueskyPreviews, type BlueskyPreviewsProps, DEFAULT_LINK_PREVIEW, FacebookLinkPreview, type FacebookLinkPreviewProps, FacebookPostPreview, FacebookPreviews, type FacebookPreviewsProps, GoogleSearchPreview, type GoogleSearchPreviewProps, InstagramPostPreview, InstagramPreviews, LANDSCAPE_MODE, LinkedInLinkPreview, type LinkedInLinkPreviewProps, LinkedInPostPreview, LinkedInPreviews, MastodonLinkPreview, MastodonPostPreview, MastodonPreviews, type MastodonPreviewsProps, type MediaItem, NextdoorLinkPreview, type NextdoorLinkPreviewProps, NextdoorPostPreview, NextdoorPreviews, PORTRAIT_MODE, type SocialPreviewBaseProps, type SocialPreviewsBaseProps, TYPE_ARTICLE, TYPE_WEBSITE, ThreadsLinkPreview, ThreadsPostPreview, ThreadsPreviews, TumblrLinkPreview, TumblrPostPreview, TumblrPreviews, type TumblrPreviewsProps, TwitterLinkPreview, TwitterPostPreview, TwitterPreviews };
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.mts.map