libbitsub 1.11.0 → 1.12.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 +114 -17
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/hlsjs.d.ts +6 -0
- package/dist/integrations/hlsjs.d.ts.map +1 -1
- package/dist/integrations/hlsjs.js +3 -0
- package/dist/integrations/hlsjs.js.map +1 -1
- package/dist/integrations/index.d.ts +10 -2
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +10 -2
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/react.d.ts +10 -1
- package/dist/integrations/react.d.ts.map +1 -1
- package/dist/integrations/react.js +11 -2
- package/dist/integrations/react.js.map +1 -1
- package/dist/integrations/shaka.d.ts +6 -0
- package/dist/integrations/shaka.d.ts.map +1 -1
- package/dist/integrations/shaka.js +3 -0
- package/dist/integrations/shaka.js.map +1 -1
- package/dist/integrations/shared.d.ts +4 -2
- package/dist/integrations/shared.d.ts.map +1 -1
- package/dist/integrations/shared.js.map +1 -1
- package/dist/integrations/videojs.d.ts +9 -0
- package/dist/integrations/videojs.d.ts.map +1 -1
- package/dist/integrations/videojs.js +3 -0
- package/dist/integrations/videojs.js.map +1 -1
- package/dist/ts/capabilities.d.ts +14 -0
- package/dist/ts/capabilities.d.ts.map +1 -0
- package/dist/ts/capabilities.js +111 -0
- package/dist/ts/capabilities.js.map +1 -0
- package/dist/ts/diagnostics.d.ts +6 -0
- package/dist/ts/diagnostics.d.ts.map +1 -1
- package/dist/ts/diagnostics.js +6 -0
- package/dist/ts/diagnostics.js.map +1 -1
- package/dist/ts/frame-export.d.ts +4 -0
- package/dist/ts/frame-export.d.ts.map +1 -1
- package/dist/ts/frame-export.js +4 -0
- package/dist/ts/frame-export.js.map +1 -1
- package/dist/ts/parsers.d.ts +39 -2
- package/dist/ts/parsers.d.ts.map +1 -1
- package/dist/ts/parsers.js +229 -1
- package/dist/ts/parsers.js.map +1 -1
- package/dist/ts/range-loader.d.ts +6 -0
- package/dist/ts/range-loader.d.ts.map +1 -1
- package/dist/ts/range-loader.js +3 -0
- package/dist/ts/range-loader.js.map +1 -1
- package/dist/ts/renderers.d.ts +129 -10
- package/dist/ts/renderers.d.ts.map +1 -1
- package/dist/ts/renderers.js +1342 -138
- package/dist/ts/renderers.js.map +1 -1
- package/dist/ts/types.d.ts +196 -6
- package/dist/ts/types.d.ts.map +1 -1
- package/dist/ts/utils.d.ts +2 -0
- package/dist/ts/utils.d.ts.map +1 -1
- package/dist/ts/utils.js +100 -2
- package/dist/ts/utils.js.map +1 -1
- package/dist/ts/video-frame-scheduler.d.ts +35 -0
- package/dist/ts/video-frame-scheduler.d.ts.map +1 -0
- package/dist/ts/video-frame-scheduler.js +98 -0
- package/dist/ts/video-frame-scheduler.js.map +1 -0
- package/dist/ts/worker.d.ts.map +1 -1
- package/dist/ts/worker.js +394 -0
- package/dist/ts/worker.js.map +1 -1
- package/dist/wrapper.d.ts +4 -3
- package/dist/wrapper.d.ts.map +1 -1
- package/dist/wrapper.js +3 -2
- package/dist/wrapper.js.map +1 -1
- package/package.json +7 -2
- package/pkg/README.md +114 -17
- package/pkg/libbitsub.d.ts +51 -1
- package/pkg/libbitsub.js +178 -3
- package/pkg/libbitsub_bg.wasm +0 -0
- package/pkg/libbitsub_bg.wasm.d.ts +21 -0
- package/pkg/package.json +4 -4
- package/src/integrations/hlsjs.ts +6 -0
- package/src/integrations/index.ts +10 -2
- package/src/integrations/react.tsx +17 -2
- package/src/integrations/shaka.ts +6 -0
- package/src/integrations/shared.ts +4 -1
- package/src/integrations/videojs.ts +9 -0
- package/src/wrapper.ts +22 -2
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* hls.js handles HLS media and WebVTT/IMSC text tracks; use this helper for
|
|
5
5
|
* external PGS/VobSub/MKS bitmap overlays on the same media element.
|
|
6
6
|
*
|
|
7
|
+
* @module
|
|
8
|
+
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
9
11
|
* import Hls from 'hls.js'
|
|
@@ -33,8 +35,10 @@ export interface HlsLike {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
/** Options for attachBitSubToHls(). */
|
|
36
39
|
export type BitSubHlsOptions = AttachBitSubOptions
|
|
37
40
|
|
|
41
|
+
/** Handle returned by attachBitSubToHls(). */
|
|
38
42
|
export interface BitSubHlsHandle extends BitSubController {
|
|
39
43
|
/** Underlying hls.js instance. */
|
|
40
44
|
readonly hls: HlsLike
|
|
@@ -150,5 +154,7 @@ export function attachBitSubToHls(hls: HlsLike, options: BitSubHlsOptions = {}):
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
|
|
157
|
+
/** Shared attach options and controller types. */
|
|
153
158
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
159
|
+
/** Attach or construct a libbitsub controller. */
|
|
154
160
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Optional player integrations for libbitsub.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Prefer deep imports (`libbitsub/videojs`, `libbitsub/shaka`, `libbitsub/hlsjs`,
|
|
5
|
+
* `libbitsub/react`) so unused peer dependencies stay out of your bundle.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
5
8
|
*/
|
|
6
9
|
|
|
10
|
+
/** Shared attach/create helpers used by every player adapter. */
|
|
7
11
|
export {
|
|
8
12
|
attachBitSub,
|
|
9
13
|
createBitSubRenderer,
|
|
@@ -13,6 +17,7 @@ export {
|
|
|
13
17
|
type BitSubSourceOptions
|
|
14
18
|
} from './shared'
|
|
15
19
|
|
|
20
|
+
/** Video.js plugin and player typings. */
|
|
16
21
|
export {
|
|
17
22
|
registerBitSubPlugin,
|
|
18
23
|
type BitSubVideoJsApi,
|
|
@@ -22,10 +27,13 @@ export {
|
|
|
22
27
|
type VideoJsPlayerLike
|
|
23
28
|
} from './videojs'
|
|
24
29
|
|
|
30
|
+
/** Shaka Player adapter. */
|
|
25
31
|
export { attachBitSubToShaka, type BitSubShakaHandle, type BitSubShakaOptions, type ShakaPlayerLike } from './shaka'
|
|
26
32
|
|
|
33
|
+
/** hls.js adapter. */
|
|
27
34
|
export { attachBitSubToHls, type BitSubHlsHandle, type BitSubHlsOptions, type HlsLike } from './hlsjs'
|
|
28
35
|
|
|
36
|
+
/** React hook and overlay component. */
|
|
29
37
|
export {
|
|
30
38
|
BitSubOverlay,
|
|
31
39
|
useBitSub,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Optional React bindings for libbitsub bitmap subtitles.
|
|
3
3
|
*
|
|
4
|
-
* Peer dependency: react >= 18
|
|
4
|
+
* Peer dependency: react >= 18.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
5
7
|
*
|
|
6
8
|
* @example
|
|
7
9
|
* ```tsx
|
|
@@ -26,13 +28,16 @@ import { useEffect, useRef, useState, type CSSProperties, type ReactElement, typ
|
|
|
26
28
|
import { attachBitSub, type AttachBitSubOptions, type BitSubController, type BitSubSourceOptions } from './shared'
|
|
27
29
|
import type { SubtitleDisplaySettings, SubtitleDiagnosticWarning, SubtitleRendererEvent } from '../wrapper'
|
|
28
30
|
|
|
31
|
+
/** Subtitle source fields accepted by the React bindings. */
|
|
29
32
|
export type BitSubReactSource = BitSubSourceOptions
|
|
30
33
|
|
|
34
|
+
/** Options for useBitSub(). */
|
|
31
35
|
export interface UseBitSubOptions extends BitSubReactSource {
|
|
32
36
|
/** When false, do not load even if source fields are set. Default true. */
|
|
33
37
|
enabled?: boolean
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
/** Return value of useBitSub(). */
|
|
36
41
|
export interface UseBitSubResult {
|
|
37
42
|
controller: BitSubController | null
|
|
38
43
|
error: Error | null
|
|
@@ -48,6 +53,10 @@ function sourceKey(source: BitSubReactSource | null | undefined): string {
|
|
|
48
53
|
hasIdxContent: Boolean(source.idxContent),
|
|
49
54
|
cacheLimit: source.cacheLimit ?? null,
|
|
50
55
|
timeOffset: source.timeOffset ?? null,
|
|
56
|
+
frameAwareSync: source.frameAwareSync ?? null,
|
|
57
|
+
backend: source.backend ?? null,
|
|
58
|
+
devicePixelRatioCap: source.devicePixelRatioCap ?? null,
|
|
59
|
+
offscreenRender: source.offscreenRender ?? null,
|
|
51
60
|
streamingLoad: source.streamingLoad ?? null,
|
|
52
61
|
rangeRequests: source.rangeRequests ?? null,
|
|
53
62
|
debug: source.debug ?? null,
|
|
@@ -83,6 +92,8 @@ export function useBitSub(
|
|
|
83
92
|
const enabled = options?.enabled !== false
|
|
84
93
|
const key = sourceKey(options)
|
|
85
94
|
const displaySettings = options?.displaySettings
|
|
95
|
+
const container = options?.container
|
|
96
|
+
const canvas = options?.canvas
|
|
86
97
|
|
|
87
98
|
useEffect(() => {
|
|
88
99
|
setError(null)
|
|
@@ -135,7 +146,7 @@ export function useBitSub(
|
|
|
135
146
|
setController(null)
|
|
136
147
|
}
|
|
137
148
|
// key captures source identity; callback props stay fresh via refs
|
|
138
|
-
}, [videoRef, key, enabled])
|
|
149
|
+
}, [videoRef, key, enabled, container, canvas])
|
|
139
150
|
|
|
140
151
|
useEffect(() => {
|
|
141
152
|
if (displaySettings) {
|
|
@@ -146,6 +157,7 @@ export function useBitSub(
|
|
|
146
157
|
return { controller, error }
|
|
147
158
|
}
|
|
148
159
|
|
|
160
|
+
/** Props for BitSubOverlay. */
|
|
149
161
|
export interface BitSubOverlayProps extends UseBitSubOptions {
|
|
150
162
|
videoRef: RefObject<HTMLVideoElement | null>
|
|
151
163
|
/** Optional class name applied to a zero-size host span for debugging. */
|
|
@@ -165,6 +177,9 @@ export function BitSubOverlay(props: BitSubOverlayProps): ReactElement | null {
|
|
|
165
177
|
return <span className={className} style={{ display: 'none', ...style }} aria-hidden='true' />
|
|
166
178
|
}
|
|
167
179
|
|
|
180
|
+
/** Shared attach options and controller types. */
|
|
168
181
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
182
|
+
/** Attach or construct a libbitsub controller. */
|
|
169
183
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
|
184
|
+
/** Runtime overlay display settings. */
|
|
170
185
|
export type { SubtitleDisplaySettings }
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Bitmap PGS/VobSub tracks are not native Shaka text tracks — this helper
|
|
5
5
|
* overlays libbitsub on the player media element.
|
|
6
6
|
*
|
|
7
|
+
* @module
|
|
8
|
+
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
9
11
|
* import shaka from 'shaka-player'
|
|
@@ -26,8 +28,10 @@ export interface ShakaPlayerLike {
|
|
|
26
28
|
removeEventListener?(type: string, listener: (...args: unknown[]) => void): void
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
/** Options for attachBitSubToShaka(). */
|
|
29
32
|
export type BitSubShakaOptions = AttachBitSubOptions
|
|
30
33
|
|
|
34
|
+
/** Handle returned by attachBitSubToShaka(). */
|
|
31
35
|
export interface BitSubShakaHandle extends BitSubController {
|
|
32
36
|
/** Underlying Shaka player reference. */
|
|
33
37
|
readonly player: ShakaPlayerLike
|
|
@@ -88,5 +92,7 @@ export function attachBitSubToShaka(player: ShakaPlayerLike, options: BitSubShak
|
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
/** Shared attach options and controller types. */
|
|
91
96
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
97
|
+
/** Attach or construct a libbitsub controller. */
|
|
92
98
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import {
|
|
7
7
|
createAutoSubtitleRenderer,
|
|
8
8
|
type AutoVideoSubtitleOptions,
|
|
9
|
+
type DvbRenderer,
|
|
9
10
|
type PgsRenderer,
|
|
10
11
|
type SubtitleDisplaySettings,
|
|
11
12
|
type SubtitleRendererStats,
|
|
@@ -13,11 +14,12 @@ import {
|
|
|
13
14
|
} from '../wrapper'
|
|
14
15
|
|
|
15
16
|
/** High-level renderer produced by integrations. */
|
|
16
|
-
export type BitSubRenderer = PgsRenderer | VobSubRenderer
|
|
17
|
+
export type BitSubRenderer = PgsRenderer | VobSubRenderer | DvbRenderer
|
|
17
18
|
|
|
18
19
|
/** Subtitle source + renderer options without a bound video element. */
|
|
19
20
|
export type BitSubSourceOptions = Omit<AutoVideoSubtitleOptions, 'video'>
|
|
20
21
|
|
|
22
|
+
/** Handle returned by player adapters. */
|
|
21
23
|
export interface BitSubController {
|
|
22
24
|
/** Active renderer, or null when no track is loaded. */
|
|
23
25
|
readonly renderer: BitSubRenderer | null
|
|
@@ -39,6 +41,7 @@ export interface BitSubController {
|
|
|
39
41
|
setVideo(video: HTMLVideoElement | null): void
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
/** Options for attachBitSub(). */
|
|
42
45
|
export interface AttachBitSubOptions extends BitSubSourceOptions {
|
|
43
46
|
/** When false, skip the initial load even if source fields are present. Default true. */
|
|
44
47
|
autoLoad?: boolean
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Optional Video.js plugin for libbitsub bitmap subtitles.
|
|
3
3
|
*
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
4
6
|
* @example
|
|
5
7
|
* ```ts
|
|
6
8
|
* import videojs from 'video.js'
|
|
@@ -26,24 +28,29 @@ export interface VideoJsPlayerLike {
|
|
|
26
28
|
trigger?(event: string, data?: unknown): void
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
/** Minimal Video.js plugin instance surface. */
|
|
29
32
|
export interface VideoJsPluginBase {
|
|
30
33
|
player: VideoJsPlayerLike
|
|
31
34
|
options_: unknown
|
|
32
35
|
dispose(): void
|
|
33
36
|
}
|
|
34
37
|
|
|
38
|
+
/** Minimal Video.js plugin constructor surface. */
|
|
35
39
|
export interface VideoJsPluginConstructor {
|
|
36
40
|
new (player: VideoJsPlayerLike, options?: unknown): VideoJsPluginBase
|
|
37
41
|
prototype: VideoJsPluginBase
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
/** Minimal video.js factory used by the plugin. */
|
|
40
45
|
export interface VideoJsLike {
|
|
41
46
|
getPlugin(name: string): VideoJsPluginConstructor
|
|
42
47
|
registerPlugin(name: string, plugin: unknown): void
|
|
43
48
|
}
|
|
44
49
|
|
|
50
|
+
/** Options for player.bitsub(). */
|
|
45
51
|
export type BitSubVideoJsOptions = AttachBitSubOptions
|
|
46
52
|
|
|
53
|
+
/** Video.js player.bitsub() API. */
|
|
47
54
|
export interface BitSubVideoJsApi {
|
|
48
55
|
/** Active controller, if any. */
|
|
49
56
|
controller(): BitSubController | null
|
|
@@ -196,5 +203,7 @@ export type VideoJsBitSubPlayer = VideoJsPlayerLike & {
|
|
|
196
203
|
bitsub(options?: BitSubVideoJsOptions): BitSubVideoJsApi
|
|
197
204
|
}
|
|
198
205
|
|
|
206
|
+
/** Shared attach options and controller types. */
|
|
199
207
|
export type { AttachBitSubOptions, BitSubController, BitSubSourceOptions, BitSubRenderer } from './shared'
|
|
208
|
+
/** Attach or construct a libbitsub controller. */
|
|
200
209
|
export { attachBitSub, createBitSubRenderer } from './shared'
|
package/src/wrapper.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type {
|
|
|
8
8
|
AssetFetchStrategy,
|
|
9
9
|
AutoSubtitleSource,
|
|
10
10
|
AutoVideoSubtitleOptions,
|
|
11
|
+
LiveSubtitleRenderer,
|
|
11
12
|
OpenedSubtitles,
|
|
12
13
|
SubtitleAspectMode,
|
|
13
14
|
SubtitleCacheStats,
|
|
@@ -34,6 +35,10 @@ export type {
|
|
|
34
35
|
SubtitleRendererBackend,
|
|
35
36
|
SubtitleRendererEvent,
|
|
36
37
|
SubtitleRendererStatsSnapshot,
|
|
38
|
+
SubtitleSynchronizationMode,
|
|
39
|
+
SubtitleStreamChunk,
|
|
40
|
+
RuntimeCapabilities,
|
|
41
|
+
SubtitlePresentPath,
|
|
37
42
|
VideoSubtitleOptions,
|
|
38
43
|
VideoVobSubOptions,
|
|
39
44
|
RenderResult,
|
|
@@ -51,14 +56,29 @@ export { warmup, ready, isWorkerAvailable, isWorkerReady } from './ts/worker'
|
|
|
51
56
|
// Re-export WebGPU utilities
|
|
52
57
|
export { isWebGPUSupported } from './ts/webgpu-renderer'
|
|
53
58
|
|
|
59
|
+
export {
|
|
60
|
+
getRuntimeCapabilities,
|
|
61
|
+
canUseWorkerOffscreenRender,
|
|
62
|
+
isOffscreenCanvasSupported,
|
|
63
|
+
isOffscreenCanvas2DSupported,
|
|
64
|
+
isTransferControlToOffscreenSupported,
|
|
65
|
+
isCanvas2DSupported
|
|
66
|
+
} from './ts/capabilities'
|
|
67
|
+
|
|
54
68
|
// Re-export parsers
|
|
55
|
-
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './ts/parsers'
|
|
69
|
+
export { PgsParser, DvbParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './ts/parsers'
|
|
56
70
|
|
|
57
71
|
// Re-export frame export helpers
|
|
58
72
|
export { renderFrameData, toBlob, toCanvas, toImageBitmap } from './ts/frame-export'
|
|
59
73
|
|
|
60
74
|
// Re-export renderers
|
|
61
|
-
export {
|
|
75
|
+
export {
|
|
76
|
+
PgsRenderer,
|
|
77
|
+
DvbRenderer,
|
|
78
|
+
VobSubRenderer,
|
|
79
|
+
createAutoSubtitleRenderer,
|
|
80
|
+
type SubtitleRendererStats
|
|
81
|
+
} from './ts/renderers'
|
|
62
82
|
|
|
63
83
|
// Re-export format detection utilities
|
|
64
84
|
export { detectSubtitleFormat } from './ts/utils'
|