@vocalstack/player 0.1.0-alpha.4 → 0.1.0-alpha.40

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 CHANGED
@@ -21,7 +21,7 @@ export function Video() {
21
21
 
22
22
  | Prop | Default | |
23
23
  |---|---|---|
24
- | `id` | | A share code. Or, with `token`, a transcription id. |
24
+ | `id` | | A share code. Or, with `token`, a transcription id. With neither `id` nor `src`, the player opens on a box where the visitor pastes any video link and transcribes it in their own VocalStack account. |
25
25
  | `src` | | A video or audio link (YouTube, Vimeo, an mp3 or any media URL) instead of `id`. If the visitor has already transcribed it with VocalStack, it plays. If not, they are asked whether to start transcribing it. With `token`, the link is looked up in that account instead. |
26
26
  | `token` | | A browser token (or a function returning one) for a private transcription. Never pass an API key to a browser. |
27
27
  | `mode` | `'video'` | `'video'` for the full player, `'transcript'` for the reading view with a player. |
@@ -35,6 +35,10 @@ export function Video() {
35
35
  | `endCard` | on | At the end of a video, offers to transcribe another link in the visitor's own VocalStack account. Pass `false` to turn it off. |
36
36
  | `baseUrl` | `https://api.vocalstack.com` | |
37
37
  | `onSource`, `onProgress`, `onError` | | Called with the loaded transcription, the transcription progress (0-100, `null` when done), and errors. |
38
+ | `onPlayback` | | Called about ten times a second while anything changes, with `{ t, dur, playing, idx, seekN, lang }`: the time in seconds, the length, whether it plays, the index of the current line, a counter that grows on every seek, and the language shown. |
39
+ | `ref` | | A `PlayerHandle`: `seek(t)`, `play()`, `pause()`, `toggle()`. |
40
+ | `compact` | `false` | Small controls at any width, and no title, summary or share card when paused. For a player inside a side column or card. |
41
+ | `poster` | | An image shown behind the player before a video is chosen or before the visitor connects. |
38
42
 
39
43
  ### Settings
40
44
 
@@ -61,6 +65,14 @@ export function Video() {
61
65
  <VocalStackPlayer src="https://www.youtube.com/watch?v=QWCLiPOgeuw" />
62
66
  ```
63
67
 
68
+ Follow and drive it from your page:
69
+
70
+ ```tsx
71
+ const player = useRef<PlayerHandle>(null);
72
+ <VocalStackPlayer ref={player} id="r4m4srrrhi24" onPlayback={(s) => setAt(s.t)} />
73
+ <button onClick={() => player.current?.seek(42)}>Jump to 0:42</button>
74
+ ```
75
+
64
76
  Theme it by overriding the CSS variables on `.vsp`, for example `--vsp-radius`, `--brand` and `--vs-font-sans`.
65
77
 
66
78
  ## License
@@ -0,0 +1,18 @@
1
+ export interface EmbedAt {
2
+ t: number;
3
+ play: boolean;
4
+ host?: string;
5
+ }
6
+ export declare function loomId(raw: string): string | null;
7
+ export declare function vimeoIds(raw: string): {
8
+ id: string;
9
+ h: string | null;
10
+ } | null;
11
+ export declare function dailymotionId(raw: string): string | null;
12
+ export declare function twitchTarget(raw: string): {
13
+ video?: string;
14
+ channel?: string;
15
+ clip?: string;
16
+ } | null;
17
+ export declare function embedUrl(raw: string, at: EmbedAt): string | null;
18
+ export declare function hasEmbed(raw: string | null | undefined): boolean;
@@ -0,0 +1,4 @@
1
+ import type { FollowSetup } from '../ui/FileFollow';
2
+ export declare function loomStreamUrl(id: string): Promise<string | null>;
3
+ export declare function signedLoader(master: string): (xhr: XMLHttpRequest, u: string) => void;
4
+ export declare function loomSetup(id: string): FollowSetup;
@@ -0,0 +1,13 @@
1
+ export type SiteId = 'youtube' | 'loom' | 'vimeo' | 'twitch' | 'facebook' | 'instagram' | 'dailymotion' | 'tiktok' | 'x' | 'soundcloud' | 'kick' | 'mixcloud' | 'bandcamp';
2
+ export interface Site {
3
+ id: SiteId;
4
+ name: string;
5
+ color: string;
6
+ hosts: RegExp;
7
+ glyph: string;
8
+ audioOnly?: boolean;
9
+ }
10
+ export declare const SITES: Site[];
11
+ export declare function siteById(id: string | null | undefined): Site | null;
12
+ export declare function hostOfUrl(url: string | null | undefined): string | null;
13
+ export declare function siteOf(url: string | null | undefined): Site | null;
@@ -0,0 +1,10 @@
1
+ export type VoiceWait = 'asked' | 'line' | null;
2
+ export declare function voiceWait(o: {
3
+ on: boolean;
4
+ want: boolean;
5
+ relang: boolean;
6
+ playing: boolean;
7
+ preparing: boolean;
8
+ starting: number | null | undefined;
9
+ }): VoiceWait;
10
+ export declare const VOICE_WAIT_TITLE = "Preparing the voice\u2026";
@@ -5,11 +5,13 @@ export interface Started {
5
5
  token: string;
6
6
  expiresAt: string | null;
7
7
  }
8
- export type PopupStatus = 'signing-in' | 'consent' | 'checking' | 'starting';
8
+ export type PopupStatus = 'signing-in' | 'consent' | 'looking' | 'confirm' | 'checking' | 'starting';
9
9
  export declare function openPopup(appUrl: string | undefined, ask: {
10
10
  url?: string;
11
11
  transcription?: string;
12
12
  ask?: boolean;
13
- }, onStatus?: (s: PopupStatus) => void): Promise<Started | null>;
13
+ connect?: boolean;
14
+ }, onStatus?: (s: PopupStatus) => void): Promise<Started | 'connected' | null>;
14
15
  export declare function startFromEmbed(appUrl: string | undefined, url: string, onStatus?: (s: PopupStatus) => void): Promise<Started | null>;
15
- export declare function refreshToken(appUrl: string | undefined, transcriptionId: string): Promise<Started | null>;
16
+ export declare function wasConnected(appUrl: string | undefined): boolean;
17
+ export declare function rememberConnected(appUrl: string | undefined): void;
@@ -3,6 +3,7 @@ export interface ErrorLike {
3
3
  code?: string;
4
4
  status?: number;
5
5
  details?: any;
6
+ requestId?: string;
6
7
  }
7
8
  export declare const GENERIC: string;
8
9
  export declare const OFFLINE = "Can't reach VocalStack. Check your connection.";
@@ -0,0 +1,8 @@
1
+ export declare function useYtTitle(ytId: string | null): string | null;
2
+ export declare function displayName(parts: {
3
+ name?: string | null;
4
+ sourceName?: string | null;
5
+ ytTitle?: string | null;
6
+ url?: string | null;
7
+ id: string;
8
+ }): string;
@@ -67,7 +67,7 @@ export declare function IconButton({ children, onClick, label, size, variant, bo
67
67
  active?: boolean;
68
68
  title?: string;
69
69
  }): import("react").JSX.Element;
70
- export declare function LanguageChip({ flag, code, label, onClick, variant, block, bordered, size, style }: {
70
+ export declare function LanguageChip({ flag, code, label, onClick, variant, block, bordered, size, style, flagOnly }: {
71
71
  flag: ReactNode;
72
72
  code: string;
73
73
  label?: string;
@@ -77,6 +77,7 @@ export declare function LanguageChip({ flag, code, label, onClick, variant, bloc
77
77
  bordered?: boolean;
78
78
  size?: 'sm';
79
79
  style?: React.CSSProperties;
80
+ flagOnly?: boolean;
80
81
  }): import("react").JSX.Element;
81
82
  export declare function CopyButton({ value, label, onCopied }: {
82
83
  value: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import './styles.css';
2
- export { VocalStackPlayer, type VocalStackPlayerProps, type PlayerSettings, type PlayerControls } from './ui/VocalStackPlayer';
2
+ export { VocalStackPlayer, type VocalStackPlayerProps, type PlayerSettings, type PlayerControls, type PlayerHandle, type PlaybackState } from './ui/VocalStackPlayer';
3
3
  export type { EndCardOptions } from './ui/EndCard';
4
4
  export { PlayerApiProvider, usePlayerApi, useApi, type PlayerApi, type PlayerApiProviderProps, type ApiOptions, type PlayerSource, type TokenSource, type Listen } from './data/context';
5
5
  export type { ErrorLike } from './data/errors';
@@ -10,3 +10,5 @@ export { Transport, ReplayScrub, ExportPanel, SummaryPanel, SpeakerCast, VoiceSh
10
10
  export { FullVideo, MiniPlayer, PanelSeek, browserFull, realFull, setFullTarget, type PlayerPos, type PlayerTransport, type VoicesBtn } from './ui/full';
11
11
  export { useBackgroundBed, useSeparatedTrack, bedNote, trackPlan, REMOVE_BG_LABEL, REMOVE_BG_NOTE, type BedState, type TrackPlan, type Separated } from './core/background';
12
12
  export { snapPosition, placePosition, type PlayPos } from './core/playPosition';
13
+ export { SITES, siteOf, siteById, hostOfUrl, type Site, type SiteId } from './core/sites';
14
+ export { SiteIcon } from './ui/SiteIcon';