@vplayer/core 0.1.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/defaults.d.ts +4 -0
- package/dist/event-bus.d.ts +21 -0
- package/dist/gesture-engine.d.ts +23 -0
- package/dist/hotkey-registry.d.ts +32 -0
- package/dist/i18n.d.ts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1446 -0
- package/dist/media-capabilities.d.ts +14 -0
- package/dist/media-engine/base-engine.d.ts +43 -0
- package/dist/media-engine/dash-engine.d.ts +32 -0
- package/dist/media-engine/hls-engine.d.ts +32 -0
- package/dist/media-engine/index.d.ts +7 -0
- package/dist/media-engine/native-engine.d.ts +9 -0
- package/dist/media-engine/types.d.ts +50 -0
- package/dist/player.d.ts +19 -0
- package/dist/plugin-api.d.ts +86 -0
- package/dist/source-resolver.d.ts +10 -0
- package/dist/state/slices.d.ts +134 -0
- package/dist/storage.d.ts +25 -0
- package/dist/subtitle-parser.d.ts +41 -0
- package/dist/types.d.ts +178 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +44 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { Store } from '@tanstack/store';
|
|
2
|
+
import type { EventBus } from './event-bus';
|
|
3
|
+
import type { HotkeyRegistry } from './hotkey-registry';
|
|
4
|
+
import type { I18n } from './i18n';
|
|
5
|
+
import type { MediaCapabilitiesSnapshot } from './media-capabilities';
|
|
6
|
+
import type { DashMediaEngineOptions, HlsMediaEngineOptions, MediaEngine } from './media-engine';
|
|
7
|
+
import type { PlayerPlugin } from './plugin-api';
|
|
8
|
+
import type { AspectRatioState, FlipState } from './plugin-api';
|
|
9
|
+
import type { PlayerSource } from './source-resolver';
|
|
10
|
+
import type { PlaybackStatus } from './state/slices';
|
|
11
|
+
import type { MediaState } from './state/slices';
|
|
12
|
+
import type { Storage } from './storage';
|
|
13
|
+
import type { SubtitleTrack } from './subtitle-parser';
|
|
14
|
+
export type { MediaState };
|
|
15
|
+
/** Iconify icon identifier, e.g. "lucide:play" or "mdi:play" */
|
|
16
|
+
export type SvgIcon = string;
|
|
17
|
+
export interface PlayerIcons {
|
|
18
|
+
play: SvgIcon;
|
|
19
|
+
pause: SvgIcon;
|
|
20
|
+
replay: SvgIcon;
|
|
21
|
+
skipBack: SvgIcon;
|
|
22
|
+
skipForward: SvgIcon;
|
|
23
|
+
volumeHigh: SvgIcon;
|
|
24
|
+
volumeLow: SvgIcon;
|
|
25
|
+
volumeOff: SvgIcon;
|
|
26
|
+
settings: SvgIcon;
|
|
27
|
+
pip: SvgIcon;
|
|
28
|
+
miniPlayer: SvgIcon;
|
|
29
|
+
close: SvgIcon;
|
|
30
|
+
fullscreen: SvgIcon;
|
|
31
|
+
fullscreenExit: SvgIcon;
|
|
32
|
+
chevronLeft: SvgIcon;
|
|
33
|
+
check: SvgIcon;
|
|
34
|
+
spinner: SvgIcon;
|
|
35
|
+
screenshot: SvgIcon;
|
|
36
|
+
flip: SvgIcon;
|
|
37
|
+
aspectRatio: SvgIcon;
|
|
38
|
+
info: SvgIcon;
|
|
39
|
+
loop: SvgIcon;
|
|
40
|
+
}
|
|
41
|
+
export interface PlayerOptions {
|
|
42
|
+
src: string;
|
|
43
|
+
/** MIME/content type hint used by source provider selection. */
|
|
44
|
+
type?: string;
|
|
45
|
+
poster?: string;
|
|
46
|
+
subtitles?: SubtitleTrack[];
|
|
47
|
+
qualities?: string[];
|
|
48
|
+
autoPlay?: boolean;
|
|
49
|
+
thumbnails?: string;
|
|
50
|
+
lang?: string;
|
|
51
|
+
translations?: Record<string, string>;
|
|
52
|
+
plugins?: PlayerPlugin[];
|
|
53
|
+
persistPreferences?: boolean;
|
|
54
|
+
defaultHotkeys?: boolean;
|
|
55
|
+
reconnectMax?: number;
|
|
56
|
+
reconnectSleep?: number;
|
|
57
|
+
/** Optional hls.js config passed when an .m3u8 source needs Media Source Extensions. */
|
|
58
|
+
hlsConfig?: HlsMediaEngineOptions['hlsConfig'];
|
|
59
|
+
/** Optional dash.js config passed when an .mpd source is used. */
|
|
60
|
+
dashConfig?: DashMediaEngineOptions['dashConfig'];
|
|
61
|
+
onTimeUpdate?: (time: number) => void;
|
|
62
|
+
onEnded?: () => void;
|
|
63
|
+
onError?: (message: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Custom media engine or factory.
|
|
66
|
+
*
|
|
67
|
+
* - `MediaEngine` instance — used directly (must already be bound to a
|
|
68
|
+
* `<video>` element).
|
|
69
|
+
* - `(video: HTMLVideoElement) => MediaEngine` — factory called at mount
|
|
70
|
+
* time with the player's `<video>` element.
|
|
71
|
+
*
|
|
72
|
+
* When omitted, a NativeVideoEngine is created automatically.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // HLS via factory (recommended)
|
|
77
|
+
* createPlayer({
|
|
78
|
+
* engine: (video) => new HlsMediaEngine(video, { src: '...' }),
|
|
79
|
+
* })
|
|
80
|
+
*
|
|
81
|
+
* // Pre-configured instance
|
|
82
|
+
* createPlayer({
|
|
83
|
+
* engine: new HlsMediaEngine(videoEl, { src: '...' }),
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
engine?: MediaEngine | ((video: HTMLVideoElement) => MediaEngine);
|
|
88
|
+
}
|
|
89
|
+
export type { PlaybackStatus };
|
|
90
|
+
export type { MediaCapabilitiesSnapshot, PlayerSource };
|
|
91
|
+
export interface PlayerError {
|
|
92
|
+
message: string;
|
|
93
|
+
reconnectAttempt: number;
|
|
94
|
+
isReconnecting: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface MediaRemote {
|
|
97
|
+
play: () => void;
|
|
98
|
+
pause: () => void;
|
|
99
|
+
togglePlay: () => void;
|
|
100
|
+
seek: (time: number) => void;
|
|
101
|
+
skip: (seconds: number) => void;
|
|
102
|
+
setVolume: (v: number) => void;
|
|
103
|
+
toggleMute: () => void;
|
|
104
|
+
setPlaybackRate: (rate: number) => void;
|
|
105
|
+
toggleFullscreen: () => void;
|
|
106
|
+
togglePiP: () => void;
|
|
107
|
+
setActiveSubtitle: (track: SubtitleTrack | null) => void;
|
|
108
|
+
setActiveQuality: (q: string) => void;
|
|
109
|
+
takeScreenshot: () => void;
|
|
110
|
+
setFlip: (flip: FlipState) => void;
|
|
111
|
+
setAspectRatio: (ratio: AspectRatioState) => void;
|
|
112
|
+
cycleAspectRatio: () => void;
|
|
113
|
+
toggleLoop: () => void;
|
|
114
|
+
toggleInfoPanel: () => void;
|
|
115
|
+
}
|
|
116
|
+
export interface PlayerLabels {
|
|
117
|
+
play: string;
|
|
118
|
+
pause: string;
|
|
119
|
+
replay: string;
|
|
120
|
+
mute: string;
|
|
121
|
+
unmute: string;
|
|
122
|
+
settings: string;
|
|
123
|
+
pip: string;
|
|
124
|
+
pipExit: string;
|
|
125
|
+
miniPlayer: string;
|
|
126
|
+
exitMiniPlayer: string;
|
|
127
|
+
fullscreen: string;
|
|
128
|
+
fullscreenExit: string;
|
|
129
|
+
speed: string;
|
|
130
|
+
quality: string;
|
|
131
|
+
subtitles: string;
|
|
132
|
+
off: string;
|
|
133
|
+
endedTitle: string;
|
|
134
|
+
screenshot: string;
|
|
135
|
+
flip: string;
|
|
136
|
+
flipNormal: string;
|
|
137
|
+
flipHorizontal: string;
|
|
138
|
+
flipVertical: string;
|
|
139
|
+
aspectRatio: string;
|
|
140
|
+
aspectRatioDefault: string;
|
|
141
|
+
aspectRatio16: string;
|
|
142
|
+
aspectRatio4: string;
|
|
143
|
+
aspectRatioFill: string;
|
|
144
|
+
aspectRatioCover: string;
|
|
145
|
+
aspectRatio21: string;
|
|
146
|
+
continue: string;
|
|
147
|
+
continuePlay: string;
|
|
148
|
+
continueStartOver: string;
|
|
149
|
+
error: string;
|
|
150
|
+
retry: string;
|
|
151
|
+
contextMenuPlay: string;
|
|
152
|
+
contextMenuPause: string;
|
|
153
|
+
contextMenuLoop: string;
|
|
154
|
+
infoPanel: string;
|
|
155
|
+
loop: string;
|
|
156
|
+
}
|
|
157
|
+
export interface PlayerSystems {
|
|
158
|
+
events: EventBus;
|
|
159
|
+
storage: Storage;
|
|
160
|
+
i18n: I18n;
|
|
161
|
+
hotkeys: HotkeyRegistry;
|
|
162
|
+
}
|
|
163
|
+
export interface PlayerInstance {
|
|
164
|
+
store: Store<MediaState>;
|
|
165
|
+
remote: MediaRemote;
|
|
166
|
+
events: EventBus;
|
|
167
|
+
storage: Storage;
|
|
168
|
+
i18n: I18n;
|
|
169
|
+
hotkeys: HotkeyRegistry;
|
|
170
|
+
/** The active media engine. Null before mount and after unmount. */
|
|
171
|
+
engine: MediaEngine | null;
|
|
172
|
+
updateOptions(opts: Partial<Pick<PlayerOptions, 'src' | 'type' | 'poster' | 'autoPlay' | 'subtitles' | 'qualities' | 'thumbnails'>>): void;
|
|
173
|
+
setThumbnails(url?: string): void;
|
|
174
|
+
initPlugins(plugins: PlayerPlugin[]): () => void;
|
|
175
|
+
mount(videoEl: HTMLVideoElement, containerEl: HTMLDivElement): void;
|
|
176
|
+
unmount(): void;
|
|
177
|
+
destroy(): void;
|
|
178
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatTime(seconds: number): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vplayer/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/divyam234/vplayer.git",
|
|
8
|
+
"directory": "packages/core"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"test:coverage": "vitest run --coverage"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@tanstack/store": "^0.8.0",
|
|
37
|
+
"dashjs": "^5.1.1",
|
|
38
|
+
"hls.js": "^1.6.16"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"typescript": "^6.0.2",
|
|
42
|
+
"vite": "^8.0.0"
|
|
43
|
+
}
|
|
44
|
+
}
|