libbitsub 1.9.0 → 1.10.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/README.md +176 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ts/diagnostics.d.ts +35 -0
- package/dist/ts/diagnostics.d.ts.map +1 -0
- package/dist/ts/diagnostics.js +102 -0
- package/dist/ts/diagnostics.js.map +1 -0
- package/dist/ts/frame-export.d.ts +6 -0
- package/dist/ts/frame-export.d.ts.map +1 -0
- package/dist/ts/frame-export.js +235 -0
- package/dist/ts/frame-export.js.map +1 -0
- package/dist/ts/parsers.d.ts +44 -4
- package/dist/ts/parsers.d.ts.map +1 -1
- package/dist/ts/parsers.js +269 -56
- package/dist/ts/parsers.js.map +1 -1
- package/dist/ts/renderers.d.ts +19 -2
- package/dist/ts/renderers.d.ts.map +1 -1
- package/dist/ts/renderers.js +150 -27
- package/dist/ts/renderers.js.map +1 -1
- package/dist/ts/types.d.ts +110 -1
- package/dist/ts/types.d.ts.map +1 -1
- package/dist/ts/utils.d.ts +1 -1
- package/dist/ts/utils.d.ts.map +1 -1
- package/dist/ts/utils.js +8 -1
- package/dist/ts/utils.js.map +1 -1
- package/dist/ts/worker.d.ts.map +1 -1
- package/dist/ts/worker.js +6 -4
- package/dist/ts/worker.js.map +1 -1
- package/dist/wrapper.d.ts +4 -2
- package/dist/wrapper.d.ts.map +1 -1
- package/dist/wrapper.js +4 -1
- package/dist/wrapper.js.map +1 -1
- package/package.json +1 -1
- package/pkg/README.md +176 -8
- package/pkg/libbitsub.d.ts +15 -0
- package/pkg/libbitsub.js +48 -0
- package/pkg/libbitsub_bg.wasm +0 -0
- package/pkg/libbitsub_bg.wasm.d.ts +3 -0
- package/pkg/package.json +1 -1
- package/src/wrapper.ts +20 -1
package/dist/ts/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/ts/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,IAAI,YAAY,GAAkB,IAAI,CAAA;AACtC,IAAI,iBAAiB,GAA2B,IAAI,CAAA;AACpD,IAAI,SAAS,GAAG,CAAC,CAAA;AAEjB,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAM7B,CAAA;AAEH,0CAA0C;AAC1C,MAAM,UAAU,iBAAiB;IAC7B,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,KAAK,WAAW,CAAA;AACxG,CAAC;AAED,6DAA6D;AAC7D,SAAS,kBAAkB;IACvB,OAAO
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/ts/worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,IAAI,YAAY,GAAkB,IAAI,CAAA;AACtC,IAAI,iBAAiB,GAA2B,IAAI,CAAA;AACpD,IAAI,SAAS,GAAG,CAAC,CAAA;AAEjB,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAM7B,CAAA;AAEH,0CAA0C;AAC1C,MAAM,UAAU,iBAAiB;IAC7B,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,KAAK,WAAW,CAAA;AACxG,CAAC;AAED,6DAA6D;AAC7D,SAAS,kBAAkB;IACvB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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pgs-js implementation.
|
|
4
4
|
*/
|
|
5
|
-
export type { AutoSubtitleSource, AutoVideoSubtitleOptions, SubtitleAspectMode, SubtitleCueBounds, SubtitleCueMetadata, SubtitleData, SubtitleCompositionData, SubtitleDisplaySettings, SubtitleFormatName, SubtitleHorizontalAlign, SubtitleParserMetadata, SubtitleRendererBackend, SubtitleRendererEvent, SubtitleRendererStatsSnapshot, VideoSubtitleOptions, VideoVobSubOptions, RenderResult, SubtitleFrame, VobSubFrame } from './ts/types';
|
|
5
|
+
export type { AutoSubtitleSource, AutoVideoSubtitleOptions, OpenedSubtitles, SubtitleAspectMode, SubtitleCacheStats, SubtitleFrameCanvasOptions, SubtitleFrameCanvasTarget, SubtitleFrameCropMode, SubtitleFrameRenderOptions, SubtitleRenderedFrameData, SubtitleCueBounds, SubtitleCueMetadata, SubtitleData, SubtitleDiagnosticDetailValue, SubtitleDiagnosticErrorCode, SubtitleDiagnosticErrorLike, SubtitleDiagnosticsOptions, SubtitleDiagnosticWarning, SubtitleDiagnosticWarningCode, SubtitleCompositionData, SubtitleDisplaySettings, SubtitleFormatName, SubtitleHorizontalAlign, SubtitleLastRenderInfo, SubtitleParserMetadata, SubtitleRendererBackend, SubtitleRendererEvent, SubtitleRendererStatsSnapshot, VideoSubtitleOptions, VideoVobSubOptions, RenderResult, SubtitleFrame, VobSubFrame } from './ts/types';
|
|
6
|
+
export { SubtitleDiagnosticError, createSubtitleDiagnosticError, normalizeSubtitleError } from './ts/diagnostics';
|
|
6
7
|
export { initWasm, isWasmInitialized } from './ts/wasm';
|
|
7
8
|
export { isWebGPUSupported } from './ts/webgpu-renderer';
|
|
8
|
-
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser } from './ts/parsers';
|
|
9
|
+
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './ts/parsers';
|
|
10
|
+
export { renderFrameData, toBlob, toCanvas, toImageBitmap } from './ts/frame-export';
|
|
9
11
|
export { PgsRenderer, VobSubRenderer, createAutoSubtitleRenderer, type SubtitleRendererStats } from './ts/renderers';
|
|
10
12
|
export { detectSubtitleFormat } from './ts/utils';
|
|
11
13
|
import { PgsRenderer as _PgsRenderer, VobSubRenderer as _VobSubRenderer } from './ts/renderers';
|
package/dist/wrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../src/wrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../src/wrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAGjH,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAGxD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGpG,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGpF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,0BAA0B,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAGpH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAMjD,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EAAE,qBAAqB,IAAI,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAE9E,0CAA0C;AAC1C,eAAO,MAAM,WAAW,qBAAe,CAAA;AAEvC,6CAA6C;AAC7C,eAAO,MAAM,cAAc,wBAAkB,CAAA;AAE7C,oDAAoD;AACpD,eAAO,MAAM,uBAAuB,+BAAyB,CAAA"}
|
package/dist/wrapper.js
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
* TypeScript wrapper for the libbitsub Rust rendering engine.
|
|
3
3
|
* Provides a compatible API with the original libpgs-js implementation.
|
|
4
4
|
*/
|
|
5
|
+
export { SubtitleDiagnosticError, createSubtitleDiagnosticError, normalizeSubtitleError } from './ts/diagnostics';
|
|
5
6
|
// Re-export WASM management
|
|
6
7
|
export { initWasm, isWasmInitialized } from './ts/wasm';
|
|
7
8
|
// Re-export WebGPU utilities
|
|
8
9
|
export { isWebGPUSupported } from './ts/webgpu-renderer';
|
|
9
10
|
// Re-export parsers
|
|
10
|
-
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser } from './ts/parsers';
|
|
11
|
+
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './ts/parsers';
|
|
12
|
+
// Re-export frame export helpers
|
|
13
|
+
export { renderFrameData, toBlob, toCanvas, toImageBitmap } from './ts/frame-export';
|
|
11
14
|
// Re-export renderers
|
|
12
15
|
export { PgsRenderer, VobSubRenderer, createAutoSubtitleRenderer } from './ts/renderers';
|
|
13
16
|
// Re-export format detection utilities
|
package/dist/wrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../src/wrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../src/wrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuCH,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAEjH,4BAA4B;AAC5B,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEvD,6BAA6B;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,oBAAoB;AACpB,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEpG,iCAAiC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEpF,sBAAsB;AACtB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,0BAA0B,EAA8B,MAAM,gBAAgB,CAAA;AAEpH,uCAAuC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEjD,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAEhF,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EAAE,qBAAqB,IAAI,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAE9E,0CAA0C;AAC1C,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAA;AAEvC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAA;AAE7C,oDAAoD;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAA"}
|
package/package.json
CHANGED
package/pkg/README.md
CHANGED
|
@@ -13,8 +13,10 @@ Started as a fork of Arcus92's [libpgs-js](https://github.com/Arcus92/libpgs-js)
|
|
|
13
13
|
- Worker-backed parsing/rendering for large subtitle files
|
|
14
14
|
- Rich layout controls: scale, aspect mode, horizontal/vertical offsets, alignment, bottom padding, safe area, opacity
|
|
15
15
|
- Cue metadata and parser introspection APIs
|
|
16
|
+
- Rendered-frame export helpers for ImageData, ImageBitmap, Blob, and custom canvas targets
|
|
16
17
|
- Frame prefetching and cache control for high-level renderers
|
|
17
18
|
- Automatic format detection and unified loading helpers
|
|
19
|
+
- First-class diagnostics with structured error codes, warning hooks, and render/cache snapshots
|
|
18
20
|
- TypeScript support with exported event and metadata types
|
|
19
21
|
|
|
20
22
|
## Showcase
|
|
@@ -104,6 +106,7 @@ import { PgsRenderer } from 'libbitsub'
|
|
|
104
106
|
const renderer = new PgsRenderer({
|
|
105
107
|
video: videoElement,
|
|
106
108
|
subUrl: '/subtitles/movie.sup',
|
|
109
|
+
debug: true,
|
|
107
110
|
displaySettings: {
|
|
108
111
|
scale: 1.1,
|
|
109
112
|
aspectMode: 'stretch',
|
|
@@ -112,6 +115,9 @@ const renderer = new PgsRenderer({
|
|
|
112
115
|
},
|
|
113
116
|
cacheLimit: 32,
|
|
114
117
|
prefetchWindow: { before: 1, after: 2 },
|
|
118
|
+
onWarning: (warning) => {
|
|
119
|
+
console.warn(warning.code, warning.message, warning.details)
|
|
120
|
+
},
|
|
115
121
|
onEvent: (event) => {
|
|
116
122
|
if (event.type === 'worker-state') {
|
|
117
123
|
console.log('worker', event.ready ? 'ready' : 'starting', event.sessionId)
|
|
@@ -204,12 +210,15 @@ High-level renderers expose parser and cue metadata:
|
|
|
204
210
|
const metadata = renderer.getMetadata()
|
|
205
211
|
const currentCue = renderer.getCurrentCueMetadata()
|
|
206
212
|
const cue42 = renderer.getCueMetadata(42)
|
|
213
|
+
const stats = renderer.getStats()
|
|
214
|
+
const cache = renderer.getCacheStats()
|
|
215
|
+
const lastRender = renderer.getLastRenderInfo()
|
|
207
216
|
```
|
|
208
217
|
|
|
209
218
|
Low-level parsers expose the same model:
|
|
210
219
|
|
|
211
220
|
```ts
|
|
212
|
-
import { PgsParser, UnifiedSubtitleParser, VobSubParserLowLevel } from 'libbitsub'
|
|
221
|
+
import { PgsParser, UnifiedSubtitleParser, VobSubParserLowLevel, openSubtitles } from 'libbitsub'
|
|
213
222
|
|
|
214
223
|
const vob = new VobSubParserLowLevel()
|
|
215
224
|
vob.loadFromMks(new Uint8Array(mksBuffer))
|
|
@@ -217,9 +226,13 @@ vob.loadFromMks(new Uint8Array(mksBuffer))
|
|
|
217
226
|
const parser = new UnifiedSubtitleParser()
|
|
218
227
|
const detected = parser.loadAuto({ data: subtitleBytes, fileName: 'track.mks' })
|
|
219
228
|
|
|
229
|
+
const opened = await openSubtitles({ data: subtitleBytes, fileName: 'track.mks' })
|
|
230
|
+
|
|
220
231
|
console.log(detected)
|
|
221
232
|
console.log(parser.getMetadata())
|
|
222
233
|
console.log(parser.getCueMetadata(0))
|
|
234
|
+
console.log(opened.format)
|
|
235
|
+
opened.dispose()
|
|
223
236
|
```
|
|
224
237
|
|
|
225
238
|
Metadata includes:
|
|
@@ -230,6 +243,134 @@ Metadata includes:
|
|
|
230
243
|
- PGS composition count, palette ID, composition state
|
|
231
244
|
- VobSub language, track ID, IDX metadata presence, file position where available
|
|
232
245
|
|
|
246
|
+
## One-shot auto API
|
|
247
|
+
|
|
248
|
+
If you do not care whether the input is PGS or VobSub and only want one stable low-level surface, use `openSubtitles()`.
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
import { openSubtitles } from 'libbitsub'
|
|
252
|
+
|
|
253
|
+
const subtitles = await openSubtitles({
|
|
254
|
+
data: subtitleBytes,
|
|
255
|
+
fileName: 'track.sup'
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
console.log(subtitles.format)
|
|
259
|
+
console.log(subtitles.metadata)
|
|
260
|
+
console.log(subtitles.timestamps)
|
|
261
|
+
|
|
262
|
+
const frame = subtitles.renderAtTimestamp(120.5)
|
|
263
|
+
const rendered = subtitles.renderFrameDataAtTimestamp(120.5)
|
|
264
|
+
const cue = subtitles.getCueMetadata(0)
|
|
265
|
+
|
|
266
|
+
subtitles.dispose()
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`openSubtitles()` initializes WASM for you, auto-detects the format, loads the subtitle source, and returns a normalized handle with snapshot properties plus shared low-level helpers such as `renderAtIndex()`, `renderAtTimestamp()`, `renderFrameDataAtIndex()`, `renderFrameDataAtTimestamp()`, `getCueMetadata()`, `getLastRenderIssue()`, `clearCache()`, and `dispose()`.
|
|
270
|
+
|
|
271
|
+
Like `UnifiedSubtitleParser.loadAuto()`, this is a low-level in-memory API: pass binary subtitle content via `data` or `subData`, and optionally include `fileName`, `idxContent`, `idxUrl`, or `subUrl` as format hints or companion metadata.
|
|
272
|
+
|
|
273
|
+
## Frame export helpers
|
|
274
|
+
|
|
275
|
+
Low-level parser output can be flattened into a single exportable frame for previews, editors, snapshots, fixture generation, or visual diffing.
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import {
|
|
279
|
+
PgsParser,
|
|
280
|
+
initWasm,
|
|
281
|
+
renderFrameData,
|
|
282
|
+
toBlob,
|
|
283
|
+
toCanvas,
|
|
284
|
+
toImageBitmap
|
|
285
|
+
} from 'libbitsub'
|
|
286
|
+
|
|
287
|
+
await initWasm()
|
|
288
|
+
|
|
289
|
+
const parser = new PgsParser()
|
|
290
|
+
parser.load(new Uint8Array(arrayBuffer))
|
|
291
|
+
|
|
292
|
+
const subtitleFrame = parser.renderAtTimestamp(120.5)
|
|
293
|
+
const rendered = subtitleFrame ? renderFrameData(subtitleFrame, { crop: 'bounds' }) : null
|
|
294
|
+
|
|
295
|
+
if (rendered) {
|
|
296
|
+
const canvas = toCanvas(rendered)
|
|
297
|
+
const bitmap = await toImageBitmap(rendered)
|
|
298
|
+
const pngBlob = await toBlob(rendered)
|
|
299
|
+
|
|
300
|
+
console.log({
|
|
301
|
+
width: rendered.imageData.width,
|
|
302
|
+
height: rendered.imageData.height,
|
|
303
|
+
offsetX: rendered.offsetX,
|
|
304
|
+
offsetY: rendered.offsetY,
|
|
305
|
+
bounds: rendered.bounds,
|
|
306
|
+
canvas,
|
|
307
|
+
bitmap,
|
|
308
|
+
pngBlob
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Parser convenience methods avoid the extra `renderAtTimestamp()` step:
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
const rendered = parser.renderFrameDataAtTimestamp(120.5)
|
|
317
|
+
const fullScreenFrame = parser.renderFrameDataAtIndex(42, { crop: 'screen' })
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Cropping modes:
|
|
321
|
+
|
|
322
|
+
- `bounds` is the default. It returns a tightly cropped composed image and records where that image belongs in the original subtitle presentation area via `offsetX` and `offsetY`.
|
|
323
|
+
- `screen` preserves the full subtitle presentation dimensions, which is useful when you need stable frame sizes for test fixtures or when drawing into a presentation-sized surface.
|
|
324
|
+
|
|
325
|
+
Drawing behavior:
|
|
326
|
+
|
|
327
|
+
- `toCanvas(frame)` creates a new canvas sized to the rendered export.
|
|
328
|
+
- Passing an existing canvas target resizes it by default before drawing.
|
|
329
|
+
- Passing an existing 2D context draws in place by default, which is useful when you want subtitles composited into your own pre-sized surface.
|
|
330
|
+
|
|
331
|
+
## Diagnostics mode
|
|
332
|
+
|
|
333
|
+
Enable `debug: true` on high-level renderers when you need richer field diagnostics for malformed subtitle files. In debug mode, libbitsub records the most recent render attempt and emits structured warnings in addition to the existing lifecycle events.
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
import { PgsRenderer, SubtitleDiagnosticError } from 'libbitsub'
|
|
337
|
+
|
|
338
|
+
const renderer = new PgsRenderer({
|
|
339
|
+
video: videoElement,
|
|
340
|
+
subUrl: '/subtitles/movie.sup',
|
|
341
|
+
debug: true,
|
|
342
|
+
onWarning: (warning) => {
|
|
343
|
+
console.warn('[warning]', warning.code, warning.message, warning.details)
|
|
344
|
+
},
|
|
345
|
+
onError: (error) => {
|
|
346
|
+
if (error instanceof SubtitleDiagnosticError) {
|
|
347
|
+
console.error('[error]', error.code, error.message, error.details)
|
|
348
|
+
return
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
console.error(error)
|
|
352
|
+
}
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
console.log(renderer.getStats())
|
|
356
|
+
console.log(renderer.getCacheStats())
|
|
357
|
+
console.log(renderer.getLastRenderInfo())
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Structured diagnostic error codes currently include:
|
|
361
|
+
|
|
362
|
+
- `UNSUPPORTED_FORMAT`
|
|
363
|
+
- `BAD_IDX`
|
|
364
|
+
- `MISSING_PALETTE`
|
|
365
|
+
- `TRACK_NOT_FOUND`
|
|
366
|
+
- `MISSING_INPUT`
|
|
367
|
+
- `FETCH_FAILED`
|
|
368
|
+
- `INVALID_SUBTITLE_DATA`
|
|
369
|
+
- `WORKER_FALLBACK`
|
|
370
|
+
- `UNKNOWN`
|
|
371
|
+
|
|
372
|
+
Warnings use a smaller code set focused on non-fatal conditions such as malformed bitmap buffers, worker fallback, and missing PGS palettes during render.
|
|
373
|
+
|
|
233
374
|
## MKS security and corruption checks
|
|
234
375
|
|
|
235
376
|
The `.mks` path validates Matroska structure before handing payloads to the VobSub decoder. Embedded subtitle blocks are size-checked, compressed blocks use bounded zlib inflation, and extracted SPU packets are rejected if their declared payload lengths or control offsets are inconsistent. Malformed or oversized `.mks` payloads fail fast instead of being partially decoded.
|
|
@@ -260,6 +401,7 @@ const renderer = new PgsRenderer({
|
|
|
260
401
|
case 'loading':
|
|
261
402
|
case 'loaded':
|
|
262
403
|
case 'error':
|
|
404
|
+
case 'warning':
|
|
263
405
|
case 'renderer-change':
|
|
264
406
|
case 'worker-state':
|
|
265
407
|
case 'cache-change':
|
|
@@ -328,7 +470,8 @@ Emitted events:
|
|
|
328
470
|
| --- | --- |
|
|
329
471
|
| `loading` | subtitle format |
|
|
330
472
|
| `loaded` | subtitle format and parser metadata |
|
|
331
|
-
| `error` | subtitle format and `
|
|
473
|
+
| `error` | subtitle format and `SubtitleDiagnosticErrorLike` |
|
|
474
|
+
| `warning` | `SubtitleDiagnosticWarning` |
|
|
332
475
|
| `renderer-change` | active backend: `webgpu`, `webgl2`, or `canvas2d` |
|
|
333
476
|
| `worker-state` | whether worker mode is enabled, ready, fallback status, and the active session ID |
|
|
334
477
|
| `cache-change` | cached frame count, pending renders, and configured cache limit |
|
|
@@ -356,6 +499,8 @@ const stats = renderer.getStats()
|
|
|
356
499
|
- `totalEntries`
|
|
357
500
|
- `currentIndex`
|
|
358
501
|
|
|
502
|
+
`getCacheStats()` adds worker/session state for the current renderer cache, while `getLastRenderInfo()` exposes the most recent render outcome with a status of `rendered`, `cleared`, `pending`, `empty`, or `failed`.
|
|
503
|
+
|
|
359
504
|
## Low-level APIs
|
|
360
505
|
|
|
361
506
|
### PGS parser
|
|
@@ -368,7 +513,9 @@ parser.load(new Uint8Array(arrayBuffer))
|
|
|
368
513
|
|
|
369
514
|
const timestamps = parser.getTimestamps()
|
|
370
515
|
const frame = parser.renderAtIndex(0)
|
|
516
|
+
const rendered = parser.renderFrameDataAtTimestamp(120.5)
|
|
371
517
|
const metadata = parser.getMetadata()
|
|
518
|
+
const lastIssue = parser.getLastRenderIssue()
|
|
372
519
|
```
|
|
373
520
|
|
|
374
521
|
### VobSub parser
|
|
@@ -381,7 +528,9 @@ parser.loadFromData(idxContent, new Uint8Array(subArrayBuffer))
|
|
|
381
528
|
parser.setDebandEnabled(true)
|
|
382
529
|
|
|
383
530
|
const frame = parser.renderAtTimestamp(120.5)
|
|
531
|
+
const rendered = parser.renderFrameDataAtIndex(0, { crop: 'screen' })
|
|
384
532
|
const cue = parser.getCueMetadata(0)
|
|
533
|
+
const lastIssue = parser.getLastRenderIssue()
|
|
385
534
|
```
|
|
386
535
|
|
|
387
536
|
### Unified parser
|
|
@@ -391,7 +540,10 @@ import { UnifiedSubtitleParser, detectSubtitleFormat } from 'libbitsub'
|
|
|
391
540
|
|
|
392
541
|
const format = detectSubtitleFormat({ data: subtitleBytes, fileName: 'track.sup' })
|
|
393
542
|
|
|
394
|
-
const parser = new UnifiedSubtitleParser(
|
|
543
|
+
const parser = new UnifiedSubtitleParser({
|
|
544
|
+
debug: true,
|
|
545
|
+
onWarning: (warning) => console.warn(warning.code, warning.message)
|
|
546
|
+
})
|
|
395
547
|
parser.loadAuto({ data: subtitleBytes, fileName: 'track.sup' })
|
|
396
548
|
```
|
|
397
549
|
|
|
@@ -404,19 +556,20 @@ libbitsub prefers:
|
|
|
404
556
|
3. Canvas2D
|
|
405
557
|
|
|
406
558
|
```ts
|
|
407
|
-
import {
|
|
559
|
+
import { isWebGPUSupported } from 'libbitsub'
|
|
408
560
|
|
|
409
561
|
console.log({
|
|
410
|
-
webgpu: isWebGPUSupported()
|
|
411
|
-
webgl2: isWebGL2Supported()
|
|
562
|
+
webgpu: isWebGPUSupported()
|
|
412
563
|
})
|
|
413
564
|
```
|
|
414
565
|
|
|
566
|
+
WebGL2 and Canvas2D fallback remain automatic. Use `onWebGPUFallback`, `onWebGL2Fallback`, `onEvent`, or `onWarning` if you need to observe backend changes.
|
|
567
|
+
|
|
415
568
|
## Notes
|
|
416
569
|
|
|
417
570
|
- Worker mode is shared, but subtitle parser state is isolated per renderer session.
|
|
418
571
|
- Multiple subtitle renderers can coexist without reusing the same parser instance.
|
|
419
|
-
- If worker startup fails, the high-level API falls back to main-thread parsing.
|
|
572
|
+
- If worker startup fails, the high-level API falls back to main-thread parsing and emits a `WORKER_FALLBACK` warning/event when diagnostics are being observed.
|
|
420
573
|
- The library only handles bitmap subtitle formats. It does not parse text subtitle formats such as SRT or ASS.
|
|
421
574
|
|
|
422
575
|
## API Reference
|
|
@@ -428,6 +581,13 @@ console.log({
|
|
|
428
581
|
- `isWebGPUSupported(): boolean` checks WebGPU support.
|
|
429
582
|
- `detectSubtitleFormat(source: AutoSubtitleSource): 'pgs' | 'vobsub' | null` detects the bitmap subtitle format from file hints or binary data.
|
|
430
583
|
- `createAutoSubtitleRenderer(options: AutoVideoSubtitleOptions): PgsRenderer | VobSubRenderer` creates a high-level renderer after format detection.
|
|
584
|
+
- `openSubtitles(source, options?): Promise<OpenedSubtitles>` initializes WASM, auto-detects the low-level format, and returns a normalized parser handle.
|
|
585
|
+
- `renderFrameData(frame, options?): SubtitleRenderedFrameData | null` composes a `SubtitleData` frame into exportable pixels.
|
|
586
|
+
- `toCanvas(frame, target?, options?): HTMLCanvasElement | OffscreenCanvas` draws a rendered frame to a new or existing canvas/context.
|
|
587
|
+
- `toImageBitmap(frame, options?): Promise<ImageBitmap>` creates an `ImageBitmap` from a subtitle frame export.
|
|
588
|
+
- `toBlob(frame, type?, quality?, options?): Promise<Blob>` encodes a subtitle frame export, defaulting to PNG.
|
|
589
|
+
- `SubtitleDiagnosticError` is the structured error class libbitsub uses for coded diagnostics.
|
|
590
|
+
- `createSubtitleDiagnosticError(...)` and `normalizeSubtitleError(...)` are exported for integrations that want to preserve libbitsub-style error codes.
|
|
431
591
|
- Legacy aliases remain exported: `PGSRenderer`, `VobsubRenderer`, `UnifiedSubtitleRenderer`.
|
|
432
592
|
|
|
433
593
|
### High-level renderers
|
|
@@ -439,6 +599,8 @@ console.log({
|
|
|
439
599
|
- `setDisplaySettings(settings: Partial<SubtitleDisplaySettings>): void` updates layout settings.
|
|
440
600
|
- `resetDisplaySettings(): void` resets layout settings to defaults.
|
|
441
601
|
- `getStats(): SubtitleRendererStats` returns render statistics.
|
|
602
|
+
- `getCacheStats(): SubtitleCacheStats` returns cache occupancy, worker readiness, and session ID details.
|
|
603
|
+
- `getLastRenderInfo(): SubtitleLastRenderInfo | null` returns the last render attempt recorded in debug mode.
|
|
442
604
|
- `getMetadata(): SubtitleParserMetadata | null` returns track-level metadata.
|
|
443
605
|
- `getCurrentCueMetadata(): SubtitleCueMetadata | null` returns the currently displayed cue metadata.
|
|
444
606
|
- `getCueMetadata(index: number): SubtitleCueMetadata | null` returns metadata for a specific cue.
|
|
@@ -553,7 +715,8 @@ interface SubtitleDisplaySettings {
|
|
|
553
715
|
type SubtitleRendererEvent =
|
|
554
716
|
| { type: 'loading'; format: SubtitleFormatName }
|
|
555
717
|
| { type: 'loaded'; format: SubtitleFormatName; metadata: SubtitleParserMetadata }
|
|
556
|
-
| { type: 'error'; format: SubtitleFormatName; error:
|
|
718
|
+
| { type: 'error'; format: SubtitleFormatName; error: SubtitleDiagnosticErrorLike }
|
|
719
|
+
| { type: 'warning'; warning: SubtitleDiagnosticWarning }
|
|
557
720
|
| { type: 'renderer-change'; renderer: 'webgpu' | 'webgl2' | 'canvas2d' }
|
|
558
721
|
| { type: 'worker-state'; enabled: boolean; ready: boolean; sessionId: string | null; fallback?: boolean }
|
|
559
722
|
| { type: 'cache-change'; cachedFrames: number; pendingRenders: number; cacheLimit: number }
|
|
@@ -578,6 +741,11 @@ Both shapes expose:
|
|
|
578
741
|
- `totalEntries`
|
|
579
742
|
- `currentIndex`
|
|
580
743
|
|
|
744
|
+
Related diagnostics shapes:
|
|
745
|
+
|
|
746
|
+
- `SubtitleCacheStats` from `getCacheStats()`.
|
|
747
|
+
- `SubtitleLastRenderInfo` from `getLastRenderInfo()` when `debug` is enabled.
|
|
748
|
+
|
|
581
749
|
#### `SubtitleParserMetadata`
|
|
582
750
|
|
|
583
751
|
```ts
|
package/pkg/libbitsub.d.ts
CHANGED
|
@@ -57,6 +57,10 @@ export class PgsParser {
|
|
|
57
57
|
* Get the number of display sets.
|
|
58
58
|
*/
|
|
59
59
|
readonly count: number;
|
|
60
|
+
/**
|
|
61
|
+
* Get the last non-fatal render issue for diagnostics.
|
|
62
|
+
*/
|
|
63
|
+
readonly lastRenderIssue: string;
|
|
60
64
|
/**
|
|
61
65
|
* Get the presentation height for this subtitle track.
|
|
62
66
|
*/
|
|
@@ -231,6 +235,10 @@ export class SubtitleRenderer {
|
|
|
231
235
|
* Get the VobSub language code if available.
|
|
232
236
|
*/
|
|
233
237
|
readonly language: string;
|
|
238
|
+
/**
|
|
239
|
+
* Get the last non-fatal render issue for diagnostics.
|
|
240
|
+
*/
|
|
241
|
+
readonly lastRenderIssue: string;
|
|
234
242
|
/**
|
|
235
243
|
* Get the presentation height for the loaded subtitle track.
|
|
236
244
|
*/
|
|
@@ -351,6 +359,10 @@ export class VobSubParser {
|
|
|
351
359
|
* Get the declared language code from IDX metadata.
|
|
352
360
|
*/
|
|
353
361
|
readonly language: string;
|
|
362
|
+
/**
|
|
363
|
+
* Get the last non-fatal render issue for diagnostics.
|
|
364
|
+
*/
|
|
365
|
+
readonly lastRenderIssue: string;
|
|
354
366
|
/**
|
|
355
367
|
* Get the presentation height for this subtitle track.
|
|
356
368
|
*/
|
|
@@ -390,6 +402,7 @@ export interface InitOutput {
|
|
|
390
402
|
readonly pgsparser_getCuePaletteId: (a: number, b: number) => number;
|
|
391
403
|
readonly pgsparser_getCueStartTime: (a: number, b: number) => number;
|
|
392
404
|
readonly pgsparser_getTimestamps: (a: number) => any;
|
|
405
|
+
readonly pgsparser_lastRenderIssue: (a: number) => [number, number];
|
|
393
406
|
readonly pgsparser_new: () => number;
|
|
394
407
|
readonly pgsparser_parse: (a: number, b: number, c: number) => number;
|
|
395
408
|
readonly pgsparser_renderAtIndex: (a: number, b: number) => number;
|
|
@@ -420,6 +433,7 @@ export interface InitOutput {
|
|
|
420
433
|
readonly subtitlerenderer_getTimestamps: (a: number) => any;
|
|
421
434
|
readonly subtitlerenderer_hasIdxMetadata: (a: number) => number;
|
|
422
435
|
readonly subtitlerenderer_language: (a: number) => [number, number];
|
|
436
|
+
readonly subtitlerenderer_lastRenderIssue: (a: number) => [number, number];
|
|
423
437
|
readonly subtitlerenderer_loadPgs: (a: number, b: number, c: number) => number;
|
|
424
438
|
readonly subtitlerenderer_loadVobSub: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
425
439
|
readonly subtitlerenderer_loadVobSubMks: (a: number, b: number, c: number) => [number, number];
|
|
@@ -449,6 +463,7 @@ export interface InitOutput {
|
|
|
449
463
|
readonly vobsubparser_getTimestamps: (a: number) => any;
|
|
450
464
|
readonly vobsubparser_hasIdxMetadata: (a: number) => number;
|
|
451
465
|
readonly vobsubparser_language: (a: number) => [number, number];
|
|
466
|
+
readonly vobsubparser_lastRenderIssue: (a: number) => [number, number];
|
|
452
467
|
readonly vobsubparser_loadFromData: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
453
468
|
readonly vobsubparser_loadFromMks: (a: number, b: number, c: number) => [number, number];
|
|
454
469
|
readonly vobsubparser_loadFromSubOnly: (a: number, b: number, c: number) => void;
|
package/pkg/libbitsub.js
CHANGED
|
@@ -90,6 +90,22 @@ export class PgsParser {
|
|
|
90
90
|
const ret = wasm.pgsparser_getTimestamps(this.__wbg_ptr);
|
|
91
91
|
return ret;
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the last non-fatal render issue for diagnostics.
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
get lastRenderIssue() {
|
|
98
|
+
let deferred1_0;
|
|
99
|
+
let deferred1_1;
|
|
100
|
+
try {
|
|
101
|
+
const ret = wasm.pgsparser_lastRenderIssue(this.__wbg_ptr);
|
|
102
|
+
deferred1_0 = ret[0];
|
|
103
|
+
deferred1_1 = ret[1];
|
|
104
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
105
|
+
} finally {
|
|
106
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
93
109
|
/**
|
|
94
110
|
* Create a new PGS parser.
|
|
95
111
|
*/
|
|
@@ -471,6 +487,22 @@ export class SubtitleRenderer {
|
|
|
471
487
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
472
488
|
}
|
|
473
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Get the last non-fatal render issue for diagnostics.
|
|
492
|
+
* @returns {string}
|
|
493
|
+
*/
|
|
494
|
+
get lastRenderIssue() {
|
|
495
|
+
let deferred1_0;
|
|
496
|
+
let deferred1_1;
|
|
497
|
+
try {
|
|
498
|
+
const ret = wasm.subtitlerenderer_lastRenderIssue(this.__wbg_ptr);
|
|
499
|
+
deferred1_0 = ret[0];
|
|
500
|
+
deferred1_1 = ret[1];
|
|
501
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
502
|
+
} finally {
|
|
503
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
474
506
|
/**
|
|
475
507
|
* Load PGS subtitle data.
|
|
476
508
|
* @param {Uint8Array} data
|
|
@@ -772,6 +804,22 @@ export class VobSubParser {
|
|
|
772
804
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
773
805
|
}
|
|
774
806
|
}
|
|
807
|
+
/**
|
|
808
|
+
* Get the last non-fatal render issue for diagnostics.
|
|
809
|
+
* @returns {string}
|
|
810
|
+
*/
|
|
811
|
+
get lastRenderIssue() {
|
|
812
|
+
let deferred1_0;
|
|
813
|
+
let deferred1_1;
|
|
814
|
+
try {
|
|
815
|
+
const ret = wasm.vobsubparser_lastRenderIssue(this.__wbg_ptr);
|
|
816
|
+
deferred1_0 = ret[0];
|
|
817
|
+
deferred1_1 = ret[1];
|
|
818
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
819
|
+
} finally {
|
|
820
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
775
823
|
/**
|
|
776
824
|
* Load VobSub from IDX content and SUB data.
|
|
777
825
|
* @param {string} idx_content
|
package/pkg/libbitsub_bg.wasm
CHANGED
|
Binary file
|
|
@@ -17,6 +17,7 @@ export const pgsparser_getCueEndTime: (a: number, b: number) => number;
|
|
|
17
17
|
export const pgsparser_getCuePaletteId: (a: number, b: number) => number;
|
|
18
18
|
export const pgsparser_getCueStartTime: (a: number, b: number) => number;
|
|
19
19
|
export const pgsparser_getTimestamps: (a: number) => any;
|
|
20
|
+
export const pgsparser_lastRenderIssue: (a: number) => [number, number];
|
|
20
21
|
export const pgsparser_new: () => number;
|
|
21
22
|
export const pgsparser_parse: (a: number, b: number, c: number) => number;
|
|
22
23
|
export const pgsparser_renderAtIndex: (a: number, b: number) => number;
|
|
@@ -47,6 +48,7 @@ export const subtitlerenderer_getCueStartTime: (a: number, b: number) => number;
|
|
|
47
48
|
export const subtitlerenderer_getTimestamps: (a: number) => any;
|
|
48
49
|
export const subtitlerenderer_hasIdxMetadata: (a: number) => number;
|
|
49
50
|
export const subtitlerenderer_language: (a: number) => [number, number];
|
|
51
|
+
export const subtitlerenderer_lastRenderIssue: (a: number) => [number, number];
|
|
50
52
|
export const subtitlerenderer_loadPgs: (a: number, b: number, c: number) => number;
|
|
51
53
|
export const subtitlerenderer_loadVobSub: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
52
54
|
export const subtitlerenderer_loadVobSubMks: (a: number, b: number, c: number) => [number, number];
|
|
@@ -76,6 +78,7 @@ export const vobsubparser_getCueStartTime: (a: number, b: number) => number;
|
|
|
76
78
|
export const vobsubparser_getTimestamps: (a: number) => any;
|
|
77
79
|
export const vobsubparser_hasIdxMetadata: (a: number) => number;
|
|
78
80
|
export const vobsubparser_language: (a: number) => [number, number];
|
|
81
|
+
export const vobsubparser_lastRenderIssue: (a: number) => [number, number];
|
|
79
82
|
export const vobsubparser_loadFromData: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
80
83
|
export const vobsubparser_loadFromMks: (a: number, b: number, c: number) => [number, number];
|
|
81
84
|
export const vobsubparser_loadFromSubOnly: (a: number, b: number, c: number) => void;
|
package/pkg/package.json
CHANGED
package/src/wrapper.ts
CHANGED
|
@@ -7,14 +7,28 @@
|
|
|
7
7
|
export type {
|
|
8
8
|
AutoSubtitleSource,
|
|
9
9
|
AutoVideoSubtitleOptions,
|
|
10
|
+
OpenedSubtitles,
|
|
10
11
|
SubtitleAspectMode,
|
|
12
|
+
SubtitleCacheStats,
|
|
13
|
+
SubtitleFrameCanvasOptions,
|
|
14
|
+
SubtitleFrameCanvasTarget,
|
|
15
|
+
SubtitleFrameCropMode,
|
|
16
|
+
SubtitleFrameRenderOptions,
|
|
17
|
+
SubtitleRenderedFrameData,
|
|
11
18
|
SubtitleCueBounds,
|
|
12
19
|
SubtitleCueMetadata,
|
|
13
20
|
SubtitleData,
|
|
21
|
+
SubtitleDiagnosticDetailValue,
|
|
22
|
+
SubtitleDiagnosticErrorCode,
|
|
23
|
+
SubtitleDiagnosticErrorLike,
|
|
24
|
+
SubtitleDiagnosticsOptions,
|
|
25
|
+
SubtitleDiagnosticWarning,
|
|
26
|
+
SubtitleDiagnosticWarningCode,
|
|
14
27
|
SubtitleCompositionData,
|
|
15
28
|
SubtitleDisplaySettings,
|
|
16
29
|
SubtitleFormatName,
|
|
17
30
|
SubtitleHorizontalAlign,
|
|
31
|
+
SubtitleLastRenderInfo,
|
|
18
32
|
SubtitleParserMetadata,
|
|
19
33
|
SubtitleRendererBackend,
|
|
20
34
|
SubtitleRendererEvent,
|
|
@@ -26,6 +40,8 @@ export type {
|
|
|
26
40
|
VobSubFrame
|
|
27
41
|
} from './ts/types'
|
|
28
42
|
|
|
43
|
+
export { SubtitleDiagnosticError, createSubtitleDiagnosticError, normalizeSubtitleError } from './ts/diagnostics'
|
|
44
|
+
|
|
29
45
|
// Re-export WASM management
|
|
30
46
|
export { initWasm, isWasmInitialized } from './ts/wasm'
|
|
31
47
|
|
|
@@ -33,7 +49,10 @@ export { initWasm, isWasmInitialized } from './ts/wasm'
|
|
|
33
49
|
export { isWebGPUSupported } from './ts/webgpu-renderer'
|
|
34
50
|
|
|
35
51
|
// Re-export parsers
|
|
36
|
-
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser } from './ts/parsers'
|
|
52
|
+
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './ts/parsers'
|
|
53
|
+
|
|
54
|
+
// Re-export frame export helpers
|
|
55
|
+
export { renderFrameData, toBlob, toCanvas, toImageBitmap } from './ts/frame-export'
|
|
37
56
|
|
|
38
57
|
// Re-export renderers
|
|
39
58
|
export { PgsRenderer, VobSubRenderer, createAutoSubtitleRenderer, type SubtitleRendererStats } from './ts/renderers'
|