@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
package/README.md CHANGED
@@ -4,6 +4,8 @@ A TypeScript engine that adds captions to a video and burns them in — all in t
4
4
 
5
5
  Captions are HTML elements styled with CSS. On export, the engine rasterizes that DOM at each frame's timestamp into a bitmap and composites it with the video frame. The browser renders the captions.
6
6
 
7
+ **See it running:** [tscaps.io/local](https://tscaps.io/local) is a full caption editor built on this engine, transcription and export included, running entirely in the browser with no account and no upload. It is the fastest way to see what the engine does before writing any code against it.
8
+
7
9
  ## Install
8
10
 
9
11
  ```bash
@@ -254,17 +256,19 @@ Document
254
256
 
255
257
  The pipeline restructures the same `Word`s into different `Segment`s and `Line`s through `SegmentSplitter` and `LineSplitter`; the underlying word data (`text`, `time`, `tags`) does not change.
256
258
 
257
- The render layer exposes that document to CSS through three surfaces: a flat set of CSS classes per element, a flat set of CSS custom properties per element, and a tag system that adds more classes via taggers. Everything the examples above target — `.word`, `.word-being-narrated`, `--on-segment-starts`, `var(--on-line-being-narrated-starts)` — comes from these surfaces.
259
+ The render layer exposes that document to CSS through four surfaces: a flat set of CSS classes per element, a flat set of CSS custom properties per element, a tag system that adds more classes via taggers, and an opt-in `data-tscaps-el` attribute for reaching one element by id. Everything the examples above target — `.word`, `.word-being-narrated`, `--on-segment-starts`, `var(--on-line-being-narrated-starts)` — comes from these surfaces.
260
+
261
+ `Section` never renders as an element: it is the grouping that decides which splitter and tagger chain a run of segments goes through, and the rendered subtree starts at `.segment`.
258
262
 
259
263
  ### CSS classes the engine emits
260
264
 
261
265
  Every rendered element carries its element class:
262
266
 
263
- - `.section` — the root of the active Section
264
- - `.segment` — a caption block
267
+ - `.segment` — a caption block, the root of the rendered subtree
265
268
  - `.line` — a visible line within a segment
266
269
  - `.word` — a single word within a line
267
270
  - `.letter` — a single letter within a word, emitted only when `rendering.splitWordsIntoLetters` is `true`
271
+ - `.word-decoration` — a decoration attached to a word (an emoji, for instance)
268
272
 
269
273
  State classes — computed per frame from the current playback time and attached to the matching `.word` / `.line`:
270
274
 
@@ -279,17 +283,36 @@ Positional tags from `StructureTagger`, assigned once after splitting:
279
283
  - `first-line-in-segment`, `last-line-in-segment`
280
284
  - `first-line-in-section`, `last-line-in-section`
281
285
  - `first-segment-in-section`, `last-segment-in-section`
282
- - `first-section-in-document`, `last-section-in-document`
286
+ - `first-segment-in-document`, `last-segment-in-document`
287
+
288
+ Classes on elements the renderer creates rather than on document nodes, collected in the `CssClass` enum:
289
+
290
+ - `behind-actor-active` — on `.segment` while the text-behind-actor effect is active for it
291
+ - `tscaps-video-frame-layer` — the layer holding the video frame, emitted inside `.segment` when `rendering.videoFrame.required` is set
292
+ - `segment-decorations-above`, `segment-decorations-below` — the containers of decorations lifted out of line flow
283
293
 
284
294
  Semantic tag classes come from `Tagger` implementations you add to the pipeline (see *Tags and taggers* below) and are entirely consumer-defined.
285
295
 
296
+ ### Addressing one element
297
+
298
+ A class reaches every element of its kind. To reach a single one, name its id in `SubtitleStyle.addressableElementIds` and the renderer stamps `data-tscaps-el="<id>"` (`DataAttribute.ELEMENT_ID`) on it:
299
+
300
+ ```ts
301
+ .withSubtitleStyles({ default: { ...style, addressableElementIds: new Set([word.id]) } })
302
+ ```
303
+
304
+ ```css
305
+ [data-tscaps-el="<id>"] { color: #ff5c8a; }
306
+ ```
307
+
308
+ Any element id qualifies — segment, line, word or decoration. A word the bidirectional algorithm paints in two places gets the attribute on both pieces. The attribute is serialized once per element per rendered tile, so a caption with every word addressed grows the batch by a double-digit percentage; address nothing and it costs nothing.
309
+
286
310
  ### CSS custom properties
287
311
 
288
312
  Each rendered element exposes timing values relative to the current frame, so you can drive `animation-delay`, `animation-duration`, or any other CSS value from the narration timeline. `--on-…-starts` and `--on-…-ends` are seconds until the event; they go negative once the event is in the past. `--…-duration` is a span.
289
313
 
290
- Element-level timing:
314
+ Segment-level timing:
291
315
 
292
- - `--on-section-starts`, `--on-section-ends`, `--section-duration`
293
316
  - `--on-segment-starts`, `--on-segment-ends`, `--segment-duration`
294
317
 
295
318
  Per-state timing, for both `.line` and `.word` (substitute `<elem>` with `line` or `word`):
@@ -302,10 +325,24 @@ Letter-level, when splitting into letters:
302
325
 
303
326
  - `--letter-index`, `--letter-count`
304
327
 
328
+ Structural metadata — unitless integers, so a rule can stagger, scale or branch by an element's position and size without randomness. No `on-` prefix, because they are not events:
329
+
330
+ - `--segment-index` — the segment's 0-based position within its section
331
+ - `--segment-char-count` — character length of the segment's full text, the input for auto-shrink rules
332
+ - `--word-index` — the word's 0-based position within its line
333
+ - `--word-count` — on `.segment` and on `.line`; the nearest ancestor wins for a `.word` reading it
334
+ - `--word-char-count` — code-point length of the word's display text
335
+ - `--last-word-char-count` — on `.segment` and on `.line`; the length of the closing word, without traversing to it
336
+
305
337
  Layout and frame:
306
338
 
307
339
  - `--subtitle-region-width`, `--subtitle-region-height`, `--subtitle-region-x`, `--subtitle-region-y` — the caption region's box, useful when positioning relative to the video frame
308
340
  - `--video-frame` — the underlying video frame as `url("data:image/jpeg;base64,…")`, only set when `rendering.videoFrame.required` is `true` (see [docs/RENDERING_INTERNALS.md](docs/RENDERING_INTERNALS.md))
341
+ - `--segment-padding-top`, `--segment-padding-bottom` — the padding the renderer put on the segment to give a filter room to spread
342
+
343
+ Read by the engine's own baseline rules, so a stylesheet writes them rather than reading them:
344
+
345
+ - `--decoration-font-size-multiplier`, `--decoration-gap-multiplier` — how large a decoration renders next to its word, and how far from it
309
346
 
310
347
  ### Tags and taggers
311
348
 
@@ -321,7 +358,10 @@ Tags map one-to-one onto CSS classes through `Tag.toCssClass()`. Unknown tag cla
321
358
 
322
359
  The examples above cover the common cases. The pipeline exposes more knobs you'll reach for as your needs grow:
323
360
 
324
- - **Built-in transcribers**: `WhisperTranscriber` (the default, in-browser Whisper), `SrtTranscriber` (parses SubRip), `PassthroughTranscriber` (wraps a pre-built `Document`). Or implement your own by satisfying the `Transcriber` interface.
361
+ - **Built-in transcribers**: `WhisperTranscriber` (the default, in-browser Whisper, with a `tiny` / `base` / `small` / `medium` model ladder), `SrtTranscriber` and `VttTranscriber` (parse SubRip and WebVTT, reading per-word timings where the file carries them), `PassthroughTranscriber` (wraps a pre-built `Document`). Or implement your own by satisfying the `Transcriber` interface.
362
+ - **Writing subtitle files**: `SubtitleFileSerializer` is the inverse of the parsers. `SrtSubtitleFileSerializer`, `VttSubtitleFileSerializer`, `AssSubtitleFileSerializer`, `SbvSubtitleFileSerializer`, `TtmlSubtitleFileSerializer` and `TextSubtitleFileSerializer` each declare their own media type and extension, and `granularity: 'word'` asks for per-word timing where the format can express it.
363
+ - **Right-to-left and mixed-script text**: each line is resolved through the Unicode bidirectional algorithm and its words are emitted in painting order. `RenderingConfig.textDirection` supplies the paragraph direction, `TextDirectionDetector` infers it from a text, and `AlignmentConfig.horizontalAlign` additionally accepts `start` / `end` so one declaration can follow the reading direction.
364
+ - **Cuts**: time ranges declared on a `Document` are removed from the exported video, and captions realign to the shortened timeline.
325
365
  - **Segment splitters**: the default `CompositeSegmentSplitter` chains a sentence-boundary cut with a scaled-character budget. Individual strategies are exposed for custom chains — `BoundarySegmentSplitter`, `LimitByWordsSegmentSplitter`, `LimitByScaledCharsSegmentSplitter`, `PauseBasedSegmentSplitter`, `SpeakerChangeSegmentSplitter`.
326
366
  - **Line splitters**: `BalancedLineSplitter` (char-balanced, no measurer needed) and `BalancedPixelWidthLineSplitter` (pixel-balanced, backed by a `TextMeasurer` — `DomProbeCanvasTextMeasurer` is the default measurer).
327
367
  - **Replace any stage**: `withTranscriber`, `withSegmentSplitter`, `withLineSplitter`, `withVideoRenderer`, `withSubtitleFrameRenderer`, `withOverlayFrameRenderer`. Defaults stay in place until explicitly replaced.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export * from './modules/document/index';
2
2
  export * from './modules/transcription/index';
3
+ export * from './modules/subtitle-file/index';
3
4
  export * from './modules/video/index';
4
5
  export * from './modules/rendering/index';
5
6
  export * from './modules/css/index';
6
7
  export * from './modules/svg-filter/index';
7
8
  export * from './modules/splitting/index';
9
+ export * from './modules/bidi/index';
8
10
  export * from './modules/tagging/index';
11
+ export * from './modules/tags/index';
9
12
  export * from './modules/effect/index';
10
13
  export * from './modules/profiling/index';
11
14
  export * from './modules/pipeline/index';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,14 @@
1
1
  export * from './modules/document/index';
2
2
  export * from './modules/transcription/index';
3
+ export * from './modules/subtitle-file/index';
3
4
  export * from './modules/video/index';
4
5
  export * from './modules/rendering/index';
5
6
  export * from './modules/css/index';
6
7
  export * from './modules/svg-filter/index';
7
8
  export * from './modules/splitting/index';
9
+ export * from './modules/bidi/index';
8
10
  export * from './modules/tagging/index';
11
+ export * from './modules/tags/index';
9
12
  export * from './modules/effect/index';
10
13
  export * from './modules/profiling/index';
11
14
  export * from './modules/pipeline/index';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { TextDirection } from '../bidi/TextDirection';
2
+ /**
3
+ * Outcome of the Unicode bidirectional algorithm over one stretch of
4
+ * text. Both arrays are indexed by UTF-16 unit and have the same length
5
+ * as the analyzed string.
6
+ */
7
+ export interface BidiAnalysis {
8
+ /** Resolved embedding level of each unit, in source order. */
9
+ readonly levels: ReadonlyArray<number>;
10
+ /** Source index of each unit, ordered as the text paints from left to right. */
11
+ readonly visualOrder: ReadonlyArray<number>;
12
+ }
13
+ /**
14
+ * Resolves the Unicode bidirectional algorithm (UAX #9) for a text.
15
+ *
16
+ * `baseDirection` is required rather than inferred from the text: the
17
+ * standard's own fallback picks the direction of the first strong
18
+ * character, which misreads a sentence opening with a foreign name.
19
+ */
20
+ export interface BidiAnalyzer {
21
+ analyze(text: string, baseDirection: TextDirection): BidiAnalysis;
22
+ }
23
+ //# sourceMappingURL=BidiAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/BidiAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,YAAY,CAAC;CACnE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BidiAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiAnalyzer.js","sourceRoot":"","sources":["../../../src/modules/bidi/BidiAnalyzer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import type { TextDirection } from '../bidi/TextDirection';
2
+ /**
3
+ * Reads the direction Unicode assigns to a single character.
4
+ *
5
+ * Most characters carry none of their own: digits, punctuation, spaces
6
+ * and symbols take their direction from whatever surrounds them, and
7
+ * only letters of a directional script speak for themselves.
8
+ */
9
+ export interface BidiCharacterClassifier {
10
+ /** The character's own direction, or `null` when it takes one from its context. */
11
+ strongDirectionOf(character: string): TextDirection | null;
12
+ }
13
+ //# sourceMappingURL=BidiCharacterClassifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiCharacterClassifier.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/BidiCharacterClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,mFAAmF;IACnF,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAAC;CAC5D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BidiCharacterClassifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiCharacterClassifier.js","sourceRoot":"","sources":["../../../src/modules/bidi/BidiCharacterClassifier.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { BidiAnalysis, BidiAnalyzer } from '../bidi/BidiAnalyzer';
2
+ import type { TextDirection } from '../bidi/TextDirection';
3
+ /**
4
+ * Bidi resolution backed by a standalone implementation of UAX #9.
5
+ *
6
+ * Resolves from the characters alone and never touches the DOM, so the
7
+ * same text yields the same layout in a browser, a worker, or a build
8
+ * step.
9
+ */
10
+ export declare class BidiJsAnalyzer implements BidiAnalyzer {
11
+ private readonly bidi;
12
+ analyze(text: string, baseDirection: TextDirection): BidiAnalysis;
13
+ }
14
+ //# sourceMappingURL=BidiJsAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiJsAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/BidiJsAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;;GAMG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAE5C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,YAAY;CAOlE"}
@@ -0,0 +1,19 @@
1
+ import bidiFactory from 'bidi-js';
2
+ /**
3
+ * Bidi resolution backed by a standalone implementation of UAX #9.
4
+ *
5
+ * Resolves from the characters alone and never touches the DOM, so the
6
+ * same text yields the same layout in a browser, a worker, or a build
7
+ * step.
8
+ */
9
+ export class BidiJsAnalyzer {
10
+ bidi = bidiFactory();
11
+ analyze(text, baseDirection) {
12
+ const embedding = this.bidi.getEmbeddingLevels(text, baseDirection);
13
+ return {
14
+ levels: Array.from(embedding.levels),
15
+ visualOrder: this.bidi.getReorderedIndices(text, embedding),
16
+ };
17
+ }
18
+ }
19
+ //# sourceMappingURL=BidiJsAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiJsAnalyzer.js","sourceRoot":"","sources":["../../../src/modules/bidi/BidiJsAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,WAA0B,MAAM,SAAS,CAAC;AAIjD;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IACR,IAAI,GAAS,WAAW,EAAE,CAAC;IAE5C,OAAO,CAAC,IAAY,EAAE,aAA4B;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACpE,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YACpC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC;SAC5D,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { BidiCharacterClassifier } from '../bidi/BidiCharacterClassifier';
2
+ import type { TextDirection } from '../bidi/TextDirection';
3
+ /** Character classification read from the Unicode tables of a UAX #9 implementation. */
4
+ export declare class BidiJsCharacterClassifier implements BidiCharacterClassifier {
5
+ private readonly bidi;
6
+ strongDirectionOf(character: string): TextDirection | null;
7
+ }
8
+ //# sourceMappingURL=BidiJsCharacterClassifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiJsCharacterClassifier.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/BidiJsCharacterClassifier.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQjE,wFAAwF;AACxF,qBAAa,yBAA0B,YAAW,uBAAuB;IACvE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAE5C,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAM3D"}
@@ -0,0 +1,19 @@
1
+ import bidiFactory from 'bidi-js';
2
+ // The Unicode bidi classes that carry a direction of their own: `L` for
3
+ // left-to-right letters, `R` and `AL` for right-to-left ones (`AL` being the
4
+ // Arabic script specifically). Every other class is context-dependent.
5
+ const STRONG_LEFT_TO_RIGHT = 'L';
6
+ const STRONG_RIGHT_TO_LEFT = new Set(['R', 'AL']);
7
+ /** Character classification read from the Unicode tables of a UAX #9 implementation. */
8
+ export class BidiJsCharacterClassifier {
9
+ bidi = bidiFactory();
10
+ strongDirectionOf(character) {
11
+ const type = this.bidi.getBidiCharTypeName(character);
12
+ if (type === STRONG_LEFT_TO_RIGHT)
13
+ return 'ltr';
14
+ if (STRONG_RIGHT_TO_LEFT.has(type))
15
+ return 'rtl';
16
+ return null;
17
+ }
18
+ }
19
+ //# sourceMappingURL=BidiJsCharacterClassifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BidiJsCharacterClassifier.js","sourceRoot":"","sources":["../../../src/modules/bidi/BidiJsCharacterClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,WAA0B,MAAM,SAAS,CAAC;AAIjD,wEAAwE;AACxE,6EAA6E;AAC7E,uEAAuE;AACvE,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAElD,wFAAwF;AACxF,MAAM,OAAO,yBAAyB;IACnB,IAAI,GAAS,WAAW,EAAE,CAAC;IAE5C,iBAAiB,CAAC,SAAiB;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,KAAK,CAAC;QAChD,IAAI,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Tells whether a text is written in a script whose letters join up.
3
+ *
4
+ * Text like that cannot be broken into independently painted letters:
5
+ * each letter would be shaped in isolation, the connections between
6
+ * them would disappear, and the word would read as a row of unrelated
7
+ * marks.
8
+ */
9
+ export declare class CursiveScriptDetector {
10
+ isCursive(text: string): boolean;
11
+ }
12
+ //# sourceMappingURL=CursiveScriptDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CursiveScriptDetector.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/CursiveScriptDetector.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,qBAAa,qBAAqB;IAEhC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGjC"}
@@ -0,0 +1,20 @@
1
+ // Scripts whose letters connect to their neighbours, so a letter takes a
2
+ // different shape depending on what sits beside it. Listed by Unicode script
3
+ // property rather than by codepoint range, and by `Script_Extensions` so the
4
+ // letters Persian and Urdu add to the Arabic script come along. Hebrew, Thaana
5
+ // and Divehi are right-to-left but do not join, so they are absent on purpose.
6
+ const CURSIVE_SCRIPTS = /[\p{Script_Extensions=Arabic}\p{Script=Syriac}\p{Script=Mongolian}\p{Script=Nko}\p{Script=Adlam}\p{Script=Mandaic}\p{Script=Hanifi_Rohingya}]/u;
7
+ /**
8
+ * Tells whether a text is written in a script whose letters join up.
9
+ *
10
+ * Text like that cannot be broken into independently painted letters:
11
+ * each letter would be shaped in isolation, the connections between
12
+ * them would disappear, and the word would read as a row of unrelated
13
+ * marks.
14
+ */
15
+ export class CursiveScriptDetector {
16
+ isCursive(text) {
17
+ return CURSIVE_SCRIPTS.test(text);
18
+ }
19
+ }
20
+ //# sourceMappingURL=CursiveScriptDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CursiveScriptDetector.js","sourceRoot":"","sources":["../../../src/modules/bidi/CursiveScriptDetector.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,MAAM,eAAe,GACnB,gJAAgJ,CAAC;AAEnJ;;;;;;;GAOG;AACH,MAAM,OAAO,qBAAqB;IAEhC,SAAS,CAAC,IAAY;QACpB,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A side named by where reading begins and ends rather than by where it
3
+ * lands on screen. `start` is the left edge of left-to-right text and the
4
+ * right edge of right-to-left text.
5
+ */
6
+ export type ReadingSide = 'start' | 'center' | 'end';
7
+ /** A side of the screen, which stays where it is in either direction. */
8
+ export type PhysicalSide = 'left' | 'center' | 'right';
9
+ /** Every screen side, for reading one back off something that was stored. */
10
+ export declare const PHYSICAL_SIDES: ReadonlyArray<PhysicalSide>;
11
+ /**
12
+ * Either vocabulary, the way `text-align` accepts both. A layout value takes
13
+ * this type when the choice between them belongs to the author: naming a
14
+ * screen side pins the value to the frame, naming a reading side lets it
15
+ * follow the language of the text.
16
+ */
17
+ export type HorizontalSide = PhysicalSide | ReadingSide;
18
+ //# sourceMappingURL=HorizontalSide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalSide.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/HorizontalSide.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAErD,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD,6EAA6E;AAC7E,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,YAAY,CAA+B,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Every screen side, for reading one back off something that was stored. */
2
+ export const PHYSICAL_SIDES = ['left', 'center', 'right'];
3
+ //# sourceMappingURL=HorizontalSide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalSide.js","sourceRoot":"","sources":["../../../src/modules/bidi/HorizontalSide.ts"],"names":[],"mappings":"AAUA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAgC,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { HorizontalSide, PhysicalSide } from '../bidi/HorizontalSide';
2
+ import type { TextDirection } from '../bidi/TextDirection';
3
+ /**
4
+ * Resolves a horizontal side to the side of the screen it lands on under a
5
+ * given paragraph direction. A side already named in screen terms passes
6
+ * through, which is what lets a layout value accept either vocabulary.
7
+ *
8
+ * Values are resolved here rather than handed to CSS as `start` / `end`
9
+ * because CSS resolves its own flow-relative keywords against the element's
10
+ * `direction`, which the renderer pins so that words already placed in
11
+ * painting order are not placed again.
12
+ */
13
+ export declare class HorizontalSideResolver {
14
+ toPhysical(side: HorizontalSide, textDirection: TextDirection): PhysicalSide;
15
+ /**
16
+ * Restates a fraction measured from the reading start as one measured from
17
+ * the left edge, and back — the conversion is its own inverse.
18
+ */
19
+ mirrorOffset(offset: number, textDirection: TextDirection): number;
20
+ }
21
+ //# sourceMappingURL=HorizontalSideResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalSideResolver.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/HorizontalSideResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;;;;;GASG;AACH,qBAAa,sBAAsB;IACjC,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,GAAG,YAAY;IAM5E;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,MAAM;CAGnE"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Resolves a horizontal side to the side of the screen it lands on under a
3
+ * given paragraph direction. A side already named in screen terms passes
4
+ * through, which is what lets a layout value accept either vocabulary.
5
+ *
6
+ * Values are resolved here rather than handed to CSS as `start` / `end`
7
+ * because CSS resolves its own flow-relative keywords against the element's
8
+ * `direction`, which the renderer pins so that words already placed in
9
+ * painting order are not placed again.
10
+ */
11
+ export class HorizontalSideResolver {
12
+ toPhysical(side, textDirection) {
13
+ if (side === 'start')
14
+ return textDirection === 'ltr' ? 'left' : 'right';
15
+ if (side === 'end')
16
+ return textDirection === 'ltr' ? 'right' : 'left';
17
+ return side;
18
+ }
19
+ /**
20
+ * Restates a fraction measured from the reading start as one measured from
21
+ * the left edge, and back — the conversion is its own inverse.
22
+ */
23
+ mirrorOffset(offset, textDirection) {
24
+ return textDirection === 'ltr' ? offset : 1 - offset;
25
+ }
26
+ }
27
+ //# sourceMappingURL=HorizontalSideResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalSideResolver.js","sourceRoot":"","sources":["../../../src/modules/bidi/HorizontalSideResolver.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,OAAO,sBAAsB;IACjC,UAAU,CAAC,IAAoB,EAAE,aAA4B;QAC3D,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QACxE,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,MAAc,EAAE,aAA4B;QACvD,OAAO,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import type { BidiCharacterClassifier } from '../bidi/BidiCharacterClassifier';
2
+ import type { TextDirection } from '../bidi/TextDirection';
3
+ import type { TextDirectionDetector } from '../bidi/TextDirectionDetector';
4
+ /**
5
+ * Decides by counting: whichever direction more of the text's own
6
+ * directional characters carry wins, and a text with none reads left to
7
+ * right.
8
+ *
9
+ * The standard's own fallback — take the direction of the first strong
10
+ * character — is a poor fit for a long text, because a single foreign
11
+ * name at the start would speak for everything after it. Counting looks
12
+ * at the whole text instead.
13
+ *
14
+ * A tie, or a text where a minority script still dominates the meaning,
15
+ * resolves left to right. That is the conservative side: a text wrongly
16
+ * read as right-to-left rearranges every line of it, while the opposite
17
+ * mistake leaves the text in the order it was written.
18
+ */
19
+ export declare class StrongCharacterMajorityTextDirectionDetector implements TextDirectionDetector {
20
+ private readonly characterClassifier;
21
+ constructor(characterClassifier: BidiCharacterClassifier);
22
+ detect(text: string): TextDirection;
23
+ }
24
+ //# sourceMappingURL=StrongCharacterMajorityTextDirectionDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StrongCharacterMajorityTextDirectionDetector.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/StrongCharacterMajorityTextDirectionDetector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF;;;;;;;;;;;;;;GAcG;AACH,qBAAa,4CAA6C,YAAW,qBAAqB;IAE5E,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBAAnB,mBAAmB,EAAE,uBAAuB;IAEzE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;CAUpC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Decides by counting: whichever direction more of the text's own
3
+ * directional characters carry wins, and a text with none reads left to
4
+ * right.
5
+ *
6
+ * The standard's own fallback — take the direction of the first strong
7
+ * character — is a poor fit for a long text, because a single foreign
8
+ * name at the start would speak for everything after it. Counting looks
9
+ * at the whole text instead.
10
+ *
11
+ * A tie, or a text where a minority script still dominates the meaning,
12
+ * resolves left to right. That is the conservative side: a text wrongly
13
+ * read as right-to-left rearranges every line of it, while the opposite
14
+ * mistake leaves the text in the order it was written.
15
+ */
16
+ export class StrongCharacterMajorityTextDirectionDetector {
17
+ characterClassifier;
18
+ constructor(characterClassifier) {
19
+ this.characterClassifier = characterClassifier;
20
+ }
21
+ detect(text) {
22
+ let rightToLeft = 0;
23
+ let leftToRight = 0;
24
+ for (const character of text) {
25
+ const direction = this.characterClassifier.strongDirectionOf(character);
26
+ if (direction === 'rtl')
27
+ rightToLeft++;
28
+ else if (direction === 'ltr')
29
+ leftToRight++;
30
+ }
31
+ return rightToLeft > leftToRight ? 'rtl' : 'ltr';
32
+ }
33
+ }
34
+ //# sourceMappingURL=StrongCharacterMajorityTextDirectionDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StrongCharacterMajorityTextDirectionDetector.js","sourceRoot":"","sources":["../../../src/modules/bidi/StrongCharacterMajorityTextDirectionDetector.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,4CAA4C;IAE1B;IAA7B,YAA6B,mBAA4C;QAA5C,wBAAmB,GAAnB,mBAAmB,CAAyB;IAAG,CAAC;IAE7E,MAAM,CAAC,IAAY;QACjB,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YACxE,IAAI,SAAS,KAAK,KAAK;gBAAE,WAAW,EAAE,CAAC;iBAClC,IAAI,SAAS,KAAK,KAAK;gBAAE,WAAW,EAAE,CAAC;QAC9C,CAAC;QACD,OAAO,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Base direction a stretch of text is laid out against. It is the
3
+ * paragraph embedding level the Unicode bidirectional algorithm starts
4
+ * from: `ltr` is level 0, `rtl` is level 1. Every level the algorithm
5
+ * resolves is relative to it, so the same text under a different base
6
+ * paints in a different order.
7
+ */
8
+ export type TextDirection = 'ltr' | 'rtl';
9
+ //# sourceMappingURL=TextDirection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextDirection.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/TextDirection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextDirection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextDirection.js","sourceRoot":"","sources":["../../../src/modules/bidi/TextDirection.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { TextDirection } from '../bidi/TextDirection';
2
+ /**
3
+ * Infers the direction a text is meant to be read in.
4
+ *
5
+ * The answer is a starting point, not a verdict: text that mixes scripts
6
+ * is genuinely ambiguous, so consumers are expected to let the reader
7
+ * override whatever comes back.
8
+ */
9
+ export interface TextDirectionDetector {
10
+ detect(text: string): TextDirection;
11
+ }
12
+ //# sourceMappingURL=TextDirectionDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextDirectionDetector.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/TextDirectionDetector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;CACrC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextDirectionDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextDirectionDetector.js","sourceRoot":"","sources":["../../../src/modules/bidi/TextDirectionDetector.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import type { TextDirection } from '../bidi/TextDirection';
2
+ /**
3
+ * One stretch of a word that resolves to a single bidi embedding level.
4
+ *
5
+ * A word normally yields exactly one. A word that wraps neutral
6
+ * characters around a run of another script yields several, and they can
7
+ * land far apart on the line, because the algorithm places each level
8
+ * separately.
9
+ */
10
+ export interface WordFragment {
11
+ /** Position of the owning word within its line, in spoken order. */
12
+ readonly wordIndex: number;
13
+ readonly text: string;
14
+ /** Direction this fragment's own characters read in. */
15
+ readonly direction: TextDirection;
16
+ /**
17
+ * Whether the fragment painted immediately before this one ends where
18
+ * this one begins, with no word separator between them. Such a pair
19
+ * reads as one uninterrupted stretch and takes no inter-word gap.
20
+ */
21
+ readonly joinedToPrevious: boolean;
22
+ /**
23
+ * Whether this fragment's characters connect to one another, so
24
+ * painting them as separate boxes would break their shapes.
25
+ */
26
+ readonly charactersJoin: boolean;
27
+ /**
28
+ * Whether this is the last fragment of its word in paint order.
29
+ * Anything a word appends once — a decoration glyph, trailing text —
30
+ * belongs here, or a split word would show it on every piece.
31
+ */
32
+ readonly carriesWordTail: boolean;
33
+ }
34
+ //# sourceMappingURL=WordFragment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WordFragment.d.ts","sourceRoot":"","sources":["../../../src/modules/bidi/WordFragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=WordFragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WordFragment.js","sourceRoot":"","sources":["../../../src/modules/bidi/WordFragment.ts"],"names":[],"mappings":""}