@tscaps/engine 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +12 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/modules/css/BrowserCssResourceEmbedder.d.ts +5 -0
  8. package/dist/modules/css/BrowserCssResourceEmbedder.d.ts.map +1 -0
  9. package/dist/modules/css/BrowserCssResourceEmbedder.js +41 -0
  10. package/dist/modules/css/BrowserCssResourceEmbedder.js.map +1 -0
  11. package/dist/modules/css/CssMinifier.d.ts +12 -0
  12. package/dist/modules/css/CssMinifier.d.ts.map +1 -0
  13. package/dist/modules/css/CssMinifier.js +47 -0
  14. package/dist/modules/css/CssMinifier.js.map +1 -0
  15. package/dist/modules/css/CssResourceEmbedder.d.ts +4 -0
  16. package/dist/modules/css/CssResourceEmbedder.d.ts.map +1 -0
  17. package/dist/modules/css/CssResourceEmbedder.js +2 -0
  18. package/dist/modules/css/CssResourceEmbedder.js.map +1 -0
  19. package/dist/modules/css/CssScoper.d.ts +16 -0
  20. package/dist/modules/css/CssScoper.d.ts.map +1 -0
  21. package/dist/modules/css/CssScoper.js +109 -0
  22. package/dist/modules/css/CssScoper.js.map +1 -0
  23. package/dist/modules/css/NoopCssResourceEmbedder.d.ts +12 -0
  24. package/dist/modules/css/NoopCssResourceEmbedder.d.ts.map +1 -0
  25. package/dist/modules/css/NoopCssResourceEmbedder.js +13 -0
  26. package/dist/modules/css/NoopCssResourceEmbedder.js.map +1 -0
  27. package/dist/modules/css/index.d.ts +6 -0
  28. package/dist/modules/css/index.d.ts.map +1 -0
  29. package/dist/modules/css/index.js +5 -0
  30. package/dist/modules/css/index.js.map +1 -0
  31. package/dist/modules/document/CssVariable.d.ts +46 -0
  32. package/dist/modules/document/CssVariable.d.ts.map +1 -0
  33. package/dist/modules/document/CssVariable.js +47 -0
  34. package/dist/modules/document/CssVariable.js.map +1 -0
  35. package/dist/modules/document/Document.d.ts +43 -0
  36. package/dist/modules/document/Document.d.ts.map +1 -0
  37. package/dist/modules/document/Document.js +86 -0
  38. package/dist/modules/document/Document.js.map +1 -0
  39. package/dist/modules/document/DocumentEditor.d.ts +111 -0
  40. package/dist/modules/document/DocumentEditor.d.ts.map +1 -0
  41. package/dist/modules/document/DocumentEditor.js +555 -0
  42. package/dist/modules/document/DocumentEditor.js.map +1 -0
  43. package/dist/modules/document/Letter.d.ts +17 -0
  44. package/dist/modules/document/Letter.d.ts.map +1 -0
  45. package/dist/modules/document/Letter.js +17 -0
  46. package/dist/modules/document/Letter.js.map +1 -0
  47. package/dist/modules/document/Line.d.ts +31 -0
  48. package/dist/modules/document/Line.d.ts.map +1 -0
  49. package/dist/modules/document/Line.js +94 -0
  50. package/dist/modules/document/Line.js.map +1 -0
  51. package/dist/modules/document/LineState.d.ts +6 -0
  52. package/dist/modules/document/LineState.d.ts.map +1 -0
  53. package/dist/modules/document/LineState.js +7 -0
  54. package/dist/modules/document/LineState.js.map +1 -0
  55. package/dist/modules/document/NarrationPace.d.ts +20 -0
  56. package/dist/modules/document/NarrationPace.d.ts.map +1 -0
  57. package/dist/modules/document/NarrationPace.js +60 -0
  58. package/dist/modules/document/NarrationPace.js.map +1 -0
  59. package/dist/modules/document/Section.d.ts +45 -0
  60. package/dist/modules/document/Section.d.ts.map +1 -0
  61. package/dist/modules/document/Section.js +94 -0
  62. package/dist/modules/document/Section.js.map +1 -0
  63. package/dist/modules/document/Segment.d.ts +40 -0
  64. package/dist/modules/document/Segment.d.ts.map +1 -0
  65. package/dist/modules/document/Segment.js +85 -0
  66. package/dist/modules/document/Segment.js.map +1 -0
  67. package/dist/modules/document/Tag.d.ts +24 -0
  68. package/dist/modules/document/Tag.d.ts.map +1 -0
  69. package/dist/modules/document/Tag.js +37 -0
  70. package/dist/modules/document/Tag.js.map +1 -0
  71. package/dist/modules/document/TimeFragment.d.ts +11 -0
  72. package/dist/modules/document/TimeFragment.d.ts.map +1 -0
  73. package/dist/modules/document/TimeFragment.js +29 -0
  74. package/dist/modules/document/TimeFragment.js.map +1 -0
  75. package/dist/modules/document/Word.d.ts +40 -0
  76. package/dist/modules/document/Word.d.ts.map +1 -0
  77. package/dist/modules/document/Word.js +114 -0
  78. package/dist/modules/document/Word.js.map +1 -0
  79. package/dist/modules/document/WordState.d.ts +6 -0
  80. package/dist/modules/document/WordState.d.ts.map +1 -0
  81. package/dist/modules/document/WordState.js +7 -0
  82. package/dist/modules/document/WordState.js.map +1 -0
  83. package/dist/modules/document/index.d.ts +14 -0
  84. package/dist/modules/document/index.d.ts.map +1 -0
  85. package/dist/modules/document/index.js +14 -0
  86. package/dist/modules/document/index.js.map +1 -0
  87. package/dist/modules/effect/CarryQuotesEffect.d.ts +47 -0
  88. package/dist/modules/effect/CarryQuotesEffect.d.ts.map +1 -0
  89. package/dist/modules/effect/CarryQuotesEffect.js +181 -0
  90. package/dist/modules/effect/CarryQuotesEffect.js.map +1 -0
  91. package/dist/modules/effect/Effect.d.ts +16 -0
  92. package/dist/modules/effect/Effect.d.ts.map +1 -0
  93. package/dist/modules/effect/Effect.js +2 -0
  94. package/dist/modules/effect/Effect.js.map +1 -0
  95. package/dist/modules/effect/GapFreeEffect.d.ts +24 -0
  96. package/dist/modules/effect/GapFreeEffect.d.ts.map +1 -0
  97. package/dist/modules/effect/GapFreeEffect.js +67 -0
  98. package/dist/modules/effect/GapFreeEffect.js.map +1 -0
  99. package/dist/modules/effect/RemovePunctuationEffect.d.ts +21 -0
  100. package/dist/modules/effect/RemovePunctuationEffect.d.ts.map +1 -0
  101. package/dist/modules/effect/RemovePunctuationEffect.js +52 -0
  102. package/dist/modules/effect/RemovePunctuationEffect.js.map +1 -0
  103. package/dist/modules/effect/SmartLowercaseEffect.d.ts +21 -0
  104. package/dist/modules/effect/SmartLowercaseEffect.d.ts.map +1 -0
  105. package/dist/modules/effect/SmartLowercaseEffect.js +45 -0
  106. package/dist/modules/effect/SmartLowercaseEffect.js.map +1 -0
  107. package/dist/modules/effect/SmartPunctuationEffect.d.ts +25 -0
  108. package/dist/modules/effect/SmartPunctuationEffect.d.ts.map +1 -0
  109. package/dist/modules/effect/SmartPunctuationEffect.js +68 -0
  110. package/dist/modules/effect/SmartPunctuationEffect.js.map +1 -0
  111. package/dist/modules/effect/index.d.ts +7 -0
  112. package/dist/modules/effect/index.d.ts.map +1 -0
  113. package/dist/modules/effect/index.js +6 -0
  114. package/dist/modules/effect/index.js.map +1 -0
  115. package/dist/modules/pipeline/PipelineProgress.d.ts +30 -0
  116. package/dist/modules/pipeline/PipelineProgress.d.ts.map +1 -0
  117. package/dist/modules/pipeline/PipelineProgress.js +2 -0
  118. package/dist/modules/pipeline/PipelineProgress.js.map +1 -0
  119. package/dist/modules/pipeline/RenderPipeline.d.ts +105 -0
  120. package/dist/modules/pipeline/RenderPipeline.d.ts.map +1 -0
  121. package/dist/modules/pipeline/RenderPipeline.js +232 -0
  122. package/dist/modules/pipeline/RenderPipeline.js.map +1 -0
  123. package/dist/modules/pipeline/RenderPipelineBuilder.d.ts +143 -0
  124. package/dist/modules/pipeline/RenderPipelineBuilder.d.ts.map +1 -0
  125. package/dist/modules/pipeline/RenderPipelineBuilder.js +317 -0
  126. package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -0
  127. package/dist/modules/pipeline/index.d.ts +6 -0
  128. package/dist/modules/pipeline/index.d.ts.map +1 -0
  129. package/dist/modules/pipeline/index.js +3 -0
  130. package/dist/modules/pipeline/index.js.map +1 -0
  131. package/dist/modules/profiling/Profiler.d.ts +115 -0
  132. package/dist/modules/profiling/Profiler.d.ts.map +1 -0
  133. package/dist/modules/profiling/Profiler.js +316 -0
  134. package/dist/modules/profiling/Profiler.js.map +1 -0
  135. package/dist/modules/profiling/index.d.ts +2 -0
  136. package/dist/modules/profiling/index.d.ts.map +1 -0
  137. package/dist/modules/profiling/index.js +2 -0
  138. package/dist/modules/profiling/index.js.map +1 -0
  139. package/dist/modules/rendering/AlignmentConfig.d.ts +21 -0
  140. package/dist/modules/rendering/AlignmentConfig.d.ts.map +1 -0
  141. package/dist/modules/rendering/AlignmentConfig.js +2 -0
  142. package/dist/modules/rendering/AlignmentConfig.js.map +1 -0
  143. package/dist/modules/rendering/BoxEdges.d.ts +8 -0
  144. package/dist/modules/rendering/BoxEdges.d.ts.map +1 -0
  145. package/dist/modules/rendering/BoxEdges.js +2 -0
  146. package/dist/modules/rendering/BoxEdges.js.map +1 -0
  147. package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts +12 -0
  148. package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts.map +1 -0
  149. package/dist/modules/rendering/BrowserOverlayFrameRenderer.js +31 -0
  150. package/dist/modules/rendering/BrowserOverlayFrameRenderer.js.map +1 -0
  151. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts +57 -0
  152. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -0
  153. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +775 -0
  154. package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -0
  155. package/dist/modules/rendering/ElementRenderOverrides.d.ts +15 -0
  156. package/dist/modules/rendering/ElementRenderOverrides.d.ts.map +1 -0
  157. package/dist/modules/rendering/ElementRenderOverrides.js +24 -0
  158. package/dist/modules/rendering/ElementRenderOverrides.js.map +1 -0
  159. package/dist/modules/rendering/InlineStyleMap.d.ts +9 -0
  160. package/dist/modules/rendering/InlineStyleMap.d.ts.map +1 -0
  161. package/dist/modules/rendering/InlineStyleMap.js +2 -0
  162. package/dist/modules/rendering/InlineStyleMap.js.map +1 -0
  163. package/dist/modules/rendering/LayeredSubtitleFrame.d.ts +20 -0
  164. package/dist/modules/rendering/LayeredSubtitleFrame.d.ts.map +1 -0
  165. package/dist/modules/rendering/LayeredSubtitleFrame.js +36 -0
  166. package/dist/modules/rendering/LayeredSubtitleFrame.js.map +1 -0
  167. package/dist/modules/rendering/OverlayFrameRenderer.d.ts +27 -0
  168. package/dist/modules/rendering/OverlayFrameRenderer.d.ts.map +1 -0
  169. package/dist/modules/rendering/OverlayFrameRenderer.js +2 -0
  170. package/dist/modules/rendering/OverlayFrameRenderer.js.map +1 -0
  171. package/dist/modules/rendering/RenderingConfig.d.ts +22 -0
  172. package/dist/modules/rendering/RenderingConfig.d.ts.map +1 -0
  173. package/dist/modules/rendering/RenderingConfig.js +2 -0
  174. package/dist/modules/rendering/RenderingConfig.js.map +1 -0
  175. package/dist/modules/rendering/ScopedRenderOverride.d.ts +19 -0
  176. package/dist/modules/rendering/ScopedRenderOverride.d.ts.map +1 -0
  177. package/dist/modules/rendering/ScopedRenderOverride.js +2 -0
  178. package/dist/modules/rendering/ScopedRenderOverride.js.map +1 -0
  179. package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts +41 -0
  180. package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts.map +1 -0
  181. package/dist/modules/rendering/SegmentPaintRegionResolver.js +47 -0
  182. package/dist/modules/rendering/SegmentPaintRegionResolver.js.map +1 -0
  183. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts +58 -0
  184. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts.map +1 -0
  185. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js +132 -0
  186. package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js.map +1 -0
  187. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +111 -0
  188. package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -0
  189. package/dist/modules/rendering/SubtitleFrameRenderer.js +2 -0
  190. package/dist/modules/rendering/SubtitleFrameRenderer.js.map +1 -0
  191. package/dist/modules/rendering/VideoFrameLayerClass.d.ts +21 -0
  192. package/dist/modules/rendering/VideoFrameLayerClass.d.ts.map +1 -0
  193. package/dist/modules/rendering/VideoFrameLayerClass.js +21 -0
  194. package/dist/modules/rendering/VideoFrameLayerClass.js.map +1 -0
  195. package/dist/modules/rendering/VideoFrameSource.d.ts +29 -0
  196. package/dist/modules/rendering/VideoFrameSource.d.ts.map +1 -0
  197. package/dist/modules/rendering/VideoFrameSource.js +2 -0
  198. package/dist/modules/rendering/VideoFrameSource.js.map +1 -0
  199. package/dist/modules/rendering/index.d.ts +14 -0
  200. package/dist/modules/rendering/index.d.ts.map +1 -0
  201. package/dist/modules/rendering/index.js +6 -0
  202. package/dist/modules/rendering/index.js.map +1 -0
  203. package/dist/modules/splitting/BalancedLineSplitter.d.ts +24 -0
  204. package/dist/modules/splitting/BalancedLineSplitter.d.ts.map +1 -0
  205. package/dist/modules/splitting/BalancedLineSplitter.js +81 -0
  206. package/dist/modules/splitting/BalancedLineSplitter.js.map +1 -0
  207. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts +31 -0
  208. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts.map +1 -0
  209. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js +99 -0
  210. package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js.map +1 -0
  211. package/dist/modules/splitting/BoundarySegmentSplitter.d.ts +19 -0
  212. package/dist/modules/splitting/BoundarySegmentSplitter.d.ts.map +1 -0
  213. package/dist/modules/splitting/BoundarySegmentSplitter.js +38 -0
  214. package/dist/modules/splitting/BoundarySegmentSplitter.js.map +1 -0
  215. package/dist/modules/splitting/CompositeSegmentSplitter.d.ts +8 -0
  216. package/dist/modules/splitting/CompositeSegmentSplitter.d.ts.map +1 -0
  217. package/dist/modules/splitting/CompositeSegmentSplitter.js +12 -0
  218. package/dist/modules/splitting/CompositeSegmentSplitter.js.map +1 -0
  219. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts +56 -0
  220. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts.map +1 -0
  221. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js +197 -0
  222. package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js.map +1 -0
  223. package/dist/modules/splitting/GraphemeWordSplitter.d.ts +11 -0
  224. package/dist/modules/splitting/GraphemeWordSplitter.d.ts.map +1 -0
  225. package/dist/modules/splitting/GraphemeWordSplitter.js +12 -0
  226. package/dist/modules/splitting/GraphemeWordSplitter.js.map +1 -0
  227. package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts +15 -0
  228. package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts.map +1 -0
  229. package/dist/modules/splitting/LimitByCharsSegmentSplitter.js +64 -0
  230. package/dist/modules/splitting/LimitByCharsSegmentSplitter.js.map +1 -0
  231. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts +30 -0
  232. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts.map +1 -0
  233. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js +66 -0
  234. package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js.map +1 -0
  235. package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts +12 -0
  236. package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts.map +1 -0
  237. package/dist/modules/splitting/LimitByWordsSegmentSplitter.js +25 -0
  238. package/dist/modules/splitting/LimitByWordsSegmentSplitter.js.map +1 -0
  239. package/dist/modules/splitting/LineSplitter.d.ts +10 -0
  240. package/dist/modules/splitting/LineSplitter.d.ts.map +1 -0
  241. package/dist/modules/splitting/LineSplitter.js +2 -0
  242. package/dist/modules/splitting/LineSplitter.js.map +1 -0
  243. package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts +24 -0
  244. package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts.map +1 -0
  245. package/dist/modules/splitting/PauseBasedSegmentSplitter.js +43 -0
  246. package/dist/modules/splitting/PauseBasedSegmentSplitter.js.map +1 -0
  247. package/dist/modules/splitting/SegmentSplitter.d.ts +10 -0
  248. package/dist/modules/splitting/SegmentSplitter.d.ts.map +1 -0
  249. package/dist/modules/splitting/SegmentSplitter.js +2 -0
  250. package/dist/modules/splitting/SegmentSplitter.js.map +1 -0
  251. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts +17 -0
  252. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts.map +1 -0
  253. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js +46 -0
  254. package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js.map +1 -0
  255. package/dist/modules/splitting/TextMeasurer.d.ts +15 -0
  256. package/dist/modules/splitting/TextMeasurer.d.ts.map +1 -0
  257. package/dist/modules/splitting/TextMeasurer.js +2 -0
  258. package/dist/modules/splitting/TextMeasurer.js.map +1 -0
  259. package/dist/modules/splitting/WordSplitter.d.ts +8 -0
  260. package/dist/modules/splitting/WordSplitter.d.ts.map +1 -0
  261. package/dist/modules/splitting/WordSplitter.js +2 -0
  262. package/dist/modules/splitting/WordSplitter.js.map +1 -0
  263. package/dist/modules/splitting/index.d.ts +24 -0
  264. package/dist/modules/splitting/index.d.ts.map +1 -0
  265. package/dist/modules/splitting/index.js +12 -0
  266. package/dist/modules/splitting/index.js.map +1 -0
  267. package/dist/modules/svg-filter/SvgFilter.d.ts +16 -0
  268. package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -0
  269. package/dist/modules/svg-filter/SvgFilter.js +28 -0
  270. package/dist/modules/svg-filter/SvgFilter.js.map +1 -0
  271. package/dist/modules/svg-filter/SvgFilterBundle.d.ts +16 -0
  272. package/dist/modules/svg-filter/SvgFilterBundle.d.ts.map +1 -0
  273. package/dist/modules/svg-filter/SvgFilterBundle.js +20 -0
  274. package/dist/modules/svg-filter/SvgFilterBundle.js.map +1 -0
  275. package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts +16 -0
  276. package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts.map +1 -0
  277. package/dist/modules/svg-filter/SvgFilterDefinitions.js +25 -0
  278. package/dist/modules/svg-filter/SvgFilterDefinitions.js.map +1 -0
  279. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts +21 -0
  280. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts.map +1 -0
  281. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js +50 -0
  282. package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js.map +1 -0
  283. package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts +17 -0
  284. package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts.map +1 -0
  285. package/dist/modules/svg-filter/SvgFilterLengthResolver.js +27 -0
  286. package/dist/modules/svg-filter/SvgFilterLengthResolver.js.map +1 -0
  287. package/dist/modules/svg-filter/SvgFilterScope.d.ts +18 -0
  288. package/dist/modules/svg-filter/SvgFilterScope.d.ts.map +1 -0
  289. package/dist/modules/svg-filter/SvgFilterScope.js +28 -0
  290. package/dist/modules/svg-filter/SvgFilterScope.js.map +1 -0
  291. package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts +52 -0
  292. package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts.map +1 -0
  293. package/dist/modules/svg-filter/SvgFilterScopeProvider.js +2 -0
  294. package/dist/modules/svg-filter/SvgFilterScopeProvider.js.map +1 -0
  295. package/dist/modules/svg-filter/SvgFilterScoper.d.ts +60 -0
  296. package/dist/modules/svg-filter/SvgFilterScoper.d.ts.map +1 -0
  297. package/dist/modules/svg-filter/SvgFilterScoper.js +58 -0
  298. package/dist/modules/svg-filter/SvgFilterScoper.js.map +1 -0
  299. package/dist/modules/svg-filter/index.d.ts +10 -0
  300. package/dist/modules/svg-filter/index.d.ts.map +1 -0
  301. package/dist/modules/svg-filter/index.js +8 -0
  302. package/dist/modules/svg-filter/index.js.map +1 -0
  303. package/dist/modules/tagging/RegexTagger.d.ts +11 -0
  304. package/dist/modules/tagging/RegexTagger.d.ts.map +1 -0
  305. package/dist/modules/tagging/RegexTagger.js +32 -0
  306. package/dist/modules/tagging/RegexTagger.js.map +1 -0
  307. package/dist/modules/tagging/SpanTagger.d.ts +25 -0
  308. package/dist/modules/tagging/SpanTagger.d.ts.map +1 -0
  309. package/dist/modules/tagging/SpanTagger.js +73 -0
  310. package/dist/modules/tagging/SpanTagger.js.map +1 -0
  311. package/dist/modules/tagging/StructureTagger.d.ts +20 -0
  312. package/dist/modules/tagging/StructureTagger.d.ts.map +1 -0
  313. package/dist/modules/tagging/StructureTagger.js +74 -0
  314. package/dist/modules/tagging/StructureTagger.js.map +1 -0
  315. package/dist/modules/tagging/Tagger.d.ts +5 -0
  316. package/dist/modules/tagging/Tagger.d.ts.map +1 -0
  317. package/dist/modules/tagging/Tagger.js +5 -0
  318. package/dist/modules/tagging/Tagger.js.map +1 -0
  319. package/dist/modules/tagging/WordlistTagger.d.ts +11 -0
  320. package/dist/modules/tagging/WordlistTagger.d.ts.map +1 -0
  321. package/dist/modules/tagging/WordlistTagger.js +31 -0
  322. package/dist/modules/tagging/WordlistTagger.js.map +1 -0
  323. package/dist/modules/tagging/index.d.ts +6 -0
  324. package/dist/modules/tagging/index.d.ts.map +1 -0
  325. package/dist/modules/tagging/index.js +6 -0
  326. package/dist/modules/tagging/index.js.map +1 -0
  327. package/dist/modules/transcription/AudioDecoder.d.ts +11 -0
  328. package/dist/modules/transcription/AudioDecoder.d.ts.map +1 -0
  329. package/dist/modules/transcription/AudioDecoder.js +2 -0
  330. package/dist/modules/transcription/AudioDecoder.js.map +1 -0
  331. package/dist/modules/transcription/BrowserAudioDecoder.d.ts +13 -0
  332. package/dist/modules/transcription/BrowserAudioDecoder.d.ts.map +1 -0
  333. package/dist/modules/transcription/BrowserAudioDecoder.js +34 -0
  334. package/dist/modules/transcription/BrowserAudioDecoder.js.map +1 -0
  335. package/dist/modules/transcription/PassthroughTranscriber.d.ts +20 -0
  336. package/dist/modules/transcription/PassthroughTranscriber.d.ts.map +1 -0
  337. package/dist/modules/transcription/PassthroughTranscriber.js +23 -0
  338. package/dist/modules/transcription/PassthroughTranscriber.js.map +1 -0
  339. package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts +12 -0
  340. package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts.map +1 -0
  341. package/dist/modules/transcription/PreDecodedAudioDecoder.js +14 -0
  342. package/dist/modules/transcription/PreDecodedAudioDecoder.js.map +1 -0
  343. package/dist/modules/transcription/SrtTranscriber.d.ts +33 -0
  344. package/dist/modules/transcription/SrtTranscriber.d.ts.map +1 -0
  345. package/dist/modules/transcription/SrtTranscriber.js +111 -0
  346. package/dist/modules/transcription/SrtTranscriber.js.map +1 -0
  347. package/dist/modules/transcription/Transcriber.d.ts +23 -0
  348. package/dist/modules/transcription/Transcriber.d.ts.map +1 -0
  349. package/dist/modules/transcription/Transcriber.js +2 -0
  350. package/dist/modules/transcription/Transcriber.js.map +1 -0
  351. package/dist/modules/transcription/WhisperTranscriber.d.ts +44 -0
  352. package/dist/modules/transcription/WhisperTranscriber.d.ts.map +1 -0
  353. package/dist/modules/transcription/WhisperTranscriber.js +162 -0
  354. package/dist/modules/transcription/WhisperTranscriber.js.map +1 -0
  355. package/dist/modules/transcription/index.d.ts +8 -0
  356. package/dist/modules/transcription/index.d.ts.map +1 -0
  357. package/dist/modules/transcription/index.js +6 -0
  358. package/dist/modules/transcription/index.js.map +1 -0
  359. package/dist/modules/video/RenderJob.d.ts +95 -0
  360. package/dist/modules/video/RenderJob.d.ts.map +1 -0
  361. package/dist/modules/video/RenderJob.js +2 -0
  362. package/dist/modules/video/RenderJob.js.map +1 -0
  363. package/dist/modules/video/VideoRenderer.d.ts +5 -0
  364. package/dist/modules/video/VideoRenderer.d.ts.map +1 -0
  365. package/dist/modules/video/VideoRenderer.js +2 -0
  366. package/dist/modules/video/VideoRenderer.js.map +1 -0
  367. package/dist/modules/video/index.d.ts +33 -0
  368. package/dist/modules/video/index.d.ts.map +1 -0
  369. package/dist/modules/video/index.js +17 -0
  370. package/dist/modules/video/index.js.map +1 -0
  371. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts +69 -0
  372. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts.map +1 -0
  373. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js +206 -0
  374. package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js.map +1 -0
  375. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts +24 -0
  376. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts.map +1 -0
  377. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js +2 -0
  378. package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js.map +1 -0
  379. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts +20 -0
  380. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts.map +1 -0
  381. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js +2 -0
  382. package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js.map +1 -0
  383. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts +11 -0
  384. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts.map +1 -0
  385. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js +32 -0
  386. package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js.map +1 -0
  387. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts +12 -0
  388. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts.map +1 -0
  389. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js +14 -0
  390. package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js.map +1 -0
  391. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts +28 -0
  392. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts.map +1 -0
  393. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js +52 -0
  394. package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js.map +1 -0
  395. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts +25 -0
  396. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts.map +1 -0
  397. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js +52 -0
  398. package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js.map +1 -0
  399. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts +32 -0
  400. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts.map +1 -0
  401. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js +60 -0
  402. package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js.map +1 -0
  403. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts +27 -0
  404. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts.map +1 -0
  405. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js +72 -0
  406. package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js.map +1 -0
  407. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts +32 -0
  408. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts.map +1 -0
  409. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js +2 -0
  410. package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js.map +1 -0
  411. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts +25 -0
  412. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts.map +1 -0
  413. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js +37 -0
  414. package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js.map +1 -0
  415. package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts +32 -0
  416. package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts.map +1 -0
  417. package/dist/modules/video/mediabunny/codec/CodecPolicy.js +2 -0
  418. package/dist/modules/video/mediabunny/codec/CodecPolicy.js.map +1 -0
  419. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts +59 -0
  420. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts.map +1 -0
  421. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js +110 -0
  422. package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js.map +1 -0
  423. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts +27 -0
  424. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts.map +1 -0
  425. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js +44 -0
  426. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js.map +1 -0
  427. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts +10 -0
  428. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts.map +1 -0
  429. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js +15 -0
  430. package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js.map +1 -0
  431. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts +29 -0
  432. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts.map +1 -0
  433. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js +2 -0
  434. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js.map +1 -0
  435. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts +16 -0
  436. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts.map +1 -0
  437. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js +2 -0
  438. package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js.map +1 -0
  439. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +25 -0
  440. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +1 -0
  441. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +74 -0
  442. package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +1 -0
  443. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts +26 -0
  444. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts.map +1 -0
  445. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js +147 -0
  446. package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js.map +1 -0
  447. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts +12 -0
  448. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts.map +1 -0
  449. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js +25 -0
  450. package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js.map +1 -0
  451. package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts +30 -0
  452. package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts.map +1 -0
  453. package/dist/modules/video/mediabunny/frame/FrameCompositor.js +2 -0
  454. package/dist/modules/video/mediabunny/frame/FrameCompositor.js.map +1 -0
  455. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts +44 -0
  456. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts.map +1 -0
  457. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js +334 -0
  458. package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js.map +1 -0
  459. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts +10 -0
  460. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts.map +1 -0
  461. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js +17 -0
  462. package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js.map +1 -0
  463. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts +30 -0
  464. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts.map +1 -0
  465. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js +2 -0
  466. package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js.map +1 -0
  467. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts +22 -0
  468. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts.map +1 -0
  469. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js +2 -0
  470. package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js.map +1 -0
  471. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts +17 -0
  472. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts.map +1 -0
  473. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js +48 -0
  474. package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js.map +1 -0
  475. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts +11 -0
  476. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts.map +1 -0
  477. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js +22 -0
  478. package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js.map +1 -0
  479. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts +27 -0
  480. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts.map +1 -0
  481. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js +2 -0
  482. package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js.map +1 -0
  483. package/package.json +67 -0
@@ -0,0 +1,316 @@
1
+ export class Profiler {
2
+ /**
3
+ * Master switch. While `false`, {@link record} and {@link time} are no-ops
4
+ * (timing source is not even read), so manual `profiler.time(...)` calls
5
+ * can be left in production code at zero cost. The various `wrap` methods
6
+ * flip this to `true` automatically.
7
+ */
8
+ enabled = false;
9
+ /** Sample `performance.memory.usedJSHeapSize` around each call. Chrome-only. */
10
+ measureMemory;
11
+ samples = new Map();
12
+ memDeltas = new Map();
13
+ memSamples = new Map();
14
+ originals = new WeakMap();
15
+ warnOverMs;
16
+ maxSamplesPerLabel;
17
+ constructor(opts = {}) {
18
+ this.measureMemory = opts.measureMemory ?? false;
19
+ this.warnOverMs = opts.warnOverMs ?? Infinity;
20
+ this.maxSamplesPerLabel = opts.maxSamplesPerLabel ?? 10000;
21
+ }
22
+ /**
23
+ * Wraps `target` in a `Proxy` that times every method call. The returned
24
+ * value is a stand-in for `target`: pass it where you would have passed
25
+ * the original. The original instance keeps working unchanged.
26
+ */
27
+ wrap(target, opts = {}) {
28
+ this.enabled = true;
29
+ const className = opts.name ?? target.constructor?.name ?? 'anonymous';
30
+ const include = toPredicate(opts.include);
31
+ const exclude = toPredicate(opts.exclude);
32
+ const wrapped = new Map();
33
+ const get = (obj, prop, receiver) => {
34
+ const value = Reflect.get(obj, prop, receiver);
35
+ if (typeof prop !== 'string' || typeof value !== 'function' || prop === 'constructor') {
36
+ return value;
37
+ }
38
+ const fn = value;
39
+ if (include && !include(prop))
40
+ return fn.bind(obj);
41
+ if (exclude && exclude(prop))
42
+ return fn.bind(obj);
43
+ let cached = wrapped.get(prop);
44
+ if (!cached) {
45
+ const label = `${className}.${prop}`;
46
+ cached = this.wrapMethod(fn.bind(obj), label);
47
+ wrapped.set(prop, cached);
48
+ }
49
+ return cached;
50
+ };
51
+ return new Proxy(target, { get });
52
+ }
53
+ /**
54
+ * Replaces every method on `Klass.prototype` with a timed version. All
55
+ * instances — past and future — pick up the instrumentation, because the
56
+ * prototype lookup is dynamic. Use {@link restoreClass} to undo.
57
+ */
58
+ wrapClass(Klass, opts = {}) {
59
+ this.enabled = true;
60
+ const proto = Klass.prototype;
61
+ if (!proto)
62
+ return;
63
+ const className = opts.name ?? Klass.name ?? 'anonymous';
64
+ const include = toPredicate(opts.include);
65
+ const exclude = toPredicate(opts.exclude);
66
+ let saved = this.originals.get(proto);
67
+ if (!saved) {
68
+ saved = new Map();
69
+ this.originals.set(proto, saved);
70
+ }
71
+ const chain = [proto];
72
+ if (opts.includeInherited) {
73
+ let p = Object.getPrototypeOf(proto);
74
+ while (p && p !== Object.prototype) {
75
+ chain.push(p);
76
+ p = Object.getPrototypeOf(p);
77
+ }
78
+ }
79
+ for (const target of chain) {
80
+ for (const key of Object.getOwnPropertyNames(target)) {
81
+ if (key === 'constructor')
82
+ continue;
83
+ if (include && !include(key))
84
+ continue;
85
+ if (exclude && exclude(key))
86
+ continue;
87
+ const descriptor = Object.getOwnPropertyDescriptor(target, key);
88
+ if (!descriptor || typeof descriptor.value !== 'function')
89
+ continue;
90
+ if (saved.has(key))
91
+ continue;
92
+ saved.set(key, descriptor);
93
+ const original = descriptor.value;
94
+ const label = `${className}.${key}`;
95
+ const wrappedFn = this.wrapMethod(original, label);
96
+ Object.defineProperty(target, key, {
97
+ ...descriptor,
98
+ value: wrappedFn,
99
+ });
100
+ }
101
+ }
102
+ }
103
+ /**
104
+ * Restores a class previously instrumented via {@link wrapClass} to its
105
+ * original prototype methods.
106
+ */
107
+ restoreClass(Klass) {
108
+ const proto = Klass.prototype;
109
+ if (!proto)
110
+ return;
111
+ const saved = this.originals.get(proto);
112
+ if (!saved)
113
+ return;
114
+ for (const [key, descriptor] of saved) {
115
+ Object.defineProperty(proto, key, descriptor);
116
+ }
117
+ this.originals.delete(proto);
118
+ }
119
+ /**
120
+ * Wraps every class exported by a module namespace (`import * as M from '...'`).
121
+ * Returns the list of class names that were instrumented, for quick sanity
122
+ * checks. The namespace object itself is not mutated — only the prototypes
123
+ * of the classes it references.
124
+ */
125
+ wrapNamespace(ns, opts = {}) {
126
+ const classFilter = toPredicate(opts.classFilter);
127
+ const touched = [];
128
+ for (const key of Object.keys(ns)) {
129
+ const value = ns[key];
130
+ if (!isClass(value))
131
+ continue;
132
+ if (classFilter && !classFilter(key))
133
+ continue;
134
+ this.wrapClass(value, { ...opts, name: opts.name ?? key });
135
+ touched.push(key);
136
+ }
137
+ return touched;
138
+ }
139
+ /** Times an arbitrary function — sync or async. Escape hatch for non-method code. */
140
+ time(label, fn) {
141
+ if (!this.enabled)
142
+ return fn();
143
+ const start = performance.now();
144
+ const startMem = this.startMem();
145
+ try {
146
+ const result = fn();
147
+ if (isPromiseLike(result)) {
148
+ return Promise.resolve(result).finally(() => {
149
+ this.record(label, performance.now() - start, this.endMem(startMem));
150
+ });
151
+ }
152
+ this.record(label, performance.now() - start, this.endMem(startMem));
153
+ return result;
154
+ }
155
+ catch (e) {
156
+ this.record(label, performance.now() - start, this.endMem(startMem));
157
+ throw e;
158
+ }
159
+ }
160
+ /** Records a manual measurement. Useful for instrumenting points that aren't whole methods. */
161
+ record(label, durationMs, deltaBytes = null) {
162
+ if (!this.enabled)
163
+ return;
164
+ let arr = this.samples.get(label);
165
+ if (!arr) {
166
+ arr = [];
167
+ this.samples.set(label, arr);
168
+ }
169
+ if (arr.length < this.maxSamplesPerLabel)
170
+ arr.push(durationMs);
171
+ if (deltaBytes !== null && this.measureMemory) {
172
+ this.memDeltas.set(label, (this.memDeltas.get(label) ?? 0) + deltaBytes);
173
+ this.memSamples.set(label, (this.memSamples.get(label) ?? 0) + 1);
174
+ }
175
+ if (durationMs >= this.warnOverMs) {
176
+ console.warn(`[profiler] slow call: ${label} took ${durationMs.toFixed(2)}ms`);
177
+ }
178
+ }
179
+ /** Builds an aggregated report from the samples collected so far. */
180
+ report() {
181
+ const stats = [];
182
+ let totalCalls = 0;
183
+ let totalMs = 0;
184
+ for (const [label, samples] of this.samples) {
185
+ if (samples.length === 0)
186
+ continue;
187
+ const sorted = [...samples].sort((a, b) => a - b);
188
+ const sum = sorted.reduce((acc, v) => acc + v, 0);
189
+ const memTotal = this.memDeltas.get(label);
190
+ stats.push({
191
+ label,
192
+ count: sorted.length,
193
+ totalMs: sum,
194
+ meanMs: sum / sorted.length,
195
+ minMs: sorted[0],
196
+ maxMs: sorted[sorted.length - 1],
197
+ p50Ms: percentile(sorted, 0.5),
198
+ p95Ms: percentile(sorted, 0.95),
199
+ p99Ms: percentile(sorted, 0.99),
200
+ totalDeltaBytes: memTotal ?? null,
201
+ });
202
+ totalCalls += sorted.length;
203
+ totalMs += sum;
204
+ }
205
+ return { stats, totalCalls, totalMs };
206
+ }
207
+ /** Pretty-prints the report as a sortable `console.table`. */
208
+ printReport(opts = {}) {
209
+ const report = this.report();
210
+ const sortBy = opts.sortBy ?? 'totalMs';
211
+ const top = opts.top ?? report.stats.length;
212
+ const sorted = [...report.stats].sort((a, b) => b[sortBy] - a[sortBy]);
213
+ const rows = sorted.slice(0, top).map((s) => ({
214
+ label: s.label,
215
+ count: s.count,
216
+ totalMs: round(s.totalMs),
217
+ meanMs: round(s.meanMs),
218
+ p50: round(s.p50Ms),
219
+ p95: round(s.p95Ms),
220
+ p99: round(s.p99Ms),
221
+ maxMs: round(s.maxMs),
222
+ memMB: s.totalDeltaBytes !== null ? round(s.totalDeltaBytes / 1024 / 1024) : '—',
223
+ }));
224
+ console.groupCollapsed(`[profiler] ${report.totalCalls} calls, ${round(report.totalMs)}ms total`);
225
+ console.table(rows);
226
+ console.groupEnd();
227
+ }
228
+ reset() {
229
+ this.samples.clear();
230
+ this.memDeltas.clear();
231
+ this.memSamples.clear();
232
+ }
233
+ /**
234
+ * Returns the V8 JS heap size in bytes (Chrome only). Note: this is the JS
235
+ * isolate's used heap only — it excludes WebCodecs buffers, decoded bitmap
236
+ * caches, and other native memory held by the renderer process.
237
+ *
238
+ * When the runtime was started with `--js-flags="--expose-gc"`, this forces
239
+ * a synchronous full GC before reading so what's left is the actually-retained
240
+ * portion. Without that flag, returns the heap as-is.
241
+ */
242
+ snapshotHeap() {
243
+ const w = globalThis;
244
+ w.gc?.();
245
+ return readHeapBytes();
246
+ }
247
+ wrapMethod(fn, label) {
248
+ const record = (durationMs, delta) => this.record(label, durationMs, delta);
249
+ const startMem = () => this.startMem();
250
+ const endMem = (start) => this.endMem(start);
251
+ return function wrappedMethod(...args) {
252
+ const start = performance.now();
253
+ const mStart = startMem();
254
+ try {
255
+ const result = fn.apply(this, args);
256
+ if (isPromiseLike(result)) {
257
+ return Promise.resolve(result).finally(() => {
258
+ record(performance.now() - start, endMem(mStart));
259
+ });
260
+ }
261
+ record(performance.now() - start, endMem(mStart));
262
+ return result;
263
+ }
264
+ catch (e) {
265
+ record(performance.now() - start, endMem(mStart));
266
+ throw e;
267
+ }
268
+ };
269
+ }
270
+ startMem() {
271
+ if (!this.measureMemory)
272
+ return null;
273
+ return readHeapBytes();
274
+ }
275
+ endMem(start) {
276
+ if (start === null)
277
+ return null;
278
+ const end = readHeapBytes();
279
+ return end === null ? null : end - start;
280
+ }
281
+ }
282
+ function toPredicate(filter) {
283
+ if (!filter)
284
+ return null;
285
+ if (filter instanceof RegExp)
286
+ return (s) => filter.test(s);
287
+ return filter;
288
+ }
289
+ function isClass(value) {
290
+ if (typeof value !== 'function')
291
+ return false;
292
+ const candidate = value;
293
+ if (!candidate.prototype)
294
+ return false;
295
+ const name = candidate.name;
296
+ return !!name && /^[A-Z]/.test(name);
297
+ }
298
+ function isPromiseLike(value) {
299
+ return !!value && typeof value.then === 'function';
300
+ }
301
+ function percentile(sorted, q) {
302
+ if (sorted.length === 0)
303
+ return 0;
304
+ const idx = Math.min(sorted.length - 1, Math.floor(q * sorted.length));
305
+ return sorted[idx];
306
+ }
307
+ function round(n) {
308
+ return Math.round(n * 100) / 100;
309
+ }
310
+ function readHeapBytes() {
311
+ const perf = performance;
312
+ return perf.memory ? perf.memory.usedJSHeapSize : null;
313
+ }
314
+ /** Default instance — share across modules to aggregate a single report. */
315
+ export const profiler = new Profiler();
316
+ //# sourceMappingURL=Profiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Profiler.js","sourceRoot":"","sources":["../../../src/modules/profiling/Profiler.ts"],"names":[],"mappings":"AA2BA,MAAM,OAAO,QAAQ;IACnB;;;;;OAKG;IACH,OAAO,GAAG,KAAK,CAAC;IAChB,gFAAgF;IAChF,aAAa,CAAU;IAEN,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,SAAS,GAAG,IAAI,OAAO,EAA2C,CAAC;IACnE,UAAU,CAAS;IACnB,kBAAkB,CAAS;IAE5C,YAAY,OAAwB,EAAE;QACpC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,KAAK,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC;QAC9C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,IAAI,KAAK,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAmB,MAAS,EAAE,OAAoB,EAAE;QACtD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,WAAW,CAAC;QACvE,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiB,CAAC;QAEzC,MAAM,GAAG,GAAG,CAAC,GAAM,EAAE,IAAqB,EAAE,QAAiB,EAAW,EAAE;YACxE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,E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AAE,CAAS;IAC7C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC,GAAG,CAAE,CAAC;AACtB,CAAC;AAED,SAAS,KAAK,CAAC,CAAS;IACtB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACnC,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,IAAI,GAAG,WAAoE,CAAC;IAClF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Profiler, profiler, type ProfilerOptions, type WrapOptions, type NamespaceWrapOptions, type MethodStat, type ProfilerReport, type PrintOptions, } from '../profiling/Profiler';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/profiling/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Profiler, profiler, } from '../profiling/Profiler';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/profiling/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,GAOT,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,21 @@
1
+ export type VerticalAlign = 'top' | 'center' | 'bottom';
2
+ export type HorizontalAlign = 'left' | 'center' | 'right';
3
+ /**
4
+ * Symmetric box-anchor positioning. `*Offset` is the absolute position of
5
+ * the anchor point as a fraction of the video's dimensions; `*Align`
6
+ * decides which edge of the caption box lands on that point:
7
+ * top/left → 0% of own size
8
+ * center → 50%
9
+ * bottom/right → 100%
10
+ *
11
+ * E.g. `verticalOffset: 1, verticalAlign: 'bottom'` pins the box's bottom
12
+ * edge to the video's bottom edge. `horizontalOffset: 0.5,
13
+ * horizontalAlign: 'center'` centers the box horizontally.
14
+ */
15
+ export interface AlignmentConfig {
16
+ verticalAlign: VerticalAlign;
17
+ verticalOffset: number;
18
+ horizontalAlign: HorizontalAlign;
19
+ horizontalOffset: number;
20
+ }
21
+ //# sourceMappingURL=AlignmentConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlignmentConfig.d.ts","sourceRoot":"","sources":["../../../src/modules/rendering/AlignmentConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,aAAa,CAAC;IAE7B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IAEjC,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AlignmentConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlignmentConfig.js","sourceRoot":"","sources":["../../../src/modules/rendering/AlignmentConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /** Per-side box lengths as CSS length tokens (`"0.5em"`, `"10px"`, `"2cqh"`, …). */
2
+ export interface BoxEdges {
3
+ readonly top: string;
4
+ readonly right: string;
5
+ readonly bottom: string;
6
+ readonly left: string;
7
+ }
8
+ //# sourceMappingURL=BoxEdges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BoxEdges.d.ts","sourceRoot":"","sources":["../../../src/modules/rendering/BoxEdges.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BoxEdges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BoxEdges.js","sourceRoot":"","sources":["../../../src/modules/rendering/BoxEdges.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { OverlayFrame, OverlayFrameRenderer } from '../rendering/OverlayFrameRenderer';
2
+ /**
3
+ * Renders an HTML snippet as a single SVG `foreignObject` and decodes it
4
+ * through an `<img>` so the resulting bitmap can be drawn into any 2D
5
+ * context, including OffscreenCanvas. The SVG-image sandbox keeps the
6
+ * downstream canvas untainted, which is what the export pipeline relies
7
+ * on.
8
+ */
9
+ export declare class BrowserOverlayFrameRenderer implements OverlayFrameRenderer {
10
+ render(html: string, width: number, height: number): Promise<OverlayFrame>;
11
+ }
12
+ //# sourceMappingURL=BrowserOverlayFrameRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserOverlayFrameRenderer.d.ts","sourceRoot":"","sources":["../../../src/modules/rendering/BrowserOverlayFrameRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AAEjD;;;;;;GAMG;AACH,qBAAa,2BAA4B,YAAW,oBAAoB;IAEhE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CA0BjF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Renders an HTML snippet as a single SVG `foreignObject` and decodes it
3
+ * through an `<img>` so the resulting bitmap can be drawn into any 2D
4
+ * context, including OffscreenCanvas. The SVG-image sandbox keeps the
5
+ * downstream canvas untainted, which is what the export pipeline relies
6
+ * on.
7
+ */
8
+ export class BrowserOverlayFrameRenderer {
9
+ async render(html, width, height) {
10
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">
11
+ <foreignObject width="100%" height="100%">
12
+ <div xmlns="http://www.w3.org/1999/xhtml" style="position:relative;width:${width}px;height:${height}px;overflow:hidden;">${html}</div>
13
+ </foreignObject>
14
+ </svg>`;
15
+ const img = new Image();
16
+ img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
17
+ // decode() resolves only after the image is fully parsed AND ready to
18
+ // paint. onload fires earlier — for SVG with foreignObject + custom
19
+ // fonts, that often races ahead of font/style application.
20
+ try {
21
+ await img.decode();
22
+ }
23
+ catch (e) {
24
+ throw new Error(`Overlay render failed: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
25
+ }
26
+ return {
27
+ draw: (ctx, dx, dy, dWidth, dHeight) => ctx.drawImage(img, dx, dy, dWidth, dHeight),
28
+ };
29
+ }
30
+ }
31
+ //# sourceMappingURL=BrowserOverlayFrameRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserOverlayFrameRenderer.js","sourceRoot":"","sources":["../../../src/modules/rendering/BrowserOverlayFrameRenderer.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,MAAM,OAAO,2BAA2B;IAEtC,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,KAAa,EAAE,MAAc;QACtD,MAAM,GAAG,GAAG,kDAAkD,KAAK,aAAa,MAAM;;+EAEX,KAAK,aAAa,MAAM,wBAAwB,IAAI;;OAE5H,CAAC;QAEJ,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,GAAG,CAAC,GAAG,GAAG,oCAAoC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;QAExE,sEAAsE;QACtE,oEAAoE;QACpE,2DAA2D;QAC3D,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACb,0BAA0B,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EACtE,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC;SACpF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ import type { SubtitleFrame, SubtitleFrameRenderer, SubtitleStyle } from '../rendering/SubtitleFrameRenderer';
2
+ import type { Document } from '../document/Document';
3
+ import type { CssResourceEmbedder } from '../css/CssResourceEmbedder';
4
+ import type { WordSplitter } from '../splitting/WordSplitter';
5
+ import type { VideoFrameSource } from '../rendering/VideoFrameSource';
6
+ /**
7
+ * Browser-native `SubtitleFrameRenderer` that builds each batch as a
8
+ * single SVG holding one `foreignObject` per unique visual state, and
9
+ * decodes it through an `<img>` so the resulting bitmap paints into
10
+ * any 2D context — including OffscreenCanvas — without tainting the
11
+ * canvas.
12
+ *
13
+ * Inside a batch, timestamps that hit the same visual state collapse
14
+ * into a single sprite tile; tiles stack along the smaller dimension
15
+ * axis (portrait → row, landscape → column) so the sprite sheet stays
16
+ * under whatever sprite-length cap the host's 2D-canvas backend
17
+ * actually honors. That cap is probed empirically on first `open`
18
+ * — no public browser API surfaces it directly and reported
19
+ * limits (WebGL `MAX_TEXTURE_SIZE`, `MAX_VIEWPORT_DIMS`) bear no
20
+ * stable relationship to what `img.decode` / `drawImage` accept.
21
+ */
22
+ export declare class BrowserSubtitleFrameRenderer implements SubtitleFrameRenderer {
23
+ private readonly cssEmbedder;
24
+ private readonly wordSplitter;
25
+ private readonly maxBufferPixels;
26
+ private session;
27
+ private readonly cssScoper;
28
+ private readonly cssMinifier;
29
+ private readonly svgFilterScoper;
30
+ private width;
31
+ private height;
32
+ /**
33
+ * @param cssEmbedder Inlines external resources (fonts, images)
34
+ * referenced by each style's CSS so the resulting stylesheet is
35
+ * self-contained inside the sandboxed render SVG.
36
+ * @param wordSplitter Splits words into letter units when a style's
37
+ * `RenderingConfig.splitWordsIntoLetters` is set.
38
+ * @param maxBufferPixels Per-batch memory budget in pixels. With
39
+ * the probed sprite-length cap, drives `getMaxBatchSize`. The
40
+ * default sizes a batch to ~80 MB of pixel buffer.
41
+ */
42
+ constructor(cssEmbedder: CssResourceEmbedder, wordSplitter: WordSplitter, maxBufferPixels?: number);
43
+ open(doc: Document, styles: Readonly<Record<string, SubtitleStyle>>, width: number, height: number, videoFrameSource?: VideoFrameSource): Promise<void>;
44
+ getMaxBatchSize(): Promise<number>;
45
+ /**
46
+ * Renders a green field with a red 2×2 marker in the bottom-right
47
+ * corner at the target size, decodes it, paints it, and reads back
48
+ * the corner pixel. Some hosts decode oversize SVGs but leave the
49
+ * far edges of the raster blank — the readback catches that.
50
+ */
51
+ private testTileSize;
52
+ getFrames(timestamps: ReadonlyArray<number>): Promise<Array<SubtitleFrame | null>>;
53
+ getFrame(timestamp: number): Promise<SubtitleFrame | null>;
54
+ close(): void;
55
+ private prepareStyle;
56
+ }
57
+ //# sourceMappingURL=BrowserSubtitleFrameRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserSubtitleFrameRenderer.d.ts","sourceRoot":"","sources":["../../../src/modules/rendering/BrowserSubtitleFrameRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,aAAa,EACd,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAM3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,qCAAqC,CAAC;AA0E9F;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,4BAA6B,YAAW,qBAAqB;IAmBtE,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;IApBlC,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAAqB;IAEnC;;;;;;;;;OASG;gBAEgB,WAAW,EAAE,mBAAmB,EAChC,YAAY,EAAE,YAAY,EAC1B,eAAe,GAAE,MAAkC;IAGhE,IAAI,CACR,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,EAC/C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,gBAAgB,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