videobook 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- package/bin/videobook.js +7 -0
- package/dist/acestep/client.js +203 -0
- package/dist/acestep/config.js +62 -0
- package/dist/acestep/errors.js +8 -0
- package/dist/acestep/process.js +175 -0
- package/dist/alive-captions/analyze.js +117 -0
- package/dist/alive-captions/audio.js +179 -0
- package/dist/alive-captions/frames.js +59 -0
- package/dist/alive-captions/model.js +37 -0
- package/dist/alive-captions/schema.js +49 -0
- package/dist/alive-captions/track.js +9 -0
- package/dist/api-key.js +33 -0
- package/dist/app-state.js +56 -0
- package/dist/app.js +257 -0
- package/dist/archive-b2.js +332 -0
- package/dist/archive-store.js +169 -0
- package/dist/artifact-label.js +36 -0
- package/dist/artifact-refs.js +49 -0
- package/dist/asset-tag-extraction.js +169 -0
- package/dist/asset-tags.js +228 -0
- package/dist/asset-usage.js +23 -0
- package/dist/audio-cue.js +71 -0
- package/dist/audio-encoding.js +32 -0
- package/dist/audio-sync-request.js +1 -0
- package/dist/audio-sync.js +223 -0
- package/dist/audio-trim-range.js +31 -0
- package/dist/book-context.js +31 -0
- package/dist/book-manager.js +374 -0
- package/dist/catalog-gc.js +26 -0
- package/dist/chain-executor.js +815 -0
- package/dist/chain-generation.js +115 -0
- package/dist/chain-plan.js +746 -0
- package/dist/chain-step-review.js +60 -0
- package/dist/character-name.js +25 -0
- package/dist/chat-generation-routing.js +73 -0
- package/dist/chat-generation-settings.js +78 -0
- package/dist/chat-models.js +44 -0
- package/dist/chat-prompt-rewrite.js +67 -0
- package/dist/chat-router.js +628 -0
- package/dist/chat-view-actions.js +49 -0
- package/dist/cli/args.js +242 -0
- package/dist/cli/config-command.js +103 -0
- package/dist/cli/doctor-command.js +289 -0
- package/dist/cli/entry.js +2 -0
- package/dist/cli/key-report.js +16 -0
- package/dist/cli/main.js +104 -0
- package/dist/cli/mcp-command.js +88 -0
- package/dist/cli/mcp-relay.js +51 -0
- package/dist/cli/open-browser.js +14 -0
- package/dist/cli/run-command.js +231 -0
- package/dist/cli/serve-command.js +62 -0
- package/dist/cli/setup-command.js +60 -0
- package/dist/cli/stdio-guard.js +8 -0
- package/dist/cold-open-model.js +7 -0
- package/dist/cold-open.js +79 -0
- package/dist/command-reference.js +95 -0
- package/dist/content-store.js +74 -0
- package/dist/cost.js +8 -0
- package/dist/crop-geometry.js +23 -0
- package/dist/dancing-workflow.js +447 -0
- package/dist/data-home.js +44 -0
- package/dist/diagnostics.js +109 -0
- package/dist/dialog-quality.js +34 -0
- package/dist/downloads-dest.js +56 -0
- package/dist/editing-moments.js +194 -0
- package/dist/elevenlabs-audio-extension.js +66 -0
- package/dist/engine.js +54 -0
- package/dist/env-file.js +91 -0
- package/dist/env-secrets.js +148 -0
- package/dist/ffmpeg-binary.js +12 -0
- package/dist/ffmpeg.js +425 -0
- package/dist/ffprobe-binary.js +77 -0
- package/dist/forget-asset.js +216 -0
- package/dist/frame-utils.js +27 -0
- package/dist/generation-credit-error.js +11 -0
- package/dist/generation-input-mentions.js +117 -0
- package/dist/generation-input-policy.js +68 -0
- package/dist/generation-reference-mentions.js +97 -0
- package/dist/goal-characters.js +49 -0
- package/dist/goal-plan-v3.js +273 -0
- package/dist/goal-plan.js +220 -0
- package/dist/goal-planner-prompt.js +28 -0
- package/dist/goal-prompt-budget.js +4 -0
- package/dist/goal-reference-images.js +25 -0
- package/dist/goal-state.js +261 -0
- package/dist/goal-stills.js +153 -0
- package/dist/goal-store.js +144 -0
- package/dist/goal-styles.js +144 -0
- package/dist/goal-v3-runtime.js +157 -0
- package/dist/guides/character_schema_guide.md +70 -0
- package/dist/guides/gpt_image_2_5_prompting_guide.md +21 -0
- package/dist/guides/grok_imagine_prompting_guide.md +72 -0
- package/dist/guides/image_reproduction_guide.md +84 -0
- package/dist/guides/kling_3_0_prompting_guide.md +136 -0
- package/dist/guides/nano_banana_pro_prompting_guide.md +28 -0
- package/dist/guides/seedance_2_prompting_guide.md +172 -0
- package/dist/http-access.js +49 -0
- package/dist/http-byte-range.js +31 -0
- package/dist/hydration.js +56 -0
- package/dist/image-compress.js +77 -0
- package/dist/image-edit-default.js +1 -0
- package/dist/image-edit-models.js +41 -0
- package/dist/image-edit-settings.js +11 -0
- package/dist/image-region-edit.js +32 -0
- package/dist/image-subject-map.js +523 -0
- package/dist/image.js +46 -0
- package/dist/index.js +12 -0
- package/dist/job-deadline.js +60 -0
- package/dist/jobs/_alibaba-upload.js +30 -0
- package/dist/jobs/_audio-chunks.js +31 -0
- package/dist/jobs/_download-into-asset.js +15 -0
- package/dist/jobs/_fal-shared.js +22 -0
- package/dist/jobs/_fal-upload.js +35 -0
- package/dist/jobs/_image-edit-adapter.js +213 -0
- package/dist/jobs/_kie-poll.js +119 -0
- package/dist/jobs/_kie-upload.js +32 -0
- package/dist/jobs/_lease.js +163 -0
- package/dist/jobs/_persist-output.js +19 -0
- package/dist/jobs/_storage-retry.js +21 -0
- package/dist/jobs/_transcribe.js +245 -0
- package/dist/jobs/_translate-transcript.js +270 -0
- package/dist/jobs/analyze-alive-captions.js +10 -0
- package/dist/jobs/analyze-editing-moments.js +104 -0
- package/dist/jobs/analyze-jokes.js +143 -0
- package/dist/jobs/analyze-keyword-placement.js +155 -0
- package/dist/jobs/analyze-music.js +14 -0
- package/dist/jobs/analyze-video.js +282 -0
- package/dist/jobs/apply-cuts.js +83 -0
- package/dist/jobs/apply-sfx.js +107 -0
- package/dist/jobs/archive-clip.js +458 -0
- package/dist/jobs/assemble-goal.js +98 -0
- package/dist/jobs/audio-boost.js +71 -0
- package/dist/jobs/audio-mix.js +161 -0
- package/dist/jobs/backfill-asset-tags.js +144 -0
- package/dist/jobs/burn-watermark.js +316 -0
- package/dist/jobs/change-video-speed.js +176 -0
- package/dist/jobs/clean-video-audio.js +207 -0
- package/dist/jobs/cold-open.js +166 -0
- package/dist/jobs/combine-goal.js +108 -0
- package/dist/jobs/complete-provider-task.js +185 -0
- package/dist/jobs/copy-library-asset.js +33 -0
- package/dist/jobs/cost-estimate-assessment.js +113 -0
- package/dist/jobs/crop-image.js +47 -0
- package/dist/jobs/crop-video.js +71 -0
- package/dist/jobs/describe-image.js +181 -0
- package/dist/jobs/detect-scenes.js +33 -0
- package/dist/jobs/doctor-fix.js +100 -0
- package/dist/jobs/download-video.js +427 -0
- package/dist/jobs/enqueue-search-index.js +24 -0
- package/dist/jobs/even-split.js +122 -0
- package/dist/jobs/export-sequence.js +365 -0
- package/dist/jobs/extend-audio.js +229 -0
- package/dist/jobs/extract-audio.js +72 -0
- package/dist/jobs/extract-frame.js +58 -0
- package/dist/jobs/extract-notebook-audio.js +82 -0
- package/dist/jobs/extract-notebook-frame.js +93 -0
- package/dist/jobs/extract-video-clip.js +8 -0
- package/dist/jobs/extract-video-poster.js +55 -0
- package/dist/jobs/extract-waveform.js +25 -0
- package/dist/jobs/finish-goal.js +255 -0
- package/dist/jobs/forget-asset.js +11 -0
- package/dist/jobs/generate-acestep-cover.js +219 -0
- package/dist/jobs/generate-media.js +70 -0
- package/dist/jobs/image-subjects.js +1059 -0
- package/dist/jobs/index.js +18 -0
- package/dist/jobs/inject-first-frame.js +175 -0
- package/dist/jobs/isolate-vocals.js +69 -0
- package/dist/jobs/kie-paygate.js +177 -0
- package/dist/jobs/label-music-sections.js +5 -0
- package/dist/jobs/osg-placement.js +135 -0
- package/dist/jobs/pad-video.js +72 -0
- package/dist/jobs/plan-goal.js +97 -0
- package/dist/jobs/post-record.js +21 -0
- package/dist/jobs/post-to-x.js +21 -0
- package/dist/jobs/prepare-search-reference.js +190 -0
- package/dist/jobs/prepare-temporal-search.js +16 -0
- package/dist/jobs/process-audio.js +67 -0
- package/dist/jobs/process-image.js +58 -0
- package/dist/jobs/process-upload.js +166 -0
- package/dist/jobs/process-video.js +438 -0
- package/dist/jobs/register-all.js +161 -0
- package/dist/jobs/relayout-notebook.js +78 -0
- package/dist/jobs/remove-sound.js +299 -0
- package/dist/jobs/render-project.js +380 -0
- package/dist/jobs/render-qr-outro.js +138 -0
- package/dist/jobs/render-timeline.js +283 -0
- package/dist/jobs/repair-search-indexes.js +42 -0
- package/dist/jobs/replace-video-audio.js +64 -0
- package/dist/jobs/restore-archive-clip.js +53 -0
- package/dist/jobs/reverse-video.js +53 -0
- package/dist/jobs/rewrite-script.js +173 -0
- package/dist/jobs/run-notebook.js +3335 -0
- package/dist/jobs/semantic-index.js +797 -0
- package/dist/jobs/smooth-scene-concat.js +257 -0
- package/dist/jobs/splice-video.js +280 -0
- package/dist/jobs/split-video.js +127 -0
- package/dist/jobs/suggest-cuts.js +149 -0
- package/dist/jobs/suggest-sfx.js +135 -0
- package/dist/jobs/sync-video-to-audio.js +329 -0
- package/dist/jobs/tag-asset.js +266 -0
- package/dist/jobs/task-failure.js +16 -0
- package/dist/jobs/timewarp-video.js +152 -0
- package/dist/jobs/transcribe-video-audio.js +117 -0
- package/dist/jobs/transcribe.js +35 -0
- package/dist/jobs/translate-transcript.js +55 -0
- package/dist/jobs/trim-audio.js +133 -0
- package/dist/jobs/trim-video.js +291 -0
- package/dist/jobs/xai-paygate.js +26 -0
- package/dist/keyword-placement-cache.js +74 -0
- package/dist/lazy-render.js +142 -0
- package/dist/library-browse.js +78 -0
- package/dist/lightning-defaults.js +206 -0
- package/dist/load-env.js +12 -0
- package/dist/local-search-models.js +206 -0
- package/dist/local-upload.js +318 -0
- package/dist/logger.js +69 -0
- package/dist/media/adapters/alibaba.js +20 -0
- package/dist/media/adapters/elevenlabs.js +58 -0
- package/dist/media/adapters/fal.js +45 -0
- package/dist/media/adapters/index.js +26 -0
- package/dist/media/adapters/kie.js +120 -0
- package/dist/media/adapters/pending.js +21 -0
- package/dist/media/adapters/types.js +5 -0
- package/dist/media/adapters/xai.js +18 -0
- package/dist/media/catalog.js +236 -0
- package/dist/media/complete.js +191 -0
- package/dist/media/cost.js +45 -0
- package/dist/media/descriptor.js +157 -0
- package/dist/media/endpoints.js +11 -0
- package/dist/media/frame-options.js +18 -0
- package/dist/media/insert-video-timing.js +17 -0
- package/dist/media/json-schema.js +75 -0
- package/dist/media/legacy-task-types.js +129 -0
- package/dist/media/listing.js +24 -0
- package/dist/media/model-id.js +14 -0
- package/dist/media/preview.js +86 -0
- package/dist/media/prompt-dialects.js +65 -0
- package/dist/media/ref-fields.js +106 -0
- package/dist/media/refs.js +131 -0
- package/dist/media/request.js +188 -0
- package/dist/media/types.js +6 -0
- package/dist/media/wire.js +161 -0
- package/dist/media-library.js +535 -0
- package/dist/media-output-path.js +33 -0
- package/dist/multyculty-workflow.js +757 -0
- package/dist/notebook-action-catalog.js +608 -0
- package/dist/notebook-cell-outputs.js +726 -0
- package/dist/notebook-credit-retry.js +45 -0
- package/dist/notebook-fixtures.js +8 -0
- package/dist/notebook-generation-contract.js +77 -0
- package/dist/notebook-generation-controls.js +145 -0
- package/dist/notebook-goal-layout.js +40 -0
- package/dist/notebook-graph.js +37 -0
- package/dist/notebook-image-edit.js +84 -0
- package/dist/notebook-initial-generation-prompt.js +222 -0
- package/dist/notebook-live-analysis.js +941 -0
- package/dist/notebook-media-ops.js +579 -0
- package/dist/notebook-mutations.js +20 -0
- package/dist/notebook-placement.js +41 -0
- package/dist/notebook-provider-failure.js +87 -0
- package/dist/notebook-published-post.js +26 -0
- package/dist/notebook-reference-resolver.js +227 -0
- package/dist/notebook-relayout.js +270 -0
- package/dist/notebook-run-plan.js +519 -0
- package/dist/notebook-shots.js +162 -0
- package/dist/notebook-workflow.js +856 -0
- package/dist/one-password.js +200 -0
- package/dist/openai-intelligence.js +99 -0
- package/dist/original-media-file.js +12 -0
- package/dist/osg-assets.js +36 -0
- package/dist/osg-placement-cache.js +64 -0
- package/dist/osg-settings.js +27 -0
- package/dist/paid-tools.js +22 -0
- package/dist/platform-guidance.js +26 -0
- package/dist/posts/dropbox-auth.js +91 -0
- package/dist/posts/dropbox-upload.js +132 -0
- package/dist/posts/icloud-drive.js +134 -0
- package/dist/posts/icloud-status.js +64 -0
- package/dist/posts/post-contract.js +2 -0
- package/dist/posts/post-copy-format.js +43 -0
- package/dist/posts/post-copy.js +193 -0
- package/dist/posts/post-folder.js +18 -0
- package/dist/posts/post-metrics.js +119 -0
- package/dist/posts/post-store.js +340 -0
- package/dist/posts/x-post-target.js +43 -0
- package/dist/preview-payload.js +90 -0
- package/dist/prompt-surfaces.js +22 -0
- package/dist/provider-prompt-transform.js +77 -0
- package/dist/provider-status-link.js +21 -0
- package/dist/provider-task-record.js +78 -0
- package/dist/provider-task-status.js +47 -0
- package/dist/provider-usage.js +294 -0
- package/dist/queue.js +810 -0
- package/dist/reference-video-duration.js +17 -0
- package/dist/remotion/BlurFillVideo.js +51 -0
- package/dist/remotion/KeywordGraphicsOverlay.js +68 -0
- package/dist/remotion/OsgOverlay.js +30 -0
- package/dist/remotion/QrOutroComposition.js +47 -0
- package/dist/remotion/RenderComposition.js +11 -0
- package/dist/remotion/browser.js +59 -0
- package/dist/remotion/constants.js +35 -0
- package/dist/remotion/index.js +66 -0
- package/dist/remotion/keyword-graphics.js +151 -0
- package/dist/remotion/keyword-placement.js +182 -0
- package/dist/remotion/osg-spec.js +198 -0
- package/dist/remotion/public/qr-outro-impact.wav +0 -0
- package/dist/remotion/qr-outro-audio.js +1 -0
- package/dist/remotion/qr-outro-spec.js +211 -0
- package/dist/remotion/shared-bundle.js +37 -0
- package/dist/remotion/subtitles/AliveCaptions.js +83 -0
- package/dist/remotion/subtitles/Highlight.js +58 -0
- package/dist/remotion/subtitles/Impact.js +67 -0
- package/dist/remotion/subtitles/SubtitleOverlay.js +9 -0
- package/dist/remotion/subtitles/alive-layout.js +321 -0
- package/dist/remotion/subtitles/alive-types.js +17 -0
- package/dist/remotion/subtitles/chunker.js +68 -0
- package/dist/remotion/subtitles/segments.js +42 -0
- package/dist/remotion/subtitles/styles.js +4 -0
- package/dist/remotion/subtitles/types.js +1 -0
- package/dist/remotion/util.js +18 -0
- package/dist/remotion-cancellation.js +15 -0
- package/dist/rename-helpers.js +204 -0
- package/dist/rhythm/analyze.js +128 -0
- package/dist/rhythm/contract.js +14 -0
- package/dist/rhythm/draft-model.js +19 -0
- package/dist/rhythm/energy.js +133 -0
- package/dist/rhythm/fft.js +44 -0
- package/dist/rhythm/model.js +71 -0
- package/dist/rhythm/music-analysis.js +124 -0
- package/dist/rhythm/music-draft.js +261 -0
- package/dist/rhythm/onset.js +101 -0
- package/dist/rhythm/run-worker.js +51 -0
- package/dist/rhythm/score.js +47 -0
- package/dist/rhythm/section-labels.js +168 -0
- package/dist/rhythm/sequence-rhythm.js +67 -0
- package/dist/rhythm/synthesize.js +103 -0
- package/dist/rhythm/timing.js +98 -0
- package/dist/rhythm/track.js +320 -0
- package/dist/rhythm/visual-fit.js +4 -0
- package/dist/rhythm/worker.js +25 -0
- package/dist/scene-detect.js +200 -0
- package/dist/scene-transition.js +12 -0
- package/dist/scheduled-posts.js +200 -0
- package/dist/search-index-coverage.js +13 -0
- package/dist/search-index-media.js +71 -0
- package/dist/search-reference-store.js +60 -0
- package/dist/search-scoring.js +17 -0
- package/dist/serve.js +125 -0
- package/dist/server-lock.js +143 -0
- package/dist/server.js +42 -0
- package/dist/srt.js +16 -0
- package/dist/tag-backfill-state.js +121 -0
- package/dist/tag-settings.js +30 -0
- package/dist/tag-vocabulary.js +237 -0
- package/dist/test-queue-cleanup.js +1 -0
- package/dist/time-parse.js +50 -0
- package/dist/timeline-helpers.js +554 -0
- package/dist/timewarp.js +87 -0
- package/dist/tools/_image-inputs.js +9 -0
- package/dist/tools/_media-refs.js +84 -0
- package/dist/tools/_shared.js +59 -0
- package/dist/tools/_suggest-shared.js +279 -0
- package/dist/tools/add-timeline-audio.js +73 -0
- package/dist/tools/alive-captions.js +157 -0
- package/dist/tools/analyze-jokes.js +56 -0
- package/dist/tools/analyze-video.js +66 -0
- package/dist/tools/animate-keywords.js +217 -0
- package/dist/tools/api-status.js +42 -0
- package/dist/tools/application-commands.js +34 -0
- package/dist/tools/apply-cuts.js +112 -0
- package/dist/tools/apply-sfx.js +152 -0
- package/dist/tools/apply-watermark.js +670 -0
- package/dist/tools/archive-clip.js +74 -0
- package/dist/tools/asset-history.js +61 -0
- package/dist/tools/asset-manifest.js +24 -0
- package/dist/tools/asset-tags.js +151 -0
- package/dist/tools/assign-slot.js +97 -0
- package/dist/tools/audio-boost.js +107 -0
- package/dist/tools/audio-mix.js +121 -0
- package/dist/tools/book-usage.js +16 -0
- package/dist/tools/chain.js +136 -0
- package/dist/tools/change-video-speed.js +105 -0
- package/dist/tools/chat-history.js +5 -0
- package/dist/tools/chat.js +848 -0
- package/dist/tools/clean-video-audio.js +97 -0
- package/dist/tools/clear-failed-tasks.js +66 -0
- package/dist/tools/cold-open.js +114 -0
- package/dist/tools/command-plan.js +1680 -0
- package/dist/tools/commands.js +1666 -0
- package/dist/tools/concat-images.js +236 -0
- package/dist/tools/connect-service.js +55 -0
- package/dist/tools/copy-file-to-clipboard.js +58 -0
- package/dist/tools/create-character.js +114 -0
- package/dist/tools/create-qart.js +253 -0
- package/dist/tools/create-qr-outro.js +149 -0
- package/dist/tools/create-qrbtf.js +215 -0
- package/dist/tools/create-watermark.js +97 -0
- package/dist/tools/crop-asset.js +18 -0
- package/dist/tools/crop-image.js +120 -0
- package/dist/tools/crop-video.js +97 -0
- package/dist/tools/delete-asset.js +104 -0
- package/dist/tools/describe-image.js +69 -0
- package/dist/tools/detect-scenes.js +44 -0
- package/dist/tools/doctor.js +126 -0
- package/dist/tools/download-video.js +114 -0
- package/dist/tools/duplicate-asset.js +184 -0
- package/dist/tools/edit-timeline.js +59 -0
- package/dist/tools/editing-moments.js +105 -0
- package/dist/tools/estimate-cost.js +171 -0
- package/dist/tools/even-split.js +295 -0
- package/dist/tools/export-asset-file.js +22 -0
- package/dist/tools/export-asset.js +140 -0
- package/dist/tools/export-sequence.js +250 -0
- package/dist/tools/export-to-downloads.js +54 -0
- package/dist/tools/export-transcript-srt.js +79 -0
- package/dist/tools/extend-audio.js +100 -0
- package/dist/tools/extract-audio.js +174 -0
- package/dist/tools/extract-frame.js +108 -0
- package/dist/tools/extract-notebook-audio.js +173 -0
- package/dist/tools/extract-notebook-frame.js +160 -0
- package/dist/tools/extract-video-clip.js +101 -0
- package/dist/tools/generate-media.js +157 -0
- package/dist/tools/generation-payload.js +48 -0
- package/dist/tools/get-timeline.js +12 -0
- package/dist/tools/get-watermark-config.js +38 -0
- package/dist/tools/goal.js +644 -0
- package/dist/tools/image-subjects.js +711 -0
- package/dist/tools/index.js +323 -0
- package/dist/tools/inject-first-frame.js +154 -0
- package/dist/tools/invert-image.js +70 -0
- package/dist/tools/isolate-vocals.js +66 -0
- package/dist/tools/list-assets.js +98 -0
- package/dist/tools/list-cell-generations.js +225 -0
- package/dist/tools/list-elevenlabs-voices.js +163 -0
- package/dist/tools/log-wrapper.js +29 -0
- package/dist/tools/make-cover-song.js +95 -0
- package/dist/tools/mark-asset-seen.js +23 -0
- package/dist/tools/media-library.js +245 -0
- package/dist/tools/move-timeline-audio.js +35 -0
- package/dist/tools/music-analysis.js +60 -0
- package/dist/tools/music-draft.js +29 -0
- package/dist/tools/pad-video.js +87 -0
- package/dist/tools/post-record.js +83 -0
- package/dist/tools/post.js +168 -0
- package/dist/tools/prompt-history.js +164 -0
- package/dist/tools/provider-key-status.js +248 -0
- package/dist/tools/qrbtf-render.js +849 -0
- package/dist/tools/read-asset-metadata.js +26 -0
- package/dist/tools/read-file-at-commit.js +29 -0
- package/dist/tools/read-transcript.js +41 -0
- package/dist/tools/reconcile-project-work.js +1452 -0
- package/dist/tools/recover-asset.js +28 -0
- package/dist/tools/remove-sound.js +72 -0
- package/dist/tools/remove-timeline-audio.js +34 -0
- package/dist/tools/remove-timeline-slot.js +40 -0
- package/dist/tools/rename-all.js +434 -0
- package/dist/tools/rename-asset.js +34 -0
- package/dist/tools/render-settings.js +47 -0
- package/dist/tools/render-timeline.js +120 -0
- package/dist/tools/render.js +384 -0
- package/dist/tools/reorder-character-images.js +45 -0
- package/dist/tools/replace-video-audio.js +133 -0
- package/dist/tools/restore-archive-clips.js +209 -0
- package/dist/tools/restore-asset-version.js +37 -0
- package/dist/tools/retry-generation.js +54 -0
- package/dist/tools/reverse-video.js +74 -0
- package/dist/tools/rewrite-prompt.js +388 -0
- package/dist/tools/rewrite-script.js +67 -0
- package/dist/tools/schema-from-apicity.js +66 -0
- package/dist/tools/search-archive.js +150 -0
- package/dist/tools/semantic-search.js +1214 -0
- package/dist/tools/sequence-rhythm.js +43 -0
- package/dist/tools/set-character-metadata.js +84 -0
- package/dist/tools/set-env-secret.js +40 -0
- package/dist/tools/set-osg.js +143 -0
- package/dist/tools/show-folder.js +37 -0
- package/dist/tools/smooth-scene-concat.js +122 -0
- package/dist/tools/splice-video.js +149 -0
- package/dist/tools/split-video.js +202 -0
- package/dist/tools/suggest-cuts.js +45 -0
- package/dist/tools/suggest-sfx.js +43 -0
- package/dist/tools/sync-video-to-audio.js +115 -0
- package/dist/tools/tag-backfill.js +177 -0
- package/dist/tools/timewarp-video.js +85 -0
- package/dist/tools/tool-def.js +1 -0
- package/dist/tools/tool-json-schema.js +116 -0
- package/dist/tools/transcribe.js +90 -0
- package/dist/tools/translate-subtitles.js +59 -0
- package/dist/tools/trim-audio.js +139 -0
- package/dist/tools/trim-video.js +168 -0
- package/dist/tools/update-script.js +25 -0
- package/dist/tools/update-timeline-audio.js +40 -0
- package/dist/tools/upload-file.js +41 -0
- package/dist/tools/verify-x-mentions.js +141 -0
- package/dist/tools/video-editing-command-contract.js +291 -0
- package/dist/tools/video-source-reference.js +30 -0
- package/dist/tools/video-time-input.js +18 -0
- package/dist/tools/videobook-domain.js +2021 -0
- package/dist/tools/wait-for-asset-ready.js +143 -0
- package/dist/tools/workspace-actions.js +54 -0
- package/dist/transcript-projection.js +202 -0
- package/dist/transcript-srt.js +33 -0
- package/dist/upload.js +76 -0
- package/dist/usage-providers.js +25 -0
- package/dist/video-analysis-projection.js +46 -0
- package/dist/video-poster.js +33 -0
- package/dist/video-proxy.js +99 -0
- package/dist/vision-regions.js +111 -0
- package/dist/voice-actions.js +90 -0
- package/dist/voice-audio.js +55 -0
- package/dist/voice-config.js +122 -0
- package/dist/voice-continuation.js +54 -0
- package/dist/voice-contract.js +1 -0
- package/dist/voice-http.js +145 -0
- package/dist/voice-reply-progress.js +55 -0
- package/dist/voice-session.js +992 -0
- package/dist/watermark-badge.js +259 -0
- package/dist/watermark-config.js +111 -0
- package/dist/watermark-handle-position.js +55 -0
- package/dist/watermark-platform.js +15 -0
- package/dist/watermark-timing.js +16 -0
- package/dist/workspace-action-catalog.js +315 -0
- package/dist/workspace-action-contract.js +21 -0
- package/dist/workspace-action-groups.js +98 -0
- package/dist/workspace-action-surfaces.js +7 -0
- package/dist/x/account.js +88 -0
- package/dist/x/authenticated-handle.js +30 -0
- package/dist/x/oauth-flow.js +191 -0
- package/dist/x/post-contract.js +1 -0
- package/dist/x/post-metadata.js +44 -0
- package/dist/x/post-to-x.js +456 -0
- package/dist/x/published-post-cell.js +90 -0
- package/dist/x/x-tokens.js +69 -0
- package/dist/ytdlp-binary.js +65 -0
- package/dist/zod-slots.js +334 -0
- package/package.json +84 -4
- package/ui/assets/alive-captions-BWb5nLKj.css +1 -0
- package/ui/assets/alive-captions-DPEr1nKM.js +1 -0
- package/ui/assets/confirm-bodies-D8ouHXKy.js +1 -0
- package/ui/assets/confirm-bodies-DrMhaXC6.css +1 -0
- package/ui/assets/fullscreen-B7nw4YbE.js +1 -0
- package/ui/assets/goal-ui-DK-xTCK0.js +2 -0
- package/ui/assets/goal-ui-DXdUM2KF.css +1 -0
- package/ui/assets/index-DzPAnCUj.css +1 -0
- package/ui/assets/index-kS1905s5.js +37 -0
- package/ui/assets/inspector-MlzQbTVo.js +1 -0
- package/ui/assets/jobs-ui-CoinOWx0.js +1 -0
- package/ui/assets/music-video-Cbe80kmQ.js +1 -0
- package/ui/assets/music-video-DPaiKKEq.css +1 -0
- package/ui/assets/ui-Oirr9VOf.css +1 -0
- package/ui/assets/ui-xo_Y1yQg.js +2 -0
- package/ui/assets/vendor-D2rfiZ5j.css +1 -0
- package/ui/assets/vendor-DfTCWgKm.js +19 -0
- package/ui/assets/vendor-flow-BXbeWxW7.js +7 -0
- package/ui/assets/vendor-flow-BnuhLJ6X.css +1 -0
- package/ui/assets/vendor-icons-CGqhCIXV.js +1 -0
- package/ui/assets/vendor-mcp-BTlEJcHV.js +67 -0
- package/ui/assets/vendor-react-Dj7D1fD4.js +9 -0
- package/ui/assets/vendor-remotion-CH1HXrlc.js +95 -0
- package/ui/assets/videobook-Qlp9HQFu.js +20 -0
- package/ui/favicon.svg +8 -0
- package/ui/index.html +126 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { findAudioFile, findPrimaryMediaFile, findVideoFile, MVP_CONTRACT_VERSION, isUuidV7, normalizeRational, sourceTicksToSequenceFrames, } from "videobook-engine";
|
|
3
|
+
import { v7 as uuidv7 } from "uuid";
|
|
4
|
+
import { probeVideo } from "./ffmpeg.js";
|
|
5
|
+
const CANVAS = {
|
|
6
|
+
landscape: { width: 1920, height: 1080 },
|
|
7
|
+
portrait: { width: 1080, height: 1920 },
|
|
8
|
+
square: { width: 1080, height: 1080 },
|
|
9
|
+
};
|
|
10
|
+
function orientation(sequence) {
|
|
11
|
+
if (sequence.width === sequence.height)
|
|
12
|
+
return "square";
|
|
13
|
+
return sequence.width > sequence.height ? "landscape" : "portrait";
|
|
14
|
+
}
|
|
15
|
+
function clipsForTrack(sequence, trackId) {
|
|
16
|
+
return sequence.clips
|
|
17
|
+
.filter((clip) => clip.trackId === trackId)
|
|
18
|
+
.sort((left, right) => left.timelineStartFrame - right.timelineStartFrame
|
|
19
|
+
|| left.clipId.localeCompare(right.clipId));
|
|
20
|
+
}
|
|
21
|
+
function gainDbToVolume(gainDb) {
|
|
22
|
+
if (gainDb <= -120)
|
|
23
|
+
return 0;
|
|
24
|
+
return Math.round(100_000_000 * (10 ** (gainDb / 20))) / 1_000_000;
|
|
25
|
+
}
|
|
26
|
+
function volumeToGainDb(volume) {
|
|
27
|
+
if (volume === undefined)
|
|
28
|
+
return 0;
|
|
29
|
+
if (volume <= 0)
|
|
30
|
+
return -120;
|
|
31
|
+
return 20 * Math.log10(volume / 100);
|
|
32
|
+
}
|
|
33
|
+
function clipVolume(clip) {
|
|
34
|
+
return clip.audio ? { volume: clip.audio.muted ? 0 : gainDbToVolume(clip.audio.gainDb) } : {};
|
|
35
|
+
}
|
|
36
|
+
function secondsFromFrames(frames, sequence) {
|
|
37
|
+
return frames * sequence.frameRate.denominator / sequence.frameRate.numerator;
|
|
38
|
+
}
|
|
39
|
+
function millisecondsFromFrames(frames, sequence) {
|
|
40
|
+
return Math.round(secondsFromFrames(frames, sequence) * 1_000_000) / 1_000;
|
|
41
|
+
}
|
|
42
|
+
function framesFromSeconds(seconds, sequence) {
|
|
43
|
+
return Math.max(0, Math.round(seconds * sequence.frameRate.numerator / sequence.frameRate.denominator));
|
|
44
|
+
}
|
|
45
|
+
function framesFromMilliseconds(milliseconds, sequence) {
|
|
46
|
+
return framesFromSeconds(milliseconds / 1_000, sequence);
|
|
47
|
+
}
|
|
48
|
+
export function readTimeline(engine) {
|
|
49
|
+
const sequence = engine.sequences.getPrimary();
|
|
50
|
+
const primaryVideoTrack = sequence.tracks
|
|
51
|
+
.filter((track) => track.kind === "video")
|
|
52
|
+
.sort((left, right) => left.ordinal - right.ordinal)[0];
|
|
53
|
+
const audioTrackIds = new Set(sequence.tracks
|
|
54
|
+
.filter((track) => track.kind === "audio")
|
|
55
|
+
.map((track) => track.trackId));
|
|
56
|
+
const slots = primaryVideoTrack
|
|
57
|
+
? clipsForTrack(sequence, primaryVideoTrack.trackId).map((clip) => ({
|
|
58
|
+
id: clip.clipId,
|
|
59
|
+
artifactId: clip.source.artifactId,
|
|
60
|
+
...clipVolume(clip),
|
|
61
|
+
...(clip.audio
|
|
62
|
+
? {
|
|
63
|
+
audioFadeIn: secondsFromFrames(clip.audio.fadeInFrames, sequence),
|
|
64
|
+
audioFadeOut: secondsFromFrames(clip.audio.fadeOutFrames, sequence),
|
|
65
|
+
}
|
|
66
|
+
: {}),
|
|
67
|
+
}))
|
|
68
|
+
: [];
|
|
69
|
+
const audio = sequence.clips
|
|
70
|
+
.filter((clip) => audioTrackIds.has(clip.trackId))
|
|
71
|
+
.sort((left, right) => left.timelineStartFrame - right.timelineStartFrame
|
|
72
|
+
|| left.clipId.localeCompare(right.clipId))
|
|
73
|
+
.map((clip) => ({
|
|
74
|
+
id: clip.clipId,
|
|
75
|
+
artifactId: clip.source.artifactId,
|
|
76
|
+
startFrame: clip.timelineStartFrame,
|
|
77
|
+
durationFrames: clip.durationFrames,
|
|
78
|
+
...clipVolume(clip),
|
|
79
|
+
...(clip.audio
|
|
80
|
+
? {
|
|
81
|
+
fadeIn: millisecondsFromFrames(clip.audio.fadeInFrames, sequence),
|
|
82
|
+
fadeOut: millisecondsFromFrames(clip.audio.fadeOutFrames, sequence),
|
|
83
|
+
}
|
|
84
|
+
: {}),
|
|
85
|
+
}));
|
|
86
|
+
return {
|
|
87
|
+
bookId: engine.book.get().bookId,
|
|
88
|
+
render: orientation(sequence),
|
|
89
|
+
slots,
|
|
90
|
+
audio,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function timelinePayload(timeline) {
|
|
94
|
+
return {
|
|
95
|
+
book_id: timeline.bookId,
|
|
96
|
+
render: timeline.render,
|
|
97
|
+
slots: timeline.slots.map((slot) => ({
|
|
98
|
+
id: slot.id,
|
|
99
|
+
artifact_id: slot.artifactId,
|
|
100
|
+
...(slot.volume === undefined ? {} : { volume: slot.volume }),
|
|
101
|
+
...(slot.audioFadeIn === undefined ? {} : { audioFadeIn: slot.audioFadeIn }),
|
|
102
|
+
...(slot.audioFadeOut === undefined ? {} : { audioFadeOut: slot.audioFadeOut }),
|
|
103
|
+
})),
|
|
104
|
+
audio: timeline.audio.map((clip) => ({
|
|
105
|
+
id: clip.id,
|
|
106
|
+
artifact_id: clip.artifactId,
|
|
107
|
+
start_frame: clip.startFrame,
|
|
108
|
+
duration_frames: clip.durationFrames,
|
|
109
|
+
...(clip.volume === undefined ? {} : { volume: clip.volume }),
|
|
110
|
+
...(clip.fadeIn === undefined ? {} : { fadeIn: clip.fadeIn }),
|
|
111
|
+
...(clip.fadeOut === undefined ? {} : { fadeOut: clip.fadeOut }),
|
|
112
|
+
})),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function timelineInput(timeline) {
|
|
116
|
+
return {
|
|
117
|
+
render: timeline.render,
|
|
118
|
+
slots: timeline.slots.map((slot) => ({
|
|
119
|
+
id: slot.id,
|
|
120
|
+
artifactId: slot.artifactId,
|
|
121
|
+
...(slot.volume === undefined ? {} : { volume: slot.volume }),
|
|
122
|
+
...(slot.audioFadeIn === undefined ? {} : { audioFadeIn: slot.audioFadeIn }),
|
|
123
|
+
...(slot.audioFadeOut === undefined ? {} : { audioFadeOut: slot.audioFadeOut }),
|
|
124
|
+
})),
|
|
125
|
+
audio: timeline.audio.map((clip) => ({
|
|
126
|
+
id: clip.id,
|
|
127
|
+
artifactId: clip.artifactId,
|
|
128
|
+
startFrame: clip.startFrame,
|
|
129
|
+
durationFrames: clip.durationFrames,
|
|
130
|
+
...(clip.volume === undefined ? {} : { volume: clip.volume }),
|
|
131
|
+
...(clip.fadeIn === undefined ? {} : { fadeIn: clip.fadeIn }),
|
|
132
|
+
...(clip.fadeOut === undefined ? {} : { fadeOut: clip.fadeOut }),
|
|
133
|
+
})),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function timelineSuccessResult(timeline) {
|
|
137
|
+
return { ok: true, value: timeline };
|
|
138
|
+
}
|
|
139
|
+
function timelineError(error) {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
error: {
|
|
143
|
+
message: error instanceof Error ? error.message : String(error),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function requiredArtifact(engine, reference) {
|
|
148
|
+
const result = engine.artifacts.get(reference);
|
|
149
|
+
if (!result.ok)
|
|
150
|
+
throw new Error(result.error.message);
|
|
151
|
+
return result.value;
|
|
152
|
+
}
|
|
153
|
+
async function requiredTimedStream(engine, artifact, kind) {
|
|
154
|
+
const manifest = await engine.files.manifest(artifact.artifactId);
|
|
155
|
+
if (!manifest.ok)
|
|
156
|
+
throw new Error(manifest.error.message);
|
|
157
|
+
const file = kind === "video"
|
|
158
|
+
? findVideoFile(manifest.value.files)
|
|
159
|
+
: findAudioFile(manifest.value.files, artifact.kind)
|
|
160
|
+
?? findPrimaryMediaFile(manifest.value.files, artifact.kind);
|
|
161
|
+
if (!file) {
|
|
162
|
+
throw new Error(`${artifact.label ?? artifact.artifactId} has no ${kind} source file`);
|
|
163
|
+
}
|
|
164
|
+
const existing = engine.streams.list(artifact.artifactId);
|
|
165
|
+
if (!existing.ok)
|
|
166
|
+
throw new Error(existing.error.message);
|
|
167
|
+
const registered = existing.value.find((stream) => stream.kind === kind
|
|
168
|
+
&& stream.sourcePath === file.name
|
|
169
|
+
&& stream.objectHash === file.objectHash);
|
|
170
|
+
if (registered)
|
|
171
|
+
return registered;
|
|
172
|
+
const probe = await probeVideo(join(manifest.value.path, file.name));
|
|
173
|
+
const stream = kind === "video" ? probe.videoStream : probe.audioStream;
|
|
174
|
+
if (!stream)
|
|
175
|
+
throw new Error(`${artifact.label ?? artifact.artifactId} has no ${kind} stream`);
|
|
176
|
+
const result = await engine.streams.register({
|
|
177
|
+
artifactId: artifact.artifactId,
|
|
178
|
+
sourcePath: file.name,
|
|
179
|
+
objectHash: file.objectHash,
|
|
180
|
+
streamIndex: stream.index,
|
|
181
|
+
kind,
|
|
182
|
+
timeBase: stream.timeBase,
|
|
183
|
+
durationTicks: stream.durationTicks,
|
|
184
|
+
codec: stream.codec,
|
|
185
|
+
...(stream.video ? { video: stream.video } : {}),
|
|
186
|
+
...(stream.audio ? { audio: stream.audio } : {}),
|
|
187
|
+
});
|
|
188
|
+
if (!result.ok)
|
|
189
|
+
throw new Error(result.error.message);
|
|
190
|
+
return result.value;
|
|
191
|
+
}
|
|
192
|
+
async function slotSource(engine, artifactId) {
|
|
193
|
+
const artifact = requiredArtifact(engine, artifactId);
|
|
194
|
+
const sequence = engine.sequences.getPrimary();
|
|
195
|
+
if (artifact.kind === "image") {
|
|
196
|
+
const manifest = await engine.files.manifest(artifact.artifactId);
|
|
197
|
+
if (!manifest.ok)
|
|
198
|
+
throw new Error(manifest.error.message);
|
|
199
|
+
const file = findPrimaryMediaFile(manifest.value.files, artifact.kind);
|
|
200
|
+
if (!file)
|
|
201
|
+
throw new Error(`${artifact.label ?? artifact.artifactId} has no image source file`);
|
|
202
|
+
return {
|
|
203
|
+
source: {
|
|
204
|
+
kind: "still",
|
|
205
|
+
artifactId: artifact.artifactId,
|
|
206
|
+
sourcePath: file.name,
|
|
207
|
+
objectHash: file.objectHash,
|
|
208
|
+
},
|
|
209
|
+
durationFrames: framesFromSeconds(3, sequence),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const stream = await requiredTimedStream(engine, artifact, "video");
|
|
213
|
+
return {
|
|
214
|
+
source: {
|
|
215
|
+
kind: "timed",
|
|
216
|
+
artifactId: artifact.artifactId,
|
|
217
|
+
range: {
|
|
218
|
+
streamId: stream.streamId,
|
|
219
|
+
objectHash: stream.objectHash,
|
|
220
|
+
startTick: 0,
|
|
221
|
+
durationTicks: stream.durationTicks,
|
|
222
|
+
timeBase: stream.timeBase,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
durationFrames: Math.max(1, sourceTicksToSequenceFrames(stream.durationTicks, stream.timeBase, sequence.frameRate)),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
async function audioSource(engine, artifactId) {
|
|
229
|
+
const artifact = requiredArtifact(engine, artifactId);
|
|
230
|
+
const sequence = engine.sequences.getPrimary();
|
|
231
|
+
const stream = await requiredTimedStream(engine, artifact, "audio");
|
|
232
|
+
return {
|
|
233
|
+
source: {
|
|
234
|
+
kind: "timed",
|
|
235
|
+
artifactId: artifact.artifactId,
|
|
236
|
+
range: {
|
|
237
|
+
streamId: stream.streamId,
|
|
238
|
+
objectHash: stream.objectHash,
|
|
239
|
+
startTick: 0,
|
|
240
|
+
durationTicks: stream.durationTicks,
|
|
241
|
+
timeBase: stream.timeBase,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
sourceFrames: Math.max(1, sourceTicksToSequenceFrames(stream.durationTicks, stream.timeBase, sequence.frameRate)),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function clipAudio(durationFrames, volume, requestedFadeInFrames, requestedFadeOutFrames, existing) {
|
|
248
|
+
const previous = existing?.audio;
|
|
249
|
+
if (!previous && volume === undefined && !requestedFadeInFrames && !requestedFadeOutFrames) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const preserveGain = previous && (volume === undefined || volume === clipVolume(existing).volume);
|
|
253
|
+
const fadeInFrames = Math.min(durationFrames, requestedFadeInFrames ?? previous?.fadeInFrames ?? 0);
|
|
254
|
+
const fadeOutFrames = Math.min(durationFrames - fadeInFrames, requestedFadeOutFrames ?? previous?.fadeOutFrames ?? 0);
|
|
255
|
+
return {
|
|
256
|
+
gainDb: preserveGain ? previous.gainDb : volumeToGainDb(volume),
|
|
257
|
+
muted: preserveGain ? previous.muted : volume === 0,
|
|
258
|
+
fadeInFrames,
|
|
259
|
+
fadeOutFrames,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function placementFromClip(clip) {
|
|
263
|
+
return {
|
|
264
|
+
trackId: clip.trackId,
|
|
265
|
+
timelineStartFrame: clip.timelineStartFrame,
|
|
266
|
+
durationFrames: clip.durationFrames,
|
|
267
|
+
source: clip.source,
|
|
268
|
+
...("speed" in clip ? { speed: clip.speed, reverse: clip.reverse, audioPolicy: clip.audioPolicy } : {}),
|
|
269
|
+
...(clip.transform ? { transform: clip.transform } : {}),
|
|
270
|
+
...(clip.audio ? { audio: clip.audio } : {}),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function validateTimelineInput(engine, sequence, input, trackIds) {
|
|
274
|
+
const ids = new Set();
|
|
275
|
+
for (const entry of [...input.slots ?? [], ...input.audio ?? []]) {
|
|
276
|
+
if (entry.id) {
|
|
277
|
+
if (!isUuidV7(entry.id))
|
|
278
|
+
throw new Error(`Clip ID must be a UUIDv7: ${entry.id}`);
|
|
279
|
+
if (ids.has(entry.id))
|
|
280
|
+
throw new Error(`Duplicate clip ID: ${entry.id}`);
|
|
281
|
+
ids.add(entry.id);
|
|
282
|
+
const existing = sequence.clips.find((clip) => clip.clipId === entry.id);
|
|
283
|
+
if (existing && !trackIds.has(existing.trackId)) {
|
|
284
|
+
throw new Error(`Clip belongs to a track outside the compatibility timeline: ${entry.id}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
requiredArtifact(engine, entry.artifactId);
|
|
288
|
+
}
|
|
289
|
+
for (const clip of input.audio ?? []) {
|
|
290
|
+
if (!Number.isSafeInteger(clip.startFrame) || clip.startFrame < 0
|
|
291
|
+
|| !Number.isSafeInteger(clip.durationFrames) || clip.durationFrames < 1
|
|
292
|
+
|| !Number.isSafeInteger(clip.startFrame + clip.durationFrames)) {
|
|
293
|
+
throw new Error("Audio timeline range must use safe non-negative integer frames");
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
async function planSlots(engine, sequence, slots, trackId) {
|
|
298
|
+
const previous = clipsForTrack(sequence, trackId);
|
|
299
|
+
const retainedIds = new Set(slots.map((slot) => slot.id));
|
|
300
|
+
const retained = previous.filter((clip) => retainedIds.has(clip.clipId));
|
|
301
|
+
const preservesOrder = retained.length === slots.length && slots.every((slot, index) => slot.id === retained[index]?.clipId && slot.artifactId === retained[index]?.source.artifactId);
|
|
302
|
+
let nextStart = 0;
|
|
303
|
+
const planned = [];
|
|
304
|
+
for (const slot of slots) {
|
|
305
|
+
const existing = previous.find((clip) => clip.clipId === slot.id && clip.source.artifactId === slot.artifactId);
|
|
306
|
+
const source = existing ? undefined : await slotSource(engine, slot.artifactId);
|
|
307
|
+
const base = existing ? placementFromClip(existing) : {
|
|
308
|
+
trackId,
|
|
309
|
+
timelineStartFrame: nextStart,
|
|
310
|
+
durationFrames: source.durationFrames,
|
|
311
|
+
source: source.source,
|
|
312
|
+
...(source.source.kind === "timed" ? {
|
|
313
|
+
speed: { numerator: 1, denominator: 1 }, reverse: false, audioPolicy: "preserve-pitch",
|
|
314
|
+
} : {}),
|
|
315
|
+
};
|
|
316
|
+
const audio = clipAudio(base.durationFrames, slot.volume, slot.audioFadeIn === undefined ? undefined : framesFromSeconds(slot.audioFadeIn, sequence), slot.audioFadeOut === undefined ? undefined : framesFromSeconds(slot.audioFadeOut, sequence), existing);
|
|
317
|
+
const placement = {
|
|
318
|
+
...base,
|
|
319
|
+
timelineStartFrame: preservesOrder
|
|
320
|
+
? base.timelineStartFrame - previous.filter((clip) => !retainedIds.has(clip.clipId)
|
|
321
|
+
&& clip.timelineStartFrame < base.timelineStartFrame).reduce((total, clip) => total + clip.durationFrames, 0)
|
|
322
|
+
: nextStart,
|
|
323
|
+
...(audio ? { audio } : {}),
|
|
324
|
+
};
|
|
325
|
+
nextStart = placement.timelineStartFrame + placement.durationFrames;
|
|
326
|
+
if (!Number.isSafeInteger(nextStart))
|
|
327
|
+
throw new Error("Timeline exceeds safe integer precision");
|
|
328
|
+
planned.push({ clipId: slot.id ?? uuidv7(), existing, placement });
|
|
329
|
+
}
|
|
330
|
+
return planned;
|
|
331
|
+
}
|
|
332
|
+
async function planAudio(engine, sequence, audio) {
|
|
333
|
+
const audioTracks = sequence.tracks.filter((track) => track.kind === "audio");
|
|
334
|
+
const planned = [];
|
|
335
|
+
for (const clip of audio) {
|
|
336
|
+
const existing = sequence.clips.find((candidate) => candidate.clipId === clip.id
|
|
337
|
+
&& candidate.source.artifactId === clip.artifactId
|
|
338
|
+
&& audioTracks.some((track) => track.trackId === candidate.trackId));
|
|
339
|
+
const source = existing ? undefined : await audioSource(engine, clip.artifactId);
|
|
340
|
+
const base = existing ? placementFromClip(existing) : {
|
|
341
|
+
trackId: "", timelineStartFrame: clip.startFrame, durationFrames: clip.durationFrames,
|
|
342
|
+
source: source.source, reverse: false, audioPolicy: "preserve-pitch",
|
|
343
|
+
speed: normalizeRational({ numerator: source.sourceFrames, denominator: clip.durationFrames }),
|
|
344
|
+
};
|
|
345
|
+
const speed = existing && "speed" in existing && existing.durationFrames !== clip.durationFrames
|
|
346
|
+
? normalizeRational({ numerator: existing.speed.numerator * existing.durationFrames,
|
|
347
|
+
denominator: existing.speed.denominator * clip.durationFrames })
|
|
348
|
+
: base.speed;
|
|
349
|
+
const settings = clipAudio(clip.durationFrames, clip.volume, clip.fadeIn === undefined ? undefined : framesFromMilliseconds(clip.fadeIn, sequence), clip.fadeOut === undefined ? undefined : framesFromMilliseconds(clip.fadeOut, sequence), existing);
|
|
350
|
+
planned.push({ clipId: clip.id ?? uuidv7(), existing, placement: {
|
|
351
|
+
...base, timelineStartFrame: clip.startFrame, durationFrames: clip.durationFrames,
|
|
352
|
+
...(speed ? { speed } : {}), ...(settings ? { audio: settings } : {}),
|
|
353
|
+
} });
|
|
354
|
+
}
|
|
355
|
+
return planned;
|
|
356
|
+
}
|
|
357
|
+
function endFrame(clip) {
|
|
358
|
+
return clip.timelineStartFrame + clip.durationFrames;
|
|
359
|
+
}
|
|
360
|
+
function allocateAudioLanes(sequence, clips) {
|
|
361
|
+
const tracks = sequence.tracks.filter((track) => track.kind === "audio").sort((left, right) => left.ordinal - right.ordinal);
|
|
362
|
+
const lanes = tracks.map((track) => ({ ...track, clips: [] }));
|
|
363
|
+
const ordered = [...clips].sort((left, right) => Number(!left.existing || left.placement.timelineStartFrame !== left.existing.timelineStartFrame)
|
|
364
|
+
- Number(!right.existing || right.placement.timelineStartFrame !== right.existing.timelineStartFrame));
|
|
365
|
+
for (const clip of ordered) {
|
|
366
|
+
const fits = (lane) => lane.clips.every((entry) => entry.timelineStartFrame >= endFrame(clip.placement) || clip.placement.timelineStartFrame >= endFrame(entry));
|
|
367
|
+
const preferred = lanes.find((lane) => lane.trackId === clip.existing?.trackId);
|
|
368
|
+
const settings = { enabled: preferred?.enabled ?? true, muted: preferred?.muted ?? false, solo: preferred?.solo ?? false };
|
|
369
|
+
let lane = preferred && fits(preferred) ? preferred : lanes.find((candidate) => !candidate.locked
|
|
370
|
+
&& candidate.enabled === settings.enabled && candidate.muted === settings.muted && candidate.solo === settings.solo && fits(candidate));
|
|
371
|
+
if (!lane) {
|
|
372
|
+
lane = { trackId: uuidv7(), locked: false, clips: [], ...settings };
|
|
373
|
+
lanes.push(lane);
|
|
374
|
+
}
|
|
375
|
+
lane.clips.push(clip.placement);
|
|
376
|
+
clip.placement.trackId = lane.trackId;
|
|
377
|
+
}
|
|
378
|
+
return lanes.slice(tracks.length);
|
|
379
|
+
}
|
|
380
|
+
function timelineOperations(sequence, planned, managedTracks) {
|
|
381
|
+
const retained = new Set(planned.filter((clip) => clip.existing).map((clip) => clip.clipId));
|
|
382
|
+
const operations = [];
|
|
383
|
+
for (const transition of sequence.transitions) {
|
|
384
|
+
const outgoing = planned.find((clip) => clip.clipId === transition.outgoingClipId && clip.existing)?.placement;
|
|
385
|
+
const incoming = planned.find((clip) => clip.clipId === transition.incomingClipId && clip.existing)?.placement;
|
|
386
|
+
if (!outgoing || !incoming)
|
|
387
|
+
continue;
|
|
388
|
+
if (outgoing.trackId !== incoming.trackId || endFrame(outgoing) !== incoming.timelineStartFrame
|
|
389
|
+
|| transition.durationFrames > Math.min(outgoing.durationFrames, incoming.durationFrames)) {
|
|
390
|
+
operations.push({ kind: "set-transition", transition: null,
|
|
391
|
+
outgoingClipId: transition.outgoingClipId, incomingClipId: transition.incomingClipId });
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
for (const clip of sequence.clips
|
|
395
|
+
.filter((clip) => managedTracks.has(clip.trackId) && !retained.has(clip.clipId))) {
|
|
396
|
+
operations.push({ kind: "remove-range", trackIds: [clip.trackId], ripple: false,
|
|
397
|
+
range: { sequenceId: sequence.sequenceId, startFrame: clip.timelineStartFrame, durationFrames: clip.durationFrames } });
|
|
398
|
+
}
|
|
399
|
+
const moving = planned.filter(({ existing, placement }) => existing && (existing.timelineStartFrame !== placement.timelineStartFrame || existing.trackId !== placement.trackId
|
|
400
|
+
|| existing.durationFrames !== placement.durationFrames));
|
|
401
|
+
let stagingFrame = Math.max(0, ...sequence.clips.map(endFrame), ...planned.map((clip) => endFrame(clip.placement)));
|
|
402
|
+
const staged = new Map();
|
|
403
|
+
for (const clip of moving) {
|
|
404
|
+
staged.set(clip.clipId, stagingFrame);
|
|
405
|
+
operations.push({ kind: "move-clip", clipId: clip.clipId, trackId: clip.existing.trackId, timelineStartFrame: stagingFrame });
|
|
406
|
+
stagingFrame += Math.max(clip.existing.durationFrames, clip.placement.durationFrames);
|
|
407
|
+
if (!Number.isSafeInteger(stagingFrame))
|
|
408
|
+
throw new Error("Timeline move exceeds safe integer precision");
|
|
409
|
+
}
|
|
410
|
+
for (const { clipId, existing, placement } of planned) {
|
|
411
|
+
if (!existing)
|
|
412
|
+
continue;
|
|
413
|
+
if (existing.durationFrames !== placement.durationFrames) {
|
|
414
|
+
operations.push({ kind: "trim-clip", clipId, timelineStartFrame: staged.get(clipId), durationFrames: placement.durationFrames,
|
|
415
|
+
...(existing.source.kind === "timed" ? { sourceRange: existing.source.range } : {}) });
|
|
416
|
+
}
|
|
417
|
+
if (staged.has(clipId))
|
|
418
|
+
operations.push({ kind: "move-clip", clipId, trackId: placement.trackId, timelineStartFrame: placement.timelineStartFrame });
|
|
419
|
+
if (placement.audio && JSON.stringify(placement.audio) !== JSON.stringify(existing.audio)) {
|
|
420
|
+
operations.push({ kind: "set-clip-audio", clipId, audio: placement.audio });
|
|
421
|
+
}
|
|
422
|
+
if ("speed" in existing && placement.speed && JSON.stringify(existing.speed) !== JSON.stringify(placement.speed)) {
|
|
423
|
+
operations.push({ kind: "set-clip-speed", clipId, speed: placement.speed, reverse: existing.reverse, audioPolicy: existing.audioPolicy });
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
for (const { clipId, existing, placement } of planned) {
|
|
427
|
+
if (!existing)
|
|
428
|
+
operations.push({ kind: "insert-clip", clipId, placement, mode: "overwrite" });
|
|
429
|
+
}
|
|
430
|
+
return operations;
|
|
431
|
+
}
|
|
432
|
+
function previewTimeline(engine, operations) {
|
|
433
|
+
if (operations.length === 0)
|
|
434
|
+
return undefined;
|
|
435
|
+
const sequence = engine.sequences.getPrimary();
|
|
436
|
+
const intent = {
|
|
437
|
+
intentVersion: MVP_CONTRACT_VERSION, commandId: uuidv7(), sequenceId: sequence.sequenceId,
|
|
438
|
+
baseRevision: sequence.revision, actor: "videobook.timeline-compat", sourceSurface: "slash",
|
|
439
|
+
confirmationPolicy: "always", operations,
|
|
440
|
+
};
|
|
441
|
+
const preview = engine.edits.preview(intent);
|
|
442
|
+
if (!preview.ok)
|
|
443
|
+
throw new Error(preview.error.message);
|
|
444
|
+
if (!preview.value.valid)
|
|
445
|
+
throw new Error(preview.value.conflicts.map((conflict) => conflict.message).join("; ")
|
|
446
|
+
|| "Timeline edit conflicts with the current sequence");
|
|
447
|
+
return { intent, previewHash: preview.value.previewHash };
|
|
448
|
+
}
|
|
449
|
+
export async function writeTimeline(engine, input, options = {}) {
|
|
450
|
+
try {
|
|
451
|
+
let sequence = engine.sequences.getPrimary();
|
|
452
|
+
const videoTrack = sequence.tracks.filter((track) => track.kind === "video").sort((left, right) => left.ordinal - right.ordinal)[0];
|
|
453
|
+
if (!videoTrack)
|
|
454
|
+
throw new Error("Primary sequence has no video track");
|
|
455
|
+
const managedTracks = new Set(sequence.tracks.filter((track) => track.kind === "audio" || track.trackId === videoTrack.trackId).map((track) => track.trackId));
|
|
456
|
+
validateTimelineInput(engine, sequence, input, managedTracks);
|
|
457
|
+
const slots = await planSlots(engine, sequence, input.slots ?? [], videoTrack.trackId);
|
|
458
|
+
const audio = await planAudio(engine, sequence, input.audio ?? []);
|
|
459
|
+
const extraTracks = new Set(sequence.clips.filter((clip) => options.removeArtifactId
|
|
460
|
+
&& clip.source.artifactId === options.removeArtifactId && !managedTracks.has(clip.trackId)).map((clip) => clip.trackId));
|
|
461
|
+
const extraClips = sequence.clips.filter((clip) => extraTracks.has(clip.trackId) && clip.source.artifactId !== options.removeArtifactId)
|
|
462
|
+
.map((clip) => ({ clipId: clip.clipId, existing: clip, placement: placementFromClip(clip) }));
|
|
463
|
+
for (const trackId of extraTracks)
|
|
464
|
+
managedTracks.add(trackId);
|
|
465
|
+
const pendingLanes = allocateAudioLanes(sequence, audio);
|
|
466
|
+
const pendingLaneIds = new Set(pendingLanes.map((lane) => lane.trackId));
|
|
467
|
+
let planned = [...slots, ...audio, ...extraClips];
|
|
468
|
+
if (pendingLanes.length > 0) {
|
|
469
|
+
const validationTrack = sequence.tracks.find((track) => track.kind === "audio" && !track.locked);
|
|
470
|
+
if (!validationTrack)
|
|
471
|
+
throw new Error("Primary sequence has no unlocked audio track");
|
|
472
|
+
let validationStart = Math.max(0, ...sequence.clips.map(endFrame), ...planned.map((clip) => endFrame(clip.placement)));
|
|
473
|
+
const validationPlan = planned.map((clip) => {
|
|
474
|
+
if (!pendingLaneIds.has(clip.placement.trackId))
|
|
475
|
+
return clip;
|
|
476
|
+
const placement = { ...clip.placement, trackId: validationTrack.trackId, timelineStartFrame: validationStart };
|
|
477
|
+
validationStart = endFrame(placement);
|
|
478
|
+
return { ...clip, placement };
|
|
479
|
+
});
|
|
480
|
+
previewTimeline(engine, timelineOperations(sequence, validationPlan, managedTracks));
|
|
481
|
+
if (options.dryRun)
|
|
482
|
+
return timelineSuccessResult(readTimeline(engine));
|
|
483
|
+
const laneIds = new Map();
|
|
484
|
+
for (const pending of pendingLanes) {
|
|
485
|
+
const added = await engine.sequences.addTrack(sequence.sequenceId, { kind: "audio" });
|
|
486
|
+
if (!added.ok)
|
|
487
|
+
throw new Error(added.error.message);
|
|
488
|
+
const track = added.value.tracks.find((candidate) => !sequence.tracks.some((existing) => existing.trackId === candidate.trackId));
|
|
489
|
+
laneIds.set(pending.trackId, track.trackId);
|
|
490
|
+
sequence = added.value;
|
|
491
|
+
if (!pending.enabled || pending.muted || pending.solo) {
|
|
492
|
+
const configured = await engine.sequences.updateTrack(track.trackId, {
|
|
493
|
+
enabled: pending.enabled, muted: pending.muted, solo: pending.solo,
|
|
494
|
+
});
|
|
495
|
+
if (!configured.ok)
|
|
496
|
+
throw new Error(configured.error.message);
|
|
497
|
+
sequence = configured.value;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
planned = planned.map((clip) => ({ ...clip, placement: { ...clip.placement, trackId: laneIds.get(clip.placement.trackId) ?? clip.placement.trackId } }));
|
|
501
|
+
}
|
|
502
|
+
const preview = previewTimeline(engine, timelineOperations(sequence, planned, managedTracks));
|
|
503
|
+
if (options.dryRun)
|
|
504
|
+
return timelineSuccessResult(readTimeline(engine));
|
|
505
|
+
if (preview) {
|
|
506
|
+
const committed = await engine.edits.commit(preview.intent, preview.previewHash);
|
|
507
|
+
if (!committed.ok)
|
|
508
|
+
return timelineError(committed.error.message);
|
|
509
|
+
}
|
|
510
|
+
if (orientation(sequence) !== input.render) {
|
|
511
|
+
const canvas = await engine.sequences.updateCanvas(sequence.sequenceId, CANVAS[input.render]);
|
|
512
|
+
if (!canvas.ok)
|
|
513
|
+
return timelineError(canvas.error.message);
|
|
514
|
+
}
|
|
515
|
+
return timelineSuccessResult(readTimeline(engine));
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
return timelineError(error);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
export function timelineSuccess(timeline) {
|
|
522
|
+
return {
|
|
523
|
+
content: [{ type: "text", text: JSON.stringify(timelinePayload(timeline)) }],
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
export function timelineFailure(message) {
|
|
527
|
+
return {
|
|
528
|
+
isError: true,
|
|
529
|
+
content: [{ type: "text", text: message }],
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
export function slotIndex(value) {
|
|
533
|
+
const match = /^@?s(\d+)$/i.exec(value.trim());
|
|
534
|
+
if (!match)
|
|
535
|
+
return null;
|
|
536
|
+
const index = Number.parseInt(match[1], 10) - 1;
|
|
537
|
+
return index >= 0 ? index : null;
|
|
538
|
+
}
|
|
539
|
+
export function resolveArtifact(engine, reference) {
|
|
540
|
+
const result = engine.artifacts.get(reference);
|
|
541
|
+
return result.ok ? result.value : null;
|
|
542
|
+
}
|
|
543
|
+
const SLOT_REF_PATTERN = /@s(\d{1,3})\b/giu;
|
|
544
|
+
export function timelineSlotArtifactIds(engine) {
|
|
545
|
+
return readTimeline(engine).slots.map((slot) => slot.artifactId);
|
|
546
|
+
}
|
|
547
|
+
/** Replace `@s01`-style timeline slot refs with `@<artifact-id>` tokens. */
|
|
548
|
+
export function expandTimelineSlotRefs(text, slotArtifactIds) {
|
|
549
|
+
return text.replace(SLOT_REF_PATTERN, (token, digits) => {
|
|
550
|
+
const index = Number.parseInt(digits, 10) - 1;
|
|
551
|
+
const artifactId = index >= 0 ? slotArtifactIds[index] : undefined;
|
|
552
|
+
return artifactId ? `@${artifactId}` : token;
|
|
553
|
+
});
|
|
554
|
+
}
|
package/dist/timewarp.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const TIMEWARP_STRETCH_MIN = 0.25;
|
|
2
|
+
const TIMEWARP_STRETCH_MAX = 4;
|
|
3
|
+
function requireFinite(name, value) {
|
|
4
|
+
if (!Number.isFinite(value)) {
|
|
5
|
+
throw new Error(`${name} must be a finite number`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function segment(kind, startSeconds, endSeconds, stretchFactor) {
|
|
9
|
+
return {
|
|
10
|
+
kind,
|
|
11
|
+
startSeconds,
|
|
12
|
+
endSeconds,
|
|
13
|
+
stretchFactor,
|
|
14
|
+
outputDuration: (endSeconds - startSeconds) * stretchFactor,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createTimewarpPlan(input) {
|
|
18
|
+
const { sourceDuration, sourceFps, startSeconds, endSeconds, stretchFactor, } = input;
|
|
19
|
+
requireFinite("sourceDuration", sourceDuration);
|
|
20
|
+
requireFinite("sourceFps", sourceFps);
|
|
21
|
+
requireFinite("startSeconds", startSeconds);
|
|
22
|
+
requireFinite("endSeconds", endSeconds);
|
|
23
|
+
requireFinite("stretchFactor", stretchFactor);
|
|
24
|
+
if (sourceDuration <= 0)
|
|
25
|
+
throw new Error("Source duration must be greater than zero");
|
|
26
|
+
if (sourceFps <= 0)
|
|
27
|
+
throw new Error("Source frame rate must be greater than zero");
|
|
28
|
+
if (startSeconds < 0 || startSeconds >= endSeconds || endSeconds > sourceDuration) {
|
|
29
|
+
throw new Error(`Timewarp range must satisfy 0 <= start < end <= ${sourceDuration.toFixed(3)}`);
|
|
30
|
+
}
|
|
31
|
+
if (stretchFactor < TIMEWARP_STRETCH_MIN || stretchFactor > TIMEWARP_STRETCH_MAX) {
|
|
32
|
+
throw new Error(`Stretch factor must be between ${TIMEWARP_STRETCH_MIN} and ${TIMEWARP_STRETCH_MAX}`);
|
|
33
|
+
}
|
|
34
|
+
if (stretchFactor === 1)
|
|
35
|
+
throw new Error("Stretch factor 1 is a no-op");
|
|
36
|
+
const selectedSourceDuration = endSeconds - startSeconds;
|
|
37
|
+
const outsideSourceDuration = sourceDuration - selectedSourceDuration;
|
|
38
|
+
if (outsideSourceDuration <= 0) {
|
|
39
|
+
throw new Error("Timewarp range cannot cover the full clip");
|
|
40
|
+
}
|
|
41
|
+
const selectedOutputDuration = selectedSourceDuration * stretchFactor;
|
|
42
|
+
const outsideOutputDuration = sourceDuration - selectedOutputDuration;
|
|
43
|
+
if (outsideOutputDuration <= 0) {
|
|
44
|
+
throw new Error("Stretch factor leaves no time for material outside the selection");
|
|
45
|
+
}
|
|
46
|
+
const outsideStretchFactor = outsideOutputDuration / outsideSourceDuration;
|
|
47
|
+
const segments = [];
|
|
48
|
+
if (startSeconds > 0) {
|
|
49
|
+
segments.push(segment("prefix", 0, startSeconds, outsideStretchFactor));
|
|
50
|
+
}
|
|
51
|
+
segments.push(segment("selection", startSeconds, endSeconds, stretchFactor));
|
|
52
|
+
if (endSeconds < sourceDuration) {
|
|
53
|
+
segments.push(segment("suffix", endSeconds, sourceDuration, outsideStretchFactor));
|
|
54
|
+
}
|
|
55
|
+
const frameDuration = 1 / sourceFps;
|
|
56
|
+
const tooShort = segments.find((item) => item.outputDuration + 1e-9 < frameDuration);
|
|
57
|
+
if (tooShort) {
|
|
58
|
+
throw new Error(`${tooShort.kind} output is shorter than one source frame (${frameDuration.toFixed(6)}s)`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
sourceDuration,
|
|
62
|
+
sourceFps,
|
|
63
|
+
startSeconds,
|
|
64
|
+
endSeconds,
|
|
65
|
+
stretchFactor,
|
|
66
|
+
selectedSourceDuration,
|
|
67
|
+
selectedOutputDuration,
|
|
68
|
+
outsideSourceDuration,
|
|
69
|
+
outsideOutputDuration,
|
|
70
|
+
outsideStretchFactor,
|
|
71
|
+
segments,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function filterNumber(value) {
|
|
75
|
+
return Number(value.toFixed(12)).toString();
|
|
76
|
+
}
|
|
77
|
+
export function buildTimewarpVideoFilter(plan) {
|
|
78
|
+
const filters = plan.segments.map((item, index) => {
|
|
79
|
+
const start = filterNumber(item.startSeconds);
|
|
80
|
+
const end = filterNumber(item.endSeconds);
|
|
81
|
+
const factor = filterNumber(item.stretchFactor);
|
|
82
|
+
return `[0:v:0]trim=start=${start}:end=${end},setpts=(PTS-STARTPTS)*${factor}[v${index}]`;
|
|
83
|
+
});
|
|
84
|
+
const inputs = plan.segments.map((_, index) => `[v${index}]`).join("");
|
|
85
|
+
filters.push(`${inputs}concat=n=${plan.segments.length}:v=1:a=0[vout]`);
|
|
86
|
+
return filters.join(";");
|
|
87
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { extname } from "node:path";
|
|
2
|
+
const IMAGE_EXTENSIONS = new Set(["jpg", "jpeg", "png", "webp", "gif"]);
|
|
3
|
+
export function findImageFile(files) {
|
|
4
|
+
const images = files.filter((f) => {
|
|
5
|
+
const ext = (f.extension ?? extname(f.name)).replace(/^\./, "").toLowerCase();
|
|
6
|
+
return IMAGE_EXTENSIONS.has(ext);
|
|
7
|
+
});
|
|
8
|
+
return images.find((f) => f.name.startsWith("original")) ?? images[0] ?? null;
|
|
9
|
+
}
|