@xhub-short/sdk 0.1.0-beta.0 → 0.1.0-beta.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.
- package/README.md +63 -13
- package/dist/index.d.ts +1782 -1316
- package/dist/index.js +1607 -956
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -483,38 +483,88 @@ export type { FeedState, PlayerState, ResourceState, ... } from '@xhub-short/cor
|
|
|
483
483
|
|
|
484
484
|
## 🚀 Quick Start
|
|
485
485
|
|
|
486
|
-
###
|
|
486
|
+
### Simplest Usage (Recommended)
|
|
487
487
|
|
|
488
488
|
```tsx
|
|
489
|
-
import {
|
|
489
|
+
import { ShortVideoRoot, VideoFeed, DefaultSlot } from '@xhub-short/sdk';
|
|
490
490
|
|
|
491
491
|
function App() {
|
|
492
492
|
return (
|
|
493
|
-
<
|
|
493
|
+
<ShortVideoRoot
|
|
494
494
|
config={{
|
|
495
495
|
preset: {
|
|
496
496
|
baseUrl: 'https://api.example.com/v1',
|
|
497
497
|
auth: { getAccessToken: () => localStorage.getItem('token') },
|
|
498
498
|
endpoints: {
|
|
499
499
|
feed: { list: '/videos', detail: '/videos/:id' },
|
|
500
|
-
interaction: { like: '/videos/:id/like'
|
|
500
|
+
interaction: { like: '/videos/:id/like' },
|
|
501
501
|
},
|
|
502
502
|
},
|
|
503
503
|
}}
|
|
504
|
+
errorMode="auto-skip-with-toast"
|
|
504
505
|
>
|
|
505
|
-
<VideoFeed
|
|
506
|
-
|
|
506
|
+
<VideoFeed renderSlot={(video, index) => (
|
|
507
|
+
<DefaultSlot
|
|
508
|
+
video={video}
|
|
509
|
+
index={index}
|
|
510
|
+
showBookmark={true}
|
|
511
|
+
onOpenComments={(videoId) => openSheet(videoId)}
|
|
512
|
+
onShare={(video) => shareVideo(video)}
|
|
513
|
+
/>
|
|
514
|
+
)} />
|
|
515
|
+
</ShortVideoRoot>
|
|
507
516
|
);
|
|
508
517
|
}
|
|
509
|
-
|
|
510
|
-
function VideoFeed() {
|
|
511
|
-
const { videos, loadInitial, loadMore, hasMore } = useFeed();
|
|
512
|
-
const { load, play, pause, isPlaying } = usePlayer();
|
|
513
|
-
|
|
514
|
-
// Your UI here...
|
|
515
|
-
}
|
|
516
518
|
```
|
|
517
519
|
|
|
520
|
+
**That's it!** The SDK handles everything: video loading, HLS playback, swipe navigation, like/follow actions, error handling, and more.
|
|
521
|
+
|
|
522
|
+
### DefaultSlot Props
|
|
523
|
+
|
|
524
|
+
| Prop | Type | Default | Description |
|
|
525
|
+
|------|------|---------|-------------|
|
|
526
|
+
| `video` | `VideoItem` | required | Video data |
|
|
527
|
+
| `index` | `number` | required | Index in feed |
|
|
528
|
+
| `showPoster` | `boolean` | `true` | Show poster |
|
|
529
|
+
| `showLikeAnimation` | `boolean` | `true` | Double-tap hearts |
|
|
530
|
+
| `showAuthorInfo` | `boolean` | `true` | Avatar + follow |
|
|
531
|
+
| `showActionBar` | `boolean` | `true` | Like, comment, share |
|
|
532
|
+
| `showVideoInfo` | `boolean` | `true` | Caption, hashtags |
|
|
533
|
+
| `showProgressBar` | `boolean` | `true` | Progress bar |
|
|
534
|
+
| `showBookmark` | `boolean` | `false` | Bookmark button |
|
|
535
|
+
| `onOpenComments` | `(videoId) => void` | - | Comment click |
|
|
536
|
+
| `onShare` | `(video) => void` | - | Share click |
|
|
537
|
+
| `onOpenProfile` | `(author) => void` | - | Author click |
|
|
538
|
+
| `onHashtagClick` | `(tag) => void` | - | Hashtag click |
|
|
539
|
+
|
|
540
|
+
### Custom Usage (Advanced)
|
|
541
|
+
|
|
542
|
+
For full control, use individual components:
|
|
543
|
+
|
|
544
|
+
```tsx
|
|
545
|
+
import {
|
|
546
|
+
ShortVideoRoot, VideoFeed, VideoSlot, VideoPlayer,
|
|
547
|
+
ActionBar, AuthorInfo, VideoInfo, ProgressBar
|
|
548
|
+
} from '@xhub-short/sdk';
|
|
549
|
+
import { VideoSlotOverlay, VideoSlotPoster } from '@xhub-short/ui';
|
|
550
|
+
|
|
551
|
+
<VideoFeed renderSlot={(video, index) => (
|
|
552
|
+
<VideoSlot video={video} index={index}>
|
|
553
|
+
<VideoPlayer />
|
|
554
|
+
<VideoSlotPoster />
|
|
555
|
+
<VideoSlotOverlay>
|
|
556
|
+
<VideoSlotOverlay.Actions>
|
|
557
|
+
<AuthorInfo video={video} variant="avatar-badge" />
|
|
558
|
+
<ActionBar video={video} />
|
|
559
|
+
</VideoSlotOverlay.Actions>
|
|
560
|
+
<VideoSlotOverlay.Bottom>
|
|
561
|
+
<VideoInfo video={video} />
|
|
562
|
+
<ProgressBar showTime />
|
|
563
|
+
</VideoSlotOverlay.Bottom>
|
|
564
|
+
</VideoSlotOverlay>
|
|
565
|
+
</VideoSlot>
|
|
566
|
+
)} />
|
|
567
|
+
|
|
518
568
|
### With Custom Adapters
|
|
519
569
|
|
|
520
570
|
```tsx
|