dsh-drawai 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4142 -0
- package/README.md +43 -10
- package/lib/audio-media.js +147 -0
- package/lib/audio-service.js +66 -0
- package/lib/canvas-format.js +134 -0
- package/lib/client.js +5283 -223
- package/lib/comfyui-default-workflow.mjs +1825 -0
- package/lib/comfyui-workflow.mjs +426 -0
- package/lib/document-commands.js +12 -0
- package/lib/document-core.js +29 -0
- package/lib/drawing-tasks.js +26 -0
- package/lib/imagegen.mjs +596 -0
- package/lib/index.js +1758 -129
- package/lib/media.js +26 -13
- package/lib/mgstyle-core.js +75 -0
- package/lib/motion/apply.js +180 -0
- package/lib/motion/asset-pack-lock.js +10 -0
- package/lib/motion/asset-pack.js +335 -0
- package/lib/motion/assets.js +290 -0
- package/lib/motion/audio.js +103 -0
- package/lib/motion/audiolevel.js +63 -0
- package/lib/motion/audiomix.js +144 -0
- package/lib/motion/beats.js +337 -0
- package/lib/motion/builtin-assets.js +62 -0
- package/lib/motion/canvas-spec.js +442 -0
- package/lib/motion/capture.js +95 -0
- package/lib/motion/cards.js +80 -0
- package/lib/motion/collect.js +447 -0
- package/lib/motion/delivery.js +112 -0
- package/lib/motion/edge-speech.py +90 -0
- package/lib/motion/entry.jsx +73 -0
- package/lib/motion/export.js +200 -0
- package/lib/motion/ffmpeg.js +42 -0
- package/lib/motion/fonts.js +71 -0
- package/lib/motion/jobs.js +113 -0
- package/lib/motion/json.js +4 -0
- package/lib/motion/media-catalog.js +59 -0
- package/lib/motion/mgstyles/BRIEF-TEMPLATE.md +63 -0
- package/lib/motion/mgstyles/briefs/01-flat-vector.md +104 -0
- package/lib/motion/mgstyles/briefs/02-line-art.md +97 -0
- package/lib/motion/mgstyles/briefs/03-isometric.md +108 -0
- package/lib/motion/mgstyles/briefs/05-cel-boil.md +145 -0
- package/lib/motion/mgstyles/briefs/06-collage.md +149 -0
- package/lib/motion/mgstyles/briefs/07-liquid.md +106 -0
- package/lib/motion/mgstyles/briefs/08-morph.md +111 -0
- package/lib/motion/mgstyles/briefs/09-bauhaus.md +150 -0
- package/lib/motion/mgstyles/briefs/10-synthwave.md +151 -0
- package/lib/motion/mgstyles/briefs/12-aurora-glass.md +147 -0
- package/lib/motion/mgstyles/briefs/18-hanazi.md +140 -0
- package/lib/motion/mgstyles/briefs/19-paperclip.md +156 -0
- package/lib/motion/mgstyles/briefs/20-pixel.md +118 -0
- package/lib/motion/mgstyles/briefs/22-hud.md +118 -0
- package/lib/motion/mgstyles/catalog.d/01-flat-vector.json +34 -0
- package/lib/motion/mgstyles/catalog.d/02-line-art.json +34 -0
- package/lib/motion/mgstyles/catalog.d/03-isometric.json +35 -0
- package/lib/motion/mgstyles/catalog.d/05-cel-boil.json +28 -0
- package/lib/motion/mgstyles/catalog.d/06-collage.json +28 -0
- package/lib/motion/mgstyles/catalog.d/07-liquid.json +28 -0
- package/lib/motion/mgstyles/catalog.d/08-morph.json +28 -0
- package/lib/motion/mgstyles/catalog.d/09-bauhaus.json +28 -0
- package/lib/motion/mgstyles/catalog.d/10-synthwave.json +28 -0
- package/lib/motion/mgstyles/catalog.d/12-aurora-glass.json +28 -0
- package/lib/motion/mgstyles/catalog.d/18-hanazi.json +28 -0
- package/lib/motion/mgstyles/catalog.d/19-paperclip.json +28 -0
- package/lib/motion/mgstyles/catalog.d/20-pixel.json +28 -0
- package/lib/motion/mgstyles/catalog.d/22-hud.json +28 -0
- package/lib/motion/mgstyles/catalog.json +1356 -0
- package/lib/motion/mgstyles/upstream/README.md +147 -0
- package/lib/motion/mgstyles/upstream/README.zh-CN.md +147 -0
- package/lib/motion/mgstyles/upstream/demos/01-flat-vector/cues.json +1 -0
- package/lib/motion/mgstyles/upstream/demos/01-flat-vector/index.html +712 -0
- package/lib/motion/mgstyles/upstream/demos/02-line-art/cues.json +331 -0
- package/lib/motion/mgstyles/upstream/demos/02-line-art/film.js +676 -0
- package/lib/motion/mgstyles/upstream/demos/02-line-art/index.html +18 -0
- package/lib/motion/mgstyles/upstream/demos/02-line-art/tools/dump_timing.mjs +26 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/cues.json +109 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/index.html +25 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/anim.js +82 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/main.js +219 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/night5.js +180 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/render.js +202 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/title.js +167 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/title5.js +294 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/ui.js +141 -0
- package/lib/motion/mgstyles/upstream/demos/03-isometric/js/world.js +1399 -0
- package/lib/motion/mgstyles/upstream/demos/05-cel-boil/cues.json +157 -0
- package/lib/motion/mgstyles/upstream/demos/05-cel-boil/index.html +34 -0
- package/lib/motion/mgstyles/upstream/demos/05-cel-boil/js/engine.js +326 -0
- package/lib/motion/mgstyles/upstream/demos/05-cel-boil/js/scene.js +2036 -0
- package/lib/motion/mgstyles/upstream/demos/06-collage/assets/gen/layout.json +157 -0
- package/lib/motion/mgstyles/upstream/demos/06-collage/cues.json +80 -0
- package/lib/motion/mgstyles/upstream/demos/06-collage/index.html +889 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/cues.json +100 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/index.html +108 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/engine.js +153 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/links.js +64 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/lookdev.js +46 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/scene.js +963 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/shaders.js +647 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/textsdf.js +114 -0
- package/lib/motion/mgstyles/upstream/demos/07-liquid/js/type.js +50 -0
- package/lib/motion/mgstyles/upstream/demos/08-morph/cues.json +131 -0
- package/lib/motion/mgstyles/upstream/demos/08-morph/glyphs.json +1 -0
- package/lib/motion/mgstyles/upstream/demos/08-morph/index.html +901 -0
- package/lib/motion/mgstyles/upstream/demos/09-bauhaus/cues.json +270 -0
- package/lib/motion/mgstyles/upstream/demos/09-bauhaus/film.js +697 -0
- package/lib/motion/mgstyles/upstream/demos/09-bauhaus/index.html +12 -0
- package/lib/motion/mgstyles/upstream/demos/10-synthwave/cues.json +44 -0
- package/lib/motion/mgstyles/upstream/demos/10-synthwave/index.html +1028 -0
- package/lib/motion/mgstyles/upstream/demos/12-aurora-glass/cues.json +67 -0
- package/lib/motion/mgstyles/upstream/demos/12-aurora-glass/index.html +16 -0
- package/lib/motion/mgstyles/upstream/demos/12-aurora-glass/main.js +967 -0
- package/lib/motion/mgstyles/upstream/demos/12-aurora-glass/shaders.js +468 -0
- package/lib/motion/mgstyles/upstream/demos/18-hanazi/cues.json +117 -0
- package/lib/motion/mgstyles/upstream/demos/18-hanazi/index.html +541 -0
- package/lib/motion/mgstyles/upstream/demos/19-paperclip/assets/countries-110m.json +1 -0
- package/lib/motion/mgstyles/upstream/demos/19-paperclip/assets/stickers/meta.json +34 -0
- package/lib/motion/mgstyles/upstream/demos/19-paperclip/cues.json +285 -0
- package/lib/motion/mgstyles/upstream/demos/19-paperclip/index.html +599 -0
- package/lib/motion/mgstyles/upstream/demos/20-pixel/cues.json +42 -0
- package/lib/motion/mgstyles/upstream/demos/20-pixel/film.js +914 -0
- package/lib/motion/mgstyles/upstream/demos/20-pixel/index.html +18 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/cues.json +108 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/index.html +125 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/js/holo.js +275 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/js/hud.js +855 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/js/post.js +150 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/js/util.js +65 -0
- package/lib/motion/mgstyles/upstream/demos/22-hud/js/v5.js +142 -0
- package/lib/motion/mgstyles/upstream/harness/render.mjs +319 -0
- package/lib/motion/mgstyles/upstream/manifest.json +269 -0
- package/lib/motion/mgstyles/upstream/prompts/01-flat-vector.md +98 -0
- package/lib/motion/mgstyles/upstream/prompts/02-line-art.md +95 -0
- package/lib/motion/mgstyles/upstream/prompts/03-isometric.md +97 -0
- package/lib/motion/mgstyles/upstream/prompts/05-cel-boil.md +95 -0
- package/lib/motion/mgstyles/upstream/prompts/06-collage.md +95 -0
- package/lib/motion/mgstyles/upstream/prompts/07-liquid.md +98 -0
- package/lib/motion/mgstyles/upstream/prompts/08-morph.md +95 -0
- package/lib/motion/mgstyles/upstream/prompts/09-bauhaus.md +96 -0
- package/lib/motion/mgstyles/upstream/prompts/10-synthwave.md +95 -0
- package/lib/motion/mgstyles/upstream/prompts/12-aurora-glass.md +96 -0
- package/lib/motion/mgstyles/upstream/prompts/18-hanazi.md +95 -0
- package/lib/motion/mgstyles/upstream/prompts/19-paperclip.md +96 -0
- package/lib/motion/mgstyles/upstream/prompts/20-pixel.md +96 -0
- package/lib/motion/mgstyles/upstream/prompts/22-hud.md +95 -0
- package/lib/motion/mgstyles/upstream/rubric.md +51 -0
- package/lib/motion/mgstyles/upstream/template.md +36 -0
- package/lib/motion/pixelqa.js +198 -0
- package/lib/motion/preview.js +95 -0
- package/lib/motion/project.js +395 -0
- package/lib/motion/qa.js +290 -0
- package/lib/motion/reference-media.jsx +10 -0
- package/lib/motion/render-settings.js +112 -0
- package/lib/motion/render.js +159 -0
- package/lib/motion/scene-kit.js +183 -0
- package/lib/motion/sfx.js +232 -0
- package/lib/motion/shotcraft/ClipCard.tsx +204 -0
- package/lib/motion/shotcraft/catalog.json +2461 -0
- package/lib/motion/shotcraft/upstream/SKILL.md +286 -0
- package/lib/motion/shotcraft/upstream/assets/lib/Caption.tsx +54 -0
- package/lib/motion/shotcraft/upstream/assets/lib/ClipCard.tsx +200 -0
- package/lib/motion/shotcraft/upstream/assets/lib/DigitRoll.tsx +45 -0
- package/lib/motion/shotcraft/upstream/assets/lib/FlashCut.tsx +20 -0
- package/lib/motion/shotcraft/upstream/assets/lib/FlatPanel.tsx +65 -0
- package/lib/motion/shotcraft/upstream/assets/lib/PageCam.tsx +151 -0
- package/lib/motion/shotcraft/upstream/assets/lib/VerticalTicker.tsx +129 -0
- package/lib/motion/shotcraft/upstream/assets/lib/helpers/camera.tsx +75 -0
- package/lib/motion/shotcraft/upstream/assets/lib/helpers/motion.ts +40 -0
- package/lib/motion/shotcraft/upstream/assets/lib/helpers/rand.ts +11 -0
- package/lib/motion/shotcraft/upstream/assets/lib/helpers/shake.ts +10 -0
- package/lib/motion/shotcraft/upstream/assets/scripts/__pycache__/sfx-source.cpython-313.pyc +0 -0
- package/lib/motion/shotcraft/upstream/assets/scripts/build-readme-cover.mjs +49 -0
- package/lib/motion/shotcraft/upstream/assets/scripts/capture-template.mjs +210 -0
- package/lib/motion/shotcraft/upstream/assets/scripts/sfx-source.py +423 -0
- package/lib/motion/shotcraft/upstream/assets/scripts/smoke-render-demos.py +170 -0
- package/lib/motion/shotcraft/upstream/assets/scripts/test_sfx_source.py +157 -0
- package/lib/motion/shotcraft/upstream/demos/README.md +120 -0
- package/lib/motion/shotcraft/upstream/demos/_fixtures/Brand.tsx +112 -0
- package/lib/motion/shotcraft/upstream/demos/_fixtures/Fixtures.tsx +647 -0
- package/lib/motion/shotcraft/upstream/demos/_fixtures/Look.tsx +316 -0
- package/lib/motion/shotcraft/upstream/demos/_fixtures/Motion.tsx +82 -0
- package/lib/motion/shotcraft/upstream/demos/_fixtures/PageCam2D.tsx +115 -0
- package/lib/motion/shotcraft/upstream/demos/_fixtures/Polish.tsx +243 -0
- package/lib/motion/shotcraft/upstream/demos/_textures/live-layout.json +389 -0
- package/lib/motion/shotcraft/upstream/demos/camera/basic-3d-scene/Basic3DScene.tsx +250 -0
- package/lib/motion/shotcraft/upstream/demos/camera/crash-zoom-punch/CrashImpactReal.tsx +305 -0
- package/lib/motion/shotcraft/upstream/demos/camera/crash-zoom-punch/CrashZoomReal.tsx +246 -0
- package/lib/motion/shotcraft/upstream/demos/camera/cursor-flyover/CursorFlyover.tsx +390 -0
- package/lib/motion/shotcraft/upstream/demos/camera/depth-layer-moves/MultiplaneReal.tsx +138 -0
- package/lib/motion/shotcraft/upstream/demos/camera/graze-face-tour/GrazeFaceTour.tsx +542 -0
- package/lib/motion/shotcraft/upstream/demos/camera/overhead-camera-moves/OverheadTabletopDrop.tsx +315 -0
- package/lib/motion/shotcraft/upstream/demos/camera/overhead-camera-moves/TiltReveal.tsx +299 -0
- package/lib/motion/shotcraft/upstream/demos/camera/space-camera-moves/DroneDiveLanding.tsx +173 -0
- package/lib/motion/shotcraft/upstream/demos/camera/space-camera-moves/ExplodedView.tsx +348 -0
- package/lib/motion/shotcraft/upstream/demos/camera/steep-tilt-glide/SteepTiltGlide.tsx +366 -0
- package/lib/motion/shotcraft/upstream/demos/camera/tension-camera-moves/BulletTimeFreezeOrbit.tsx +279 -0
- package/lib/motion/shotcraft/upstream/demos/camera/tension-camera-moves/PullBackIsolation.tsx +184 -0
- package/lib/motion/shotcraft/upstream/demos/camera/terminal-3d/Terminal3D.tsx +390 -0
- package/lib/motion/shotcraft/upstream/demos/data/before-after-slider-scrub/BeforeAfterSliderScrub.tsx +155 -0
- package/lib/motion/shotcraft/upstream/demos/data/chart-live-moves/AxisRescaleShockV2.tsx +303 -0
- package/lib/motion/shotcraft/upstream/demos/data/chart-live-moves/OscilloscopeStreamV2.tsx +290 -0
- package/lib/motion/shotcraft/upstream/demos/data/chart-live-moves/UnitDotSwarmRegroupV2.tsx +278 -0
- package/lib/motion/shotcraft/upstream/demos/data/gauge-readout-moves/NeedleSweepSelftest.tsx +307 -0
- package/lib/motion/shotcraft/upstream/demos/data/gauge-readout-moves/TapeScrollFixedPointer.tsx +215 -0
- package/lib/motion/shotcraft/upstream/demos/data/scroll-brake-moves/BrakeReticleLock.tsx +299 -0
- package/lib/motion/shotcraft/upstream/demos/data/scroll-brake-moves/ChangelogScrollBrake.tsx +232 -0
- package/lib/motion/shotcraft/upstream/demos/data/timeline-travel/TimelineTravel.tsx +290 -0
- package/lib/motion/shotcraft/upstream/demos/effects/assemble-then-type-flyin/AssembleThenTypeFlyin.tsx +273 -0
- package/lib/motion/shotcraft/upstream/demos/effects/aurora-bloom-bg-flip/AuroraBloomBgFlip.tsx +167 -0
- package/lib/motion/shotcraft/upstream/demos/effects/brand-frame-snap/BrandFrameSnap.tsx +536 -0
- package/lib/motion/shotcraft/upstream/demos/effects/fui-hud-moves/ReticleLockOn.tsx +164 -0
- package/lib/motion/shotcraft/upstream/demos/effects/glow-flyline-moves/FlylineArc.tsx +175 -0
- package/lib/motion/shotcraft/upstream/demos/effects/glow-flyline-moves/GlowOrbAmbient.tsx +197 -0
- package/lib/motion/shotcraft/upstream/demos/effects/glow-flyline-moves/OrbFlylineRelay.tsx +241 -0
- package/lib/motion/shotcraft/upstream/demos/effects/icon-performance-moves/AttentionBounce.tsx +279 -0
- package/lib/motion/shotcraft/upstream/demos/effects/impact-feedback/AnimeImpact.tsx +230 -0
- package/lib/motion/shotcraft/upstream/demos/effects/impact-feedback/HitCounter.tsx +345 -0
- package/lib/motion/shotcraft/upstream/demos/effects/light-play-moves/SheenSweepRetry.tsx +275 -0
- package/lib/motion/shotcraft/upstream/demos/effects/light-play-moves/SpotlightSweepReveal.tsx +229 -0
- package/lib/motion/shotcraft/upstream/demos/effects/radial-ripple-phone-chips/RadialRipplePhoneChips.tsx +312 -0
- package/lib/motion/shotcraft/upstream/demos/effects/riso-print-hits/RisoMisregistrationHit.tsx +222 -0
- package/lib/motion/shotcraft/upstream/demos/effects/scan-bracket-sweep/ScanBracketSweep.tsx +295 -0
- package/lib/motion/shotcraft/upstream/demos/effects/scanline-annotate-focus/ScanlineAnnotateFocus.tsx +329 -0
- package/lib/motion/shotcraft/upstream/demos/effects/scanline-assemble-flyin/ScanlineAssembleFlyin.tsx +315 -0
- package/lib/motion/shotcraft/upstream/demos/effects/slam-entrance-moves/ImpactBurstKit.tsx +264 -0
- package/lib/motion/shotcraft/upstream/demos/effects/slam-entrance-moves/KanadaPerspectiveSnap.tsx +260 -0
- package/lib/motion/shotcraft/upstream/demos/effects/slam-entrance-moves/ScoreSlam.tsx +263 -0
- package/lib/motion/shotcraft/upstream/demos/effects/spotlight-sweep-moves/CornerSpotlightReveal.tsx +123 -0
- package/lib/motion/shotcraft/upstream/demos/effects/spotlight-sweep-moves/GlowWakeSleepPanel.tsx +187 -0
- package/lib/motion/shotcraft/upstream/demos/effects/spotlight-sweep-moves/SlideSpotlightPan.tsx +175 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/autolayout-gap-dial/AutolayoutGapDial.tsx +305 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/canvas-materialize-moves/DiagramCascadeBuild.tsx +350 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/canvas-materialize-moves/PanelToCanvasMaterialize.tsx +352 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/chip-grid-single-select-blackout/ChipGridSingleSelectBlackout.tsx +218 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/collab-cursor-moves/CursorCastEnsemble.tsx +297 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/glass-pill-dictation-typing/GlassPillDictationTyping.tsx +157 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/hashtag-to-pill-materialize/HashtagToPillMaterialize.tsx +218 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/picker-carousel-feature-cycle/PickerCarouselFeatureCycle.tsx +202 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/segmented-thumb-hero/SegmentedThumbHero.tsx +265 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/theme-switch-moves/PaletteThemeRipple.tsx +457 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/theme-switch-moves/ThemeSweepToggle.tsx +446 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/type-and-filter/TypeAndFilter.tsx +249 -0
- package/lib/motion/shotcraft/upstream/demos/interaction/voice-waveform-live/VoiceWaveformLive.tsx +278 -0
- package/lib/motion/shotcraft/upstream/demos/opening/crane-rise-reveal/CraneRiseReveal.tsx +332 -0
- package/lib/motion/shotcraft/upstream/demos/opening/dataviz-landscape-open/DatavizLandscapeOpen.tsx +358 -0
- package/lib/motion/shotcraft/upstream/demos/opening/fracture/Fracture.tsx +201 -0
- package/lib/motion/shotcraft/upstream/demos/opening/icon-field-colorize/IconFieldColorize.tsx +200 -0
- package/lib/motion/shotcraft/upstream/demos/opening/letterspace-materialize/LetterspaceMaterialize.tsx +208 -0
- package/lib/motion/shotcraft/upstream/demos/opening/magician-card-flourish/MagicianCardFlourish.tsx +341 -0
- package/lib/motion/shotcraft/upstream/demos/opening/orbit-ring-title-open/OrbitRingTitleOpen.tsx +389 -0
- package/lib/motion/shotcraft/upstream/demos/opening/spotlight-hero-card/SpotlightHeroCard.tsx +293 -0
- package/lib/motion/shotcraft/upstream/demos/opening/stroke-segment-build/StrokeSegmentBuild.tsx +183 -0
- package/lib/motion/shotcraft/upstream/demos/opening/text-as-mask/TextAsMask.tsx +245 -0
- package/lib/motion/shotcraft/upstream/demos/outro/grain-dissolve/GrainDissolve.tsx +222 -0
- package/lib/motion/shotcraft/upstream/demos/outro/logo-shrink-wordmark-lockup/LogoShrinkWordmarkLockup.tsx +223 -0
- package/lib/motion/shotcraft/upstream/demos/outro/neon-triple-marquee/NeonTripleMarquee.tsx +217 -0
- package/lib/motion/shotcraft/upstream/demos/outro/outro-group-photo-launch/OutroGroupPhotoLaunch.tsx +343 -0
- package/lib/motion/shotcraft/upstream/demos/outro/ui-strip-away-outro/UiStripAwayOutro.tsx +357 -0
- package/lib/motion/shotcraft/upstream/demos/outro/ui-to-brand-morph/IconFlipBloomLogo.tsx +187 -0
- package/lib/motion/shotcraft/upstream/demos/outro/ui-to-brand-morph/InputMorphsIntoLogo.tsx +333 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/beat-cut-moves/PaparazziFlash.tsx +274 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/beat-step-list-theme-cycle/BeatStepListThemeCycle.tsx +270 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/panel-grid-moves/ComicPanelSplit.tsx +430 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/quad-split-parallel-scenes/QuadSplitParallelScenes.tsx +252 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/rhythm-interrupt-moves/JumpCutPunchIn.tsx +106 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/sakuga-timing-shift/SakugaTimingShift.tsx +288 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/speed-ramp-freeze/FreezeAnnotateReal.tsx +362 -0
- package/lib/motion/shotcraft/upstream/demos/rhythm/trailer-grammar-moves/TrailerBumper.tsx +168 -0
- package/lib/motion/shotcraft/upstream/demos/transition/bottom-push-stack-wipe/BottomPushStackWipe.tsx +310 -0
- package/lib/motion/shotcraft/upstream/demos/transition/card-flip-reveal/CardFlipReveal.tsx +261 -0
- package/lib/motion/shotcraft/upstream/demos/transition/card-flock-tumble/CardFlockTumble.tsx +459 -0
- package/lib/motion/shotcraft/upstream/demos/transition/circle-match-iris/CircleMatchIris.tsx +294 -0
- package/lib/motion/shotcraft/upstream/demos/transition/gradient-transition/GradientTransition.tsx +161 -0
- package/lib/motion/shotcraft/upstream/demos/transition/line-carry-transition/LineCarryTransition.tsx +248 -0
- package/lib/motion/shotcraft/upstream/demos/transition/mosaic-reframe/MosaicReframe.tsx +359 -0
- package/lib/motion/shotcraft/upstream/demos/transition/page-turn-transitions/BarnDoorSplit.tsx +227 -0
- package/lib/motion/shotcraft/upstream/demos/transition/print-texture-transitions/InkBleedReveal.tsx +162 -0
- package/lib/motion/shotcraft/upstream/demos/transition/shot-transitions/PortalWipeV2.tsx +248 -0
- package/lib/motion/shotcraft/upstream/demos/transition/shot-transitions/WhipBrakeReal.tsx +186 -0
- package/lib/motion/shotcraft/upstream/demos/transition/tear-streak-transitions/GlitchDisplace.tsx +355 -0
- package/lib/motion/shotcraft/upstream/demos/transition/transition-hidden-cut/InvisibleCut.tsx +272 -0
- package/lib/motion/shotcraft/upstream/demos/transition/transition-hidden-cut/LightLeakBurn.tsx +262 -0
- package/lib/motion/shotcraft/upstream/demos/transition/transition-hidden-cut/VersusSlam.tsx +217 -0
- package/lib/motion/shotcraft/upstream/demos/transition/transition-travel/LetterformZoom.tsx +285 -0
- package/lib/motion/shotcraft/upstream/demos/transition/white-flash-logo-simplify-cut/WhiteFlashLogoSimplifyCut.tsx +205 -0
- package/lib/motion/shotcraft/upstream/demos/transition/wipe-transitions/BlindsSlice.tsx +178 -0
- package/lib/motion/shotcraft/upstream/demos/typography/blur-slide/BlurSlide.tsx +147 -0
- package/lib/motion/shotcraft/upstream/demos/typography/brace-expand/BraceExpand.tsx +143 -0
- package/lib/motion/shotcraft/upstream/demos/typography/brand-ink-open/BrandInkOpen.tsx +134 -0
- package/lib/motion/shotcraft/upstream/demos/typography/countdown-arc-scatter/CountdownArcScatter.tsx +217 -0
- package/lib/motion/shotcraft/upstream/demos/typography/flying-words/FlyingWords.tsx +198 -0
- package/lib/motion/shotcraft/upstream/demos/typography/glitch-cycle/GlitchCycle.tsx +221 -0
- package/lib/motion/shotcraft/upstream/demos/typography/gradient-word-sweep/GradientWordSweep.tsx +312 -0
- package/lib/motion/shotcraft/upstream/demos/typography/lead-word-zoom-assemble/LeadWordZoomAssemble.tsx +261 -0
- package/lib/motion/shotcraft/upstream/demos/typography/marker-underline-title/MarkerUnderlineTitle.tsx +121 -0
- package/lib/motion/shotcraft/upstream/demos/typography/outline-word-fill/OutlineWordFill.tsx +153 -0
- package/lib/motion/shotcraft/upstream/demos/typography/paper-title-card/PaperTitleCard.tsx +179 -0
- package/lib/motion/shotcraft/upstream/demos/typography/pill-chip-slot-cycle-handled/PillChipSlotCycleHandled.tsx +140 -0
- package/lib/motion/shotcraft/upstream/demos/typography/pill-slot-cycle/PillSlotCycle.tsx +309 -0
- package/lib/motion/shotcraft/upstream/demos/typography/text-column-converge/TextColumnConverge.tsx +191 -0
- package/lib/motion/shotcraft/upstream/demos/typography/title-demote-to-label/TitleDemoteToLabel.tsx +292 -0
- package/lib/motion/shotcraft/upstream/demos/typography/type-assembly-moves/LetterformDriftAssembly.tsx +135 -0
- package/lib/motion/shotcraft/upstream/demos/typography/type-assembly-moves/SplitTextStagger.tsx +124 -0
- package/lib/motion/shotcraft/upstream/demos/typography/type-assembly-moves/TextOnPath.tsx +255 -0
- package/lib/motion/shotcraft/upstream/demos/typography/type-entrance-moves/LetterDropPhysics.tsx +173 -0
- package/lib/motion/shotcraft/upstream/demos/typography/type-rhythm-sync/FontWeightPump.tsx +225 -0
- package/lib/motion/shotcraft/upstream/demos/typography/type-rhythm-sync/KaraokeFillSync.tsx +141 -0
- package/lib/motion/shotcraft/upstream/demos/typography/typewriter-moves/TypewriterErrorRetype.tsx +137 -0
- package/lib/motion/shotcraft/upstream/demos/typography/vertical-word-roll-blur-cycle/VerticalWordRollBlurCycle.tsx +147 -0
- package/lib/motion/shotcraft/upstream/demos/typography/word-relay-filmstrip/WordRelayFilmstrip.tsx +409 -0
- package/lib/motion/shotcraft/upstream/demos/typography/word-relay-geometry/WordRelayGeometry.tsx +280 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/avatar-bracket-carousel/AvatarBracketCarousel.tsx +271 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/bezier-source-converge-merge/BezierSourceConvergeMerge.tsx +385 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/card-stack/CardStack.tsx +312 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/carousel-3d/Carousel3D.tsx +303 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/clipcard-looping/ClipCardLooping.tsx +77 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/cloner-depth-echo/ClonerDepthEcho.tsx +311 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/deck-deal-flyin/DeckDealFlyin.tsx +307 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/doc-park-left-pill-deal/DocParkLeftPillDeal.tsx +349 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/document-typewriter-reveal/DocumentTypewriterReveal.tsx +255 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/draw-svg-trace/DrawSvgTrace.tsx +244 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/element-body-moves/ContactShadowLift.tsx +217 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/integration-hub-map/IntegrationHubMap.tsx +652 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/list-reveal/ListReveal.tsx +153 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/list-stack-press/ListStackPress.tsx +238 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/neon-frame-forerun/NeonFrameForerun.tsx +324 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/neon-frame-orbit-drop/NeonFrameForerunOrbit.tsx +354 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/page-waterfall-wall/PageWaterfallWall.tsx +101 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/page-waterfall-wall/VerticalTicker.tsx +129 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/product-card-progressive-assemble/ProductCardProgressiveAssemble.tsx +297 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/radial-wave/RadialWave.tsx +57 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/research-card-stack-scroll/ResearchCardStackScroll.tsx +155 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/row-embed/RowEmbed.tsx +175 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/value-stagger-gradient/ValueStaggerGradient.tsx +153 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/wall-reveal-moves/BentoLightUp.tsx +146 -0
- package/lib/motion/shotcraft/upstream/demos/ui-entrance/wall-reveal-moves/WireframeDrawOn.tsx +226 -0
- package/lib/motion/shotcraft/upstream/gallery/api/library.json +1 -0
- package/lib/motion/shotcraft/upstream/manifest.json +2715 -0
- package/lib/motion/shotcraft/upstream/references/aesthetic-rules.md +193 -0
- package/lib/motion/shotcraft/upstream/references/final-review.md +121 -0
- package/lib/motion/shotcraft/upstream/references/guided-free-creation.md +199 -0
- package/lib/motion/shotcraft/upstream/references/jianying-export.md +183 -0
- package/lib/motion/shotcraft/upstream/references/music-beat-sync.md +257 -0
- package/lib/motion/shotcraft/upstream/references/pipeline.md +382 -0
- package/lib/motion/shotcraft/upstream/references/publish-upload-post.md +111 -0
- package/lib/motion/shotcraft/upstream/references/sequences/promo-energy-arc.md +50 -0
- package/lib/motion/shotcraft/upstream/references/sfx-sourcing.md +95 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/basic-3d-scene.md +41 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/crash-zoom-punch.md +52 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/cursor-flyover.md +39 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/depth-layer-moves.md +39 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/graze-face-tour.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/overhead-camera-moves.md +51 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/space-camera-moves.md +46 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/steep-tilt-glide.md +52 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/tension-camera-moves.md +43 -0
- package/lib/motion/shotcraft/upstream/references/shots/camera/terminal-3d.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/data/before-after-slider-scrub.md +48 -0
- package/lib/motion/shotcraft/upstream/references/shots/data/chart-live-moves.md +52 -0
- package/lib/motion/shotcraft/upstream/references/shots/data/gauge-readout-moves.md +45 -0
- package/lib/motion/shotcraft/upstream/references/shots/data/scroll-brake-moves.md +46 -0
- package/lib/motion/shotcraft/upstream/references/shots/data/timeline-travel.md +44 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/assemble-then-type-flyin.md +63 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/aurora-bloom-bg-flip.md +54 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/brand-frame-snap.md +58 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/fui-hud-moves.md +35 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/glow-flyline-moves.md +53 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/icon-performance-moves.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/impact-feedback.md +50 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/light-play-moves.md +46 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/radial-ripple-phone-chips.md +56 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/riso-print-hits.md +49 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/scan-bracket-sweep.md +50 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/scanline-annotate-focus.md +53 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/scanline-assemble-flyin.md +53 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/slam-entrance-moves.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/effects/spotlight-sweep-moves.md +52 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/autolayout-gap-dial.md +60 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/canvas-materialize-moves.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/chip-grid-single-select-blackout.md +51 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/collab-cursor-moves.md +41 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/glass-pill-dictation-typing.md +53 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/hashtag-to-pill-materialize.md +60 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/picker-carousel-feature-cycle.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/segmented-thumb-hero.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/theme-switch-moves.md +47 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/type-and-filter.md +37 -0
- package/lib/motion/shotcraft/upstream/references/shots/interaction/voice-waveform-live.md +54 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/brand-ink-open.md +36 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/crane-rise-reveal.md +56 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/dataviz-landscape-open.md +56 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/fracture.md +40 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/icon-field-colorize.md +60 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/letterspace-materialize.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/magician-card-flourish.md +73 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/orbit-ring-title-open.md +87 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/spotlight-hero-card.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/stroke-segment-build.md +50 -0
- package/lib/motion/shotcraft/upstream/references/shots/opening/text-as-mask.md +59 -0
- package/lib/motion/shotcraft/upstream/references/shots/outro/grain-dissolve.md +38 -0
- package/lib/motion/shotcraft/upstream/references/shots/outro/logo-shrink-wordmark-lockup.md +38 -0
- package/lib/motion/shotcraft/upstream/references/shots/outro/neon-triple-marquee.md +59 -0
- package/lib/motion/shotcraft/upstream/references/shots/outro/outro-group-photo-launch.md +39 -0
- package/lib/motion/shotcraft/upstream/references/shots/outro/ui-strip-away-outro.md +61 -0
- package/lib/motion/shotcraft/upstream/references/shots/outro/ui-to-brand-morph.md +52 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/beat-cut-moves.md +50 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/beat-step-list-theme-cycle.md +66 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/panel-grid-moves.md +43 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/quad-split-parallel-scenes.md +38 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/rhythm-interrupt-moves.md +38 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/sakuga-timing-shift.md +56 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/speed-ramp-freeze.md +44 -0
- package/lib/motion/shotcraft/upstream/references/shots/rhythm/trailer-grammar-moves.md +38 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/bottom-push-stack-wipe.md +63 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/card-flip-reveal.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/card-flock-tumble.md +63 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/circle-match-iris.md +58 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/gradient-transition.md +45 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/line-carry-transition.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/mosaic-reframe.md +49 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/page-turn-transitions.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/print-texture-transitions.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/shot-transitions.md +45 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/tear-streak-transitions.md +48 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/transition-hidden-cut.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/transition-travel.md +43 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/white-flash-logo-simplify-cut.md +41 -0
- package/lib/motion/shotcraft/upstream/references/shots/transition/wipe-transitions.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/blur-slide.md +59 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/brace-expand.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/countdown-arc-scatter.md +65 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/document-typewriter-reveal.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/flying-words.md +64 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/glitch-cycle.md +64 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/gradient-word-sweep.md +54 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/lead-word-zoom-assemble.md +91 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/marker-underline-title.md +51 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/outline-word-fill.md +66 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/paper-title-card.md +38 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/pill-chip-slot-cycle-handled.md +66 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/pill-slot-cycle.md +58 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/text-column-converge.md +61 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/title-demote-to-label.md +64 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/type-assembly-moves.md +45 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/type-entrance-moves.md +41 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/type-rhythm-sync.md +51 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/typewriter-moves.md +42 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/vertical-word-roll-blur-cycle.md +63 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/word-relay-filmstrip.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/typography/word-relay-geometry.md +75 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/avatar-bracket-carousel.md +59 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/bezier-source-converge-merge.md +67 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/card-stack.md +60 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/carousel-3d.md +66 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/cloner-depth-echo.md +40 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/deck-deal-flyin.md +45 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/doc-park-left-pill-deal.md +62 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/draw-svg-trace.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/element-body-moves.md +37 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/integration-hub-map.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/list-reveal.md +50 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/list-stack-press.md +43 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/neon-frame-forerun.md +55 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/neon-frame-orbit-drop.md +51 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/page-waterfall-wall.md +51 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/product-card-progressive-assemble.md +56 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/radial-wave.md +49 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/research-card-stack-scroll.md +57 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/row-embed.md +36 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/value-stagger-gradient.md +64 -0
- package/lib/motion/shotcraft/upstream/references/shots/ui-entrance/wall-reveal-moves.md +47 -0
- package/lib/motion/shotcraft/upstream/references/sound-design.md +170 -0
- package/lib/motion/shotcraft/upstream/references/workbench.md +157 -0
- package/lib/motion/shotcraft/upstream/template/TEMPLATE.md +103 -0
- package/lib/motion/shotcraft/upstream/template/THEMES.md +44 -0
- package/lib/motion/shotcraft/upstream/template/package.json +20 -0
- package/lib/motion/shotcraft/upstream/template/remotion.config.ts +6 -0
- package/lib/motion/shotcraft/upstream/template/src/Root.tsx +17 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/Caption.tsx +65 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/DigitRoll.tsx +48 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/FlashCut.tsx +24 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/Main.tsx +192 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/PaperTitleCard.tsx +111 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/PageCam.tsx +150 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/SceneDetail.tsx +158 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/SceneFlyIn.tsx +468 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/SceneOpen.tsx +552 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/SceneOutroLive.tsx +411 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/ScenePapers.tsx +200 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live/SceneWbr.tsx +324 -0
- package/lib/motion/shotcraft/upstream/template/src/aifl/live-layout.json +389 -0
- package/lib/motion/shotcraft/upstream/template/src/index.ts +4 -0
- package/lib/motion/shotcraft/upstream/template/src/themes/ThemedFilm.tsx +7 -0
- package/lib/motion/shotcraft/upstream/template/src/themes/manifest.tsx +68 -0
- package/lib/motion/shotcraft/upstream/template/src/themes/palette-assets.json +1 -0
- package/lib/motion/shotcraft/upstream/template/src/themes/palette-assets.ts +24 -0
- package/lib/motion/shotcraft/upstream/template/src/themes/palettes.json +74 -0
- package/lib/motion/shotcraft/upstream/template/src/themes/visual-theme.tsx +91 -0
- package/lib/motion/shotcraft/upstream/template/src/workbench.ts +213 -0
- package/lib/motion/shotcraft/upstream/template/tsconfig.json +15 -0
- package/lib/motion/spec.js +113 -0
- package/lib/motion/style-engine.js +153 -0
- package/lib/motion/style-frames.js +268 -0
- package/lib/motion/sync.js +214 -0
- package/lib/motion/theme.js +121 -0
- package/lib/motion/voice.js +417 -0
- package/lib/motion-agent-files.js +82 -0
- package/lib/motion-agent-protocol.js +66 -0
- package/lib/motion-agent-tools.js +196 -0
- package/lib/motion-agent.js +171 -0
- package/lib/motion-capture.js +92 -0
- package/lib/motion-core.js +238 -0
- package/lib/motion-film-review.js +71 -0
- package/lib/motion-library.js +210 -0
- package/lib/motion-planner.js +254 -0
- package/lib/motion-project.js +80 -0
- package/lib/motion-render-worker.js +145 -0
- package/lib/motion-session.js +32 -0
- package/lib/motion-source.js +49 -0
- package/lib/motion-tasks.js +452 -0
- package/lib/motion-vision.js +43 -0
- package/lib/mxfile.js +27 -7
- package/lib/routing/node-runtime.js +14 -0
- package/lib/routing/router.js +211 -0
- package/lib/routing/vendor/README.md +96 -0
- package/lib/routing/vendor/libavoid-routing.js +753 -0
- package/lib/routing/vendor/libavoid.min.js +59 -0
- package/lib/shotcard-core.js +39 -0
- package/lib/shotcard-reference.js +56 -0
- package/lib/style-kernel.js +37 -3
- package/lib/task-patches.js +26 -2
- package/lib/video-export.js +17 -2
- package/package.json +29 -4
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 取「整片风格」上游 demo 的参考帧。
|
|
3
|
+
*
|
|
4
|
+
* brief 能写清色板与判据,但写不清动效:转场怎么擦、冲击有没有环、相机有没有抖、
|
|
5
|
+
* 颗粒是逐像素还是几百个点 —— 这些只有看帧才知道。这里用上游自带的服务端 + Chrome
|
|
6
|
+
* 打开 demos/<slug>/index.html,按 cues.json 的时间点调 renderAt(t) 截帧,交给模型当
|
|
7
|
+
* 对照物。缺字体/纸纹时用占位资源兜底,并记在 notes 里,不假装素材齐全。
|
|
8
|
+
*/
|
|
9
|
+
import {openBrowser} from '@remotion/renderer'
|
|
10
|
+
import {existsSync,mkdirSync,readFileSync,statSync,writeFileSync} from 'node:fs'
|
|
11
|
+
import {createServer} from 'node:http'
|
|
12
|
+
import {extname,join,normalize,resolve,sep} from 'node:path'
|
|
13
|
+
import {tmpdir} from 'node:os'
|
|
14
|
+
import {fileURLToPath} from 'node:url'
|
|
15
|
+
import {fontsDir, mediaLibraryRoot} from './asset-pack.js'
|
|
16
|
+
import {fontFaces} from './fonts.js'
|
|
17
|
+
|
|
18
|
+
const UPSTREAM = fileURLToPath(new URL('./mgstyles/upstream', import.meta.url))
|
|
19
|
+
const DEMO_FONT_ALIASES = {
|
|
20
|
+
'/demos/03-isometric/assets/fonts/Unbounded-800-static.ttf': 'Unbounded',
|
|
21
|
+
'/demos/07-liquid/assets/Fraunces-Liquid-72-900-Soft.ttf': 'Fraunces',
|
|
22
|
+
'/demos/08-morph/assets/fonts/Outfit-SemiBold.ttf': 'Outfit',
|
|
23
|
+
'/demos/10-synthwave/assets/fonts/MrDafoe-Regular.ttf': 'Mr Dafoe',
|
|
24
|
+
}
|
|
25
|
+
// 上游 demo 的 importmap 指向 /node_modules/three/...、/node_modules/opentype.js/...,
|
|
26
|
+
// 但这些包只在插件根目录的 node_modules 里。旧版只服务 upstream 目录,于是模块 404、
|
|
27
|
+
// window.__ready 永不置真,最后报了句"没有在 120 秒内就绪"——错误信息指向了完全错误的地方。
|
|
28
|
+
const MODULES = fileURLToPath(new URL('../../node_modules', import.meta.url))
|
|
29
|
+
|
|
30
|
+
const MIME = {
|
|
31
|
+
'.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.mjs': 'text/javascript',
|
|
32
|
+
'.css': 'text/css', '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg',
|
|
33
|
+
'.jpeg': 'image/jpeg', '.webp': 'image/webp', '.svg': 'image/svg+xml', '.ttf': 'font/ttf',
|
|
34
|
+
'.otf': 'font/otf', '.woff': 'font/woff', '.woff2': 'font/woff2', '.wav': 'audio/wav',
|
|
35
|
+
'.mp3': 'audio/mpeg', '.mp4': 'video/mp4', '.wasm': 'application/wasm', '.glb': 'model/gltf-binary',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 1×1 透明 PNG:纸纹/贴图没 vendored 时先让页面能 decode 通过,画面里那块会是平的,notes 会写明。
|
|
39
|
+
const PLACEHOLDER_PNG = Buffer.from(
|
|
40
|
+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',
|
|
41
|
+
'base64',
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
// 字体没 vendored 时用系统字体顶上:document.fonts.load() 才不会 reject(字形本来就从 glyphs.json 来,
|
|
45
|
+
// 参考帧里字的形状可能略有出入,但不会整页 init 失败)。
|
|
46
|
+
const SYSTEM_FONT = [
|
|
47
|
+
...(fontsDir() ? [join(fontsDir(), 'NotoSansSC-VF.ttf')] : []),
|
|
48
|
+
'C:/Windows/Fonts/segoeui.ttf',
|
|
49
|
+
'C:/Windows/Fonts/arial.ttf',
|
|
50
|
+
'C:/Windows/Fonts/msyh.ttc',
|
|
51
|
+
].find((path) => existsSync(path))
|
|
52
|
+
|
|
53
|
+
/** 素材库贴图目录:素材包没装好时返回 null。 */
|
|
54
|
+
function texturesDir() {
|
|
55
|
+
const root = mediaLibraryRoot()
|
|
56
|
+
return root ? join(root, 'assets', 'textures') : null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function flattenNumbers(value, out) {
|
|
60
|
+
if (typeof value === 'number' && Number.isFinite(value)) out.push(value)
|
|
61
|
+
else if (Array.isArray(value)) for (const item of value) flattenNumbers(item, out)
|
|
62
|
+
else if (value && typeof value === 'object') for (const item of Object.values(value)) flattenNumbers(item, out)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function cueTimes(slug, duration) {
|
|
66
|
+
const file = join(UPSTREAM, 'demos', slug, 'cues.json')
|
|
67
|
+
if (!existsSync(file)) return []
|
|
68
|
+
try {
|
|
69
|
+
const raw = JSON.parse(readFileSync(file, 'utf8'))
|
|
70
|
+
const out = []
|
|
71
|
+
// bpm/fps 是参数不是时间点;loop 是几何;它们混进来会截到片尾之外的空帧。
|
|
72
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
73
|
+
if (/^(bpm|fps|loop)$/i.test(key)) continue
|
|
74
|
+
flattenNumbers(value, out)
|
|
75
|
+
}
|
|
76
|
+
const limit = Number.isFinite(duration) && duration > 0 ? duration - 0.04 : 60
|
|
77
|
+
return [...new Set(out.filter((t) => t >= 0.05 && t <= limit).map((t) => Math.round(t * 100) / 100))].sort((a, b) => a - b)
|
|
78
|
+
} catch {
|
|
79
|
+
return []
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function pickTimes(slug, count, explicit, duration) {
|
|
84
|
+
if (Array.isArray(explicit) && explicit.length) {
|
|
85
|
+
const limit = Number.isFinite(duration) && duration > 0 ? duration : Infinity
|
|
86
|
+
return explicit.map(Number).filter((t) => Number.isFinite(t) && t >= 0 && t <= limit).slice(0, 24)
|
|
87
|
+
}
|
|
88
|
+
const cues = cueTimes(slug, duration)
|
|
89
|
+
const wanted = Math.max(1, Math.min(24, Math.floor(Number(count) || 8)))
|
|
90
|
+
if (cues.length >= wanted) {
|
|
91
|
+
// 均匀覆盖全片,同时尽量落在 cue 上(动作发生的那几帧信息量最大)
|
|
92
|
+
const min = cues[0], max = cues[cues.length - 1]
|
|
93
|
+
return Array.from({ length: wanted }, (_, i) => {
|
|
94
|
+
const target = min + ((max - min) * i) / Math.max(1, wanted - 1)
|
|
95
|
+
return cues.reduce((best, t) => (Math.abs(t - target) < Math.abs(best - target) ? t : best), cues[0])
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
const max = Number.isFinite(duration) && duration > 0 ? duration : 10
|
|
99
|
+
return Array.from({ length: wanted }, (_, i) => Math.round(((max * i) / Math.max(1, wanted - 1)) * 1000) / 1000)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// demo 的 importmap 指向 /node_modules/*,只有真装在本机的包才服务得出来。
|
|
103
|
+
// 缺包时页面会静默卡在模块加载阶段,等到超时也只会说"没就绪"—— 这里提前查,几十毫秒就报清缺什么。
|
|
104
|
+
function missingModules(slug) {
|
|
105
|
+
const html = join(UPSTREAM, 'demos', slug, 'index.html')
|
|
106
|
+
let text = ''
|
|
107
|
+
try { text = readFileSync(html, 'utf8') } catch { return [] }
|
|
108
|
+
const refs = [...text.matchAll(/["'](\/node_modules\/[^"']+)["']/g)].map((match) => match[1])
|
|
109
|
+
return [...new Set(refs)].filter((ref) => !existsSync(join(MODULES, ref.slice('/node_modules/'.length))))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function startStaticServer(misses) {
|
|
113
|
+
const roots = {vendor: resolve(MODULES), upstream: resolve(UPSTREAM)}
|
|
114
|
+
return new Promise((done) => {
|
|
115
|
+
const server = createServer((req, res) => {
|
|
116
|
+
try {
|
|
117
|
+
const pathname = decodeURIComponent(new URL(req.url, 'http://x').pathname)
|
|
118
|
+
if (pathname === '/assets/fonts/fonts.css') {
|
|
119
|
+
misses.push('/assets/fonts/fonts.css(使用 DrawAI 内置字体,部分上游字体或字重可能不同)')
|
|
120
|
+
res.writeHead(200, {'Content-Type': 'text/css; charset=utf-8'})
|
|
121
|
+
return res.end(fontFaces().map(face => '@font-face{font-family:' + JSON.stringify(face.family) + ';src:url(' + JSON.stringify('/__drawai-fonts/' + face.file) + ');font-weight:' + face.weight + ';font-style:' + face.style + ';font-display:block}').join('\n'))
|
|
122
|
+
}
|
|
123
|
+
if (pathname.startsWith('/__drawai-fonts/') && fontFaces().some(face => pathname === '/__drawai-fonts/' + face.file)) {
|
|
124
|
+
const file = join(fontsDir() || '', pathname.split('/').at(-1))
|
|
125
|
+
if (!existsSync(file)) { res.writeHead(404); return res.end('missing bundled font') }
|
|
126
|
+
res.writeHead(200, {'Content-Type': 'font/ttf'})
|
|
127
|
+
return res.end(readFileSync(file))
|
|
128
|
+
}
|
|
129
|
+
if (DEMO_FONT_ALIASES[pathname]) {
|
|
130
|
+
const face = fontFaces().find(item => item.family === DEMO_FONT_ALIASES[pathname] && item.style === 'normal')
|
|
131
|
+
if (face && existsSync(join(fontsDir() || '', face.file))) {
|
|
132
|
+
if (face.weight.includes(' ')) misses.push(pathname + '(使用同字体族可变字体,字重或轴值可能不同)')
|
|
133
|
+
res.writeHead(200, {'Content-Type': 'font/ttf'})
|
|
134
|
+
return res.end(readFileSync(join(fontsDir() || '', face.file)))
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const vendor = pathname.startsWith('/node_modules/')
|
|
138
|
+
// 两条挂载点:/node_modules/* → 插件 node_modules;其余 → upstream。各自限制在自己目录内。
|
|
139
|
+
const root = vendor ? roots.vendor : roots.upstream
|
|
140
|
+
const relative = vendor ? pathname.slice('/node_modules'.length) : pathname
|
|
141
|
+
let file = resolve(join(root, normalize(relative)))
|
|
142
|
+
if (file !== root && !file.startsWith(root + sep)) { res.writeHead(403); return res.end('403') }
|
|
143
|
+
if (existsSync(file) && statSync(file).isDirectory()) file = join(file, 'index.html')
|
|
144
|
+
// Shared upstream textures are packaged separately from the text-only demo tree.
|
|
145
|
+
if (!vendor && !existsSync(file) && pathname.startsWith('/assets/textures/')) {
|
|
146
|
+
const tdir = texturesDir()
|
|
147
|
+
const texture = tdir ? resolve(tdir, pathname.slice('/assets/textures/'.length)) : ''
|
|
148
|
+
if (tdir && texture.startsWith(resolve(tdir) + sep) && existsSync(texture)) file = texture
|
|
149
|
+
}
|
|
150
|
+
if (!existsSync(file)) {
|
|
151
|
+
misses.push(pathname)
|
|
152
|
+
// 模块缺失不能给占位:给个假的 three.module.js 只会让页面以更难懂的方式失败。
|
|
153
|
+
if (vendor) { res.writeHead(404); return res.end('404 ' + pathname) }
|
|
154
|
+
// 字体/纸纹/贴图没 vendor:CSS 给空表,图片给 1px 占位,其余 404(页面会走 fallback)
|
|
155
|
+
if (/\.css$/i.test(pathname)) { res.writeHead(200, {'Content-Type': 'text/css'}); return res.end('/* placeholder */') }
|
|
156
|
+
if (/\.(png|jpe?g|webp)$/i.test(pathname)) { res.writeHead(200, {'Content-Type': MIME[extname(file).toLowerCase()] || 'image/png'}); return res.end(PLACEHOLDER_PNG) }
|
|
157
|
+
if (/\.(ttf|otf|woff2?)$/i.test(pathname) && SYSTEM_FONT) {
|
|
158
|
+
res.writeHead(200, {'Content-Type': 'font/ttf'})
|
|
159
|
+
return res.end(readFileSync(SYSTEM_FONT))
|
|
160
|
+
}
|
|
161
|
+
res.writeHead(404); return res.end('404 ' + pathname)
|
|
162
|
+
}
|
|
163
|
+
res.writeHead(200, {'Content-Type': MIME[extname(file).toLowerCase()] || 'application/octet-stream', 'Cache-Control': 'no-store'})
|
|
164
|
+
res.end(readFileSync(file))
|
|
165
|
+
} catch (error) {
|
|
166
|
+
res.writeHead(500); res.end(String(error))
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
server.listen(0, '127.0.0.1', () => done(server))
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function findChrome(browserExecutable) {
|
|
174
|
+
return [browserExecutable, process.env.DRAWAI_CHROME_PATH,
|
|
175
|
+
'C:/Program Files/Google/Chrome/Application/chrome.exe',
|
|
176
|
+
'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
|
177
|
+
'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'].find((path) => path && existsSync(path))
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export async function captureStyleFrames({slug, times: explicitTimes, count = 8, browserExecutable, directory, signal} = {}) {
|
|
181
|
+
if (typeof slug !== 'string' || !/^[a-z0-9][a-z0-9-]*$/i.test(slug)) throw new Error('slug 无效:' + slug)
|
|
182
|
+
const demo = join(UPSTREAM, 'demos', slug)
|
|
183
|
+
if (!existsSync(join(demo, 'index.html'))) throw new Error('这个风格没有可截帧的上游 demo:' + slug + '(只有说明、没有 index.html)')
|
|
184
|
+
const missing = missingModules(slug)
|
|
185
|
+
if (missing.length) {
|
|
186
|
+
throw new Error('这个 demo 的依赖没装在本机(' + missing.join(', ') + '),页面加载不到模块,截不了帧。'
|
|
187
|
+
+ '三条路:① 改用 action:"source" 读 demos/' + slug + '/ 下的源码与 cues.json 反推动效(多数情况够用);'
|
|
188
|
+
+ '② 在插件目录跑 `npm i --no-save opentype.js simplex-noise topojson-client d3` 后重试(这几个包只为截参考帧,不进 package.json);'
|
|
189
|
+
+ '③ 换一个不依赖它们的 demo。')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const misses = []
|
|
193
|
+
const server = await startStaticServer(misses)
|
|
194
|
+
const port = server.address().port
|
|
195
|
+
const executable = findChrome(browserExecutable)
|
|
196
|
+
signal?.throwIfAborted()
|
|
197
|
+
const browser = await openBrowser('chrome', {browserExecutable: executable, logLevel: 'error'})
|
|
198
|
+
try {
|
|
199
|
+
const page = await browser.newPage({context: () => null, logLevel: 'error', indent: false, pageIndex: 0, onBrowserLog: null, onLog: () => {}})
|
|
200
|
+
await page.setViewport({width: 1920, height: 1080, deviceScaleFactor: 1})
|
|
201
|
+
await page.goto({url: 'http://127.0.0.1:' + port + '/demos/' + slug + '/index.html', timeout: 60000})
|
|
202
|
+
// 就绪等待 30 秒:实测最慢的能截的 demo 8.4 秒就绪;真出问题的页面不会在第 31 秒突然变好。
|
|
203
|
+
// 超时要把"缺了哪些资源"一起报出来,并分清是缺 npm 包还是上游素材没 vendored——两者的处理办法不一样。
|
|
204
|
+
try {
|
|
205
|
+
await page.evaluate(() => new Promise((resolve, reject) => {
|
|
206
|
+
const started = Date.now()
|
|
207
|
+
const tick = () => {
|
|
208
|
+
if (window.__ready === true) return resolve(true)
|
|
209
|
+
if (Date.now() - started > 30000) return reject(new Error('__timeout__'))
|
|
210
|
+
setTimeout(tick, 100)
|
|
211
|
+
}
|
|
212
|
+
tick()
|
|
213
|
+
}))
|
|
214
|
+
} catch {
|
|
215
|
+
const lost = [...new Set(misses)]
|
|
216
|
+
const modules = lost.filter((path) => path.startsWith('/node_modules/')).slice(0, 4)
|
|
217
|
+
const assets = lost.filter((path) => !path.startsWith('/node_modules/') && !/favicon|fonts\.css/.test(path)).slice(0, 4)
|
|
218
|
+
throw new Error('上游 demo 没有就绪(30 秒)'
|
|
219
|
+
+ (modules.length ? ';缺 npm 包:' + modules.join(', ') : '')
|
|
220
|
+
+ (assets.length ? ';缺上游素材:' + assets.join(', ') + '(这些没有 vendored,不是配置问题)' : '')
|
|
221
|
+
+ (modules.length || assets.length ? '' : ';模块可能抛错')
|
|
222
|
+
+ '。改用 action:"source" 读 demos/' + slug + '/ 下的源码与 cues.json 反推动效,通常比等截帧更省事。')
|
|
223
|
+
}
|
|
224
|
+
const meta = await page.evaluate(() => ({
|
|
225
|
+
width: window.DEMO?.width || 1920,
|
|
226
|
+
height: window.DEMO?.height || 1080,
|
|
227
|
+
fps: window.DEMO?.fps || 30,
|
|
228
|
+
duration: window.DEMO?.duration || 10,
|
|
229
|
+
hasRenderAt: typeof window.renderAt === 'function',
|
|
230
|
+
}))
|
|
231
|
+
if (!meta.hasRenderAt) throw new Error('这个 demo 没有 window.renderAt(t),无法按时间取帧;改用 action:"source" 读源码')
|
|
232
|
+
const width = Math.max(320, Math.min(2560, Math.round(meta.width)))
|
|
233
|
+
const height = Math.max(240, Math.min(1440, Math.round(meta.height)))
|
|
234
|
+
const fps = Math.max(1, Math.round(meta.fps || 30))
|
|
235
|
+
await page.setViewport({width, height, deviceScaleFactor: 1})
|
|
236
|
+
const times = pickTimes(slug, count, explicitTimes, Number(meta.duration) || 10)
|
|
237
|
+
if (!times.length) throw new Error('没有可用的时间点(cues.json 里的时间都超出片长)')
|
|
238
|
+
|
|
239
|
+
const dir = directory || join(tmpdir(), 'dsh-drawai', 'style-frames', slug)
|
|
240
|
+
mkdirSync(dir, {recursive: true})
|
|
241
|
+
const files = []
|
|
242
|
+
for (const [index, t] of times.entries()) {
|
|
243
|
+
signal?.throwIfAborted()
|
|
244
|
+
await page.evaluate(async (time, fpsValue) => {
|
|
245
|
+
await window.renderAt?.(time)
|
|
246
|
+
// 两帧 rAF:让画面里基于 frame 的绘制与 CSS/WAAPI 都落到同一时刻
|
|
247
|
+
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(resolve, 30))))
|
|
248
|
+
void fpsValue
|
|
249
|
+
}, t, fps)
|
|
250
|
+
const result = await page._client().send('Page.captureScreenshot', {
|
|
251
|
+
format: 'png', captureBeyondViewport: false,
|
|
252
|
+
clip: {x: 0, y: 0, width, height, scale: 1},
|
|
253
|
+
})
|
|
254
|
+
const data = Buffer.from((result.value || result).data, 'base64')
|
|
255
|
+
if (data.length > 12 * 1024 * 1024) throw new Error('参考帧体积过大:' + t + 's')
|
|
256
|
+
const file = join(dir, 'frame-' + String(index).padStart(2, '0') + '-' + t.toFixed(2) + 's.png')
|
|
257
|
+
writeFileSync(file, data)
|
|
258
|
+
files.push({time: t, frame: Math.round(t * fps), path: file, bytes: data.length})
|
|
259
|
+
}
|
|
260
|
+
const notes = []
|
|
261
|
+
if (misses.length) notes.push('缺上游资源(已用占位兜底,画面里的字体/纸纹可能与原片不同):' + [...new Set(misses)].slice(0, 8).join(', '))
|
|
262
|
+
notes.push('这些是参考帧:写场景前逐张看,按 STYLE.md 的效果配方逐项对照(转场/冲击/相机/颗粒/二次运动),别只对"形"。')
|
|
263
|
+
return {slug, width, height, fps, duration: meta.duration, times, directory: dir, files, notes}
|
|
264
|
+
} finally {
|
|
265
|
+
await browser.close({silent: true}).catch(() => {})
|
|
266
|
+
await new Promise((done) => server.close(done))
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// One source of truth: source-music seconds -> edit events -> source SFX peaks.
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync, unlinkSync } from 'node:fs'
|
|
4
|
+
import { join, resolve, relative, isAbsolute } from 'node:path'
|
|
5
|
+
import { decodePcm } from './beats.js'
|
|
6
|
+
import { runFfmpeg } from './ffmpeg.js'
|
|
7
|
+
import { parseProjectJson } from './json.js'
|
|
8
|
+
|
|
9
|
+
const number = (value, name) => {
|
|
10
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) throw new Error(name + ' 必须是有限数字')
|
|
11
|
+
return value
|
|
12
|
+
}
|
|
13
|
+
export function assetPath(dir, file) {
|
|
14
|
+
const root = resolve(dir, 'assets'), path = resolve(root, file || '')
|
|
15
|
+
const rel = relative(root, path)
|
|
16
|
+
if (!rel || isAbsolute(rel) || rel === '..' || rel.startsWith('..' + (process.platform === 'win32' ? '\\' : '/'))) throw new Error('同步音频必须位于工程 assets 内')
|
|
17
|
+
return path
|
|
18
|
+
}
|
|
19
|
+
export const syncKey = (timeline) => createHash('sha256').update(JSON.stringify(timeline)).digest('hex')
|
|
20
|
+
export function syncRevision(dir, timeline) {
|
|
21
|
+
const music = timeline.audio?.find((cue) => cue.id === timeline.sync?.musicCueId)
|
|
22
|
+
if (timeline.sync?.analysisSourceHash && (!music || timeline.sync.analysisSourceHash !== filmHash(assetPath(dir, music.file)))) throw new Error('音乐文件已变更,请重新 motion_sync bind 分析后绑定')
|
|
23
|
+
const hash = createHash('sha256').update(syncKey(timeline))
|
|
24
|
+
for (const shot of timeline.shots) {
|
|
25
|
+
const file = join(dir, shot.file || '')
|
|
26
|
+
if (shot.file && existsSync(file)) hash.update(readFileSync(file))
|
|
27
|
+
}
|
|
28
|
+
for (const cue of timeline.audio || []) hash.update(readFileSync(assetPath(dir, cue.file)))
|
|
29
|
+
const walk = (path) => {
|
|
30
|
+
if (!existsSync(path)) return
|
|
31
|
+
for (const entry of readdirSync(path, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
32
|
+
const file = join(path, entry.name)
|
|
33
|
+
if (entry.isDirectory()) walk(file)
|
|
34
|
+
else if (entry.isFile()) hash.update(entry.name).update(readFileSync(file))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
walk(join(dir, 'components'))
|
|
38
|
+
walk(join(dir, 'assets'))
|
|
39
|
+
for (const entry of readdirSync(dir).sort()) if (/\.(tsx?|jsx?)$/.test(entry) && !/^index\./.test(entry)) hash.update(entry).update(readFileSync(join(dir, entry)))
|
|
40
|
+
return hash.digest('hex')
|
|
41
|
+
}
|
|
42
|
+
export const filmHash = (file) => createHash('sha256').update(readFileSync(file)).digest('hex')
|
|
43
|
+
|
|
44
|
+
export function resolveSync(input) {
|
|
45
|
+
const timeline = structuredClone(input), sync = timeline.sync
|
|
46
|
+
if (!sync) return timeline
|
|
47
|
+
const fps = number(timeline.fps, 'fps')
|
|
48
|
+
if (sync.toleranceFrames !== undefined && (number(sync.toleranceFrames, 'toleranceFrames') < 0 || sync.toleranceFrames > 3)) throw new Error('toleranceFrames 必须在0–3内')
|
|
49
|
+
if (fps <= 0 || !Array.isArray(sync.anchors) || !sync.anchors.length || sync.anchors.length > 200) throw new Error('sync 需要 1–200 个 anchors')
|
|
50
|
+
const music = timeline.audio?.find((cue) => cue.id === sync.musicCueId)
|
|
51
|
+
if (!music || music.loop) throw new Error('sync.musicCueId 必须指向不循环的音乐轨')
|
|
52
|
+
const offset = sync.outputOffsetSeconds === undefined ? 0 : number(sync.outputOffsetSeconds, 'outputOffsetSeconds')
|
|
53
|
+
if (Math.abs(offset) > 1) throw new Error('输出偏移超出 ±1 秒')
|
|
54
|
+
const ids = new Set(), targets = new Set(), cueIds = new Set()
|
|
55
|
+
const rows = sync.anchors.map((anchor) => {
|
|
56
|
+
if (typeof anchor.id !== 'string' || !anchor.id || ids.has(anchor.id)) throw new Error('anchor.id 必须唯一')
|
|
57
|
+
ids.add(anchor.id)
|
|
58
|
+
if (anchor.visual) visualPeak(Buffer.alloc(0), 1, 1, 0, anchor.visual)
|
|
59
|
+
if (anchor.sfx !== undefined && !Array.isArray(anchor.sfx)) throw new Error('sfx 必须是绑定数组')
|
|
60
|
+
if (!['cut', 'action'].includes(anchor.type)) throw new Error('anchor.type 必须是 cut/action')
|
|
61
|
+
const shot = timeline.shots.find((item) => item.id === anchor.shotId)
|
|
62
|
+
if (!shot) throw new Error('锚点引用了不存在的镜头:' + anchor.shotId)
|
|
63
|
+
const targetKey = anchor.type + ':' + anchor.shotId + ':' + (anchor.type === 'action' ? anchor.name : '')
|
|
64
|
+
if (targets.has(targetKey)) throw new Error('同一个切镜或动作不能重复绑定')
|
|
65
|
+
targets.add(targetKey)
|
|
66
|
+
if (anchor.type === 'action' && (typeof anchor.name !== 'string' || !anchor.name)) throw new Error('动作锚点需要 name')
|
|
67
|
+
if ((anchor.at === undefined) === (anchor.beat === undefined)) throw new Error('锚点必须且只能给 at(源音乐秒)或 beat(0 起拍号)')
|
|
68
|
+
let sourceSeconds
|
|
69
|
+
if (anchor.at !== undefined) sourceSeconds = number(anchor.at, 'at')
|
|
70
|
+
else {
|
|
71
|
+
const grid = sync.analysis?.grid
|
|
72
|
+
if (!grid || ![grid.t0, grid.periodMs, grid.residualMs, grid.coverage].every(Number.isFinite) || grid.periodMs <= 0 || grid.residualMs > 15 || grid.coverage < 0.45) throw new Error('按拍号绑定需要通过验收的音乐网格;否则使用 at 实测瞬态')
|
|
73
|
+
const beat = number(anchor.beat, 'beat')
|
|
74
|
+
if (beat < 0) throw new Error('beat 必须从0起')
|
|
75
|
+
sourceSeconds = grid.t0 + beat * grid.periodMs / 1000
|
|
76
|
+
}
|
|
77
|
+
const musicLocal = sourceSeconds - (music.trimStart || 0)
|
|
78
|
+
if (musicLocal < 0 || musicLocal * fps >= music.durationInFrames) throw new Error('拍点超出音乐播放窗口:' + anchor.id)
|
|
79
|
+
const seconds = music.from / fps + musicLocal + offset
|
|
80
|
+
const frame = Math.round(seconds * fps)
|
|
81
|
+
if (frame < 0 || frame >= timeline.durationInFrames) throw new Error('锚点超出影片范围:' + anchor.id)
|
|
82
|
+
if (anchor.type === 'cut') shot.startFrame = frame
|
|
83
|
+
return { ...anchor, sourceSeconds, seconds, frame, quantizationMs: (frame / fps - seconds) * 1000 }
|
|
84
|
+
})
|
|
85
|
+
for (let i = 0; i < timeline.shots.length; i++) {
|
|
86
|
+
const shot = timeline.shots[i], end = timeline.shots[i + 1]?.startFrame ?? timeline.durationInFrames
|
|
87
|
+
if (shot.startFrame < 0 || end <= shot.startFrame) throw new Error('切镜绑定导致镜头倒序或长度为零')
|
|
88
|
+
shot.durationFrames = end - shot.startFrame
|
|
89
|
+
shot.anchors = Object.create(null)
|
|
90
|
+
}
|
|
91
|
+
for (const row of rows) {
|
|
92
|
+
const shot = timeline.shots.find((item) => item.id === row.shotId)
|
|
93
|
+
if (row.frame < shot.startFrame || row.frame >= shot.startFrame + shot.durationFrames) throw new Error('动作锚点不在所属镜头内:' + row.id)
|
|
94
|
+
if (row.type === 'action') shot.anchors[row.name] = row.frame - shot.startFrame
|
|
95
|
+
for (const sfx of row.sfx || []) {
|
|
96
|
+
if (cueIds.has(sfx.cueId) || sfx.cueId === music.id) throw new Error('音效轨不能重复绑定或绑定音乐自身')
|
|
97
|
+
cueIds.add(sfx.cueId)
|
|
98
|
+
const cue = timeline.audio.find((item) => item.id === sfx.cueId)
|
|
99
|
+
if (!cue || cue.loop) throw new Error('音效绑定需要存在且不循环的 cueId')
|
|
100
|
+
const lag = number(sfx.peakSeconds, 'peakSeconds') - (cue.trimStart || 0)
|
|
101
|
+
if (lag < 0 || lag * fps >= cue.durationInFrames) throw new Error('音效峰值超出裁剪窗口')
|
|
102
|
+
const from = Math.round(row.frame - (lag + offset) * fps)
|
|
103
|
+
if (from < 0 || from + cue.durationInFrames > timeline.durationInFrames) throw new Error('音效绑定超出影片范围,不会静默截断')
|
|
104
|
+
cue.from = from
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
sync.resolved = rows
|
|
108
|
+
return timeline
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Normalized waveform matching around an expected transient. Low/ambiguous
|
|
112
|
+
// matches remain unverified; absence of evidence must never become a pass.
|
|
113
|
+
export function matchTransient(source, output, sourceAt, expectedAt, sampleRate, searchSeconds = 0.2) {
|
|
114
|
+
const radius = Math.round(sampleRate * 0.025), center = Math.round(sourceAt * sampleRate)
|
|
115
|
+
const step = 4, template = []
|
|
116
|
+
for (let i = -radius; i <= radius; i += step) template.push(source[center + i] || 0)
|
|
117
|
+
const norm = Math.sqrt(template.reduce((sum, x) => sum + x * x, 0))
|
|
118
|
+
if (!norm) return null
|
|
119
|
+
let best = { score: -1, at: 0 }, second = -1
|
|
120
|
+
const scores = []
|
|
121
|
+
const start = Math.max(radius, Math.round((expectedAt - searchSeconds) * sampleRate)), end = Math.min(output.length - radius - 1, Math.round((expectedAt + searchSeconds) * sampleRate))
|
|
122
|
+
for (let at = start; at <= end; at++) {
|
|
123
|
+
let dot = 0, energy = 0
|
|
124
|
+
for (let i = 0; i < template.length; i++) { const x = output[at - radius + i * step]; dot += template[i] * x; energy += x * x }
|
|
125
|
+
const score = energy ? dot / (norm * Math.sqrt(energy)) : 0
|
|
126
|
+
scores.push({ at, score })
|
|
127
|
+
if (score > best.score) best = { at, score }
|
|
128
|
+
}
|
|
129
|
+
for (const candidate of scores) if (Math.abs(candidate.at - best.at) > sampleRate * 0.01) second = Math.max(second, candidate.score)
|
|
130
|
+
return best.score >= 0.45 && best.score - second >= 0.05 ? { at: best.at / sampleRate, confidence: best.score } : null
|
|
131
|
+
}
|
|
132
|
+
function samples(decoded) {
|
|
133
|
+
return Float64Array.from({ length: decoded.pcm.length / 2 }, (_, i) => decoded.pcm.readInt16LE(i * 2) / 32768)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function visualPeak(bytes, width, height, firstFrame, visual = {}) {
|
|
137
|
+
if (visual.metric !== undefined && !['change', 'brightness'].includes(visual.metric)) throw new Error('visual.metric 必须为 change/brightness')
|
|
138
|
+
if (visual.minSignal !== undefined && (number(visual.minSignal, 'minSignal') <= 0 || visual.minSignal > 255)) throw new Error('minSignal 必须在0–255内')
|
|
139
|
+
const size = width * height, count = Math.floor(bytes.length / size), scores = []
|
|
140
|
+
const roi = visual.roi || { x: 0, y: 0, w: 1, h: 1 }
|
|
141
|
+
for (const key of ['x', 'y', 'w', 'h']) number(roi[key], 'visual.roi.' + key)
|
|
142
|
+
if (roi.x < 0 || roi.y < 0 || roi.w <= 0 || roi.h <= 0 || roi.x + roi.w > 1 || roi.y + roi.h > 1) throw new Error('ROI 必须在 0–1 内')
|
|
143
|
+
for (let f = 1; f < count; f++) {
|
|
144
|
+
let sum = 0, n = 0
|
|
145
|
+
for (let y = Math.floor(roi.y * height); y < Math.ceil((roi.y + roi.h) * height); y++) for (let x = Math.floor(roi.x * width); x < Math.ceil((roi.x + roi.w) * width); x++) {
|
|
146
|
+
const i = y * width + x
|
|
147
|
+
sum += visual.metric === 'brightness' ? bytes[f * size + i] : Math.abs(bytes[f * size + i] - bytes[(f - 1) * size + i]); n++
|
|
148
|
+
}
|
|
149
|
+
scores.push({ frame: firstFrame + f, score: sum / n })
|
|
150
|
+
}
|
|
151
|
+
scores.sort((a, b) => b.score - a.score)
|
|
152
|
+
const best = scores[0], other = scores.find((item) => Math.abs(item.frame - best?.frame) > 1)
|
|
153
|
+
return best && best.score >= (visual.minSignal ?? 8) && (!other || best.score > other.score * 1.15) ? best : null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function verifySync(dir, film, input) {
|
|
157
|
+
const timeline = resolveSync(input), sync = timeline.sync
|
|
158
|
+
if (!sync?.resolved?.length) throw new Error('尚未绑定锚点,先 motion_sync bind')
|
|
159
|
+
const revision = syncRevision(dir, timeline)
|
|
160
|
+
const receiptPath = film + '.sync.json'
|
|
161
|
+
const receipt = existsSync(receiptPath) ? parseProjectJson(readFileSync(receiptPath, 'utf8')) : null
|
|
162
|
+
if (receipt && receipt.revision !== revision) throw new Error('成片与当前绑定或场景版本不一致,请重新渲染后验收')
|
|
163
|
+
if (receipt && receipt.filmHash !== filmHash(film)) throw new Error('成片文件与渲染回执不一致,请重新渲染')
|
|
164
|
+
const out = join(dir, '.out', 'qa', 'sync'); mkdirSync(out, { recursive: true })
|
|
165
|
+
const decoded = await decodePcm(film), output = samples(decoded), rate = decoded.sampleRate
|
|
166
|
+
const cache = new Map()
|
|
167
|
+
const load = async (cue) => {
|
|
168
|
+
const path = assetPath(dir, cue.file)
|
|
169
|
+
if (!cache.has(path)) cache.set(path, samples(await decodePcm(path)))
|
|
170
|
+
return cache.get(path)
|
|
171
|
+
}
|
|
172
|
+
const music = timeline.audio.find((cue) => cue.id === sync.musicCueId), musicSource = await load(music)
|
|
173
|
+
const rows = [], offsets = []
|
|
174
|
+
for (const [index, anchor] of sync.resolved.entries()) {
|
|
175
|
+
const heard = matchTransient(musicSource, output, anchor.sourceSeconds, anchor.seconds, rate)
|
|
176
|
+
if (heard) offsets.push(heard.at - (music.from / timeline.fps + anchor.sourceSeconds - (music.trimStart || 0)))
|
|
177
|
+
let visual = null
|
|
178
|
+
// A cut is an observable frame difference. Continuous actions need an
|
|
179
|
+
// explicitly selected metric/ROI; do not infer their semantic peak.
|
|
180
|
+
if (anchor.type === 'cut' || anchor.visual) {
|
|
181
|
+
const first = Math.max(0, anchor.frame - 6), last = Math.min(timeline.durationInFrames - 1, anchor.frame + 6)
|
|
182
|
+
const path = join(out, 'anchor-' + index + '.gray')
|
|
183
|
+
try {
|
|
184
|
+
await runFfmpeg(['-loglevel', 'error', '-i', film, '-vf', 'select=between(n\\,' + first + '\\,' + last + '),scale=96:54,format=gray', '-vsync', '0', '-f', 'rawvideo', path], { cwd: dir, log: join(out, 'visual.log') })
|
|
185
|
+
visual = visualPeak(readFileSync(path), 96, 54, first, anchor.visual)
|
|
186
|
+
unlinkSync(join(out, 'visual.log'))
|
|
187
|
+
} finally {
|
|
188
|
+
if (existsSync(path)) unlinkSync(path)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const sfxRows = []
|
|
192
|
+
for (const binding of anchor.sfx || []) {
|
|
193
|
+
const cue = timeline.audio.find((item) => item.id === binding.cueId)
|
|
194
|
+
const match = await load(cue).then((source) => matchTransient(source, output, binding.peakSeconds, anchor.frame / timeline.fps, rate))
|
|
195
|
+
sfxRows.push({ cueId: cue.id, measuredSeconds: match?.at ?? null, confidence: match?.confidence ?? null,
|
|
196
|
+
errorFrames: match && heard ? (match.at - heard.at) * timeline.fps : null })
|
|
197
|
+
}
|
|
198
|
+
const error = heard && visual ? visual.frame - heard.at * timeline.fps : null
|
|
199
|
+
const tolerance = sync.toleranceFrames ?? 2
|
|
200
|
+
const status = error === null || sfxRows.some((item) => item.errorFrames === null) ? 'unverified'
|
|
201
|
+
: Math.abs(error) > tolerance || sfxRows.some((item) => Math.abs(item.errorFrames) > tolerance) ? 'fail' : 'pass'
|
|
202
|
+
rows.push({ id: anchor.id, type: anchor.type, plannedFrame: anchor.frame, quantizationMs: anchor.quantizationMs,
|
|
203
|
+
measuredMusicSeconds: heard?.at ?? null, musicConfidence: heard?.confidence ?? null, measuredVisualFrame: visual?.frame ?? null,
|
|
204
|
+
audiovisualErrorFrames: error, sfx: sfxRows, status })
|
|
205
|
+
}
|
|
206
|
+
offsets.sort((a, b) => a - b)
|
|
207
|
+
const report = { version: 1, film, timelineKey: revision, renderReceipt: !!receipt, fps: timeline.fps, generatedAt: new Date().toISOString(),
|
|
208
|
+
status: rows.some((row) => row.status === 'fail') ? 'fail' : rows.some((row) => row.status === 'unverified') ? 'unverified' : 'pass',
|
|
209
|
+
measuredOutputOffsetSeconds: offsets.length >= 3 && offsets.at(-1) - offsets[0] < 0.015 ? offsets[Math.floor(offsets.length / 2)] : null,
|
|
210
|
+
rows }
|
|
211
|
+
if (!receipt) report.status = report.status === 'fail' ? 'fail' : 'unverified'
|
|
212
|
+
writeFileSync(join(out, 'report.json'), JSON.stringify(report, null, 2))
|
|
213
|
+
return report
|
|
214
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// 主题:把"一套配色"变成一个可以 import 的 theme.ts。
|
|
2
|
+
//
|
|
3
|
+
// 上游 template/src/themes 里有 8 套 palettes(page/surface/field/text/muted/
|
|
4
|
+
// accent/border),但工程模板从来不引用它们——每条片子都从素骨架开始,配色
|
|
5
|
+
// 只能靠场景代码里手写十六进制。这里把那条线接上:
|
|
6
|
+
//
|
|
7
|
+
// createProject(dir, { theme: 'vintage-kraft' }) → 生成 theme.ts
|
|
8
|
+
// scene-*.tsx 里 import { PAPER, INK, STAMP } from './theme'
|
|
9
|
+
//
|
|
10
|
+
// theme.ts 是普通源码,agent 照样可以改;theme.json 只记"这条片子用的哪套"。
|
|
11
|
+
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
13
|
+
import { join } from 'node:path'
|
|
14
|
+
import { parseProjectJson } from './json.js'
|
|
15
|
+
|
|
16
|
+
const PALETTES = new URL('./shotcraft/upstream/template/src/themes/palettes.json', import.meta.url)
|
|
17
|
+
|
|
18
|
+
// 兜底:注册表读不到时也能建工程。这套就是本片用的纸墨色。
|
|
19
|
+
const FALLBACK = {
|
|
20
|
+
'paper-ink': { page: '#EDE8DE', surface: '#F5F1E8', field: '#E4DED2', text: '#2A2724', muted: '#8C8375', accent: '#B23A2E', border: '#CFC7B8' },
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function paletteTable() {
|
|
24
|
+
try {
|
|
25
|
+
const table = JSON.parse(readFileSync(PALETTES, 'utf8'))
|
|
26
|
+
if (table && typeof table === 'object' && !Array.isArray(table)) return { ...FALLBACK, ...table }
|
|
27
|
+
} catch {
|
|
28
|
+
/* 读不到就用兜底 */
|
|
29
|
+
}
|
|
30
|
+
return { ...FALLBACK }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function listThemes() {
|
|
34
|
+
return Object.entries(paletteTable()).map(([name, tokens]) => ({ name, page: tokens.page, accent: tokens.accent }))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const HEX = /^#[0-9a-fA-F]{3,8}$/
|
|
38
|
+
|
|
39
|
+
// 也接受直接给一套色(对象),方便"这条片子就想要这个纸色"的一次性需求。
|
|
40
|
+
export function resolveTheme(input) {
|
|
41
|
+
if (input && typeof input === 'object' && !Array.isArray(input)) {
|
|
42
|
+
const tokens = normalizeTokens(input)
|
|
43
|
+
return { name: String(input.name || 'custom'), tokens, custom: true }
|
|
44
|
+
}
|
|
45
|
+
const name = String(input || '').trim()
|
|
46
|
+
if (!name) return null
|
|
47
|
+
const table = paletteTable()
|
|
48
|
+
const tokens = table[name]
|
|
49
|
+
if (!tokens) throw new Error('没有这套主题:' + name + '。可选:' + Object.keys(table).join('、'))
|
|
50
|
+
return { name, tokens: normalizeTokens(tokens) }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function normalizeTokens(input) {
|
|
54
|
+
const pick = (keys, fallback) => {
|
|
55
|
+
for (const key of keys) if (typeof input[key] === 'string' && HEX.test(input[key].trim())) return input[key].trim()
|
|
56
|
+
return fallback
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
page: pick(['page', 'paper', 'background', 'bg'], FALLBACK['paper-ink'].page),
|
|
60
|
+
surface: pick(['surface', 'card'], FALLBACK['paper-ink'].surface),
|
|
61
|
+
field: pick(['field', 'panel'], FALLBACK['paper-ink'].field),
|
|
62
|
+
text: pick(['text', 'ink', 'foreground', 'fg'], FALLBACK['paper-ink'].text),
|
|
63
|
+
muted: pick(['muted', 'dust', 'secondary'], FALLBACK['paper-ink'].muted),
|
|
64
|
+
accent: pick(['accent', 'stamp', 'highlight'], FALLBACK['paper-ink'].accent),
|
|
65
|
+
border: pick(['border', 'rule', 'line'], FALLBACK['paper-ink'].border),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const DEFAULT_FONTS = {
|
|
70
|
+
serif: '"Noto Serif SC", "Songti SC", "Source Han Serif SC", serif',
|
|
71
|
+
sans: '"Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
72
|
+
mono: '"JetBrains Mono", monospace',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 场景文件只认这几个名字:PAPER / INK / DUST / STAMP / SURFACE / FIELD / BORDER。
|
|
76
|
+
export function themeSource(theme, fonts = {}) {
|
|
77
|
+
const t = theme.tokens
|
|
78
|
+
const f = { ...DEFAULT_FONTS, ...fonts }
|
|
79
|
+
const fallback = (value, family, generic) => {
|
|
80
|
+
const text = String(value || DEFAULT_FONTS[generic === 'serif' ? 'serif' : 'sans'])
|
|
81
|
+
if (text.includes(family)) return text
|
|
82
|
+
return text.replace(/,?\s*(sans-serif|serif)\s*$/i, '') + ', "' + family + '", ' + generic
|
|
83
|
+
}
|
|
84
|
+
f.serif = fallback(f.serif, 'Noto Serif SC', 'serif')
|
|
85
|
+
f.sans = fallback(f.sans, 'Noto Sans SC', 'sans-serif')
|
|
86
|
+
const q = (value) => "'" + String(value).replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'"
|
|
87
|
+
return [
|
|
88
|
+
'// 主题:' + theme.name + '(由 motion_project 的 theme 参数生成,可以手改)',
|
|
89
|
+
'export const THEME_NAME = ' + q(theme.name),
|
|
90
|
+
'export const PAPER = ' + q(t.page) + ' // 纸',
|
|
91
|
+
'export const SURFACE = ' + q(t.surface),
|
|
92
|
+
'export const FIELD = ' + q(t.field),
|
|
93
|
+
'export const INK = ' + q(t.text) + ' // 墨',
|
|
94
|
+
'export const DUST = ' + q(t.muted) + ' // 次级文字',
|
|
95
|
+
'export const STAMP = ' + q(t.accent) + ' // 唯一的强调色',
|
|
96
|
+
'export const BORDER = ' + q(t.border),
|
|
97
|
+
'',
|
|
98
|
+
'export const SERIF = ' + q(f.serif),
|
|
99
|
+
'export const SANS = ' + q(f.sans),
|
|
100
|
+
'export const MONO = ' + q(f.mono),
|
|
101
|
+
'',
|
|
102
|
+
'export const TOKENS = ' + JSON.stringify(t, null, 2) + ' as const',
|
|
103
|
+
'',
|
|
104
|
+
].join('\n')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function writeTheme(dir, theme, fonts) {
|
|
108
|
+
writeFileSync(join(dir, 'theme.ts'), themeSource(theme, fonts), 'utf8')
|
|
109
|
+
writeFileSync(join(dir, 'theme.json'), JSON.stringify({ name: theme.name, tokens: theme.tokens, at: new Date().toISOString() }, null, 2) + '\n', 'utf8')
|
|
110
|
+
return { file: join(dir, 'theme.ts'), name: theme.name, tokens: theme.tokens }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function readTheme(dir) {
|
|
114
|
+
const file = join(dir, 'theme.json')
|
|
115
|
+
if (!existsSync(file)) return null
|
|
116
|
+
try {
|
|
117
|
+
return parseProjectJson(readFileSync(file, 'utf8'))
|
|
118
|
+
} catch {
|
|
119
|
+
return null
|
|
120
|
+
}
|
|
121
|
+
}
|