@tscaps/engine 0.3.1 → 0.4.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 (251) hide show
  1. package/README.md +35 -8
  2. package/dist/modules/document/CssVariable.d.ts +6 -0
  3. package/dist/modules/document/CssVariable.d.ts.map +1 -1
  4. package/dist/modules/document/CssVariable.js +6 -0
  5. package/dist/modules/document/CssVariable.js.map +1 -1
  6. package/dist/modules/document/Document.d.ts +3 -0
  7. package/dist/modules/document/Document.d.ts.map +1 -1
  8. package/dist/modules/document/Document.js +12 -1
  9. package/dist/modules/document/Document.js.map +1 -1
  10. package/dist/modules/document/DocumentEditor.d.ts +16 -4
  11. package/dist/modules/document/DocumentEditor.d.ts.map +1 -1
  12. package/dist/modules/document/DocumentEditor.js +14 -10
  13. package/dist/modules/document/DocumentEditor.js.map +1 -1
  14. package/dist/modules/document/Line.d.ts +6 -0
  15. package/dist/modules/document/Line.d.ts.map +1 -1
  16. package/dist/modules/document/Line.js +10 -0
  17. package/dist/modules/document/Line.js.map +1 -1
  18. package/dist/modules/document/Word.d.ts +8 -0
  19. package/dist/modules/document/Word.d.ts.map +1 -1
  20. package/dist/modules/document/Word.js +11 -1
  21. package/dist/modules/document/Word.js.map +1 -1
  22. package/dist/modules/pipeline/RenderPipelineBuilder.d.ts +1 -1
  23. package/dist/modules/pipeline/RenderPipelineBuilder.d.ts.map +1 -1
  24. package/dist/modules/pipeline/RenderPipelineBuilder.js +15 -5
  25. package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -1
  26. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts +18 -8
  27. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -1
  28. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +27 -21
  29. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -1
  30. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +41 -33
  31. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -1
  32. package/dist/modules/rendering/index.d.ts +4 -0
  33. package/dist/modules/rendering/index.d.ts.map +1 -1
  34. package/dist/modules/rendering/index.js +2 -0
  35. package/dist/modules/rendering/index.js.map +1 -1
  36. package/dist/modules/rendering/subtitle/ActiveRenderSession.d.ts +13 -6
  37. package/dist/modules/rendering/subtitle/ActiveRenderSession.d.ts.map +1 -1
  38. package/dist/modules/rendering/subtitle/ActiveRenderSession.js +16 -9
  39. package/dist/modules/rendering/subtitle/ActiveRenderSession.js.map +1 -1
  40. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.d.ts +5 -2
  41. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.d.ts.map +1 -1
  42. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.js +26 -8
  43. package/dist/modules/rendering/subtitle/ActiveRenderSessionFactory.js.map +1 -1
  44. package/dist/modules/rendering/subtitle/AnimationStateFingerprint.d.ts +20 -0
  45. package/dist/modules/rendering/subtitle/AnimationStateFingerprint.d.ts.map +1 -0
  46. package/dist/modules/rendering/subtitle/AnimationStateFingerprint.js +2 -0
  47. package/dist/modules/rendering/subtitle/AnimationStateFingerprint.js.map +1 -0
  48. package/dist/modules/rendering/subtitle/AssetGroupBuilder.d.ts +4 -0
  49. package/dist/modules/rendering/subtitle/AssetGroupBuilder.d.ts.map +1 -1
  50. package/dist/modules/rendering/subtitle/AssetGroupBuilder.js +8 -0
  51. package/dist/modules/rendering/subtitle/AssetGroupBuilder.js.map +1 -1
  52. package/dist/modules/rendering/subtitle/BatchPlanner.d.ts +50 -5
  53. package/dist/modules/rendering/subtitle/BatchPlanner.d.ts.map +1 -1
  54. package/dist/modules/rendering/subtitle/BatchPlanner.js +97 -15
  55. package/dist/modules/rendering/subtitle/BatchPlanner.js.map +1 -1
  56. package/dist/modules/rendering/subtitle/ElementWidthMeasurer.d.ts +56 -0
  57. package/dist/modules/rendering/subtitle/ElementWidthMeasurer.d.ts.map +1 -0
  58. package/dist/modules/rendering/subtitle/ElementWidthMeasurer.js +119 -0
  59. package/dist/modules/rendering/subtitle/ElementWidthMeasurer.js.map +1 -0
  60. package/dist/modules/rendering/subtitle/ElementWidths.d.ts +23 -0
  61. package/dist/modules/rendering/subtitle/ElementWidths.d.ts.map +1 -0
  62. package/dist/modules/rendering/subtitle/ElementWidths.js +29 -0
  63. package/dist/modules/rendering/subtitle/ElementWidths.js.map +1 -0
  64. package/dist/modules/rendering/subtitle/ImageDecodeSpriteSheetRasterProbe.d.ts +18 -0
  65. package/dist/modules/rendering/subtitle/ImageDecodeSpriteSheetRasterProbe.d.ts.map +1 -0
  66. package/dist/modules/rendering/subtitle/ImageDecodeSpriteSheetRasterProbe.js +42 -0
  67. package/dist/modules/rendering/subtitle/ImageDecodeSpriteSheetRasterProbe.js.map +1 -0
  68. package/dist/modules/rendering/subtitle/KeyframeScanAnimationStateFingerprint.d.ts +35 -0
  69. package/dist/modules/rendering/subtitle/KeyframeScanAnimationStateFingerprint.d.ts.map +1 -0
  70. package/dist/modules/rendering/subtitle/KeyframeScanAnimationStateFingerprint.js +64 -0
  71. package/dist/modules/rendering/subtitle/KeyframeScanAnimationStateFingerprint.js.map +1 -0
  72. package/dist/modules/rendering/subtitle/PreparedStyle.d.ts +2 -0
  73. package/dist/modules/rendering/subtitle/PreparedStyle.d.ts.map +1 -1
  74. package/dist/modules/rendering/subtitle/PreparedStyleFactory.d.ts.map +1 -1
  75. package/dist/modules/rendering/subtitle/PreparedStyleFactory.js +12 -1
  76. package/dist/modules/rendering/subtitle/PreparedStyleFactory.js.map +1 -1
  77. package/dist/modules/rendering/subtitle/SegmentAnchorVarsBuilder.d.ts +28 -0
  78. package/dist/modules/rendering/subtitle/SegmentAnchorVarsBuilder.d.ts.map +1 -0
  79. package/dist/modules/rendering/subtitle/SegmentAnchorVarsBuilder.js +23 -0
  80. package/dist/modules/rendering/subtitle/SegmentAnchorVarsBuilder.js.map +1 -0
  81. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.d.ts +3 -0
  82. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.d.ts.map +1 -1
  83. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.js +12 -3
  84. package/dist/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.js.map +1 -1
  85. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.d.ts +7 -1
  86. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.d.ts.map +1 -1
  87. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.js +23 -5
  88. package/dist/modules/rendering/subtitle/SegmentWrapperRenderer.js.map +1 -1
  89. package/dist/modules/rendering/subtitle/SpriteSheetProbeObserver.d.ts +29 -0
  90. package/dist/modules/rendering/subtitle/SpriteSheetProbeObserver.d.ts.map +1 -0
  91. package/dist/modules/rendering/subtitle/SpriteSheetProbeObserver.js +2 -0
  92. package/dist/modules/rendering/subtitle/SpriteSheetProbeObserver.js.map +1 -0
  93. package/dist/modules/rendering/subtitle/SpriteSheetRasterProbe.d.ts +19 -0
  94. package/dist/modules/rendering/subtitle/SpriteSheetRasterProbe.d.ts.map +1 -0
  95. package/dist/modules/rendering/subtitle/SpriteSheetRasterProbe.js +2 -0
  96. package/dist/modules/rendering/subtitle/SpriteSheetRasterProbe.js.map +1 -0
  97. package/dist/modules/rendering/subtitle/SpriteSheetSizeProbe.d.ts +31 -0
  98. package/dist/modules/rendering/subtitle/SpriteSheetSizeProbe.d.ts.map +1 -0
  99. package/dist/modules/rendering/subtitle/SpriteSheetSizeProbe.js +89 -0
  100. package/dist/modules/rendering/subtitle/SpriteSheetSizeProbe.js.map +1 -0
  101. package/dist/modules/rendering/subtitle/SubtreeAnimationReading.d.ts +49 -0
  102. package/dist/modules/rendering/subtitle/SubtreeAnimationReading.d.ts.map +1 -0
  103. package/dist/modules/rendering/subtitle/SubtreeAnimationReading.js +87 -0
  104. package/dist/modules/rendering/subtitle/SubtreeAnimationReading.js.map +1 -0
  105. package/dist/modules/rendering/subtitle/SubtreeAnimationSupport.d.ts +17 -0
  106. package/dist/modules/rendering/subtitle/SubtreeAnimationSupport.d.ts.map +1 -0
  107. package/dist/modules/rendering/subtitle/SubtreeAnimationSupport.js +53 -0
  108. package/dist/modules/rendering/subtitle/SubtreeAnimationSupport.js.map +1 -0
  109. package/dist/modules/rendering/subtitle/SubtreeMountAnimationStateFingerprint.d.ts +62 -0
  110. package/dist/modules/rendering/subtitle/SubtreeMountAnimationStateFingerprint.d.ts.map +1 -0
  111. package/dist/modules/rendering/subtitle/SubtreeMountAnimationStateFingerprint.js +153 -0
  112. package/dist/modules/rendering/subtitle/SubtreeMountAnimationStateFingerprint.js.map +1 -0
  113. package/dist/modules/rendering/subtitle/SvgFilterStateFingerprint.d.ts +47 -0
  114. package/dist/modules/rendering/subtitle/SvgFilterStateFingerprint.d.ts.map +1 -0
  115. package/dist/modules/rendering/subtitle/SvgFilterStateFingerprint.js +69 -0
  116. package/dist/modules/rendering/subtitle/SvgFilterStateFingerprint.js.map +1 -0
  117. package/dist/modules/rendering/subtitle/UnknownAnimationStateFingerprint.d.ts +9 -0
  118. package/dist/modules/rendering/subtitle/UnknownAnimationStateFingerprint.d.ts.map +1 -0
  119. package/dist/modules/rendering/subtitle/UnknownAnimationStateFingerprint.js +10 -0
  120. package/dist/modules/rendering/subtitle/UnknownAnimationStateFingerprint.js.map +1 -0
  121. package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.d.ts.map +1 -1
  122. package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.js +2 -0
  123. package/dist/modules/rendering/subtitle/VideoFrameVarsBuilder.js.map +1 -1
  124. package/dist/modules/rendering/types/ElementRenderOverrides.d.ts +2 -0
  125. package/dist/modules/rendering/types/ElementRenderOverrides.d.ts.map +1 -1
  126. package/dist/modules/rendering/types/ElementRenderOverrides.js +4 -0
  127. package/dist/modules/rendering/types/ElementRenderOverrides.js.map +1 -1
  128. package/dist/modules/splitting/BalancedLineSplitter.d.ts +9 -0
  129. package/dist/modules/splitting/BalancedLineSplitter.d.ts.map +1 -1
  130. package/dist/modules/splitting/BalancedLineSplitter.js +15 -3
  131. package/dist/modules/splitting/BalancedLineSplitter.js.map +1 -1
  132. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts +1 -4
  133. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts.map +1 -1
  134. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js +5 -7
  135. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js.map +1 -1
  136. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts +16 -7
  137. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts.map +1 -1
  138. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js +44 -33
  139. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js.map +1 -1
  140. package/dist/modules/splitting/TextMeasurer.d.ts +9 -4
  141. package/dist/modules/splitting/TextMeasurer.d.ts.map +1 -1
  142. package/dist/modules/svg-filter/SvgFilter.d.ts +9 -0
  143. package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -1
  144. package/dist/modules/svg-filter/SvgFilter.js +17 -0
  145. package/dist/modules/svg-filter/SvgFilter.js.map +1 -1
  146. package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts +7 -0
  147. package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts.map +1 -1
  148. package/dist/modules/svg-filter/SvgFilterDefinitions.js +17 -0
  149. package/dist/modules/svg-filter/SvgFilterDefinitions.js.map +1 -1
  150. package/dist/modules/tagging/RegexTagger.js +1 -2
  151. package/dist/modules/tagging/RegexTagger.js.map +1 -1
  152. package/dist/modules/tagging/SpanTagger.js +1 -2
  153. package/dist/modules/tagging/SpanTagger.js.map +1 -1
  154. package/dist/modules/tagging/StructureTagger.js +1 -2
  155. package/dist/modules/tagging/StructureTagger.js.map +1 -1
  156. package/dist/modules/tagging/WordlistTagger.js +1 -2
  157. package/dist/modules/tagging/WordlistTagger.js.map +1 -1
  158. package/dist/modules/transcription/AudioSegmentLayout.d.ts +23 -0
  159. package/dist/modules/transcription/AudioSegmentLayout.d.ts.map +1 -0
  160. package/dist/modules/transcription/AudioSegmentLayout.js +40 -0
  161. package/dist/modules/transcription/AudioSegmentLayout.js.map +1 -0
  162. package/dist/modules/transcription/FallbackAudioDecoder.d.ts +25 -0
  163. package/dist/modules/transcription/FallbackAudioDecoder.d.ts.map +1 -0
  164. package/dist/modules/transcription/FallbackAudioDecoder.js +46 -0
  165. package/dist/modules/transcription/FallbackAudioDecoder.js.map +1 -0
  166. package/dist/modules/transcription/MediaBunnyAudioOnlyRemuxer.d.ts +71 -0
  167. package/dist/modules/transcription/MediaBunnyAudioOnlyRemuxer.d.ts.map +1 -0
  168. package/dist/modules/transcription/MediaBunnyAudioOnlyRemuxer.js +145 -0
  169. package/dist/modules/transcription/MediaBunnyAudioOnlyRemuxer.js.map +1 -0
  170. package/dist/modules/transcription/WebAudioAudioDecoder.d.ts +46 -0
  171. package/dist/modules/transcription/WebAudioAudioDecoder.d.ts.map +1 -0
  172. package/dist/modules/transcription/WebAudioAudioDecoder.js +123 -0
  173. package/dist/modules/transcription/WebAudioAudioDecoder.js.map +1 -0
  174. package/dist/modules/transcription/index.d.ts +4 -0
  175. package/dist/modules/transcription/index.d.ts.map +1 -1
  176. package/dist/modules/transcription/index.js +3 -0
  177. package/dist/modules/transcription/index.js.map +1 -1
  178. package/dist/modules/video/RenderJob.d.ts +23 -0
  179. package/dist/modules/video/RenderJob.d.ts.map +1 -1
  180. package/dist/modules/video/index.d.ts +5 -3
  181. package/dist/modules/video/index.d.ts.map +1 -1
  182. package/dist/modules/video/index.js +2 -0
  183. package/dist/modules/video/index.js.map +1 -1
  184. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.d.ts +33 -1
  185. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.d.ts.map +1 -1
  186. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.js +97 -20
  187. package/dist/modules/video/mediabunny/MediaBunnyTranscodeCoordinator.js.map +1 -1
  188. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts.map +1 -1
  189. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js +1 -0
  190. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js.map +1 -1
  191. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts +20 -9
  192. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts.map +1 -1
  193. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js +56 -14
  194. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js.map +1 -1
  195. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts +29 -10
  196. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts.map +1 -1
  197. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js +48 -17
  198. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js.map +1 -1
  199. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts +28 -11
  200. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts.map +1 -1
  201. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts +33 -12
  202. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts.map +1 -1
  203. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js +53 -18
  204. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js.map +1 -1
  205. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts.map +1 -1
  206. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js +7 -3
  207. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js.map +1 -1
  208. package/dist/modules/video/mediabunny/frame/BufferedVideoFrameSource.d.ts +45 -0
  209. package/dist/modules/video/mediabunny/frame/BufferedVideoFrameSource.d.ts.map +1 -0
  210. package/dist/modules/video/mediabunny/frame/BufferedVideoFrameSource.js +93 -0
  211. package/dist/modules/video/mediabunny/frame/BufferedVideoFrameSource.js.map +1 -0
  212. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts.map +1 -1
  213. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js +3 -1
  214. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js.map +1 -1
  215. package/dist/modules/video/mediabunny/frame/RetainedVideoFrame.d.ts +26 -0
  216. package/dist/modules/video/mediabunny/frame/RetainedVideoFrame.d.ts.map +1 -0
  217. package/dist/modules/video/mediabunny/frame/RetainedVideoFrame.js +55 -0
  218. package/dist/modules/video/mediabunny/frame/RetainedVideoFrame.js.map +1 -0
  219. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts +6 -1
  220. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts.map +1 -1
  221. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderSelectionFailedError.d.ts +14 -0
  222. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderSelectionFailedError.d.ts.map +1 -0
  223. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderSelectionFailedError.js +14 -0
  224. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderSelectionFailedError.js.map +1 -0
  225. package/dist/modules/video/mediabunny/frame/WebCodecsOnlyVideoFrameDecoderFactory.d.ts +16 -0
  226. package/dist/modules/video/mediabunny/frame/WebCodecsOnlyVideoFrameDecoderFactory.d.ts.map +1 -0
  227. package/dist/modules/video/mediabunny/frame/WebCodecsOnlyVideoFrameDecoderFactory.js +23 -0
  228. package/dist/modules/video/mediabunny/frame/WebCodecsOnlyVideoFrameDecoderFactory.js.map +1 -0
  229. package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.d.ts +9 -3
  230. package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.d.ts.map +1 -1
  231. package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.js +24 -7
  232. package/dist/modules/video/mediabunny/painter/CaptionsOverlayFramePainter.js.map +1 -1
  233. package/dist/modules/video/mediabunny/painter/FramePainter.d.ts +35 -14
  234. package/dist/modules/video/mediabunny/painter/FramePainter.d.ts.map +1 -1
  235. package/package.json +1 -1
  236. package/dist/modules/rendering/subtitle/AbstractAnim.d.ts +0 -13
  237. package/dist/modules/rendering/subtitle/AbstractAnim.d.ts.map +0 -1
  238. package/dist/modules/rendering/subtitle/AbstractAnim.js +0 -2
  239. package/dist/modules/rendering/subtitle/AbstractAnim.js.map +0 -1
  240. package/dist/modules/rendering/subtitle/AnimationProbe.d.ts +0 -39
  241. package/dist/modules/rendering/subtitle/AnimationProbe.d.ts.map +0 -1
  242. package/dist/modules/rendering/subtitle/AnimationProbe.js +0 -203
  243. package/dist/modules/rendering/subtitle/AnimationProbe.js.map +0 -1
  244. package/dist/modules/rendering/subtitle/SpriteSheetSizeProber.d.ts +0 -17
  245. package/dist/modules/rendering/subtitle/SpriteSheetSizeProber.d.ts.map +0 -1
  246. package/dist/modules/rendering/subtitle/SpriteSheetSizeProber.js +0 -58
  247. package/dist/modules/rendering/subtitle/SpriteSheetSizeProber.js.map +0 -1
  248. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +0 -27
  249. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +0 -1
  250. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +0 -84
  251. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +0 -1
@@ -0,0 +1,119 @@
1
+ import { CssVariable } from '../../document/CssVariable';
2
+ import { DataAttribute } from '../../document/DataAttribute';
3
+ import { ElementWidths } from '../../rendering/subtitle/ElementWidths';
4
+ import { profiler } from '../../profiling/Profiler';
5
+ const WIDTH_VARIABLES = [
6
+ CssVariable.SEGMENT_WIDTH_EM,
7
+ CssVariable.LINE_WIDTH_EM,
8
+ CssVariable.WORD_WIDTH_EM,
9
+ ];
10
+ /**
11
+ * How wide a caption's elements lay out, measured by mounting the
12
+ * subtree under the consumer's own stylesheet and reading the boxes
13
+ * back. Answers once per caption per style and reuses that for every
14
+ * frame the caption is on screen; `clear` drops what it kept.
15
+ *
16
+ * Segments, lines and words answer, and nothing else does. They are the
17
+ * three a stylesheet lays text out in, and every extra kind costs
18
+ * another custom property on every rendered element for a question no
19
+ * stylesheet has asked yet. Adding a kind is adding its variable here.
20
+ *
21
+ * A style whose CSS reads none of the properties is never measured: the
22
+ * work is a mount and a layout read, and nothing would consume it.
23
+ *
24
+ * Measuring the subtree as it is really built is what keeps the answer
25
+ * honest. Whatever classes the caption carries at that moment are on
26
+ * it, so a template that restyles a whole caption on a render state is
27
+ * measured in the typography that state produces, with no second
28
+ * description of that state to keep in step.
29
+ */
30
+ export class ElementWidthMeasurer {
31
+ subtreeBuilder;
32
+ viewportWidth;
33
+ viewportHeight;
34
+ widthsByKey = new Map();
35
+ constructor(subtreeBuilder, viewportWidth, viewportHeight) {
36
+ this.subtreeBuilder = subtreeBuilder;
37
+ this.viewportWidth = viewportWidth;
38
+ this.viewportHeight = viewportHeight;
39
+ }
40
+ widthsFor(style, styleInput, segment, t, indexInSection) {
41
+ if (!this.styleReadsAnyWidth(style))
42
+ return ElementWidths.empty();
43
+ const key = `${style.kind}:${segment.id}`;
44
+ let widths = this.widthsByKey.get(key);
45
+ if (!widths) {
46
+ widths = this.measure(style, styleInput, segment, t, indexInSection);
47
+ this.widthsByKey.set(key, widths);
48
+ }
49
+ return widths;
50
+ }
51
+ clear() {
52
+ this.widthsByKey.clear();
53
+ }
54
+ styleReadsAnyWidth(style) {
55
+ return WIDTH_VARIABLES.some((property) => style.usedCssVars.has(property));
56
+ }
57
+ measure(style, styleInput, segment, t, indexInSection) {
58
+ const host = document.createElement('div');
59
+ host.style.cssText = `container-type: size; width: ${this.viewportWidth}px; height: ${this.viewportHeight}px;`;
60
+ const inner = document.createElement('div');
61
+ inner.style.cssText = 'display:inline-block;';
62
+ profiler.time('ElementWidthMeasurer.mount', () => {
63
+ inner.innerHTML = this.buildMeasurableSubtree(styleInput, segment, t, indexInSection);
64
+ host.appendChild(inner);
65
+ style.probeContainer.appendChild(host);
66
+ });
67
+ try {
68
+ return profiler.time('ElementWidthMeasurer.read', () => this.readWidths(inner));
69
+ }
70
+ finally {
71
+ style.probeContainer.removeChild(host);
72
+ }
73
+ }
74
+ /**
75
+ * The subtree as it will really be built, with every element named so
76
+ * its box can be found again afterwards.
77
+ *
78
+ * The widths are deliberately absent from it. A stylesheet sizing text
79
+ * from its own width would otherwise have to be measured at the size
80
+ * it is being asked to produce; leaving the properties unset lets the
81
+ * rule fall back, and since the answer is a multiple of the font size,
82
+ * whichever size the fallback lands on gives the same one.
83
+ */
84
+ buildMeasurableSubtree(styleInput, segment, t, indexInSection) {
85
+ const named = { ...styleInput, addressableElementIds: this.everyElementId(segment) };
86
+ return this.subtreeBuilder.buildSegmentSubtree(named, segment, t, new Set(), indexInSection);
87
+ }
88
+ everyElementId(segment) {
89
+ const ids = new Set([segment.id]);
90
+ for (const line of segment.lines) {
91
+ ids.add(line.id);
92
+ for (const word of line.words)
93
+ ids.add(word.id);
94
+ }
95
+ return ids;
96
+ }
97
+ /**
98
+ * An element that generates no box reports zero. That is the true
99
+ * answer rather than a missing one — a stylesheet asking the width of
100
+ * something it took out of flow is asking about a box that is not
101
+ * there.
102
+ */
103
+ readWidths(host) {
104
+ const widthEmByElementId = new Map();
105
+ for (const element of host.querySelectorAll(`[${DataAttribute.ELEMENT_ID}]`)) {
106
+ const elementId = element.getAttribute(DataAttribute.ELEMENT_ID);
107
+ if (elementId)
108
+ widthEmByElementId.set(elementId, this.widthEmOf(element));
109
+ }
110
+ return new ElementWidths(widthEmByElementId);
111
+ }
112
+ widthEmOf(element) {
113
+ const fontSizePx = parseFloat(window.getComputedStyle(element).fontSize) || 0;
114
+ if (fontSizePx <= 0)
115
+ return 0;
116
+ return element.getBoundingClientRect().width / fontSizePx;
117
+ }
118
+ }
119
+ //# sourceMappingURL=ElementWidthMeasurer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementWidthMeasurer.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/ElementWidthMeasurer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,MAAM,eAAe,GAA0B;IAC7C,WAAW,CAAC,gBAAgB;IAC5B,WAAW,CAAC,aAAa;IACzB,WAAW,CAAC,aAAa;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,oBAAoB;IAIZ;IACA;IACA;IALF,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEhE,YACmB,cAAyC,EACzC,aAAqB,EACrB,cAAsB;QAFtB,mBAAc,GAAd,cAAc,CAA2B;QACzC,kBAAa,GAAb,aAAa,CAAQ;QACrB,mBAAc,GAAd,cAAc,CAAQ;IACtC,CAAC;IAEJ,SAAS,CACP,KAAoB,EACpB,UAAoC,EACpC,OAAgB,EAChB,CAAS,EACT,cAAsB;QAEtB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;YAAE,OAAO,aAAa,CAAC,KAAK,EAAE,CAAC;QAClE,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;QAC1C,IAAI,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,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AAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC/C,CAAC;IAEO,SAAS,CAAC,OAAoB;QACpC,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC9E,IAAI,UAAU,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC;QAC9B,OAAO,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC;IAC5D,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import type { InlineStyleMap } from '../../rendering/types/InlineStyleMap';
2
+ /**
3
+ * How wide each element of one rendered caption came out, as a
4
+ * multiple of the font size that element renders at.
5
+ *
6
+ * The multiple is what makes the answer usable: a stylesheet deriving a
7
+ * font size from a width cannot be told the width in pixels, because
8
+ * the pixels it would be told are the ones its own answer produces. A
9
+ * width in `em` is free of that, so it stays true whatever size the
10
+ * measurement happened to be taken at.
11
+ */
12
+ export declare class ElementWidths {
13
+ private readonly widthEmByElementId;
14
+ constructor(widthEmByElementId: ReadonlyMap<string, number>);
15
+ static empty(): ElementWidths;
16
+ /**
17
+ * The named custom property carrying `elementId`'s width, or nothing
18
+ * at all when the element was not measured — so a caller can spread
19
+ * the result unconditionally.
20
+ */
21
+ varsFor(property: string, elementId: string): InlineStyleMap;
22
+ }
23
+ //# sourceMappingURL=ElementWidths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementWidths.d.ts","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/ElementWidths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAE9E;;;;;;;;;GASG;AACH,qBAAa,aAAa;IAEZ,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAAlB,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAE5E,MAAM,CAAC,KAAK,IAAI,aAAa;IAI7B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc;CAI7D"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * How wide each element of one rendered caption came out, as a
3
+ * multiple of the font size that element renders at.
4
+ *
5
+ * The multiple is what makes the answer usable: a stylesheet deriving a
6
+ * font size from a width cannot be told the width in pixels, because
7
+ * the pixels it would be told are the ones its own answer produces. A
8
+ * width in `em` is free of that, so it stays true whatever size the
9
+ * measurement happened to be taken at.
10
+ */
11
+ export class ElementWidths {
12
+ widthEmByElementId;
13
+ constructor(widthEmByElementId) {
14
+ this.widthEmByElementId = widthEmByElementId;
15
+ }
16
+ static empty() {
17
+ return new ElementWidths(new Map());
18
+ }
19
+ /**
20
+ * The named custom property carrying `elementId`'s width, or nothing
21
+ * at all when the element was not measured — so a caller can spread
22
+ * the result unconditionally.
23
+ */
24
+ varsFor(property, elementId) {
25
+ const widthEm = this.widthEmByElementId.get(elementId);
26
+ return widthEm === undefined ? {} : { [property]: String(widthEm) };
27
+ }
28
+ }
29
+ //# sourceMappingURL=ElementWidths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementWidths.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/ElementWidths.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAEK;IAA7B,YAA6B,kBAA+C;QAA/C,uBAAkB,GAAlB,kBAAkB,CAA6B;IAAG,CAAC;IAEhF,MAAM,CAAC,KAAK;QACV,OAAO,IAAI,aAAa,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAgB,EAAE,SAAiB;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACtE,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import type { SpriteSheetRasterOutcome, SpriteSheetRasterProbe } from '../../rendering/subtitle/SpriteSheetRasterProbe';
2
+ /**
3
+ * Draws a data-URL SVG through an `<img>` onto a canvas, the same
4
+ * delivery path a real sprite sheet takes, and reads its far corner
5
+ * back.
6
+ *
7
+ * The readback is the point: some hosts decode an oversize SVG and
8
+ * report success while leaving the far edges unpainted. Nothing public
9
+ * answers this instead — the reported WebGL limits (`MAX_TEXTURE_SIZE`,
10
+ * `MAX_VIEWPORT_DIMS`) bear no stable relation to what `img.decode` and
11
+ * `drawImage` accept.
12
+ */
13
+ export declare class ImageDecodeSpriteSheetRasterProbe implements SpriteSheetRasterProbe {
14
+ offer(width: number, height: number): Promise<SpriteSheetRasterOutcome>;
15
+ private markerSvg;
16
+ private isMarker;
17
+ }
18
+ //# sourceMappingURL=ImageDecodeSpriteSheetRasterProbe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageDecodeSpriteSheetRasterProbe.d.ts","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/ImageDecodeSpriteSheetRasterProbe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAI5D;;;;;;;;;;GAUG;AACH,qBAAa,iCAAkC,YAAW,sBAAsB;IAExE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAe7E,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,QAAQ;CAGjB"}
@@ -0,0 +1,42 @@
1
+ const MARKER_SIZE_PX = 2;
2
+ /**
3
+ * Draws a data-URL SVG through an `<img>` onto a canvas, the same
4
+ * delivery path a real sprite sheet takes, and reads its far corner
5
+ * back.
6
+ *
7
+ * The readback is the point: some hosts decode an oversize SVG and
8
+ * report success while leaving the far edges unpainted. Nothing public
9
+ * answers this instead — the reported WebGL limits (`MAX_TEXTURE_SIZE`,
10
+ * `MAX_VIEWPORT_DIMS`) bear no stable relation to what `img.decode` and
11
+ * `drawImage` accept.
12
+ */
13
+ export class ImageDecodeSpriteSheetRasterProbe {
14
+ async offer(width, height) {
15
+ const image = new Image();
16
+ image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(this.markerSvg(width, height))}`;
17
+ try {
18
+ await image.decode();
19
+ const context = new OffscreenCanvas(width, height).getContext('2d');
20
+ if (!context)
21
+ return { refusal: 'no-context' };
22
+ context.drawImage(image, 0, 0);
23
+ const corner = context.getImageData(width - 1, height - 1, 1, 1).data;
24
+ return this.isMarker(corner) ? { refusal: null } : { refusal: 'blank-edge' };
25
+ }
26
+ catch (cause) {
27
+ return { refusal: 'error', cause };
28
+ }
29
+ }
30
+ markerSvg(width, height) {
31
+ const x = width - MARKER_SIZE_PX;
32
+ const y = height - MARKER_SIZE_PX;
33
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">`
34
+ + `<rect width="100%" height="100%" fill="green"/>`
35
+ + `<rect x="${x}" y="${y}" width="${MARKER_SIZE_PX}" height="${MARKER_SIZE_PX}" fill="red"/>`
36
+ + `</svg>`;
37
+ }
38
+ isMarker(pixel) {
39
+ return pixel[0] > 200 && pixel[1] < 80 && pixel[2] < 80 && pixel[3] > 200;
40
+ }
41
+ }
42
+ //# sourceMappingURL=ImageDecodeSpriteSheetRasterProbe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageDecodeSpriteSheetRasterProbe.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/ImageDecodeSpriteSheetRasterProbe.ts"],"names":[],"mappings":"AAKA,MAAM,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,CAAC,YAAY,cAAc,aAAa,cAAc,gBAAgB;cAC3F,QAAQ,CAAC;IACf,CAAC;IAEO,QAAQ,CAAC,KAAwB;QACvC,OAAO,KAAK,CAAC,CAAC,CAAE,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAE,GAAG,EAAE,IAAI,KAAK,CAAC,CAAC,CAAE,GAAG,EAAE,IAAI,KAAK,CAAC,CAAC,CAAE,GAAG,GAAG,CAAC;IAChF,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ import type { CssKeyframesScanner } from '../../css/CssKeyframesScanner';
2
+ import type { PreparedStyle } from '../../rendering/subtitle/PreparedStyle';
3
+ import type { AnimationStateFingerprint } from '../../rendering/subtitle/AnimationStateFingerprint';
4
+ /**
5
+ * Reads the style's CSS. One that neither defines nor applies any
6
+ * `@keyframes`, and declares no transition, has no animation to be at
7
+ * a point in, so it is described the same way at every timestamp.
8
+ * Anything else is never comparable.
9
+ *
10
+ * Coarse: a style is answered for as a whole, so one animation
11
+ * anywhere in it makes every timestamp incomparable, however still the
12
+ * segment being described happens to be.
13
+ *
14
+ * Defining a `@keyframes` counts even where nothing applies it, which
15
+ * is what covers `animation: var(--name)` — the name is not in the
16
+ * declaration to be found, and only the block gives it away.
17
+ *
18
+ * Every source of CSS the style carries is read, including the inline
19
+ * styles its overrides put on single elements.
20
+ *
21
+ * Read once per style: a prepared style's CSS does not change, and it
22
+ * can carry embedded font faces, which makes it large. The answer is
23
+ * held against the style itself, so one prepared from different CSS is
24
+ * never given another's.
25
+ */
26
+ export declare class KeyframeScanAnimationStateFingerprint implements AnimationStateFingerprint {
27
+ private readonly keyframesScanner;
28
+ private readonly movesByStyle;
29
+ constructor(keyframesScanner: CssKeyframesScanner);
30
+ at(style: PreparedStyle): Promise<string | null>;
31
+ private moves;
32
+ private everyDeclarationOf;
33
+ private serialize;
34
+ }
35
+ //# sourceMappingURL=KeyframeScanAnimationStateFingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyframeScanAnimationStateFingerprint.d.ts","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/KeyframeScanAnimationStateFingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAUvG;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,qCAAsC,YAAW,yBAAyB;IAGzE,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAF7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyC;gBAEzC,gBAAgB,EAAE,mBAAmB;IAElE,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIhD,OAAO,CAAC,KAAK;IAWb,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,SAAS;CAIlB"}
@@ -0,0 +1,64 @@
1
+ /** The description every timestamp gets when the style has no animation to be at a point in. */
2
+ const NO_ANIMATION = '';
3
+ // A transition needs a value to change on an element that was already
4
+ // laid out, which a subtree built from scratch never has — except
5
+ // under `@starting-style`, which runs on first paint.
6
+ const TRANSITION_PATTERN = /transition|@starting-style/;
7
+ /**
8
+ * Reads the style's CSS. One that neither defines nor applies any
9
+ * `@keyframes`, and declares no transition, has no animation to be at
10
+ * a point in, so it is described the same way at every timestamp.
11
+ * Anything else is never comparable.
12
+ *
13
+ * Coarse: a style is answered for as a whole, so one animation
14
+ * anywhere in it makes every timestamp incomparable, however still the
15
+ * segment being described happens to be.
16
+ *
17
+ * Defining a `@keyframes` counts even where nothing applies it, which
18
+ * is what covers `animation: var(--name)` — the name is not in the
19
+ * declaration to be found, and only the block gives it away.
20
+ *
21
+ * Every source of CSS the style carries is read, including the inline
22
+ * styles its overrides put on single elements.
23
+ *
24
+ * Read once per style: a prepared style's CSS does not change, and it
25
+ * can carry embedded font faces, which makes it large. The answer is
26
+ * held against the style itself, so one prepared from different CSS is
27
+ * never given another's.
28
+ */
29
+ export class KeyframeScanAnimationStateFingerprint {
30
+ keyframesScanner;
31
+ movesByStyle = new WeakMap();
32
+ constructor(keyframesScanner) {
33
+ this.keyframesScanner = keyframesScanner;
34
+ }
35
+ at(style) {
36
+ return Promise.resolve(this.moves(style) ? null : NO_ANIMATION);
37
+ }
38
+ moves(style) {
39
+ const known = this.movesByStyle.get(style);
40
+ if (known !== undefined)
41
+ return known;
42
+ const css = this.everyDeclarationOf(style);
43
+ const moves = this.keyframesScanner.definedNames(css).size > 0
44
+ || this.keyframesScanner.referencedNames(css).size > 0
45
+ || TRANSITION_PATTERN.test(css);
46
+ this.movesByStyle.set(style, moves);
47
+ return moves;
48
+ }
49
+ everyDeclarationOf(style) {
50
+ return [
51
+ style.baselineCss,
52
+ style.scopedCss,
53
+ this.serialize(style.inlineStyles),
54
+ ...[...style.segmentOverrides.values(), ...style.wordOverrides.values()]
55
+ .map((override) => this.serialize(override.inlineStyles)),
56
+ ].join(';');
57
+ }
58
+ serialize(inlineStyles) {
59
+ if (!inlineStyles)
60
+ return '';
61
+ return Object.entries(inlineStyles).map(([property, value]) => `${property}:${value}`).join(';');
62
+ }
63
+ }
64
+ //# sourceMappingURL=KeyframeScanAnimationStateFingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyframeScanAnimationStateFingerprint.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/KeyframeScanAnimationStateFingerprint.ts"],"names":[],"mappings":"AAKA,gGAAgG;AAChG,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,sEAAsE;AACtE,kEAAkE;AAClE,sDAAsD;AACtD,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,qCAAqC;IAGnB;IAFZ,YAAY,GAAG,IAAI,OAAO,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,CAAC;IAEO,SAAS,CAAC,YAAwC;QACxD,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnG,CAAC;CACF"}
@@ -26,6 +26,8 @@ export interface PreparedStyle {
26
26
  segmentOverrides: ElementRenderOverrides;
27
27
  decorationPlacements: ReadonlyMap<string, DecorationPlacementSide>;
28
28
  addressableElementIds: ReadonlySet<string>;
29
+ /** Every custom property the style's CSS reads, whether by substitution or style query. */
30
+ usedCssVars: ReadonlySet<string>;
29
31
  probeStyleElement: HTMLStyleElement;
30
32
  probeContainer: HTMLElement;
31
33
  scopeClass: string;
@@ -1 +1 @@
1
- {"version":3,"file":"PreparedStyle.d.ts","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/PreparedStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAEnF;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EA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AAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAO3G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAW/E;;;;;;GAMG;AACH,qBAAa,oBAAoB;IAG7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,4BAA4B;gBAN5B,WAAW,EAAE,mBAAmB,EAChC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB,EAC9C,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,4BAA4B,EAAE,4BAA4B;IAGvE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;IAuDvF,OAAO,CAAC,yBAAyB;IAKjC,OAAO,CAAC,qBAAqB;CAS9B"}
@@ -2,6 +2,14 @@ import { SvgFilterBundle } from '../../svg-filter/SvgFilterBundle';
2
2
  import { SvgFilterScope } from '../../svg-filter/SvgFilterScope';
3
3
  import { ElementRenderOverrides } from '../../rendering/types/ElementRenderOverrides';
4
4
  import { InlineStyleEmitter } from '../../rendering/styles/InlineStyleEmitter';
5
+ // `!important`, so a sheet declaring any of them for its own layout
6
+ // cannot bring the probe container back on screen.
7
+ const PROBE_CONTAINER_STYLES = {
8
+ position: 'fixed',
9
+ left: '-99999px',
10
+ visibility: 'hidden',
11
+ 'pointer-events': 'none',
12
+ };
5
13
  /**
6
14
  * Prepares a `SubtitleStyle` for downstream rendering: minifies and
7
15
  * embeds the CSS, scopes it to a unique class, mounts a probe
@@ -47,7 +55,9 @@ export class PreparedStyleFactory {
47
55
  document.head.appendChild(probeStyleEl);
48
56
  const probeContainer = document.createElement('div');
49
57
  probeContainer.className = scopeClass;
50
- probeContainer.style.cssText = 'position:fixed;left:-99999px;visibility:hidden;pointer-events:none;';
58
+ for (const [property, value] of Object.entries(PROBE_CONTAINER_STYLES)) {
59
+ probeContainer.style.setProperty(property, value, 'important');
60
+ }
51
61
  document.body.appendChild(probeContainer);
52
62
  const usedCssVars = this.cssVarReferenceScanner.scan(baselineCss + scopedCss);
53
63
  return {
@@ -67,6 +77,7 @@ export class PreparedStyleFactory {
67
77
  probeStyleElement: probeStyleEl,
68
78
  probeContainer,
69
79
  scopeClass,
80
+ usedCssVars,
70
81
  inlineStyleEmitter: new InlineStyleEmitter(usedCssVars),
71
82
  baselineNeeds,
72
83
  baselineCss,
@@ -1 +1 @@
1
- {"version":3,"file":"PreparedStyleFactory.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/PreparedStyleFactory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAKlF;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IAGZ;IACA;IACA;IACA;IACA;IACA;IACA;IAPnB,YACmB,WAAgC,EAChC,SAAoB,EACpB,WAAwB,EACxB,sBAA8C,EAC9C,mBAAwC,EACxC,eAAgC,EAChC,4BAA0D;QAN1D,gBAAW,GAAX,WAAW,CAAqB;QAChC,cAAS,GAAT,SAAS,CAAW;QACpB,gBAAW,GAAX,WAAW,CAAa;QACxB,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,wBAAmB,GAAnB,mB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YACvD,aAAa;YACb,WAAW;SACZ,CAAC;IACJ,CAAC;IAEO,yBAAyB,CAAC,GAAW,EAAE,SAA0B;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC,CAAC;IAEO,qBAAqB,CAAC,GAAa,EAAE,IAAY;QACvD,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;gBAAE,SAAS;YACpC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACtC,IAAI,IAAI,CAAC,UAAU;oBAAE,OAAO,IAAI,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
1
+ {"version":3,"file":"PreparedStyleFactory.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/PreparedStyleFactory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAKlF,oEAAoE;AACpE,mDAAmD;AACnD,MAAM,sBAAsB,GAA2B;IACrD,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,QAAQ;IACpB,gBAAgB,EAAE,MAAM;CACzB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IAGZ;IACA;IACA;IACA;IACA;IACA;IACA;IAPnB,YACmB,WAAgC,EAChC,SAAoB,EACpB,WAAw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AE,KAAK,CAAC,aAAa,IAAI,sBAAsB,CAAC,KAAK,EAAE;YACpE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,IAAI,sBAAsB,CAAC,KAAK,EAAE;YAC1E,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,IAAI,IAAI,GAAG,EAAmC;YAC9F,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,IAAI,IAAI,GAAG,EAAU;YACvE,iBAAiB,EAAE,YAAY;YAC/B,cAAc;YACd,UAAU;YACV,WAAW;YACX,kBAAkB,EAAE,IAAI,kBAAkB,CAAC,WAAW,CAAC;YACvD,aAAa;YACb,WAAW;SACZ,CAAC;IACJ,CAAC;IAEO,yBAAyB,CAAC,GAAW,EAAE,SAA0B;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC,CAAC;IAEO,qBAAqB,CAAC,GAAa,EAAE,IAAY;QACvD,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;gBAAE,SAAS;YACpC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACtC,IAAI,IAAI,CAAC,UAAU;oBAAE,OAAO,IAAI,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ import type { InlineStyleMap } from '../../rendering/types/InlineStyleMap';
2
+ /**
3
+ * Where a subtree's anchor sits, in the terms a stylesheet needs to
4
+ * reason about it.
5
+ */
6
+ export interface AnchorPlacement {
7
+ /** Anchor position down the frame, as a fraction of its height. */
8
+ readonly verticalOffset: number;
9
+ /** Share of the box's own height that sits above the anchor: 0, 50 or 100. */
10
+ readonly vAnchorPct: number;
11
+ }
12
+ /**
13
+ * Publishes a subtree's vertical anchor so a stylesheet can address the
14
+ * frame rather than the anchor it happens to hang from.
15
+ *
16
+ * Positioning is resolved before any stylesheet runs, which leaves CSS
17
+ * able to move a caption only *relative* to wherever it was placed. A
18
+ * rule wanting an absolute position therefore has to undo the placement
19
+ * first, and these two values are what that costs: the offset says where
20
+ * the anchor landed, and the origin says which part of the box was put
21
+ * on it. Emitted as a percentage, the origin resolves against the box's
22
+ * own height inside a `translate`, so a rule can convert any anchor to a
23
+ * top-edge one without knowing how tall the caption grew.
24
+ */
25
+ export declare class SegmentAnchorVarsBuilder {
26
+ build(placement: AnchorPlacement): InlineStyleMap;
27
+ }
28
+ //# sourceMappingURL=SegmentAnchorVarsBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentAnchorVarsBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/SegmentAnchorVarsBuilder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,mEAAmE;IACnE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAwB;IAEnC,KAAK,CAAC,SAAS,EAAE,eAAe,GAAG,cAAc;CAMlD"}
@@ -0,0 +1,23 @@
1
+ import { CssVariable } from '../../document/CssVariable';
2
+ /**
3
+ * Publishes a subtree's vertical anchor so a stylesheet can address the
4
+ * frame rather than the anchor it happens to hang from.
5
+ *
6
+ * Positioning is resolved before any stylesheet runs, which leaves CSS
7
+ * able to move a caption only *relative* to wherever it was placed. A
8
+ * rule wanting an absolute position therefore has to undo the placement
9
+ * first, and these two values are what that costs: the offset says where
10
+ * the anchor landed, and the origin says which part of the box was put
11
+ * on it. Emitted as a percentage, the origin resolves against the box's
12
+ * own height inside a `translate`, so a rule can convert any anchor to a
13
+ * top-edge one without knowing how tall the caption grew.
14
+ */
15
+ export class SegmentAnchorVarsBuilder {
16
+ build(placement) {
17
+ return {
18
+ [CssVariable.SEGMENT_ANCHOR_Y]: String(placement.verticalOffset),
19
+ [CssVariable.SEGMENT_ANCHOR_ORIGIN_Y]: `${placement.vAnchorPct}%`,
20
+ };
21
+ }
22
+ }
23
+ //# sourceMappingURL=SegmentAnchorVarsBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentAnchorVarsBuilder.js","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/SegmentAnchorVarsBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAc5D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,wBAAwB;IAEnC,KAAK,CAAC,SAA0B;QAC9B,OAAO;YACL,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;YAChE,CAAC,WAAW,CAAC,uBAAuB,CAAC,EAAE,GAAG,SAAS,CAAC,UAAU,GAAG;SAClE,CAAC;IACJ,CAAC;CACF"}
@@ -1,6 +1,7 @@
1
1
  import type { Segment } from '../../document/Segment';
2
2
  import type { Line } from '../../document/Line';
3
3
  import type { Word } from '../../document/Word';
4
+ import { ElementWidths } from '../../rendering/subtitle/ElementWidths';
4
5
  import type { InlineStyleMap } from '../../rendering/types/InlineStyleMap';
5
6
  import type { InlineStyleEmitter } from '../../rendering/styles/InlineStyleEmitter';
6
7
  import type { ElementRenderOverrides } from '../../rendering/types/ElementRenderOverrides';
@@ -34,6 +35,8 @@ export interface SegmentSubtreeStyleInput {
34
35
  * stamping everything grows it by roughly a quarter.
35
36
  */
36
37
  readonly addressableElementIds: ReadonlySet<string>;
38
+ /** Measured widths of this segment's elements; empty when nothing reads them. */
39
+ readonly elementWidths: ElementWidths;
37
40
  }
38
41
  /**
39
42
  * Builds the `wrapper → segment → lines → words/letters` HTML
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentSubtreeHtmlBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/rendering/subtitle/SegmentSubtreeHtmlBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAKnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOnE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC/C,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;IACzC,QAAQ,CAAC,kBAAkB,EAAE,cAAc,CAAC;IAC5C,0FAA0F;IAC1F,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpD,qHAAqH;IACrH,QAAQ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C,EAAE,MAAM,EACT,cAAc,EAAE,MAAM,GACrB,MAAM;IAQT,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,aAAa;IAsBrB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,qBAAqB;IA4C7B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,qCAAqC;IAc7C,OAAO,CAAC,8BAA8B;IAuBtC,OAAO,CAAC,uBAAuB;IAa/B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,UAAU;CAGnB"}
@@ -90,13 +90,19 @@ export class SegmentSubtreeHtmlBuilder {
90
90
  // from them.
91
91
  composeSegmentHtml(style, seg, t, indexInSection, innerHtml) {
92
92
  const classes = [...seg.getCssClasses(t), ...style.extraSegmentClasses].join(' ');
93
- const segStyle = style.inlineStyleEmitter.serializeStyles(seg.getCssVariables(t, { indexInSection }));
93
+ const segStyle = style.inlineStyleEmitter.serializeStyles({
94
+ ...seg.getCssVariables(t, { indexInSection }),
95
+ ...style.elementWidths.varsFor(CssVariable.SEGMENT_WIDTH_EM, seg.id),
96
+ });
94
97
  return `<div class="${classes}" style="${segStyle}"${this.elementIdAttr(style, seg.id)}>${innerHtml}</div>`;
95
98
  }
96
99
  buildLineWrapperHtml(style, line, t, segTime, innerHtml) {
97
100
  const classes = line.getCssClasses(t).join(' ');
98
101
  const lineStyle = LINE_LAYOUT_STYLE
99
- + style.inlineStyleEmitter.serializeStyles(line.getCssVariables(t, { segTime }));
102
+ + style.inlineStyleEmitter.serializeStyles({
103
+ ...line.getCssVariables(t, { segTime }),
104
+ ...style.elementWidths.varsFor(CssVariable.LINE_WIDTH_EM, line.id),
105
+ });
100
106
  return `<div class="${classes}" style="${lineStyle}"${this.elementIdAttr(style, line.id)}>${innerHtml}</div>`;
101
107
  }
102
108
  buildLineHtml(style, line, t, excludedWordIds, segTime) {
@@ -154,7 +160,10 @@ export class SegmentSubtreeHtmlBuilder {
154
160
  buildWordFragmentHtml(style, input, t, segTime) {
155
161
  const { fragment, word, indexInLine } = input;
156
162
  const wordClasses = word.getCssClasses(t);
157
- const wordVars = word.getCssVariables(t, { segTime, indexInLine });
163
+ const wordVars = {
164
+ ...word.getCssVariables(t, { segTime, indexInLine }),
165
+ ...style.elementWidths.varsFor(CssVariable.WORD_WIDTH_EM, word.id),
166
+ };
158
167
  const overrideStyle = style.inlineStyleEmitter.serializeStyles(style.wordOverrides.get(word.id)?.inlineStyles);
159
168
  const decorationHtml = fragment.carriesWordTail && this.shouldEmitInlineDecoration(style, word)
160
169
  ? this.buildDecorationSpanHtml(style, word.decoration, t, segTime, word.time)