@vibeframe/cli 0.27.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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-lint.log +21 -0
- package/.turbo/turbo-test.log +689 -0
- package/dist/agent/adapters/claude.d.ts +15 -0
- package/dist/agent/adapters/claude.d.ts.map +1 -0
- package/dist/agent/adapters/claude.js +119 -0
- package/dist/agent/adapters/claude.js.map +1 -0
- package/dist/agent/adapters/gemini.d.ts +15 -0
- package/dist/agent/adapters/gemini.d.ts.map +1 -0
- package/dist/agent/adapters/gemini.js +132 -0
- package/dist/agent/adapters/gemini.js.map +1 -0
- package/dist/agent/adapters/index.d.ts +27 -0
- package/dist/agent/adapters/index.d.ts.map +1 -0
- package/dist/agent/adapters/index.js +38 -0
- package/dist/agent/adapters/index.js.map +1 -0
- package/dist/agent/adapters/ollama.d.ts +20 -0
- package/dist/agent/adapters/ollama.d.ts.map +1 -0
- package/dist/agent/adapters/ollama.js +186 -0
- package/dist/agent/adapters/ollama.js.map +1 -0
- package/dist/agent/adapters/openai.d.ts +15 -0
- package/dist/agent/adapters/openai.d.ts.map +1 -0
- package/dist/agent/adapters/openai.js +92 -0
- package/dist/agent/adapters/openai.js.map +1 -0
- package/dist/agent/adapters/xai.d.ts +15 -0
- package/dist/agent/adapters/xai.d.ts.map +1 -0
- package/dist/agent/adapters/xai.js +95 -0
- package/dist/agent/adapters/xai.js.map +1 -0
- package/dist/agent/index.d.ts +69 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +180 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/memory/index.d.ts +70 -0
- package/dist/agent/memory/index.d.ts.map +1 -0
- package/dist/agent/memory/index.js +132 -0
- package/dist/agent/memory/index.js.map +1 -0
- package/dist/agent/prompts/system.d.ts +6 -0
- package/dist/agent/prompts/system.d.ts.map +1 -0
- package/dist/agent/prompts/system.js +103 -0
- package/dist/agent/prompts/system.js.map +1 -0
- package/dist/agent/tools/ai-editing.d.ts +15 -0
- package/dist/agent/tools/ai-editing.d.ts.map +1 -0
- package/dist/agent/tools/ai-editing.js +763 -0
- package/dist/agent/tools/ai-editing.js.map +1 -0
- package/dist/agent/tools/ai-generation.d.ts +13 -0
- package/dist/agent/tools/ai-generation.d.ts.map +1 -0
- package/dist/agent/tools/ai-generation.js +973 -0
- package/dist/agent/tools/ai-generation.js.map +1 -0
- package/dist/agent/tools/ai-pipeline.d.ts +14 -0
- package/dist/agent/tools/ai-pipeline.d.ts.map +1 -0
- package/dist/agent/tools/ai-pipeline.js +961 -0
- package/dist/agent/tools/ai-pipeline.js.map +1 -0
- package/dist/agent/tools/ai.d.ts +13 -0
- package/dist/agent/tools/ai.d.ts.map +1 -0
- package/dist/agent/tools/ai.js +19 -0
- package/dist/agent/tools/ai.js.map +1 -0
- package/dist/agent/tools/batch.d.ts +6 -0
- package/dist/agent/tools/batch.d.ts.map +1 -0
- package/dist/agent/tools/batch.js +383 -0
- package/dist/agent/tools/batch.js.map +1 -0
- package/dist/agent/tools/e2e.test.d.ts +26 -0
- package/dist/agent/tools/e2e.test.d.ts.map +1 -0
- package/dist/agent/tools/e2e.test.js +397 -0
- package/dist/agent/tools/e2e.test.js.map +1 -0
- package/dist/agent/tools/export.d.ts +6 -0
- package/dist/agent/tools/export.d.ts.map +1 -0
- package/dist/agent/tools/export.js +171 -0
- package/dist/agent/tools/export.js.map +1 -0
- package/dist/agent/tools/filesystem.d.ts +6 -0
- package/dist/agent/tools/filesystem.d.ts.map +1 -0
- package/dist/agent/tools/filesystem.js +212 -0
- package/dist/agent/tools/filesystem.js.map +1 -0
- package/dist/agent/tools/index.d.ts +65 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +120 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/integration.test.d.ts +11 -0
- package/dist/agent/tools/integration.test.d.ts.map +1 -0
- package/dist/agent/tools/integration.test.js +659 -0
- package/dist/agent/tools/integration.test.js.map +1 -0
- package/dist/agent/tools/media.d.ts +6 -0
- package/dist/agent/tools/media.d.ts.map +1 -0
- package/dist/agent/tools/media.js +616 -0
- package/dist/agent/tools/media.js.map +1 -0
- package/dist/agent/tools/project.d.ts +6 -0
- package/dist/agent/tools/project.d.ts.map +1 -0
- package/dist/agent/tools/project.js +284 -0
- package/dist/agent/tools/project.js.map +1 -0
- package/dist/agent/tools/timeline.d.ts +6 -0
- package/dist/agent/tools/timeline.d.ts.map +1 -0
- package/dist/agent/tools/timeline.js +873 -0
- package/dist/agent/tools/timeline.js.map +1 -0
- package/dist/agent/types.d.ts +59 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +5 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/commands/agent.d.ts +21 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +290 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/ai-analyze.d.ts +106 -0
- package/dist/commands/ai-analyze.d.ts.map +1 -0
- package/dist/commands/ai-analyze.js +327 -0
- package/dist/commands/ai-analyze.js.map +1 -0
- package/dist/commands/ai-animated-caption.d.ts +64 -0
- package/dist/commands/ai-animated-caption.d.ts.map +1 -0
- package/dist/commands/ai-animated-caption.js +272 -0
- package/dist/commands/ai-animated-caption.js.map +1 -0
- package/dist/commands/ai-audio.d.ts +20 -0
- package/dist/commands/ai-audio.d.ts.map +1 -0
- package/dist/commands/ai-audio.js +808 -0
- package/dist/commands/ai-audio.js.map +1 -0
- package/dist/commands/ai-broll.d.ts +15 -0
- package/dist/commands/ai-broll.d.ts.map +1 -0
- package/dist/commands/ai-broll.js +406 -0
- package/dist/commands/ai-broll.js.map +1 -0
- package/dist/commands/ai-edit-cli.d.ts +14 -0
- package/dist/commands/ai-edit-cli.d.ts.map +1 -0
- package/dist/commands/ai-edit-cli.js +579 -0
- package/dist/commands/ai-edit-cli.js.map +1 -0
- package/dist/commands/ai-edit.d.ts +398 -0
- package/dist/commands/ai-edit.d.ts.map +1 -0
- package/dist/commands/ai-edit.js +1019 -0
- package/dist/commands/ai-edit.js.map +1 -0
- package/dist/commands/ai-fill-gaps.d.ts +14 -0
- package/dist/commands/ai-fill-gaps.d.ts.map +1 -0
- package/dist/commands/ai-fill-gaps.js +451 -0
- package/dist/commands/ai-fill-gaps.js.map +1 -0
- package/dist/commands/ai-helpers.d.ts +20 -0
- package/dist/commands/ai-helpers.d.ts.map +1 -0
- package/dist/commands/ai-helpers.js +59 -0
- package/dist/commands/ai-helpers.js.map +1 -0
- package/dist/commands/ai-highlights.d.ts +127 -0
- package/dist/commands/ai-highlights.d.ts.map +1 -0
- package/dist/commands/ai-highlights.js +1026 -0
- package/dist/commands/ai-highlights.js.map +1 -0
- package/dist/commands/ai-image.d.ts +34 -0
- package/dist/commands/ai-image.d.ts.map +1 -0
- package/dist/commands/ai-image.js +653 -0
- package/dist/commands/ai-image.js.map +1 -0
- package/dist/commands/ai-motion.d.ts +50 -0
- package/dist/commands/ai-motion.d.ts.map +1 -0
- package/dist/commands/ai-motion.js +271 -0
- package/dist/commands/ai-motion.js.map +1 -0
- package/dist/commands/ai-narrate.d.ts +66 -0
- package/dist/commands/ai-narrate.d.ts.map +1 -0
- package/dist/commands/ai-narrate.js +329 -0
- package/dist/commands/ai-narrate.js.map +1 -0
- package/dist/commands/ai-review.d.ts +57 -0
- package/dist/commands/ai-review.d.ts.map +1 -0
- package/dist/commands/ai-review.js +251 -0
- package/dist/commands/ai-review.js.map +1 -0
- package/dist/commands/ai-script-pipeline-cli.d.ts +9 -0
- package/dist/commands/ai-script-pipeline-cli.d.ts.map +1 -0
- package/dist/commands/ai-script-pipeline-cli.js +1494 -0
- package/dist/commands/ai-script-pipeline-cli.js.map +1 -0
- package/dist/commands/ai-script-pipeline.d.ts +259 -0
- package/dist/commands/ai-script-pipeline.d.ts.map +1 -0
- package/dist/commands/ai-script-pipeline.js +1027 -0
- package/dist/commands/ai-script-pipeline.js.map +1 -0
- package/dist/commands/ai-suggest-edit.d.ts +14 -0
- package/dist/commands/ai-suggest-edit.d.ts.map +1 -0
- package/dist/commands/ai-suggest-edit.js +220 -0
- package/dist/commands/ai-suggest-edit.js.map +1 -0
- package/dist/commands/ai-video-fx.d.ts +14 -0
- package/dist/commands/ai-video-fx.d.ts.map +1 -0
- package/dist/commands/ai-video-fx.js +395 -0
- package/dist/commands/ai-video-fx.js.map +1 -0
- package/dist/commands/ai-video.d.ts +15 -0
- package/dist/commands/ai-video.d.ts.map +1 -0
- package/dist/commands/ai-video.js +785 -0
- package/dist/commands/ai-video.js.map +1 -0
- package/dist/commands/ai-viral.d.ts +15 -0
- package/dist/commands/ai-viral.d.ts.map +1 -0
- package/dist/commands/ai-viral.js +519 -0
- package/dist/commands/ai-viral.js.map +1 -0
- package/dist/commands/ai-visual-fx.d.ts +14 -0
- package/dist/commands/ai-visual-fx.d.ts.map +1 -0
- package/dist/commands/ai-visual-fx.js +505 -0
- package/dist/commands/ai-visual-fx.js.map +1 -0
- package/dist/commands/ai.d.ts +38 -0
- package/dist/commands/ai.d.ts.map +1 -0
- package/dist/commands/ai.js +225 -0
- package/dist/commands/ai.js.map +1 -0
- package/dist/commands/ai.test.d.ts +2 -0
- package/dist/commands/ai.test.d.ts.map +1 -0
- package/dist/commands/ai.test.js +554 -0
- package/dist/commands/ai.test.js.map +1 -0
- package/dist/commands/analyze.d.ts +16 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +247 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/audio.d.ts +18 -0
- package/dist/commands/audio.d.ts.map +1 -0
- package/dist/commands/audio.js +539 -0
- package/dist/commands/audio.js.map +1 -0
- package/dist/commands/batch.d.ts +3 -0
- package/dist/commands/batch.d.ts.map +1 -0
- package/dist/commands/batch.js +366 -0
- package/dist/commands/batch.js.map +1 -0
- package/dist/commands/batch.test.d.ts +2 -0
- package/dist/commands/batch.test.d.ts.map +1 -0
- package/dist/commands/batch.test.js +203 -0
- package/dist/commands/batch.test.js.map +1 -0
- package/dist/commands/detect.d.ts +3 -0
- package/dist/commands/detect.d.ts.map +1 -0
- package/dist/commands/detect.js +273 -0
- package/dist/commands/detect.js.map +1 -0
- package/dist/commands/doctor.d.ts +6 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +191 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/edit-cmd.d.ts +26 -0
- package/dist/commands/edit-cmd.d.ts.map +1 -0
- package/dist/commands/edit-cmd.js +870 -0
- package/dist/commands/edit-cmd.js.map +1 -0
- package/dist/commands/export.d.ts +39 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +730 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/generate.d.ts +25 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +1885 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/media.d.ts +3 -0
- package/dist/commands/media.d.ts.map +1 -0
- package/dist/commands/media.js +165 -0
- package/dist/commands/media.js.map +1 -0
- package/dist/commands/output.d.ts +45 -0
- package/dist/commands/output.d.ts.map +1 -0
- package/dist/commands/output.js +122 -0
- package/dist/commands/output.js.map +1 -0
- package/dist/commands/pipeline.d.ts +19 -0
- package/dist/commands/pipeline.d.ts.map +1 -0
- package/dist/commands/pipeline.js +345 -0
- package/dist/commands/pipeline.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +139 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/project.test.d.ts +2 -0
- package/dist/commands/project.test.d.ts.map +1 -0
- package/dist/commands/project.test.js +105 -0
- package/dist/commands/project.test.js.map +1 -0
- package/dist/commands/sanitize.d.ts +21 -0
- package/dist/commands/sanitize.d.ts.map +1 -0
- package/dist/commands/sanitize.js +56 -0
- package/dist/commands/sanitize.js.map +1 -0
- package/dist/commands/schema.d.ts +11 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +101 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +440 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/timeline.d.ts +3 -0
- package/dist/commands/timeline.d.ts.map +1 -0
- package/dist/commands/timeline.js +469 -0
- package/dist/commands/timeline.js.map +1 -0
- package/dist/commands/timeline.test.d.ts +2 -0
- package/dist/commands/timeline.test.d.ts.map +1 -0
- package/dist/commands/timeline.test.js +320 -0
- package/dist/commands/timeline.test.js.map +1 -0
- package/dist/commands/validate.d.ts +32 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +63 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/config/config.test.d.ts +2 -0
- package/dist/config/config.test.d.ts.map +1 -0
- package/dist/config/config.test.js +164 -0
- package/dist/config/config.test.js.map +1 -0
- package/dist/config/index.d.ts +35 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +101 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/schema.d.ts +43 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +42 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +2 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/project.d.ts +84 -0
- package/dist/engine/project.d.ts.map +1 -0
- package/dist/engine/project.js +355 -0
- package/dist/engine/project.js.map +1 -0
- package/dist/engine/project.test.d.ts +2 -0
- package/dist/engine/project.test.d.ts.map +1 -0
- package/dist/engine/project.test.js +599 -0
- package/dist/engine/project.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/api-key.d.ts +36 -0
- package/dist/utils/api-key.d.ts.map +1 -0
- package/dist/utils/api-key.js +211 -0
- package/dist/utils/api-key.js.map +1 -0
- package/dist/utils/api-key.test.d.ts +2 -0
- package/dist/utils/api-key.test.d.ts.map +1 -0
- package/dist/utils/api-key.test.js +35 -0
- package/dist/utils/api-key.test.js.map +1 -0
- package/dist/utils/audio.d.ts +23 -0
- package/dist/utils/audio.d.ts.map +1 -0
- package/dist/utils/audio.js +79 -0
- package/dist/utils/audio.js.map +1 -0
- package/dist/utils/exec-safe.d.ts +22 -0
- package/dist/utils/exec-safe.d.ts.map +1 -0
- package/dist/utils/exec-safe.js +62 -0
- package/dist/utils/exec-safe.js.map +1 -0
- package/dist/utils/first-run.d.ts +13 -0
- package/dist/utils/first-run.d.ts.map +1 -0
- package/dist/utils/first-run.js +48 -0
- package/dist/utils/first-run.js.map +1 -0
- package/dist/utils/provider-resolver.d.ts +15 -0
- package/dist/utils/provider-resolver.d.ts.map +1 -0
- package/dist/utils/provider-resolver.js +42 -0
- package/dist/utils/provider-resolver.js.map +1 -0
- package/dist/utils/remotion.d.ts +210 -0
- package/dist/utils/remotion.d.ts.map +1 -0
- package/dist/utils/remotion.js +731 -0
- package/dist/utils/remotion.js.map +1 -0
- package/dist/utils/subtitle.d.ts +65 -0
- package/dist/utils/subtitle.d.ts.map +1 -0
- package/dist/utils/subtitle.js +135 -0
- package/dist/utils/subtitle.js.map +1 -0
- package/dist/utils/subtitle.test.d.ts +2 -0
- package/dist/utils/subtitle.test.d.ts.map +1 -0
- package/dist/utils/subtitle.test.js +175 -0
- package/dist/utils/subtitle.test.js.map +1 -0
- package/dist/utils/tty.d.ts +45 -0
- package/dist/utils/tty.d.ts.map +1 -0
- package/dist/utils/tty.js +172 -0
- package/dist/utils/tty.js.map +1 -0
- package/package.json +102 -0
- package/src/agent/adapters/claude.ts +143 -0
- package/src/agent/adapters/gemini.ts +159 -0
- package/src/agent/adapters/index.ts +61 -0
- package/src/agent/adapters/ollama.ts +231 -0
- package/src/agent/adapters/openai.ts +116 -0
- package/src/agent/adapters/xai.ts +119 -0
- package/src/agent/index.ts +251 -0
- package/src/agent/memory/index.ts +151 -0
- package/src/agent/prompts/system.ts +106 -0
- package/src/agent/tools/ai-editing.ts +845 -0
- package/src/agent/tools/ai-generation.ts +1073 -0
- package/src/agent/tools/ai-pipeline.ts +1055 -0
- package/src/agent/tools/ai.ts +21 -0
- package/src/agent/tools/batch.ts +429 -0
- package/src/agent/tools/e2e.test.ts +545 -0
- package/src/agent/tools/export.ts +184 -0
- package/src/agent/tools/filesystem.ts +237 -0
- package/src/agent/tools/index.ts +150 -0
- package/src/agent/tools/integration.test.ts +775 -0
- package/src/agent/tools/media.ts +697 -0
- package/src/agent/tools/project.ts +313 -0
- package/src/agent/tools/timeline.ts +951 -0
- package/src/agent/types.ts +68 -0
- package/src/commands/agent.ts +340 -0
- package/src/commands/ai-analyze.ts +429 -0
- package/src/commands/ai-animated-caption.ts +390 -0
- package/src/commands/ai-audio.ts +941 -0
- package/src/commands/ai-broll.ts +490 -0
- package/src/commands/ai-edit-cli.ts +658 -0
- package/src/commands/ai-edit.ts +1542 -0
- package/src/commands/ai-fill-gaps.ts +566 -0
- package/src/commands/ai-helpers.ts +65 -0
- package/src/commands/ai-highlights.ts +1303 -0
- package/src/commands/ai-image.ts +761 -0
- package/src/commands/ai-motion.ts +347 -0
- package/src/commands/ai-narrate.ts +451 -0
- package/src/commands/ai-review.ts +309 -0
- package/src/commands/ai-script-pipeline-cli.ts +1710 -0
- package/src/commands/ai-script-pipeline.ts +1365 -0
- package/src/commands/ai-suggest-edit.ts +264 -0
- package/src/commands/ai-video-fx.ts +445 -0
- package/src/commands/ai-video.ts +915 -0
- package/src/commands/ai-viral.ts +595 -0
- package/src/commands/ai-visual-fx.ts +601 -0
- package/src/commands/ai.test.ts +627 -0
- package/src/commands/ai.ts +307 -0
- package/src/commands/analyze.ts +282 -0
- package/src/commands/audio.ts +644 -0
- package/src/commands/batch.test.ts +279 -0
- package/src/commands/batch.ts +440 -0
- package/src/commands/detect.ts +329 -0
- package/src/commands/doctor.ts +237 -0
- package/src/commands/edit-cmd.ts +1014 -0
- package/src/commands/export.ts +918 -0
- package/src/commands/generate.ts +2146 -0
- package/src/commands/media.ts +177 -0
- package/src/commands/output.ts +142 -0
- package/src/commands/pipeline.ts +398 -0
- package/src/commands/project.test.ts +127 -0
- package/src/commands/project.ts +149 -0
- package/src/commands/sanitize.ts +60 -0
- package/src/commands/schema.ts +130 -0
- package/src/commands/setup.ts +509 -0
- package/src/commands/timeline.test.ts +499 -0
- package/src/commands/timeline.ts +529 -0
- package/src/commands/validate.ts +77 -0
- package/src/config/config.test.ts +197 -0
- package/src/config/index.ts +125 -0
- package/src/config/schema.ts +82 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/project.test.ts +702 -0
- package/src/engine/project.ts +439 -0
- package/src/index.ts +146 -0
- package/src/utils/api-key.test.ts +41 -0
- package/src/utils/api-key.ts +247 -0
- package/src/utils/audio.ts +83 -0
- package/src/utils/exec-safe.ts +75 -0
- package/src/utils/first-run.ts +52 -0
- package/src/utils/provider-resolver.ts +56 -0
- package/src/utils/remotion.ts +951 -0
- package/src/utils/subtitle.test.ts +227 -0
- package/src/utils/subtitle.ts +169 -0
- package/src/utils/tty.ts +196 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
+
import { Project, generateId } from "./project";
|
|
3
|
+
|
|
4
|
+
describe("generateId", () => {
|
|
5
|
+
it("generates unique IDs", () => {
|
|
6
|
+
const id1 = generateId();
|
|
7
|
+
const id2 = generateId();
|
|
8
|
+
expect(id1).not.toBe(id2);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("generates IDs in expected format", () => {
|
|
12
|
+
const id = generateId();
|
|
13
|
+
expect(id).toMatch(/^\d+-[a-z0-9]+$/);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe("Project", () => {
|
|
18
|
+
let project: Project;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
project = new Project("Test Project");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("initialization", () => {
|
|
25
|
+
it("creates project with given name", () => {
|
|
26
|
+
expect(project.getMeta().name).toBe("Test Project");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("creates project with default aspect ratio 16:9", () => {
|
|
30
|
+
expect(project.getMeta().aspectRatio).toBe("16:9");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("creates project with default frame rate 30", () => {
|
|
34
|
+
expect(project.getMeta().frameRate).toBe(30);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("creates project with two default tracks", () => {
|
|
38
|
+
const tracks = project.getTracks();
|
|
39
|
+
expect(tracks).toHaveLength(2);
|
|
40
|
+
expect(tracks[0].type).toBe("video");
|
|
41
|
+
expect(tracks[1].type).toBe("audio");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("creates project with empty clips and sources", () => {
|
|
45
|
+
expect(project.getClips()).toHaveLength(0);
|
|
46
|
+
expect(project.getSources()).toHaveLength(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("creates project with zero duration", () => {
|
|
50
|
+
expect(project.getDuration()).toBe(0);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("project settings", () => {
|
|
55
|
+
it("sets project name", () => {
|
|
56
|
+
project.setName("New Name");
|
|
57
|
+
expect(project.getMeta().name).toBe("New Name");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("sets aspect ratio", () => {
|
|
61
|
+
project.setAspectRatio("9:16");
|
|
62
|
+
expect(project.getMeta().aspectRatio).toBe("9:16");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("sets frame rate", () => {
|
|
66
|
+
project.setFrameRate(60);
|
|
67
|
+
expect(project.getMeta().frameRate).toBe(60);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("media sources", () => {
|
|
72
|
+
it("adds a source", () => {
|
|
73
|
+
const source = project.addSource({
|
|
74
|
+
name: "test.mp4",
|
|
75
|
+
type: "video",
|
|
76
|
+
url: "/path/to/test.mp4",
|
|
77
|
+
duration: 10,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(source.id).toBeDefined();
|
|
81
|
+
expect(source.name).toBe("test.mp4");
|
|
82
|
+
expect(project.getSources()).toHaveLength(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("gets source by id", () => {
|
|
86
|
+
const source = project.addSource({
|
|
87
|
+
name: "test.mp4",
|
|
88
|
+
type: "video",
|
|
89
|
+
url: "/path/to/test.mp4",
|
|
90
|
+
duration: 10,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const found = project.getSource(source.id);
|
|
94
|
+
expect(found).toBeDefined();
|
|
95
|
+
expect(found?.name).toBe("test.mp4");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("removes a source", () => {
|
|
99
|
+
const source = project.addSource({
|
|
100
|
+
name: "test.mp4",
|
|
101
|
+
type: "video",
|
|
102
|
+
url: "/path/to/test.mp4",
|
|
103
|
+
duration: 10,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const removed = project.removeSource(source.id);
|
|
107
|
+
expect(removed).toBe(true);
|
|
108
|
+
expect(project.getSources()).toHaveLength(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("removes clips when source is removed", () => {
|
|
112
|
+
const source = project.addSource({
|
|
113
|
+
name: "test.mp4",
|
|
114
|
+
type: "video",
|
|
115
|
+
url: "/path/to/test.mp4",
|
|
116
|
+
duration: 10,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
project.addClip({
|
|
120
|
+
sourceId: source.id,
|
|
121
|
+
trackId: "video-track-1",
|
|
122
|
+
startTime: 0,
|
|
123
|
+
duration: 5,
|
|
124
|
+
sourceStartOffset: 0,
|
|
125
|
+
sourceEndOffset: 5,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(project.getClips()).toHaveLength(1);
|
|
129
|
+
project.removeSource(source.id);
|
|
130
|
+
expect(project.getClips()).toHaveLength(0);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("returns false when removing non-existent source", () => {
|
|
134
|
+
const removed = project.removeSource("non-existent");
|
|
135
|
+
expect(removed).toBe(false);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("tracks", () => {
|
|
140
|
+
it("adds a track", () => {
|
|
141
|
+
const track = project.addTrack({
|
|
142
|
+
name: "Video 2",
|
|
143
|
+
type: "video",
|
|
144
|
+
order: 2,
|
|
145
|
+
isMuted: false,
|
|
146
|
+
isLocked: false,
|
|
147
|
+
isVisible: true,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(track.id).toBeDefined();
|
|
151
|
+
expect(track.name).toBe("Video 2");
|
|
152
|
+
expect(project.getTracks()).toHaveLength(3);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("gets track by id", () => {
|
|
156
|
+
const track = project.getTrack("video-track-1");
|
|
157
|
+
expect(track).toBeDefined();
|
|
158
|
+
expect(track?.name).toBe("Video 1");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("gets tracks by type", () => {
|
|
162
|
+
const videoTracks = project.getTracksByType("video");
|
|
163
|
+
const audioTracks = project.getTracksByType("audio");
|
|
164
|
+
|
|
165
|
+
expect(videoTracks).toHaveLength(1);
|
|
166
|
+
expect(audioTracks).toHaveLength(1);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("updates a track", () => {
|
|
170
|
+
const updated = project.updateTrack("video-track-1", { name: "Main Video" });
|
|
171
|
+
expect(updated).toBe(true);
|
|
172
|
+
expect(project.getTrack("video-track-1")?.name).toBe("Main Video");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("removes a track", () => {
|
|
176
|
+
const removed = project.removeTrack("video-track-1");
|
|
177
|
+
expect(removed).toBe(true);
|
|
178
|
+
expect(project.getTracks()).toHaveLength(1);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("removes clips when track is removed", () => {
|
|
182
|
+
const source = project.addSource({
|
|
183
|
+
name: "test.mp4",
|
|
184
|
+
type: "video",
|
|
185
|
+
url: "/path/to/test.mp4",
|
|
186
|
+
duration: 10,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
project.addClip({
|
|
190
|
+
sourceId: source.id,
|
|
191
|
+
trackId: "video-track-1",
|
|
192
|
+
startTime: 0,
|
|
193
|
+
duration: 5,
|
|
194
|
+
sourceStartOffset: 0,
|
|
195
|
+
sourceEndOffset: 5,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
expect(project.getClips()).toHaveLength(1);
|
|
199
|
+
project.removeTrack("video-track-1");
|
|
200
|
+
expect(project.getClips()).toHaveLength(0);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
describe("clips", () => {
|
|
205
|
+
let sourceId: string;
|
|
206
|
+
|
|
207
|
+
beforeEach(() => {
|
|
208
|
+
const source = project.addSource({
|
|
209
|
+
name: "test.mp4",
|
|
210
|
+
type: "video",
|
|
211
|
+
url: "/path/to/test.mp4",
|
|
212
|
+
duration: 10,
|
|
213
|
+
});
|
|
214
|
+
sourceId = source.id;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("adds a clip", () => {
|
|
218
|
+
const clip = project.addClip({
|
|
219
|
+
sourceId,
|
|
220
|
+
trackId: "video-track-1",
|
|
221
|
+
startTime: 0,
|
|
222
|
+
duration: 5,
|
|
223
|
+
sourceStartOffset: 0,
|
|
224
|
+
sourceEndOffset: 5,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
expect(clip.id).toBeDefined();
|
|
228
|
+
expect(clip.effects).toEqual([]);
|
|
229
|
+
expect(project.getClips()).toHaveLength(1);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("gets clip by id", () => {
|
|
233
|
+
const clip = project.addClip({
|
|
234
|
+
sourceId,
|
|
235
|
+
trackId: "video-track-1",
|
|
236
|
+
startTime: 0,
|
|
237
|
+
duration: 5,
|
|
238
|
+
sourceStartOffset: 0,
|
|
239
|
+
sourceEndOffset: 5,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const found = project.getClip(clip.id);
|
|
243
|
+
expect(found).toBeDefined();
|
|
244
|
+
expect(found?.sourceId).toBe(sourceId);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("gets clips by track", () => {
|
|
248
|
+
project.addClip({
|
|
249
|
+
sourceId,
|
|
250
|
+
trackId: "video-track-1",
|
|
251
|
+
startTime: 0,
|
|
252
|
+
duration: 5,
|
|
253
|
+
sourceStartOffset: 0,
|
|
254
|
+
sourceEndOffset: 5,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const videoClips = project.getClipsByTrack("video-track-1");
|
|
258
|
+
const audioClips = project.getClipsByTrack("audio-track-1");
|
|
259
|
+
|
|
260
|
+
expect(videoClips).toHaveLength(1);
|
|
261
|
+
expect(audioClips).toHaveLength(0);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("updates a clip", () => {
|
|
265
|
+
const clip = project.addClip({
|
|
266
|
+
sourceId,
|
|
267
|
+
trackId: "video-track-1",
|
|
268
|
+
startTime: 0,
|
|
269
|
+
duration: 5,
|
|
270
|
+
sourceStartOffset: 0,
|
|
271
|
+
sourceEndOffset: 5,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const updated = project.updateClip(clip.id, { duration: 3 });
|
|
275
|
+
expect(updated).toBe(true);
|
|
276
|
+
expect(project.getClip(clip.id)?.duration).toBe(3);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("moves a clip", () => {
|
|
280
|
+
const clip = project.addClip({
|
|
281
|
+
sourceId,
|
|
282
|
+
trackId: "video-track-1",
|
|
283
|
+
startTime: 0,
|
|
284
|
+
duration: 5,
|
|
285
|
+
sourceStartOffset: 0,
|
|
286
|
+
sourceEndOffset: 5,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
project.moveClip(clip.id, "video-track-1", 10);
|
|
290
|
+
expect(project.getClip(clip.id)?.startTime).toBe(10);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it("prevents negative start time when moving", () => {
|
|
294
|
+
const clip = project.addClip({
|
|
295
|
+
sourceId,
|
|
296
|
+
trackId: "video-track-1",
|
|
297
|
+
startTime: 5,
|
|
298
|
+
duration: 5,
|
|
299
|
+
sourceStartOffset: 0,
|
|
300
|
+
sourceEndOffset: 5,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
project.moveClip(clip.id, "video-track-1", -10);
|
|
304
|
+
expect(project.getClip(clip.id)?.startTime).toBe(0);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("trims clip start", () => {
|
|
308
|
+
const clip = project.addClip({
|
|
309
|
+
sourceId,
|
|
310
|
+
trackId: "video-track-1",
|
|
311
|
+
startTime: 0,
|
|
312
|
+
duration: 10,
|
|
313
|
+
sourceStartOffset: 0,
|
|
314
|
+
sourceEndOffset: 10,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
project.trimClipStart(clip.id, 2);
|
|
318
|
+
const updated = project.getClip(clip.id);
|
|
319
|
+
expect(updated?.startTime).toBe(2);
|
|
320
|
+
expect(updated?.sourceStartOffset).toBe(2);
|
|
321
|
+
expect(updated?.duration).toBe(8);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it("trims clip end", () => {
|
|
325
|
+
const clip = project.addClip({
|
|
326
|
+
sourceId,
|
|
327
|
+
trackId: "video-track-1",
|
|
328
|
+
startTime: 0,
|
|
329
|
+
duration: 10,
|
|
330
|
+
sourceStartOffset: 0,
|
|
331
|
+
sourceEndOffset: 10,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
project.trimClipEnd(clip.id, 5);
|
|
335
|
+
const updated = project.getClip(clip.id);
|
|
336
|
+
expect(updated?.duration).toBe(5);
|
|
337
|
+
expect(updated?.sourceEndOffset).toBe(5);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("enforces minimum duration when trimming", () => {
|
|
341
|
+
const clip = project.addClip({
|
|
342
|
+
sourceId,
|
|
343
|
+
trackId: "video-track-1",
|
|
344
|
+
startTime: 0,
|
|
345
|
+
duration: 10,
|
|
346
|
+
sourceStartOffset: 0,
|
|
347
|
+
sourceEndOffset: 10,
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
project.trimClipEnd(clip.id, 0);
|
|
351
|
+
expect(project.getClip(clip.id)?.duration).toBe(0.1);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it("removes a clip", () => {
|
|
355
|
+
const clip = project.addClip({
|
|
356
|
+
sourceId,
|
|
357
|
+
trackId: "video-track-1",
|
|
358
|
+
startTime: 0,
|
|
359
|
+
duration: 5,
|
|
360
|
+
sourceStartOffset: 0,
|
|
361
|
+
sourceEndOffset: 5,
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
const removed = project.removeClip(clip.id);
|
|
365
|
+
expect(removed).toBe(true);
|
|
366
|
+
expect(project.getClips()).toHaveLength(0);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("calculates project duration from clips", () => {
|
|
370
|
+
project.addClip({
|
|
371
|
+
sourceId,
|
|
372
|
+
trackId: "video-track-1",
|
|
373
|
+
startTime: 0,
|
|
374
|
+
duration: 5,
|
|
375
|
+
sourceStartOffset: 0,
|
|
376
|
+
sourceEndOffset: 5,
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
project.addClip({
|
|
380
|
+
sourceId,
|
|
381
|
+
trackId: "video-track-1",
|
|
382
|
+
startTime: 10,
|
|
383
|
+
duration: 5,
|
|
384
|
+
sourceStartOffset: 0,
|
|
385
|
+
sourceEndOffset: 5,
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
expect(project.getDuration()).toBe(15);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe("splitClip", () => {
|
|
392
|
+
it("splits a clip at given time", () => {
|
|
393
|
+
const clip = project.addClip({
|
|
394
|
+
sourceId,
|
|
395
|
+
trackId: "video-track-1",
|
|
396
|
+
startTime: 0,
|
|
397
|
+
duration: 10,
|
|
398
|
+
sourceStartOffset: 0,
|
|
399
|
+
sourceEndOffset: 10,
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
const result = project.splitClip(clip.id, 4);
|
|
403
|
+
expect(result).not.toBeNull();
|
|
404
|
+
|
|
405
|
+
const [firstClip, secondClip] = result!;
|
|
406
|
+
expect(firstClip.duration).toBe(4);
|
|
407
|
+
expect(firstClip.sourceEndOffset).toBe(4);
|
|
408
|
+
expect(secondClip.startTime).toBe(4);
|
|
409
|
+
expect(secondClip.duration).toBe(6);
|
|
410
|
+
expect(secondClip.sourceStartOffset).toBe(4);
|
|
411
|
+
expect(project.getClips()).toHaveLength(2);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("returns null for non-existent clip", () => {
|
|
415
|
+
const result = project.splitClip("non-existent", 5);
|
|
416
|
+
expect(result).toBeNull();
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it("returns null when split time is at or before 0", () => {
|
|
420
|
+
const clip = project.addClip({
|
|
421
|
+
sourceId,
|
|
422
|
+
trackId: "video-track-1",
|
|
423
|
+
startTime: 0,
|
|
424
|
+
duration: 10,
|
|
425
|
+
sourceStartOffset: 0,
|
|
426
|
+
sourceEndOffset: 10,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
expect(project.splitClip(clip.id, 0)).toBeNull();
|
|
430
|
+
expect(project.splitClip(clip.id, -1)).toBeNull();
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it("returns null when split time is at or after duration", () => {
|
|
434
|
+
const clip = project.addClip({
|
|
435
|
+
sourceId,
|
|
436
|
+
trackId: "video-track-1",
|
|
437
|
+
startTime: 0,
|
|
438
|
+
duration: 10,
|
|
439
|
+
sourceStartOffset: 0,
|
|
440
|
+
sourceEndOffset: 10,
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
expect(project.splitClip(clip.id, 10)).toBeNull();
|
|
444
|
+
expect(project.splitClip(clip.id, 15)).toBeNull();
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
describe("duplicateClip", () => {
|
|
449
|
+
it("duplicates a clip after original", () => {
|
|
450
|
+
const clip = project.addClip({
|
|
451
|
+
sourceId,
|
|
452
|
+
trackId: "video-track-1",
|
|
453
|
+
startTime: 0,
|
|
454
|
+
duration: 5,
|
|
455
|
+
sourceStartOffset: 0,
|
|
456
|
+
sourceEndOffset: 5,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const duplicate = project.duplicateClip(clip.id);
|
|
460
|
+
expect(duplicate).not.toBeNull();
|
|
461
|
+
expect(duplicate?.sourceId).toBe(sourceId);
|
|
462
|
+
expect(duplicate?.trackId).toBe("video-track-1");
|
|
463
|
+
expect(duplicate?.startTime).toBe(5); // After original
|
|
464
|
+
expect(duplicate?.duration).toBe(5);
|
|
465
|
+
expect(project.getClips()).toHaveLength(2);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it("duplicates a clip at specified time", () => {
|
|
469
|
+
const clip = project.addClip({
|
|
470
|
+
sourceId,
|
|
471
|
+
trackId: "video-track-1",
|
|
472
|
+
startTime: 0,
|
|
473
|
+
duration: 5,
|
|
474
|
+
sourceStartOffset: 0,
|
|
475
|
+
sourceEndOffset: 5,
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
const duplicate = project.duplicateClip(clip.id, 20);
|
|
479
|
+
expect(duplicate).not.toBeNull();
|
|
480
|
+
expect(duplicate?.startTime).toBe(20);
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
it("duplicates clip effects with new IDs", () => {
|
|
484
|
+
const clip = project.addClip({
|
|
485
|
+
sourceId,
|
|
486
|
+
trackId: "video-track-1",
|
|
487
|
+
startTime: 0,
|
|
488
|
+
duration: 5,
|
|
489
|
+
sourceStartOffset: 0,
|
|
490
|
+
sourceEndOffset: 5,
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
project.addEffect(clip.id, {
|
|
494
|
+
type: "fadeIn",
|
|
495
|
+
startTime: 0,
|
|
496
|
+
duration: 1,
|
|
497
|
+
params: { intensity: 1 },
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
const duplicate = project.duplicateClip(clip.id);
|
|
501
|
+
expect(duplicate?.effects).toHaveLength(1);
|
|
502
|
+
expect(duplicate?.effects[0].type).toBe("fadeIn");
|
|
503
|
+
expect(duplicate?.effects[0].id).not.toBe(clip.effects?.[0]?.id);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
it("returns null for non-existent clip", () => {
|
|
507
|
+
const result = project.duplicateClip("non-existent");
|
|
508
|
+
expect(result).toBeNull();
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
describe("effects", () => {
|
|
514
|
+
let clipId: string;
|
|
515
|
+
|
|
516
|
+
beforeEach(() => {
|
|
517
|
+
const source = project.addSource({
|
|
518
|
+
name: "test.mp4",
|
|
519
|
+
type: "video",
|
|
520
|
+
url: "/path/to/test.mp4",
|
|
521
|
+
duration: 10,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
const clip = project.addClip({
|
|
525
|
+
sourceId: source.id,
|
|
526
|
+
trackId: "video-track-1",
|
|
527
|
+
startTime: 0,
|
|
528
|
+
duration: 5,
|
|
529
|
+
sourceStartOffset: 0,
|
|
530
|
+
sourceEndOffset: 5,
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
clipId = clip.id;
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it("adds an effect to a clip", () => {
|
|
537
|
+
const effect = project.addEffect(clipId, {
|
|
538
|
+
type: "fadeIn",
|
|
539
|
+
startTime: 0,
|
|
540
|
+
duration: 1,
|
|
541
|
+
params: { intensity: 1 },
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
expect(effect).not.toBeNull();
|
|
545
|
+
expect(effect?.type).toBe("fadeIn");
|
|
546
|
+
expect(project.getClip(clipId)?.effects).toHaveLength(1);
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
it("returns null when adding effect to non-existent clip", () => {
|
|
550
|
+
const effect = project.addEffect("non-existent", {
|
|
551
|
+
type: "fadeIn",
|
|
552
|
+
startTime: 0,
|
|
553
|
+
duration: 1,
|
|
554
|
+
params: {},
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
expect(effect).toBeNull();
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it("removes an effect from a clip", () => {
|
|
561
|
+
const effect = project.addEffect(clipId, {
|
|
562
|
+
type: "fadeIn",
|
|
563
|
+
startTime: 0,
|
|
564
|
+
duration: 1,
|
|
565
|
+
params: {},
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
const removed = project.removeEffect(clipId, effect!.id);
|
|
569
|
+
expect(removed).toBe(true);
|
|
570
|
+
expect(project.getClip(clipId)?.effects).toHaveLength(0);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
it("updates an effect", () => {
|
|
574
|
+
const effect = project.addEffect(clipId, {
|
|
575
|
+
type: "fadeIn",
|
|
576
|
+
startTime: 0,
|
|
577
|
+
duration: 1,
|
|
578
|
+
params: { intensity: 0.5 },
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
const updated = project.updateEffect(clipId, effect!.id, {
|
|
582
|
+
params: { intensity: 1 },
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
expect(updated).toBe(true);
|
|
586
|
+
expect(project.getClip(clipId)?.effects[0].params.intensity).toBe(1);
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
describe("transitions", () => {
|
|
591
|
+
it("adds a transition", () => {
|
|
592
|
+
const transition = project.addTransition({
|
|
593
|
+
type: "dissolve",
|
|
594
|
+
duration: 1,
|
|
595
|
+
fromClipId: "clip-1",
|
|
596
|
+
toClipId: "clip-2",
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
expect(transition.id).toBeDefined();
|
|
600
|
+
expect(project.getTransitions()).toHaveLength(1);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it("removes a transition", () => {
|
|
604
|
+
const transition = project.addTransition({
|
|
605
|
+
type: "dissolve",
|
|
606
|
+
duration: 1,
|
|
607
|
+
fromClipId: "clip-1",
|
|
608
|
+
toClipId: "clip-2",
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
const removed = project.removeTransition(transition.id);
|
|
612
|
+
expect(removed).toBe(true);
|
|
613
|
+
expect(project.getTransitions()).toHaveLength(0);
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
describe("serialization", () => {
|
|
618
|
+
it("serializes to JSON", () => {
|
|
619
|
+
const source = project.addSource({
|
|
620
|
+
name: "test.mp4",
|
|
621
|
+
type: "video",
|
|
622
|
+
url: "/path/to/test.mp4",
|
|
623
|
+
duration: 10,
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
project.addClip({
|
|
627
|
+
sourceId: source.id,
|
|
628
|
+
trackId: "video-track-1",
|
|
629
|
+
startTime: 0,
|
|
630
|
+
duration: 5,
|
|
631
|
+
sourceStartOffset: 0,
|
|
632
|
+
sourceEndOffset: 5,
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
const json = project.toJSON();
|
|
636
|
+
expect(json.version).toBe("1.0.0");
|
|
637
|
+
expect(json.state.project.name).toBe("Test Project");
|
|
638
|
+
expect(json.state.sources).toHaveLength(1);
|
|
639
|
+
expect(json.state.clips).toHaveLength(1);
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
it("deserializes from JSON", () => {
|
|
643
|
+
const source = project.addSource({
|
|
644
|
+
name: "test.mp4",
|
|
645
|
+
type: "video",
|
|
646
|
+
url: "/path/to/test.mp4",
|
|
647
|
+
duration: 10,
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
project.addClip({
|
|
651
|
+
sourceId: source.id,
|
|
652
|
+
trackId: "video-track-1",
|
|
653
|
+
startTime: 0,
|
|
654
|
+
duration: 5,
|
|
655
|
+
sourceStartOffset: 0,
|
|
656
|
+
sourceEndOffset: 5,
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
const json = project.toJSON();
|
|
660
|
+
const restored = Project.fromJSON(json);
|
|
661
|
+
|
|
662
|
+
expect(restored.getMeta().name).toBe("Test Project");
|
|
663
|
+
expect(restored.getSources()).toHaveLength(1);
|
|
664
|
+
expect(restored.getClips()).toHaveLength(1);
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
it("returns immutable state copy", () => {
|
|
668
|
+
const state1 = project.getState();
|
|
669
|
+
const state2 = project.getState();
|
|
670
|
+
|
|
671
|
+
expect(state1).not.toBe(state2);
|
|
672
|
+
expect(state1).toEqual(state2);
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
describe("summary", () => {
|
|
677
|
+
it("returns project summary", () => {
|
|
678
|
+
const source = project.addSource({
|
|
679
|
+
name: "test.mp4",
|
|
680
|
+
type: "video",
|
|
681
|
+
url: "/path/to/test.mp4",
|
|
682
|
+
duration: 10,
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
project.addClip({
|
|
686
|
+
sourceId: source.id,
|
|
687
|
+
trackId: "video-track-1",
|
|
688
|
+
startTime: 0,
|
|
689
|
+
duration: 5,
|
|
690
|
+
sourceStartOffset: 0,
|
|
691
|
+
sourceEndOffset: 5,
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
const summary = project.getSummary();
|
|
695
|
+
expect(summary.name).toBe("Test Project");
|
|
696
|
+
expect(summary.duration).toBe(5);
|
|
697
|
+
expect(summary.trackCount).toBe(2);
|
|
698
|
+
expect(summary.clipCount).toBe(1);
|
|
699
|
+
expect(summary.sourceCount).toBe(1);
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
});
|