@xhub-short/contracts 0.1.0-beta.14 → 0.1.0-beta.17

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.ts CHANGED
@@ -74,19 +74,18 @@ interface ContentStats {
74
74
  shares: number;
75
75
  /** Total bookmark/save count (optional) */
76
76
  bookmarks?: number;
77
- }
78
- /**
79
- * Video statistics (extends base with views)
80
- */
81
- interface VideoStats extends ContentStats {
82
77
  /** Total view count */
83
78
  views: number;
84
79
  }
85
80
  /**
86
- * Image post statistics (alias for ContentStats)
81
+ * Article statistics (alias for ContentStats)
87
82
  * @see ContentStats
88
83
  */
89
- type ImagePostStats = ContentStats;
84
+ type ArticleStats = ContentStats;
85
+ /**
86
+ * @deprecated Use ArticleStats instead. Will be removed in v3.0
87
+ */
88
+ type ImagePostStats = ArticleStats;
90
89
  /**
91
90
  * Base content item shared by all content types
92
91
  */
@@ -122,51 +121,31 @@ interface VideoItem extends BaseContentItem {
122
121
  /** Video title/description */
123
122
  title?: string;
124
123
  /** Video statistics */
125
- stats: VideoStats;
124
+ stats: ContentStats;
126
125
  }
127
126
  /**
128
- * Image Post content structure
129
- * Represents a carousel of images in the feed
127
+ * Article content structure
128
+ * Represents a carousel of images/other content in the feed
130
129
  */
131
- interface ImagePost extends BaseContentItem {
130
+ interface Article extends BaseContentItem {
132
131
  /** Content type discriminator */
133
- type: 'image';
132
+ type: 'article';
134
133
  /** Array of image URLs (1 or more) */
135
134
  images: string[];
136
135
  /** Post caption/description */
137
136
  caption?: string;
138
137
  /** Post statistics */
139
- stats: ImagePostStats;
138
+ stats: ArticleStats;
140
139
  }
141
140
  /**
142
- * Union type for all feed content types
143
- * Use type guards to narrow the type
141
+ * @deprecated Use Article instead. Will be removed in v3.0
144
142
  */
145
- type ContentItem = VideoItem | ImagePost;
143
+ type ImagePost = Article;
146
144
  /**
147
- * Type guard to check if content is a VideoItem
148
- *
149
- * @example
150
- * ```typescript
151
- * if (isVideoItem(item)) {
152
- * // item is VideoItem here
153
- * console.log(item.source.url);
154
- * }
155
- * ```
156
- */
157
- declare function isVideoItem(item: ContentItem): item is VideoItem;
158
- /**
159
- * Type guard to check if content is an ImagePost
160
- *
161
- * @example
162
- * ```typescript
163
- * if (isImagePost(item)) {
164
- * // item is ImagePost here
165
- * console.log(item.images.length);
166
- * }
167
- * ```
145
+ * Union type for all feed content types
146
+ * Use type guards to narrow the type
168
147
  */
169
- declare function isImagePost(item: ContentItem): item is ImagePost;
148
+ type ContentItem = VideoItem | Article;
170
149
  /**
171
150
  * Feed pagination response
172
151
  *
@@ -181,7 +160,7 @@ declare function isImagePost(item: ContentItem): item is ImagePost;
181
160
  * const mixedFeed: FeedResponse<ContentItem> = await dataSource.fetchFeed();
182
161
  * ```
183
162
  */
184
- interface FeedResponse<T = VideoItem> {
163
+ interface FeedResponse<T = ContentItem> {
185
164
  /** List of content items */
186
165
  items: T[];
187
166
  /** Cursor for next page (null if no more data) */
@@ -193,9 +172,9 @@ interface FeedResponse<T = VideoItem> {
193
172
  * Feed state for state management
194
173
  */
195
174
  interface FeedState {
196
- /** Map of video items by ID (for O(1) lookup and deduplication) */
197
- itemsMap: Map<string, VideoItem>;
198
- /** Ordered list of video IDs for rendering */
175
+ /** Map of content items by ID (for O(1) lookup and deduplication) */
176
+ itemsMap: Map<string, ContentItem>;
177
+ /** Ordered list of item IDs for rendering */
199
178
  orderedIds: string[];
200
179
  /** Current cursor for pagination */
201
180
  cursor: string | null;
@@ -249,8 +228,10 @@ interface PlayerError {
249
228
  * Used by Lifecycle Manager for state restoration
250
229
  */
251
230
  interface SessionSnapshot {
252
- /** Video items from feed (for offline restore) */
253
- items: VideoItem[];
231
+ /** Content items from feed (for offline restore) */
232
+ items: ContentItem[];
233
+ /** @deprecated Use items instead. Will be removed in v3.0 */
234
+ videos?: VideoItem[];
254
235
  /** Feed cursor position for pagination */
255
236
  cursor: string | null;
256
237
  /** Index of the currently focused video */
@@ -372,6 +353,19 @@ interface LogEntry {
372
353
  stack?: string;
373
354
  }
374
355
 
356
+ /**
357
+ * Type guard to check if content is a VideoItem
358
+ */
359
+ declare function isVideoItem(item: ContentItem): item is VideoItem;
360
+ /**
361
+ * Type guard to check if content is an Article
362
+ */
363
+ declare function isArticle(item: ContentItem): item is Article;
364
+ /**
365
+ * @deprecated Use isArticle instead. Will be removed in v3.0
366
+ */
367
+ declare function isImagePost(item: ContentItem): item is Article;
368
+
375
369
  /**
376
370
  * Comment Feature Types
377
371
  * Supports nested replies (1 level), pagination, and optimistic updates
@@ -607,7 +601,7 @@ declare const DEFAULT_COMMENT_CONFIG: CommentConfig;
607
601
  /**
608
602
  * IDataSource - Data Port Interface
609
603
  *
610
- * This interface defines the contract for fetching video data.
604
+ * This interface defines the contract for fetching feed content.
611
605
  * SDK core never knows about specific APIs - it only talks to this interface.
612
606
  *
613
607
  * Implementations:
@@ -631,7 +625,7 @@ declare const DEFAULT_COMMENT_CONFIG: CommentConfig;
631
625
  */
632
626
  interface IDataSource {
633
627
  /**
634
- * Fetch a page of videos for the feed
628
+ * Fetch a page of items for the feed
635
629
  *
636
630
  * @param cursor - Pagination cursor from previous response (undefined for first page)
637
631
  * @returns Promise resolving to feed response with items and pagination info
@@ -644,21 +638,25 @@ interface IDataSource {
644
638
  */
645
639
  fetchFeed(cursor?: string): Promise<FeedResponse>;
646
640
  /**
647
- * Get detailed information for a specific video
641
+ * Get detailed information for a specific content item
648
642
  *
649
- * @param id - Video ID
650
- * @returns Promise resolving to video item details
651
- * @throws Error if video not found or network fails
643
+ * @param id - Content ID
644
+ * @returns Promise resolving to content item details
645
+ * @throws Error if content not found or network fails
652
646
  *
653
647
  * Implementation notes:
654
648
  * - May return cached data if available
655
- * - Should throw specific error for 404 (video deleted/not found)
649
+ * - Should throw specific error for 404 (content deleted/not found)
656
650
  */
657
- getVideoDetail(id: string): Promise<VideoItem>;
651
+ getContentDetail(id: string): Promise<ContentItem>;
658
652
  /**
659
- * Optional: Prefetch videos for smoother scrolling
653
+ * @deprecated Use getContentDetail instead. Will be removed in v3.0
654
+ */
655
+ getVideoDetail?(id: string): Promise<VideoItem>;
656
+ /**
657
+ * Optional: Prefetch content for smoother scrolling
660
658
  *
661
- * @param ids - Array of video IDs to prefetch
659
+ * @param ids - Array of content IDs to prefetch
662
660
  * @returns Promise resolving when prefetch is complete
663
661
  *
664
662
  * Implementation notes:
@@ -825,7 +823,7 @@ interface IInteraction {
825
823
  * Data structure for prefetch cache
826
824
  *
827
825
  * Stored in localStorage for instant feed loading on fresh app open.
828
- * Contains video metadata (NOT video data) for immediate display.
826
+ * Contains content metadata (NOT heavy media data) for immediate display.
829
827
  *
830
828
  * @example
831
829
  * ```typescript
@@ -839,10 +837,10 @@ interface IInteraction {
839
837
  */
840
838
  interface PrefetchCacheData {
841
839
  /**
842
- * Cached video items (tail of feed - videos user hasn't seen)
840
+ * Cached content items (tail of feed - items user hasn't seen)
843
841
  * These are shown instantly on fresh load
844
842
  */
845
- items: VideoItem[];
843
+ items: ContentItem[];
846
844
  /**
847
845
  * Timestamp when cache was saved
848
846
  * Used for debugging and potential TTL features
@@ -939,6 +937,18 @@ interface IStorage {
939
937
  * - Used for debugging and LRU eviction
940
938
  */
941
939
  keys(): Promise<string[]>;
940
+ /**
941
+ * Get a value from storage synchronously (optional)
942
+ *
943
+ * Used for zero-flash cache hydration during React render phase.
944
+ * Only implement if the underlying storage supports synchronous reads
945
+ * (e.g., localStorage). Async-only storage (e.g., IndexedDB) should
946
+ * not implement this.
947
+ *
948
+ * @param key - Storage key
949
+ * @returns The stored value or null if not found / not supported
950
+ */
951
+ getSync?<T>(key: string): T | null;
942
952
  }
943
953
  /**
944
954
  * Specialized interface for session snapshot storage
@@ -1789,7 +1799,9 @@ type UIComponent<P = object> = (props: P) => UINode;
1789
1799
  * Feed state from useFeed() hook
1790
1800
  */
1791
1801
  interface UIFeedState {
1792
- /** List of video items */
1802
+ /** List of content items (Video or Article) */
1803
+ items: ContentItem[];
1804
+ /** @deprecated Use items instead. Will be removed in v3.0 */
1793
1805
  videos: VideoItem[];
1794
1806
  /** Whether feed is loading */
1795
1807
  isLoading: boolean;
@@ -1897,7 +1909,7 @@ interface UIInteractionState {
1897
1909
  interface UIInteractionActions {
1898
1910
  /** Toggle like state (debounced - updates UI immediately, API call is debounced) */
1899
1911
  toggleLike: () => void;
1900
- /** Share video */
1912
+ /** Share content */
1901
1913
  share: () => Promise<void>;
1902
1914
  /** Open comments */
1903
1915
  openComments: () => void;
@@ -1923,16 +1935,18 @@ interface UIAuthorActions {
1923
1935
  openProfile: () => void;
1924
1936
  }
1925
1937
  /**
1926
- * Video info state for VideoInfo component
1938
+ * Content info state for VideoInfo/ArticleInfo component
1927
1939
  */
1928
1940
  interface UIVideoInfoState {
1929
- /** Video item */
1930
- video: VideoItem;
1941
+ /** Content item (Video or Article) */
1942
+ content: ContentItem;
1943
+ /** @deprecated Use content instead. Will be removed in v3.0 */
1944
+ video?: VideoItem;
1931
1945
  /** Author name */
1932
1946
  authorName: string;
1933
1947
  /** Whether author is verified */
1934
1948
  isVerified: boolean;
1935
- /** Video caption/title */
1949
+ /** Content caption/title */
1936
1950
  caption: string;
1937
1951
  /** Hashtags array */
1938
1952
  hashtags: string[];
@@ -1960,10 +1974,41 @@ interface UIVideoInfoActions {
1960
1974
  onLocationClick?: () => void;
1961
1975
  }
1962
1976
  /**
1963
- * VideoFeed headless component props
1977
+ * Article-specific UI state
1964
1978
  */
1965
- interface VideoFeedHeadlessProps {
1966
- /** Feed state (videos, loading, etc.) */
1979
+ interface UIArticleState {
1980
+ /** Article item */
1981
+ article: Article;
1982
+ /** Current image index */
1983
+ currentImageIndex: number;
1984
+ /** Whether music is playing */
1985
+ isMusicPlaying: boolean;
1986
+ /** Last music toggle timestamp (for synchronization) */
1987
+ lastMusicToggleTime: number;
1988
+ }
1989
+ /**
1990
+ * Article-specific UI actions
1991
+ */
1992
+ interface UIArticleActions {
1993
+ /** Set current image index */
1994
+ setCurrentIndex: (index: number) => void;
1995
+ /** Toggle music playback */
1996
+ toggleMusic: () => void;
1997
+ /** Toggle like state */
1998
+ toggleLike: () => Promise<void>;
1999
+ /** Toggle bookmark state */
2000
+ toggleBookmark: () => void;
2001
+ /** Open detail view */
2002
+ openDetail: () => void;
2003
+ /** Close detail view */
2004
+ closeDetail: () => void;
2005
+ }
2006
+ /**
2007
+ * Feed headless component props
2008
+ * Position-based virtual scroller for mixed content.
2009
+ */
2010
+ interface FeedHeadlessProps {
2011
+ /** Feed state (items, loading, etc.) */
1967
2012
  feedState: UIFeedState;
1968
2013
  /** Swipe/scroll state */
1969
2014
  swipeState: UISwipeState;
@@ -1971,8 +2016,8 @@ interface VideoFeedHeadlessProps {
1971
2016
  height?: number | string;
1972
2017
  /** Additional CSS classes */
1973
2018
  className?: string;
1974
- /** Render function for each video slot */
1975
- renderSlot: (video: VideoItem, index: number) => UINode;
2019
+ /** Render function for each content slot */
2020
+ renderSlot: (item: ContentItem, index: number) => UINode;
1976
2021
  /** Called when active index changes */
1977
2022
  onIndexChange?: (index: number) => void;
1978
2023
  /** Called when reaching near end of feed */
@@ -1980,6 +2025,8 @@ interface VideoFeedHeadlessProps {
1980
2025
  /** Threshold for triggering onEndReached (default: 2) */
1981
2026
  endReachedThreshold?: number;
1982
2027
  }
2028
+ /** @deprecated Use FeedHeadlessProps instead. Will be removed in v3.0 */
2029
+ type VideoFeedHeadlessProps = FeedHeadlessProps;
1983
2030
  /**
1984
2031
  * VideoSlot headless component props
1985
2032
  */
@@ -2153,6 +2200,84 @@ interface VideoInfoHeadlessProps {
2153
2200
  /** Children (for compound pattern) */
2154
2201
  children?: UINode;
2155
2202
  }
2203
+ /**
2204
+ * ArticleSlot headless component props
2205
+ */
2206
+ interface ArticleSlotHeadlessProps {
2207
+ /** Article to display */
2208
+ article: Article;
2209
+ /** Whether slot is active */
2210
+ isActive: boolean;
2211
+ /** Current image index */
2212
+ currentImageIndex: number;
2213
+ /** Index change handler */
2214
+ onImageIndexChange: (index: number) => void;
2215
+ /** Music toggle handler */
2216
+ onToggleMusic: () => void;
2217
+ /** Whether music is playing */
2218
+ isMusicPlaying: boolean;
2219
+ /** Last music toggle timestamp */
2220
+ lastMusicToggleTime?: number;
2221
+ /** Double tap handler (usually for like) */
2222
+ onDoubleTap?: () => void;
2223
+ /** "Read More" click handler */
2224
+ onReadMoreClick?: () => void;
2225
+ /** Long press handler */
2226
+ onLongPress?: () => void;
2227
+ /** Single tap handler */
2228
+ onTap?: () => void;
2229
+ /** Swipe direction change handler (for gesture locking) */
2230
+ onSwipeDirectionChange?: (direction: 'horizontal' | 'vertical' | null) => void;
2231
+ /** Children (overlay content) */
2232
+ children?: UINode;
2233
+ /** Additional CSS classes */
2234
+ className?: string;
2235
+ /** Music info (optional) */
2236
+ music?: {
2237
+ id: string;
2238
+ title: string;
2239
+ artist: string;
2240
+ };
2241
+ }
2242
+ /** @deprecated Use ArticleSlotHeadlessProps instead */
2243
+ type ImagePostSlotHeadlessProps = ArticleSlotHeadlessProps;
2244
+ /**
2245
+ * DetailView headless component props
2246
+ */
2247
+ interface DetailViewHeadlessProps {
2248
+ /** Whether open */
2249
+ isOpen: boolean;
2250
+ /** Close handler */
2251
+ onClose: () => void;
2252
+ /** Article to display */
2253
+ article: Article;
2254
+ /** Initial index */
2255
+ initialImageIndex?: number;
2256
+ /** Header title */
2257
+ headerTitle?: string;
2258
+ /** Liked state */
2259
+ isLiked?: boolean;
2260
+ /** Following state */
2261
+ isFollowing?: boolean;
2262
+ /** Bookmarked state */
2263
+ isBookmarked?: boolean;
2264
+ /** Like handler */
2265
+ onLike?: () => void;
2266
+ /** Comment handler */
2267
+ onComment?: () => void;
2268
+ /** Share handler */
2269
+ onShare?: () => void;
2270
+ /** Bookmark handler */
2271
+ onBookmark?: () => void;
2272
+ /** Follow handler */
2273
+ onFollow?: () => void;
2274
+ /** Gesture lock handler */
2275
+ onGestureLock?: (locked: boolean) => void;
2276
+ /** Children (compound components) */
2277
+ children?: UINode;
2278
+ /** Custom bottom bar renderer */
2279
+ renderBottomBar?: (props: any) => UINode;
2280
+ }
2156
2281
  /**
2157
2282
  * ErrorBoundary component props
2158
2283
  */
@@ -2184,15 +2309,17 @@ interface SkeletonProps {
2184
2309
  className?: string;
2185
2310
  }
2186
2311
  /**
2187
- * VideoFeed wired component props
2312
+ * Feed wired component props
2188
2313
  * feedState and swipeState are injected by SDK
2189
2314
  */
2190
- interface VideoFeedProps extends Omit<VideoFeedHeadlessProps, 'feedState' | 'swipeState'> {
2315
+ interface FeedProps extends Omit<FeedHeadlessProps, 'feedState' | 'swipeState'> {
2191
2316
  /** Override feed state (optional) */
2192
2317
  feedState?: UIFeedState;
2193
2318
  /** Override swipe state (optional) */
2194
2319
  swipeState?: UISwipeState;
2195
2320
  }
2321
+ /** @deprecated Use FeedProps instead. Will be removed in v3.0 */
2322
+ type VideoFeedProps = FeedProps;
2196
2323
  /**
2197
2324
  * VideoSlot wired component props
2198
2325
  * resourceState, playerState, playerControls are injected by SDK
@@ -2218,8 +2345,10 @@ interface VideoPlayerWiredProps extends Partial<VideoPlayerHeadlessProps> {
2218
2345
  * interactionState and interactionActions are injected by SDK
2219
2346
  */
2220
2347
  interface ActionBarProps extends Omit<ActionBarHeadlessProps, 'interactionState' | 'interactionActions'> {
2221
- /** Video to get interaction state for */
2222
- video: VideoItem;
2348
+ /** Content to get interaction state for */
2349
+ content: ContentItem;
2350
+ /** @deprecated Use content instead. Will be removed in v3.0 */
2351
+ video?: VideoItem;
2223
2352
  /** Override interaction state (optional) */
2224
2353
  interactionState?: UIInteractionState;
2225
2354
  /** Override interaction actions (optional) */
@@ -2230,8 +2359,10 @@ interface ActionBarProps extends Omit<ActionBarHeadlessProps, 'interactionState'
2230
2359
  * authorState and authorActions are injected by SDK
2231
2360
  */
2232
2361
  interface AuthorInfoProps extends Omit<AuthorInfoHeadlessProps, 'authorState' | 'authorActions'> {
2233
- /** Video to get author from */
2234
- video: VideoItem;
2362
+ /** Content to get author from */
2363
+ content: ContentItem;
2364
+ /** @deprecated Use content instead. Will be removed in v3.0 */
2365
+ video?: VideoItem;
2235
2366
  /** Override author state (optional) */
2236
2367
  authorState?: UIAuthorState;
2237
2368
  /** Override author actions (optional) */
@@ -2242,8 +2373,10 @@ interface AuthorInfoProps extends Omit<AuthorInfoHeadlessProps, 'authorState' |
2242
2373
  * videoInfoState and videoInfoActions are injected by SDK
2243
2374
  */
2244
2375
  interface VideoInfoProps extends Omit<VideoInfoHeadlessProps, 'videoInfoState' | 'videoInfoActions'> {
2245
- /** Video to get info from */
2246
- video: VideoItem;
2376
+ /** Content to get info from */
2377
+ content: ContentItem;
2378
+ /** @deprecated Use content instead. Will be removed in v3.0 */
2379
+ video?: VideoItem;
2247
2380
  /** Override video info state (optional) */
2248
2381
  videoInfoState?: UIVideoInfoState;
2249
2382
  /** Override video info actions (optional) */
@@ -2465,4 +2598,4 @@ type IconComponent = UIComponent<{
2465
2598
  */
2466
2599
  type FormatCountFn = (count: number) => string;
2467
2600
 
2468
- export { type ActionBarHeadlessProps, type ActionBarProps, type ActionButtonHeadlessProps, type AnalyticsConfig, type AnalyticsEvent, type AnalyticsEventType, type Author, type AuthorInfoHeadlessProps, type AuthorInfoProps, type BaseContentItem, type Comment, type CommentAdapterConfig, type CommentAuthor, type CommentConfig, type CommentEndpoints, type CommentInputHeadlessProps, type CommentItem, type CommentItemHeadlessProps, type CommentListResponse, type CommentManagerState, type CommentReportReason, type CommentSheetHeadlessProps, type CommentSheetProps, type CommentState, type CommentTransformers, type ContentItem, type ContentStats, DEFAULT_COMMENT_CONFIG, DEFAULT_COMMENT_ENDPOINTS, type DeleteCommentPayload, type EditCommentPayload, type ErrorBoundaryProps, type FeedResponse, type FeedState, type FormatCountFn, type IAnalytics, type ICommentAdapter, type IDataSource, type IInteraction, type ILocalization, type ILogger, type INetworkAdapter, type IPlaylistDataSource, type IPosterLoader, type ISessionStorage, type IStorage, type IVideoLoader, type IconComponent, type ImagePost, type ImagePostStats, type InternalLogger, type LocalizationConfig, type LogEntry, type LogLevel, type LoggerConfig, type MessageCatalog, type MessageKey, type MessageKey as MessageKeyType, type MessageValue, type MessageValues, type MockCommentAdapterConfig, type MusicInfo, type NetworkQuality, type NetworkType, type OptimisticAction, type PartialMessageCatalog, type PlaybackState, type PlayerError, type PlayerState, type PlaylistCollectionResponse, type PlaylistData, type PlaylistItem, type PlaylistSummary, type PostCommentPayload, type PostReplyPayload, type PrefetchCacheData, type PreloadConfig, type PreloadResult, type PreloadStatus, type ProgressBarHeadlessProps, type ReplyItem, type ReplyItemHeadlessProps, type ReplyListResponse, type ReportCommentPayload, type ReportReason, type SDKConfig, type SessionSnapshot, type SkeletonProps, type UIAuthorActions, type UIAuthorState, type UICommentActions, type UICommentState, type UIComponent, type UIFeedState, type UIInteractionActions, type UIInteractionState, type UINode, type UIPlayerControls, type UIPlayerState, type UIRef, type UIResourceState, type UISwipeState, type UIVideoInfoActions, type UIVideoInfoState, type VideoFeedHeadlessProps, type VideoFeedProps, type VideoInfoHeadlessProps, type VideoInfoProps, type VideoItem, type VideoPlayerHeadlessProps, type VideoPlayerWiredProps, type VideoQuality, type VideoSlotHeadlessProps, type VideoSlotProps, type VideoSource, type VideoStats, type WiredComponent, type WiredComponentConfig, isImagePost, isVideoItem };
2601
+ export { type ActionBarHeadlessProps, type ActionBarProps, type ActionButtonHeadlessProps, type AnalyticsConfig, type AnalyticsEvent, type AnalyticsEventType, type Article, type ArticleSlotHeadlessProps, type ArticleStats, type Author, type AuthorInfoHeadlessProps, type AuthorInfoProps, type BaseContentItem, type Comment, type CommentAdapterConfig, type CommentAuthor, type CommentConfig, type CommentEndpoints, type CommentInputHeadlessProps, type CommentItem, type CommentItemHeadlessProps, type CommentListResponse, type CommentManagerState, type CommentReportReason, type CommentSheetHeadlessProps, type CommentSheetProps, type CommentState, type CommentTransformers, type ContentItem, type ContentStats, DEFAULT_COMMENT_CONFIG, DEFAULT_COMMENT_ENDPOINTS, type DeleteCommentPayload, type DetailViewHeadlessProps, type EditCommentPayload, type ErrorBoundaryProps, type FeedResponse, type FeedState, type FormatCountFn, type IAnalytics, type ICommentAdapter, type IDataSource, type IInteraction, type ILocalization, type ILogger, type INetworkAdapter, type IPlaylistDataSource, type IPosterLoader, type ISessionStorage, type IStorage, type IVideoLoader, type IconComponent, type ImagePost, type ImagePostSlotHeadlessProps, type ImagePostStats, type InternalLogger, type LocalizationConfig, type LogEntry, type LogLevel, type LoggerConfig, type MessageCatalog, type MessageKey, type MessageKey as MessageKeyType, type MessageValue, type MessageValues, type MockCommentAdapterConfig, type MusicInfo, type NetworkQuality, type NetworkType, type OptimisticAction, type PartialMessageCatalog, type PlaybackState, type PlayerError, type PlayerState, type PlaylistCollectionResponse, type PlaylistData, type PlaylistItem, type PlaylistSummary, type PostCommentPayload, type PostReplyPayload, type PrefetchCacheData, type PreloadConfig, type PreloadResult, type PreloadStatus, type ProgressBarHeadlessProps, type ReplyItem, type ReplyItemHeadlessProps, type ReplyListResponse, type ReportCommentPayload, type ReportReason, type SDKConfig, type SessionSnapshot, type SkeletonProps, type UIArticleActions, type UIArticleState, type UIAuthorActions, type UIAuthorState, type UICommentActions, type UICommentState, type UIComponent, type UIFeedState, type UIInteractionActions, type UIInteractionState, type UINode, type UIPlayerControls, type UIPlayerState, type UIRef, type UIResourceState, type UISwipeState, type UIVideoInfoActions, type UIVideoInfoState, type VideoFeedHeadlessProps, type VideoFeedProps, type VideoInfoHeadlessProps, type VideoInfoProps, type VideoItem, type VideoPlayerHeadlessProps, type VideoPlayerWiredProps, type VideoQuality, type VideoSlotHeadlessProps, type VideoSlotProps, type VideoSource, type WiredComponent, type WiredComponentConfig, isArticle, isImagePost, isVideoItem };
package/dist/index.js CHANGED
@@ -1,9 +1,15 @@
1
- // src/types.ts
1
+ // src/type-guards.ts
2
2
  function isVideoItem(item) {
3
3
  return item.type === "video";
4
4
  }
5
+ function isArticle(item) {
6
+ return item.type === "article";
7
+ }
5
8
  function isImagePost(item) {
6
- return item.type === "image";
9
+ if (process.env.NODE_ENV !== "production") {
10
+ console.warn("[xhub-short] isImagePost is deprecated. Use isArticle instead.");
11
+ }
12
+ return isArticle(item);
7
13
  }
8
14
 
9
15
  // src/comment-types.ts
@@ -33,4 +39,4 @@ var DEFAULT_COMMENT_ENDPOINTS = {
33
39
  report: "/comments/:id/report"
34
40
  };
35
41
 
36
- export { DEFAULT_COMMENT_CONFIG, DEFAULT_COMMENT_ENDPOINTS, isImagePost, isVideoItem };
42
+ export { DEFAULT_COMMENT_CONFIG, DEFAULT_COMMENT_ENDPOINTS, isArticle, isImagePost, isVideoItem };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xhub-short/contracts",
3
3
  "sideEffects": false,
4
- "version": "0.1.0-beta.14",
4
+ "version": "0.1.0-beta.17",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -20,14 +20,20 @@
20
20
  "dist"
21
21
  ],
22
22
  "devDependencies": {
23
+ "@types/node": "^22.0.0",
23
24
  "tsup": "^8.3.0",
24
25
  "typescript": "^5.7.0",
25
- "@xhub-short/tsconfig": "0.0.1-beta.2"
26
+ "vitest": "^2.1.0",
27
+ "@vitest/coverage-v8": "^2.1.0",
28
+ "@xhub-short/tsconfig": "0.0.1-beta.2",
29
+ "@xhub-short/vitest-config": "0.1.0-beta.13"
26
30
  },
27
31
  "scripts": {
28
32
  "build": "tsup",
29
33
  "dev": "tsup --watch",
30
34
  "typecheck": "tsc --noEmit",
35
+ "test": "vitest run",
36
+ "test:coverage": "vitest run --coverage",
31
37
  "clean": "rm -rf dist"
32
38
  }
33
39
  }