@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.
- package/LICENSE +21 -0
- package/README.md +349 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.d.ts +5 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.d.ts.map +1 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.js +41 -0
- package/dist/modules/css/BrowserCssResourceEmbedder.js.map +1 -0
- package/dist/modules/css/CssMinifier.d.ts +12 -0
- package/dist/modules/css/CssMinifier.d.ts.map +1 -0
- package/dist/modules/css/CssMinifier.js +47 -0
- package/dist/modules/css/CssMinifier.js.map +1 -0
- package/dist/modules/css/CssResourceEmbedder.d.ts +4 -0
- package/dist/modules/css/CssResourceEmbedder.d.ts.map +1 -0
- package/dist/modules/css/CssResourceEmbedder.js +2 -0
- package/dist/modules/css/CssResourceEmbedder.js.map +1 -0
- package/dist/modules/css/CssScoper.d.ts +16 -0
- package/dist/modules/css/CssScoper.d.ts.map +1 -0
- package/dist/modules/css/CssScoper.js +109 -0
- package/dist/modules/css/CssScoper.js.map +1 -0
- package/dist/modules/css/NoopCssResourceEmbedder.d.ts +12 -0
- package/dist/modules/css/NoopCssResourceEmbedder.d.ts.map +1 -0
- package/dist/modules/css/NoopCssResourceEmbedder.js +13 -0
- package/dist/modules/css/NoopCssResourceEmbedder.js.map +1 -0
- package/dist/modules/css/index.d.ts +6 -0
- package/dist/modules/css/index.d.ts.map +1 -0
- package/dist/modules/css/index.js +5 -0
- package/dist/modules/css/index.js.map +1 -0
- package/dist/modules/document/CssVariable.d.ts +46 -0
- package/dist/modules/document/CssVariable.d.ts.map +1 -0
- package/dist/modules/document/CssVariable.js +47 -0
- package/dist/modules/document/CssVariable.js.map +1 -0
- package/dist/modules/document/Document.d.ts +43 -0
- package/dist/modules/document/Document.d.ts.map +1 -0
- package/dist/modules/document/Document.js +86 -0
- package/dist/modules/document/Document.js.map +1 -0
- package/dist/modules/document/DocumentEditor.d.ts +111 -0
- package/dist/modules/document/DocumentEditor.d.ts.map +1 -0
- package/dist/modules/document/DocumentEditor.js +555 -0
- package/dist/modules/document/DocumentEditor.js.map +1 -0
- package/dist/modules/document/Letter.d.ts +17 -0
- package/dist/modules/document/Letter.d.ts.map +1 -0
- package/dist/modules/document/Letter.js +17 -0
- package/dist/modules/document/Letter.js.map +1 -0
- package/dist/modules/document/Line.d.ts +31 -0
- package/dist/modules/document/Line.d.ts.map +1 -0
- package/dist/modules/document/Line.js +94 -0
- package/dist/modules/document/Line.js.map +1 -0
- package/dist/modules/document/LineState.d.ts +6 -0
- package/dist/modules/document/LineState.d.ts.map +1 -0
- package/dist/modules/document/LineState.js +7 -0
- package/dist/modules/document/LineState.js.map +1 -0
- package/dist/modules/document/NarrationPace.d.ts +20 -0
- package/dist/modules/document/NarrationPace.d.ts.map +1 -0
- package/dist/modules/document/NarrationPace.js +60 -0
- package/dist/modules/document/NarrationPace.js.map +1 -0
- package/dist/modules/document/Section.d.ts +45 -0
- package/dist/modules/document/Section.d.ts.map +1 -0
- package/dist/modules/document/Section.js +94 -0
- package/dist/modules/document/Section.js.map +1 -0
- package/dist/modules/document/Segment.d.ts +40 -0
- package/dist/modules/document/Segment.d.ts.map +1 -0
- package/dist/modules/document/Segment.js +85 -0
- package/dist/modules/document/Segment.js.map +1 -0
- package/dist/modules/document/Tag.d.ts +24 -0
- package/dist/modules/document/Tag.d.ts.map +1 -0
- package/dist/modules/document/Tag.js +37 -0
- package/dist/modules/document/Tag.js.map +1 -0
- package/dist/modules/document/TimeFragment.d.ts +11 -0
- package/dist/modules/document/TimeFragment.d.ts.map +1 -0
- package/dist/modules/document/TimeFragment.js +29 -0
- package/dist/modules/document/TimeFragment.js.map +1 -0
- package/dist/modules/document/Word.d.ts +40 -0
- package/dist/modules/document/Word.d.ts.map +1 -0
- package/dist/modules/document/Word.js +114 -0
- package/dist/modules/document/Word.js.map +1 -0
- package/dist/modules/document/WordState.d.ts +6 -0
- package/dist/modules/document/WordState.d.ts.map +1 -0
- package/dist/modules/document/WordState.js +7 -0
- package/dist/modules/document/WordState.js.map +1 -0
- package/dist/modules/document/index.d.ts +14 -0
- package/dist/modules/document/index.d.ts.map +1 -0
- package/dist/modules/document/index.js +14 -0
- package/dist/modules/document/index.js.map +1 -0
- package/dist/modules/effect/CarryQuotesEffect.d.ts +47 -0
- package/dist/modules/effect/CarryQuotesEffect.d.ts.map +1 -0
- package/dist/modules/effect/CarryQuotesEffect.js +181 -0
- package/dist/modules/effect/CarryQuotesEffect.js.map +1 -0
- package/dist/modules/effect/Effect.d.ts +16 -0
- package/dist/modules/effect/Effect.d.ts.map +1 -0
- package/dist/modules/effect/Effect.js +2 -0
- package/dist/modules/effect/Effect.js.map +1 -0
- package/dist/modules/effect/GapFreeEffect.d.ts +24 -0
- package/dist/modules/effect/GapFreeEffect.d.ts.map +1 -0
- package/dist/modules/effect/GapFreeEffect.js +67 -0
- package/dist/modules/effect/GapFreeEffect.js.map +1 -0
- package/dist/modules/effect/RemovePunctuationEffect.d.ts +21 -0
- package/dist/modules/effect/RemovePunctuationEffect.d.ts.map +1 -0
- package/dist/modules/effect/RemovePunctuationEffect.js +52 -0
- package/dist/modules/effect/RemovePunctuationEffect.js.map +1 -0
- package/dist/modules/effect/SmartLowercaseEffect.d.ts +21 -0
- package/dist/modules/effect/SmartLowercaseEffect.d.ts.map +1 -0
- package/dist/modules/effect/SmartLowercaseEffect.js +45 -0
- package/dist/modules/effect/SmartLowercaseEffect.js.map +1 -0
- package/dist/modules/effect/SmartPunctuationEffect.d.ts +25 -0
- package/dist/modules/effect/SmartPunctuationEffect.d.ts.map +1 -0
- package/dist/modules/effect/SmartPunctuationEffect.js +68 -0
- package/dist/modules/effect/SmartPunctuationEffect.js.map +1 -0
- package/dist/modules/effect/index.d.ts +7 -0
- package/dist/modules/effect/index.d.ts.map +1 -0
- package/dist/modules/effect/index.js +6 -0
- package/dist/modules/effect/index.js.map +1 -0
- package/dist/modules/pipeline/PipelineProgress.d.ts +30 -0
- package/dist/modules/pipeline/PipelineProgress.d.ts.map +1 -0
- package/dist/modules/pipeline/PipelineProgress.js +2 -0
- package/dist/modules/pipeline/PipelineProgress.js.map +1 -0
- package/dist/modules/pipeline/RenderPipeline.d.ts +105 -0
- package/dist/modules/pipeline/RenderPipeline.d.ts.map +1 -0
- package/dist/modules/pipeline/RenderPipeline.js +232 -0
- package/dist/modules/pipeline/RenderPipeline.js.map +1 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.d.ts +143 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.d.ts.map +1 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.js +317 -0
- package/dist/modules/pipeline/RenderPipelineBuilder.js.map +1 -0
- package/dist/modules/pipeline/index.d.ts +6 -0
- package/dist/modules/pipeline/index.d.ts.map +1 -0
- package/dist/modules/pipeline/index.js +3 -0
- package/dist/modules/pipeline/index.js.map +1 -0
- package/dist/modules/profiling/Profiler.d.ts +115 -0
- package/dist/modules/profiling/Profiler.d.ts.map +1 -0
- package/dist/modules/profiling/Profiler.js +316 -0
- package/dist/modules/profiling/Profiler.js.map +1 -0
- package/dist/modules/profiling/index.d.ts +2 -0
- package/dist/modules/profiling/index.d.ts.map +1 -0
- package/dist/modules/profiling/index.js +2 -0
- package/dist/modules/profiling/index.js.map +1 -0
- package/dist/modules/rendering/AlignmentConfig.d.ts +21 -0
- package/dist/modules/rendering/AlignmentConfig.d.ts.map +1 -0
- package/dist/modules/rendering/AlignmentConfig.js +2 -0
- package/dist/modules/rendering/AlignmentConfig.js.map +1 -0
- package/dist/modules/rendering/BoxEdges.d.ts +8 -0
- package/dist/modules/rendering/BoxEdges.d.ts.map +1 -0
- package/dist/modules/rendering/BoxEdges.js +2 -0
- package/dist/modules/rendering/BoxEdges.js.map +1 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts +12 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.js +31 -0
- package/dist/modules/rendering/BrowserOverlayFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts +57 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js +775 -0
- package/dist/modules/rendering/BrowserSubtitleFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/ElementRenderOverrides.d.ts +15 -0
- package/dist/modules/rendering/ElementRenderOverrides.d.ts.map +1 -0
- package/dist/modules/rendering/ElementRenderOverrides.js +24 -0
- package/dist/modules/rendering/ElementRenderOverrides.js.map +1 -0
- package/dist/modules/rendering/InlineStyleMap.d.ts +9 -0
- package/dist/modules/rendering/InlineStyleMap.d.ts.map +1 -0
- package/dist/modules/rendering/InlineStyleMap.js +2 -0
- package/dist/modules/rendering/InlineStyleMap.js.map +1 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.d.ts +20 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.d.ts.map +1 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.js +36 -0
- package/dist/modules/rendering/LayeredSubtitleFrame.js.map +1 -0
- package/dist/modules/rendering/OverlayFrameRenderer.d.ts +27 -0
- package/dist/modules/rendering/OverlayFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/OverlayFrameRenderer.js +2 -0
- package/dist/modules/rendering/OverlayFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/RenderingConfig.d.ts +22 -0
- package/dist/modules/rendering/RenderingConfig.d.ts.map +1 -0
- package/dist/modules/rendering/RenderingConfig.js +2 -0
- package/dist/modules/rendering/RenderingConfig.js.map +1 -0
- package/dist/modules/rendering/ScopedRenderOverride.d.ts +19 -0
- package/dist/modules/rendering/ScopedRenderOverride.d.ts.map +1 -0
- package/dist/modules/rendering/ScopedRenderOverride.js +2 -0
- package/dist/modules/rendering/ScopedRenderOverride.js.map +1 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts +41 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.d.ts.map +1 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.js +47 -0
- package/dist/modules/rendering/SegmentPaintRegionResolver.js.map +1 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts +58 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.d.ts.map +1 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js +132 -0
- package/dist/modules/rendering/SegmentSubtreeHtmlBuilder.js.map +1 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.d.ts +111 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.d.ts.map +1 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.js +2 -0
- package/dist/modules/rendering/SubtitleFrameRenderer.js.map +1 -0
- package/dist/modules/rendering/VideoFrameLayerClass.d.ts +21 -0
- package/dist/modules/rendering/VideoFrameLayerClass.d.ts.map +1 -0
- package/dist/modules/rendering/VideoFrameLayerClass.js +21 -0
- package/dist/modules/rendering/VideoFrameLayerClass.js.map +1 -0
- package/dist/modules/rendering/VideoFrameSource.d.ts +29 -0
- package/dist/modules/rendering/VideoFrameSource.d.ts.map +1 -0
- package/dist/modules/rendering/VideoFrameSource.js +2 -0
- package/dist/modules/rendering/VideoFrameSource.js.map +1 -0
- package/dist/modules/rendering/index.d.ts +14 -0
- package/dist/modules/rendering/index.d.ts.map +1 -0
- package/dist/modules/rendering/index.js +6 -0
- package/dist/modules/rendering/index.js.map +1 -0
- package/dist/modules/splitting/BalancedLineSplitter.d.ts +24 -0
- package/dist/modules/splitting/BalancedLineSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/BalancedLineSplitter.js +81 -0
- package/dist/modules/splitting/BalancedLineSplitter.js.map +1 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts +31 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js +99 -0
- package/dist/modules/splitting/BalancedPixelWidthLineSplitter.js.map +1 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.d.ts +19 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.js +38 -0
- package/dist/modules/splitting/BoundarySegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.d.ts +8 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.js +12 -0
- package/dist/modules/splitting/CompositeSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts +56 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.d.ts.map +1 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js +197 -0
- package/dist/modules/splitting/DomProbeCanvasTextMeasurer.js.map +1 -0
- package/dist/modules/splitting/GraphemeWordSplitter.d.ts +11 -0
- package/dist/modules/splitting/GraphemeWordSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/GraphemeWordSplitter.js +12 -0
- package/dist/modules/splitting/GraphemeWordSplitter.js.map +1 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts +15 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.js +64 -0
- package/dist/modules/splitting/LimitByCharsSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts +30 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js +66 -0
- package/dist/modules/splitting/LimitByScaledCharsSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts +12 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.js +25 -0
- package/dist/modules/splitting/LimitByWordsSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/LineSplitter.d.ts +10 -0
- package/dist/modules/splitting/LineSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/LineSplitter.js +2 -0
- package/dist/modules/splitting/LineSplitter.js.map +1 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts +24 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.js +43 -0
- package/dist/modules/splitting/PauseBasedSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/SegmentSplitter.d.ts +10 -0
- package/dist/modules/splitting/SegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/SegmentSplitter.js +2 -0
- package/dist/modules/splitting/SegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts +17 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js +46 -0
- package/dist/modules/splitting/SpeakerChangeSegmentSplitter.js.map +1 -0
- package/dist/modules/splitting/TextMeasurer.d.ts +15 -0
- package/dist/modules/splitting/TextMeasurer.d.ts.map +1 -0
- package/dist/modules/splitting/TextMeasurer.js +2 -0
- package/dist/modules/splitting/TextMeasurer.js.map +1 -0
- package/dist/modules/splitting/WordSplitter.d.ts +8 -0
- package/dist/modules/splitting/WordSplitter.d.ts.map +1 -0
- package/dist/modules/splitting/WordSplitter.js +2 -0
- package/dist/modules/splitting/WordSplitter.js.map +1 -0
- package/dist/modules/splitting/index.d.ts +24 -0
- package/dist/modules/splitting/index.d.ts.map +1 -0
- package/dist/modules/splitting/index.js +12 -0
- package/dist/modules/splitting/index.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilter.d.ts +16 -0
- package/dist/modules/svg-filter/SvgFilter.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilter.js +28 -0
- package/dist/modules/svg-filter/SvgFilter.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterBundle.d.ts +16 -0
- package/dist/modules/svg-filter/SvgFilterBundle.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterBundle.js +20 -0
- package/dist/modules/svg-filter/SvgFilterBundle.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts +16 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.js +25 -0
- package/dist/modules/svg-filter/SvgFilterDefinitions.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts +21 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js +50 -0
- package/dist/modules/svg-filter/SvgFilterDefinitionsParser.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts +17 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.js +27 -0
- package/dist/modules/svg-filter/SvgFilterLengthResolver.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScope.d.ts +18 -0
- package/dist/modules/svg-filter/SvgFilterScope.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScope.js +28 -0
- package/dist/modules/svg-filter/SvgFilterScope.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts +52 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.js +2 -0
- package/dist/modules/svg-filter/SvgFilterScopeProvider.js.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScoper.d.ts +60 -0
- package/dist/modules/svg-filter/SvgFilterScoper.d.ts.map +1 -0
- package/dist/modules/svg-filter/SvgFilterScoper.js +58 -0
- package/dist/modules/svg-filter/SvgFilterScoper.js.map +1 -0
- package/dist/modules/svg-filter/index.d.ts +10 -0
- package/dist/modules/svg-filter/index.d.ts.map +1 -0
- package/dist/modules/svg-filter/index.js +8 -0
- package/dist/modules/svg-filter/index.js.map +1 -0
- package/dist/modules/tagging/RegexTagger.d.ts +11 -0
- package/dist/modules/tagging/RegexTagger.d.ts.map +1 -0
- package/dist/modules/tagging/RegexTagger.js +32 -0
- package/dist/modules/tagging/RegexTagger.js.map +1 -0
- package/dist/modules/tagging/SpanTagger.d.ts +25 -0
- package/dist/modules/tagging/SpanTagger.d.ts.map +1 -0
- package/dist/modules/tagging/SpanTagger.js +73 -0
- package/dist/modules/tagging/SpanTagger.js.map +1 -0
- package/dist/modules/tagging/StructureTagger.d.ts +20 -0
- package/dist/modules/tagging/StructureTagger.d.ts.map +1 -0
- package/dist/modules/tagging/StructureTagger.js +74 -0
- package/dist/modules/tagging/StructureTagger.js.map +1 -0
- package/dist/modules/tagging/Tagger.d.ts +5 -0
- package/dist/modules/tagging/Tagger.d.ts.map +1 -0
- package/dist/modules/tagging/Tagger.js +5 -0
- package/dist/modules/tagging/Tagger.js.map +1 -0
- package/dist/modules/tagging/WordlistTagger.d.ts +11 -0
- package/dist/modules/tagging/WordlistTagger.d.ts.map +1 -0
- package/dist/modules/tagging/WordlistTagger.js +31 -0
- package/dist/modules/tagging/WordlistTagger.js.map +1 -0
- package/dist/modules/tagging/index.d.ts +6 -0
- package/dist/modules/tagging/index.d.ts.map +1 -0
- package/dist/modules/tagging/index.js +6 -0
- package/dist/modules/tagging/index.js.map +1 -0
- package/dist/modules/transcription/AudioDecoder.d.ts +11 -0
- package/dist/modules/transcription/AudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/AudioDecoder.js +2 -0
- package/dist/modules/transcription/AudioDecoder.js.map +1 -0
- package/dist/modules/transcription/BrowserAudioDecoder.d.ts +13 -0
- package/dist/modules/transcription/BrowserAudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/BrowserAudioDecoder.js +34 -0
- package/dist/modules/transcription/BrowserAudioDecoder.js.map +1 -0
- package/dist/modules/transcription/PassthroughTranscriber.d.ts +20 -0
- package/dist/modules/transcription/PassthroughTranscriber.d.ts.map +1 -0
- package/dist/modules/transcription/PassthroughTranscriber.js +23 -0
- package/dist/modules/transcription/PassthroughTranscriber.js.map +1 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts +12 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.d.ts.map +1 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.js +14 -0
- package/dist/modules/transcription/PreDecodedAudioDecoder.js.map +1 -0
- package/dist/modules/transcription/SrtTranscriber.d.ts +33 -0
- package/dist/modules/transcription/SrtTranscriber.d.ts.map +1 -0
- package/dist/modules/transcription/SrtTranscriber.js +111 -0
- package/dist/modules/transcription/SrtTranscriber.js.map +1 -0
- package/dist/modules/transcription/Transcriber.d.ts +23 -0
- package/dist/modules/transcription/Transcriber.d.ts.map +1 -0
- package/dist/modules/transcription/Transcriber.js +2 -0
- package/dist/modules/transcription/Transcriber.js.map +1 -0
- package/dist/modules/transcription/WhisperTranscriber.d.ts +44 -0
- package/dist/modules/transcription/WhisperTranscriber.d.ts.map +1 -0
- package/dist/modules/transcription/WhisperTranscriber.js +162 -0
- package/dist/modules/transcription/WhisperTranscriber.js.map +1 -0
- package/dist/modules/transcription/index.d.ts +8 -0
- package/dist/modules/transcription/index.d.ts.map +1 -0
- package/dist/modules/transcription/index.js +6 -0
- package/dist/modules/transcription/index.js.map +1 -0
- package/dist/modules/video/RenderJob.d.ts +95 -0
- package/dist/modules/video/RenderJob.d.ts.map +1 -0
- package/dist/modules/video/RenderJob.js +2 -0
- package/dist/modules/video/RenderJob.js.map +1 -0
- package/dist/modules/video/VideoRenderer.d.ts +5 -0
- package/dist/modules/video/VideoRenderer.d.ts.map +1 -0
- package/dist/modules/video/VideoRenderer.js +2 -0
- package/dist/modules/video/VideoRenderer.js.map +1 -0
- package/dist/modules/video/index.d.ts +33 -0
- package/dist/modules/video/index.d.ts.map +1 -0
- package/dist/modules/video/index.js +17 -0
- package/dist/modules/video/index.js.map +1 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts +69 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js +206 -0
- package/dist/modules/video/mediabunny/MediaBunnyVideoRenderer.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts +24 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js +2 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts +20 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js +2 -0
- package/dist/modules/video/mediabunny/audio/AudioTrackBridgeFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts +11 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js +32 -0
- package/dist/modules/video/mediabunny/audio/DefaultAudioTrackBridgeFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts +12 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js +14 -0
- package/dist/modules/video/mediabunny/audio/DiscardAudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts +28 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js +52 -0
- package/dist/modules/video/mediabunny/audio/PassthroughAudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts +25 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js +52 -0
- package/dist/modules/video/mediabunny/audio/TranscodeAudioTrackBridge.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts +32 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js +60 -0
- package/dist/modules/video/mediabunny/caption/BatchedSubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts +27 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js +72 -0
- package/dist/modules/video/mediabunny/caption/ComposedSubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts +32 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js +2 -0
- package/dist/modules/video/mediabunny/caption/SubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts +25 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js +37 -0
- package/dist/modules/video/mediabunny/caption/VideoBoundSubtitleLayerSource.js.map +1 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts +32 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.js +2 -0
- package/dist/modules/video/mediabunny/codec/CodecPolicy.js.map +1 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts +59 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js +110 -0
- package/dist/modules/video/mediabunny/codec/DefaultCodecPolicy.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts +27 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js +44 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoder.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts +10 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js +15 -0
- package/dist/modules/video/mediabunny/encoder/MediaBunnyCanvasVideoTrackEncoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts +29 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js +2 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoder.js.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts +16 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js +2 -0
- package/dist/modules/video/mediabunny/encoder/VideoTrackEncoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts +25 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js +74 -0
- package/dist/modules/video/mediabunny/frame/CurrentFrameVideoSource.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts +26 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js +147 -0
- package/dist/modules/video/mediabunny/frame/CustomWebCodecsVideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts +12 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js +25 -0
- package/dist/modules/video/mediabunny/frame/DefaultVideoFrameDecoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts +30 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.js +2 -0
- package/dist/modules/video/mediabunny/frame/FrameCompositor.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts +44 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js +334 -0
- package/dist/modules/video/mediabunny/frame/HtmlVideoElementVideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts +10 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js +17 -0
- package/dist/modules/video/mediabunny/frame/LayeredFrameCompositor.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts +30 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js +2 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts +22 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js +2 -0
- package/dist/modules/video/mediabunny/frame/VideoFrameDecoderFactory.js.map +1 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts +17 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js +48 -0
- package/dist/modules/video/mediabunny/frame/WebCodecsVideoFrameDecoder.js.map +1 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts +11 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js +22 -0
- package/dist/modules/video/mediabunny/output/MediaBunnyOutputTargetBuilder.js.map +1 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts +27 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.d.ts.map +1 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js +2 -0
- package/dist/modules/video/mediabunny/output/OutputTargetBuilder.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TextMeasurer } from '../splitting/TextMeasurer';
|
|
2
|
+
export interface DomProbeCanvasTextMeasurerParams {
|
|
3
|
+
/** CSS (raw, unscoped). Cascade source for the probe. */
|
|
4
|
+
css: string;
|
|
5
|
+
/** Custom properties to apply on the probe. */
|
|
6
|
+
cssVars: Record<string, string>;
|
|
7
|
+
/** Probe container width in px. Anchors `cqw` resolution without layout. */
|
|
8
|
+
containerWidth: number;
|
|
9
|
+
/** Probe container height in px. Anchors `cqh` resolution without layout. */
|
|
10
|
+
containerHeight: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolves text width by reading typography from a persistent
|
|
14
|
+
* shadow-encapsulated DOM probe and measuring with Canvas 2D `measureText`.
|
|
15
|
+
* Effects that `measureText` does not natively apply — letter-spacing,
|
|
16
|
+
* word-spacing, padding, margin, `text-transform` — are read from the
|
|
17
|
+
* probe and added analytically.
|
|
18
|
+
*
|
|
19
|
+
* `@font-face` blocks are stripped from `css` before injection: re-applying
|
|
20
|
+
* them resets `document.fonts.status` to 'loading'.
|
|
21
|
+
*
|
|
22
|
+
* Repeated constructions with the same `(css, cssVars, container size)`
|
|
23
|
+
* reuse a previously resolved typography from a module-level cache and
|
|
24
|
+
* touch no DOM.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DomProbeCanvasTextMeasurer implements TextMeasurer {
|
|
27
|
+
private readonly _typography;
|
|
28
|
+
constructor(params: DomProbeCanvasTextMeasurerParams);
|
|
29
|
+
measure(text: string): number;
|
|
30
|
+
spaceWidth(): number;
|
|
31
|
+
private probe;
|
|
32
|
+
private signatureOf;
|
|
33
|
+
private ensureProbe;
|
|
34
|
+
private syncContainerSize;
|
|
35
|
+
private syncCss;
|
|
36
|
+
/**
|
|
37
|
+
* Diff the requested cssVars against what was last applied to the probe
|
|
38
|
+
* and write only the deltas. Each `setProperty` invalidates the style
|
|
39
|
+
* cache for the subtree, so writing unchanged values would inflate the
|
|
40
|
+
* next computed-style read for no reason.
|
|
41
|
+
*/
|
|
42
|
+
private syncCssVars;
|
|
43
|
+
private ensureCanvasContext;
|
|
44
|
+
/**
|
|
45
|
+
* Freeze the element at its final keyframe so the read reflects the
|
|
46
|
+
* resting layout. Without this, computed style for any animated
|
|
47
|
+
* layout-affecting property (font-size, letter-spacing, padding…)
|
|
48
|
+
* lands at the `0%` state.
|
|
49
|
+
*/
|
|
50
|
+
private pinAnimations;
|
|
51
|
+
private requireValue;
|
|
52
|
+
private parsePx;
|
|
53
|
+
private normalizeTextTransform;
|
|
54
|
+
private applyTransform;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=DomProbeCanvasTextMeasurer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomProbeCanvasTextMeasurer.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/DomProbeCanvasTextMeasurer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE,MAAM,WAAW,gCAAgC;IAC/C,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,eAAe,EAAE,MAAM,CAAC;CACzB;AAoCD;;;;;;;;;;;;;GAaG;AACH,qBAAa,0BAA2B,YAAW,YAAY;IAC7D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;gBAErC,MAAM,EAAE,gCAAgC;IAYpD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY7B,UAAU,IAAI,MAAM;IAMpB,OAAO,CAAC,KAAK;IAqBb,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,WAAW;IAqCnB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,OAAO;IAOf;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,mBAAmB;IAO3B;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,cAAc;CAQvB"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Segment } from '../document/Segment';
|
|
2
|
+
import { Line } from '../document/Line';
|
|
3
|
+
import { Word } from '../document/Word';
|
|
4
|
+
import { LineState } from '../document/LineState';
|
|
5
|
+
// Probe DOM is persistent and shadow-encapsulated. Re-mounting per call
|
|
6
|
+
// would invalidate the document style + layout cache, and the follow-up
|
|
7
|
+
// `getComputedStyle` read would force a synchronous flush — the very cost
|
|
8
|
+
// this class exists to avoid. The shadow boundary keeps the probe's
|
|
9
|
+
// `<style>` rules from matching elements outside the probe subtree.
|
|
10
|
+
let _styleEl = null;
|
|
11
|
+
let _container = null;
|
|
12
|
+
let _word = null;
|
|
13
|
+
let _cctx = null;
|
|
14
|
+
// Last DOM state actually applied to the probe. A subsequent call that
|
|
15
|
+
// matches a tracked value skips the corresponding write — every write
|
|
16
|
+
// invalidates the style cache and inflates the next computed-style read.
|
|
17
|
+
let _appliedCss = null;
|
|
18
|
+
let _appliedWidth = null;
|
|
19
|
+
let _appliedHeight = null;
|
|
20
|
+
let _appliedCssVars = new Map();
|
|
21
|
+
// Resolved typography keyed by the `(css, size, cssVars)` signature that
|
|
22
|
+
// produced it. Cache hits skip the probe entirely — no DOM writes, no
|
|
23
|
+
// `getComputedStyle`, no style flush.
|
|
24
|
+
const _typographyCache = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* Resolves text width by reading typography from a persistent
|
|
27
|
+
* shadow-encapsulated DOM probe and measuring with Canvas 2D `measureText`.
|
|
28
|
+
* Effects that `measureText` does not natively apply — letter-spacing,
|
|
29
|
+
* word-spacing, padding, margin, `text-transform` — are read from the
|
|
30
|
+
* probe and added analytically.
|
|
31
|
+
*
|
|
32
|
+
* `@font-face` blocks are stripped from `css` before injection: re-applying
|
|
33
|
+
* them resets `document.fonts.status` to 'loading'.
|
|
34
|
+
*
|
|
35
|
+
* Repeated constructions with the same `(css, cssVars, container size)`
|
|
36
|
+
* reuse a previously resolved typography from a module-level cache and
|
|
37
|
+
* touch no DOM.
|
|
38
|
+
*/
|
|
39
|
+
export class DomProbeCanvasTextMeasurer {
|
|
40
|
+
_typography;
|
|
41
|
+
constructor(params) {
|
|
42
|
+
const css = params.css.replace(/@font-face[^{]*\{[^}]*\}/g, '');
|
|
43
|
+
const signature = this.signatureOf(css, params);
|
|
44
|
+
const cached = _typographyCache.get(signature);
|
|
45
|
+
if (cached) {
|
|
46
|
+
this._typography = cached;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this._typography = this.probe(css, params);
|
|
50
|
+
_typographyCache.set(signature, this._typography);
|
|
51
|
+
}
|
|
52
|
+
measure(text) {
|
|
53
|
+
const t = this.applyTransform(text, this._typography.textTransform);
|
|
54
|
+
const cctx = this.ensureCanvasContext();
|
|
55
|
+
cctx.font = this._typography.font;
|
|
56
|
+
return (cctx.measureText(t).width +
|
|
57
|
+
Math.max(0, t.length - 1) * this._typography.letterSpacingPx +
|
|
58
|
+
this._typography.paddingX +
|
|
59
|
+
this._typography.marginX);
|
|
60
|
+
}
|
|
61
|
+
spaceWidth() {
|
|
62
|
+
const cctx = this.ensureCanvasContext();
|
|
63
|
+
cctx.font = this._typography.font;
|
|
64
|
+
return cctx.measureText(' ').width + this._typography.wordSpacingPx + this._typography.letterSpacingPx;
|
|
65
|
+
}
|
|
66
|
+
probe(css, params) {
|
|
67
|
+
const probe = this.ensureProbe();
|
|
68
|
+
this.syncContainerSize(probe.container, params.containerWidth, params.containerHeight);
|
|
69
|
+
this.syncCss(css);
|
|
70
|
+
this.syncCssVars(probe.container, params.cssVars);
|
|
71
|
+
const cs = getComputedStyle(probe.word);
|
|
72
|
+
const fontStyle = this.requireValue(cs.fontStyle, 'font-style');
|
|
73
|
+
const fontWeight = this.requireValue(cs.fontWeight, 'font-weight');
|
|
74
|
+
const fontSize = this.requireValue(cs.fontSize, 'font-size');
|
|
75
|
+
const fontFamily = this.requireValue(cs.fontFamily, 'font-family');
|
|
76
|
+
return {
|
|
77
|
+
font: `${fontStyle} ${fontWeight} ${fontSize} ${fontFamily}`,
|
|
78
|
+
letterSpacingPx: this.parsePx(cs.letterSpacing),
|
|
79
|
+
wordSpacingPx: this.parsePx(cs.wordSpacing),
|
|
80
|
+
paddingX: this.parsePx(cs.paddingLeft) + this.parsePx(cs.paddingRight),
|
|
81
|
+
marginX: this.parsePx(cs.marginLeft) + this.parsePx(cs.marginRight),
|
|
82
|
+
textTransform: this.normalizeTextTransform(cs.textTransform),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
signatureOf(css, params) {
|
|
86
|
+
const keys = Object.keys(params.cssVars).sort();
|
|
87
|
+
const cssVarsStr = keys.map((k) => `${k}=${params.cssVars[k]}`).join(';');
|
|
88
|
+
return `${params.containerWidth}x${params.containerHeight}|${cssVarsStr}|${css}`;
|
|
89
|
+
}
|
|
90
|
+
ensureProbe() {
|
|
91
|
+
if (_container && _word)
|
|
92
|
+
return { container: _container, word: _word };
|
|
93
|
+
const host = document.createElement('div');
|
|
94
|
+
host.style.cssText =
|
|
95
|
+
`position:fixed;left:-99999px;top:-99999px;visibility:hidden;pointer-events:none;`;
|
|
96
|
+
const shadow = host.attachShadow({ mode: 'open' });
|
|
97
|
+
_styleEl = document.createElement('style');
|
|
98
|
+
shadow.appendChild(_styleEl);
|
|
99
|
+
_container = document.createElement('div');
|
|
100
|
+
_container.style.cssText = `container-type:size;`;
|
|
101
|
+
this.pinAnimations(_container);
|
|
102
|
+
const segmentEl = document.createElement('div');
|
|
103
|
+
segmentEl.className = Segment.CSS_CLASS;
|
|
104
|
+
this.pinAnimations(segmentEl);
|
|
105
|
+
const lineEl = document.createElement('div');
|
|
106
|
+
lineEl.className = `${Line.CSS_CLASS} ${LineState.NOT_NARRATED_YET}`;
|
|
107
|
+
this.pinAnimations(lineEl);
|
|
108
|
+
_word = document.createElement('span');
|
|
109
|
+
_word.className = `${Word.CSS_CLASS} ${LineState.NOT_NARRATED_YET}`;
|
|
110
|
+
_word.textContent = 'M';
|
|
111
|
+
this.pinAnimations(_word);
|
|
112
|
+
lineEl.appendChild(_word);
|
|
113
|
+
segmentEl.appendChild(lineEl);
|
|
114
|
+
_container.appendChild(segmentEl);
|
|
115
|
+
shadow.appendChild(_container);
|
|
116
|
+
document.body.appendChild(host);
|
|
117
|
+
return { container: _container, word: _word };
|
|
118
|
+
}
|
|
119
|
+
syncContainerSize(container, width, height) {
|
|
120
|
+
if (width !== _appliedWidth) {
|
|
121
|
+
container.style.width = `${width}px`;
|
|
122
|
+
_appliedWidth = width;
|
|
123
|
+
}
|
|
124
|
+
if (height !== _appliedHeight) {
|
|
125
|
+
container.style.height = `${height}px`;
|
|
126
|
+
_appliedHeight = height;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
syncCss(css) {
|
|
130
|
+
if (css !== _appliedCss) {
|
|
131
|
+
_styleEl.textContent = css;
|
|
132
|
+
_appliedCss = css;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Diff the requested cssVars against what was last applied to the probe
|
|
137
|
+
* and write only the deltas. Each `setProperty` invalidates the style
|
|
138
|
+
* cache for the subtree, so writing unchanged values would inflate the
|
|
139
|
+
* next computed-style read for no reason.
|
|
140
|
+
*/
|
|
141
|
+
syncCssVars(container, cssVars) {
|
|
142
|
+
for (const [k, v] of Object.entries(cssVars)) {
|
|
143
|
+
if (_appliedCssVars.get(k) !== v) {
|
|
144
|
+
container.style.setProperty(k, v);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const k of _appliedCssVars.keys()) {
|
|
148
|
+
if (!(k in cssVars)) {
|
|
149
|
+
container.style.removeProperty(k);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
_appliedCssVars = new Map(Object.entries(cssVars));
|
|
153
|
+
}
|
|
154
|
+
ensureCanvasContext() {
|
|
155
|
+
if (!_cctx) {
|
|
156
|
+
_cctx = document.createElement('canvas').getContext('2d');
|
|
157
|
+
}
|
|
158
|
+
return _cctx;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Freeze the element at its final keyframe so the read reflects the
|
|
162
|
+
* resting layout. Without this, computed style for any animated
|
|
163
|
+
* layout-affecting property (font-size, letter-spacing, padding…)
|
|
164
|
+
* lands at the `0%` state.
|
|
165
|
+
*/
|
|
166
|
+
pinAnimations(el) {
|
|
167
|
+
el.style.animationPlayState = 'paused';
|
|
168
|
+
el.style.animationDelay = '-1000s';
|
|
169
|
+
el.style.animationFillMode = 'both';
|
|
170
|
+
}
|
|
171
|
+
requireValue(value, propertyName) {
|
|
172
|
+
if (!value) {
|
|
173
|
+
throw new Error(`DomProbeCanvasTextMeasurer: getComputedStyle returned empty ${propertyName} on the probe word — typography cannot be resolved.`);
|
|
174
|
+
}
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
parsePx(value) {
|
|
178
|
+
if (!value || value === 'normal')
|
|
179
|
+
return 0;
|
|
180
|
+
const n = parseFloat(value);
|
|
181
|
+
return Number.isFinite(n) ? n : 0;
|
|
182
|
+
}
|
|
183
|
+
normalizeTextTransform(value) {
|
|
184
|
+
if (value === 'uppercase' || value === 'lowercase' || value === 'capitalize')
|
|
185
|
+
return value;
|
|
186
|
+
return 'none';
|
|
187
|
+
}
|
|
188
|
+
applyTransform(text, t) {
|
|
189
|
+
switch (t) {
|
|
190
|
+
case 'uppercase': return text.toUpperCase();
|
|
191
|
+
case 'lowercase': return text.toLowerCase();
|
|
192
|
+
case 'capitalize': return text.replace(/(?:^|\s)\S/g, (c) => c.toUpperCase());
|
|
193
|
+
default: return text;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=DomProbeCanvasTextMeasurer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DomProbeCanvasTextMeasurer.js","sourceRoot":"","sources":["../../../src/modules/splitting/DomProbeCanvasTextMeasurer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAwBxD,wEAAwE;AACxE,wEAAwE;AACxE,0EAA0E;AAC1E,oEAAoE;AACpE,oEAAoE;AACpE,IAAI,QAAQ,GAA4B,IAAI,CAAC;AAC7C,IAAI,UAAU,GAAuB,IAAI,CAAC;AAC1C,IAAI,KAAK,GAAuB,IAAI,CAAC;AACrC,IAAI,KAAK,GAAoC,IAAI,CAAC;AAElD,uEAAuE;AACvE,sEAAsE;AACtE,yEAAyE;AACzE,IAAI,WAAW,GAAkB,IAAI,CAAC;AACtC,IAAI,aAAa,GAAkB,IAAI,CAAC;AACxC,IAAI,cAAc,GAAkB,IAAI,CAAC;AACzC,IAAI,eAAe,GAAwB,IAAI,GAAG,EAAE,CAAC;AAErD,yEAAyE;AACzE,sEAAsE;AACtE,sCAAsC;AACtC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,0BAA0B;IACpB,WAAW,CAAqB;IAEjD,YAAY,MAAwC;QAClD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAA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AAI,KAAK,CACb,+DAA+D,YAAY,qDAAqD,CACjI,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,OAAO,CAAC,KAAa;QAC3B,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAEO,sBAAsB,CAAC,KAAa;QAC1C,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,YAAY;YAAE,OAAO,KAAK,CAAC;QAC3F,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,cAAc,CAAC,IAAY,EAAE,CAAgB;QACnD,QAAQ,CAAC,EAAE,CAAC;YACV,KAAK,WAAW,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;YAC5C,KAAK,WAAW,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;YAC5C,KAAK,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9E,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WordSplitter } from '../splitting/WordSplitter';
|
|
2
|
+
/**
|
|
3
|
+
* Splits text into grapheme clusters — the units the user perceives as
|
|
4
|
+
* single characters. Correctly handles surrogate pairs, combining marks,
|
|
5
|
+
* ZWJ sequences, and regional-indicator flags, which `[...str]` shatters.
|
|
6
|
+
*/
|
|
7
|
+
export declare class GraphemeWordSplitter implements WordSplitter {
|
|
8
|
+
private readonly segmenter;
|
|
9
|
+
split(text: string): string[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=GraphemeWordSplitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphemeWordSplitter.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/GraphemeWordSplitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8D;IAExF,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;CAG9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits text into grapheme clusters — the units the user perceives as
|
|
3
|
+
* single characters. Correctly handles surrogate pairs, combining marks,
|
|
4
|
+
* ZWJ sequences, and regional-indicator flags, which `[...str]` shatters.
|
|
5
|
+
*/
|
|
6
|
+
export class GraphemeWordSplitter {
|
|
7
|
+
segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
8
|
+
split(text) {
|
|
9
|
+
return Array.from(this.segmenter.segment(text), (s) => s.segment);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=GraphemeWordSplitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphemeWordSplitter.js","sourceRoot":"","sources":["../../../src/modules/splitting/GraphemeWordSplitter.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACd,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;IAExF,KAAK,CAAC,IAAY;QAChB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SegmentSplitter } from '../splitting/SegmentSplitter';
|
|
2
|
+
import { Segment } from '../document/Segment';
|
|
3
|
+
export interface LimitByCharsConfig {
|
|
4
|
+
maxChars: number;
|
|
5
|
+
minChars: number;
|
|
6
|
+
minDuration: number;
|
|
7
|
+
minLastWordDuration: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class LimitByCharsSegmentSplitter implements SegmentSplitter {
|
|
10
|
+
private readonly _config;
|
|
11
|
+
constructor(_config: LimitByCharsConfig);
|
|
12
|
+
split(segments: ReadonlyArray<Segment>): Segment[];
|
|
13
|
+
private splitSegment;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=LimitByCharsSegmentSplitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LimitByCharsSegmentSplitter.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/LimitByCharsSegmentSplitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAUD,qBAAa,2BAA4B,YAAW,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAExD,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE;IAIlD,OAAO,CAAC,YAAY;CAiDrB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Segment } from '../document/Segment';
|
|
2
|
+
import { Line } from '../document/Line';
|
|
3
|
+
// Splits segments so that no segment exceeds `maxChars` characters.
|
|
4
|
+
// If the remaining words after a cut would be fewer than `minChars` characters,
|
|
5
|
+
// or their total duration would be less than `minDuration` seconds, they are
|
|
6
|
+
// absorbed into the current segment instead of forming a new one.
|
|
7
|
+
// `minLastWordDuration` (seconds) protects templates that reveal words as they
|
|
8
|
+
// are narrated: when the chunk's tail word would be on screen for less than
|
|
9
|
+
// the threshold, the cut is deferred forward one word at a time until the
|
|
10
|
+
// tail can stay long enough to be readable. Defaults to 0 (off).
|
|
11
|
+
export class LimitByCharsSegmentSplitter {
|
|
12
|
+
_config;
|
|
13
|
+
constructor(_config) {
|
|
14
|
+
this._config = _config;
|
|
15
|
+
}
|
|
16
|
+
split(segments) {
|
|
17
|
+
return segments.flatMap((segment) => this.splitSegment(segment));
|
|
18
|
+
}
|
|
19
|
+
splitSegment(segment) {
|
|
20
|
+
const { maxChars, minChars, minDuration, minLastWordDuration } = this._config;
|
|
21
|
+
const words = segment.getWords();
|
|
22
|
+
const result = [];
|
|
23
|
+
let currentChunk = [];
|
|
24
|
+
let currentLength = 0;
|
|
25
|
+
for (let i = 0; i < words.length; i++) {
|
|
26
|
+
const word = words[i];
|
|
27
|
+
const addedLength = currentLength === 0 ? word.text.length : word.text.length + 1;
|
|
28
|
+
if (currentLength + addedLength > maxChars && currentChunk.length > 0) {
|
|
29
|
+
// Defer the cut while the chunk's tail word's narration is too short
|
|
30
|
+
// to read. Each extra word pushed in becomes the new tail and gets
|
|
31
|
+
// re-evaluated against the threshold.
|
|
32
|
+
let nextIndex = i;
|
|
33
|
+
while (nextIndex < words.length &&
|
|
34
|
+
currentChunk[currentChunk.length - 1].time.duration < minLastWordDuration) {
|
|
35
|
+
currentChunk.push(words[nextIndex]);
|
|
36
|
+
nextIndex++;
|
|
37
|
+
}
|
|
38
|
+
if (nextIndex >= words.length)
|
|
39
|
+
break;
|
|
40
|
+
const remaining = words.slice(nextIndex);
|
|
41
|
+
const remainingChars = remaining.reduce((sum, w) => sum + w.text.length, 0);
|
|
42
|
+
const remainingDuration = remaining[remaining.length - 1].time.end - remaining[0].time.start;
|
|
43
|
+
if (remainingChars < minChars || remainingDuration < minDuration) {
|
|
44
|
+
currentChunk.push(...remaining);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
result.push(new Segment({ lines: [new Line({ words: currentChunk })] }));
|
|
48
|
+
const startWord = words[nextIndex];
|
|
49
|
+
currentChunk = [startWord];
|
|
50
|
+
currentLength = startWord.text.length;
|
|
51
|
+
i = nextIndex;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
currentChunk.push(word);
|
|
55
|
+
currentLength += addedLength;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (currentChunk.length > 0) {
|
|
59
|
+
result.push(new Segment({ lines: [new Line({ words: currentChunk })] }));
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=LimitByCharsSegmentSplitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LimitByCharsSegmentSplitter.js","sourceRoot":"","sources":["../../../src/modules/splitting/LimitByCharsSegmentSplitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAS9C,oEAAoE;AACpE,gFAAgF;AAChF,6EAA6E;AAC7E,kEAAkE;AAClE,+EAA+E;AAC/E,4EAA4E;AAC5E,0EAA0E;AAC1E,iEAAiE;AACjE,MAAM,OAAO,2BAA2B;IACT;IAA7B,YAA6B,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAE5D,KAAK,CAAC,QAAgC;QACpC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAA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mentSplitter } from '../splitting/SegmentSplitter';
|
|
2
|
+
import { Segment } from '../document/Segment';
|
|
3
|
+
export interface LimitByScaledCharsConfig {
|
|
4
|
+
maxChars: number;
|
|
5
|
+
minChars: number;
|
|
6
|
+
scale: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Splits segments by character count weighted by a scaling factor: each
|
|
10
|
+
* character contributes `scale` to a running budget and the segment is cut
|
|
11
|
+
* so that no chunk exceeds `maxChars`. When the tail left after a greedy
|
|
12
|
+
* cut would weigh less than `minChars`, the current chunk is shrunk word
|
|
13
|
+
* by word until the tail reaches `minChars` — provided the current chunk
|
|
14
|
+
* stays at or above `minChars` itself. Only when both bounds cannot be
|
|
15
|
+
* honoured at once (e.g. the remaining text is shorter than two
|
|
16
|
+
* `minChars` blocks) are the residual words absorbed into the current
|
|
17
|
+
* chunk as a last resort.
|
|
18
|
+
*
|
|
19
|
+
* At `scale = 1` the behaviour is identical to a plain character-count
|
|
20
|
+
* limit. A higher `scale` shrinks the effective capacity proportionally,
|
|
21
|
+
* which lets callers express "how much text per segment" once and have it
|
|
22
|
+
* adapt to whatever rendered size the text ends up at.
|
|
23
|
+
*/
|
|
24
|
+
export declare class LimitByScaledCharsSegmentSplitter implements SegmentSplitter {
|
|
25
|
+
private readonly _config;
|
|
26
|
+
constructor(_config: LimitByScaledCharsConfig);
|
|
27
|
+
split(segments: ReadonlyArray<Segment>): Segment[];
|
|
28
|
+
private splitSegment;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=LimitByScaledCharsSegmentSplitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LimitByScaledCharsSegmentSplitter.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/LimitByScaledCharsSegmentSplitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iCAAkC,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,wBAAwB;IAE9D,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE;IAIlD,OAAO,CAAC,YAAY;CA4CrB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Segment } from '../document/Segment';
|
|
2
|
+
import { Line } from '../document/Line';
|
|
3
|
+
/**
|
|
4
|
+
* Splits segments by character count weighted by a scaling factor: each
|
|
5
|
+
* character contributes `scale` to a running budget and the segment is cut
|
|
6
|
+
* so that no chunk exceeds `maxChars`. When the tail left after a greedy
|
|
7
|
+
* cut would weigh less than `minChars`, the current chunk is shrunk word
|
|
8
|
+
* by word until the tail reaches `minChars` — provided the current chunk
|
|
9
|
+
* stays at or above `minChars` itself. Only when both bounds cannot be
|
|
10
|
+
* honoured at once (e.g. the remaining text is shorter than two
|
|
11
|
+
* `minChars` blocks) are the residual words absorbed into the current
|
|
12
|
+
* chunk as a last resort.
|
|
13
|
+
*
|
|
14
|
+
* At `scale = 1` the behaviour is identical to a plain character-count
|
|
15
|
+
* limit. A higher `scale` shrinks the effective capacity proportionally,
|
|
16
|
+
* which lets callers express "how much text per segment" once and have it
|
|
17
|
+
* adapt to whatever rendered size the text ends up at.
|
|
18
|
+
*/
|
|
19
|
+
export class LimitByScaledCharsSegmentSplitter {
|
|
20
|
+
_config;
|
|
21
|
+
constructor(_config) {
|
|
22
|
+
this._config = _config;
|
|
23
|
+
}
|
|
24
|
+
split(segments) {
|
|
25
|
+
return segments.flatMap((segment) => this.splitSegment(segment));
|
|
26
|
+
}
|
|
27
|
+
splitSegment(segment) {
|
|
28
|
+
const { maxChars, minChars, scale } = this._config;
|
|
29
|
+
const words = segment.getWords();
|
|
30
|
+
const n = words.length;
|
|
31
|
+
if (n === 0)
|
|
32
|
+
return [];
|
|
33
|
+
const weight = (from, to) => {
|
|
34
|
+
if (to <= from)
|
|
35
|
+
return 0;
|
|
36
|
+
let chars = to - from - 1;
|
|
37
|
+
for (let k = from; k < to; k++)
|
|
38
|
+
chars += words[k].text.length;
|
|
39
|
+
return chars * scale;
|
|
40
|
+
};
|
|
41
|
+
const result = [];
|
|
42
|
+
let start = 0;
|
|
43
|
+
while (start < n) {
|
|
44
|
+
let end = start + 1;
|
|
45
|
+
while (end < n && weight(start, end + 1) <= maxChars)
|
|
46
|
+
end++;
|
|
47
|
+
if (end === n) {
|
|
48
|
+
result.push(new Segment({ lines: [new Line({ words: words.slice(start, end) })] }));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
while (weight(end, n) < minChars &&
|
|
52
|
+
end > start + 1 &&
|
|
53
|
+
weight(start, end - 1) >= minChars) {
|
|
54
|
+
end--;
|
|
55
|
+
}
|
|
56
|
+
if (weight(end, n) < minChars) {
|
|
57
|
+
result.push(new Segment({ lines: [new Line({ words: words.slice(start, n) })] }));
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
result.push(new Segment({ lines: [new Line({ words: words.slice(start, end) })] }));
|
|
61
|
+
start = end;
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=LimitByScaledCharsSegmentSplitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LimitByScaledCharsSegmentSplitter.js","sourceRoot":"","sources":["../../../src/modules/splitting/LimitByScaledCharsSegmentSplitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAQ9C;;;;;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,CAAC,EAAE,CAAC;gBACd,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACpF,MAAM;YACR,CAAC;YAED,OACE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,QAAQ;gBACzB,GAAG,GAAG,KAAK,GAAG,CAAC;gBACf,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,QAAQ,EAClC,CAAC;gBACD,GAAG,EAAE,CAAC;YACR,CAAC;YAED,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC;gBAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClF,MAAM;YACR,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACpF,KAAK,GAAG,GAAG,CAAC;QACd,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SegmentSplitter } from '../splitting/SegmentSplitter';
|
|
2
|
+
import { Segment } from '../document/Segment';
|
|
3
|
+
export interface LimitByWordsConfig {
|
|
4
|
+
maxWords: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class LimitByWordsSegmentSplitter implements SegmentSplitter {
|
|
7
|
+
private readonly _config;
|
|
8
|
+
constructor(_config: LimitByWordsConfig);
|
|
9
|
+
split(segments: ReadonlyArray<Segment>): Segment[];
|
|
10
|
+
private splitSegment;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LimitByWordsSegmentSplitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LimitByWordsSegmentSplitter.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/LimitByWordsSegmentSplitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,qBAAa,2BAA4B,YAAW,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAExD,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE;IAIlD,OAAO,CAAC,YAAY;CAYrB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Segment } from '../document/Segment';
|
|
2
|
+
import { Line } from '../document/Line';
|
|
3
|
+
// Splits segments so that no segment has more than `maxWords` words.
|
|
4
|
+
export class LimitByWordsSegmentSplitter {
|
|
5
|
+
_config;
|
|
6
|
+
constructor(_config) {
|
|
7
|
+
this._config = _config;
|
|
8
|
+
}
|
|
9
|
+
split(segments) {
|
|
10
|
+
return segments.flatMap((segment) => this.splitSegment(segment));
|
|
11
|
+
}
|
|
12
|
+
splitSegment(segment) {
|
|
13
|
+
const { maxWords } = this._config;
|
|
14
|
+
const words = segment.getWords();
|
|
15
|
+
if (words.length <= maxWords)
|
|
16
|
+
return [segment];
|
|
17
|
+
const result = [];
|
|
18
|
+
for (let i = 0; i < words.length; i += maxWords) {
|
|
19
|
+
const chunk = words.slice(i, i + maxWords);
|
|
20
|
+
result.push(new Segment({ lines: [new Line({ words: chunk })] }));
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=LimitByWordsSegmentSplitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LimitByWordsSegmentSplitter.js","sourceRoot":"","sources":["../../../src/modules/splitting/LimitByWordsSegmentSplitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAO9C,qEAAqE;AACrE,MAAM,OAAO,2BAA2B;IACT;IAA7B,YAA6B,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAE5D,KAAK,CAAC,QAAgC;QACpC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IAEO,YAAY,CAAC,OAAgB;QACnC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjC,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;YAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAc,EAAE,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAW,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Segment } from '../document/Segment';
|
|
2
|
+
/**
|
|
3
|
+
* Splits the words within each segment of a single Section into multiple
|
|
4
|
+
* Line objects based on layout constraints. Receives the segments of one
|
|
5
|
+
* Section and runs after SegmentSplitter, before StructureTagger.
|
|
6
|
+
*/
|
|
7
|
+
export interface LineSplitter {
|
|
8
|
+
split(segments: ReadonlyArray<Segment>): Segment[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=LineSplitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LineSplitter.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/LineSplitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;CACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LineSplitter.js","sourceRoot":"","sources":["../../../src/modules/splitting/LineSplitter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SegmentSplitter } from '../splitting/SegmentSplitter';
|
|
2
|
+
import { Segment } from '../document/Segment';
|
|
3
|
+
export interface PauseBasedConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Minimum gap, in seconds, between the end of one word and the start of
|
|
6
|
+
* the next that triggers a segment cut. Pauses below this threshold are
|
|
7
|
+
* left inside the current segment.
|
|
8
|
+
*/
|
|
9
|
+
minGap: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Splits segments at audible pauses between consecutive words. The cut is
|
|
13
|
+
* placed wherever the gap between the previous word's `end` and the next
|
|
14
|
+
* word's `start` exceeds `minGap`. This is the coarsest segmentation step:
|
|
15
|
+
* it lets downstream splitters (boundary, char/word limits) refine the
|
|
16
|
+
* pause-bounded chunks without ever merging across a real pause.
|
|
17
|
+
*/
|
|
18
|
+
export declare class PauseBasedSegmentSplitter implements SegmentSplitter {
|
|
19
|
+
private readonly _config;
|
|
20
|
+
constructor(_config: PauseBasedConfig);
|
|
21
|
+
split(segments: ReadonlyArray<Segment>): Segment[];
|
|
22
|
+
private splitSegment;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=PauseBasedSegmentSplitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PauseBasedSegmentSplitter.d.ts","sourceRoot":"","sources":["../../../src/modules/splitting/PauseBasedSegmentSplitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,gBAAgB;IAEtD,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE;IAIlD,OAAO,CAAC,YAAY;CA0BrB"}
|