@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Franco Zanardi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# @tscaps/engine
|
|
2
|
+
|
|
3
|
+
> Burn subtitles into video in the browser. No server, no editor.
|
|
4
|
+
|
|
5
|
+
`@tscaps/engine` is a TypeScript engine that takes a video file, sources its captions (in-browser Whisper transcription, an existing `.srt`, or a hand-built `Document`), lays them out through CSS, and exports the result frame-by-frame to a new video — all client-side, with no backend involved.
|
|
6
|
+
|
|
7
|
+
The defining technical bet: **CSS is the rendering engine**. Subtitle preview is a DOM overlay above a `<video>` element. Final export samples that same CSS-styled DOM into bitmaps per frame, composited by a browser-side video pipeline. One visual artifact, two rendering paths.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @tscaps/engine
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The engine targets modern browsers (Chrome 94+, Edge 94+, Safari 16.4+, Firefox 130+) and requires WebCodecs, Web Audio, and Canvas APIs. Node ≥20 is needed only for development tooling; the engine itself does not run in Node.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
The minimum-viable consumer: feed a video in, get back a captioned `Blob`. With no transcriber supplied, the engine downloads a Whisper model on first run (~80MB, cached after) and transcribes the audio itself.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { RenderPipelineBuilder } from '@tscaps/engine';
|
|
23
|
+
|
|
24
|
+
const inputVideo: Blob = /* from a file input, fetch, etc. */;
|
|
25
|
+
|
|
26
|
+
const pipeline = new RenderPipelineBuilder()
|
|
27
|
+
.withInputVideo(inputVideo)
|
|
28
|
+
.build();
|
|
29
|
+
|
|
30
|
+
const { blob } = await pipeline.run();
|
|
31
|
+
// `blob` is a Blob containing the captioned mp4
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
The examples below build on each other and share two fixtures so each variation is easy to compare side by side:
|
|
37
|
+
|
|
38
|
+
**The clip** — a short demo video the engine renders captions onto:
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
**The SRT** — caption text and cue timings used as input to `SrtTranscriber` throughout:
|
|
43
|
+
|
|
44
|
+
```srt
|
|
45
|
+
1
|
|
46
|
+
00:00:00,500 --> 00:00:02,500
|
|
47
|
+
Welcome to the engine.
|
|
48
|
+
|
|
49
|
+
2
|
|
50
|
+
00:00:02,500 --> 00:00:05,500
|
|
51
|
+
Captions burned in the browser.
|
|
52
|
+
|
|
53
|
+
3
|
|
54
|
+
00:00:05,500 --> 00:00:08,000
|
|
55
|
+
No server, no editor.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 1. From an SRT file
|
|
59
|
+
|
|
60
|
+
Feed the engine a hand-authored `.srt`. `SrtTranscriber` parses cues into a `Document` and skips the Whisper model entirely. Default styling: bold white text, bottom-center, with a soft shadow.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { RenderPipelineBuilder, SrtTranscriber } from '@tscaps/engine';
|
|
64
|
+
|
|
65
|
+
const srt = await (await fetch('/captions.srt')).text();
|
|
66
|
+
|
|
67
|
+
const pipeline = new RenderPipelineBuilder()
|
|
68
|
+
.withInputVideo(inputVideo)
|
|
69
|
+
.withTranscriber(new SrtTranscriber(srt))
|
|
70
|
+
.build();
|
|
71
|
+
|
|
72
|
+
const { blob } = await pipeline.run();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
### 2. Custom caption style
|
|
78
|
+
|
|
79
|
+
Hand the pipeline a CSS string. The default selectors are `.segment`, `.line`, and `.word`; the engine attaches those classes to the rendered DOM. Container units (`cqh`, `cqw`) scale sizes against the video frame. `-webkit-text-stroke` paired with `paint-order: stroke fill` paints the outline outside the glyph instead of bleeding into it.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
const captionCss = `
|
|
83
|
+
.segment {
|
|
84
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
85
|
+
font-weight: 800;
|
|
86
|
+
font-size: 6cqh;
|
|
87
|
+
color: #ffd400;
|
|
88
|
+
-webkit-text-stroke: 0.06em #000;
|
|
89
|
+
paint-order: stroke fill;
|
|
90
|
+
text-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.6);
|
|
91
|
+
text-align: center;
|
|
92
|
+
line-height: 1.2;
|
|
93
|
+
}
|
|
94
|
+
.line { display: block; text-align: center; }
|
|
95
|
+
.word { display: inline-block; margin: 0 0.15em; }
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
const pipeline = new RenderPipelineBuilder()
|
|
99
|
+
.withInputVideo(inputVideo)
|
|
100
|
+
.withTranscriber(new SrtTranscriber(srt))
|
|
101
|
+
.withCss(captionCss)
|
|
102
|
+
.build();
|
|
103
|
+
|
|
104
|
+
const { blob } = await pipeline.run();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
109
|
+
### 3. Caption position
|
|
110
|
+
|
|
111
|
+
Captions default to bottom-center. To move them, pass an `AlignmentConfig` — fractions of the video's width and height as the anchor point, plus which edge of the caption box lands on that point.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const pipeline = new RenderPipelineBuilder()
|
|
115
|
+
.withInputVideo(inputVideo)
|
|
116
|
+
.withTranscriber(new SrtTranscriber(srt))
|
|
117
|
+
.withCss(captionCss)
|
|
118
|
+
.withAlignment({
|
|
119
|
+
verticalAlign: 'top',
|
|
120
|
+
verticalOffset: 0.12,
|
|
121
|
+
horizontalAlign: 'center',
|
|
122
|
+
horizontalOffset: 0.5,
|
|
123
|
+
})
|
|
124
|
+
.build();
|
|
125
|
+
|
|
126
|
+
const { blob } = await pipeline.run();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+

|
|
130
|
+
|
|
131
|
+
### 4. One word at a time (splitters)
|
|
132
|
+
|
|
133
|
+
The engine pipes the `Document` through a `SegmentSplitter` and a `LineSplitter` before rendering. Override them to force exactly one word per segment and one line per segment, then style each word as a large standalone caption.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import {
|
|
137
|
+
RenderPipelineBuilder,
|
|
138
|
+
SrtTranscriber,
|
|
139
|
+
LimitByWordsSegmentSplitter,
|
|
140
|
+
} from '@tscaps/engine';
|
|
141
|
+
|
|
142
|
+
const singleWordCss = `
|
|
143
|
+
.segment {
|
|
144
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
145
|
+
font-weight: 900;
|
|
146
|
+
font-size: 11cqh;
|
|
147
|
+
color: #ffffff;
|
|
148
|
+
-webkit-text-stroke: 0.05em #000;
|
|
149
|
+
paint-order: stroke fill;
|
|
150
|
+
text-shadow: 0 0.12em 0.3em rgba(0, 0, 0, 0.6);
|
|
151
|
+
text-align: center;
|
|
152
|
+
line-height: 1.1;
|
|
153
|
+
}
|
|
154
|
+
.line { display: block; text-align: center; }
|
|
155
|
+
.word { display: inline-block; }
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
const pipeline = new RenderPipelineBuilder()
|
|
159
|
+
.withInputVideo(inputVideo)
|
|
160
|
+
.withTranscriber(new SrtTranscriber(srt))
|
|
161
|
+
.withSegmentSplitter(new LimitByWordsSegmentSplitter({ maxWords: 1 }))
|
|
162
|
+
.withDefaultLineSplitterConfig({ maxLines: 1 })
|
|
163
|
+
.withCss(singleWordCss)
|
|
164
|
+
.build();
|
|
165
|
+
|
|
166
|
+
const { blob } = await pipeline.run();
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+

|
|
170
|
+
|
|
171
|
+
### 5. Karaoke highlight (state classes)
|
|
172
|
+
|
|
173
|
+
Every word carries a state class that reflects the current playback time: `word-not-narrated-yet`, `word-being-narrated`, or `word-already-narrated`. Target those classes in CSS to recolour each word as it plays.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
const karaokeCss = `
|
|
177
|
+
.segment {
|
|
178
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
179
|
+
font-weight: 800;
|
|
180
|
+
font-size: 6cqh;
|
|
181
|
+
-webkit-text-stroke: 0.06em #000;
|
|
182
|
+
paint-order: stroke fill;
|
|
183
|
+
text-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.6);
|
|
184
|
+
text-align: center;
|
|
185
|
+
line-height: 1.2;
|
|
186
|
+
}
|
|
187
|
+
.line { display: block; text-align: center; }
|
|
188
|
+
.word {
|
|
189
|
+
display: inline-block;
|
|
190
|
+
margin: 0 0.15em;
|
|
191
|
+
color: #ffffff;
|
|
192
|
+
}
|
|
193
|
+
.word.word-being-narrated { color: #ffd400; }
|
|
194
|
+
.word.word-already-narrated { color: #b0b0b0; }
|
|
195
|
+
`;
|
|
196
|
+
|
|
197
|
+
const pipeline = new RenderPipelineBuilder()
|
|
198
|
+
.withInputVideo(inputVideo)
|
|
199
|
+
.withTranscriber(new SrtTranscriber(srt))
|
|
200
|
+
.withCss(karaokeCss)
|
|
201
|
+
.build();
|
|
202
|
+
|
|
203
|
+
const { blob } = await pipeline.run();
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+

|
|
207
|
+
|
|
208
|
+
### 6. Animation driven by playback timing
|
|
209
|
+
|
|
210
|
+
The engine also exposes CSS custom properties that encode timing relative to the current frame — `--on-segment-starts`, `--on-line-being-narrated-starts`, `--word-being-narrated-duration`, and so on. Use them as `animation-delay` (or `animation-duration`) so a single keyframe rule plays in sync with the narration, frame after frame.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const slideInCss = `
|
|
214
|
+
@keyframes segment-slide-in {
|
|
215
|
+
from { transform: translateY(0.5em); opacity: 0; }
|
|
216
|
+
to { transform: translateY(0); opacity: 1; }
|
|
217
|
+
}
|
|
218
|
+
.segment {
|
|
219
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
220
|
+
font-weight: 800;
|
|
221
|
+
font-size: 6cqh;
|
|
222
|
+
text-align: center;
|
|
223
|
+
line-height: 1.2;
|
|
224
|
+
padding: 0.2em 0.6em;
|
|
225
|
+
border-radius: 0.25em;
|
|
226
|
+
background: rgba(255, 212, 0, 0.92);
|
|
227
|
+
color: #111;
|
|
228
|
+
animation: segment-slide-in 0.35s var(--on-segment-starts) ease-out both;
|
|
229
|
+
}
|
|
230
|
+
.line { display: block; text-align: center; }
|
|
231
|
+
.word { display: inline-block; margin: 0 0.1em; }
|
|
232
|
+
`;
|
|
233
|
+
|
|
234
|
+
const pipeline = new RenderPipelineBuilder()
|
|
235
|
+
.withInputVideo(inputVideo)
|
|
236
|
+
.withTranscriber(new SrtTranscriber(srt))
|
|
237
|
+
.withCss(slideInCss)
|
|
238
|
+
.build();
|
|
239
|
+
|
|
240
|
+
const { blob } = await pipeline.run();
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+

|
|
244
|
+
|
|
245
|
+
## Document model
|
|
246
|
+
|
|
247
|
+
Every transcriber produces a `Document` whose hierarchy is:
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
Document
|
|
251
|
+
└── Section[] contiguous run, processed by one splitter + tagger chain
|
|
252
|
+
└── Segment[] one screen-sized caption block, carries a time range
|
|
253
|
+
└── Line[] one visible line of text within a segment
|
|
254
|
+
└── Word[] a word with text, time range, and tag set
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The pipeline restructures the same `Word`s into different `Segment`s and `Line`s through `SegmentSplitter` and `LineSplitter`; the underlying word data (`text`, `time`, `tags`) does not change.
|
|
258
|
+
|
|
259
|
+
The render layer exposes that document to CSS through three surfaces: a flat set of CSS classes per element, a flat set of CSS custom properties per element, and a tag system that adds more classes via taggers. Everything the examples above target — `.word`, `.word-being-narrated`, `--on-segment-starts`, `var(--on-line-being-narrated-starts)` — comes from these surfaces.
|
|
260
|
+
|
|
261
|
+
### CSS classes the engine emits
|
|
262
|
+
|
|
263
|
+
Every rendered element carries its element class:
|
|
264
|
+
|
|
265
|
+
- `.section` — the root of the active Section
|
|
266
|
+
- `.segment` — a caption block
|
|
267
|
+
- `.line` — a visible line within a segment
|
|
268
|
+
- `.word` — a single word within a line
|
|
269
|
+
- `.letter` — a single letter within a word, emitted only when `rendering.splitWordsIntoLetters` is `true`
|
|
270
|
+
|
|
271
|
+
State classes — computed per frame from the current playback time and attached to the matching `.word` / `.line`:
|
|
272
|
+
|
|
273
|
+
- `word-not-narrated-yet`, `word-being-narrated`, `word-already-narrated`
|
|
274
|
+
- `line-not-narrated-yet`, `line-being-narrated`, `line-already-narrated`
|
|
275
|
+
|
|
276
|
+
Positional tags from `StructureTagger`, assigned once after splitting:
|
|
277
|
+
|
|
278
|
+
- `first-word-in-line`, `last-word-in-line`
|
|
279
|
+
- `first-word-in-segment`, `last-word-in-segment`
|
|
280
|
+
- `first-word-in-section`, `last-word-in-section`
|
|
281
|
+
- `first-line-in-segment`, `last-line-in-segment`
|
|
282
|
+
- `first-line-in-section`, `last-line-in-section`
|
|
283
|
+
- `first-segment-in-section`, `last-segment-in-section`
|
|
284
|
+
- `first-section-in-document`, `last-section-in-document`
|
|
285
|
+
|
|
286
|
+
Semantic tag classes come from `Tagger` implementations you add to the pipeline (see *Tags and taggers* below) and are entirely consumer-defined.
|
|
287
|
+
|
|
288
|
+
### CSS custom properties
|
|
289
|
+
|
|
290
|
+
Each rendered element exposes timing values relative to the current frame, so you can drive `animation-delay`, `animation-duration`, or any other CSS value from the narration timeline. `--on-…-starts` and `--on-…-ends` are seconds until the event; they go negative once the event is in the past. `--…-duration` is a span.
|
|
291
|
+
|
|
292
|
+
Element-level timing:
|
|
293
|
+
|
|
294
|
+
- `--on-section-starts`, `--on-section-ends`, `--section-duration`
|
|
295
|
+
- `--on-segment-starts`, `--on-segment-ends`, `--segment-duration`
|
|
296
|
+
|
|
297
|
+
Per-state timing, for both `.line` and `.word` (substitute `<elem>` with `line` or `word`):
|
|
298
|
+
|
|
299
|
+
- `--on-<elem>-not-narrated-yet-starts`, `--on-<elem>-not-narrated-yet-ends`, `--<elem>-not-narrated-yet-duration`
|
|
300
|
+
- `--on-<elem>-being-narrated-starts`, `--on-<elem>-being-narrated-ends`, `--<elem>-being-narrated-duration`
|
|
301
|
+
- `--on-<elem>-already-narrated-starts`, `--on-<elem>-already-narrated-ends`, `--<elem>-already-narrated-duration`
|
|
302
|
+
|
|
303
|
+
Letter-level, when splitting into letters:
|
|
304
|
+
|
|
305
|
+
- `--letter-index`, `--letter-count`
|
|
306
|
+
|
|
307
|
+
Layout and frame:
|
|
308
|
+
|
|
309
|
+
- `--subtitle-region-width`, `--subtitle-region-height`, `--subtitle-region-x`, `--subtitle-region-y` — the caption region's box, useful when positioning relative to the video frame
|
|
310
|
+
- `--video-frame` — the underlying video frame as `url("data:image/jpeg;base64,…")`, only set when `rendering.videoFrame.required` is `true` (see [docs/RENDERING_INTERNALS.md](docs/RENDERING_INTERNALS.md))
|
|
311
|
+
|
|
312
|
+
### Tags and taggers
|
|
313
|
+
|
|
314
|
+
A `Tag` is a CSS class the engine attaches to an element of the document. The engine recognises three sources:
|
|
315
|
+
|
|
316
|
+
- **Structural tags** are assigned by `StructureTagger`, which runs once after splitting and encodes each element's positional role within its container (the list above under *CSS classes*). The structural tagger is part of every default pipeline; you can target these classes without writing any tagger yourself.
|
|
317
|
+
- **Semantic tags** are assigned by `Tagger` implementations that pattern-match against word data. Built-ins: `RegexTagger` (matches a regex against the word text), `WordlistTagger` (membership in a set of strings), `SpanTagger` (a contiguous range of words by index). Build your own by extending the `Tagger` abstract class. Attach them through `.addTagger(...)` or `.withTaggers([...])` on the builder.
|
|
318
|
+
- **State tags** — `word-being-narrated`, `line-already-narrated`, etc. — are computed at render time from the current playback timestamp. They are never stored on the `Word` or `Line`; the engine just derives them per frame.
|
|
319
|
+
|
|
320
|
+
Tags map one-to-one onto CSS classes through `Tag.toCssClass()`. Unknown tag classes are silently ignored by CSS, so adding a new tag category is additive — it never breaks existing stylesheets.
|
|
321
|
+
|
|
322
|
+
## What else the engine can do
|
|
323
|
+
|
|
324
|
+
The examples above cover the common cases. The pipeline exposes more knobs you'll reach for as your needs grow:
|
|
325
|
+
|
|
326
|
+
- **Built-in transcribers**: `WhisperTranscriber` (the default, in-browser Whisper), `SrtTranscriber` (parses SubRip), `PassthroughTranscriber` (wraps a pre-built `Document`). Or implement your own by satisfying the `Transcriber` interface.
|
|
327
|
+
- **Segment splitters**: the default `CompositeSegmentSplitter` chains a sentence-boundary cut with a scaled-character budget. Individual strategies are exposed for custom chains — `BoundarySegmentSplitter`, `LimitByWordsSegmentSplitter`, `LimitByScaledCharsSegmentSplitter`, `PauseBasedSegmentSplitter`, `SpeakerChangeSegmentSplitter`.
|
|
328
|
+
- **Line splitters**: `BalancedLineSplitter` (char-balanced, no measurer needed) and `BalancedPixelWidthLineSplitter` (pixel-balanced, backed by a `TextMeasurer` — `DomProbeCanvasTextMeasurer` is the default measurer).
|
|
329
|
+
- **Replace any stage**: `withTranscriber`, `withSegmentSplitter`, `withLineSplitter`, `withVideoRenderer`, `withSubtitleFrameRenderer`, `withOverlayFrameRenderer`. Defaults stay in place until explicitly replaced.
|
|
330
|
+
- **Tweak default-stage configs without rebuilding them**: `withDefaultSegmentSplitterConfig({ maxChars, minChars, ... })`, `withDefaultLineSplitterConfig({ maxLines, maxWidthRatio, ... })`.
|
|
331
|
+
- **Output control**: `withOutputFormat('mp4' | 'webm')`, `withOutputResolution(width, height)`, `withQuality(...)`, `withOutputStream(...)` for streaming the encoded bytes as they're produced.
|
|
332
|
+
- **Per-step execution**: `runTranscriptionStep`, `runSplittingStep`, `runStructuralTaggingStep`, `runSemanticTaggingStep`, `runEffectsStep`, `runRenderingStep`. Useful when you want to inspect or hand-edit the `Document` between stages — `getDocument()` and `setDocument(doc)` give you read/replace access.
|
|
333
|
+
- **Progress reporting**: `run` accepts a callback that fires through every pipeline stage — Whisper model download, transcription, splitting, tagging, effects, and per-frame rendering progress.
|
|
334
|
+
- **Effects and semantic taggers**: pure document-transforming stages (smart punctuation, lowercase, regex/wordlist taggers, etc.) added via `addEffect` and `addTagger`.
|
|
335
|
+
- **Multi-style captions**: `withSubtitleStyles({ kindA: ..., kindB: ... })` for documents with multiple `Section.kind` groups, each carrying its own visual rule.
|
|
336
|
+
|
|
337
|
+
Full type definitions and inline JSDoc ship in `dist/index.d.ts`. Runnable browser and CLI consumers live in [`examples/`](examples) in the source repository.
|
|
338
|
+
|
|
339
|
+
## Going deeper
|
|
340
|
+
|
|
341
|
+
For the parts of the engine that sit below the public pipeline API — how each output frame is sampled into a bitmap via SVG `<foreignObject>`, how MediaBunny powers the encode, the browser caveats that come with that approach, how to feed the underlying video frame into your caption styles, and how SVG filters are authored — see [docs/RENDERING_INTERNALS.md](docs/RENDERING_INTERNALS.md).
|
|
342
|
+
|
|
343
|
+
## Project status
|
|
344
|
+
|
|
345
|
+
Pre-1.0. The public API surface is stabilising but may shift between minor versions until `1.0`. Pin to an exact version in production and review the changelog before upgrading.
|
|
346
|
+
|
|
347
|
+
## License
|
|
348
|
+
|
|
349
|
+
MIT — see [LICENSE](LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './modules/document/index';
|
|
2
|
+
export * from './modules/transcription/index';
|
|
3
|
+
export * from './modules/video/index';
|
|
4
|
+
export * from './modules/rendering/index';
|
|
5
|
+
export * from './modules/css/index';
|
|
6
|
+
export * from './modules/svg-filter/index';
|
|
7
|
+
export * from './modules/splitting/index';
|
|
8
|
+
export * from './modules/tagging/index';
|
|
9
|
+
export * from './modules/effect/index';
|
|
10
|
+
export * from './modules/profiling/index';
|
|
11
|
+
export * from './modules/pipeline/index';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './modules/document/index';
|
|
2
|
+
export * from './modules/transcription/index';
|
|
3
|
+
export * from './modules/video/index';
|
|
4
|
+
export * from './modules/rendering/index';
|
|
5
|
+
export * from './modules/css/index';
|
|
6
|
+
export * from './modules/svg-filter/index';
|
|
7
|
+
export * from './modules/splitting/index';
|
|
8
|
+
export * from './modules/tagging/index';
|
|
9
|
+
export * from './modules/effect/index';
|
|
10
|
+
export * from './modules/profiling/index';
|
|
11
|
+
export * from './modules/pipeline/index';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserCssResourceEmbedder.d.ts","sourceRoot":"","sources":["../../../src/modules/css/BrowserCssResourceEmbedder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,qBAAa,0BAA2B,YAAW,mBAAmB;IAC9D,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAyC1C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class BrowserCssResourceEmbedder {
|
|
2
|
+
async embed(css) {
|
|
3
|
+
const urlRegex = /url\(\s*(['"]?)(.*?)\1\s*\)/g;
|
|
4
|
+
const matches = [...css.matchAll(urlRegex)];
|
|
5
|
+
// Extract unique URLs, ignoring those already embedded as data: URIs
|
|
6
|
+
// and same-document fragment refs like url(#filter-id), which point
|
|
7
|
+
// at sibling <defs> inside the host SVG and must be left intact.
|
|
8
|
+
const allUrls = matches.map((m) => m[2]);
|
|
9
|
+
const validUrls = allUrls.filter((url) => Boolean(url) && !url.startsWith('data:') && !url.startsWith('#'));
|
|
10
|
+
const uniqueUrls = [...new Set(validUrls)];
|
|
11
|
+
const replacements = new Map();
|
|
12
|
+
await Promise.all(uniqueUrls.map(async (url) => {
|
|
13
|
+
try {
|
|
14
|
+
const response = await window.fetch(url);
|
|
15
|
+
if (!response.ok)
|
|
16
|
+
throw new Error(`HTTP ${response.status}`);
|
|
17
|
+
const blob = await response.blob();
|
|
18
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
|
19
|
+
const reader = new FileReader();
|
|
20
|
+
reader.onloadend = () => resolve(reader.result);
|
|
21
|
+
reader.onerror = reject;
|
|
22
|
+
reader.readAsDataURL(blob);
|
|
23
|
+
});
|
|
24
|
+
replacements.set(url, dataUrl);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
console.warn(`BrowserCssResourceEmbedder failed to embed resource: ${url}`, e);
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
let result = css;
|
|
31
|
+
for (const match of matches) {
|
|
32
|
+
const url = match[2];
|
|
33
|
+
if (url && replacements.has(url)) {
|
|
34
|
+
const newUrl = replacements.get(url);
|
|
35
|
+
result = result.replace(match[0], `url("${newUrl}")`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=BrowserCssResourceEmbedder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserCssResourceEmbedder.js","sourceRoot":"","sources":["../../../src/modules/css/BrowserCssResourceEmbedder.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,0BAA0B;IACrC,KAAK,CAAC,KAAK,CAAC,GAAW;QACrB,MAAM,QAAQ,GAAG,8BAA8B,CAAC;QAChD,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE5C,qEAAqE;QACrE,oEAAoE;QACpE,iEAAiE;QACjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7H,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAE3C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE/C,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7C,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,QAAQ,CAAC,EAAE;oBAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC7D,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnC,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;oBAC3D,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;oBAChC,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;oBAC1D,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;oBACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;gBACH,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACjC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,wDAAwD,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;YACjF,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;QAEJ,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjC,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;gBACtC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,MAAM,IAAI,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips CSS block comments (`/* … *\/`) from a stylesheet, leaving
|
|
3
|
+
* whitespace and rule structure untouched.
|
|
4
|
+
*
|
|
5
|
+
* Comment-like sequences inside string literals are preserved. An
|
|
6
|
+
* unterminated comment drops everything from its opening to the end
|
|
7
|
+
* of the input — matching what browsers do when they encounter one.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CssMinifier {
|
|
10
|
+
minify(css: string): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CssMinifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CssMinifier.d.ts","sourceRoot":"","sources":["../../../src/modules/css/CssMinifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAkC5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips CSS block comments (`/* … *\/`) from a stylesheet, leaving
|
|
3
|
+
* whitespace and rule structure untouched.
|
|
4
|
+
*
|
|
5
|
+
* Comment-like sequences inside string literals are preserved. An
|
|
6
|
+
* unterminated comment drops everything from its opening to the end
|
|
7
|
+
* of the input — matching what browsers do when they encounter one.
|
|
8
|
+
*/
|
|
9
|
+
export class CssMinifier {
|
|
10
|
+
minify(css) {
|
|
11
|
+
let result = '';
|
|
12
|
+
let i = 0;
|
|
13
|
+
let stringDelim = null;
|
|
14
|
+
while (i < css.length) {
|
|
15
|
+
const ch = css[i];
|
|
16
|
+
if (stringDelim) {
|
|
17
|
+
result += ch;
|
|
18
|
+
if (ch === '\\' && i + 1 < css.length) {
|
|
19
|
+
result += css[i + 1];
|
|
20
|
+
i += 2;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (ch === stringDelim)
|
|
24
|
+
stringDelim = null;
|
|
25
|
+
i++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (ch === '"' || ch === "'") {
|
|
29
|
+
stringDelim = ch;
|
|
30
|
+
result += ch;
|
|
31
|
+
i++;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (ch === '/' && css[i + 1] === '*') {
|
|
35
|
+
const end = css.indexOf('*/', i + 2);
|
|
36
|
+
if (end === -1)
|
|
37
|
+
break;
|
|
38
|
+
i = end + 2;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
result += ch;
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=CssMinifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CssMinifier.js","sourceRoot":"","sources":["../../../src/modules/css/CssMinifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,WAAW;IACtB,MAAM,CAAC,GAAW;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,WAAW,GAAqB,IAAI,CAAC;QACzC,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAE,CAAC;YACnB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,IAAI,EAAE,CAAC;gBACb,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;oBACtC,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBACrB,CAAC,IAAI,CAAC,CAAC;oBACP,SAAS;gBACX,CAAC;gBACD,IAAI,EAAE,KAAK,WAAW;oBAAE,WAAW,GAAG,IAAI,CAAC;gBAC3C,CAAC,EAAE,CAAC;gBACJ,SAAS;YACX,CAAC;YACD,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;gBAC7B,WAAW,GAAG,EAAE,CAAC;gBACjB,MAAM,IAAI,EAAE,CAAC;gBACb,CAAC,EAAE,CAAC;gBACJ,SAAS;YACX,CAAC;YACD,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBACrC,IAAI,GAAG,KAAK,CAAC,CAAC;oBAAE,MAAM;gBACtB,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;gBACZ,SAAS;YACX,CAAC;YACD,MAAM,IAAI,EAAE,CAAC;YACb,CAAC,EAAE,CAAC;QACN,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CssResourceEmbedder.d.ts","sourceRoot":"","sources":["../../../src/modules/css/CssResourceEmbedder.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CssResourceEmbedder.js","sourceRoot":"","sources":["../../../src/modules/css/CssResourceEmbedder.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scopes a CSS string so it can coexist with sibling stylesheets in
|
|
3
|
+
* the same document. Top-level selectors get prefixed with
|
|
4
|
+
* `scopeSelector`; every `@keyframes` declaration is renamed to a
|
|
5
|
+
* scope-unique form and the matching `animation-name` / `animation`
|
|
6
|
+
* shorthand references in the same stylesheet are rewritten in step.
|
|
7
|
+
*
|
|
8
|
+
* `scopeSelector` is expected to be a simple class selector
|
|
9
|
+
* (e.g. `.my-scope`); its identifier portion seeds the keyframe rename.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CssScoper {
|
|
12
|
+
scope(css: string, scopeSelector: string): string;
|
|
13
|
+
private scopeKeyframes;
|
|
14
|
+
private scopeSelectors;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=CssScoper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CssScoper.d.ts","sourceRoot":"","sources":["../../../src/modules/css/CssScoper.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;IAKjD,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,cAAc;CA0DvB"}
|