@wix/blog 1.0.690 → 1.0.692

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.
Files changed (85) hide show
  1. package/_sdk-exports/context-blog-feed-context-provider/runtime.d.ts +483 -0
  2. package/_sdk-exports/context-blog-feed-context-provider/runtime.js +5 -0
  3. package/_sdk-exports/context-category-item-context-provider/runtime.d.ts +189 -0
  4. package/_sdk-exports/context-category-item-context-provider/runtime.js +2 -0
  5. package/_sdk-exports/context-post-by-id-context-provider/runtime.d.ts +31 -0
  6. package/_sdk-exports/context-post-by-id-context-provider/runtime.js +5 -0
  7. package/_sdk-exports/context-post-context-provider/runtime.d.ts +3213 -0
  8. package/_sdk-exports/context-post-context-provider/runtime.js +5 -0
  9. package/_sdk-exports/context-post-item-context-provider/runtime.d.ts +386 -0
  10. package/_sdk-exports/context-post-item-context-provider/runtime.js +5 -0
  11. package/_sdk-exports/context-related-posts-context-provider/runtime.d.ts +341 -0
  12. package/_sdk-exports/context-related-posts-context-provider/runtime.js +5 -0
  13. package/_sdk-exports/context-tag-item-context-provider/runtime.d.ts +185 -0
  14. package/_sdk-exports/context-tag-item-context-provider/runtime.js +2 -0
  15. package/blog-feed-context-provider/package.json +3 -0
  16. package/build/cjs/context-blog-feed-context-provider.d.ts +483 -0
  17. package/build/cjs/context-blog-feed-context-provider.js +4601 -0
  18. package/build/cjs/context-blog-feed-context-provider.js.map +1 -0
  19. package/build/cjs/context-category-item-context-provider.d.ts +189 -0
  20. package/build/cjs/context-category-item-context-provider.js +578 -0
  21. package/build/cjs/context-category-item-context-provider.js.map +1 -0
  22. package/build/cjs/context-post-by-id-context-provider.d.ts +31 -0
  23. package/build/cjs/context-post-by-id-context-provider.js +4531 -0
  24. package/build/cjs/context-post-by-id-context-provider.js.map +1 -0
  25. package/build/cjs/context-post-context-provider.d.ts +3213 -0
  26. package/build/cjs/context-post-context-provider.js +5404 -0
  27. package/build/cjs/context-post-context-provider.js.map +1 -0
  28. package/build/cjs/context-post-item-context-provider.d.ts +386 -0
  29. package/build/cjs/context-post-item-context-provider.js +3682 -0
  30. package/build/cjs/context-post-item-context-provider.js.map +1 -0
  31. package/build/cjs/context-related-posts-context-provider.d.ts +341 -0
  32. package/build/cjs/context-related-posts-context-provider.js +4355 -0
  33. package/build/cjs/context-related-posts-context-provider.js.map +1 -0
  34. package/build/cjs/context-tag-item-context-provider.d.ts +185 -0
  35. package/build/cjs/context-tag-item-context-provider.js +578 -0
  36. package/build/cjs/context-tag-item-context-provider.js.map +1 -0
  37. package/build/es/context-blog-feed-context-provider.d.mts +483 -0
  38. package/build/es/context-blog-feed-context-provider.mjs +4571 -0
  39. package/build/es/context-blog-feed-context-provider.mjs.map +1 -0
  40. package/build/es/context-category-item-context-provider.d.mts +189 -0
  41. package/build/es/context-category-item-context-provider.mjs +549 -0
  42. package/build/es/context-category-item-context-provider.mjs.map +1 -0
  43. package/build/es/context-post-by-id-context-provider.d.mts +31 -0
  44. package/build/es/context-post-by-id-context-provider.mjs +4491 -0
  45. package/build/es/context-post-by-id-context-provider.mjs.map +1 -0
  46. package/build/es/context-post-context-provider.d.mts +3213 -0
  47. package/build/es/context-post-context-provider.mjs +5374 -0
  48. package/build/es/context-post-context-provider.mjs.map +1 -0
  49. package/build/es/context-post-item-context-provider.d.mts +386 -0
  50. package/build/es/context-post-item-context-provider.mjs +3652 -0
  51. package/build/es/context-post-item-context-provider.mjs.map +1 -0
  52. package/build/es/context-related-posts-context-provider.d.mts +341 -0
  53. package/build/es/context-related-posts-context-provider.mjs +4325 -0
  54. package/build/es/context-related-posts-context-provider.mjs.map +1 -0
  55. package/build/es/context-tag-item-context-provider.d.mts +185 -0
  56. package/build/es/context-tag-item-context-provider.mjs +549 -0
  57. package/build/es/context-tag-item-context-provider.mjs.map +1 -0
  58. package/build/internal/cjs/context-blog-feed-context-provider.d.ts +483 -0
  59. package/build/internal/cjs/context-category-item-context-provider.d.ts +189 -0
  60. package/build/internal/cjs/context-post-by-id-context-provider.d.ts +31 -0
  61. package/build/internal/cjs/context-post-context-provider.d.ts +3213 -0
  62. package/build/internal/cjs/context-post-item-context-provider.d.ts +386 -0
  63. package/build/internal/cjs/context-related-posts-context-provider.d.ts +341 -0
  64. package/build/internal/cjs/context-tag-item-context-provider.d.ts +185 -0
  65. package/build/internal/es/context-blog-feed-context-provider.d.mts +483 -0
  66. package/build/internal/es/context-category-item-context-provider.d.mts +189 -0
  67. package/build/internal/es/context-post-by-id-context-provider.d.mts +31 -0
  68. package/build/internal/es/context-post-context-provider.d.mts +3213 -0
  69. package/build/internal/es/context-post-item-context-provider.d.mts +386 -0
  70. package/build/internal/es/context-related-posts-context-provider.d.mts +341 -0
  71. package/build/internal/es/context-tag-item-context-provider.d.mts +185 -0
  72. package/category-item-context-provider/package.json +3 -0
  73. package/context/blog-feed-context-provider/package.json +3 -0
  74. package/context/category-item-context-provider/package.json +3 -0
  75. package/context/post-by-id-context-provider/package.json +3 -0
  76. package/context/post-context-provider/package.json +3 -0
  77. package/context/post-item-context-provider/package.json +3 -0
  78. package/context/related-posts-context-provider/package.json +3 -0
  79. package/context/tag-item-context-provider/package.json +3 -0
  80. package/package.json +104 -5
  81. package/post-by-id-context-provider/package.json +3 -0
  82. package/post-context-provider/package.json +3 -0
  83. package/post-item-context-provider/package.json +3 -0
  84. package/related-posts-context-provider/package.json +3 -0
  85. package/tag-item-context-provider/package.json +3 -0
@@ -0,0 +1,386 @@
1
+ import React from "react";
2
+
3
+ //#region ../../node_modules/@wix/editor-react-types/dist/links.d.ts
4
+ type LinkTarget = '_self' | '_blank';
5
+ /**
6
+ * A link to a URL, used for navigation within components.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import type { Link } from '@wix/editor-react-types';
11
+ *
12
+ * interface MyComponentProps {
13
+ * link?: Link;
14
+ * }
15
+ * ```
16
+ */
17
+ type Link = {
18
+ /**
19
+ * The link URL. For partial links (see `pageRole`), this is the router prefix
20
+ * (e.g. `https://www.my-site.com/prefix`) rather than a fully resolved URL.
21
+ */
22
+ href?: string;
23
+ /**
24
+ * Where this link should open.
25
+ * - `'_self'` — opens in the same page.
26
+ * - `'_blank'` — opens in a new tab.
27
+ */
28
+ target?: LinkTarget; /** The `rel` attribute of the link. Accepts LinkRel values separated by a space. */
29
+ rel?: string;
30
+ /**
31
+ * Page role identifier. Present only on partial links, where only the router prefix is
32
+ * known and the full URL format is owned by the Router/App. Applications can use such
33
+ * links in functions to resolve the complete URL at runtime (e.g. for binding links).
34
+ * Resolved links will not have this field.
35
+ */
36
+ pageRole?: string;
37
+ };
38
+ //#endregion
39
+ //#region ../../node_modules/@wix/editor-react-types/dist/image.d.ts
40
+ type Point = {
41
+ x: number;
42
+ y: number;
43
+ };
44
+ type Crop = Point & {
45
+ width: number;
46
+ height: number;
47
+ };
48
+ /**
49
+ * An image from Wix Media.
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * import type { Image } from '@wix/editor-react-types';
54
+ *
55
+ * interface MyComponentProps {
56
+ * image?: Image;
57
+ * }
58
+ *
59
+ * const MyComponent = ({ image }: MyComponentProps) => (
60
+ * <img src={image?.url} alt={image?.alt} />
61
+ * );
62
+ * ```
63
+ */
64
+ type Image = {
65
+ /** The image URI. */uri?: string; /** The image URL. */
66
+ url: string; /** The image file name. */
67
+ name?: string; /** The image height in pixels. */
68
+ height?: number; /** The image width in pixels. */
69
+ width?: number; /** Whether the image is animated (e.g. GIF). */
70
+ animated?: boolean; /** The crop region applied to the image. */
71
+ crop?: Crop; /** The image quality, as a percentage from 0 to 100. */
72
+ quality?: number; /** The image alt text for accessibility. */
73
+ alt?: string;
74
+ };
75
+ //#endregion
76
+ //#region ../../node_modules/@wix/editor-react-types/dist/base.d.ts
77
+ /**
78
+ * Rich text content with resolved links.
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * import type { RichText } from '@wix/editor-react-types';
83
+ *
84
+ * interface MyComponentProps {
85
+ * description?: RichText;
86
+ * }
87
+ *
88
+ * const MyComponent = ({ description }: MyComponentProps) => (
89
+ * <div>
90
+ * {description?.html}
91
+ * {description?.linkList.map((link) => (
92
+ * <a key={link.href} href={link.href}>{link.href}</a>
93
+ * ))}
94
+ * </div>
95
+ * );
96
+ * ```
97
+ */
98
+ type RichText = {
99
+ /** The original rich text content. */text: string; /** The HTML content with all links resolved. */
100
+ html: string; /** All links present in the rich text content. */
101
+ linkList: Array<Link>;
102
+ };
103
+ //#endregion
104
+ //#region ../../node_modules/type-fest/source/observable-like.d.ts
105
+ declare global {
106
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
107
+ interface SymbolConstructor {
108
+ readonly observable: symbol;
109
+ }
110
+ }
111
+ /**
112
+ @remarks
113
+ The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
114
+ As well, some guidance on making an `Observable` to not include `closed` property.
115
+ @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
116
+ @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
117
+ @see https://github.com/benlesh/symbol-observable#making-an-object-observable
118
+
119
+ @category Observable
120
+ */
121
+ //#endregion
122
+ //#region ../../node_modules/@wix/sdk-types/build/index.d.ts
123
+ declare global {
124
+ interface ContextualClient {}
125
+ }
126
+ /**
127
+ * Creates concrete types from SDK descriptors when a contextual client is
128
+ * available.
129
+ *
130
+ * For a REST descriptor the built (bound) API is intersected with the original
131
+ * descriptor, matching what `contextualizeRESTModuleV2` returns at runtime — a
132
+ * value callable as the bound API and still usable as a descriptor. Keeping the
133
+ * descriptor half lets contextual modules be passed to descriptor-constrained
134
+ * helpers such as `elevate` from `@wix/sdk/context` (FEDINF-14092).
135
+ *
136
+ * The `& T` is scoped to REST descriptors — the only shape codegen wraps in
137
+ * `MaybeContext` — so `BuildDescriptors` (used by `createClient().use`) is left
138
+ * unchanged and stays bound-only. The fix lives here rather than in `elevate`,
139
+ * which is kept strict on purpose (see #941) so it still rejects bound-only
140
+ * functions that are unsafe through `createRESTModule`.
141
+ */
142
+ declare global {
143
+ /**
144
+ * A global interface to set the exposure toggle for the SDK.
145
+ * @example
146
+ * ```ts
147
+ * declare global {
148
+ * interface SDKExposureToggle {
149
+ * alpha: true;
150
+ * }
151
+ * }
152
+ */
153
+ interface SDKExposureToggle {}
154
+ }
155
+ declare global {
156
+ /**
157
+ * A global interface to set the type mode for the SDK.
158
+ * @example
159
+ * ```ts
160
+ * declare global {
161
+ * interface SDKTypeMode {
162
+ * strict: true;
163
+ * }
164
+ * }
165
+ */
166
+ interface SDKTypeMode {}
167
+ }
168
+ //#endregion
169
+ //#region src/lib/parse-post-cover-media.d.ts
170
+ /** One playable rendition of a Wix-hosted cover video (a raw REST `VideoResolution`). */
171
+ interface VideoSource {
172
+ url: string;
173
+ width?: number;
174
+ height?: number;
175
+ }
176
+ type EmbedProvider = 'youtube' | 'vimeo' | 'unknown';
177
+ /**
178
+ * The post cover as the Cover Media widget consumes it — a discriminated union over the
179
+ * `post.media` oneof: a Wix-hosted image, a Wix-hosted video (`wixMedia.videoV2`), or an
180
+ * externally hosted embed (`embedMedia`, YouTube/Vimeo).
181
+ */
182
+ type CoverMedia = {
183
+ kind: 'image';
184
+ image: Image;
185
+ } | {
186
+ kind: 'wixVideo'; /** The WixMedia video id — the `wix:video://v1/<id>/...` path segment. */
187
+ id: string;
188
+ posterUrl?: string;
189
+ posterWidth?: number;
190
+ posterHeight?: number;
191
+ /**
192
+ * Playable mp4 renditions, optimal-first. Empty when the raw REST join was
193
+ * unavailable — the widget then renders the poster alone (see post-video-api.ts
194
+ * for why the SDK's `videoV2` string cannot carry these).
195
+ */
196
+ sources: VideoSource[];
197
+ altText: string;
198
+ } | {
199
+ kind: 'embed';
200
+ provider: EmbedProvider; /** The author-supplied external video URL, as the Blog API stores it. */
201
+ videoUrl: string; /** Provider player URL for click-to-play; absent for an unrecognized provider. */
202
+ embedUrl?: string;
203
+ thumbnailUrl?: string;
204
+ thumbnailWidth?: number;
205
+ thumbnailHeight?: number;
206
+ altText: string;
207
+ };
208
+ //#endregion
209
+ //#region src/extensions/post-list-context-provider/utils.d.ts
210
+ /**
211
+ * One item of the `postsList` array — the object the platform hands the Post Item
212
+ * context provider as its `postData` prop (via the manifest's `contextImplementor`).
213
+ * The `item*`/`recentPostItem` keys must match the Post Item context manifest's
214
+ * `context.items` keys — the runtime resolves an element's binding by looking the key
215
+ * up on the per-item hook's return value.
216
+ */
217
+ interface PostListItem {
218
+ /** Repeater item identity; also the manifest contract's `_id`. */
219
+ _id: string;
220
+ /** The manifest contract's `title` (plain text, non-bindable — see `itemTitle` below). */
221
+ title: string;
222
+ itemTitle: RichText;
223
+ itemExcerpt: RichText;
224
+ itemCoverImage: Image | undefined;
225
+ /**
226
+ * The cover as the Cover Media widget renders it — image OR playable video, where
227
+ * `itemCoverImage` above can only ever be the image. Runtime-only by design: deliberately
228
+ * absent from `POST_ITEM_CONTRACT_ITEMS` and the Post Item manifest (the runtime injects
229
+ * the full item object regardless, and the manifest contract must stay text-scalars-only —
230
+ * see post-item-contract.ts). Not bindable in Connect Value; consumed via
231
+ * `usePostItemContext()` only.
232
+ */
233
+ itemCoverMedia: CoverMedia | undefined;
234
+ itemLink: Link | undefined;
235
+ itemPublishedDate: RichText;
236
+ /**
237
+ * Raw values for the compact widgets (Metadata, Counters), which format for themselves
238
+ * (a design-panel date/number format) instead of parsing the richText labels above.
239
+ * Runtime-only like `itemCoverMedia` — never bindable items. JSON-safe on purpose (ISO
240
+ * string, numbers): the item crosses the platform's per-cell prop injection, and a `Date`
241
+ * would not survive the round-trip.
242
+ */
243
+ /** ISO 8601; `undefined` for a post without `firstPublishedDate`. */
244
+ publishedDateValue: string | undefined;
245
+ /**
246
+ * The clock `itemPublishedDate` was formatted from (`useHydrationClock`) — the compact
247
+ * widgets format `publishedDateValue` for themselves and must use the same one, or their
248
+ * label would hydrate against a different "now" than the bound text did.
249
+ */
250
+ clockValue: number;
251
+ /** `undefined` when absent OR 0 — the same API-artifact rule as `timeToRead` below. */
252
+ minutesToReadValue: number | undefined;
253
+ /**
254
+ * The server-side METRICS counters as raw numbers, the seed the Post Item provider
255
+ * publishes as `viewCountValue`/`commentCountValue` until its client-only metrics read
256
+ * lands (and for good in the editor, where that read is skipped). Same three-way rule as
257
+ * the `viewCount`/`commentCount` labels: metric → canvas stand-in → `undefined`, never 0.
258
+ */
259
+ initialViewCount: number | undefined;
260
+ initialCommentCount: number | undefined;
261
+ /**
262
+ * The remaining keys reuse the Post context's names verbatim — the registry is per app and
263
+ * keyed by item path, so re-declaring a key at the same dataType on the Post Item context
264
+ * costs no new registry rows (the same trick `likeCount` already relies on).
265
+ */
266
+ authorName: RichText;
267
+ authorImage: Image | undefined;
268
+ timeToRead: RichText;
269
+ /**
270
+ * Resolved in priority order by `counterLabel`:
271
+ * 1. the post's own `metrics` (the `METRICS` fieldset) — renders everywhere, including
272
+ * the editor canvas and inside SSR HTML;
273
+ * 2. an editor stand-in, when the API answers without metrics;
274
+ * 3. blank, for the Post Item provider to fill in from its per-cell metrics read.
275
+ *
276
+ * Blank rather than zero at step 3 because a seeded "0 views" reads as a confident wrong
277
+ * number until that read lands. Step 1 exists because step 3 alone is not enough: the
278
+ * per-cell read is client-only by design (personal data must never bake into SSR HTML the
279
+ * host caches for days) AND is skipped outright in the editor, which left a bound counter
280
+ * permanently blank on the canvas.
281
+ */
282
+ viewCount: RichText;
283
+ commentCount: RichText;
284
+ /**
285
+ * The post's MAIN category label — one, not a list. blog-client's feed card renders a single
286
+ * category (`post.categoryIds[0]`); its multi-category `CategoryLabelList` was built for the
287
+ * feed and never shipped, and the 3-chip list lives on the post page only.
288
+ */
289
+ itemCategoryLabel: RichText;
290
+ /** Mirrors the Post Item manifest's nested (non-bindable) `recentPostItem` data item. */
291
+ recentPostItem: {
292
+ title: string;
293
+ slug: string;
294
+ };
295
+ /**
296
+ * Whether the post takes new comments — the Comments widget's lock in a cell. Runtime-only
297
+ * like `itemCoverMedia`; `undefined` (partial fieldset, canvas stand-in) reads as unlocked.
298
+ */
299
+ commentingEnabled: boolean | undefined;
300
+ }
301
+ //#endregion
302
+ //#region src/hooks/post-likes.types.d.ts
303
+ interface PostLikes {
304
+ isLiked: boolean;
305
+ /** Server count adjusted by the viewer's optimistic toggle delta. */
306
+ likeCount: number;
307
+ /**
308
+ * False while the fresh like-count read is in flight (always false on SSR) — the
309
+ * Counters widget renders a skeleton instead of a possibly-stale number until it flips.
310
+ * A skipped read (editor, preview, no post id) and a failed read both settle to true
311
+ * with the baked count, so the skeleton never outlives its fetch.
312
+ */
313
+ isLikeCountLoaded: boolean;
314
+ /**
315
+ * View and comment totals off the same metrics read, `undefined` until it lands (and for
316
+ * good on the editor/preview paths that skip it). Nothing bakes these into SSR HTML, so a
317
+ * consumer must render nothing rather than a zero while they are `undefined`.
318
+ */
319
+ viewCount: number | undefined;
320
+ commentCount: number | undefined;
321
+ toggleLike: (pointerEvent?: PointerEvent) => Promise<void>;
322
+ /**
323
+ * The same like state, live: updated synchronously, while the fields above update in a
324
+ * transition. Stable identity — publish it on the context value as is.
325
+ */
326
+ liveLikes: LiveLikes;
327
+ }
328
+ /** What `LiveLikes` reports — the `PostLikes` fields a widget renders. */
329
+ type LiveLikeSnapshot = Pick<PostLikes, 'isLiked' | 'likeCount' | 'isLikeCountLoaded' | 'viewCount' | 'commentCount'>;
330
+ /**
331
+ * Why the like state exists twice: on a hydrating post page, a provider state update that is
332
+ * NOT a transition makes React discard the server HTML of every child boundary still waiting
333
+ * on its module load or the viewport gate (React #421 — thunderbolt logs "SSR HTML discard").
334
+ * So the provider's own state updates only in transitions — but a transition is held until
335
+ * every boundary below has hydrated, which for a viewport-gated one means until the visitor
336
+ * scrolls to it. The Counters and Actions widgets subscribe here instead, after their own
337
+ * mount, and show the fresh numbers right away (`usePostWidgetContext`).
338
+ */
339
+ interface LiveLikes {
340
+ get(): LiveLikeSnapshot;
341
+ subscribe(listener: () => void): () => void;
342
+ }
343
+ //#endregion
344
+ //#region src/extensions/post-item-context-provider/post-item-context-provider.d.ts
345
+ /**
346
+ * The context value IS the item — its `item*` keys sit top-level because the runtime
347
+ * resolves an element's binding by looking the manifest item key up on this hook's
348
+ * return value (through `contextSpecifier.hook`).
349
+ */
350
+ type PostItemContextType = PostListItem & Omit<PostLikes, 'likeCount' | 'viewCount' | 'commentCount'> & {
351
+ /**
352
+ * The raw counters for widgets (Counters reads `likeCountValue`). Named apart
353
+ * from the bindable richText labels `likeCount` / `viewCount` / `commentCount`, which
354
+ * `PostListItem` already carries and this provider overrides once the per-cell metadata
355
+ * read resolves.
356
+ */
357
+ likeCountValue: number;
358
+ viewCountValue: number | undefined;
359
+ commentCountValue: number | undefined;
360
+ likeCount: RichText;
361
+ viewCount: RichText;
362
+ commentCount: RichText;
363
+ };
364
+ /**
365
+ * Nullable rather than throwing: the hook runs for every element inside the repeater
366
+ * cell, including on the editor stage before the cell is populated.
367
+ */
368
+ declare function usePostItemContext(): PostItemContextType | null;
369
+ /** Props accepted by {@link PostItemContextProvider}. */
370
+ interface PostItemContextProviderProps extends React.PropsWithChildren {
371
+ /**
372
+ * The current item of the `postsList` array, injected by the platform per repeater
373
+ * cell (the Post List manifest's `contextImplementor.propKey`). Absent on the editor's
374
+ * unbound template cell — the three-way branch below matches the bookings builder's
375
+ * service-context: item → publish it; no item → render children over nulls (the
376
+ * nullable hook is the "null fields"); this provider has no standalone fetch path.
377
+ */
378
+ postData?: PostListItem;
379
+ }
380
+ /** Supplies one blog post, injected per repeater cell, to its children. */
381
+ declare function PostItemContextProvider({
382
+ postData,
383
+ children
384
+ }: PostItemContextProviderProps): React.ReactNode;
385
+ //#endregion
386
+ export { PostItemContextProvider, PostItemContextProvider as default, PostItemContextProviderProps, PostItemContextType, type PostListItem, usePostItemContext };