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/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/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
export { PgsRenderer, VobSubRenderer, createAutoSubtitleRenderer, type VideoSubtitleOptions, type VideoVobSubOptions, type SubtitleRendererStats } from './wrapper';
|
|
7
|
-
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser } from './wrapper';
|
|
8
|
-
export { initWasm, isWasmInitialized, isWebGPUSupported, detectSubtitleFormat, type AutoSubtitleSource, type AutoVideoSubtitleOptions, type SubtitleAspectMode, type SubtitleCueBounds, type SubtitleCueMetadata, type SubtitleData, type SubtitleCompositionData, type SubtitleDisplaySettings, type SubtitleFormatName, type SubtitleHorizontalAlign, type SubtitleParserMetadata, type SubtitleRendererBackend, type SubtitleRendererEvent, type SubtitleRendererStatsSnapshot } from './wrapper';
|
|
7
|
+
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './wrapper';
|
|
8
|
+
export { initWasm, isWasmInitialized, isWebGPUSupported, detectSubtitleFormat, renderFrameData, toBlob, toCanvas, toImageBitmap, createSubtitleDiagnosticError, normalizeSubtitleError, SubtitleDiagnosticError, type AutoSubtitleSource, type AutoVideoSubtitleOptions, type OpenedSubtitles, type SubtitleAspectMode, type SubtitleCacheStats, type SubtitleCueBounds, type SubtitleCueMetadata, type SubtitleData, type SubtitleDiagnosticDetailValue, type SubtitleDiagnosticErrorCode, type SubtitleDiagnosticErrorLike, type SubtitleDiagnosticsOptions, type SubtitleDiagnosticWarning, type SubtitleDiagnosticWarningCode, type SubtitleCompositionData, type SubtitleDisplaySettings, type SubtitleFrameCanvasOptions, type SubtitleFrameCanvasTarget, type SubtitleFrameCropMode, type SubtitleFrameRenderOptions, type SubtitleRenderedFrameData, type SubtitleFormatName, type SubtitleHorizontalAlign, type SubtitleLastRenderInfo, type SubtitleParserMetadata, type SubtitleRendererBackend, type SubtitleRendererEvent, type SubtitleRendererStatsSnapshot } from './wrapper';
|
|
9
9
|
export type { RenderResult, SubtitleFrame, VobSubFrame } from './wrapper';
|
|
10
10
|
export { PGSRenderer, VobsubRenderer, UnifiedSubtitleRenderer } from './wrapper';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,WAAW,EACX,cAAc,EACd,0BAA0B,EAC1B,KAAK,oB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AGlB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAGzE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// High-level video-integrated renderers (compatible with old libpgs-js API)
|
|
7
7
|
export { PgsRenderer, VobSubRenderer, createAutoSubtitleRenderer } from './wrapper';
|
|
8
8
|
// Low-level parsers for programmatic use
|
|
9
|
-
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser } from './wrapper';
|
|
9
|
+
export { PgsParser, VobSubParserLowLevel, UnifiedSubtitleParser, openSubtitles } from './wrapper';
|
|
10
10
|
// Utility exports
|
|
11
|
-
export { initWasm, isWasmInitialized, isWebGPUSupported, detectSubtitleFormat } from './wrapper';
|
|
11
|
+
export { initWasm, isWasmInitialized, isWebGPUSupported, detectSubtitleFormat, renderFrameData, toBlob, toCanvas, toImageBitmap, createSubtitleDiagnosticError, normalizeSubtitleError, SubtitleDiagnosticError } from './wrapper';
|
|
12
12
|
// Legacy aliases
|
|
13
13
|
export { PGSRenderer, VobsubRenderer, UnifiedSubtitleRenderer } from './wrapper';
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,OAAO,EACL,WAAW,EACX,cAAc,EACd,0BAA0B,EAI3B,MAAM,WAAW,CAAA;AAElB,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,OAAO,EACL,WAAW,EACX,cAAc,EACd,0BAA0B,EAI3B,MAAM,WAAW,CAAA;AAElB,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEjG,kBAAkB;AAClB,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,aAAa,EACb,6BAA6B,EAC7B,sBAAsB,EACtB,uBAAuB,EA6BxB,MAAM,WAAW,CAAA;AAKlB,iBAAiB;AACjB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SubtitleDiagnosticDetailValue, SubtitleDiagnosticErrorCode, SubtitleDiagnosticErrorLike, SubtitleDiagnosticWarning, SubtitleDiagnosticWarningCode, SubtitleFormatName } from './types';
|
|
2
|
+
interface SubtitleDiagnosticContext {
|
|
3
|
+
format?: SubtitleFormatName;
|
|
4
|
+
details?: Record<string, SubtitleDiagnosticDetailValue>;
|
|
5
|
+
fallbackCode?: SubtitleDiagnosticErrorCode;
|
|
6
|
+
}
|
|
7
|
+
export declare class SubtitleDiagnosticError extends Error implements SubtitleDiagnosticErrorLike {
|
|
8
|
+
readonly code: SubtitleDiagnosticErrorCode;
|
|
9
|
+
readonly format?: SubtitleFormatName;
|
|
10
|
+
readonly details?: Record<string, SubtitleDiagnosticDetailValue>;
|
|
11
|
+
readonly cause?: unknown;
|
|
12
|
+
constructor(code: SubtitleDiagnosticErrorCode, message: string, options?: {
|
|
13
|
+
format?: SubtitleFormatName;
|
|
14
|
+
details?: Record<string, SubtitleDiagnosticDetailValue>;
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare function createSubtitleDiagnosticError(code: SubtitleDiagnosticErrorCode, message: string, options?: {
|
|
19
|
+
format?: SubtitleFormatName;
|
|
20
|
+
details?: Record<string, SubtitleDiagnosticDetailValue>;
|
|
21
|
+
cause?: unknown;
|
|
22
|
+
}): SubtitleDiagnosticError;
|
|
23
|
+
export declare function normalizeSubtitleError(error: unknown, context?: SubtitleDiagnosticContext): SubtitleDiagnosticError;
|
|
24
|
+
export declare function createSubtitleWarning(code: SubtitleDiagnosticWarningCode, message: string, options?: {
|
|
25
|
+
format?: SubtitleFormatName;
|
|
26
|
+
cueIndex?: number;
|
|
27
|
+
details?: Record<string, SubtitleDiagnosticDetailValue>;
|
|
28
|
+
}): SubtitleDiagnosticWarning;
|
|
29
|
+
export declare function warningFromRenderIssue(renderIssue: string | null | undefined, options?: {
|
|
30
|
+
format?: SubtitleFormatName;
|
|
31
|
+
cueIndex?: number;
|
|
32
|
+
}): SubtitleDiagnosticWarning | null;
|
|
33
|
+
export declare function formatSubtitleWarningForConsole(warning: SubtitleDiagnosticWarning): string;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/ts/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAEhB,UAAU,yBAAyB;IACjC,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;IACvD,YAAY,CAAC,EAAE,2BAA2B,CAAA;CAC3C;AAED,qBAAa,uBAAwB,SAAQ,KAAM,YAAW,2BAA2B;IACvF,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAA;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAA;IACpC,QAAQ,CAAC,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,0 +1,102 @@
|
|
|
1
|
+
export class SubtitleDiagnosticError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
format;
|
|
4
|
+
details;
|
|
5
|
+
cause;
|
|
6
|
+
constructor(code, message, options = {}) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'SubtitleDiagnosticError';
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.format = options.format;
|
|
11
|
+
this.details = options.details;
|
|
12
|
+
this.cause = options.cause;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function createSubtitleDiagnosticError(code, message, options = {}) {
|
|
16
|
+
return new SubtitleDiagnosticError(code, message, options);
|
|
17
|
+
}
|
|
18
|
+
export function normalizeSubtitleError(error, context = {}) {
|
|
19
|
+
if (error instanceof SubtitleDiagnosticError) {
|
|
20
|
+
return error;
|
|
21
|
+
}
|
|
22
|
+
const resolvedError = error instanceof Error ? error : new Error(String(error));
|
|
23
|
+
const code = inferSubtitleDiagnosticErrorCode(resolvedError.message, context.fallbackCode);
|
|
24
|
+
return new SubtitleDiagnosticError(code, resolvedError.message, {
|
|
25
|
+
format: context.format,
|
|
26
|
+
details: context.details,
|
|
27
|
+
cause: error
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function createSubtitleWarning(code, message, options = {}) {
|
|
31
|
+
return {
|
|
32
|
+
code,
|
|
33
|
+
message,
|
|
34
|
+
format: options.format,
|
|
35
|
+
cueIndex: options.cueIndex,
|
|
36
|
+
details: options.details
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function warningFromRenderIssue(renderIssue, options = {}) {
|
|
40
|
+
const normalizedIssue = renderIssue?.trim().toUpperCase();
|
|
41
|
+
if (!normalizedIssue)
|
|
42
|
+
return null;
|
|
43
|
+
switch (normalizedIssue) {
|
|
44
|
+
case 'MISSING_PALETTE':
|
|
45
|
+
return createSubtitleWarning('MISSING_PALETTE', 'PGS cue references a palette that was not available at render time.', {
|
|
46
|
+
format: options.format,
|
|
47
|
+
cueIndex: options.cueIndex
|
|
48
|
+
});
|
|
49
|
+
case 'INVALID_PACKET':
|
|
50
|
+
return createSubtitleWarning('INVALID_SUBTITLE_DATA', 'Subtitle packet could not be decoded for the requested cue.', {
|
|
51
|
+
format: options.format,
|
|
52
|
+
cueIndex: options.cueIndex
|
|
53
|
+
});
|
|
54
|
+
case 'RENDER_CONTEXT_UNAVAILABLE':
|
|
55
|
+
return createSubtitleWarning('INVALID_SUBTITLE_DATA', 'Subtitle render context could not be assembled for the requested cue.', {
|
|
56
|
+
format: options.format,
|
|
57
|
+
cueIndex: options.cueIndex
|
|
58
|
+
});
|
|
59
|
+
case 'EMPTY_RENDER':
|
|
60
|
+
return createSubtitleWarning('INVALID_SUBTITLE_DATA', 'Subtitle cue rendered without any visible bitmap data.', {
|
|
61
|
+
format: options.format,
|
|
62
|
+
cueIndex: options.cueIndex
|
|
63
|
+
});
|
|
64
|
+
default:
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function formatSubtitleWarningForConsole(warning) {
|
|
69
|
+
return `[libbitsub:${warning.code}] ${warning.message}`;
|
|
70
|
+
}
|
|
71
|
+
function inferSubtitleDiagnosticErrorCode(message, fallbackCode = 'UNKNOWN') {
|
|
72
|
+
const normalizedMessage = message.toLowerCase();
|
|
73
|
+
if (normalizedMessage.includes('detect subtitle format') || normalizedMessage.includes('unsupported format')) {
|
|
74
|
+
return 'UNSUPPORTED_FORMAT';
|
|
75
|
+
}
|
|
76
|
+
if (normalizedMessage.includes('no s_vobsub track') || normalizedMessage.includes('track not found')) {
|
|
77
|
+
return 'TRACK_NOT_FOUND';
|
|
78
|
+
}
|
|
79
|
+
if (normalizedMessage.includes('idx') ||
|
|
80
|
+
normalizedMessage.includes('codecprivate') ||
|
|
81
|
+
normalizedMessage.includes('filepos')) {
|
|
82
|
+
return 'BAD_IDX';
|
|
83
|
+
}
|
|
84
|
+
if (normalizedMessage.includes('palette')) {
|
|
85
|
+
return 'MISSING_PALETTE';
|
|
86
|
+
}
|
|
87
|
+
if (normalizedMessage.includes('failed to fetch')) {
|
|
88
|
+
return 'FETCH_FAILED';
|
|
89
|
+
}
|
|
90
|
+
if (normalizedMessage.includes('no ') && normalizedMessage.includes('provided')) {
|
|
91
|
+
return 'MISSING_INPUT';
|
|
92
|
+
}
|
|
93
|
+
if (normalizedMessage.includes('invalid') ||
|
|
94
|
+
normalizedMessage.includes('truncated') ||
|
|
95
|
+
normalizedMessage.includes('malformed') ||
|
|
96
|
+
normalizedMessage.includes('subtitle block') ||
|
|
97
|
+
normalizedMessage.includes('payload')) {
|
|
98
|
+
return 'INVALID_SUBTITLE_DATA';
|
|
99
|
+
}
|
|
100
|
+
return fallbackCode;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/ts/diagnostics.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,CAA6B;IACjC,MAAM,CAAqB;IAC3B,OAAO,CAAgD;IAC9C,KAAK,CAAU;IAEjC,YACE,IAAiC,EACjC,OAAe,EACf,OAAO,GAIH,EAAE;QAEN,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;IAC5B,CAAC;CACF;AAED,MAAM,UAAU,6BAA6B,CAC3C,IAAiC,EACjC,OAAe,EACf,OAAO,GAIH,EAAE;IAEN,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAA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AAC,EACrC,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAClD,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAChF,OAAO,eAAe,CAAA;IACxB,CAAC;IAED,IACE,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC;QACrC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC;QACvC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC;QACvC,iBAAiB,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC5C,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,EACrC,CAAC;QACD,OAAO,uBAAuB,CAAA;IAChC,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SubtitleData, SubtitleFrameCanvasOptions, SubtitleFrameCanvasTarget, SubtitleFrameRenderOptions, SubtitleRenderedFrameData } from './types';
|
|
2
|
+
export declare function renderFrameData(frame: SubtitleData, options?: SubtitleFrameRenderOptions): SubtitleRenderedFrameData | null;
|
|
3
|
+
export declare function toCanvas(frame: SubtitleData | SubtitleRenderedFrameData, target?: SubtitleFrameCanvasTarget, options?: SubtitleFrameCanvasOptions): HTMLCanvasElement | OffscreenCanvas;
|
|
4
|
+
export declare function toImageBitmap(frame: SubtitleData | SubtitleRenderedFrameData, options?: SubtitleFrameRenderOptions): Promise<ImageBitmap>;
|
|
5
|
+
export declare function toBlob(frame: SubtitleData | SubtitleRenderedFrameData, type?: string, quality?: number, options?: SubtitleFrameRenderOptions): Promise<Blob>;
|
|
6
|
+
//# sourceMappingURL=frame-export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-export.d.ts","sourceRoot":"","sources":["../../src/ts/frame-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,0BAA0B,EAC1B,yBAAyB,EAEzB,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AA4IhB,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,GAAE,0BAA+B,GAAG,yBAAyB,GAAG,IAAI,CAoD/H;AAED,wBAAgB,QAAQ,CACtB,KAAK,EAAE,YAAY,GAAG,yBAAyB,EAC/C,MAAM,CAAC,EAAE,yBAAyB,EAClC,OAAO,GAAE,0BAA+B,GACvC,iBAAiB,GAAG,eAAe,CAyCrC;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,YAAY,GAAG,yBAAyB,EAC/C,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,WAAW,CAAC,CAqBtB;AAED,wBAAsB,MAAM,CAC1B,KAAK,EAAE,YAAY,GAAG,yBAAyB,EAC/C,IAAI,GAAE,MAAoB,EAC1B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|