kasaframe 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +148 -0
- package/README.md +92 -2
- package/app/package.json +12 -0
- package/app/server/engine.ts +533 -0
- package/app/server/main.ts +209 -0
- package/app/web/env.d.ts +2 -0
- package/app/web/icons.ts +31 -0
- package/app/web/index.html +21 -0
- package/app/web/main.ts +1195 -0
- package/app/web/style.css +463 -0
- package/bin/hooks.mjs +64 -0
- package/bin/kf.mjs +32 -0
- package/docs/AGENTS.md +286 -0
- package/music/README.md +37 -0
- package/package.json +44 -4
- package/packages/adapters/package.json +36 -0
- package/packages/adapters/src/css.ts +11 -0
- package/packages/adapters/src/gsap.ts +26 -0
- package/packages/adapters/src/index.ts +9 -0
- package/packages/adapters/src/lottie.ts +22 -0
- package/packages/adapters/src/media.ts +59 -0
- package/packages/adapters/src/page.ts +229 -0
- package/packages/adapters/src/project.ts +214 -0
- package/packages/adapters/src/react.ts +36 -0
- package/packages/adapters/src/svelte.ts +22 -0
- package/packages/adapters/src/three.ts +18 -0
- package/packages/adapters/src/vue.ts +27 -0
- package/packages/check/package.json +19 -0
- package/packages/check/src/check.ts +280 -0
- package/packages/check/src/cli.ts +70 -0
- package/packages/check/src/image.ts +146 -0
- package/packages/check/src/index.ts +9 -0
- package/packages/check/src/ocr.swift +37 -0
- package/packages/check/src/probe.ts +328 -0
- package/packages/check/src/report.ts +44 -0
- package/packages/check/src/rules/assets.ts +45 -0
- package/packages/check/src/rules/beats.ts +212 -0
- package/packages/check/src/rules/camera.ts +217 -0
- package/packages/check/src/rules/captions.ts +49 -0
- package/packages/check/src/rules/flash.ts +235 -0
- package/packages/check/src/rules/frames.ts +136 -0
- package/packages/check/src/rules/layout.ts +281 -0
- package/packages/check/src/rules/page.ts +87 -0
- package/packages/check/src/rules/runs.ts +20 -0
- package/packages/check/src/rules/text.ts +326 -0
- package/packages/check/src/scan.ts +240 -0
- package/packages/check/src/serve.ts +67 -0
- package/packages/check/src/types.ts +80 -0
- package/packages/check/src/video.ts +137 -0
- package/packages/cli/package.json +30 -0
- package/packages/cli/src/blur.ts +80 -0
- package/packages/cli/src/browser.ts +203 -0
- package/packages/cli/src/command.ts +44 -0
- package/packages/cli/src/commands/app.ts +25 -0
- package/packages/cli/src/commands/beats.ts +36 -0
- package/packages/cli/src/commands/bench.ts +123 -0
- package/packages/cli/src/commands/blender.ts +293 -0
- package/packages/cli/src/commands/check.ts +25 -0
- package/packages/cli/src/commands/direct.ts +210 -0
- package/packages/cli/src/commands/doctor.ts +30 -0
- package/packages/cli/src/commands/gen.ts +173 -0
- package/packages/cli/src/commands/look.ts +46 -0
- package/packages/cli/src/commands/lyrics.ts +157 -0
- package/packages/cli/src/commands/make.ts +1121 -0
- package/packages/cli/src/commands/music.ts +78 -0
- package/packages/cli/src/commands/narrate.ts +238 -0
- package/packages/cli/src/commands/new.ts +185 -0
- package/packages/cli/src/commands/preview.ts +43 -0
- package/packages/cli/src/commands/render.ts +250 -0
- package/packages/cli/src/commands/series.ts +110 -0
- package/packages/cli/src/commands/setup.ts +102 -0
- package/packages/cli/src/commands/sheet.ts +114 -0
- package/packages/cli/src/commands/skill.ts +43 -0
- package/packages/cli/src/commands/still.ts +40 -0
- package/packages/cli/src/commands/theme.ts +172 -0
- package/packages/cli/src/commands/transitions.ts +40 -0
- package/packages/cli/src/deps.ts +122 -0
- package/packages/cli/src/ffmpeg.ts +81 -0
- package/packages/cli/src/index.ts +8 -0
- package/packages/cli/src/kf.ts +64 -0
- package/packages/cli/src/lock.ts +72 -0
- package/packages/cli/src/mix.ts +131 -0
- package/packages/cli/src/out.ts +13 -0
- package/packages/cli/src/pool.ts +34 -0
- package/packages/cli/src/segments.ts +402 -0
- package/packages/cli/src/serve.ts +124 -0
- package/packages/clock/package.json +14 -0
- package/packages/clock/src/index.ts +25 -0
- package/packages/clock/src/install.ts +351 -0
- package/packages/clock/src/types.ts +45 -0
- package/packages/core/package.json +9 -0
- package/packages/core/src/beats.ts +283 -0
- package/packages/core/src/ease.ts +87 -0
- package/packages/core/src/frame.ts +99 -0
- package/packages/core/src/index.ts +27 -0
- package/packages/core/src/project.ts +157 -0
- package/packages/core/src/rand.ts +56 -0
- package/packages/core/src/spring.ts +52 -0
- package/packages/core/src/style.ts +100 -0
- package/packages/core/src/time.ts +88 -0
- package/packages/director/package.json +23 -0
- package/packages/director/src/assemble.ts +361 -0
- package/packages/director/src/brief.ts +122 -0
- package/packages/director/src/catalog.ts +49 -0
- package/packages/director/src/content.ts +343 -0
- package/packages/director/src/fallback.ts +58 -0
- package/packages/director/src/index.ts +13 -0
- package/packages/director/src/pattern.ts +90 -0
- package/packages/director/src/patterns/fill/cells.ts +115 -0
- package/packages/director/src/patterns/formula/stack.ts +93 -0
- package/packages/director/src/patterns/util.ts +58 -0
- package/packages/director/src/scene.ts +62 -0
- package/packages/director/src/select.ts +163 -0
- package/packages/director/src/transitions.ts +115 -0
- package/packages/gen/PROVIDERS.md +90 -0
- package/packages/gen/package.json +9 -0
- package/packages/gen/src/ask.ts +132 -0
- package/packages/gen/src/audio.ts +91 -0
- package/packages/gen/src/blender.ts +54 -0
- package/packages/gen/src/capabilities.ts +151 -0
- package/packages/gen/src/generate.ts +206 -0
- package/packages/gen/src/image/codex.ts +117 -0
- package/packages/gen/src/image/og.ts +133 -0
- package/packages/gen/src/index.ts +26 -0
- package/packages/gen/src/keys.ts +86 -0
- package/packages/gen/src/media.ts +150 -0
- package/packages/gen/src/music/elevenlabs.ts +41 -0
- package/packages/gen/src/music/index.ts +120 -0
- package/packages/gen/src/music/library.ts +73 -0
- package/packages/gen/src/music/lyria.ts +52 -0
- package/packages/gen/src/music/types.ts +28 -0
- package/packages/gen/src/plan.ts +106 -0
- package/packages/gen/src/registry.ts +54 -0
- package/packages/gen/src/seam.ts +103 -0
- package/packages/gen/src/tts/dashscope.ts +64 -0
- package/packages/gen/src/tts/elevenlabs.ts +84 -0
- package/packages/gen/src/tts/gemini.ts +73 -0
- package/packages/gen/src/tts/index.ts +241 -0
- package/packages/gen/src/tts/local.ts +42 -0
- package/packages/gen/src/tts/types.ts +44 -0
- package/packages/gen/src/types.ts +90 -0
- package/packages/gen/src/video/fal.ts +140 -0
- package/packages/gen/src/video/h3.ts +112 -0
- package/packages/gen/src/video/http.ts +44 -0
- package/packages/gen/src/video/ltx.ts +60 -0
- package/packages/gen/src/video/minimax.ts +55 -0
- package/packages/gen/src/video/veo.ts +71 -0
- package/packages/jizura/package.json +16 -0
- package/packages/jizura/src/deny.ts +73 -0
- package/packages/jizura/src/index.ts +7 -0
- package/packages/jizura/src/install.ts +269 -0
- package/packages/jizura/src/layer.ts +325 -0
- package/packages/jizura/src/lyrics.ts +81 -0
- package/packages/jizura/src/pin.ts +8 -0
- package/packages/jizura/src/vendor.ts +140 -0
- package/packages/jizura/src/vite.ts +63 -0
- package/packages/jizura/vendor/JIZURA_LICENSE.txt +21 -0
- package/packages/jizura/vendor/NOTICE +43 -0
- package/packages/jizura/vendor/engine.json +47 -0
- package/packages/jizura/vendor/fonts/BlackHanSans-Regular.woff2 +0 -0
- package/packages/jizura/vendor/fonts/DotGothic16-Regular.woff2 +0 -0
- package/packages/jizura/vendor/fonts/GowunBatang-Bold.woff2 +0 -0
- package/packages/jizura/vendor/fonts/IBMPlexMono-Medium.ttf +0 -0
- package/packages/jizura/vendor/fonts/IBMPlexMono-SemiBold.ttf +0 -0
- package/packages/jizura/vendor/fonts/NotoSansKR-VF.woff2 +0 -0
- package/packages/jizura/vendor/fonts/NotoSerifKR-VF.woff2 +0 -0
- package/packages/jizura/vendor/fonts/OFL-blackhansans.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-dotgothic16.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-gowunbatang.txt +94 -0
- package/packages/jizura/vendor/fonts/OFL-ibmplexmono.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-notosanskr.txt +93 -0
- package/packages/jizura/vendor/fonts/OFL-notoserifkr.txt +94 -0
- package/packages/jizura/vendor/fonts/fonts.json +52 -0
- package/packages/jizura/vendor/jizura_engine.js +35024 -0
- package/packages/motion/README.md +153 -0
- package/packages/motion/package.json +30 -0
- package/packages/motion/src/camera.ts +97 -0
- package/packages/motion/src/captions.ts +487 -0
- package/packages/motion/src/enter.ts +128 -0
- package/packages/motion/src/hangul.ts +129 -0
- package/packages/motion/src/impact.ts +100 -0
- package/packages/motion/src/index.ts +17 -0
- package/packages/motion/src/moves/brushWipe.ts +103 -0
- package/packages/motion/src/moves/cloneArray.ts +111 -0
- package/packages/motion/src/moves/curtains.ts +81 -0
- package/packages/motion/src/moves/dress.ts +191 -0
- package/packages/motion/src/moves/echoStack.ts +70 -0
- package/packages/motion/src/moves/fit.ts +70 -0
- package/packages/motion/src/moves/flood.ts +61 -0
- package/packages/motion/src/moves/ghostStack.ts +88 -0
- package/packages/motion/src/moves/gridFloor.ts +100 -0
- package/packages/motion/src/moves/imageSwarm.ts +113 -0
- package/packages/motion/src/moves/index.ts +38 -0
- package/packages/motion/src/moves/irisBlades.ts +113 -0
- package/packages/motion/src/moves/karaokeLine.ts +108 -0
- package/packages/motion/src/moves/ledBoard.ts +94 -0
- package/packages/motion/src/moves/liquidTab.ts +72 -0
- package/packages/motion/src/moves/markerWrite.ts +63 -0
- package/packages/motion/src/moves/menu.ts +138 -0
- package/packages/motion/src/moves/morphBox.ts +96 -0
- package/packages/motion/src/moves/neonSign.ts +78 -0
- package/packages/motion/src/moves/panelPop.ts +78 -0
- package/packages/motion/src/moves/paperTear.ts +75 -0
- package/packages/motion/src/moves/path.ts +64 -0
- package/packages/motion/src/moves/pathText.ts +107 -0
- package/packages/motion/src/moves/pointSphere.ts +109 -0
- package/packages/motion/src/moves/ransomLetters.ts +73 -0
- package/packages/motion/src/moves/shapeMorph.ts +143 -0
- package/packages/motion/src/moves/slamWords.ts +96 -0
- package/packages/motion/src/moves/sparkTrail.ts +130 -0
- package/packages/motion/src/moves/speedLines.ts +91 -0
- package/packages/motion/src/moves/splitFlap.ts +149 -0
- package/packages/motion/src/moves/stepWords.ts +128 -0
- package/packages/motion/src/moves/strikeOut.ts +98 -0
- package/packages/motion/src/moves/sunburst.ts +58 -0
- package/packages/motion/src/moves/tickerRows.ts +91 -0
- package/packages/motion/src/moves/tokenPicker.ts +115 -0
- package/packages/motion/src/moves/truchet.ts +85 -0
- package/packages/motion/src/moves/wordWall.ts +78 -0
- package/packages/motion/src/moves/worldRoll.ts +32 -0
- package/packages/motion/src/particles.ts +102 -0
- package/packages/motion/src/react/index.tsx +21 -0
- package/packages/motion/src/react/parts.tsx +431 -0
- package/packages/motion/src/react/time.tsx +97 -0
- package/packages/motion/src/text.ts +103 -0
- package/packages/motion/src/transition.ts +82 -0
- package/packages/motion/src/transition3d/cards.ts +65 -0
- package/packages/motion/src/transition3d/chain.ts +84 -0
- package/packages/motion/src/transition3d/dive.ts +181 -0
- package/packages/motion/src/transition3d/fold.ts +110 -0
- package/packages/motion/src/transition3d/gl.ts +219 -0
- package/packages/motion/src/transition3d/index.ts +235 -0
- package/packages/motion/src/transition3d/live.ts +70 -0
- package/packages/motion/src/transition3d/portal.ts +115 -0
- package/packages/motion/src/transition3d/react.tsx +29 -0
- package/packages/motion/src/transition3d/rig.ts +600 -0
- package/packages/motion/src/transition3d/shatter.ts +104 -0
- package/packages/motion/src/transition3d/space.ts +173 -0
- package/packages/motion/src/transition3d/whip.ts +78 -0
- package/packages/motion/src/transition3d/world.ts +737 -0
- package/packages/motion/src/transition3d/zoomOut.ts +114 -0
- package/packages/motion/src/transitions2d/catalog.ts +127 -0
- package/packages/motion/src/transitions2d/css.d.ts +2 -0
- package/packages/motion/src/transitions2d/cult-ui/LICENSE.md +9 -0
- package/packages/motion/src/transitions2d/cult-ui/RollingNumber.tsx +43 -0
- package/packages/motion/src/transitions2d/gl-transitions/LICENSE +25 -0
- package/packages/motion/src/transitions2d/gl-transitions/shaders.ts +1931 -0
- package/packages/motion/src/transitions2d/index.ts +2 -0
- package/packages/motion/src/transitions2d/kokonutui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/kokonutui/MatrixText.css +16 -0
- package/packages/motion/src/transitions2d/kokonutui/MatrixText.tsx +94 -0
- package/packages/motion/src/transitions2d/magicui/HyperText.css +15 -0
- package/packages/motion/src/transitions2d/magicui/HyperText.tsx +115 -0
- package/packages/motion/src/transitions2d/magicui/LICENSE.md +21 -0
- package/packages/motion/src/transitions2d/magicui/MorphingText.css +25 -0
- package/packages/motion/src/transitions2d/magicui/MorphingText.tsx +130 -0
- package/packages/motion/src/transitions2d/magicui/WordRotate.tsx +42 -0
- package/packages/motion/src/transitions2d/react.ts +13 -0
- package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.css +39 -0
- package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.tsx +32 -0
- package/packages/motion/src/transitions2d/smoothui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/smoothui/SharedAxisY.tsx +50 -0
- package/packages/motion/src/transitions2d/smoothui/TextMorph.tsx +90 -0
- package/packages/motion/src/transitions2d/smoothui/shaders.ts +223 -0
- package/packages/motion/src/transitions2d/unlumen/LICENSE +21 -0
- package/packages/motion/src/transitions2d/unlumen/ScrambleText.tsx +114 -0
- package/packages/motion/src/transitions2d/vengeance-ui/LICENSE +21 -0
- package/packages/motion/src/transitions2d/vengeance-ui/MorphText.css +69 -0
- package/packages/motion/src/transitions2d/vengeance-ui/MorphText.tsx +45 -0
- package/packages/motion/src/type.ts +131 -0
- package/packages/motion/src/ui.ts +172 -0
- package/packages/patterns/package.json +15 -0
- package/packages/patterns/src/bars/rank.ts +119 -0
- package/packages/patterns/src/before-after/shrink.ts +127 -0
- package/packages/patterns/src/before-after/strike.ts +125 -0
- package/packages/patterns/src/code/terminal.ts +133 -0
- package/packages/patterns/src/compare/bars.ts +142 -0
- package/packages/patterns/src/compare/duel.ts +103 -0
- package/packages/patterns/src/end/lockup.ts +85 -0
- package/packages/patterns/src/end/slam.ts +91 -0
- package/packages/patterns/src/flow/graph.ts +250 -0
- package/packages/patterns/src/hook-number/counter.ts +101 -0
- package/packages/patterns/src/hook-number/roll.ts +179 -0
- package/packages/patterns/src/hook-number/slam.ts +91 -0
- package/packages/patterns/src/index.ts +38 -0
- package/packages/patterns/src/kit.ts +449 -0
- package/packages/patterns/src/limit/gauge.ts +117 -0
- package/packages/patterns/src/list/cards.ts +131 -0
- package/packages/patterns/src/list/cycle.ts +22 -0
- package/packages/patterns/src/media/panels.ts +100 -0
- package/packages/patterns/src/objects.ts +234 -0
- package/packages/patterns/src/quote/karaoke.ts +126 -0
- package/packages/patterns/src/quote/slam.ts +22 -0
- package/packages/patterns/src/screen/focus.ts +85 -0
- package/packages/patterns/src/steps/path.ts +137 -0
- package/packages/patterns/src/steps/stack.ts +111 -0
- package/packages/patterns/src/term-reveal/chips.ts +92 -0
- package/packages/patterns/src/term-reveal/expand.ts +127 -0
- package/packages/patterns/src/timeline/axis.ts +144 -0
- package/packages/patterns/src/title/mask.ts +85 -0
- package/packages/patterns/src/title/slam.ts +23 -0
- package/packages/patterns/src/toggle-sim/switch.ts +92 -0
- package/packages/patterns/src/trend/columns.ts +108 -0
- package/packages/patterns/src/trend/draw.ts +140 -0
- package/packages/patterns/src/types.ts +67 -0
- package/packages/patterns/src/words/moves.ts +42 -0
- package/packages/patterns/src/words/slam.ts +4 -0
- package/packages/plan/package.json +15 -0
- package/packages/plan/src/asks.ts +256 -0
- package/packages/plan/src/brief.ts +383 -0
- package/packages/plan/src/captions.ts +78 -0
- package/packages/plan/src/detect.ts +93 -0
- package/packages/plan/src/index.ts +27 -0
- package/packages/plan/src/layout.ts +176 -0
- package/packages/plan/src/llm.ts +172 -0
- package/packages/plan/src/look.ts +222 -0
- package/packages/plan/src/plan.ts +179 -0
- package/packages/plan/src/request.ts +55 -0
- package/packages/plan/src/series.ts +76 -0
- package/packages/plan/src/studio.ts +53 -0
- package/packages/plan/src/templates.ts +42 -0
- package/packages/plan/src/themes.ts +48 -0
- package/packages/plan/src/types.ts +157 -0
- package/packages/studio/package.json +12 -0
- package/packages/studio/src/index.ts +1 -0
- package/packages/studio/src/plugin.ts +236 -0
- package/packages/studio/src/ui/main.ts +503 -0
- package/packages/studio/src/ui/studio.css +165 -0
- package/packages/studio/src/ui/timeline.ts +317 -0
- package/packages/themes/kit/THEME-MAKE.md +68 -0
- package/packages/themes/kit/THEME.md +30 -0
- package/packages/themes/kit/briefs/og-intro-15s/brief.json +16 -0
- package/packages/themes/kit/briefs/og-intro-15s/facts.ts +29 -0
- package/packages/themes/kit/briefs/og-intro-15s/logo.svg +12 -0
- package/packages/themes/kit/effects.ts +5 -0
- package/packages/themes/kit/sample/index.html +11 -0
- package/packages/themes/kit/sample/main.ts +9 -0
- package/packages/themes/kit/sample/scenes/scene.ts +15 -0
- package/packages/themes/package.json +19 -0
- package/packages/themes/src/factory.ts +296 -0
- package/packages/themes/src/fx.ts +14 -0
- package/packages/themes/src/index.ts +114 -0
- package/packages/themes/src/slotkit.ts +79 -0
- package/packages/themes/src/slots.ts +46 -0
- package/packages/themes/src/stage3d.ts +197 -0
- package/packages/themes/src/types.ts +58 -0
- package/presets/kawaii-pastel.json +94 -0
- package/presets/neutral-dark.json +82 -0
- package/presets/og.json +98 -0
- package/series/og-shorts.json +14 -0
- package/skills/kasaframe/SKILL.md +33 -0
- package/templates/_shared/project/index.html +11 -0
- package/templates/_shared/project/lib/react.ts +22 -0
- package/templates/_shared/project/lib/stage.ts +292 -0
- package/templates/_shared/project/main.ts +9 -0
- package/templates/_shared/scenes/default.ts +21 -0
- package/templates/_shared/scenes/drop.ts +33 -0
- package/templates/_shared/scenes/end.ts +26 -0
- package/templates/_shared/scenes/hook.ts +18 -0
- package/templates/_shared/scenes/seam.ts +41 -0
- package/templates/_shared/scenes/step.ts +49 -0
- package/templates/ad/preview.png +0 -0
- package/templates/ad/template.json +151 -0
- package/templates/demo/preview.png +0 -0
- package/templates/demo/template.json +141 -0
- package/templates/explainer/preview.png +0 -0
- package/templates/explainer/template.json +193 -0
- package/templates/launch/preview.png +0 -0
- package/templates/launch/template.json +163 -0
- package/templates/mv/preview.png +0 -0
- package/templates/mv/scenes/default.ts +98 -0
- package/templates/mv/template.json +178 -0
- package/templates/promo/preview.png +0 -0
- package/templates/promo/template.json +185 -0
- package/templates/shorts/preview.png +0 -0
- package/templates/shorts/scenes/hook.ts +37 -0
- package/templates/shorts/template.json +196 -0
- package/templates/square/preview.png +0 -0
- package/templates/square/template.json +133 -0
- package/themes/debug-hud/THEME.md +39 -0
- package/themes/debug-hud/effects.ts +389 -0
- package/themes/debug-hud/sample/assets/og/logo.svg +12 -0
- package/themes/debug-hud/sample/beats.json +1 -0
- package/themes/debug-hud/sample/index.html +11 -0
- package/themes/debug-hud/sample/kf.json +59 -0
- package/themes/debug-hud/sample/lib/hudkit.ts +49 -0
- package/themes/debug-hud/sample/lib/og.ts +29 -0
- package/themes/debug-hud/sample/main.ts +9 -0
- package/themes/debug-hud/sample/scenes/end.ts +62 -0
- package/themes/debug-hud/sample/scenes/gather.ts +67 -0
- package/themes/debug-hud/sample/scenes/models.ts +70 -0
- package/themes/debug-hud/sample/scenes/price.ts +79 -0
- package/themes/debug-hud/sample/style.json +91 -0
- package/themes/debug-hud/slots.ts +99 -0
- package/themes/debug-hud/still.png +0 -0
- package/themes/debug-hud/style.json +91 -0
- package/themes/debug-hud/theme.json +68 -0
- package/themes/og-measure/THEME.md +47 -0
- package/themes/og-measure/effects.ts +432 -0
- package/themes/og-measure/sample/assets/brand/og-logo-full.svg +12 -0
- package/themes/og-measure/sample/assets/brand/og-logo.svg +12 -0
- package/themes/og-measure/sample/assets/data/measure.json +353 -0
- package/themes/og-measure/sample/beats.json +1 -0
- package/themes/og-measure/sample/index.html +11 -0
- package/themes/og-measure/sample/kf.json +66 -0
- package/themes/og-measure/sample/lib/data.ts +62 -0
- package/themes/og-measure/sample/main.ts +9 -0
- package/themes/og-measure/sample/measure.ts +78 -0
- package/themes/og-measure/sample/scenes/end.ts +47 -0
- package/themes/og-measure/sample/scenes/gather.ts +51 -0
- package/themes/og-measure/sample/scenes/models.ts +34 -0
- package/themes/og-measure/sample/scenes/one.ts +39 -0
- package/themes/og-measure/sample/scenes/price.ts +56 -0
- package/themes/og-measure/sample/style.json +97 -0
- package/themes/og-measure/slots.ts +88 -0
- package/themes/og-measure/still.png +0 -0
- package/themes/og-measure/style.json +97 -0
- package/themes/og-measure/theme.json +79 -0
- package/themes/riso-zine/THEME.md +43 -0
- package/themes/riso-zine/effects.ts +321 -0
- package/themes/riso-zine/sample/assets/og/logo.svg +12 -0
- package/themes/riso-zine/sample/beats.json +1 -0
- package/themes/riso-zine/sample/index.html +11 -0
- package/themes/riso-zine/sample/kf.json +59 -0
- package/themes/riso-zine/sample/lib/og.ts +29 -0
- package/themes/riso-zine/sample/lib/shot.ts +86 -0
- package/themes/riso-zine/sample/lib/zine.ts +42 -0
- package/themes/riso-zine/sample/main.ts +9 -0
- package/themes/riso-zine/sample/scenes/end.ts +61 -0
- package/themes/riso-zine/sample/scenes/gather.ts +62 -0
- package/themes/riso-zine/sample/scenes/models.ts +52 -0
- package/themes/riso-zine/sample/scenes/price.ts +82 -0
- package/themes/riso-zine/sample/style.json +99 -0
- package/themes/riso-zine/slots.ts +81 -0
- package/themes/riso-zine/still.png +0 -0
- package/themes/riso-zine/style.json +99 -0
- package/themes/riso-zine/theme.json +75 -0
- package/tools/beats/beats.py +372 -0
- package/tools/beats/requirements.txt +3 -0
- package/tools/lyrics/align.py +164 -0
- package/tools/lyrics/requirements.txt +9 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { KfMotionEvent, MotionRules as CoreMotionRules, SafeArea } from "@kasaframe/core";
|
|
2
|
+
|
|
3
|
+
export type Severity = "error" | "warn";
|
|
4
|
+
|
|
5
|
+
export interface Finding {
|
|
6
|
+
rule: string;
|
|
7
|
+
severity: Severity;
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
message: string;
|
|
11
|
+
// 고치는 쪽(사람이든 모델이든)이 곧장 손댈 자리를 찾도록 원자료를 붙인다.
|
|
12
|
+
detail?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Report {
|
|
16
|
+
target: string;
|
|
17
|
+
kind: "page" | "video";
|
|
18
|
+
// 페이지만 — step 이면 「같은 프레임 두 번」을 못 본다
|
|
19
|
+
mode?: "seek" | "step";
|
|
20
|
+
ok: boolean;
|
|
21
|
+
meta: { fps: number; width: number; height: number; duration: number };
|
|
22
|
+
sampled: { frames: number; textFrames: number; thumbFps: number };
|
|
23
|
+
counts: { error: number; warn: number };
|
|
24
|
+
findings: Finding[];
|
|
25
|
+
skipped: string[];
|
|
26
|
+
elapsedSec: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Box {
|
|
30
|
+
x0: number;
|
|
31
|
+
y0: number;
|
|
32
|
+
x1: number;
|
|
33
|
+
y1: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TextHit {
|
|
37
|
+
text: string;
|
|
38
|
+
// canvas 는 fillText·strokeText, DOM 은 text node
|
|
39
|
+
// caption — 엔진이 장면 위에 얹은 자막 판(data-kf-captions). 장면 글과 한 줄로 잇지 않는다
|
|
40
|
+
via: "canvas" | "dom" | "caption";
|
|
41
|
+
// 가사 층(data-kf-lyrics — JIZURA 같은 키네틱 가사) 안의 글. 띠로 흘리는 마퀴·배경 큰 글자처럼 일부러 화면 끝을 넘겨 그린다
|
|
42
|
+
lyrics?: boolean;
|
|
43
|
+
// fillText 에 문자열이 아닌 값(undefined·숫자·객체)이 들어왔을 때 그 typeof
|
|
44
|
+
argType?: string;
|
|
45
|
+
font: string;
|
|
46
|
+
sizePx: number;
|
|
47
|
+
alpha: number;
|
|
48
|
+
// 화면(뷰포트) 좌표. 화면에 붙지 않은 오프스크린 canvas 면 없다.
|
|
49
|
+
box?: Box;
|
|
50
|
+
where?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FrameText {
|
|
54
|
+
t: number;
|
|
55
|
+
hits: TextHit[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type MotionEvent = KfMotionEvent;
|
|
59
|
+
|
|
60
|
+
export interface Marker {
|
|
61
|
+
t: number;
|
|
62
|
+
label: string;
|
|
63
|
+
kind: "scene" | "beat" | "drop" | "section";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface Beats {
|
|
67
|
+
duration?: number;
|
|
68
|
+
bpm?: number;
|
|
69
|
+
beats: number[];
|
|
70
|
+
downbeats?: number[];
|
|
71
|
+
bars?: number[];
|
|
72
|
+
phrases?: number[];
|
|
73
|
+
sections?: { t: number; kind: string; strength?: number }[];
|
|
74
|
+
drops?: number[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// style.json 은 손으로 고치는 파일이라 빠진 칸이 있어도 검사는 돈다.
|
|
78
|
+
export type MotionRules = Partial<CoreMotionRules>;
|
|
79
|
+
|
|
80
|
+
export type { SafeArea };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { spawn, execFileSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync } from "node:fs";
|
|
4
|
+
import { homedir, tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { colorThumb, type Thumb } from "./image.ts";
|
|
8
|
+
import type { FrameText, TextHit } from "./types.ts";
|
|
9
|
+
|
|
10
|
+
export interface VideoInfo {
|
|
11
|
+
fps: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
duration: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function probeVideo(file: string): VideoInfo {
|
|
18
|
+
const out = execFileSync("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height,r_frame_rate:format=duration", "-of", "json", file], {
|
|
19
|
+
encoding: "utf8",
|
|
20
|
+
});
|
|
21
|
+
const j = JSON.parse(out);
|
|
22
|
+
const s = j.streams?.[0];
|
|
23
|
+
if (!s) throw new Error(`영상 스트림이 없다: ${file}`);
|
|
24
|
+
const [n, d] = String(s.r_frame_rate).split("/").map(Number);
|
|
25
|
+
return { fps: d ? n / d : n, width: s.width, height: s.height, duration: Number(j.format.duration) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const TW = 160;
|
|
29
|
+
|
|
30
|
+
// 모든 프레임을 160×90 회색조로 받아 멈춤·빈 화면·컷을 잰다. 60초 60fps 면 52MB 남짓.
|
|
31
|
+
export async function videoThumbs(file: string, info: VideoInfo, from = 0, to = info.duration): Promise<Thumb[]> {
|
|
32
|
+
// 페이지 검사의 썸네일처럼 화면비를 지킨다 — 160×90 으로 누르면 세로 영상의 안전 영역이 뒤집혀 layout.fill 이 늘 0% 였다
|
|
33
|
+
const TH = Math.max(2, Math.round((TW * info.height) / info.width));
|
|
34
|
+
// 색을 받아 섬광 검사의 빨강도 본다 — 밝기는 페이지 검사와 같은 식으로 여기서 만든다
|
|
35
|
+
const args = ["-v", "error", "-ss", String(from), "-t", String(to - from), "-i", file, "-vf", `scale=${TW}:${TH}:flags=area,format=rgb24`, "-f", "rawvideo", "-"];
|
|
36
|
+
const proc = spawn("ffmpeg", args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
37
|
+
const size = TW * TH * 3;
|
|
38
|
+
const thumbs: Thumb[] = [];
|
|
39
|
+
let buf = Buffer.alloc(0);
|
|
40
|
+
let err = "";
|
|
41
|
+
proc.stderr.on("data", (d) => (err += d));
|
|
42
|
+
for await (const chunk of proc.stdout) {
|
|
43
|
+
buf = buf.length ? Buffer.concat([buf, chunk]) : chunk;
|
|
44
|
+
while (buf.length >= size) {
|
|
45
|
+
const data = new Uint8Array(TW * TH * 4);
|
|
46
|
+
for (let i = 0, j = 0; i < size; i += 3, j += 4) {
|
|
47
|
+
data[j] = buf[i];
|
|
48
|
+
data[j + 1] = buf[i + 1];
|
|
49
|
+
data[j + 2] = buf[i + 2];
|
|
50
|
+
}
|
|
51
|
+
thumbs.push(colorThumb(from + thumbs.length / info.fps, { width: TW, height: TH, data }));
|
|
52
|
+
buf = buf.subarray(size);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const code = await new Promise<number>((r) => proc.on("close", r));
|
|
56
|
+
if (code !== 0) throw new Error(`ffmpeg 실패: ${err.slice(0, 300)}`);
|
|
57
|
+
return thumbs;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function ocrBinary(): string | null {
|
|
61
|
+
if (process.platform !== "darwin") return null;
|
|
62
|
+
const src = fileURLToPath(new URL("./ocr.swift", import.meta.url));
|
|
63
|
+
const hash = createHash("sha1").update(readFileSync(src)).digest("hex").slice(0, 10);
|
|
64
|
+
const dir = join(homedir(), ".cache", "kasaframe");
|
|
65
|
+
const bin = join(dir, `kf-ocr-${hash}`);
|
|
66
|
+
if (existsSync(bin)) return bin;
|
|
67
|
+
mkdirSync(dir, { recursive: true });
|
|
68
|
+
try {
|
|
69
|
+
const tmp = `${bin}.${process.pid}`;
|
|
70
|
+
execFileSync("swiftc", ["-O", src, "-o", tmp], { stdio: "ignore" });
|
|
71
|
+
renameSync(tmp, bin);
|
|
72
|
+
return bin;
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function runOcr(bin: string, dir: string): Promise<{ file: string; items: { s: string; c: number; x0: number; y0: number; x1: number; y1: number }[] }[]> {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const p = spawn(bin, [dir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
81
|
+
let out = "";
|
|
82
|
+
p.stdout.on("data", (d) => (out += d));
|
|
83
|
+
p.on("close", (code) =>
|
|
84
|
+
code === 0
|
|
85
|
+
? resolve(
|
|
86
|
+
out
|
|
87
|
+
.split("\n")
|
|
88
|
+
.filter(Boolean)
|
|
89
|
+
.map((l) => JSON.parse(l)),
|
|
90
|
+
)
|
|
91
|
+
: reject(new Error(`OCR 실패 (${code})`)),
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// mp4 에는 글자 정보가 없다. macOS Vision 으로 읽어 페이지 검사와 같은 꼴(FrameText)로 돌려준다.
|
|
97
|
+
// 다른 OS 거나 swiftc 가 없으면 null — 그때 글 검사는 건너뛰었다고 보고서에 적는다.
|
|
98
|
+
export async function videoText(file: string, info: VideoInfo, o: { fps: number; from?: number; to?: number; workers?: number }): Promise<FrameText[] | null> {
|
|
99
|
+
const bin = ocrBinary();
|
|
100
|
+
if (!bin) return null;
|
|
101
|
+
const from = o.from ?? 0;
|
|
102
|
+
const to = o.to ?? info.duration;
|
|
103
|
+
const root = mkdtempSync(join(tmpdir(), "kf-check-"));
|
|
104
|
+
try {
|
|
105
|
+
execFileSync("ffmpeg", ["-v", "error", "-ss", String(from), "-t", String(to - from), "-i", file, "-vf", `fps=${o.fps}`, join(root, "%06d.png")]);
|
|
106
|
+
const files = readdirSync(root).filter((f) => f.endsWith(".png")).sort();
|
|
107
|
+
const workers = Math.max(1, Math.min(o.workers ?? 4, files.length));
|
|
108
|
+
const dirs = Array.from({ length: workers }, (_, i) => {
|
|
109
|
+
const d = join(root, `w${i}`);
|
|
110
|
+
mkdirSync(d);
|
|
111
|
+
return d;
|
|
112
|
+
});
|
|
113
|
+
files.forEach((f, i) => renameSync(join(root, f), join(dirs[i % workers], f)));
|
|
114
|
+
const parts = await Promise.all(dirs.map((d) => runOcr(bin, d)));
|
|
115
|
+
const frames: FrameText[] = [];
|
|
116
|
+
for (const r of parts.flat()) {
|
|
117
|
+
const idx = Number(r.file.replace(/\D/g, "")) - 1;
|
|
118
|
+
const t = from + idx / o.fps;
|
|
119
|
+
const hits: TextHit[] = r.items.map((it) => {
|
|
120
|
+
const h = (it.y1 - it.y0) * info.height;
|
|
121
|
+
return {
|
|
122
|
+
text: it.s,
|
|
123
|
+
via: "dom",
|
|
124
|
+
font: "ocr",
|
|
125
|
+
sizePx: h * 0.8,
|
|
126
|
+
alpha: 1,
|
|
127
|
+
box: { x0: it.x0 * info.width, y0: it.y0 * info.height, x1: it.x1 * info.width, y1: it.y1 * info.height },
|
|
128
|
+
where: `ocr ${Math.round(it.c * 100)}%`,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
if (hits.length) frames.push({ t, hits });
|
|
132
|
+
}
|
|
133
|
+
return frames.sort((a, b) => a.t - b.t);
|
|
134
|
+
} finally {
|
|
135
|
+
rmSync(root, { recursive: true, force: true });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kasaframe/cli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"kf": "./src/kf.ts"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@kasaframe/adapters": "^0.0.0",
|
|
14
|
+
"@kasaframe/clock": "^0.0.0",
|
|
15
|
+
"esbuild": "^0.28.2",
|
|
16
|
+
"playwright": "^1.64.0",
|
|
17
|
+
"vite": "^8.3.3",
|
|
18
|
+
"@kasaframe/motion": "0.0.0",
|
|
19
|
+
"pngjs": "^7.0.0",
|
|
20
|
+
"@kasaframe/jizura": "^0.0.0",
|
|
21
|
+
"@kasaframe/director": "^0.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
25
|
+
"gsap": "^3.15.0",
|
|
26
|
+
"lottie-web": "^5.13.0",
|
|
27
|
+
"three": "^0.186.1",
|
|
28
|
+
"@types/pngjs": "^6.0.5"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { PNG } from "pngjs";
|
|
4
|
+
import type { PageInfo, Tab } from "./browser.ts";
|
|
5
|
+
|
|
6
|
+
export interface BlurOpts {
|
|
7
|
+
/** 하위 프레임 수 — 2 이상이면 켠다 */
|
|
8
|
+
count: number;
|
|
9
|
+
/** 셔터 각도(도). 180 이면 프레임 간격의 절반 동안 열려 있다 */
|
|
10
|
+
shutter: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** kf.json 의 render — 빠른 움직임이 많은 용도(쇼츠·홍보)는 틀이 모션 블러를 기본으로 켜 둔다 */
|
|
14
|
+
export function projectBlur(dir: string): { motionBlur?: number; shutter?: number } | undefined {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(readFileSync(join(dir, "kf.json"), "utf8")).render;
|
|
17
|
+
} catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 플래그가 프로젝트 기본(kf.json render)을 이긴다 — --motion-blur 0 이면 끈다 */
|
|
23
|
+
export function blurOpts(opts: Record<string, string | boolean | undefined>, base?: { motionBlur?: number; shutter?: number }): BlurOpts | null {
|
|
24
|
+
const count = Math.round(Number(opts["motion-blur"] ?? base?.motionBlur ?? 0));
|
|
25
|
+
if (!(count > 1)) return null;
|
|
26
|
+
const shutter = Number(opts.shutter ?? base?.shutter ?? 180);
|
|
27
|
+
return { count, shutter: Number.isFinite(shutter) ? Math.min(360, Math.max(1, shutter)) : 180 };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 하위 프레임은 그 프레임이 속한 장면 안에서만 — 셔터가 컷을 넘으면 두 장면이 겹쳐 찍힌다
|
|
31
|
+
function sceneSpan(info: PageInfo, t: number): [number, number] {
|
|
32
|
+
const starts = info.markers.filter((m) => m.kind === "scene").map((m) => m.t).sort((a, b) => a - b);
|
|
33
|
+
let a = 0;
|
|
34
|
+
let b = info.meta.duration;
|
|
35
|
+
for (const s of starts) {
|
|
36
|
+
if (s <= t + 1e-9) a = s;
|
|
37
|
+
else {
|
|
38
|
+
b = s;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return [a, b];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 프레임 시각 t 둘레(가운데 맞춤 셔터)의 하위 시각들 */
|
|
46
|
+
export function subTimes(info: PageInfo, t: number, o: BlurOpts): number[] {
|
|
47
|
+
const [a, b] = sceneSpan(info, t);
|
|
48
|
+
const open = o.shutter / 360 / info.meta.fps;
|
|
49
|
+
const last = b - 1 / (info.meta.fps * 1000);
|
|
50
|
+
return Array.from({ length: o.count }, (_, i) => Math.min(last, Math.max(a, t + ((i + 0.5) / o.count - 0.5) * open)));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 한 프레임을 하위 프레임 count 장으로 찍어 평균한 RGBA. 빨리 움직이는 것만 번지고 서 있는 것은 그대로다.
|
|
55
|
+
* 하위 프레임 번호를 페이지에 넘겨, 3D 전환이 같은 평균으로 피사계 심도를 얻는다. 같은 t 면 같은 그림
|
|
56
|
+
*/
|
|
57
|
+
export async function captureBlurred(tab: Tab, info: PageInfo, t: number, o: BlurOpts): Promise<{ data: Buffer; width: number; height: number }> {
|
|
58
|
+
let acc: Uint32Array | null = null;
|
|
59
|
+
let width = 0;
|
|
60
|
+
let height = 0;
|
|
61
|
+
const times = subTimes(info, t, o);
|
|
62
|
+
for (const [index, ts] of times.entries()) {
|
|
63
|
+
await tab.seek(ts, { index, count: o.count });
|
|
64
|
+
const img = PNG.sync.read(await tab.capture());
|
|
65
|
+
width = img.width;
|
|
66
|
+
height = img.height;
|
|
67
|
+
acc ??= new Uint32Array(img.data.length);
|
|
68
|
+
for (let j = 0; j < img.data.length; j++) acc[j] += img.data[j];
|
|
69
|
+
}
|
|
70
|
+
const n = times.length;
|
|
71
|
+
const data = Buffer.alloc(acc!.length);
|
|
72
|
+
for (let j = 0; j < acc!.length; j++) data[j] = Math.round(acc![j] / n);
|
|
73
|
+
return { data, width, height };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function rgbaToPng(img: { data: Buffer; width: number; height: number }): Buffer {
|
|
77
|
+
const png = new PNG({ width: img.width, height: img.height });
|
|
78
|
+
img.data.copy(png.data);
|
|
79
|
+
return PNG.sync.write(png, { deflateLevel: 1 });
|
|
80
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// window.__kf 전역 타입은 adapters 의 페이지 계약에 있다. cli 만 따로 타입 검사해도 보이게 끌어온다.
|
|
2
|
+
import type {} from "@kasaframe/adapters";
|
|
3
|
+
import { chromium, type Browser, type BrowserContext, type CDPSession, type Page } from "playwright";
|
|
4
|
+
import { clockScript, type ClockOptions } from "@kasaframe/clock";
|
|
5
|
+
import { openProject, type OpenProject } from "./serve.ts";
|
|
6
|
+
|
|
7
|
+
export interface PageMeta {
|
|
8
|
+
fps: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
duration: number;
|
|
12
|
+
music?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PageInfo {
|
|
16
|
+
meta: PageMeta;
|
|
17
|
+
mode: "seek" | "step";
|
|
18
|
+
markers: { t: number; label: string; kind: string }[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 같은 프레임을 두 번 찍어 같아야 하므로 GPU 래스터·LCD 글자 다듬기처럼 흔들리는 것을 끈다.
|
|
22
|
+
// partial raster 는 바뀐 조각만 다시 그려, 앞서 몇 번 찍었느냐에 따라 안티에일리어싱 가장자리가 갈린다(탭 이음매가 어긋남).
|
|
23
|
+
const ARGS = [
|
|
24
|
+
"--disable-partial-raster",
|
|
25
|
+
// 합성기 쓰레드가 opacity·transform 애니메이션을 따로 돌리면, 일시정지가 닿기 전 자기 진행값으로 한 번 그린다.
|
|
26
|
+
"--disable-threaded-animation",
|
|
27
|
+
"--font-render-hinting=none",
|
|
28
|
+
"--disable-lcd-text",
|
|
29
|
+
"--disable-skia-runtime-opts",
|
|
30
|
+
"--force-color-profile=srgb",
|
|
31
|
+
"--hide-scrollbars",
|
|
32
|
+
"--mute-audio",
|
|
33
|
+
"--autoplay-policy=no-user-gesture-required",
|
|
34
|
+
// HTML-in-Canvas — 3D 전환이 살아 있는 장면 DOM 을 시각마다 WebGL 텍스처로 올린다(texElementImage2D)
|
|
35
|
+
"--enable-features=CanvasDrawElement",
|
|
36
|
+
"--disable-background-timer-throttling",
|
|
37
|
+
"--disable-renderer-backgrounding",
|
|
38
|
+
"--disable-backgrounding-occluded-windows",
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export async function launch(): Promise<Browser> {
|
|
42
|
+
try {
|
|
43
|
+
return await chromium.launch({ headless: true, args: ARGS });
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if (!String(err).includes("Executable doesn't exist")) throw err;
|
|
46
|
+
return chromium.launch({ headless: true, channel: "chrome", args: ARGS });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class Tab {
|
|
51
|
+
readonly page: Page;
|
|
52
|
+
private cdp: CDPSession;
|
|
53
|
+
info!: PageInfo;
|
|
54
|
+
|
|
55
|
+
private constructor(page: Page, cdp: CDPSession) {
|
|
56
|
+
this.page = page;
|
|
57
|
+
this.cdp = cdp;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static async open(context: BrowserContext, url: string): Promise<Tab> {
|
|
61
|
+
const page = await context.newPage();
|
|
62
|
+
const errors: string[] = [];
|
|
63
|
+
page.on("pageerror", (e) => errors.push(e.message));
|
|
64
|
+
page.on("console", (m) => {
|
|
65
|
+
if (m.type() === "error") errors.push(m.text());
|
|
66
|
+
});
|
|
67
|
+
const tab = new Tab(page, await context.newCDPSession(page));
|
|
68
|
+
await page.goto(url, { waitUntil: "load" });
|
|
69
|
+
try {
|
|
70
|
+
await page.waitForFunction(() => typeof window.__kf?.seek === "function", null, { timeout: 15000 });
|
|
71
|
+
} catch {
|
|
72
|
+
throw new Error(`페이지가 window.__kf 를 걸지 않았다 (${url})${errors.length ? `\n 페이지 오류: ${errors.join("\n ")}` : ""}`);
|
|
73
|
+
}
|
|
74
|
+
await page.evaluate(() => window.__kf!.ready!());
|
|
75
|
+
tab.info = await page.evaluate(() => {
|
|
76
|
+
const k = window.__kf!;
|
|
77
|
+
return {
|
|
78
|
+
meta: { ...k.meta! },
|
|
79
|
+
mode: k.mode ?? "seek",
|
|
80
|
+
markers: (k.markers ?? []).map((m) => ({ t: m.t, label: m.label, kind: m.kind })),
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
const { width, height } = tab.info.meta;
|
|
84
|
+
const vp = page.viewportSize();
|
|
85
|
+
if (!vp || vp.width !== width || vp.height !== height) await page.setViewportSize({ width, height });
|
|
86
|
+
return tab;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async seek(t: number, sample?: { index: number; count: number }): Promise<void> {
|
|
90
|
+
await this.page.evaluate(([t, s]) => window.__kf!.seek!(t, s ?? undefined), [t, sample ?? null] as const);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Playwright screenshot 보다 빠르다. optimizeForSpeed 는 PNG 압축만 줄이고 픽셀은 같다.
|
|
94
|
+
private async shot(): Promise<Buffer> {
|
|
95
|
+
const { data } = await this.cdp.send("Page.captureScreenshot", {
|
|
96
|
+
format: "png",
|
|
97
|
+
optimizeForSpeed: true,
|
|
98
|
+
captureBeyondViewport: false,
|
|
99
|
+
});
|
|
100
|
+
return Buffer.from(data, "base64");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 이번 seek 에서 <video> 를 옮겼으면 합성기가 새 프레임을 받을 때까지 두 번 연속 같은 그림이 나오게 다시 찍는다.
|
|
104
|
+
async capture(): Promise<Buffer> {
|
|
105
|
+
let png = await this.shot();
|
|
106
|
+
const moved = await this.page.evaluate(() => {
|
|
107
|
+
const m = !!window.__kfMediaMoved;
|
|
108
|
+
window.__kfMediaMoved = false;
|
|
109
|
+
return m;
|
|
110
|
+
});
|
|
111
|
+
if (!moved) return png;
|
|
112
|
+
for (let i = 0; i < 8; i++) {
|
|
113
|
+
await this.page.evaluate(
|
|
114
|
+
() => new Promise<void>((r) => (window.__kfClock?.real.requestAnimationFrame ?? requestAnimationFrame)(() => r())),
|
|
115
|
+
);
|
|
116
|
+
const again = await this.shot();
|
|
117
|
+
if (again.equals(png)) return png;
|
|
118
|
+
png = again;
|
|
119
|
+
}
|
|
120
|
+
return png;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async close(): Promise<void> {
|
|
124
|
+
await this.page.close().catch(() => {});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface Session {
|
|
129
|
+
project: OpenProject;
|
|
130
|
+
browser: Browser;
|
|
131
|
+
context: BrowserContext;
|
|
132
|
+
first: Tab;
|
|
133
|
+
info: PageInfo;
|
|
134
|
+
tab(): Promise<Tab>;
|
|
135
|
+
close(): Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface SessionOptions {
|
|
139
|
+
clock?: boolean | ClockOptions;
|
|
140
|
+
width?: number;
|
|
141
|
+
height?: number;
|
|
142
|
+
// 페이지 주소 뒤에 붙일 질의 — captions=on 처럼 kf.json 을 그 판만 덮는 값
|
|
143
|
+
query?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 프로젝트를 띄우고 탭 하나를 준비한다. 렌더는 tab() 으로 더 연다.
|
|
147
|
+
export async function openSession(dir: string, o: SessionOptions = {}): Promise<Session> {
|
|
148
|
+
const project = await openProject(dir);
|
|
149
|
+
const browser = await launch();
|
|
150
|
+
try {
|
|
151
|
+
const context = await browser.newContext({
|
|
152
|
+
viewport: { width: o.width ?? 1920, height: o.height ?? 1080 },
|
|
153
|
+
deviceScaleFactor: 1,
|
|
154
|
+
});
|
|
155
|
+
if (o.clock !== false) {
|
|
156
|
+
await context.addInitScript({ content: await clockScript(o.clock === true || !o.clock ? {} : o.clock) });
|
|
157
|
+
}
|
|
158
|
+
const url = o.query ? `${project.url}${project.url.includes("?") ? "&" : "?"}${o.query.replace(/^\?/, "")}` : project.url;
|
|
159
|
+
const first = await Tab.open(context, url);
|
|
160
|
+
return {
|
|
161
|
+
project,
|
|
162
|
+
browser,
|
|
163
|
+
context,
|
|
164
|
+
first,
|
|
165
|
+
info: first.info,
|
|
166
|
+
tab: () => Tab.open(context, url),
|
|
167
|
+
async close() {
|
|
168
|
+
await browser.close().catch(() => {});
|
|
169
|
+
await project.close();
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
} catch (err) {
|
|
173
|
+
await browser.close().catch(() => {});
|
|
174
|
+
await project.close();
|
|
175
|
+
throw err;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface OpenPage {
|
|
180
|
+
page: Page;
|
|
181
|
+
meta: PageMeta;
|
|
182
|
+
mode: "seek" | "step";
|
|
183
|
+
markers: PageInfo["markers"];
|
|
184
|
+
url: string;
|
|
185
|
+
seek(t: number): Promise<void>;
|
|
186
|
+
capture(): Promise<Buffer>;
|
|
187
|
+
close(): Promise<void>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 검사·생성처럼 엔진 밖에서 렌더와 같은 길로 페이지를 열 때.
|
|
191
|
+
export async function openPage(dir: string, o: SessionOptions = {}): Promise<OpenPage> {
|
|
192
|
+
const s = await openSession(dir, o);
|
|
193
|
+
return {
|
|
194
|
+
page: s.first.page,
|
|
195
|
+
meta: s.info.meta,
|
|
196
|
+
mode: s.info.mode,
|
|
197
|
+
markers: s.info.markers,
|
|
198
|
+
url: s.project.url,
|
|
199
|
+
seek: (t) => s.first.seek(t),
|
|
200
|
+
capture: () => s.first.capture(),
|
|
201
|
+
close: () => s.close(),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// 명령 파일 하나 = commands/<이름>.ts 의 default export.
|
|
2
|
+
export interface Command {
|
|
3
|
+
summary: string;
|
|
4
|
+
usage?: string;
|
|
5
|
+
// 반환값이 종료 코드. 없으면 0.
|
|
6
|
+
run(argv: string[]): Promise<number | void>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Flags {
|
|
10
|
+
args: string[];
|
|
11
|
+
opts: Record<string, string | boolean | undefined>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// --key value · --key=value · --flag(값 없으면 true). 짧은 옵션은 쓰지 않는다.
|
|
15
|
+
export function parseFlags(argv: string[]): Flags {
|
|
16
|
+
const out: Flags = { args: [], opts: {} };
|
|
17
|
+
for (let i = 0; i < argv.length; i++) {
|
|
18
|
+
const a = argv[i];
|
|
19
|
+
if (!a.startsWith("--")) {
|
|
20
|
+
out.args.push(a);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const eq = a.indexOf("=");
|
|
24
|
+
if (eq > 0) {
|
|
25
|
+
out.opts[a.slice(2, eq)] = a.slice(eq + 1);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const next = argv[i + 1];
|
|
29
|
+
if (next !== undefined && !next.startsWith("--")) {
|
|
30
|
+
out.opts[a.slice(2)] = next;
|
|
31
|
+
i++;
|
|
32
|
+
} else {
|
|
33
|
+
out.opts[a.slice(2)] = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function num(v: string | boolean | undefined, fallback: number): number {
|
|
40
|
+
if (typeof v !== "string") return fallback;
|
|
41
|
+
const n = Number(v);
|
|
42
|
+
if (!Number.isFinite(n)) throw new Error(`숫자가 아니다: ${v}`);
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { type Command, parseFlags } from "../command.ts";
|
|
4
|
+
import { installed } from "../serve.ts";
|
|
5
|
+
|
|
6
|
+
const cmd: Command = {
|
|
7
|
+
summary: "작업실 — 요청 칸·실시간 미리보기·렌더·검사 보고를 브라우저 화면으로",
|
|
8
|
+
usage: `kf app [--port 5150] [--host 127.0.0.1] [--dir 일 폴더]
|
|
9
|
+
--host 0.0.0.0 이면 같은 망의 폰에서도 연다. 일 폴더 기본은 레포 out/app, 설치된 패키지는 ~/.kasaframe/app
|
|
10
|
+
곡 모음은 KF_MUSIC_DIR. 말로 시작한 kf make 도 작업실이 떠 있으면 스스로 붙는다(KF_APP_URL)`,
|
|
11
|
+
async run(argv) {
|
|
12
|
+
const { opts } = parseFlags(argv);
|
|
13
|
+
const set = (flag: string, env: string) => {
|
|
14
|
+
if (typeof opts[flag] === "string") process.env[env] = opts[flag] as string;
|
|
15
|
+
};
|
|
16
|
+
set("port", "KF_APP_PORT");
|
|
17
|
+
set("host", "KF_APP_HOST");
|
|
18
|
+
set("dir", "KF_APP_DIR");
|
|
19
|
+
if (installed) process.env.KF_APP_DIR ??= join(homedir(), ".kasaframe", "app");
|
|
20
|
+
await import("../../../../app/server/main.ts");
|
|
21
|
+
// 서버가 멈출 때까지 돌려 둔다 — 끝내기는 main.ts 의 SIGINT 처리가 맡는다
|
|
22
|
+
return new Promise<never>(() => {});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export default cmd;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { type Command, parseFlags } from "../command.ts";
|
|
5
|
+
import { python as pythonBin, requirements } from "../deps.ts";
|
|
6
|
+
|
|
7
|
+
const script = fileURLToPath(new URL("../../../../tools/beats/beats.py", import.meta.url));
|
|
8
|
+
|
|
9
|
+
const cmd: Command = {
|
|
10
|
+
summary: "곡을 재서 beats.json — 박·마디·프레이즈·구간·드롭·대역 에너지",
|
|
11
|
+
usage: `kf beats <곡> [--out beats.json] [--from 초] [--duration 초] [--hz 20] [--bpm 힌트]
|
|
12
|
+
|
|
13
|
+
--from·--duration 곡의 일부만 쓸 때. 모든 시각은 --from 을 0 으로 센다
|
|
14
|
+
--bpm 반박·두 배 박으로 잡힐 때만 박 추적 시작값으로 준다(시각을 곱해 만들지 않는다)
|
|
15
|
+
요약은 stderr 로 나온다. python3 + librosa 가 필요하다 — kf setup beats 가 ~/.cache/kasaframe/py/beats 에 깐다(KF_PYTHON 으로 바꿀 수 있다).`,
|
|
16
|
+
async run(argv) {
|
|
17
|
+
const { args } = parseFlags(argv);
|
|
18
|
+
if (args.length === 0) {
|
|
19
|
+
console.error("kf beats: 곡 경로가 필요하다. kf beats --help");
|
|
20
|
+
return 2;
|
|
21
|
+
}
|
|
22
|
+
if (!existsSync(args[0])) {
|
|
23
|
+
console.error(`kf beats: 곡이 없다: ${args[0]}`);
|
|
24
|
+
return 2;
|
|
25
|
+
}
|
|
26
|
+
const python = pythonBin();
|
|
27
|
+
const probe = spawnSync(python, ["-c", "import librosa"], { stdio: "ignore" });
|
|
28
|
+
if (probe.status !== 0) {
|
|
29
|
+
console.error(`kf beats: ${python} 에 librosa 가 없다 — kf setup beats (또는 ${python} -m pip install -r ${requirements})`);
|
|
30
|
+
return 1;
|
|
31
|
+
}
|
|
32
|
+
const r = spawnSync(python, [script, ...argv], { stdio: "inherit" });
|
|
33
|
+
return r.status ?? 1;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
export default cmd;
|