videojs-rewind 0.1.0 → 0.2.3
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 +79 -10
- package/dist/dom.d.ts +11 -0
- package/dist/index.js +295 -56382
- package/dist/plugin.d.ts +32 -13
- package/dist/schema.d.ts +49 -3
- package/dist/types.d.ts +5 -11
- package/dist/utils.d.ts +9 -0
- package/dist/videojs-rewind.css +6 -0
- package/package.json +1 -1
package/dist/plugin.d.ts
CHANGED
|
@@ -18,12 +18,16 @@ declare class RewindPlugin extends RewindPlugin_base {
|
|
|
18
18
|
dom: PluginDomElements;
|
|
19
19
|
private _tickInterval;
|
|
20
20
|
private _cdns;
|
|
21
|
-
private
|
|
21
|
+
private _storyboardEntry;
|
|
22
22
|
private _spriteImages;
|
|
23
23
|
private _qualitySuppressionTimer;
|
|
24
24
|
private _toastTimer;
|
|
25
25
|
private _keydownHandler;
|
|
26
26
|
private _wasPlaying;
|
|
27
|
+
private _isDisposed;
|
|
28
|
+
private _dragListenersAttached;
|
|
29
|
+
private _vhsTech;
|
|
30
|
+
private _vhsHookEvent;
|
|
27
31
|
/**
|
|
28
32
|
* @param player - The video.js player instance
|
|
29
33
|
* @param options - Partial plugin options (merged with defaults via Zod)
|
|
@@ -40,15 +44,12 @@ declare class RewindPlugin extends RewindPlugin_base {
|
|
|
40
44
|
private _buildDOM;
|
|
41
45
|
/** Remove all injected DOM elements. */
|
|
42
46
|
private _removeDOM;
|
|
43
|
-
|
|
44
|
-
* Create a DOM element with attributes and optional text content.
|
|
45
|
-
*/
|
|
46
|
-
private _createEl;
|
|
47
|
-
private _responseHook;
|
|
47
|
+
private _onVhsResponse;
|
|
48
48
|
private _wireVhsHooks;
|
|
49
49
|
private _unwireVhsHooks;
|
|
50
50
|
/**
|
|
51
51
|
* Get the CDN base URL for a given playlist URI.
|
|
52
|
+
* Prefers an explicit cdnBaseUrl option, falls back to captured values.
|
|
52
53
|
*/
|
|
53
54
|
private _getCdnBaseUrl;
|
|
54
55
|
private _wireKeyboardSeek;
|
|
@@ -88,13 +89,26 @@ declare class RewindPlugin extends RewindPlugin_base {
|
|
|
88
89
|
*/
|
|
89
90
|
private _startQualitySuppression;
|
|
90
91
|
/**
|
|
91
|
-
* Load quality preference
|
|
92
|
+
* Load quality preference. A host-supplied `loadQuality` callback takes
|
|
93
|
+
* precedence over localStorage. When neither is available, falls back to
|
|
94
|
+
* in-memory state only.
|
|
92
95
|
*/
|
|
93
96
|
private _loadQualityPreference;
|
|
94
97
|
/**
|
|
95
|
-
* Save quality preference
|
|
98
|
+
* Save quality preference. A host-supplied `saveQuality` callback takes
|
|
99
|
+
* precedence over localStorage.
|
|
96
100
|
*/
|
|
97
101
|
private _saveQualityPreference;
|
|
102
|
+
/**
|
|
103
|
+
* Seek to `time`, running rewind-to-VOD detection when behind the DVR window.
|
|
104
|
+
* Public so hosts (keyboard shortcuts, programmatic seeks) share the plugin's
|
|
105
|
+
* seek behavior instead of bypassing it with a raw `player.currentTime()`.
|
|
106
|
+
*/
|
|
107
|
+
seek(time: number): void;
|
|
108
|
+
/**
|
|
109
|
+
* Return to the live source. Public for host keyboard shortcuts / buttons.
|
|
110
|
+
*/
|
|
111
|
+
goLive(): void;
|
|
98
112
|
/**
|
|
99
113
|
* Set the preferred quality level.
|
|
100
114
|
* @param quality - Quality height (e.g., 1080) or 'auto'
|
|
@@ -105,7 +119,8 @@ declare class RewindPlugin extends RewindPlugin_base {
|
|
|
105
119
|
*/
|
|
106
120
|
getQuality(): number | 'auto';
|
|
107
121
|
/**
|
|
108
|
-
* Fetch storyboard metadata for a VOD
|
|
122
|
+
* Fetch storyboard metadata for a VOD, validate it, select the preferred
|
|
123
|
+
* entry, and preload sprite images.
|
|
109
124
|
*/
|
|
110
125
|
private _fetchStoryboardInfo;
|
|
111
126
|
/**
|
|
@@ -125,12 +140,16 @@ declare class RewindPlugin extends RewindPlugin_base {
|
|
|
125
140
|
*/
|
|
126
141
|
private _hideStoryboard;
|
|
127
142
|
/**
|
|
128
|
-
*
|
|
143
|
+
* Get the channel name from the host-supplied option.
|
|
144
|
+
* Falls back to 'unknown' when not provided.
|
|
129
145
|
*/
|
|
130
|
-
|
|
146
|
+
private _getChannelName;
|
|
131
147
|
/**
|
|
132
|
-
*
|
|
148
|
+
* Best-effort live stream total elapsed seconds (how far into the broadcast
|
|
149
|
+
* the live edge is). Passed to `resolveVodUrl` so the host can pick the VOD
|
|
150
|
+
* matching the current broadcast without re-deriving it. Returns 0 when not
|
|
151
|
+
* on a live source or when the live tracker is unavailable.
|
|
133
152
|
*/
|
|
134
|
-
private
|
|
153
|
+
private _getLiveTotalElapsed;
|
|
135
154
|
}
|
|
136
155
|
export default RewindPlugin;
|
package/dist/schema.d.ts
CHANGED
|
@@ -5,15 +5,55 @@
|
|
|
5
5
|
* Provides runtime validation of plugin options with descriptive error messages.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
/** A single storyboard sprite sheet descriptor. */
|
|
9
|
+
export declare const StoryboardEntrySchema: z.ZodObject<{
|
|
10
|
+
width: z.ZodNumber;
|
|
11
|
+
height: z.ZodNumber;
|
|
12
|
+
cols: z.ZodNumber;
|
|
13
|
+
rows: z.ZodNumber;
|
|
14
|
+
interval: z.ZodNumber;
|
|
15
|
+
count: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
images: z.ZodArray<z.ZodString>;
|
|
17
|
+
quality: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
/** Storyboard info may be a single entry or an array of entries. */
|
|
20
|
+
export declare const StoryboardInfoSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
21
|
+
width: z.ZodNumber;
|
|
22
|
+
height: z.ZodNumber;
|
|
23
|
+
cols: z.ZodNumber;
|
|
24
|
+
rows: z.ZodNumber;
|
|
25
|
+
interval: z.ZodNumber;
|
|
26
|
+
count: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
images: z.ZodArray<z.ZodString>;
|
|
28
|
+
quality: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>, z.ZodArray<z.ZodObject<{
|
|
30
|
+
width: z.ZodNumber;
|
|
31
|
+
height: z.ZodNumber;
|
|
32
|
+
cols: z.ZodNumber;
|
|
33
|
+
rows: z.ZodNumber;
|
|
34
|
+
interval: z.ZodNumber;
|
|
35
|
+
count: z.ZodDefault<z.ZodNumber>;
|
|
36
|
+
images: z.ZodArray<z.ZodString>;
|
|
37
|
+
quality: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strict>>]>;
|
|
8
39
|
/** Full plugin options schema */
|
|
9
40
|
export declare const RewindPluginOptionsSchema: z.ZodObject<{
|
|
10
41
|
customSeekBar: z.ZodDefault<z.ZodBoolean>;
|
|
11
42
|
showTotalTime: z.ZodDefault<z.ZodBoolean>;
|
|
12
43
|
enableRewindToVod: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
-
|
|
44
|
+
channelName: z.ZodOptional<z.ZodString>;
|
|
45
|
+
liveUrl: z.ZodOptional<z.ZodString>;
|
|
46
|
+
cdnBaseUrl: z.ZodOptional<z.ZodString>;
|
|
47
|
+
resolveVodUrl: z.ZodDefault<z.ZodNullable<z.ZodCustom<(channelName: string, seekTime: number, context?: {
|
|
48
|
+
currentVodId?: string;
|
|
49
|
+
liveTotalElapsed?: number;
|
|
50
|
+
}) => Promise<{
|
|
14
51
|
vodId: string;
|
|
15
52
|
hlsUrl: string;
|
|
16
|
-
} | null>, (channelName: string, seekTime: number
|
|
53
|
+
} | null>, (channelName: string, seekTime: number, context?: {
|
|
54
|
+
currentVodId?: string;
|
|
55
|
+
liveTotalElapsed?: number;
|
|
56
|
+
}) => Promise<{
|
|
17
57
|
vodId: string;
|
|
18
58
|
hlsUrl: string;
|
|
19
59
|
} | null>>>>;
|
|
@@ -21,13 +61,19 @@ export declare const RewindPluginOptionsSchema: z.ZodObject<{
|
|
|
21
61
|
preferredQuality: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"auto">]>>;
|
|
22
62
|
persistQuality: z.ZodDefault<z.ZodBoolean>;
|
|
23
63
|
storageKeyPrefix: z.ZodDefault<z.ZodString>;
|
|
64
|
+
loadQuality: z.ZodDefault<z.ZodNullable<z.ZodCustom<() => number | 'auto' | null, () => number | 'auto' | null>>>;
|
|
65
|
+
saveQuality: z.ZodDefault<z.ZodNullable<z.ZodCustom<(quality: number | 'auto') => void, (quality: number | 'auto') => void>>>;
|
|
24
66
|
storyboard: z.ZodOptional<z.ZodObject<{
|
|
25
|
-
fetchInfo: z.
|
|
67
|
+
fetchInfo: z.ZodDefault<z.ZodNullable<z.ZodCustom<(vodId: string, cdnBaseUrl: string) => Promise<unknown>, (vodId: string, cdnBaseUrl: string) => Promise<unknown>>>>;
|
|
68
|
+
resolveImageUrl: z.ZodDefault<z.ZodNullable<z.ZodCustom<(imageRef: string, entry: z.infer<typeof StoryboardEntrySchema>, cdnBaseUrl: string) => string, (imageRef: string, entry: z.infer<typeof StoryboardEntrySchema>, cdnBaseUrl: string) => string>>>;
|
|
69
|
+
preferredQuality: z.ZodOptional<z.ZodString>;
|
|
26
70
|
previewWidth: z.ZodDefault<z.ZodNumber>;
|
|
27
71
|
previewHeight: z.ZodDefault<z.ZodNumber>;
|
|
28
72
|
}, z.core.$strict>>;
|
|
29
73
|
dvrWindowThreshold: z.ZodDefault<z.ZodNumber>;
|
|
30
74
|
showToasts: z.ZodDefault<z.ZodBoolean>;
|
|
75
|
+
enableKeyboardSeek: z.ZodDefault<z.ZodBoolean>;
|
|
76
|
+
keyboardSeekStep: z.ZodDefault<z.ZodNumber>;
|
|
31
77
|
}, z.core.$strict>;
|
|
32
78
|
/** Type for the resolved options after schema parsing */
|
|
33
79
|
export type ResolvedRewindPluginOptions = z.output<typeof RewindPluginOptionsSchema>;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,19 +2,13 @@
|
|
|
2
2
|
* Type definitions for videojs-rewind.
|
|
3
3
|
*/
|
|
4
4
|
import type { z } from 'zod';
|
|
5
|
-
import type { RewindPluginOptionsSchema } from './schema.js';
|
|
5
|
+
import type { RewindPluginOptionsSchema, StoryboardInfoSchema, StoryboardEntrySchema } from './schema.js';
|
|
6
6
|
/** Inferred plugin options type from the Zod schema */
|
|
7
7
|
export type RewindPluginOptions = z.infer<typeof RewindPluginOptionsSchema>;
|
|
8
|
-
/**
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cols: number;
|
|
13
|
-
rows: number;
|
|
14
|
-
interval: number;
|
|
15
|
-
count: number;
|
|
16
|
-
images: string[];
|
|
17
|
-
}
|
|
8
|
+
/** A single storyboard sprite sheet descriptor (validated at runtime by Zod). */
|
|
9
|
+
export type StoryboardEntry = z.infer<typeof StoryboardEntrySchema>;
|
|
10
|
+
/** Storyboard info: a single entry or an array of entries (validated at runtime). */
|
|
11
|
+
export type StoryboardInfo = z.infer<typeof StoryboardInfoSchema>;
|
|
18
12
|
/** Resolved VOD result from the resolveVodUrl callback */
|
|
19
13
|
export interface VodResult {
|
|
20
14
|
vodId: string;
|
package/dist/utils.d.ts
ADDED
package/dist/videojs-rewind.css
CHANGED
|
@@ -142,6 +142,12 @@
|
|
|
142
142
|
display: none;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/* Disable slider/handle transitions during scrubbing for instant feedback */
|
|
146
|
+
.vjs-rewind-active.vjs-scrubbing .vjs-rewind-slider,
|
|
147
|
+
.vjs-rewind-active.vjs-scrubbing .vjs-rewind-handle {
|
|
148
|
+
transition: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
145
151
|
/* ---------------------------------------------------------------------------
|
|
146
152
|
Responsive: Hide timer on small players
|
|
147
153
|
--------------------------------------------------------------------------- */
|