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,326 @@
|
|
|
1
|
+
import type { Box, Finding, FrameText, SafeArea, TextHit } from "../types.ts";
|
|
2
|
+
import { runs } from "./runs.ts";
|
|
3
|
+
|
|
4
|
+
export interface Line {
|
|
5
|
+
text: string;
|
|
6
|
+
box?: Box;
|
|
7
|
+
sizePx: number;
|
|
8
|
+
alpha: number;
|
|
9
|
+
hits: TextHit[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 터미널 셀 렌더러처럼 글자를 한 자씩 그리는 화면이 많다. 같은 줄에 놓인 조각을 x 순서로 이어 붙여야
|
|
13
|
+
// 「u」「n」「d」… 로 흩어진 undefined 가 한 낱말로 보인다.
|
|
14
|
+
export function assembleLines(hits: TextHit[]): Line[] {
|
|
15
|
+
const placed = hits.filter((h) => h.box && h.alpha > 0.05);
|
|
16
|
+
const lines: Line[] = hits.filter((h) => !h.box).map((h) => ({ text: h.text, sizePx: h.sizePx, alpha: h.alpha, hits: [h] }));
|
|
17
|
+
// 가운데 높이로 묶으면 g·y 처럼 아래로 내려가는 글자가 딴 줄로 빠진다. 세로로 겹치는 정도로 묶는다.
|
|
18
|
+
const rows: { y0: number; y1: number; hits: TextHit[] }[] = [];
|
|
19
|
+
const size = (h: TextHit) => Math.max(h.sizePx, 1);
|
|
20
|
+
for (const h of [...placed].sort((a, b) => a.box!.y0 - b.box!.y0)) {
|
|
21
|
+
const b = h.box!;
|
|
22
|
+
const row = rows.find((r) => {
|
|
23
|
+
const ref = r.hits[0];
|
|
24
|
+
const overlap = Math.min(r.y1, b.y1) - Math.max(r.y0, b.y0);
|
|
25
|
+
return h.via === ref.via && !!h.lyrics === !!ref.lyrics && overlap >= 0.5 * Math.min(r.y1 - r.y0, b.y1 - b.y0) && Math.max(size(h), size(ref)) / Math.min(size(h), size(ref)) < 1.35;
|
|
26
|
+
});
|
|
27
|
+
if (row) {
|
|
28
|
+
row.hits.push(h);
|
|
29
|
+
row.y0 = Math.min(row.y0, b.y0);
|
|
30
|
+
row.y1 = Math.max(row.y1, b.y1);
|
|
31
|
+
} else rows.push({ y0: b.y0, y1: b.y1, hits: [h] });
|
|
32
|
+
}
|
|
33
|
+
for (const { hits: row } of rows) {
|
|
34
|
+
row.sort((a, b) => a.box!.x0 - b.box!.x0);
|
|
35
|
+
let cur: TextHit[] = [row[0]];
|
|
36
|
+
let text = row[0].text;
|
|
37
|
+
const flush = () => {
|
|
38
|
+
const b = cur.map((h) => h.box!);
|
|
39
|
+
lines.push({
|
|
40
|
+
text,
|
|
41
|
+
box: { x0: Math.min(...b.map((x) => x.x0)), y0: Math.min(...b.map((x) => x.y0)), x1: Math.max(...b.map((x) => x.x1)), y1: Math.max(...b.map((x) => x.y1)) },
|
|
42
|
+
sizePx: Math.max(...cur.map(size)),
|
|
43
|
+
alpha: Math.max(...cur.map((h) => h.alpha)),
|
|
44
|
+
hits: cur,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
for (let i = 1; i < row.length; i++) {
|
|
48
|
+
const prev = cur[cur.length - 1];
|
|
49
|
+
const h = row[i];
|
|
50
|
+
const gap = h.box!.x0 - prev.box!.x1;
|
|
51
|
+
// 다른 덩어리(옆 pane·다른 칸)면 끊는다. 한 칸쯤 벌어졌으면 띄어쓰기로 본다.
|
|
52
|
+
if (gap > 2.2 * size(prev)) {
|
|
53
|
+
flush();
|
|
54
|
+
cur = [h];
|
|
55
|
+
text = h.text;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
text += gap > 0.45 * size(prev) ? " " + h.text : h.text;
|
|
59
|
+
cur.push(h);
|
|
60
|
+
}
|
|
61
|
+
flush();
|
|
62
|
+
}
|
|
63
|
+
return lines;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const TOKENS: { name: string; re: RegExp }[] = [
|
|
67
|
+
{ name: "undefined", re: /undefined/ },
|
|
68
|
+
{ name: "NaN", re: /(^|[^A-Za-z])NaN([^A-Za-z]|$)/ },
|
|
69
|
+
{ name: "[object Object]", re: /\[object [A-Za-z]+\]/ },
|
|
70
|
+
// 터미널 화면의 2>/dev/null 같은 경로는 빼고
|
|
71
|
+
{ name: "null", re: /(^|[^A-Za-z/._-])null([^A-Za-z/._-]|$)/ },
|
|
72
|
+
{ name: "Infinity", re: /(^|[^A-Za-z])-?Infinity([^A-Za-z]|$)/ },
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
export interface TextRuleOptions {
|
|
76
|
+
// 코드 화면처럼 일부러 null 을 보이는 영상이면 여기 넣는다(kf.json check.allowText)
|
|
77
|
+
allow?: string[];
|
|
78
|
+
fps: number;
|
|
79
|
+
// OCR 로 읽은 글은 겹친 글자가 뭉개져 「DuHdefined」처럼 나온다. 긴 낱말은 두 글자까지 틀려도 잡는다.
|
|
80
|
+
fuzzy?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function editDistance(a: string, b: string): number {
|
|
84
|
+
const d = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
85
|
+
for (let i = 1; i <= a.length; i++) {
|
|
86
|
+
let prev = d[0];
|
|
87
|
+
d[0] = i;
|
|
88
|
+
for (let j = 1; j <= b.length; j++) {
|
|
89
|
+
const cur = d[j];
|
|
90
|
+
d[j] = Math.min(d[j] + 1, d[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
91
|
+
prev = cur;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return d[b.length];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function fuzzyHas(text: string, word: string, maxDist: number): boolean {
|
|
98
|
+
const s = text.toLowerCase().replace(/\s+/g, "");
|
|
99
|
+
const w = word.toLowerCase();
|
|
100
|
+
for (let len = w.length - 1; len <= w.length + 1; len++) {
|
|
101
|
+
for (let i = 0; i + len <= s.length; i++) if (editDistance(s.slice(i, i + len), w) <= maxDist) return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const FUZZY: { name: string; word: string; dist: number }[] = [
|
|
107
|
+
{ name: "undefined", word: "undefined", dist: 2 },
|
|
108
|
+
{ name: "[object Object]", word: "objectobject", dist: 2 },
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
export function badText(frames: FrameText[], o: TextRuleOptions): Finding[] {
|
|
112
|
+
const allow = new Set(o.allow ?? []);
|
|
113
|
+
const hitsAt = new Map<string, { t: number; line: string; where?: string; argType?: string }[]>();
|
|
114
|
+
for (const f of frames) {
|
|
115
|
+
const found = new Map<string, { line: string; where?: string; argType?: string }>();
|
|
116
|
+
for (const h of f.hits) {
|
|
117
|
+
if (h.argType && h.argType !== "number") {
|
|
118
|
+
const key = `argType:${h.argType}`;
|
|
119
|
+
if (!found.has(key)) found.set(key, { line: h.text, where: h.where, argType: h.argType });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for (const line of assembleLines(f.hits)) {
|
|
123
|
+
const names = TOKENS.filter((tok) => tok.re.test(line.text)).map((tok) => tok.name);
|
|
124
|
+
if (o.fuzzy) for (const z of FUZZY) if (!names.includes(z.name) && fuzzyHas(line.text, z.word, z.dist)) names.push(z.name);
|
|
125
|
+
for (const name of names) {
|
|
126
|
+
const key = `token:${name}`;
|
|
127
|
+
if (allow.has(name) || found.has(key)) continue;
|
|
128
|
+
found.set(key, { line: line.text.slice(0, 120), where: line.hits.find((h) => h.where)?.where });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const [key, v] of found) {
|
|
132
|
+
if (!hitsAt.has(key)) hitsAt.set(key, []);
|
|
133
|
+
hitsAt.get(key)!.push({ t: f.t, ...v });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const out: Finding[] = [];
|
|
137
|
+
for (const [key, list] of hitsAt) {
|
|
138
|
+
for (const r of runs(list.map((x) => x.t), 1.5 / o.fps)) {
|
|
139
|
+
const first = list.find((x) => x.t >= r.from)!;
|
|
140
|
+
const [kind, name] = key.split(":");
|
|
141
|
+
out.push({
|
|
142
|
+
rule: "text.bad",
|
|
143
|
+
severity: "error",
|
|
144
|
+
from: r.from,
|
|
145
|
+
to: r.to + 1 / o.fps,
|
|
146
|
+
message:
|
|
147
|
+
kind === "argType"
|
|
148
|
+
? `화면 글에 문자열이 아닌 값(${name})이 들어갔다 — "${first.line}"`
|
|
149
|
+
: `화면 글에 「${name}」 — "${first.line}"`,
|
|
150
|
+
detail: { line: first.line, where: first.where, frames: r.count },
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function primaryFamily(font: string): string {
|
|
158
|
+
const m = /\d(?:\.\d+)?px(?:\/\S+)?\s+("[^"]+"|'[^']+'|[^,]+)/.exec(font);
|
|
159
|
+
return (m?.[1] ?? font).trim().replace(/^["']|["']$/g, "");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 글꼴 크기·굵기만 다른 것은 한 줄로 묶는다 — 고칠 곳은 글꼴 이름 하나다.
|
|
163
|
+
export function glyphProblems(frames: FrameText[], glyphs: Record<string, string>, fps: number): Finding[] {
|
|
164
|
+
const groups = new Map<string, { status: string; family: string; chars: Set<string>; times: number[] }>();
|
|
165
|
+
for (const f of frames) {
|
|
166
|
+
for (const h of f.hits) {
|
|
167
|
+
for (const ch of new Set(h.text)) {
|
|
168
|
+
const st = glyphs[h.font + "\u0000" + ch];
|
|
169
|
+
if (!st || st === "ok" || st === "stack") continue;
|
|
170
|
+
const status = st === "blank" ? "tofu" : st;
|
|
171
|
+
const family = primaryFamily(h.font);
|
|
172
|
+
const key = `${status}\u0000${family}`;
|
|
173
|
+
let g = groups.get(key);
|
|
174
|
+
if (!g) groups.set(key, (g = { status, family, chars: new Set(), times: [] }));
|
|
175
|
+
g.chars.add(ch);
|
|
176
|
+
if (g.times[g.times.length - 1] !== f.t) g.times.push(f.t);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const out: Finding[] = [];
|
|
181
|
+
for (const g of groups.values()) {
|
|
182
|
+
const chars = [...g.chars];
|
|
183
|
+
const shown = chars.slice(0, 24).join("");
|
|
184
|
+
const span = runs(g.times, 1.5 / fps);
|
|
185
|
+
const from = span[0]?.from ?? 0;
|
|
186
|
+
const to = (span[span.length - 1]?.to ?? 0) + 1 / fps;
|
|
187
|
+
if (g.status === "tofu") {
|
|
188
|
+
out.push({
|
|
189
|
+
rule: "text.tofu",
|
|
190
|
+
severity: "error",
|
|
191
|
+
from,
|
|
192
|
+
to,
|
|
193
|
+
// 두부 글자는 화면에 찍어도 안 보이니 코드 포인트로 알린다.
|
|
194
|
+
message: `어떤 글꼴에도 없는 글자가 두부(빈 네모)로 나온다 — 글꼴 ${g.family} · ${chars
|
|
195
|
+
.slice(0, 12)
|
|
196
|
+
.map((c) => `U+${c.codePointAt(0)!.toString(16).toUpperCase().padStart(4, "0")}`)
|
|
197
|
+
.join(" ")}`,
|
|
198
|
+
detail: { family: g.family, chars },
|
|
199
|
+
});
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const latin = g.status === "missing-font";
|
|
203
|
+
const hangul = chars.some((c) => /[\u3131-\u318E\uAC00-\uD7A3]/.test(c));
|
|
204
|
+
out.push({
|
|
205
|
+
rule: "text.fallback",
|
|
206
|
+
severity: "warn",
|
|
207
|
+
from,
|
|
208
|
+
to,
|
|
209
|
+
message: latin
|
|
210
|
+
? `글꼴 「${g.family}」이 안 불러와져 다른 글꼴로 그렸다 — 이름이 틀렸거나 @font-face·글꼴 파일이 없다 (글자 ${chars.length}개)`
|
|
211
|
+
: `글꼴 「${g.family}」에 없는 글자를 다른 글꼴이 대신 그린다${hangul ? " — 한글이 서는 글꼴을 쓴다" : ""} · 「${shown}」`,
|
|
212
|
+
detail: { family: g.family, chars, notLoaded: latin },
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return out;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface OffscreenOptions {
|
|
219
|
+
width: number;
|
|
220
|
+
height: number;
|
|
221
|
+
fps: number;
|
|
222
|
+
safe?: SafeArea;
|
|
223
|
+
minSec?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// 들어오고 나가는 글은 잠깐 걸쳐도 된다. 같은 글이 minSec 넘게 걸쳐 있으면 잘린 채 머무는 것.
|
|
227
|
+
export function offscreenText(frames: FrameText[], o: OffscreenOptions): Finding[] {
|
|
228
|
+
const minSec = o.minSec ?? 0.5;
|
|
229
|
+
const pad = 2;
|
|
230
|
+
const safe = o.safe && (o.safe.top || o.safe.bottom || o.safe.left || o.safe.right) ? o.safe : null;
|
|
231
|
+
const seen = new Map<string, { kind: "clip" | "safe"; times: number[]; text: string; box: Box; lyrics: boolean }>();
|
|
232
|
+
for (const f of frames) {
|
|
233
|
+
for (const line of assembleLines(f.hits)) {
|
|
234
|
+
const b = line.box;
|
|
235
|
+
if (!b || line.alpha < 0.3) continue;
|
|
236
|
+
const fullyOut = b.x1 <= 0 || b.y1 <= 0 || b.x0 >= o.width || b.y0 >= o.height;
|
|
237
|
+
if (fullyOut) continue;
|
|
238
|
+
const clipped = b.x0 < -pad || b.y0 < -pad || b.x1 > o.width + pad || b.y1 > o.height + pad;
|
|
239
|
+
const unsafe =
|
|
240
|
+
!clipped &&
|
|
241
|
+
safe !== null &&
|
|
242
|
+
(b.x0 < safe.left - pad || b.y0 < safe.top - pad || b.x1 > o.width - safe.right + pad || b.y1 > o.height - safe.bottom + pad);
|
|
243
|
+
if (!clipped && !unsafe) continue;
|
|
244
|
+
const kind = clipped ? "clip" : "safe";
|
|
245
|
+
const lyrics = line.hits.every((h) => h.lyrics);
|
|
246
|
+
const key = `${kind}\u0000${lyrics ? "lyrics" : ""}\u0000${line.text}`;
|
|
247
|
+
let s = seen.get(key);
|
|
248
|
+
if (!s) seen.set(key, (s = { kind, times: [], text: line.text, box: b, lyrics }));
|
|
249
|
+
s.times.push(f.t);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const out: Finding[] = [];
|
|
253
|
+
for (const s of seen.values()) {
|
|
254
|
+
for (const r of runs(s.times, 1.5 / o.fps)) {
|
|
255
|
+
if (r.to - r.from + 1 / o.fps < minSec) continue;
|
|
256
|
+
// 가사 층의 마퀴 띠·배경 큰 글자는 일부러 화면 끝을 넘긴다 — 잘림은 경고로만(글 내용·두부·대비 판정은 그대로)
|
|
257
|
+
out.push({
|
|
258
|
+
rule: s.kind === "clip" ? "text.offscreen" : "text.safe-area",
|
|
259
|
+
severity: s.kind === "clip" && !s.lyrics ? "error" : "warn",
|
|
260
|
+
from: r.from,
|
|
261
|
+
to: r.to + 1 / o.fps,
|
|
262
|
+
message:
|
|
263
|
+
s.kind === "clip"
|
|
264
|
+
? `${s.lyrics ? "가사 층 글" : "글"}이 화면 밖으로 잘린 채 ${(r.to - r.from).toFixed(1)}초 머문다 — "${s.text.slice(0, 60)}"${s.lyrics ? " — 띠·배경 장식이면 둬도 된다. 읽혀야 할 가사 줄이면 화면 안으로" : ""}`
|
|
265
|
+
: `글이 안전 영역(플랫폼 UI 가 가리는 자리)에 걸친다 — "${s.text.slice(0, 60)}"`,
|
|
266
|
+
detail: { text: s.text.slice(0, 120), box: roundBox(s.box) },
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function roundBox(b: Box): Box {
|
|
274
|
+
return { x0: Math.round(b.x0), y0: Math.round(b.y0), x1: Math.round(b.x1), y1: Math.round(b.y1) };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface TextPolicy {
|
|
278
|
+
minPx?: number;
|
|
279
|
+
maxOnScreen?: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// 틀(template.json text)이 정한 글 규칙. 한 화면에 글 덩어리가 너무 많거나 작으면 영상에서 안 읽힌다.
|
|
283
|
+
export function textPolicy(frames: FrameText[], policy: TextPolicy, o: { fps: number; minSec?: number }): Finding[] {
|
|
284
|
+
const minSec = o.minSec ?? 1;
|
|
285
|
+
const small = new Map<string, number[]>();
|
|
286
|
+
const crowded: number[] = [];
|
|
287
|
+
let crowdMax = 0;
|
|
288
|
+
for (const f of frames) {
|
|
289
|
+
const lines = assembleLines(f.hits).filter((l) => l.box && l.alpha > 0.5 && /[\p{L}\p{N}]/u.test(l.text));
|
|
290
|
+
// 자막 판은 틀의 화면 글 수(장면이 쓰는 글)와 따로 센다 — 자막을 켰다고 장면 글이 많아진 게 아니다
|
|
291
|
+
const scene = lines.filter((l) => l.hits[0]?.via !== "caption").length;
|
|
292
|
+
if (policy.maxOnScreen && scene > policy.maxOnScreen) {
|
|
293
|
+
crowded.push(f.t);
|
|
294
|
+
crowdMax = Math.max(crowdMax, scene);
|
|
295
|
+
}
|
|
296
|
+
if (policy.minPx) for (const l of lines) if (l.sizePx < policy.minPx * 0.95) (small.get(l.text) ?? small.set(l.text, []).get(l.text)!).push(f.t);
|
|
297
|
+
}
|
|
298
|
+
const out: Finding[] = [];
|
|
299
|
+
for (const r of runs(crowded, 1.5 / o.fps)) {
|
|
300
|
+
if (r.to - r.from < minSec) continue;
|
|
301
|
+
out.push({
|
|
302
|
+
rule: "text.crowded",
|
|
303
|
+
severity: "warn",
|
|
304
|
+
from: r.from,
|
|
305
|
+
to: r.to + 1 / o.fps,
|
|
306
|
+
message: `한 화면에 글 덩어리가 최대 ${crowdMax}개 — 틀은 ${policy.maxOnScreen}개까지 (터미널·코드 화면이면 그대로 둬도 된다)`,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const smallRuns: { from: number; to: number; text: string }[] = [];
|
|
310
|
+
for (const [text, times] of small) for (const r of runs(times, 1.5 / o.fps)) if (r.to - r.from >= minSec) smallRuns.push({ from: r.from, to: r.to + 1 / o.fps, text });
|
|
311
|
+
if (smallRuns.length) {
|
|
312
|
+
smallRuns.sort((a, b) => a.from - b.from);
|
|
313
|
+
out.push({
|
|
314
|
+
rule: "text.small",
|
|
315
|
+
severity: "warn",
|
|
316
|
+
from: smallRuns[0].from,
|
|
317
|
+
to: Math.max(...smallRuns.map((x) => x.to)),
|
|
318
|
+
message: `틀의 최소 글 크기 ${policy.minPx}px 보다 작은 글 ${smallRuns.length}개 — 예: ${smallRuns
|
|
319
|
+
.slice(0, 4)
|
|
320
|
+
.map((x) => `"${x.text.trim().slice(0, 30)}"`)
|
|
321
|
+
.join(" · ")}`,
|
|
322
|
+
detail: { texts: smallRuns.slice(0, 50).map((x) => ({ text: x.text.slice(0, 60), from: x.from, to: x.to })) },
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { Browser, CDPSession, Page } from "playwright";
|
|
2
|
+
import { launch } from "@kasaframe/cli";
|
|
3
|
+
import { probe, legacyShim } from "./probe.ts";
|
|
4
|
+
import { colorThumb, decodePng, inkContrast, luma, meanAbsDiff, type Rgba, type Thumb } from "./image.ts";
|
|
5
|
+
import type { FrameText, Marker, MotionEvent, TextHit } from "./types.ts";
|
|
6
|
+
import type { CamSample } from "./rules/camera.ts";
|
|
7
|
+
|
|
8
|
+
export interface ScanOptions {
|
|
9
|
+
url: string;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
// 옛 페이지처럼 meta 를 안 주는 곳에서만 쓴다
|
|
13
|
+
fps?: number;
|
|
14
|
+
duration?: number;
|
|
15
|
+
from?: number;
|
|
16
|
+
to?: number;
|
|
17
|
+
tabs: number;
|
|
18
|
+
thumbFps: number;
|
|
19
|
+
shotFps: number;
|
|
20
|
+
clock?: string;
|
|
21
|
+
log?: (s: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ContrastSample {
|
|
25
|
+
t: number;
|
|
26
|
+
text: string;
|
|
27
|
+
ratio: number;
|
|
28
|
+
sizePx: number;
|
|
29
|
+
box: { x0: number; y0: number; x1: number; y1: number };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RepeatSample {
|
|
33
|
+
t: number;
|
|
34
|
+
diff: number;
|
|
35
|
+
textSame: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ScanResult {
|
|
39
|
+
meta: { fps: number; width: number; height: number; duration: number };
|
|
40
|
+
mode: "seek" | "step";
|
|
41
|
+
legacy: boolean;
|
|
42
|
+
markers: Marker[];
|
|
43
|
+
events: MotionEvent[];
|
|
44
|
+
texts: FrameText[];
|
|
45
|
+
thumbs: Thumb[];
|
|
46
|
+
thumbFps: number;
|
|
47
|
+
contrast: ContrastSample[];
|
|
48
|
+
errors: { t: number; text: string }[];
|
|
49
|
+
repeat: RepeatSample[];
|
|
50
|
+
glyphs: Record<string, string>;
|
|
51
|
+
// 썸네일 시각마다 카메라 층 transform·주인공 상자
|
|
52
|
+
cams: CamSample[];
|
|
53
|
+
frames: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface Opened {
|
|
57
|
+
page: Page;
|
|
58
|
+
cdp: CDPSession;
|
|
59
|
+
meta: ScanResult["meta"];
|
|
60
|
+
mode: "seek" | "step";
|
|
61
|
+
legacy: boolean;
|
|
62
|
+
markers: Marker[];
|
|
63
|
+
errors: { t: number; text: string }[];
|
|
64
|
+
cur: { t: number };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const THUMB_W = 160;
|
|
68
|
+
|
|
69
|
+
async function open(browser: Browser, o: ScanOptions): Promise<Opened> {
|
|
70
|
+
const page = await browser.newPage({ viewport: { width: o.width, height: o.height }, deviceScaleFactor: 1 });
|
|
71
|
+
const cur = { t: -1 };
|
|
72
|
+
const errors: Opened["errors"] = [];
|
|
73
|
+
page.on("pageerror", (e) => errors.push({ t: cur.t, text: `pageerror: ${e.message}` }));
|
|
74
|
+
page.on("console", (m) => {
|
|
75
|
+
if (m.type() === "error") errors.push({ t: cur.t, text: m.text() });
|
|
76
|
+
});
|
|
77
|
+
await page.addInitScript(probe);
|
|
78
|
+
if (o.clock) await page.addInitScript({ content: o.clock });
|
|
79
|
+
await page.goto(o.url, { waitUntil: "load" });
|
|
80
|
+
// main.ts 가 모듈 스크립트라 load 뒤에도 __kf 가 늦게 설 수 있다.
|
|
81
|
+
let kind = "none";
|
|
82
|
+
for (let i = 0; i < 150 && kind === "none"; i++) {
|
|
83
|
+
kind = await page.evaluate(legacyShim, { fps: o.fps ?? 60, duration: o.duration ?? 0 });
|
|
84
|
+
if (kind === "none") await page.waitForTimeout(100);
|
|
85
|
+
}
|
|
86
|
+
if (kind === "none") throw new Error(`페이지에 window.__kf 도 window.seek(t) 도 없다: ${o.url}`);
|
|
87
|
+
await page.evaluate(() => (window as any).__kf.ready());
|
|
88
|
+
const info = await page.evaluate(() => {
|
|
89
|
+
const k = (window as any).__kf;
|
|
90
|
+
return { meta: k.meta, mode: k.mode, markers: k.markers ?? [] };
|
|
91
|
+
});
|
|
92
|
+
const meta = { ...info.meta };
|
|
93
|
+
if (o.fps) meta.fps = o.fps;
|
|
94
|
+
if (o.duration) meta.duration = o.duration;
|
|
95
|
+
if (!(meta.duration > 0)) throw new Error("영상 길이를 모른다 — __kf.meta.duration 을 두거나 --duration 을 준다");
|
|
96
|
+
if (meta.width !== o.width || meta.height !== o.height) {
|
|
97
|
+
await page.setViewportSize({ width: meta.width, height: meta.height });
|
|
98
|
+
}
|
|
99
|
+
const cdp = await page.context().newCDPSession(page);
|
|
100
|
+
await page.evaluate(() => (window as any).__kfCheck.clear());
|
|
101
|
+
return { page, cdp, meta, mode: info.mode === "step" ? "step" : "seek", legacy: kind === "legacy", markers: info.markers, errors, cur };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function capture(cdp: CDPSession, w: number, h: number, scale: number): Promise<Rgba> {
|
|
105
|
+
const r = await cdp.send("Page.captureScreenshot", {
|
|
106
|
+
format: "png",
|
|
107
|
+
clip: { x: 0, y: 0, width: w, height: h, scale },
|
|
108
|
+
optimizeForSpeed: true,
|
|
109
|
+
});
|
|
110
|
+
return decodePng(Buffer.from(r.data, "base64"));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function seekTake(p: Opened, t: number): Promise<TextHit[]>;
|
|
114
|
+
async function seekTake(p: Opened, t: number, cam: true): Promise<{ hits: TextHit[]; cam: Omit<CamSample, "t"> }>;
|
|
115
|
+
async function seekTake(p: Opened, t: number, cam = false): Promise<any> {
|
|
116
|
+
p.cur.t = t;
|
|
117
|
+
return p.page.evaluate(
|
|
118
|
+
async ([tt, withCam]) => {
|
|
119
|
+
const w = window as any;
|
|
120
|
+
await w.__kf.seek(tt);
|
|
121
|
+
const hits = w.__kfCheck.take();
|
|
122
|
+
return withCam ? { hits, cam: w.__kfCheck.camera() } : hits;
|
|
123
|
+
},
|
|
124
|
+
[t, cam] as const,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function contrastOf(img: Rgba, t: number, hits: TextHit[]): ContrastSample[] {
|
|
129
|
+
const out: ContrastSample[] = [];
|
|
130
|
+
for (const h of hits) {
|
|
131
|
+
// 「·」 같은 문장부호 하나는 대비를 따질 글이 아니다.
|
|
132
|
+
if (!h.box || h.alpha < 0.6 || h.sizePx < 6 || !/[\p{L}\p{N}]/u.test(h.text)) continue;
|
|
133
|
+
const { x0, y0, x1, y1 } = h.box;
|
|
134
|
+
if (x1 <= 0 || y1 <= 0 || x0 >= img.width || y0 >= img.height) continue;
|
|
135
|
+
const ratio = inkContrast(img, h.box);
|
|
136
|
+
if (ratio === null) continue;
|
|
137
|
+
out.push({ t, text: h.text.slice(0, 60), ratio: Math.round(ratio * 100) / 100, sizePx: Math.round(h.sizePx), box: h.box });
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export async function scanPage(o: ScanOptions): Promise<ScanResult> {
|
|
143
|
+
const log = o.log ?? (() => {});
|
|
144
|
+
// 엔진과 같은 실행 플래그여야 「같은 프레임 두 번 찍기」가 렌더와 같은 조건이 된다.
|
|
145
|
+
const browser = await launch();
|
|
146
|
+
try {
|
|
147
|
+
const first = await open(browser, o);
|
|
148
|
+
const { meta } = first;
|
|
149
|
+
const tabs = first.mode === "step" ? 1 : Math.max(1, Math.min(3, o.tabs));
|
|
150
|
+
const opened = [first];
|
|
151
|
+
for (let i = 1; i < tabs; i++) opened.push(await open(browser, o));
|
|
152
|
+
|
|
153
|
+
const fps = meta.fps;
|
|
154
|
+
const total = Math.round(meta.duration * fps);
|
|
155
|
+
const i0 = Math.max(0, Math.floor((o.from ?? 0) * fps));
|
|
156
|
+
const i1 = Math.min(total, Math.ceil((o.to ?? meta.duration) * fps));
|
|
157
|
+
const thumbStep = Math.max(1, Math.round(fps / o.thumbFps));
|
|
158
|
+
const shotStep = Math.max(1, Math.round(fps / o.shotFps));
|
|
159
|
+
const per = Math.ceil((i1 - i0) / tabs);
|
|
160
|
+
const scale = THUMB_W / meta.width;
|
|
161
|
+
log(`훑기: ${(i0 / fps).toFixed(2)}–${(i1 / fps).toFixed(2)}초 ${i1 - i0}프레임 · 탭 ${tabs} · ${first.mode}${first.legacy ? "(옛 seek)" : ""}`);
|
|
162
|
+
|
|
163
|
+
const parts = await Promise.all(
|
|
164
|
+
opened.map(async (p, k) => {
|
|
165
|
+
const a = i0 + k * per;
|
|
166
|
+
const b = Math.min(i1, a + per);
|
|
167
|
+
const texts: FrameText[] = [];
|
|
168
|
+
const thumbs: Thumb[] = [];
|
|
169
|
+
const contrast: ContrastSample[] = [];
|
|
170
|
+
const cams: CamSample[] = [];
|
|
171
|
+
let next = 0.1;
|
|
172
|
+
for (let i = a; i < b; i++) {
|
|
173
|
+
const t = i / fps;
|
|
174
|
+
const onThumb = i % thumbStep === 0;
|
|
175
|
+
const got = onThumb ? await seekTake(p, t, true) : { hits: await seekTake(p, t), cam: null };
|
|
176
|
+
const hits = got.hits;
|
|
177
|
+
if (got.cam) cams.push({ t, ...got.cam });
|
|
178
|
+
if (hits.length) texts.push({ t, hits });
|
|
179
|
+
if (onThumb) thumbs.push(colorThumb(t, await capture(p.cdp, meta.width, meta.height, scale)));
|
|
180
|
+
if (i % shotStep === 0 && hits.length) contrast.push(...contrastOf(await capture(p.cdp, meta.width, meta.height, 1), t, hits));
|
|
181
|
+
if ((i - a) / (b - a) >= next) {
|
|
182
|
+
log(` 탭 ${k + 1}: ${Math.round(next * 100)}%`);
|
|
183
|
+
next += 0.25;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const repeat: RepeatSample[] = [];
|
|
187
|
+
if (p.mode === "seek" && b - a > 10) {
|
|
188
|
+
for (const f of [0.2, 0.5, 0.8]) {
|
|
189
|
+
const t = Math.round(a + (b - a) * f) / fps;
|
|
190
|
+
const hA = await seekTake(p, t);
|
|
191
|
+
const A = luma(await capture(p.cdp, meta.width, meta.height, 0.25));
|
|
192
|
+
await seekTake(p, Math.max(0, t - 0.5));
|
|
193
|
+
const hB = await seekTake(p, t);
|
|
194
|
+
const B = luma(await capture(p.cdp, meta.width, meta.height, 0.25));
|
|
195
|
+
const key = (h: TextHit[]) => h.map((x) => x.text).join("\u0001");
|
|
196
|
+
repeat.push({ t, diff: Math.round(meanAbsDiff(A, B) * 1000) / 1000, textSame: key(hA) === key(hB) });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const events: MotionEvent[] = await p.page.evaluate(() => (window as any).__kf.events ?? []);
|
|
200
|
+
return { texts, thumbs, contrast, repeat, events, cams };
|
|
201
|
+
}),
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const texts = parts.flatMap((x) => x.texts).sort((a, b) => a.t - b.t);
|
|
205
|
+
const pairs = new Set<string>();
|
|
206
|
+
for (const f of texts) for (const h of f.hits) for (const ch of new Set(h.text)) if (ch.trim()) pairs.add(h.font + "\u0000" + ch);
|
|
207
|
+
const list = [...pairs].slice(0, 6000).map((k) => k.split("\u0000") as [string, string]);
|
|
208
|
+
const glyphs: Record<string, string> = list.length ? await first.page.evaluate((ps) => (window as any).__kfCheck.glyphs(ps), list) : {};
|
|
209
|
+
|
|
210
|
+
const seen = new Set<string>();
|
|
211
|
+
const events = parts
|
|
212
|
+
.flatMap((x) => x.events)
|
|
213
|
+
.filter((e) => {
|
|
214
|
+
const key = `${e.t}|${e.kind}|${e.source}|${e.scene ?? ""}`;
|
|
215
|
+
if (seen.has(key)) return false;
|
|
216
|
+
seen.add(key);
|
|
217
|
+
return true;
|
|
218
|
+
})
|
|
219
|
+
.sort((a, b) => a.t - b.t);
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
meta,
|
|
223
|
+
mode: first.mode,
|
|
224
|
+
legacy: first.legacy,
|
|
225
|
+
markers: first.markers,
|
|
226
|
+
events,
|
|
227
|
+
texts,
|
|
228
|
+
thumbs: parts.flatMap((x) => x.thumbs).sort((a, b) => a.t - b.t),
|
|
229
|
+
thumbFps: fps / thumbStep,
|
|
230
|
+
contrast: parts.flatMap((x) => x.contrast),
|
|
231
|
+
errors: opened.flatMap((p) => p.errors).sort((a, b) => a.t - b.t),
|
|
232
|
+
repeat: parts.flatMap((x) => x.repeat),
|
|
233
|
+
glyphs,
|
|
234
|
+
cams: parts.flatMap((x) => x.cams).sort((a, b) => a.t - b.t),
|
|
235
|
+
frames: i1 - i0,
|
|
236
|
+
};
|
|
237
|
+
} finally {
|
|
238
|
+
await browser.close();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createServer, type Server } from "node:http";
|
|
2
|
+
import { createReadStream, statSync } from "node:fs";
|
|
3
|
+
import { extname, join, normalize, resolve, sep } from "node:path";
|
|
4
|
+
|
|
5
|
+
const MIME: Record<string, string> = {
|
|
6
|
+
".html": "text/html; charset=utf-8",
|
|
7
|
+
".js": "text/javascript; charset=utf-8",
|
|
8
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
9
|
+
".css": "text/css; charset=utf-8",
|
|
10
|
+
".json": "application/json; charset=utf-8",
|
|
11
|
+
".svg": "image/svg+xml",
|
|
12
|
+
".png": "image/png",
|
|
13
|
+
".jpg": "image/jpeg",
|
|
14
|
+
".jpeg": "image/jpeg",
|
|
15
|
+
".webp": "image/webp",
|
|
16
|
+
".gif": "image/gif",
|
|
17
|
+
".ttf": "font/ttf",
|
|
18
|
+
".otf": "font/otf",
|
|
19
|
+
".woff": "font/woff",
|
|
20
|
+
".woff2": "font/woff2",
|
|
21
|
+
".mp3": "audio/mpeg",
|
|
22
|
+
".wav": "audio/wav",
|
|
23
|
+
".mp4": "video/mp4",
|
|
24
|
+
".webm": "video/webm",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// 빌드가 필요 없는 페이지(옛 방식·바닐라 html)를 띄우는 정적 서버.
|
|
28
|
+
// kf 프로젝트는 엔진의 openProject(Vite)로 연다.
|
|
29
|
+
export async function serveStatic(dir: string): Promise<{ url: string; close(): Promise<void> }> {
|
|
30
|
+
const root = resolve(dir);
|
|
31
|
+
const server = createServer((req, res) => {
|
|
32
|
+
const path = decodeURIComponent((req.url || "/").split("?")[0]);
|
|
33
|
+
let file = normalize(join(root, path));
|
|
34
|
+
if (file !== root && !file.startsWith(root + sep)) {
|
|
35
|
+
res.writeHead(403).end();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
if (statSync(file).isDirectory()) file = join(file, "index.html");
|
|
40
|
+
const st = statSync(file);
|
|
41
|
+
res.writeHead(200, { "content-type": MIME[extname(file).toLowerCase()] || "application/octet-stream", "content-length": st.size });
|
|
42
|
+
createReadStream(file).pipe(res);
|
|
43
|
+
} catch {
|
|
44
|
+
res.writeHead(404).end();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const port = await listen(server);
|
|
48
|
+
return {
|
|
49
|
+
url: `http://127.0.0.1:${port}/`,
|
|
50
|
+
close: () => new Promise((r) => server.close(() => r())),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// TEAM.md 가 검사 담당에 준 포트 5130–5139 를 먼저 쓰고, 다 차면 아무 빈 포트.
|
|
55
|
+
async function listen(server: Server): Promise<number> {
|
|
56
|
+
for (const port of [5130, 5131, 5132, 5133, 5134, 5135, 5136, 5137, 5138, 5139, 0]) {
|
|
57
|
+
const ok = await new Promise<boolean>((r) => {
|
|
58
|
+
server.once("error", () => r(false));
|
|
59
|
+
server.listen(port, "127.0.0.1", () => r(true));
|
|
60
|
+
});
|
|
61
|
+
if (ok) {
|
|
62
|
+
const a = server.address();
|
|
63
|
+
return typeof a === "object" && a ? a.port : port;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new Error("빈 포트가 없다");
|
|
67
|
+
}
|