@tscaps/engine 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +16 -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,76 @@
1
+ import { ALL_FORMATS, AudioSampleSink, BlobSource, Input, } from 'mediabunny';
2
+ import { BatchedMonoResampler } from '../transcription/BatchedMonoResampler';
3
+ /**
4
+ * Decodes an audio/video Blob to mono `Float32Array` PCM at the
5
+ * requested sample rate by demuxing the container with mediabunny and
6
+ * iterating the primary audio track through {@link AudioSampleSink}.
7
+ * Downmixes and resamples in fixed-size batches via
8
+ * {@link BatchedMonoResampler} so peak memory is bounded by one batch
9
+ * of source-rate audio plus the pre-sized target buffer, not by the
10
+ * whole track — a long video no longer holds ~4× its useful PCM size
11
+ * in transient buffers on the way to the worker.
12
+ *
13
+ * Main-thread only — `OfflineAudioContext` is not available inside
14
+ * Worker contexts.
15
+ *
16
+ * A codec the current browser cannot decode surfaces as a
17
+ * `DOMException` named `NotSupportedError`, following the WebCodecs
18
+ * convention. Any other underlying mediabunny / WebCodecs failure is
19
+ * re-thrown verbatim so callers can inspect its `name` / `cause` to
20
+ * classify the reason.
21
+ */
22
+ export class MediaBunnyAudioDecoder {
23
+ async decode(audio, targetSampleRate, onProgress) {
24
+ const input = new Input({ formats: ALL_FORMATS, source: new BlobSource(audio) });
25
+ try {
26
+ return await this.decodeInput(input, targetSampleRate, onProgress);
27
+ }
28
+ finally {
29
+ input.dispose();
30
+ }
31
+ }
32
+ async decodeInput(input, targetSampleRate, onProgress) {
33
+ const track = await input.getPrimaryAudioTrack();
34
+ if (!track)
35
+ return new Float32Array(0);
36
+ if (!(await track.canDecode())) {
37
+ const codec = await track.getCodec();
38
+ throw new DOMException(`Audio codec is not supported by this browser: ${codec ?? 'unknown'}`, 'NotSupportedError');
39
+ }
40
+ const durationSeconds = await track.computeDuration();
41
+ if (durationSeconds <= 0)
42
+ return new Float32Array(0);
43
+ const target = new Float32Array(Math.max(1, Math.ceil(durationSeconds * targetSampleRate)));
44
+ const resampler = new BatchedMonoResampler(target, targetSampleRate);
45
+ const written = await this.streamMonoInto(track, resampler, durationSeconds, onProgress);
46
+ return target.subarray(0, written);
47
+ }
48
+ async streamMonoInto(track, resampler, durationSeconds, onProgress) {
49
+ const sink = new AudioSampleSink(track);
50
+ for await (const sample of sink.samples(0)) {
51
+ try {
52
+ await resampler.append(sample);
53
+ if (onProgress)
54
+ onProgress(this.progressAt(sample, durationSeconds));
55
+ }
56
+ finally {
57
+ sample.close();
58
+ }
59
+ }
60
+ if (onProgress)
61
+ onProgress(1);
62
+ return resampler.flush();
63
+ }
64
+ progressAt(sample, durationSeconds) {
65
+ const decodedSeconds = sample.timestamp + sample.numberOfFrames / sample.sampleRate;
66
+ if (durationSeconds <= 0)
67
+ return 0;
68
+ const ratio = decodedSeconds / durationSeconds;
69
+ if (ratio < 0)
70
+ return 0;
71
+ if (ratio > 1)
72
+ return 1;
73
+ return ratio;
74
+ }
75
+ }
76
+ //# sourceMappingURL=MediaBunnyAudioDecoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaBunnyAudioDecoder.js","sourceRoot":"","sources":["../../../src/modules/transcription/MediaBunnyAudioDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,GAGN,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,sBAAsB;IACjC,KAAK,CAAC,MAAM,CACV,KAAW,EACX,gBAAwB,EACxB,UAAuC;QAEvC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,gBAAgB,EA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ACxC,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC;gBACH,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC/B,IAAI,UAAU;oBAAE,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;YACvE,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEO,UAAU,CAAC,MAAmB,EAAE,eAAuB;QAC7D,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;QACpF,IAAI,eAAe,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,cAAc,GAAG,eAAe,CAAC;QAC/C,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACxB,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Local store for the model files a transcriber downloads, so a later
3
+ * run reads them back instead of fetching them again.
4
+ *
5
+ * Both operations are best-effort by contract: a store that cannot
6
+ * answer reports a miss, and a store that cannot keep a file resolves
7
+ * anyway. Neither ever rejects. Losing the copy costs a download on
8
+ * the next run, which is worth far less than the transcription in
9
+ * flight.
10
+ *
11
+ * Keys are opaque strings chosen by the caller and must round-trip
12
+ * verbatim between `put` and `match`.
13
+ */
14
+ export interface ModelFileCache {
15
+ /** The stored file, or `undefined` when this key was never kept. */
16
+ match(key: string): Promise<Response | undefined>;
17
+ /** Keeps `response` under `key`, replacing nothing already there. */
18
+ put(key: string, response: Response): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=ModelFileCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelFileCache.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAElD,qEAAqE;IACrE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ModelFileCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelFileCache.js","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCache.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Raised when the runtime exposes no place to keep model files, so
3
+ * every run has to download them again.
4
+ *
5
+ * The Cache Storage API is restricted to secure contexts and withheld
6
+ * altogether by some privacy modes, so a page served over plain HTTP
7
+ * from anything other than localhost has nowhere to put them.
8
+ *
9
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
10
+ * the class, so consumers can recognise the failure across a Worker
11
+ * boundary (where structured cloning preserves the string fields but
12
+ * not the class identity) with a single source of truth.
13
+ */
14
+ export declare class ModelFileCacheUnavailableError extends Error {
15
+ static readonly ERROR_NAME = "ModelFileCacheUnavailableError";
16
+ readonly name = "ModelFileCacheUnavailableError";
17
+ }
18
+ //# sourceMappingURL=ModelFileCacheUnavailableError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelFileCacheUnavailableError.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCacheUnavailableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAC,QAAQ,CAAC,UAAU,oCAAoC;IAC9D,QAAQ,CAAC,IAAI,oCAA6C;CAC3D"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Raised when the runtime exposes no place to keep model files, so
3
+ * every run has to download them again.
4
+ *
5
+ * The Cache Storage API is restricted to secure contexts and withheld
6
+ * altogether by some privacy modes, so a page served over plain HTTP
7
+ * from anything other than localhost has nowhere to put them.
8
+ *
9
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
10
+ * the class, so consumers can recognise the failure across a Worker
11
+ * boundary (where structured cloning preserves the string fields but
12
+ * not the class identity) with a single source of truth.
13
+ */
14
+ export class ModelFileCacheUnavailableError extends Error {
15
+ static ERROR_NAME = 'ModelFileCacheUnavailableError';
16
+ name = ModelFileCacheUnavailableError.ERROR_NAME;
17
+ }
18
+ //# sourceMappingURL=ModelFileCacheUnavailableError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelFileCacheUnavailableError.js","sourceRoot":"","sources":["../../../src/modules/transcription/ModelFileCacheUnavailableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAU,UAAU,GAAG,gCAAgC,CAAC;IACrD,IAAI,GAAG,8BAA8B,CAAC,UAAU,CAAC"}
@@ -1,33 +1,42 @@
1
- import { Document } from '../document/Document';
1
+ import type { Document } from '../document/Document';
2
2
  import type { Transcriber, TranscriberOptions, TranscriberProgressEvent } from '../transcription/Transcriber';
3
3
  /**
4
4
  * Builds a Document by parsing a SubRip (SRT) caption file. Each cue
5
5
  * becomes one `Segment` carrying the cue's full time range; the cue's
6
6
  * text (multi-line entries joined with a space, formatting tags
7
- * stripped) becomes one `Line` whose `Word` timings are spread across
8
- * the cue range proportionally to character length, so each word
9
- * lights up in sequence rather than all at once.
7
+ * stripped) becomes one `Line`.
8
+ *
9
+ * SubRip times nothing below a cue, so word timings are shared out
10
+ * across the cue in proportion to how long each word is to write. Each
11
+ * word lights up in sequence rather than all at once, but where one
12
+ * begins is a guess, not something the file said.
10
13
  *
11
14
  * The audio Blob passed to `transcribe` is ignored. Useful when the
12
15
  * caption text and timing are already known — burning a hand-authored
13
16
  * SRT into a video, replaying captions from a previous run, etc.
14
17
  *
15
- * Throws when a timecode is malformed; returns an empty Document when
16
- * the source contains 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.
17
28
  */
18
29
  export declare class SrtTranscriber implements Transcriber {
19
30
  private readonly source;
20
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 documentBuilder;
38
+ private readonly wordReader;
21
39
  constructor(source: string);
22
40
  transcribe(_audio: Blob, _options?: TranscriberOptions): Promise<Document>;
23
- private buildDocumentFromSource;
24
- private parseCues;
25
- private parseCueBlock;
26
- private findTimecodeLineIndex;
27
- private parseTimecodeLine;
28
- private toSeconds;
29
- private normalizeCueText;
30
- private buildSegmentFromCue;
31
- private distributeWordsAcrossCueRange;
32
41
  }
33
42
  //# sourceMappingURL=SrtTranscriber.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SrtTranscriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/SrtTranscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AA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E,MAAM;IAErC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAMjF"}
@@ -1,111 +1,53 @@
1
- import { Document } from '../document/Document';
2
- import { Section } from '../document/Section';
3
- import { Segment } from '../document/Segment';
4
- import { Line } from '../document/Line';
5
- import { Word } from '../document/Word';
6
- import { TimeFragment } from '../document/TimeFragment';
7
- const SRT_TIMECODE_RE = /^(\d{1,2}):(\d{2}):(\d{2})[,.](\d{1,3})\s*-->\s*(\d{1,2}):(\d{2}):(\d{2})[,.](\d{1,3})/;
8
- const FORMATTING_TAG_RE = /<[^>]+>|\{[^}]+\}/g;
9
- const BOM_RE = /^\uFEFF/;
1
+ import { CueDocumentBuilder } from '../transcription/CueDocumentBuilder';
2
+ import { CueTextTokenizer } from '../transcription/CueTextTokenizer';
3
+ import { CueTimecodeReader } from '../transcription/CueTimecodeReader';
4
+ import { EstimatedCueWordReader } from '../transcription/EstimatedCueWordReader';
5
+ import { WordTimingEstimator } from '../transcription/WordTimingEstimator';
10
6
  /**
11
7
  * Builds a Document by parsing a SubRip (SRT) caption file. Each cue
12
8
  * becomes one `Segment` carrying the cue's full time range; the cue's
13
9
  * text (multi-line entries joined with a space, formatting tags
14
- * stripped) becomes one `Line` whose `Word` timings are spread across
15
- * the cue range proportionally to character length, so each word
16
- * lights up in sequence rather than all at once.
10
+ * stripped) becomes one `Line`.
11
+ *
12
+ * SubRip times nothing below a cue, so word timings are shared out
13
+ * across the cue in proportion to how long each word is to write. Each
14
+ * word lights up in sequence rather than all at once, but where one
15
+ * begins is a guess, not something the file said.
17
16
  *
18
17
  * The audio Blob passed to `transcribe` is ignored. Useful when the
19
18
  * caption text and timing are already known — burning a hand-authored
20
19
  * SRT into a video, replaying captions from a previous run, etc.
21
20
  *
22
- * Throws when a timecode is malformed; returns an empty Document when
23
- * the source contains no parseable cues.
21
+ * A block that carries no timecode is skipped and announced through
22
+ * `onSkippedCueBlock`, so a single broken cue costs its own text and
23
+ * nothing else. Throws only when the file has blocks and none of them
24
+ * could be read, or when a timecode itself is malformed.
25
+ *
26
+ * Builds its own collaborators rather than receiving them. The
27
+ * constructor is the surface a consumer of the engine reaches for, and
28
+ * it asks for a source and nothing else, so this class is where the
29
+ * parsing side is assembled rather than a participant in someone
30
+ * else's assembly.
24
31
  */
25
32
  export class SrtTranscriber {
26
33
  source;
27
34
  onProgress;
35
+ /**
36
+ * Fired once per block left out of the document, before
37
+ * `transcribe` resolves, carrying the block verbatim.
38
+ */
39
+ onSkippedCueBlock;
40
+ documentBuilder = new CueDocumentBuilder(new CueTimecodeReader());
41
+ wordReader = new EstimatedCueWordReader(new CueTextTokenizer(), new WordTimingEstimator());
28
42
  constructor(source) {
29
43
  this.source = source;
30
44
  }
31
45
  async transcribe(_audio, _options) {
32
46
  this.onProgress?.({ stage: 'inferring', progress: 1 });
33
- return this.buildDocumentFromSource(this.source);
34
- }
35
- buildDocumentFromSource(source) {
36
- const segments = this.parseCues(source).map((cue) => this.buildSegmentFromCue(cue));
37
- const section = new Section({ segments, kind: '' });
38
- return new Document({ sections: [section] });
39
- }
40
- parseCues(source) {
41
- const normalized = source.replace(BOM_RE, '').replace(/\r\n?/g, '\n').trim();
42
- if (normalized.length === 0)
43
- return [];
44
- return normalized
45
- .split(/\n{2,}/)
46
- .map((block) => this.parseCueBlock(block))
47
- .filter((cue) => cue !== null);
48
- }
49
- parseCueBlock(block) {
50
- const lines = block.split('\n').map((l) => l.trim()).filter((l) => l.length > 0);
51
- if (lines.length === 0)
52
- return null;
53
- const timecodeLineIndex = this.findTimecodeLineIndex(lines);
54
- if (timecodeLineIndex === -1) {
55
- throw new Error(`SRT block has no timecode line: ${JSON.stringify(block)}`);
56
- }
57
- const range = this.parseTimecodeLine(lines[timecodeLineIndex]);
58
- const text = this.normalizeCueText(lines.slice(timecodeLineIndex + 1));
59
- if (text.length === 0)
60
- return null;
61
- return { startSeconds: range.startSeconds, endSeconds: range.endSeconds, text };
62
- }
63
- findTimecodeLineIndex(lines) {
64
- return lines.findIndex((line) => SRT_TIMECODE_RE.test(line));
65
- }
66
- parseTimecodeLine(line) {
67
- const match = SRT_TIMECODE_RE.exec(line);
68
- if (match === null)
69
- throw new Error(`Malformed SRT timecode: ${JSON.stringify(line)}`);
70
- const startSeconds = this.toSeconds(match[1], match[2], match[3], match[4]);
71
- const endSeconds = this.toSeconds(match[5], match[6], match[7], match[8]);
72
- if (endSeconds < startSeconds) {
73
- throw new Error(`SRT timecode ends before it starts: ${JSON.stringify(line)}`);
74
- }
75
- return { startSeconds, endSeconds };
76
- }
77
- toSeconds(hours, minutes, seconds, milliseconds) {
78
- return (Number(hours) * 3600 +
79
- Number(minutes) * 60 +
80
- Number(seconds) +
81
- Number(milliseconds.padEnd(3, '0')) / 1000);
82
- }
83
- normalizeCueText(textLines) {
84
- return textLines.join(' ').replace(FORMATTING_TAG_RE, '').replace(/\s+/g, ' ').trim();
85
- }
86
- buildSegmentFromCue(cue) {
87
- const tokens = cue.text.split(/\s+/).filter((token) => token.length > 0);
88
- if (tokens.length === 0) {
89
- return new Segment({ lines: [new Line({ words: [] })] });
90
- }
91
- const words = this.distributeWordsAcrossCueRange(tokens, cue.startSeconds, cue.endSeconds);
92
- return new Segment({ lines: [new Line({ words })] });
93
- }
94
- distributeWordsAcrossCueRange(tokens, startSeconds, endSeconds) {
95
- const totalWeight = tokens.reduce((sum, token) => sum + token.length, 0);
96
- const cueDuration = endSeconds - startSeconds;
97
- if (totalWeight === 0 || cueDuration <= 0) {
98
- return tokens.map((token) => new Word({ text: token, time: new TimeFragment(startSeconds, endSeconds) }));
99
- }
100
- const words = [];
101
- let elapsedWeight = 0;
102
- for (const token of tokens) {
103
- const wordStart = startSeconds + (elapsedWeight / totalWeight) * cueDuration;
104
- elapsedWeight += token.length;
105
- const wordEnd = startSeconds + (elapsedWeight / totalWeight) * cueDuration;
106
- words.push(new Word({ text: token, time: new TimeFragment(wordStart, wordEnd) }));
107
- }
108
- return words;
47
+ const result = this.documentBuilder.build(this.source, this.wordReader);
48
+ for (const block of result.skippedBlocks)
49
+ this.onSkippedCueBlock?.(block);
50
+ return result.document;
109
51
  }
110
52
  }
111
53
  //# sourceMappingURL=SrtTranscriber.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SrtTranscriber.js","sourceRoot":"","sources":["../../../src/modules/transcription/SrtTranscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAO9D,MAAM,eAAe,GACnB,wFAAwF,CAAC;AAC3F,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,MAAM,MAAM,GAAG,SAAS,CAAC;AAQzB;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAc;IAGI;IAF7B,UAAU,CAA6C;IAEvD,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,KAAK,CAAC,UAAU,CAAC,MAAY,EAAE,QAA6B;QAC1D,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAEO,uBAAuB,CAAC,MAAc;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CA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CAAyC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAOjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,cAAc;IAeI;IAd7B,UAAU,CAA6C;IAEvD;;;OAGG;IACH,iBAAiB,CAA2B;IAE3B,eAAe,GAAG,IAAI,kBAAkB,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;IAClE,UAAU,GAAG,IAAI,sBAAsB,CACtD,IAAI,gBAAgB,EAAE,EACtB,IAAI,mBAAmB,EAAE,CAC1B,CAAC;IAEF,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,KAAK,CAAC,UAAU,CAAC,MAAY,EAAE,QAA6B;QAC1D,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACxE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,aAAa;YAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Raised when a caption file yielded no cues at all and at least one
3
+ * of its blocks was unreadable.
4
+ *
5
+ * Skipping the odd broken block leaves a usable file behind; skipping
6
+ * every block does not, and handing back an empty transcript would
7
+ * read as "this file said nothing" rather than "this file could not
8
+ * be understood".
9
+ *
10
+ * A file that is genuinely empty is not this: it yields an empty
11
+ * document, because there is nothing to misread.
12
+ *
13
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
14
+ * the class, so consumers can recognise the failure across a Worker
15
+ * boundary (where structured cloning preserves the string fields but
16
+ * not the class identity) with a single source of truth.
17
+ */
18
+ export declare class SubtitleFileUnreadableError extends Error {
19
+ static readonly ERROR_NAME = "SubtitleFileUnreadableError";
20
+ readonly name = "SubtitleFileUnreadableError";
21
+ }
22
+ //# sourceMappingURL=SubtitleFileUnreadableError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubtitleFileUnreadableError.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/SubtitleFileUnreadableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAC,QAAQ,CAAC,UAAU,iCAAiC;IAC3D,QAAQ,CAAC,IAAI,iCAA0C;CACxD"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Raised when a caption file yielded no cues at all and at least one
3
+ * of its blocks was unreadable.
4
+ *
5
+ * Skipping the odd broken block leaves a usable file behind; skipping
6
+ * every block does not, and handing back an empty transcript would
7
+ * read as "this file said nothing" rather than "this file could not
8
+ * be understood".
9
+ *
10
+ * A file that is genuinely empty is not this: it yields an empty
11
+ * document, because there is nothing to misread.
12
+ *
13
+ * The `.name` string is set explicitly, and exposed as `ERROR_NAME` on
14
+ * the class, so consumers can recognise the failure across a Worker
15
+ * boundary (where structured cloning preserves the string fields but
16
+ * not the class identity) with a single source of truth.
17
+ */
18
+ export class SubtitleFileUnreadableError extends Error {
19
+ static ERROR_NAME = 'SubtitleFileUnreadableError';
20
+ name = SubtitleFileUnreadableError.ERROR_NAME;
21
+ }
22
+ //# sourceMappingURL=SubtitleFileUnreadableError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubtitleFileUnreadableError.js","sourceRoot":"","sources":["../../../src/modules/transcription/SubtitleFileUnreadableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAU,UAAU,GAAG,6BAA6B,CAAC;IAClD,IAAI,GAAG,2BAA2B,CAAC,UAAU,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Word } from '../document/Word';
2
+ import type { CueTextTokenizer } from '../transcription/CueTextTokenizer';
3
+ import type { CueTimecodeReader } from '../transcription/CueTimecodeReader';
4
+ import type { CueWordReader } from '../transcription/CueWordReader';
5
+ import type { WordTimingEstimator } from '../transcription/WordTimingEstimator';
6
+ /**
7
+ * Reads a cue from a format that can mark, inside the cue's own text,
8
+ * when a word is spoken — WebVTT does this so a caption can be revealed
9
+ * word by word without being broken into an entry per word.
10
+ *
11
+ * Each mark cuts the cue into a stretch that runs until the next mark,
12
+ * and the words of a stretch share it out between them. A mark before
13
+ * every word therefore yields the timing the file recorded; a mark
14
+ * every few words yields those, with the words between them estimated.
15
+ * A cue carrying no marks at all is one stretch, which is the same
16
+ * answer a format without marks would give.
17
+ */
18
+ export declare class TimestampedCueWordReader implements CueWordReader {
19
+ private readonly tokenizer;
20
+ private readonly timecodeReader;
21
+ private readonly estimator;
22
+ constructor(tokenizer: CueTextTokenizer, timecodeReader: CueTimecodeReader, estimator: WordTimingEstimator);
23
+ read(text: string, startSeconds: number, endSeconds: number): ReadonlyArray<Word>;
24
+ private cutIntoStretches;
25
+ private positionOf;
26
+ }
27
+ //# sourceMappingURL=TimestampedCueWordReader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimestampedCueWordReader.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/TimestampedCueWordReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAYtF;;;;;;;;;;;GAWG;AACH,qBAAa,wBAAyB,YAAW,aAAa;IAE1D,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAFT,SAAS,EAAE,gBAAgB,EAC3B,cAAc,EAAE,iBAAiB,EACjC,SAAS,EAAE,mBAAmB;IAGjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;IAWjF,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,UAAU;CAGnB"}
@@ -0,0 +1,52 @@
1
+ /** A cue timestamp: a position on its own inside the cue's text. */
2
+ const CUE_TIMESTAMP = /<(?:\d{1,3}:)?\d{2}:\d{2}[.,]\d{1,3}>/g;
3
+ /**
4
+ * Reads a cue from a format that can mark, inside the cue's own text,
5
+ * when a word is spoken — WebVTT does this so a caption can be revealed
6
+ * word by word without being broken into an entry per word.
7
+ *
8
+ * Each mark cuts the cue into a stretch that runs until the next mark,
9
+ * and the words of a stretch share it out between them. A mark before
10
+ * every word therefore yields the timing the file recorded; a mark
11
+ * every few words yields those, with the words between them estimated.
12
+ * A cue carrying no marks at all is one stretch, which is the same
13
+ * answer a format without marks would give.
14
+ */
15
+ export class TimestampedCueWordReader {
16
+ tokenizer;
17
+ timecodeReader;
18
+ estimator;
19
+ constructor(tokenizer, timecodeReader, estimator) {
20
+ this.tokenizer = tokenizer;
21
+ this.timecodeReader = timecodeReader;
22
+ this.estimator = estimator;
23
+ }
24
+ read(text, startSeconds, endSeconds) {
25
+ return this.cutIntoStretches(text, startSeconds, endSeconds)
26
+ .flatMap((stretch) => [
27
+ ...this.estimator.spread(this.tokenizer.tokenize(stretch.text), stretch.startSeconds, stretch.endSeconds),
28
+ ]);
29
+ }
30
+ cutIntoStretches(text, startSeconds, endSeconds) {
31
+ const stretches = [];
32
+ let textFrom = 0;
33
+ let stretchStart = startSeconds;
34
+ for (const mark of text.matchAll(CUE_TIMESTAMP)) {
35
+ const markAt = this.positionOf(mark[0]);
36
+ const markFrom = mark.index ?? 0;
37
+ stretches.push({
38
+ text: text.slice(textFrom, markFrom),
39
+ startSeconds: stretchStart,
40
+ endSeconds: markAt,
41
+ });
42
+ textFrom = markFrom + mark[0].length;
43
+ stretchStart = markAt;
44
+ }
45
+ stretches.push({ text: text.slice(textFrom), startSeconds: stretchStart, endSeconds });
46
+ return stretches;
47
+ }
48
+ positionOf(mark) {
49
+ return this.timecodeReader.readPosition(mark.slice(1, -1));
50
+ }
51
+ }
52
+ //# sourceMappingURL=TimestampedCueWordReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimestampedCueWordReader.js","sourceRoot":"","sources":["../../../src/modules/transcription/TimestampedCueWordReader.ts"],"names":[],"mappings":"AAMA,oEAAoE;AACpE,MAAM,aAAa,GAAG,wCAAwC,CAAC;AAS/D;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,wBAAwB;IAEhB;IACA;IACA;IAHnB,YACmB,SAA2B,EAC3B,cAAiC,EACjC,SAA8B;QAF9B,cAAS,GAAT,SAAS,CAAkB;QAC3B,mBAAc,GAAd,cAAc,CAAmB;QACjC,cAAS,GAAT,SAAS,CAAqB;IAC9C,CAAC;IAEJ,IAAI,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAkB;QACzD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC;aACzD,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACpB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CACtB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EACrC,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,UAAU,CACnB;SACF,CAAC,CAAC;IACP,CAAC;IAEO,gBAAgB,CACtB,IAAY,EACZ,YAAoB,EACpB,UAAkB;QAElB,MAAM,SAAS,GAAmB,EAAE,CAAC;QACrC,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,YAAY,GAAG,YAAY,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;YACjC,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBACpC,YAAY,EAAE,YAAY;gBAC1B,UAAU,EAAE,MAAM;aACnB,CAAC,CAAC;YACH,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACrC,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;QACvF,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -16,8 +16,21 @@ export type TranscriberProgressEvent = {
16
16
  stage: 'inferring';
17
17
  progress?: number;
18
18
  };
19
+ /**
20
+ * An audio region, in absolute seconds, that transcription deliberately
21
+ * left empty because decoding produced no trustworthy output for it.
22
+ */
23
+ export interface UntranscribedRegion {
24
+ startSeconds: number;
25
+ endSeconds: number;
26
+ }
19
27
  export interface Transcriber {
20
28
  onProgress?: (event: TranscriberProgressEvent) => void;
29
+ /**
30
+ * Fired at most once per region, before `transcribe` resolves.
31
+ * Implementations that always cover the full audio never fire it.
32
+ */
33
+ onUntranscribedRegion?: (region: UntranscribedRegion) => void;
21
34
  transcribe(audio: Blob, options?: TranscriberOptions): Promise<Document>;
22
35
  }
23
36
  //# sourceMappingURL=Transcriber.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Transcriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/Transcriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACvD,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1E"}
1
+ {"version":3,"file":"Transcriber.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/Transcriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACvD;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC9D,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC1E"}
@@ -0,0 +1,50 @@
1
+ import type * as Transformers from '@huggingface/transformers';
2
+ import type { ModelFileCache } from '../transcription/ModelFileCache';
3
+ /**
4
+ * The inference library, loaded on first use and configured once.
5
+ *
6
+ * It is reached through a dynamic import because a static one makes the
7
+ * whole ONNX runtime a dependency of merely *naming* a transcriber: the
8
+ * package's entry point re-exports this module, so a consumer that
9
+ * imports a document node pulls the runtime with it. In a browser that
10
+ * is a large bundle nobody asked for; in Node it is a native binding
11
+ * loaded — and on musl, failed — for code that never runs inference.
12
+ *
13
+ * The environment settings live here rather than at the call site
14
+ * because they have to be applied before the first pipeline is built and
15
+ * exactly once. Holding the module and the settings together is what
16
+ * makes "loaded" and "configured" the same event.
17
+ *
18
+ * A failed load is not cached: the import can fail on a dead network the
19
+ * same way the weights can, and a caller retrying deserves to reach the
20
+ * network again.
21
+ */
22
+ export declare class TransformersRuntime {
23
+ private readonly modelFileCache?;
24
+ private modulePromise;
25
+ constructor(modelFileCache?: ModelFileCache | undefined);
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(): Promise<typeof Transformers>;
31
+ private configure;
32
+ /**
33
+ * Takes over where the downloaded model files are kept.
34
+ *
35
+ * Left to itself the library picks a store from the environment and
36
+ * discards a refused write with nothing but a console warning, so a
37
+ * caller that wants to know when the files did not survive the run
38
+ * has to own the store. Without one, that default stands.
39
+ */
40
+ private installModelFileCache;
41
+ /**
42
+ * Raises the WASM thread count above ORT's built-in ceiling when the
43
+ * runtime supports it. ORT locks the count to 1 without cross-origin
44
+ * isolation, and even with isolation its own default caps at 4 no matter
45
+ * the machine — Whisper's encoder scales past that. On a WebGPU run this
46
+ * has no effect; the WASM backend is not touched.
47
+ */
48
+ private configureWasmThreading;
49
+ }
50
+ //# sourceMappingURL=TransformersRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformersRuntime.d.ts","sourceRoot":"","sources":["../../../src/modules/transcription/TransformersRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAmB;IAGlB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAF5C,OAAO,CAAC,aAAa,CAA6C;gBAErC,cAAc,CAAC,EAAE,cAAc,YAAA;IAE5D;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,OAAO,YAAY,CAAC;IAcpC,OAAO,CAAC,SAAS;IAMjB;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;CAM/B"}