@tscaps/engine 0.2.1 → 0.3.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.
Files changed (495) hide show
  1. package/README.md +47 -7
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/modules/bidi/BidiAnalyzer.d.ts +23 -0
  7. package/dist/modules/bidi/BidiAnalyzer.d.ts.map +1 -0
  8. package/dist/modules/bidi/BidiAnalyzer.js +2 -0
  9. package/dist/modules/bidi/BidiAnalyzer.js.map +1 -0
  10. package/dist/modules/bidi/BidiCharacterClassifier.d.ts +13 -0
  11. package/dist/modules/bidi/BidiCharacterClassifier.d.ts.map +1 -0
  12. package/dist/modules/bidi/BidiCharacterClassifier.js +2 -0
  13. package/dist/modules/bidi/BidiCharacterClassifier.js.map +1 -0
  14. package/dist/modules/bidi/BidiJsAnalyzer.d.ts +14 -0
  15. package/dist/modules/bidi/BidiJsAnalyzer.d.ts.map +1 -0
  16. package/dist/modules/bidi/BidiJsAnalyzer.js +19 -0
  17. package/dist/modules/bidi/BidiJsAnalyzer.js.map +1 -0
  18. package/dist/modules/bidi/BidiJsCharacterClassifier.d.ts +8 -0
  19. package/dist/modules/bidi/BidiJsCharacterClassifier.d.ts.map +1 -0
  20. package/dist/modules/bidi/BidiJsCharacterClassifier.js +19 -0
  21. package/dist/modules/bidi/BidiJsCharacterClassifier.js.map +1 -0
  22. package/dist/modules/bidi/CursiveScriptDetector.d.ts +12 -0
  23. package/dist/modules/bidi/CursiveScriptDetector.d.ts.map +1 -0
  24. package/dist/modules/bidi/CursiveScriptDetector.js +20 -0
  25. package/dist/modules/bidi/CursiveScriptDetector.js.map +1 -0
  26. package/dist/modules/bidi/HorizontalSide.d.ts +18 -0
  27. package/dist/modules/bidi/HorizontalSide.d.ts.map +1 -0
  28. package/dist/modules/bidi/HorizontalSide.js +3 -0
  29. package/dist/modules/bidi/HorizontalSide.js.map +1 -0
  30. package/dist/modules/bidi/HorizontalSideResolver.d.ts +21 -0
  31. package/dist/modules/bidi/HorizontalSideResolver.d.ts.map +1 -0
  32. package/dist/modules/bidi/HorizontalSideResolver.js +27 -0
  33. package/dist/modules/bidi/HorizontalSideResolver.js.map +1 -0
  34. package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.d.ts +24 -0
  35. package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.d.ts.map +1 -0
  36. package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.js +34 -0
  37. package/dist/modules/bidi/StrongCharacterMajorityTextDirectionDetector.js.map +1 -0
  38. package/dist/modules/bidi/TextDirection.d.ts +9 -0
  39. package/dist/modules/bidi/TextDirection.d.ts.map +1 -0
  40. package/dist/modules/bidi/TextDirection.js +2 -0
  41. package/dist/modules/bidi/TextDirection.js.map +1 -0
  42. package/dist/modules/bidi/TextDirectionDetector.d.ts +12 -0
  43. package/dist/modules/bidi/TextDirectionDetector.d.ts.map +1 -0
  44. package/dist/modules/bidi/TextDirectionDetector.js +2 -0
  45. package/dist/modules/bidi/TextDirectionDetector.js.map +1 -0
  46. package/dist/modules/bidi/WordFragment.d.ts +34 -0
  47. package/dist/modules/bidi/WordFragment.d.ts.map +1 -0
  48. package/dist/modules/bidi/WordFragment.js +2 -0
  49. package/dist/modules/bidi/WordFragment.js.map +1 -0
  50. package/dist/modules/bidi/WordFragmenter.d.ts +43 -0
  51. package/dist/modules/bidi/WordFragmenter.d.ts.map +1 -0
  52. package/dist/modules/bidi/WordFragmenter.js +112 -0
  53. package/dist/modules/bidi/WordFragmenter.js.map +1 -0
  54. package/dist/modules/bidi/index.d.ts +14 -0
  55. package/dist/modules/bidi/index.d.ts.map +1 -0
  56. package/dist/modules/bidi/index.js +8 -0
  57. package/dist/modules/bidi/index.js.map +1 -0
  58. package/dist/modules/css/CssBlockSealer.d.ts +30 -0
  59. package/dist/modules/css/CssBlockSealer.d.ts.map +1 -0
  60. package/dist/modules/css/CssBlockSealer.js +64 -0
  61. package/dist/modules/css/CssBlockSealer.js.map +1 -0
  62. package/dist/modules/css/CssCustomPropertyDefinitionScanner.d.ts +13 -0
  63. package/dist/modules/css/CssCustomPropertyDefinitionScanner.d.ts.map +1 -0
  64. package/dist/modules/css/CssCustomPropertyDefinitionScanner.js +24 -0
  65. package/dist/modules/css/CssCustomPropertyDefinitionScanner.js.map +1 -0
  66. package/dist/modules/css/CssFilterReferenceScanner.d.ts +15 -0
  67. package/dist/modules/css/CssFilterReferenceScanner.d.ts.map +1 -0
  68. package/dist/modules/css/CssFilterReferenceScanner.js +22 -0
  69. package/dist/modules/css/CssFilterReferenceScanner.js.map +1 -0
  70. package/dist/modules/css/CssFragmentParser.d.ts +53 -0
  71. package/dist/modules/css/CssFragmentParser.d.ts.map +1 -0
  72. package/dist/modules/css/CssFragmentParser.js +127 -0
  73. package/dist/modules/css/CssFragmentParser.js.map +1 -0
  74. package/dist/modules/css/CssKeyframeNamespacer.d.ts +21 -0
  75. package/dist/modules/css/CssKeyframeNamespacer.d.ts.map +1 -0
  76. package/dist/modules/css/CssKeyframeNamespacer.js +48 -0
  77. package/dist/modules/css/CssKeyframeNamespacer.js.map +1 -0
  78. package/dist/modules/css/CssKeyframesScanner.d.ts +29 -0
  79. package/dist/modules/css/CssKeyframesScanner.d.ts.map +1 -0
  80. package/dist/modules/css/CssKeyframesScanner.js +102 -0
  81. package/dist/modules/css/CssKeyframesScanner.js.map +1 -0
  82. package/dist/modules/css/CssLayer.d.ts +20 -0
  83. package/dist/modules/css/CssLayer.d.ts.map +1 -0
  84. package/dist/modules/css/CssLayer.js +21 -0
  85. package/dist/modules/css/CssLayer.js.map +1 -0
  86. package/dist/modules/css/CssScoper.d.ts +11 -2
  87. package/dist/modules/css/CssScoper.d.ts.map +1 -1
  88. package/dist/modules/css/CssScoper.js +53 -37
  89. package/dist/modules/css/CssScoper.js.map +1 -1
  90. package/dist/modules/css/CssSelectorClassScanner.d.ts +25 -0
  91. package/dist/modules/css/CssSelectorClassScanner.d.ts.map +1 -0
  92. package/dist/modules/css/CssSelectorClassScanner.js +91 -0
  93. package/dist/modules/css/CssSelectorClassScanner.js.map +1 -0
  94. package/dist/modules/css/CssVarReferenceScanner.d.ts +8 -5
  95. package/dist/modules/css/CssVarReferenceScanner.d.ts.map +1 -1
  96. package/dist/modules/css/CssVarReferenceScanner.js +14 -7
  97. package/dist/modules/css/CssVarReferenceScanner.js.map +1 -1
  98. package/dist/modules/css/index.d.ts +8 -0
  99. package/dist/modules/css/index.d.ts.map +1 -1
  100. package/dist/modules/css/index.js +8 -0
  101. package/dist/modules/css/index.js.map +1 -1
  102. package/dist/modules/document/CssClass.d.ts +20 -0
  103. package/dist/modules/document/CssClass.d.ts.map +1 -0
  104. package/dist/modules/document/CssClass.js +21 -0
  105. package/dist/modules/document/CssClass.js.map +1 -0
  106. package/dist/modules/document/CssVariable.d.ts +0 -6
  107. package/dist/modules/document/CssVariable.d.ts.map +1 -1
  108. package/dist/modules/document/CssVariable.js +0 -6
  109. package/dist/modules/document/CssVariable.js.map +1 -1
  110. package/dist/modules/document/DataAttribute.d.ts +26 -0
  111. package/dist/modules/document/DataAttribute.d.ts.map +1 -0
  112. package/dist/modules/document/DataAttribute.js +27 -0
  113. package/dist/modules/document/DataAttribute.js.map +1 -0
  114. package/dist/modules/document/DocumentEditor.d.ts +40 -9
  115. package/dist/modules/document/DocumentEditor.d.ts.map +1 -1
  116. package/dist/modules/document/DocumentEditor.js +69 -17
  117. package/dist/modules/document/DocumentEditor.js.map +1 -1
  118. package/dist/modules/document/DocumentNodeId.d.ts +23 -0
  119. package/dist/modules/document/DocumentNodeId.d.ts.map +1 -0
  120. package/dist/modules/document/DocumentNodeId.js +31 -0
  121. package/dist/modules/document/DocumentNodeId.js.map +1 -0
  122. package/dist/modules/document/Line.d.ts +1 -1
  123. package/dist/modules/document/Line.d.ts.map +1 -1
  124. package/dist/modules/document/Line.js +2 -1
  125. package/dist/modules/document/Line.js.map +1 -1
  126. package/dist/modules/document/Section.d.ts +1 -4
  127. package/dist/modules/document/Section.d.ts.map +1 -1
  128. package/dist/modules/document/Section.js +2 -17
  129. package/dist/modules/document/Section.js.map +1 -1
  130. package/dist/modules/document/Segment.d.ts +14 -7
  131. package/dist/modules/document/Segment.d.ts.map +1 -1
  132. package/dist/modules/document/Segment.js +26 -1
  133. package/dist/modules/document/Segment.js.map +1 -1
  134. package/dist/modules/document/Word.d.ts +1 -1
  135. package/dist/modules/document/Word.d.ts.map +1 -1
  136. package/dist/modules/document/Word.js +2 -1
  137. package/dist/modules/document/Word.js.map +1 -1
  138. package/dist/modules/document/index.d.ts +4 -2
  139. package/dist/modules/document/index.d.ts.map +1 -1
  140. package/dist/modules/document/index.js +3 -1
  141. package/dist/modules/document/index.js.map +1 -1
  142. package/dist/modules/effect/GapFreeEffect.d.ts +15 -0
  143. package/dist/modules/effect/GapFreeEffect.d.ts.map +1 -1
  144. package/dist/modules/effect/GapFreeEffect.js +29 -4
  145. package/dist/modules/effect/GapFreeEffect.js.map +1 -1
  146. package/dist/modules/pipeline/RenderPipelineBuilder.js +3 -3
  147. package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -1
  148. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -1
  149. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +4 -1
  150. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -1
  151. package/dist/modules/rendering/HorizontalPlacementResolver.d.ts +27 -0
  152. package/dist/modules/rendering/HorizontalPlacementResolver.d.ts.map +1 -0
  153. package/dist/modules/rendering/HorizontalPlacementResolver.js +31 -0
  154. package/dist/modules/rendering/HorizontalPlacementResolver.js.map +1 -0
  155. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +2 -0
  156. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -1
  157. package/dist/modules/rendering/index.d.ts +7 -4
  158. package/dist/modules/rendering/index.d.ts.map +1 -1
  159. package/dist/modules/rendering/index.js +5 -2
  160. package/dist/modules/rendering/index.js.map +1 -1
  161. package/dist/modules/rendering/styles/BaselineCssComposer.d.ts +19 -1
  162. package/dist/modules/rendering/styles/BaselineCssComposer.d.ts.map +1 -1
  163. package/dist/modules/rendering/styles/BaselineCssComposer.js +32 -8
  164. package/dist/modules/rendering/styles/BaselineCssComposer.js.map +1 -1
  165. package/dist/modules/rendering/styles/DecorationContainerBaselineCss.d.ts.map +1 -1
  166. package/dist/modules/rendering/styles/DecorationContainerBaselineCss.js +5 -4
  167. package/dist/modules/rendering/styles/DecorationContainerBaselineCss.js.map +1 -1
  168. package/dist/modules/rendering/styles/FrozenFrameCss.d.ts +28 -0
  169. package/dist/modules/rendering/styles/FrozenFrameCss.d.ts.map +1 -0
  170. package/dist/modules/rendering/styles/FrozenFrameCss.js +28 -0
  171. package/dist/modules/rendering/styles/FrozenFrameCss.js.map +1 -0
  172. package/dist/modules/rendering/styles/InlineStyleEmitter.d.ts +0 -7
  173. package/dist/modules/rendering/styles/InlineStyleEmitter.d.ts.map +1 -1
  174. package/dist/modules/rendering/styles/InlineStyleEmitter.js +0 -9
  175. package/dist/modules/rendering/styles/InlineStyleEmitter.js.map +1 -1
  176. package/dist/modules/rendering/styles/{VideoFrameLayerClass.d.ts → VideoFrameLayerBaselineCss.d.ts} +3 -10
  177. package/dist/modules/rendering/styles/VideoFrameLayerBaselineCss.d.ts.map +1 -0
  178. package/dist/modules/rendering/styles/VideoFrameLayerBaselineCss.js +15 -0
  179. package/dist/modules/rendering/styles/VideoFrameLayerBaselineCss.js.map +1 -0
  180. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.d.ts +3 -1
  181. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.d.ts.map +1 -1
  182. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.js +9 -4
  183. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.js.map +1 -1
  184. package/dist/modules/rendering/subtitle/AnimationProbe.d.ts +23 -9
  185. package/dist/modules/rendering/subtitle/AnimationProbe.d.ts.map +1 -1
  186. package/dist/modules/rendering/subtitle/AnimationProbe.js +86 -81
  187. package/dist/modules/rendering/subtitle/AnimationProbe.js.map +1 -1
  188. package/dist/modules/rendering/subtitle/BatchPlanner.d.ts +1 -0
  189. package/dist/modules/rendering/subtitle/BatchPlanner.d.ts.map +1 -1
  190. package/dist/modules/rendering/subtitle/BatchPlanner.js +16 -14
  191. package/dist/modules/rendering/subtitle/BatchPlanner.js.map +1 -1
  192. package/dist/modules/rendering/subtitle/PreparedStyle.d.ts +1 -0
  193. package/dist/modules/rendering/subtitle/PreparedStyle.d.ts.map +1 -1
  194. package/dist/modules/rendering/subtitle/PreparedStyleFactory.js +1 -1
  195. package/dist/modules/rendering/subtitle/PreparedStyleFactory.js.map +1 -1
  196. package/dist/modules/rendering/subtitle/SegmentPaintRegionResolver.d.ts.map +1 -1
  197. package/dist/modules/rendering/subtitle/SegmentPaintRegionResolver.js +7 -4
  198. package/dist/modules/rendering/subtitle/SegmentPaintRegionResolver.js.map +1 -1
  199. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.d.ts +30 -2
  200. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.d.ts.map +1 -1
  201. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.js +85 -27
  202. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.js.map +1 -1
  203. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.d.ts +3 -8
  204. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.d.ts.map +1 -1
  205. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.js +31 -40
  206. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.js.map +1 -1
  207. package/dist/modules/rendering/subtitle/SpriteSheetCompositor.d.ts +2 -0
  208. package/dist/modules/rendering/subtitle/SpriteSheetCompositor.d.ts.map +1 -1
  209. package/dist/modules/rendering/subtitle/SpriteSheetCompositor.js +18 -9
  210. package/dist/modules/rendering/subtitle/SpriteSheetCompositor.js.map +1 -1
  211. package/dist/modules/rendering/subtitle/SvgFilterMaterializer.d.ts +8 -15
  212. package/dist/modules/rendering/subtitle/SvgFilterMaterializer.d.ts.map +1 -1
  213. package/dist/modules/rendering/subtitle/SvgFilterMaterializer.js +10 -20
  214. package/dist/modules/rendering/subtitle/SvgFilterMaterializer.js.map +1 -1
  215. package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.d.ts.map +1 -1
  216. package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.js +12 -3
  217. package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.js.map +1 -1
  218. package/dist/modules/rendering/types/AlignmentConfig.d.ts +16 -4
  219. package/dist/modules/rendering/types/AlignmentConfig.d.ts.map +1 -1
  220. package/dist/modules/rendering/types/AlignmentConfig.js +2 -1
  221. package/dist/modules/rendering/types/AlignmentConfig.js.map +1 -1
  222. package/dist/modules/rendering/types/ElementRenderOverrides.d.ts +8 -0
  223. package/dist/modules/rendering/types/ElementRenderOverrides.d.ts.map +1 -1
  224. package/dist/modules/rendering/types/ElementRenderOverrides.js +28 -0
  225. package/dist/modules/rendering/types/ElementRenderOverrides.js.map +1 -1
  226. package/dist/modules/rendering/types/RenderingConfig.d.ts +7 -2
  227. package/dist/modules/rendering/types/RenderingConfig.d.ts.map +1 -1
  228. package/dist/modules/rendering/types/ScopedRenderOverride.d.ts +9 -4
  229. package/dist/modules/rendering/types/ScopedRenderOverride.d.ts.map +1 -1
  230. package/dist/modules/subtitle-file/AssSubtitleFileSerializer.d.ts +53 -0
  231. package/dist/modules/subtitle-file/AssSubtitleFileSerializer.d.ts.map +1 -0
  232. package/dist/modules/subtitle-file/AssSubtitleFileSerializer.js +133 -0
  233. package/dist/modules/subtitle-file/AssSubtitleFileSerializer.js.map +1 -0
  234. package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.d.ts +20 -0
  235. package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.d.ts.map +1 -0
  236. package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.js +31 -0
  237. package/dist/modules/subtitle-file/SbvSubtitleFileSerializer.js.map +1 -0
  238. package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.d.ts +21 -0
  239. package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.d.ts.map +1 -0
  240. package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.js +33 -0
  241. package/dist/modules/subtitle-file/SrtSubtitleFileSerializer.js.map +1 -0
  242. package/dist/modules/subtitle-file/SubtitleCue.d.ts +18 -0
  243. package/dist/modules/subtitle-file/SubtitleCue.d.ts.map +1 -0
  244. package/dist/modules/subtitle-file/SubtitleCue.js +20 -0
  245. package/dist/modules/subtitle-file/SubtitleCue.js.map +1 -0
  246. package/dist/modules/subtitle-file/SubtitleCueBuilder.d.ts +38 -0
  247. package/dist/modules/subtitle-file/SubtitleCueBuilder.d.ts.map +1 -0
  248. package/dist/modules/subtitle-file/SubtitleCueBuilder.js +106 -0
  249. package/dist/modules/subtitle-file/SubtitleCueBuilder.js.map +1 -0
  250. package/dist/modules/subtitle-file/SubtitleFileJob.d.ts +17 -0
  251. package/dist/modules/subtitle-file/SubtitleFileJob.d.ts.map +1 -0
  252. package/dist/modules/subtitle-file/SubtitleFileJob.js +2 -0
  253. package/dist/modules/subtitle-file/SubtitleFileJob.js.map +1 -0
  254. package/dist/modules/subtitle-file/SubtitleFileSerializer.d.ts +36 -0
  255. package/dist/modules/subtitle-file/SubtitleFileSerializer.d.ts.map +1 -0
  256. package/dist/modules/subtitle-file/SubtitleFileSerializer.js +44 -0
  257. package/dist/modules/subtitle-file/SubtitleFileSerializer.js.map +1 -0
  258. package/dist/modules/subtitle-file/SubtitleGranularity.d.ts +11 -0
  259. package/dist/modules/subtitle-file/SubtitleGranularity.d.ts.map +1 -0
  260. package/dist/modules/subtitle-file/SubtitleGranularity.js +2 -0
  261. package/dist/modules/subtitle-file/SubtitleGranularity.js.map +1 -0
  262. package/dist/modules/subtitle-file/SubtitleRow.d.ts +11 -0
  263. package/dist/modules/subtitle-file/SubtitleRow.d.ts.map +1 -0
  264. package/dist/modules/subtitle-file/SubtitleRow.js +14 -0
  265. package/dist/modules/subtitle-file/SubtitleRow.js.map +1 -0
  266. package/dist/modules/subtitle-file/SubtitleToken.d.ts +13 -0
  267. package/dist/modules/subtitle-file/SubtitleToken.d.ts.map +1 -0
  268. package/dist/modules/subtitle-file/SubtitleToken.js +15 -0
  269. package/dist/modules/subtitle-file/SubtitleToken.js.map +1 -0
  270. package/dist/modules/subtitle-file/TextSubtitleFileSerializer.d.ts +19 -0
  271. package/dist/modules/subtitle-file/TextSubtitleFileSerializer.d.ts.map +1 -0
  272. package/dist/modules/subtitle-file/TextSubtitleFileSerializer.js +24 -0
  273. package/dist/modules/subtitle-file/TextSubtitleFileSerializer.js.map +1 -0
  274. package/dist/modules/subtitle-file/Timecode.d.ts +20 -0
  275. package/dist/modules/subtitle-file/Timecode.d.ts.map +1 -0
  276. package/dist/modules/subtitle-file/Timecode.js +32 -0
  277. package/dist/modules/subtitle-file/Timecode.js.map +1 -0
  278. package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.d.ts +22 -0
  279. package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.d.ts.map +1 -0
  280. package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.js +57 -0
  281. package/dist/modules/subtitle-file/TtmlSubtitleFileSerializer.js.map +1 -0
  282. package/dist/modules/subtitle-file/VttSubtitleFileSerializer.d.ts +21 -0
  283. package/dist/modules/subtitle-file/VttSubtitleFileSerializer.d.ts.map +1 -0
  284. package/dist/modules/subtitle-file/VttSubtitleFileSerializer.js +39 -0
  285. package/dist/modules/subtitle-file/VttSubtitleFileSerializer.js.map +1 -0
  286. package/dist/modules/subtitle-file/index.d.ts +10 -0
  287. package/dist/modules/subtitle-file/index.d.ts.map +1 -0
  288. package/dist/modules/subtitle-file/index.js +8 -0
  289. package/dist/modules/subtitle-file/index.js.map +1 -0
  290. package/dist/modules/svg-filter/SvgFilter.d.ts +8 -1
  291. package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -1
  292. package/dist/modules/svg-filter/SvgFilter.js +9 -1
  293. package/dist/modules/svg-filter/SvgFilter.js.map +1 -1
  294. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts +1 -0
  295. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts.map +1 -1
  296. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js +9 -1
  297. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js.map +1 -1
  298. package/dist/modules/svg-filter/SvgFilterDefsRenderer.d.ts +44 -0
  299. package/dist/modules/svg-filter/SvgFilterDefsRenderer.d.ts.map +1 -0
  300. package/dist/modules/svg-filter/SvgFilterDefsRenderer.js +47 -0
  301. package/dist/modules/svg-filter/SvgFilterDefsRenderer.js.map +1 -0
  302. package/dist/modules/svg-filter/index.d.ts +2 -0
  303. package/dist/modules/svg-filter/index.d.ts.map +1 -1
  304. package/dist/modules/svg-filter/index.js +1 -0
  305. package/dist/modules/svg-filter/index.js.map +1 -1
  306. package/dist/modules/tagging/PauseTagger.d.ts.map +1 -1
  307. package/dist/modules/tagging/PauseTagger.js +2 -1
  308. package/dist/modules/tagging/PauseTagger.js.map +1 -1
  309. package/dist/modules/tagging/RegexTagger.js +1 -1
  310. package/dist/modules/tagging/RegexTagger.js.map +1 -1
  311. package/dist/modules/tagging/SpanTagger.js +1 -1
  312. package/dist/modules/tagging/SpanTagger.js.map +1 -1
  313. package/dist/modules/tagging/StructureTagger.d.ts +0 -1
  314. package/dist/modules/tagging/StructureTagger.d.ts.map +1 -1
  315. package/dist/modules/tagging/StructureTagger.js +3 -8
  316. package/dist/modules/tagging/StructureTagger.js.map +1 -1
  317. package/dist/modules/tagging/WordlistTagger.js +1 -1
  318. package/dist/modules/tagging/WordlistTagger.js.map +1 -1
  319. package/dist/modules/tags/AndTagCondition.d.ts +10 -0
  320. package/dist/modules/tags/AndTagCondition.d.ts.map +1 -0
  321. package/dist/modules/tags/AndTagCondition.js +14 -0
  322. package/dist/modules/tags/AndTagCondition.js.map +1 -0
  323. package/dist/modules/tags/HasTagCondition.d.ts +10 -0
  324. package/dist/modules/tags/HasTagCondition.d.ts.map +1 -0
  325. package/dist/modules/tags/HasTagCondition.js +18 -0
  326. package/dist/modules/tags/HasTagCondition.js.map +1 -0
  327. package/dist/modules/tags/NotTagCondition.d.ts +10 -0
  328. package/dist/modules/tags/NotTagCondition.d.ts.map +1 -0
  329. package/dist/modules/tags/NotTagCondition.js +14 -0
  330. package/dist/modules/tags/NotTagCondition.js.map +1 -0
  331. package/dist/modules/tags/OrTagCondition.d.ts +10 -0
  332. package/dist/modules/tags/OrTagCondition.d.ts.map +1 -0
  333. package/dist/modules/tags/OrTagCondition.js +14 -0
  334. package/dist/modules/tags/OrTagCondition.js.map +1 -0
  335. package/dist/modules/{document/Tag.d.ts → tags/StructureTag.d.ts} +2 -11
  336. package/dist/modules/tags/StructureTag.d.ts.map +1 -0
  337. package/dist/modules/{document/Tag.js → tags/StructureTag.js} +1 -19
  338. package/dist/modules/tags/StructureTag.js.map +1 -0
  339. package/dist/modules/tags/Tag.d.ts +8 -0
  340. package/dist/modules/tags/Tag.d.ts.map +1 -0
  341. package/dist/modules/tags/Tag.js +16 -0
  342. package/dist/modules/tags/Tag.js.map +1 -0
  343. package/dist/modules/tags/TagCondition.d.ts +12 -0
  344. package/dist/modules/tags/TagCondition.d.ts.map +1 -0
  345. package/dist/modules/tags/TagCondition.js +2 -0
  346. package/dist/modules/tags/TagCondition.js.map +1 -0
  347. package/dist/modules/tags/TagConditionParser.d.ts +21 -0
  348. package/dist/modules/tags/TagConditionParser.d.ts.map +1 -0
  349. package/dist/modules/tags/TagConditionParser.js +75 -0
  350. package/dist/modules/tags/TagConditionParser.js.map +1 -0
  351. package/dist/modules/tags/index.d.ts +9 -0
  352. package/dist/modules/tags/index.d.ts.map +1 -0
  353. package/dist/modules/tags/index.js +8 -0
  354. package/dist/modules/tags/index.js.map +1 -0
  355. package/dist/modules/transcription/AudioDecoder.d.ts +9 -4
  356. package/dist/modules/transcription/AudioDecoder.d.ts.map +1 -1
  357. package/dist/modules/transcription/BatchedMonoResampler.d.ts +45 -0
  358. package/dist/modules/transcription/BatchedMonoResampler.d.ts.map +1 -0
  359. package/dist/modules/transcription/BatchedMonoResampler.js +116 -0
  360. package/dist/modules/transcription/BatchedMonoResampler.js.map +1 -0
  361. package/dist/modules/transcription/CacheStorageModelFileCache.d.ts +38 -0
  362. package/dist/modules/transcription/CacheStorageModelFileCache.d.ts.map +1 -0
  363. package/dist/modules/transcription/CacheStorageModelFileCache.js +86 -0
  364. package/dist/modules/transcription/CacheStorageModelFileCache.js.map +1 -0
  365. package/dist/modules/transcription/CueDocumentBuilder.d.ts +40 -0
  366. package/dist/modules/transcription/CueDocumentBuilder.d.ts.map +1 -0
  367. package/dist/modules/transcription/CueDocumentBuilder.js +77 -0
  368. package/dist/modules/transcription/CueDocumentBuilder.js.map +1 -0
  369. package/dist/modules/transcription/CueParseResult.d.ts +16 -0
  370. package/dist/modules/transcription/CueParseResult.d.ts.map +1 -0
  371. package/dist/modules/transcription/CueParseResult.js +2 -0
  372. package/dist/modules/transcription/CueParseResult.js.map +1 -0
  373. package/dist/modules/transcription/CueTextTokenizer.d.ts +10 -0
  374. package/dist/modules/transcription/CueTextTokenizer.d.ts.map +1 -0
  375. package/dist/modules/transcription/CueTextTokenizer.js +21 -0
  376. package/dist/modules/transcription/CueTextTokenizer.js.map +1 -0
  377. package/dist/modules/transcription/CueTimecodeReader.d.ts +19 -0
  378. package/dist/modules/transcription/CueTimecodeReader.d.ts.map +1 -0
  379. package/dist/modules/transcription/CueTimecodeReader.js +45 -0
  380. package/dist/modules/transcription/CueTimecodeReader.js.map +1 -0
  381. package/dist/modules/transcription/CueWordReader.d.ts +12 -0
  382. package/dist/modules/transcription/CueWordReader.d.ts.map +1 -0
  383. package/dist/modules/transcription/CueWordReader.js +2 -0
  384. package/dist/modules/transcription/CueWordReader.js.map +1 -0
  385. package/dist/modules/transcription/EstimatedCueWordReader.d.ts +16 -0
  386. package/dist/modules/transcription/EstimatedCueWordReader.d.ts.map +1 -0
  387. package/dist/modules/transcription/EstimatedCueWordReader.js +17 -0
  388. package/dist/modules/transcription/EstimatedCueWordReader.js.map +1 -0
  389. package/dist/modules/transcription/LogitsProcessorListFactory.d.ts +43 -0
  390. package/dist/modules/transcription/LogitsProcessorListFactory.d.ts.map +1 -0
  391. package/dist/modules/transcription/LogitsProcessorListFactory.js +72 -0
  392. package/dist/modules/transcription/LogitsProcessorListFactory.js.map +1 -0
  393. package/dist/modules/transcription/MediaBunnyAudioDecoder.d.ts +27 -0
  394. package/dist/modules/transcription/MediaBunnyAudioDecoder.d.ts.map +1 -0
  395. package/dist/modules/transcription/MediaBunnyAudioDecoder.js +76 -0
  396. package/dist/modules/transcription/MediaBunnyAudioDecoder.js.map +1 -0
  397. package/dist/modules/transcription/ModelFileCache.d.ts +20 -0
  398. package/dist/modules/transcription/ModelFileCache.d.ts.map +1 -0
  399. package/dist/modules/transcription/ModelFileCache.js +2 -0
  400. package/dist/modules/transcription/ModelFileCache.js.map +1 -0
  401. package/dist/modules/transcription/ModelFileCacheUnavailableError.d.ts +18 -0
  402. package/dist/modules/transcription/ModelFileCacheUnavailableError.d.ts.map +1 -0
  403. package/dist/modules/transcription/ModelFileCacheUnavailableError.js +18 -0
  404. package/dist/modules/transcription/ModelFileCacheUnavailableError.js.map +1 -0
  405. package/dist/modules/transcription/SrtTranscriber.d.ts +24 -15
  406. package/dist/modules/transcription/SrtTranscriber.d.ts.map +1 -1
  407. package/dist/modules/transcription/SrtTranscriber.js +32 -90
  408. package/dist/modules/transcription/SrtTranscriber.js.map +1 -1
  409. package/dist/modules/transcription/SubtitleFileUnreadableError.d.ts +22 -0
  410. package/dist/modules/transcription/SubtitleFileUnreadableError.d.ts.map +1 -0
  411. package/dist/modules/transcription/SubtitleFileUnreadableError.js +22 -0
  412. package/dist/modules/transcription/SubtitleFileUnreadableError.js.map +1 -0
  413. package/dist/modules/transcription/TimestampedCueWordReader.d.ts +27 -0
  414. package/dist/modules/transcription/TimestampedCueWordReader.d.ts.map +1 -0
  415. package/dist/modules/transcription/TimestampedCueWordReader.js +52 -0
  416. package/dist/modules/transcription/TimestampedCueWordReader.js.map +1 -0
  417. package/dist/modules/transcription/Transcriber.d.ts +13 -0
  418. package/dist/modules/transcription/Transcriber.d.ts.map +1 -1
  419. package/dist/modules/transcription/TransformersRuntime.d.ts +50 -0
  420. package/dist/modules/transcription/TransformersRuntime.d.ts.map +1 -0
  421. package/dist/modules/transcription/TransformersRuntime.js +79 -0
  422. package/dist/modules/transcription/TransformersRuntime.js.map +1 -0
  423. package/dist/modules/transcription/VttTranscriber.d.ts +25 -7
  424. package/dist/modules/transcription/VttTranscriber.d.ts.map +1 -1
  425. package/dist/modules/transcription/VttTranscriber.js +36 -15
  426. package/dist/modules/transcription/VttTranscriber.js.map +1 -1
  427. package/dist/modules/transcription/WhisperChunkStitcher.d.ts +51 -0
  428. package/dist/modules/transcription/WhisperChunkStitcher.d.ts.map +1 -0
  429. package/dist/modules/transcription/WhisperChunkStitcher.js +101 -0
  430. package/dist/modules/transcription/WhisperChunkStitcher.js.map +1 -0
  431. package/dist/modules/transcription/WhisperDeviceUnavailableError.d.ts +16 -0
  432. package/dist/modules/transcription/WhisperDeviceUnavailableError.d.ts.map +1 -0
  433. package/dist/modules/transcription/WhisperDeviceUnavailableError.js +16 -0
  434. package/dist/modules/transcription/WhisperDeviceUnavailableError.js.map +1 -0
  435. package/dist/modules/transcription/WhisperInferenceFailedError.d.ts +16 -0
  436. package/dist/modules/transcription/WhisperInferenceFailedError.d.ts.map +1 -0
  437. package/dist/modules/transcription/WhisperInferenceFailedError.js +16 -0
  438. package/dist/modules/transcription/WhisperInferenceFailedError.js.map +1 -0
  439. package/dist/modules/transcription/WhisperInferenceProgressTracker.d.ts +61 -0
  440. package/dist/modules/transcription/WhisperInferenceProgressTracker.d.ts.map +1 -0
  441. package/dist/modules/transcription/WhisperInferenceProgressTracker.js +102 -0
  442. package/dist/modules/transcription/WhisperInferenceProgressTracker.js.map +1 -0
  443. package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.d.ts +38 -0
  444. package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.d.ts.map +1 -0
  445. package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.js +94 -0
  446. package/dist/modules/transcription/WhisperLoopAbortLogitsProcessor.js.map +1 -0
  447. package/dist/modules/transcription/WhisperModelLoadFailedError.d.ts +15 -0
  448. package/dist/modules/transcription/WhisperModelLoadFailedError.d.ts.map +1 -0
  449. package/dist/modules/transcription/WhisperModelLoadFailedError.js +15 -0
  450. package/dist/modules/transcription/WhisperModelLoadFailedError.js.map +1 -0
  451. package/dist/modules/transcription/WhisperTranscriber.d.ts +106 -7
  452. package/dist/modules/transcription/WhisperTranscriber.d.ts.map +1 -1
  453. package/dist/modules/transcription/WhisperTranscriber.js +312 -25
  454. package/dist/modules/transcription/WhisperTranscriber.js.map +1 -1
  455. package/dist/modules/transcription/WhisperWindowCoverage.d.ts +79 -0
  456. package/dist/modules/transcription/WhisperWindowCoverage.d.ts.map +1 -0
  457. package/dist/modules/transcription/WhisperWindowCoverage.js +129 -0
  458. package/dist/modules/transcription/WhisperWindowCoverage.js.map +1 -0
  459. package/dist/modules/transcription/WordTimingEstimator.d.ts +14 -0
  460. package/dist/modules/transcription/WordTimingEstimator.d.ts.map +1 -0
  461. package/dist/modules/transcription/WordTimingEstimator.js +33 -0
  462. package/dist/modules/transcription/WordTimingEstimator.js.map +1 -0
  463. package/dist/modules/transcription/index.d.ts +8 -2
  464. package/dist/modules/transcription/index.d.ts.map +1 -1
  465. package/dist/modules/transcription/index.js +5 -1
  466. package/dist/modules/transcription/index.js.map +1 -1
  467. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.d.ts.map +1 -1
  468. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.js +8 -0
  469. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.js.map +1 -1
  470. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +3 -1
  471. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +1 -1
  472. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +33 -23
  473. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +1 -1
  474. package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.js +1 -1
  475. package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.js.map +1 -1
  476. package/dist/modules/video/mediabunny/painter/TopLayerSource.d.ts +6 -7
  477. package/dist/modules/video/mediabunny/painter/TopLayerSource.d.ts.map +1 -1
  478. package/package.json +13 -10
  479. package/dist/modules/document/Tag.d.ts.map +0 -1
  480. package/dist/modules/document/Tag.js.map +0 -1
  481. package/dist/modules/rendering/styles/BehindActorBaselineCss.d.ts +0 -19
  482. package/dist/modules/rendering/styles/BehindActorBaselineCss.d.ts.map +0 -1
  483. package/dist/modules/rendering/styles/BehindActorBaselineCss.js +0 -19
  484. package/dist/modules/rendering/styles/BehindActorBaselineCss.js.map +0 -1
  485. package/dist/modules/rendering/styles/VideoFrameLayerClass.d.ts.map +0 -1
  486. package/dist/modules/rendering/styles/VideoFrameLayerClass.js +0 -21
  487. package/dist/modules/rendering/styles/VideoFrameLayerClass.js.map +0 -1
  488. package/dist/modules/rendering/types/BehindActorRequirement.d.ts +0 -12
  489. package/dist/modules/rendering/types/BehindActorRequirement.d.ts.map +0 -1
  490. package/dist/modules/rendering/types/BehindActorRequirement.js +0 -2
  491. package/dist/modules/rendering/types/BehindActorRequirement.js.map +0 -1
  492. package/dist/modules/transcription/BrowserAudioDecoder.d.ts +0 -13
  493. package/dist/modules/transcription/BrowserAudioDecoder.d.ts.map +0 -1
  494. package/dist/modules/transcription/BrowserAudioDecoder.js +0 -34
  495. package/dist/modules/transcription/BrowserAudioDecoder.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The inference library, loaded on first use and configured once.
3
+ *
4
+ * It is reached through a dynamic import because a static one makes the
5
+ * whole ONNX runtime a dependency of merely *naming* a transcriber: the
6
+ * package's entry point re-exports this module, so a consumer that
7
+ * imports a document node pulls the runtime with it. In a browser that
8
+ * is a large bundle nobody asked for; in Node it is a native binding
9
+ * loaded — and on musl, failed — for code that never runs inference.
10
+ *
11
+ * The environment settings live here rather than at the call site
12
+ * because they have to be applied before the first pipeline is built and
13
+ * exactly once. Holding the module and the settings together is what
14
+ * makes "loaded" and "configured" the same event.
15
+ *
16
+ * A failed load is not cached: the import can fail on a dead network the
17
+ * same way the weights can, and a caller retrying deserves to reach the
18
+ * network again.
19
+ */
20
+ export class TransformersRuntime {
21
+ modelFileCache;
22
+ modulePromise = null;
23
+ constructor(modelFileCache) {
24
+ this.modelFileCache = modelFileCache;
25
+ }
26
+ /**
27
+ * Resolves with the library, configured. Concurrent callers share one
28
+ * load, and the settings are applied before any of them sees it.
29
+ */
30
+ load() {
31
+ if (this.modulePromise === null) {
32
+ const attempt = import('@huggingface/transformers').then((module) => {
33
+ this.configure(module.env);
34
+ return module;
35
+ });
36
+ attempt.catch(() => {
37
+ if (this.modulePromise === attempt)
38
+ this.modulePromise = null;
39
+ });
40
+ this.modulePromise = attempt;
41
+ }
42
+ return this.modulePromise;
43
+ }
44
+ configure(env) {
45
+ env.allowLocalModels = false;
46
+ this.installModelFileCache(env);
47
+ this.configureWasmThreading(env);
48
+ }
49
+ /**
50
+ * Takes over where the downloaded model files are kept.
51
+ *
52
+ * Left to itself the library picks a store from the environment and
53
+ * discards a refused write with nothing but a console warning, so a
54
+ * caller that wants to know when the files did not survive the run
55
+ * has to own the store. Without one, that default stands.
56
+ */
57
+ installModelFileCache(env) {
58
+ if (!this.modelFileCache)
59
+ return;
60
+ env.useCustomCache = true;
61
+ env.customCache = this.modelFileCache;
62
+ }
63
+ /**
64
+ * Raises the WASM thread count above ORT's built-in ceiling when the
65
+ * runtime supports it. ORT locks the count to 1 without cross-origin
66
+ * isolation, and even with isolation its own default caps at 4 no matter
67
+ * the machine — Whisper's encoder scales past that. On a WebGPU run this
68
+ * has no effect; the WASM backend is not touched.
69
+ */
70
+ configureWasmThreading(env) {
71
+ if (typeof self === 'undefined' || !self.crossOriginIsolated)
72
+ return;
73
+ const wasm = env.backends.onnx.wasm;
74
+ if (!wasm)
75
+ return;
76
+ wasm.numThreads = Math.min(navigator.hardwareConcurrency || 4, 8);
77
+ }
78
+ }
79
+ //# sourceMappingURL=TransformersRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformersRuntime.js","sourceRoot":"","sources":["../../../src/modules/transcription/TransformersRuntime.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,mBAAmB;IAGD;IAFrB,aAAa,GAAwC,IAAI,CAAC;IAElE,YAA6B,cAA+B;QAA/B,mBAAc,GAAd,cAAc,CAAiB;IAAG,CAAC;IAEhE;;;OAGG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBAClE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC3B,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;gBACjB,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO;oBAAE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAChE,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEO,SAAS,CAAC,GAA4B;QAC5C,GAAG,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;;OAOG;IACK,qBAAqB,CAAC,GAA4B;QACxD,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO;QACjC,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC;QAC1B,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACK,sBAAsB,CAAC,GAA4B;QACzD,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,mBAAmB;YAAE,OAAO;QACrE,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -3,24 +3,42 @@ import type { Transcriber, TranscriberOptions, TranscriberProgressEvent } from '
3
3
  /**
4
4
  * Builds a Document by parsing a WebVTT (`.vtt`) caption file. Skips
5
5
  * the mandatory `WEBVTT` header block and any `NOTE`, `STYLE`, or
6
- * `REGION` blocks, then hands the remaining cue blocks to
7
- * `SrtTranscriber` — the underlying timecode grammar, tag stripping,
8
- * and word-timing distribution are compatible between the two
9
- * formats.
6
+ * `REGION` blocks, then reads the cues below them.
7
+ *
8
+ * WebVTT can mark inside a cue when each word is spoken, and those
9
+ * marks are honoured: a file carrying them yields the word timings it
10
+ * recorded rather than a guess. Where a cue carries no marks, its words
11
+ * are shared out across it the way a format without marks requires.
10
12
  *
11
13
  * The audio Blob passed to `transcribe` is ignored. Useful when
12
14
  * caption text and timing are already known — burning a hand-authored
13
15
  * VTT into a video, replaying captions from a subtitle-authoring
14
16
  * tool, etc.
15
17
  *
16
- * Throws when a cue block is malformed; returns an empty Document
17
- * when the source has no parseable cues.
18
+ * A block that carries no timecode is skipped and announced through
19
+ * `onSkippedCueBlock`, so a single broken cue costs its own text and
20
+ * nothing else. Throws only when the file has blocks and none of them
21
+ * could be read, or when a timecode itself is malformed.
22
+ *
23
+ * Builds its own collaborators rather than receiving them. The
24
+ * constructor is the surface a consumer of the engine reaches for, and
25
+ * it asks for a source and nothing else, so this class is where the
26
+ * parsing side is assembled rather than a participant in someone
27
+ * else's assembly.
18
28
  */
19
29
  export declare class VttTranscriber implements Transcriber {
20
30
  private readonly source;
21
31
  onProgress?: (event: TranscriberProgressEvent) => void;
32
+ /**
33
+ * Fired once per block left out of the document, before
34
+ * `transcribe` resolves, carrying the block verbatim.
35
+ */
36
+ onSkippedCueBlock?: (block: string) => void;
37
+ private readonly timecodeReader;
38
+ private readonly documentBuilder;
39
+ private readonly wordReader;
22
40
  constructor(source: string);
23
- transcribe(audio: Blob, options?: TranscriberOptions): Promise<Document>;
41
+ transcribe(_audio: Blob, _options?: TranscriberOptions): Promise<Document>;
24
42
  private extractCueBlocks;
25
43
  private stripWebVttHeader;
26
44
  private isCueBlock;
@@ -1 +1 @@
1
- {"version":3,"file":"VttTranscriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/VttTranscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAI5C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAe,YAAW,WAAW;IAGpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;gBAE1B,MAAM,EAAE,MAAM;IAErC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO9E,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,UAAU;CAOnB"}
1
+ {"version":3,"file":"VttTranscriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/VttTranscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAM3D,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,cAAe,YAAW,WAAW;IAiBpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAhBnC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAEvD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2B;IAC1D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA+C;IAC/E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAIzB;gBAE2B,MAAM,EAAE,MAAM;IAErC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOhF,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,UAAU;CAOnB"}
@@ -1,38 +1,59 @@
1
- import { SrtTranscriber } from '../transcription/SrtTranscriber';
1
+ import { CueDocumentBuilder } from '../transcription/CueDocumentBuilder';
2
+ import { CueTextTokenizer } from '../transcription/CueTextTokenizer';
3
+ import { CueTimecodeReader } from '../transcription/CueTimecodeReader';
4
+ import { TimestampedCueWordReader } from '../transcription/TimestampedCueWordReader';
5
+ import { WordTimingEstimator } from '../transcription/WordTimingEstimator';
2
6
  const BOM_RE = /^\uFEFF/;
3
7
  /**
4
8
  * Builds a Document by parsing a WebVTT (`.vtt`) caption file. Skips
5
9
  * the mandatory `WEBVTT` header block and any `NOTE`, `STYLE`, or
6
- * `REGION` blocks, then hands the remaining cue blocks to
7
- * `SrtTranscriber` — the underlying timecode grammar, tag stripping,
8
- * and word-timing distribution are compatible between the two
9
- * formats.
10
+ * `REGION` blocks, then reads the cues below them.
11
+ *
12
+ * WebVTT can mark inside a cue when each word is spoken, and those
13
+ * marks are honoured: a file carrying them yields the word timings it
14
+ * recorded rather than a guess. Where a cue carries no marks, its words
15
+ * are shared out across it the way a format without marks requires.
10
16
  *
11
17
  * The audio Blob passed to `transcribe` is ignored. Useful when
12
18
  * caption text and timing are already known — burning a hand-authored
13
19
  * VTT into a video, replaying captions from a subtitle-authoring
14
20
  * tool, etc.
15
21
  *
16
- * Throws when a cue block is malformed; returns an empty Document
17
- * when the source has no parseable cues.
22
+ * A block that carries no timecode is skipped and announced through
23
+ * `onSkippedCueBlock`, so a single broken cue costs its own text and
24
+ * nothing else. Throws only when the file has blocks and none of them
25
+ * could be read, or when a timecode itself is malformed.
26
+ *
27
+ * Builds its own collaborators rather than receiving them. The
28
+ * constructor is the surface a consumer of the engine reaches for, and
29
+ * it asks for a source and nothing else, so this class is where the
30
+ * parsing side is assembled rather than a participant in someone
31
+ * else's assembly.
18
32
  */
19
33
  export class VttTranscriber {
20
34
  source;
21
35
  onProgress;
36
+ /**
37
+ * Fired once per block left out of the document, before
38
+ * `transcribe` resolves, carrying the block verbatim.
39
+ */
40
+ onSkippedCueBlock;
41
+ timecodeReader = new CueTimecodeReader();
42
+ documentBuilder = new CueDocumentBuilder(this.timecodeReader);
43
+ wordReader = new TimestampedCueWordReader(new CueTextTokenizer(), this.timecodeReader, new WordTimingEstimator());
22
44
  constructor(source) {
23
45
  this.source = source;
24
46
  }
25
- async transcribe(audio, options) {
26
- const cueOnlySource = this.extractCueBlocks(this.source);
27
- const inner = new SrtTranscriber(cueOnlySource);
28
- if (this.onProgress)
29
- inner.onProgress = this.onProgress;
30
- return inner.transcribe(audio, options);
47
+ async transcribe(_audio, _options) {
48
+ this.onProgress?.({ stage: 'inferring', progress: 1 });
49
+ const result = this.documentBuilder.build(this.extractCueBlocks(this.source), this.wordReader);
50
+ for (const block of result.skippedBlocks)
51
+ this.onSkippedCueBlock?.(block);
52
+ return result.document;
31
53
  }
32
54
  extractCueBlocks(source) {
33
55
  const normalized = source.replace(BOM_RE, '').replace(/\r\n?/g, '\n');
34
- const withoutHeader = this.stripWebVttHeader(normalized);
35
- return withoutHeader
56
+ return this.stripWebVttHeader(normalized)
36
57
  .split(/\n{2,}/)
37
58
  .filter((block) => this.isCueBlock(block))
38
59
  .join('\n\n');
@@ -1 +1 @@
1
- {"version":3,"file":"VttTranscriber.js","sourceRoot":"","sources":["../../../src/modules/transcription/VttTranscriber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAOvE,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IAGI;IAF7B,UAAU,CAA6C;IAEvD,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,KAAK,CAAC,UAAU,CAAC,KAAW,EAAE,OAA4B;QACxD,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,UAAU;YAAE,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACxD,OAAO,KAAK,CAAC,UAAU,CAAC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
@@ -0,0 +1,51 @@
1
+ /** One word-timestamped chunk as transformers.js reports it. */
2
+ export interface WhisperChunk {
3
+ text: string;
4
+ timestamp: [number | null, number | null];
5
+ }
6
+ /**
7
+ * Reconciles the chunk streams from consecutive pipeline windows into
8
+ * one non-duplicated timeline.
9
+ *
10
+ * transformers.js runs Whisper's chunk-and-stitch long-form strategy:
11
+ * consecutive windows overlap by `2 * strideLengthSeconds`, and each
12
+ * window transcribes its full range independently. The library is
13
+ * supposed to discard the overlap zones at stitch time but its word-
14
+ * timestamps path leaks them through — both windows' takes on the
15
+ * same audio land in the final chunks. Under a degenerate loop or a
16
+ * token-ceiling cut, a window can also flood its overlap zone with
17
+ * garbage.
18
+ *
19
+ * This class re-splits the merged chunk stream back into per-window
20
+ * groups (detected via timestamp drops in generation order) and crops
21
+ * each to a single half of every overlap. The split point between two
22
+ * consecutive windows is the later of the overlap midpoint and the
23
+ * next window's own first chunk — so if the next window declared
24
+ * silence over part of its overlap, the previous window's take on
25
+ * that same audio is kept instead of dropped.
26
+ */
27
+ export declare class WhisperChunkStitcher {
28
+ private readonly chunkLengthSeconds;
29
+ private readonly strideLengthSeconds;
30
+ constructor(chunkLengthSeconds: number, strideLengthSeconds: number);
31
+ stitch(chunks: WhisperChunk[], audioDurationSeconds: number): WhisperChunk[];
32
+ /**
33
+ * Splits the merged chunk stream into per-window groups. Windows emit
34
+ * in generation order and each window's own timestamps are monotonic,
35
+ * so a chunk whose anchor is earlier than the previous chunk's marks
36
+ * the start of the next window.
37
+ */
38
+ private splitByGenerationWindow;
39
+ /**
40
+ * The split points between consecutive window groups, in absolute
41
+ * seconds. `boundaries[i]` is the second at which trust hands over
42
+ * from window `i` to window `i + 1`.
43
+ */
44
+ private trustBoundariesBetween;
45
+ private leftBoundaryOf;
46
+ private rightBoundaryOf;
47
+ private cropGroup;
48
+ private anchorOf;
49
+ private firstAnchorOf;
50
+ }
51
+ //# sourceMappingURL=WhisperChunkStitcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperChunkStitcher.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperChunkStitcher.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBADnB,kBAAkB,EAAE,MAAM,EAC1B,mBAAmB,EAAE,MAAM;IAG9C,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,oBAAoB,EAAE,MAAM,GAAG,YAAY,EAAE;IAW5E;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,aAAa;CAOtB"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Reconciles the chunk streams from consecutive pipeline windows into
3
+ * one non-duplicated timeline.
4
+ *
5
+ * transformers.js runs Whisper's chunk-and-stitch long-form strategy:
6
+ * consecutive windows overlap by `2 * strideLengthSeconds`, and each
7
+ * window transcribes its full range independently. The library is
8
+ * supposed to discard the overlap zones at stitch time but its word-
9
+ * timestamps path leaks them through — both windows' takes on the
10
+ * same audio land in the final chunks. Under a degenerate loop or a
11
+ * token-ceiling cut, a window can also flood its overlap zone with
12
+ * garbage.
13
+ *
14
+ * This class re-splits the merged chunk stream back into per-window
15
+ * groups (detected via timestamp drops in generation order) and crops
16
+ * each to a single half of every overlap. The split point between two
17
+ * consecutive windows is the later of the overlap midpoint and the
18
+ * next window's own first chunk — so if the next window declared
19
+ * silence over part of its overlap, the previous window's take on
20
+ * that same audio is kept instead of dropped.
21
+ */
22
+ export class WhisperChunkStitcher {
23
+ chunkLengthSeconds;
24
+ strideLengthSeconds;
25
+ constructor(chunkLengthSeconds, strideLengthSeconds) {
26
+ this.chunkLengthSeconds = chunkLengthSeconds;
27
+ this.strideLengthSeconds = strideLengthSeconds;
28
+ }
29
+ stitch(chunks, audioDurationSeconds) {
30
+ const groups = this.splitByGenerationWindow(chunks);
31
+ if (groups.length <= 1)
32
+ return chunks;
33
+ const boundaries = this.trustBoundariesBetween(groups);
34
+ return groups.flatMap((group, index) => this.cropGroup(group, this.leftBoundaryOf(index, boundaries), this.rightBoundaryOf(index, boundaries, groups.length, audioDurationSeconds)));
35
+ }
36
+ /**
37
+ * Splits the merged chunk stream into per-window groups. Windows emit
38
+ * in generation order and each window's own timestamps are monotonic,
39
+ * so a chunk whose anchor is earlier than the previous chunk's marks
40
+ * the start of the next window.
41
+ */
42
+ splitByGenerationWindow(chunks) {
43
+ const groups = [];
44
+ let current = [];
45
+ let previousAnchor = null;
46
+ for (const chunk of chunks) {
47
+ const anchor = this.anchorOf(chunk);
48
+ if (anchor !== null && previousAnchor !== null && anchor < previousAnchor) {
49
+ groups.push(current);
50
+ current = [];
51
+ }
52
+ current.push(chunk);
53
+ if (anchor !== null)
54
+ previousAnchor = anchor;
55
+ }
56
+ if (current.length > 0)
57
+ groups.push(current);
58
+ return groups;
59
+ }
60
+ /**
61
+ * The split points between consecutive window groups, in absolute
62
+ * seconds. `boundaries[i]` is the second at which trust hands over
63
+ * from window `i` to window `i + 1`.
64
+ */
65
+ trustBoundariesBetween(groups) {
66
+ const advance = this.chunkLengthSeconds - 2 * this.strideLengthSeconds;
67
+ const boundaries = [];
68
+ for (let index = 0; index < groups.length - 1; index++) {
69
+ const overlapMidpoint = index * advance + this.chunkLengthSeconds - this.strideLengthSeconds;
70
+ const nextGroupFirstAnchor = this.firstAnchorOf(groups[index + 1]);
71
+ boundaries.push(nextGroupFirstAnchor === null
72
+ ? overlapMidpoint
73
+ : Math.max(overlapMidpoint, nextGroupFirstAnchor));
74
+ }
75
+ return boundaries;
76
+ }
77
+ leftBoundaryOf(groupIndex, boundaries) {
78
+ return groupIndex === 0 ? 0 : boundaries[groupIndex - 1];
79
+ }
80
+ rightBoundaryOf(groupIndex, boundaries, groupCount, audioDurationSeconds) {
81
+ return groupIndex === groupCount - 1 ? audioDurationSeconds : boundaries[groupIndex];
82
+ }
83
+ cropGroup(group, leftSeconds, rightSeconds) {
84
+ return group.filter((chunk) => {
85
+ const anchor = this.anchorOf(chunk);
86
+ return anchor !== null && anchor >= leftSeconds && anchor < rightSeconds;
87
+ });
88
+ }
89
+ anchorOf(chunk) {
90
+ return chunk.timestamp[0] ?? chunk.timestamp[1];
91
+ }
92
+ firstAnchorOf(group) {
93
+ for (const chunk of group) {
94
+ const anchor = this.anchorOf(chunk);
95
+ if (anchor !== null)
96
+ return anchor;
97
+ }
98
+ return null;
99
+ }
100
+ }
101
+ //# sourceMappingURL=WhisperChunkStitcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperChunkStitcher.js","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperChunkStitcher.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,oBAAoB;IAEZ;IACA;IAFnB,YACmB,kBAA0B,EAC1B,mBAA2B;QAD3B,uBAAkB,GAAlB,kBAAkB,CAAQ;QAC1B,wBAAmB,GAAnB,mBAAmB,CAAQ;IAC3C,CAAC;IAEJ,MAAM,CAAC,MAAsB,EAAE,oBAA4B;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO,MAAM,CAAC;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACvD,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IAEO,aAAa,CAAC,KAAqB;QACzC,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,MAAM,KAAK,IAAI;gBAAE,OAAO,MAAM,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Raised when the device the transcriber was asked to run on is not
3
+ * usable — either the model does not ship the artefacts needed for
4
+ * that device, or the browser does not expose the runtime that device
5
+ * relies on. Fired before any model file is fetched.
6
+ *
7
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
8
+ * the class, so consumers can recognise the failure across a Worker
9
+ * boundary (where structured cloning preserves the string fields but
10
+ * not the class identity) with a single source of truth.
11
+ */
12
+ export declare class WhisperDeviceUnavailableError extends Error {
13
+ static readonly ERROR_NAME = "WhisperDeviceUnavailableError";
14
+ readonly name = "WhisperDeviceUnavailableError";
15
+ }
16
+ //# sourceMappingURL=WhisperDeviceUnavailableError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperDeviceUnavailableError.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperDeviceUnavailableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;IACtD,MAAM,CAAC,QAAQ,CAAC,UAAU,mCAAmC;IAC7D,QAAQ,CAAC,IAAI,mCAA4C;CAC1D"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Raised when the device the transcriber was asked to run on is not
3
+ * usable — either the model does not ship the artefacts needed for
4
+ * that device, or the browser does not expose the runtime that device
5
+ * relies on. Fired before any model file is fetched.
6
+ *
7
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
8
+ * the class, so consumers can recognise the failure across a Worker
9
+ * boundary (where structured cloning preserves the string fields but
10
+ * not the class identity) with a single source of truth.
11
+ */
12
+ export class WhisperDeviceUnavailableError extends Error {
13
+ static ERROR_NAME = 'WhisperDeviceUnavailableError';
14
+ name = WhisperDeviceUnavailableError.ERROR_NAME;
15
+ }
16
+ //# sourceMappingURL=WhisperDeviceUnavailableError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperDeviceUnavailableError.js","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperDeviceUnavailableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,MAAM,CAAU,UAAU,GAAG,+BAA+B,CAAC;IACpD,IAAI,GAAG,6BAA6B,CAAC,UAAU,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Raised when the Whisper pipeline was loaded successfully but the
3
+ * inference call itself rejected — the model ran out of memory, the
4
+ * WebGPU device was lost mid-decode, the input audio was too short,
5
+ * or any other runtime error surfaced while transcribing.
6
+ *
7
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
8
+ * the class, so consumers can recognise the failure across a Worker
9
+ * boundary (where structured cloning preserves the string fields but
10
+ * not the class identity) with a single source of truth.
11
+ */
12
+ export declare class WhisperInferenceFailedError extends Error {
13
+ static readonly ERROR_NAME = "WhisperInferenceFailedError";
14
+ readonly name = "WhisperInferenceFailedError";
15
+ }
16
+ //# sourceMappingURL=WhisperInferenceFailedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperInferenceFailedError.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperInferenceFailedError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAC,QAAQ,CAAC,UAAU,iCAAiC;IAC3D,QAAQ,CAAC,IAAI,iCAA0C;CACxD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Raised when the Whisper pipeline was loaded successfully but the
3
+ * inference call itself rejected — the model ran out of memory, the
4
+ * WebGPU device was lost mid-decode, the input audio was too short,
5
+ * or any other runtime error surfaced while transcribing.
6
+ *
7
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
8
+ * the class, so consumers can recognise the failure across a Worker
9
+ * boundary (where structured cloning preserves the string fields but
10
+ * not the class identity) with a single source of truth.
11
+ */
12
+ export class WhisperInferenceFailedError extends Error {
13
+ static ERROR_NAME = 'WhisperInferenceFailedError';
14
+ name = WhisperInferenceFailedError.ERROR_NAME;
15
+ }
16
+ //# sourceMappingURL=WhisperInferenceFailedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperInferenceFailedError.js","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperInferenceFailedError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAU,UAAU,GAAG,6BAA6B,CAAC;IAClD,IAAI,GAAG,2BAA2B,CAAC,UAAU,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Turns Whisper's chunk-relative timestamp stream into a monotonic
3
+ * fraction of the inference work done so far, in
4
+ * `[0, MAX_STREAMING_FRACTION]`.
5
+ *
6
+ * The transformers.js pipeline slices audio into fixed windows of
7
+ * `chunkLengthSeconds` and slides them by `chunkLengthSeconds - 2 *
8
+ * strideLengthSeconds`, decoding each window independently. Whisper's
9
+ * predicted timestamps restart at zero on every window, so a backward
10
+ * step in the observed stream is treated as the boundary between two
11
+ * pipeline windows. Small backward jitter *within* a window (the
12
+ * decoder occasionally re-emits an earlier timestamp) is tolerated up
13
+ * to `INTRA_CHUNK_TOLERANCE_SECONDS`.
14
+ *
15
+ * Progress is measured against the audio each window decodes, not
16
+ * against the position reached in the source. Consecutive windows
17
+ * overlap by `2 * strideLengthSeconds`, and that overlap is decoded
18
+ * twice: a position-based fraction cannot advance until a new window
19
+ * has re-decoded everything the previous one already covered, which
20
+ * shows up as the bar sitting frozen for the first third of every
21
+ * window. Counting each window's own audio makes the fraction track
22
+ * the decoder's actual cost instead.
23
+ *
24
+ * The returned fraction never decreases and never reaches `1`:
25
+ * Whisper still runs a word-timestamp post-processing pass after the
26
+ * last streamed segment, so a strictly-below-one ceiling leaves room
27
+ * for the caller to emit the terminal `1` from outside the streamer
28
+ * once the whole call actually completes.
29
+ */
30
+ export declare class WhisperInferenceProgressTracker {
31
+ private static readonly INTRA_CHUNK_TOLERANCE_SECONDS;
32
+ private static readonly MAX_STREAMING_FRACTION;
33
+ private readonly windowSeconds;
34
+ private readonly totalWorkSeconds;
35
+ private readonly windowAdvanceSeconds;
36
+ private currentWindowIndex;
37
+ private workBeforeCurrentWindow;
38
+ private lastReportedChunkTime;
39
+ private lastFraction;
40
+ constructor(durationSeconds: number, chunkLengthSeconds: number, strideLengthSeconds: number);
41
+ /** The audio each pipeline window decodes, in window order. */
42
+ get windowLayout(): readonly number[];
43
+ /** How far the pipeline slides between consecutive windows, in seconds. */
44
+ get advanceSeconds(): number;
45
+ /**
46
+ * Feeds a chunk-relative timestamp and returns the resulting monotonic
47
+ * progress fraction over the whole inference.
48
+ */
49
+ observeChunkEnd(timeWithinChunk: number): number;
50
+ /**
51
+ * Reproduces the window layout the transformers.js ASR pipeline builds
52
+ * for this audio, as the amount of audio each window carries. The last
53
+ * window is short whenever the audio does not end on a window boundary.
54
+ */
55
+ private measureWindows;
56
+ private isNewPipelineWindow;
57
+ private advanceWindow;
58
+ private currentWindowSeconds;
59
+ private fractionAt;
60
+ }
61
+ //# sourceMappingURL=WhisperInferenceProgressTracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhisperInferenceProgressTracker.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/WhisperInferenceProgressTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,+BAA+B;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,6BAA6B,CAAK;IAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAQ;IAEtD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAW;IACzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAE9C,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,uBAAuB,CAAK;IACpC,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,YAAY,CAAK;gBAGvB,eAAe,EAAE,MAAM,EACvB,kBAAkB,EAAE,MAAM,EAC1B,mBAAmB,EAAE,MAAM;IAO7B,+DAA+D;IAC/D,IAAI,YAAY,IAAI,SAAS,MAAM,EAAE,CAEpC;IAED,2EAA2E;IAC3E,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED;;;OAGG;IACH,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM;IAShD;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,UAAU;CAMnB"}