cuju-render 0.1.0__py3-none-any.whl
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.
- cuju/render/__init__.py +759 -0
- cuju/render/__main__.py +1065 -0
- cuju/render/_export/__init__.py +3 -0
- cuju/render/_export/feed.py +542 -0
- cuju/render/_export/sizes.py +157 -0
- cuju/render/_export/video.py +1618 -0
- cuju/render/_export/video_jobs.py +408 -0
- cuju/render/_format/__init__.py +3 -0
- cuju/render/_format/annotations.py +235 -0
- cuju/render/_format/codec.py +307 -0
- cuju/render/_format/keep.py +121 -0
- cuju/render/_format/recording.py +860 -0
- cuju/render/_format/writer.py +54 -0
- cuju/render/_guide/__init__.py +3 -0
- cuju/render/_guide/doctor.py +523 -0
- cuju/render/_guide/help.py +62 -0
- cuju/render/_guide/tutorial.py +254 -0
- cuju/render/_http/__init__.py +3 -0
- cuju/render/_http/commands.py +57 -0
- cuju/render/_http/headers.py +103 -0
- cuju/render/_http/launch.py +500 -0
- cuju/render/_http/launchers.py +408 -0
- cuju/render/_http/pwa.py +128 -0
- cuju/render/_http/server.py +2105 -0
- cuju/render/_http/window.py +360 -0
- cuju/render/_moments/__init__.py +3 -0
- cuju/render/_moments/captions.py +284 -0
- cuju/render/_moments/events.py +1123 -0
- cuju/render/_moments/search.py +694 -0
- cuju/render/_packages/__init__.py +3 -0
- cuju/render/_packages/glsl.py +746 -0
- cuju/render/_packages/loudness.py +334 -0
- cuju/render/_packages/pack.py +1959 -0
- cuju/render/_packages/presentation.py +1376 -0
- cuju/render/_packages/vocabulary.py +609 -0
- cuju/render/_playing/__init__.py +3 -0
- cuju/render/_playing/achievements.py +463 -0
- cuju/render/_playing/bench.py +609 -0
- cuju/render/_playing/challenges.py +1813 -0
- cuju/render/_playing/demo.py +323 -0
- cuju/render/_playing/draw.py +211 -0
- cuju/render/_playing/errors.py +20 -0
- cuju/render/_playing/game.py +645 -0
- cuju/render/_playing/limits.py +339 -0
- cuju/render/_playing/play.py +926 -0
- cuju/render/_playing/policy_worker.py +250 -0
- cuju/render/_playing/strict.py +810 -0
- cuju/render/_registry/__init__.py +3 -0
- cuju/render/_registry/clips.py +394 -0
- cuju/render/_registry/joints.py +108 -0
- cuju/render/_registry/teams.py +2058 -0
- cuju/render/_store/__init__.py +3 -0
- cuju/render/_store/home.py +70 -0
- cuju/render/_store/library.py +604 -0
- cuju/render/_store/samples.py +163 -0
- cuju/render/_text/__init__.py +3 -0
- cuju/render/_text/languages.py +637 -0
- cuju/render/_text/messages.py +1396 -0
- cuju/render/_tournaments/__init__.py +3 -0
- cuju/render/_tournaments/results.py +547 -0
- cuju/render/_tournaments/tournament.py +2742 -0
- cuju/render/_tournaments/tournament_cli.py +587 -0
- cuju/render/_tournaments/tournament_runner.py +1975 -0
- cuju/render/_version.py +6 -0
- cuju/render/_watch/__init__.py +3 -0
- cuju/render/_watch/grid.py +265 -0
- cuju/render/_watch/live.py +664 -0
- cuju/render/_watch/notebook.py +79 -0
- cuju/render/_watch/show.py +171 -0
- cuju/render/samples/sample-11v11.cjr +0 -0
- cuju/render/samples/sample-5v5.cjr +0 -0
- cuju/render/samples/teams/starter/main.py +33 -0
- cuju/render/scenarios/benchmark_full_game_11_vs_11_easy.py +46 -0
- cuju/render/scenarios/benchmark_full_game_11_vs_11_hard.py +46 -0
- cuju/render/scenarios/benchmark_full_game_11_vs_11_medium.py +46 -0
- cuju/render/scenarios/benchmark_full_game_5_vs_5_easy.py +34 -0
- cuju/render/scenarios/benchmark_full_game_5_vs_5_hard.py +34 -0
- cuju/render/scenarios/benchmark_full_game_5_vs_5_medium.py +34 -0
- cuju/render/web/assets/adboard_polygon.webp +0 -0
- cuju/render/web/assets/adboard_your_ad_here.webp +0 -0
- cuju/render/web/assets/animations/kaykit-rig-medium-combatmelee.glb +0 -0
- cuju/render/web/assets/animations/kaykit-rig-medium-general.glb +0 -0
- cuju/render/web/assets/animations/kaykit-rig-medium-movementadvanced.glb +0 -0
- cuju/render/web/assets/animations/kaykit-rig-medium-movementbasic.glb +0 -0
- cuju/render/web/assets/animations/kaykit-rig-medium-simulation.glb +0 -0
- cuju/render/web/assets/animations/kaykit-rig-medium-special.glb +0 -0
- cuju/render/web/assets/ball.glb +0 -0
- cuju/render/web/assets/challenges/3_vs_1_with_keeper.mp4 +0 -0
- cuju/render/web/assets/challenges/3_vs_1_with_keeper.webp +0 -0
- cuju/render/web/assets/challenges/corner.mp4 +0 -0
- cuju/render/web/assets/challenges/corner.webp +0 -0
- cuju/render/web/assets/challenges/counterattack_easy.mp4 +0 -0
- cuju/render/web/assets/challenges/counterattack_easy.webp +0 -0
- cuju/render/web/assets/challenges/counterattack_hard.mp4 +0 -0
- cuju/render/web/assets/challenges/counterattack_hard.webp +0 -0
- cuju/render/web/assets/challenges/empty_goal.mp4 +0 -0
- cuju/render/web/assets/challenges/empty_goal.webp +0 -0
- cuju/render/web/assets/challenges/empty_goal_close.mp4 +0 -0
- cuju/render/web/assets/challenges/empty_goal_close.webp +0 -0
- cuju/render/web/assets/challenges/manifest.json +375 -0
- cuju/render/web/assets/challenges/one_on_one.mp4 +0 -0
- cuju/render/web/assets/challenges/one_on_one.webp +0 -0
- cuju/render/web/assets/challenges/one_on_one_hard.mp4 +0 -0
- cuju/render/web/assets/challenges/one_on_one_hard.webp +0 -0
- cuju/render/web/assets/challenges/pass_and_shoot_with_keeper.mp4 +0 -0
- cuju/render/web/assets/challenges/pass_and_shoot_with_keeper.webp +0 -0
- cuju/render/web/assets/challenges/run_pass_and_shoot_with_keeper.mp4 +0 -0
- cuju/render/web/assets/challenges/run_pass_and_shoot_with_keeper.webp +0 -0
- cuju/render/web/assets/challenges/run_to_score.mp4 +0 -0
- cuju/render/web/assets/challenges/run_to_score.webp +0 -0
- cuju/render/web/assets/challenges/run_to_score_with_keeper.mp4 +0 -0
- cuju/render/web/assets/challenges/run_to_score_with_keeper.webp +0 -0
- cuju/render/web/assets/challenges/single_goal_versus_lazy.mp4 +0 -0
- cuju/render/web/assets/challenges/single_goal_versus_lazy.webp +0 -0
- cuju/render/web/assets/crowd.webp +0 -0
- cuju/render/web/assets/crowd_normal.webp +0 -0
- cuju/render/web/assets/cuju-logo-384.png +0 -0
- cuju/render/web/assets/cuju-logo.png +0 -0
- cuju/render/web/assets/cuju-logo.svg +46 -0
- cuju/render/web/assets/cuju-mark-light.svg +33 -0
- cuju/render/web/assets/cuju-mark.svg +33 -0
- cuju/render/web/assets/goal.glb +0 -0
- cuju/render/web/assets/grass.webp +0 -0
- cuju/render/web/assets/hair_black.png +0 -0
- cuju/render/web/assets/hair_blonde.png +0 -0
- cuju/render/web/assets/hair_brown.png +0 -0
- cuju/render/web/assets/hair_darkblonde.png +0 -0
- cuju/render/web/assets/hair_long01.glb +0 -0
- cuju/render/web/assets/hair_long02.glb +0 -0
- cuju/render/web/assets/hair_medium01.glb +0 -0
- cuju/render/web/assets/hair_red.png +0 -0
- cuju/render/web/assets/hair_short01.glb +0 -0
- cuju/render/web/assets/hair_short02.glb +0 -0
- cuju/render/web/assets/icons/cuju-192.png +0 -0
- cuju/render/web/assets/icons/cuju-512.png +0 -0
- cuju/render/web/assets/icons/cuju-maskable-512.png +0 -0
- cuju/render/web/assets/kit_goalkeeper.webp +0 -0
- cuju/render/web/assets/kit_mask.png +0 -0
- cuju/render/web/assets/kit_normal.webp +0 -0
- cuju/render/web/assets/manifest.json +601 -0
- cuju/render/web/assets/models/kaykit-barbarian.glb +0 -0
- cuju/render/web/assets/models/kaykit-barbarian.json +23 -0
- cuju/render/web/assets/models/kaykit-knight.glb +0 -0
- cuju/render/web/assets/models/kaykit-knight.json +23 -0
- cuju/render/web/assets/models/kaykit-mage.glb +0 -0
- cuju/render/web/assets/models/kaykit-mage.json +23 -0
- cuju/render/web/assets/models/kaykit-mannequin-medium.glb +0 -0
- cuju/render/web/assets/models/kaykit-mannequin-medium.json +23 -0
- cuju/render/web/assets/models/kaykit-ranger.glb +0 -0
- cuju/render/web/assets/models/kaykit-ranger.json +23 -0
- cuju/render/web/assets/models/kaykit-rogue-hooded.glb +0 -0
- cuju/render/web/assets/models/kaykit-rogue-hooded.json +23 -0
- cuju/render/web/assets/models/kaykit-rogue.glb +0 -0
- cuju/render/web/assets/models/kaykit-rogue.json +23 -0
- cuju/render/web/assets/models/kaykit-skeleton-mage.glb +0 -0
- cuju/render/web/assets/models/kaykit-skeleton-mage.json +23 -0
- cuju/render/web/assets/models/kaykit-skeleton-minion.glb +0 -0
- cuju/render/web/assets/models/kaykit-skeleton-minion.json +23 -0
- cuju/render/web/assets/models/kaykit-skeleton-rogue.glb +0 -0
- cuju/render/web/assets/models/kaykit-skeleton-rogue.json +23 -0
- cuju/render/web/assets/models/kaykit-skeleton-warrior.glb +0 -0
- cuju/render/web/assets/models/kaykit-skeleton-warrior.json +23 -0
- cuju/render/web/assets/pitch.webp +0 -0
- cuju/render/web/assets/pitch_normal.webp +0 -0
- cuju/render/web/assets/player.glb +0 -0
- cuju/render/web/assets/shoe.webp +0 -0
- cuju/render/web/assets/shoe_sole.png +0 -0
- cuju/render/web/assets/skin_01.png +0 -0
- cuju/render/web/assets/skin_02.png +0 -0
- cuju/render/web/assets/skin_03.png +0 -0
- cuju/render/web/assets/skin_04.png +0 -0
- cuju/render/web/assets/sounds/applause.ogg +0 -0
- cuju/render/web/assets/sounds/beach-wave-1.ogg +0 -0
- cuju/render/web/assets/sounds/beach-wave-2.ogg +0 -0
- cuju/render/web/assets/sounds/beach-wave-3.ogg +0 -0
- cuju/render/web/assets/sounds/beach-wave-4.ogg +0 -0
- cuju/render/web/assets/sounds/city-horn.ogg +0 -0
- cuju/render/web/assets/sounds/city-loop.ogg +0 -0
- cuju/render/web/assets/sounds/city-siren.ogg +0 -0
- cuju/render/web/assets/sounds/crowd-cheer.ogg +0 -0
- cuju/render/web/assets/sounds/crowd-loop.ogg +0 -0
- cuju/render/web/assets/sounds/crowd-ooh.ogg +0 -0
- cuju/render/web/assets/sounds/gulls.ogg +0 -0
- cuju/render/web/assets/sounds/neon-sting.ogg +0 -0
- cuju/render/web/assets/sounds/rain-loop.ogg +0 -0
- cuju/render/web/assets/sounds/sounds.json +46 -0
- cuju/render/web/assets/sounds/space-beep.ogg +0 -0
- cuju/render/web/assets/sounds/space-hum.ogg +0 -0
- cuju/render/web/assets/sounds/space-radio.ogg +0 -0
- cuju/render/web/assets/sounds/whistle-long.ogg +0 -0
- cuju/render/web/assets/sounds/whistle-short.ogg +0 -0
- cuju/render/web/assets/sounds/wind-loop.ogg +0 -0
- cuju/render/web/easy.css +357 -0
- cuju/render/web/export.html +23 -0
- cuju/render/web/feed.css +262 -0
- cuju/render/web/feed.html +28 -0
- cuju/render/web/flat.css +120 -0
- cuju/render/web/home.css +837 -0
- cuju/render/web/index.html +373 -0
- cuju/render/web/js/boot.js +50 -0
- cuju/render/web/js/broadcast/audio.js +2141 -0
- cuju/render/web/js/broadcast/celebrate.js +1238 -0
- cuju/render/web/js/broadcast/decisions.js +609 -0
- cuju/render/web/js/broadcast/hud.js +352 -0
- cuju/render/web/js/broadcast/show.js +3614 -0
- cuju/render/web/js/broadcast/transition.js +2231 -0
- cuju/render/web/js/broadcast/voices.js +153 -0
- cuju/render/web/js/capture.js +101 -0
- cuju/render/web/js/core/accessibility.js +90 -0
- cuju/render/web/js/core/api.js +429 -0
- cuju/render/web/js/core/comfort.js +135 -0
- cuju/render/web/js/core/i18n.js +705 -0
- cuju/render/web/js/core/icons.js +167 -0
- cuju/render/web/js/core/input-settings.js +156 -0
- cuju/render/web/js/core/keys.js +277 -0
- cuju/render/web/js/core/language-ui.js +125 -0
- cuju/render/web/js/core/menu.js +853 -0
- cuju/render/web/js/core/names.js +113 -0
- cuju/render/web/js/core/page-structure.js +110 -0
- cuju/render/web/js/core/scenarios.js +109 -0
- cuju/render/web/js/core/spoilers.js +236 -0
- cuju/render/web/js/core/typeahead.js +38 -0
- cuju/render/web/js/export/dom-picture.js +330 -0
- cuju/render/web/js/export/export-host.js +97 -0
- cuju/render/web/js/export/feed-dialog.js +191 -0
- cuju/render/web/js/export/feed-params.js +266 -0
- cuju/render/web/js/export/feed.js +363 -0
- cuju/render/web/js/export/mp4-mux.js +295 -0
- cuju/render/web/js/export/photo-core.js +313 -0
- cuju/render/web/js/export/photo.js +1314 -0
- cuju/render/web/js/export/safe-frame.js +59 -0
- cuju/render/web/js/export/size-fields.js +103 -0
- cuju/render/web/js/export/sizes.js +178 -0
- cuju/render/web/js/export/video-boot.js +55 -0
- cuju/render/web/js/export/video-browser.js +325 -0
- cuju/render/web/js/export/video-export.js +417 -0
- cuju/render/web/js/export/video-plan.js +207 -0
- cuju/render/web/js/export/video-range.js +185 -0
- cuju/render/web/js/export/webm-mux.js +198 -0
- cuju/render/web/js/feed-boot.js +151 -0
- cuju/render/web/js/feed-frame.js +101 -0
- cuju/render/web/js/help/doctor.js +488 -0
- cuju/render/web/js/help/firstrun.js +379 -0
- cuju/render/web/js/help/help-center.js +438 -0
- cuju/render/web/js/help/install-offer.js +164 -0
- cuju/render/web/js/help/install-state.js +104 -0
- cuju/render/web/js/help/lessons-core.js +207 -0
- cuju/render/web/js/help/lessons.js +463 -0
- cuju/render/web/js/help/palette.js +584 -0
- cuju/render/web/js/help/pwa.js +257 -0
- cuju/render/web/js/help/tour-core.js +241 -0
- cuju/render/web/js/help/tour.js +461 -0
- cuju/render/web/js/main.js +2513 -0
- cuju/render/web/js/pages/draw.js +188 -0
- cuju/render/web/js/pages/fieldpage.js +530 -0
- cuju/render/web/js/pages/home.js +521 -0
- cuju/render/web/js/pages/matches.js +779 -0
- cuju/render/web/js/pages/moments-ui.js +359 -0
- cuju/render/web/js/pages/queue-filters.js +63 -0
- cuju/render/web/js/pages/recording-groups.js +80 -0
- cuju/render/web/js/pages/recordings.js +1069 -0
- cuju/render/web/js/play/bench.js +347 -0
- cuju/render/web/js/play/challenges.js +1302 -0
- cuju/render/web/js/play/medals.js +127 -0
- cuju/render/web/js/play/play.js +1953 -0
- cuju/render/web/js/play/teasers.js +196 -0
- cuju/render/web/js/play/touch.js +350 -0
- cuju/render/web/js/play/tournament-layout.js +487 -0
- cuju/render/web/js/play/tournament-results.js +441 -0
- cuju/render/web/js/play/tournament-strict.js +560 -0
- cuju/render/web/js/play/tournament.js +2585 -0
- cuju/render/web/js/players/animate.js +972 -0
- cuju/render/web/js/players/clips.js +224 -0
- cuju/render/web/js/players/kaykit.js +162 -0
- cuju/render/web/js/players/kits.js +676 -0
- cuju/render/web/js/players/number-patch.js +82 -0
- cuju/render/web/js/players/players.js +2694 -0
- cuju/render/web/js/players/recolor.js +893 -0
- cuju/render/web/js/players/retarget.js +325 -0
- cuju/render/web/js/players/rig-numbers.js +174 -0
- cuju/render/web/js/presentation/animator.js +231 -0
- cuju/render/web/js/presentation/assign.js +85 -0
- cuju/render/web/js/presentation/behaviors.js +440 -0
- cuju/render/web/js/presentation/budget.js +209 -0
- cuju/render/web/js/presentation/catalog.js +1674 -0
- cuju/render/web/js/presentation/clocks.js +72 -0
- cuju/render/web/js/presentation/commands.js +301 -0
- cuju/render/web/js/presentation/contract.js +240 -0
- cuju/render/web/js/presentation/effects.js +904 -0
- cuju/render/web/js/presentation/flash.js +605 -0
- cuju/render/web/js/presentation/freeze-worklet.js +22 -0
- cuju/render/web/js/presentation/glsl.js +464 -0
- cuju/render/web/js/presentation/host.js +323 -0
- cuju/render/web/js/presentation/index.js +2066 -0
- cuju/render/web/js/presentation/loudness-worklet.js +235 -0
- cuju/render/web/js/presentation/loudness.js +740 -0
- cuju/render/web/js/presentation/moments.js +536 -0
- cuju/render/web/js/presentation/post.js +327 -0
- cuju/render/web/js/presentation/preview.js +180 -0
- cuju/render/web/js/presentation/protocol.js +174 -0
- cuju/render/web/js/presentation/reach.js +158 -0
- cuju/render/web/js/presentation/rigging.js +130 -0
- cuju/render/web/js/presentation/sandbox.js +157 -0
- cuju/render/web/js/presentation/shaders.js +235 -0
- cuju/render/web/js/presentation/stage.js +402 -0
- cuju/render/web/js/presentation/teamaudio.js +722 -0
- cuju/render/web/js/presentation/tracks.js +197 -0
- cuju/render/web/js/presentation/values.js +81 -0
- cuju/render/web/js/recording/annotation-data.js +203 -0
- cuju/render/web/js/recording/captions.js +491 -0
- cuju/render/web/js/recording/codec.js +185 -0
- cuju/render/web/js/recording/decode-worker.js +70 -0
- cuju/render/web/js/recording/decode.js +94 -0
- cuju/render/web/js/recording/episodes.js +46 -0
- cuju/render/web/js/recording/format.js +461 -0
- cuju/render/web/js/recording/live.js +348 -0
- cuju/render/web/js/recording/moments-query.js +59 -0
- cuju/render/web/js/recording/moments.js +149 -0
- cuju/render/web/js/recording/pose.js +86 -0
- cuju/render/web/js/recording/timeline.js +275 -0
- cuju/render/web/js/teams/art.js +50 -0
- cuju/render/web/js/teams/clip-editor.js +293 -0
- cuju/render/web/js/teams/editor.js +1979 -0
- cuju/render/web/js/teams/library.js +344 -0
- cuju/render/web/js/teams/painter.js +633 -0
- cuju/render/web/js/teams/surprise-ui.js +195 -0
- cuju/render/web/js/teams/surprise.js +497 -0
- cuju/render/web/js/teams/team-check.js +127 -0
- cuju/render/web/js/watch/annotations.js +270 -0
- cuju/render/web/js/watch/flat.js +366 -0
- cuju/render/web/js/watch/grid.js +436 -0
- cuju/render/web/js/watch/pitch2d.js +289 -0
- cuju/render/web/js/watch/player-tools.js +192 -0
- cuju/render/web/js/watch/presets.js +201 -0
- cuju/render/web/js/world/arenas.js +997 -0
- cuju/render/web/js/world/ball.js +204 -0
- cuju/render/web/js/world/cameras.js +982 -0
- cuju/render/web/js/world/crowd.js +376 -0
- cuju/render/web/js/world/field.js +227 -0
- cuju/render/web/js/world/framing.js +145 -0
- cuju/render/web/js/world/occlusion.js +48 -0
- cuju/render/web/js/world/pitch.js +703 -0
- cuju/render/web/js/world/scene.js +395 -0
- cuju/render/web/js/world/sky.js +325 -0
- cuju/render/web/js/world/stadium.js +1262 -0
- cuju/render/web/js/world/vendor-sky.js +367 -0
- cuju/render/web/js/world/weather.js +264 -0
- cuju/render/web/languages/en.json +4750 -0
- cuju/render/web/lessons.json +137 -0
- cuju/render/web/manifest.webmanifest +23 -0
- cuju/render/web/style.css +8399 -0
- cuju/render/web/sw.js +235 -0
- cuju/render/web/vendor/fabric/LICENSE +16 -0
- cuju/render/web/vendor/fabric/fabric.min.mjs +1 -0
- cuju/render/web/vendor/lucide/LICENSE +43 -0
- cuju/render/web/vendor/lucide/icons.js +141 -0
- cuju/render/web/vendor/three/LICENSE +21 -0
- cuju/render/web/vendor/three/build/three.core.js +60586 -0
- cuju/render/web/vendor/three/build/three.module.js +19719 -0
- cuju/render/web/vendor/three/examples/jsm/loaders/GLTFLoader.js +4925 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/EffectComposer.js +365 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/OutputPass.js +148 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/RenderPass.js +193 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
- cuju/render/web/vendor/three/examples/jsm/postprocessing/UnrealBloomPass.js +541 -0
- cuju/render/web/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
- cuju/render/web/vendor/three/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
- cuju/render/web/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
- cuju/render/web/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1501 -0
- cuju/render/web/vendor/three/examples/jsm/utils/SkeletonUtils.js +496 -0
- cuju_render-0.1.0.dist-info/METADATA +116 -0
- cuju_render-0.1.0.dist-info/RECORD +382 -0
- cuju_render-0.1.0.dist-info/WHEEL +4 -0
- cuju_render-0.1.0.dist-info/licenses/LICENSE +202 -0
- cuju_render-0.1.0.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
- cuju_render-0.1.0.dist-info/licenses/LICENSES/CC0-1.0.txt +127 -0
- cuju_render-0.1.0.dist-info/licenses/LICENSES/ISC.txt +16 -0
- cuju_render-0.1.0.dist-info/licenses/LICENSES/MIT.txt +24 -0
- cuju_render-0.1.0.dist-info/licenses/LICENSES/Unlicense.txt +13 -0
- cuju_render-0.1.0.dist-info/licenses/NOTICE +35 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
// Copyright 2026 The cuju Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Text captions of the events of a match, short and plain, such as "Goal, number 9 of Greens,
|
|
5
|
+
// 2 to 1", timed to the moments of moments.js. Every caption is a message id of the
|
|
6
|
+
// language files, `caption.goal` and the rest, with its values, so the captions follow the
|
|
7
|
+
// language of the page. The server writes
|
|
8
|
+
// the same cues as WebVTT with src/cuju/render/_moments/captions.py, by the same rules.
|
|
9
|
+
//
|
|
10
|
+
// The functions at the top touch nothing of the page, so they hold the same under Node. The
|
|
11
|
+
// overlay at the end shows the cues on Watch and Play, inside the safe areas, and reads each new
|
|
12
|
+
// cue to screen readers through a live region.
|
|
13
|
+
|
|
14
|
+
import { messages as languageMessages, t, tn } from '../core/i18n.js';
|
|
15
|
+
import { momentsOf } from './moments.js';
|
|
16
|
+
import { teamName as shownTeamName } from '../core/names.js';
|
|
17
|
+
|
|
18
|
+
// Seconds a cue stays at most, at least, and how many show at once.
|
|
19
|
+
export const CUE_SECONDS = 4;
|
|
20
|
+
export const MIN_CUE_SECONDS = 1.5;
|
|
21
|
+
export const SHOWN = 3;
|
|
22
|
+
export const SIZES = Object.freeze(['small', 'medium', 'large']);
|
|
23
|
+
// Steps a growing live store holds back, so the moments of its newest steps settle first.
|
|
24
|
+
export const LIVE_HOLD_STEPS = 30;
|
|
25
|
+
// Steps the overlay reads in one drawing, so a long recording costs no visible pause.
|
|
26
|
+
export const CHUNK_STEPS = 400;
|
|
27
|
+
|
|
28
|
+
const RESTARTS = new Set(['corner', 'free_kick', 'penalty', 'throw_in', 'goal_kick']);
|
|
29
|
+
|
|
30
|
+
// The text of a message with its values put in place of the names in braces.
|
|
31
|
+
export function format(messages, id, params = {}) {
|
|
32
|
+
const template = messages[id];
|
|
33
|
+
if (typeof template !== 'string') {
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
return template.replace(/\{([A-Za-z]+)\}/g, (whole, name) => (params[name] === undefined ? whole : String(params[name])));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The names of the teams and the number and roster name of every player, from a header and the
|
|
40
|
+
// styles of its teams, which hold the rosters. A player without a roster entry wears 1 in goal
|
|
41
|
+
// and one more than the index of the team otherwise, as the kits do.
|
|
42
|
+
export function captionContext(header, styles = []) {
|
|
43
|
+
const teams = [0, 1].map((side) => {
|
|
44
|
+
const name = shownTeamName((header.teams || [])[side]).trim();
|
|
45
|
+
return name || null;
|
|
46
|
+
});
|
|
47
|
+
const players = (header.players || []).map((p) => {
|
|
48
|
+
const style = styles[p.team] || (((header.teams || [])[p.team] || {}).style) || {};
|
|
49
|
+
const roster = Array.isArray(style.players) ? style.players[p.index] : null;
|
|
50
|
+
const entry = roster && typeof roster === 'object' ? roster : null;
|
|
51
|
+
let number = p.goalkeeper ? 1 : p.index + 1;
|
|
52
|
+
if (entry) {
|
|
53
|
+
number = Number.isInteger(entry.number) && entry.number >= 0 && entry.number <= 99 ? entry.number : p.index + 1;
|
|
54
|
+
}
|
|
55
|
+
const name = entry && typeof entry.name === 'string' ? entry.name.slice(0, 24).trim() : '';
|
|
56
|
+
return { team: p.team, number, name };
|
|
57
|
+
});
|
|
58
|
+
return { teams, players };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function teamName(messages, context, side) {
|
|
62
|
+
const name = context.teams[side];
|
|
63
|
+
return name || format(messages, side === 0 ? 'caption.side.left' : 'caption.side.right');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function playerPhrase(messages, context, k) {
|
|
67
|
+
const p = context.players[k];
|
|
68
|
+
if (!p) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return p.name ? format(messages, 'caption.player.named', { number: p.number, name: p.name })
|
|
72
|
+
: format(messages, 'caption.player', { number: p.number });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The message id and values of the caption of a moment, or null for a moment without one,
|
|
76
|
+
// such as a pass or a change of possession.
|
|
77
|
+
export function captionOf(moment, context, messages) {
|
|
78
|
+
const d = moment.data || {};
|
|
79
|
+
const k = moment.player;
|
|
80
|
+
const known = k != null && context.players[k] != null;
|
|
81
|
+
const player = known ? playerPhrase(messages, context, k) : null;
|
|
82
|
+
const team = moment.team != null ? teamName(messages, context, moment.team) : null;
|
|
83
|
+
const of = known ? teamName(messages, context, context.players[k].team) : null;
|
|
84
|
+
const score = Array.isArray(d.score) ? { left: d.score[0], right: d.score[1] } : {};
|
|
85
|
+
switch (moment.kind) {
|
|
86
|
+
case 'goal':
|
|
87
|
+
if (d.ownGoal && known) {
|
|
88
|
+
return { id: 'caption.goal.own', params: { player, otherTeam: of, ...score } };
|
|
89
|
+
}
|
|
90
|
+
if (known) {
|
|
91
|
+
return { id: 'caption.goal', params: { player, team, ...score } };
|
|
92
|
+
}
|
|
93
|
+
return team ? { id: 'caption.goal.team', params: { team, ...score } } : null;
|
|
94
|
+
case 'shot':
|
|
95
|
+
return known ? { id: d.header ? 'caption.shot.header' : 'caption.shot', params: { player, team: of } } : null;
|
|
96
|
+
case 'save':
|
|
97
|
+
case 'block':
|
|
98
|
+
case 'tackle':
|
|
99
|
+
case 'foul':
|
|
100
|
+
case 'offside':
|
|
101
|
+
return known ? { id: `caption.${moment.kind}`, params: { player, team: of } } : null;
|
|
102
|
+
case 'card': {
|
|
103
|
+
if (!known) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const id = d.colour === 'red' ? (d.second ? 'caption.card.secondYellow' : 'caption.card.red') : 'caption.card.yellow';
|
|
107
|
+
return { id, params: { player, team: of } };
|
|
108
|
+
}
|
|
109
|
+
case 'woodwork':
|
|
110
|
+
return { id: d.part === 'bar' ? 'caption.woodwork.bar' : 'caption.woodwork.post', params: {} };
|
|
111
|
+
case 'nearMiss':
|
|
112
|
+
return { id: d.line === 'over' ? 'caption.nearMiss.over' : 'caption.nearMiss.wide', params: {} };
|
|
113
|
+
case 'restart':
|
|
114
|
+
return RESTARTS.has(d.restart) && team ? { id: `caption.restart.${d.restart}`, params: { team } } : null;
|
|
115
|
+
case 'halftime':
|
|
116
|
+
return { id: 'caption.halftime', params: score };
|
|
117
|
+
case 'fulltime':
|
|
118
|
+
return d.winner === 0 || d.winner === 1
|
|
119
|
+
? { id: 'caption.fulltime.win', params: { team: teamName(messages, context, d.winner), ...score } }
|
|
120
|
+
: { id: 'caption.fulltime.draw', params: score };
|
|
121
|
+
default:
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// The cues of moments, each with its start and end in seconds of the timeline, its message id
|
|
127
|
+
// and values, its text and the id of its moment, in the order of their starts. A cue lasts four
|
|
128
|
+
// seconds, or until the next cue starts, and at least a second and a half.
|
|
129
|
+
export function cuesOf(moments, context, messages) {
|
|
130
|
+
const cues = [];
|
|
131
|
+
for (const moment of moments) {
|
|
132
|
+
const caption = captionOf(moment, context, messages);
|
|
133
|
+
if (caption) {
|
|
134
|
+
cues.push({
|
|
135
|
+
start: moment.t, end: 0, id: caption.id, params: caption.params,
|
|
136
|
+
text: format(messages, caption.id, caption.params), kind: moment.kind, moment: moment.id,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
cues.sort((a, b) => a.start - b.start);
|
|
141
|
+
timeCues(cues);
|
|
142
|
+
return cues;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function timeCues(cues, from = 0) {
|
|
146
|
+
for (let i = from; i < cues.length; i++) {
|
|
147
|
+
const next = i + 1 < cues.length ? cues[i + 1].start : Infinity;
|
|
148
|
+
cues[i].end = Math.max(cues[i].start + MIN_CUE_SECONDS, Math.min(cues[i].start + CUE_SECONDS, next));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// A time of a WebVTT file, hours, minutes, seconds and milliseconds.
|
|
153
|
+
export function vttTime(seconds) {
|
|
154
|
+
const ms = Math.floor(Math.max(0, seconds) * 1000 + 0.5);
|
|
155
|
+
const pad = (x, n = 2) => String(x).padStart(n, '0');
|
|
156
|
+
return `${pad(Math.floor(ms / 3600000))}:${pad(Math.floor(ms / 60000) % 60)}:${pad(Math.floor(ms / 1000) % 60)}.${pad(ms % 1000, 3)}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// The text of a cue as a WebVTT file holds it, on one line with its markup escaped. Each line
|
|
160
|
+
// break, with the spaces around it, becomes one space, so a name can neither end the cue nor
|
|
161
|
+
// start another, and the ampersand and the angle brackets become their character references,
|
|
162
|
+
// which also turns an arrow of a time line into text.
|
|
163
|
+
export function vttText(text) {
|
|
164
|
+
return String(text ?? '').replace(/\s*[\r\n]+\s*/g, ' ').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// The cues as a WebVTT file.
|
|
168
|
+
export function toVtt(cues) {
|
|
169
|
+
const lines = ['WEBVTT', ''];
|
|
170
|
+
cues.forEach((cue, i) => {
|
|
171
|
+
lines.push(String(i + 1), `${vttTime(cue.start)} --> ${vttTime(cue.end)}`, vttText(cue.text), '');
|
|
172
|
+
});
|
|
173
|
+
return lines.join('\n');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// The cues that show at time now, the newest last, at most SHOWN of them.
|
|
177
|
+
export function activeCues(cues, now) {
|
|
178
|
+
const out = [];
|
|
179
|
+
for (const cue of cues) {
|
|
180
|
+
if (cue.start > now) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
if (now < cue.end) {
|
|
184
|
+
out.push(cue);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return out.slice(-SHOWN);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// The cues whose start forward play crossed from then to now.
|
|
191
|
+
export function crossedCues(cues, then, now) {
|
|
192
|
+
return cues.filter((cue) => cue.start > then && cue.start <= now);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// The cues of one store as it grows, every step of a recording, and for a live store the steps
|
|
196
|
+
// that have settled, extended as frames arrive. A track reads at most chunk steps at a time.
|
|
197
|
+
export class CueTrack {
|
|
198
|
+
constructor(store, context, messages, live = false, chunk = Infinity) {
|
|
199
|
+
this.store = store;
|
|
200
|
+
this.context = context;
|
|
201
|
+
this.messages = messages;
|
|
202
|
+
this.live = live;
|
|
203
|
+
this.done = store.first - 1;
|
|
204
|
+
this.cues = [];
|
|
205
|
+
this.extend(chunk);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// The last step whose moments have settled.
|
|
209
|
+
get settled() {
|
|
210
|
+
return this.live ? this.store.last - LIVE_HOLD_STEPS : this.store.last;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Whether steps that have settled wait to be read.
|
|
214
|
+
get pending() {
|
|
215
|
+
return this.done < this.settled;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Reads the moments of up to steps more of the steps that settled since the last call.
|
|
219
|
+
extend(steps = Infinity) {
|
|
220
|
+
const store = this.store;
|
|
221
|
+
const from = Math.max(this.done + 1, store.first);
|
|
222
|
+
const to = Math.min(this.settled, from + steps - 1);
|
|
223
|
+
if (to < from) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const added = cuesOf(momentsOf(store, from, to), this.context, this.messages);
|
|
227
|
+
this.done = to;
|
|
228
|
+
if (!added.length) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
this.cues.push(...added);
|
|
232
|
+
this.cues.sort((a, b) => a.start - b.start);
|
|
233
|
+
timeCues(this.cues);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// The caption messages of the page, in its language with English beneath.
|
|
238
|
+
export function loadMessages() {
|
|
239
|
+
return Promise.resolve(languageMessages('caption.'));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function load(key, fallback) {
|
|
243
|
+
try {
|
|
244
|
+
const v = localStorage.getItem(`cuju.${key}`);
|
|
245
|
+
return v === null ? fallback : JSON.parse(v);
|
|
246
|
+
} catch {
|
|
247
|
+
return fallback;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function save(key, value) {
|
|
252
|
+
try {
|
|
253
|
+
localStorage.setItem(`cuju.${key}`, JSON.stringify(value));
|
|
254
|
+
} catch {
|
|
255
|
+
// Storage can be unavailable, the setting then lasts for this visit only.
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// The captions over the view of Watch and Play. The setting turns them on or off and picks a
|
|
260
|
+
// size, and the browser keeps both. Each new cue that forward play reaches goes to a live
|
|
261
|
+
// region, so a screen reader reads it once, and the cues of the moment show above the controls.
|
|
262
|
+
export class CaptionsOverlay {
|
|
263
|
+
constructor(app) {
|
|
264
|
+
this.app = app;
|
|
265
|
+
this.enabled = load('captions', false) === true;
|
|
266
|
+
this.size = SIZES.includes(load('captionSize', 'medium')) ? load('captionSize', 'medium') : 'medium';
|
|
267
|
+
this.messages = null;
|
|
268
|
+
this.track = null;
|
|
269
|
+
this.store = null;
|
|
270
|
+
this.last = null;
|
|
271
|
+
this.seekedTo = null;
|
|
272
|
+
this.shown = '';
|
|
273
|
+
this.spoken = { track: null, ids: new Set() };
|
|
274
|
+
this.box = document.createElement('div');
|
|
275
|
+
this.box.className = 'captions';
|
|
276
|
+
this.box.id = 'captions';
|
|
277
|
+
this.box.hidden = true;
|
|
278
|
+
this.box.setAttribute('aria-hidden', 'true');
|
|
279
|
+
this.live = document.createElement('div');
|
|
280
|
+
this.live.className = 'sr-only';
|
|
281
|
+
this.live.id = 'captions-live';
|
|
282
|
+
this.live.setAttribute('aria-live', 'polite');
|
|
283
|
+
this.live.setAttribute('role', 'log');
|
|
284
|
+
this.live.setAttribute('aria-label', t('captions.live'));
|
|
285
|
+
this.applySize();
|
|
286
|
+
this.addSettings();
|
|
287
|
+
loadMessages().then((messages) => {
|
|
288
|
+
this.messages = messages;
|
|
289
|
+
}).catch(() => {
|
|
290
|
+
this.messages = null;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
addSettings() {
|
|
295
|
+
const anchor = document.getElementById('labels-on') || document.getElementById('trail');
|
|
296
|
+
const label = anchor && anchor.closest('label');
|
|
297
|
+
if (!label) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const check = document.createElement('input');
|
|
301
|
+
check.type = 'checkbox';
|
|
302
|
+
check.id = 'captions-on';
|
|
303
|
+
check.checked = this.enabled;
|
|
304
|
+
check.addEventListener('change', () => this.setEnabled(check.checked));
|
|
305
|
+
const row = document.createElement('label');
|
|
306
|
+
row.className = 'check';
|
|
307
|
+
row.append(...tn('captions.settings.on', { check }));
|
|
308
|
+
const size = document.createElement('select');
|
|
309
|
+
size.id = 'captions-size';
|
|
310
|
+
for (const value of SIZES) {
|
|
311
|
+
const option = document.createElement('option');
|
|
312
|
+
option.value = value;
|
|
313
|
+
option.textContent = t(`captions.size.${value}`);
|
|
314
|
+
size.append(option);
|
|
315
|
+
}
|
|
316
|
+
size.value = this.size;
|
|
317
|
+
size.addEventListener('change', () => this.setSize(size.value));
|
|
318
|
+
const sizeRow = document.createElement('label');
|
|
319
|
+
sizeRow.append(...tn('captions.settings.size', { size }));
|
|
320
|
+
label.after(row, sizeRow);
|
|
321
|
+
this.check = check;
|
|
322
|
+
this.select = size;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
setEnabled(on) {
|
|
326
|
+
this.enabled = !!on;
|
|
327
|
+
save('captions', this.enabled);
|
|
328
|
+
if (this.check) {
|
|
329
|
+
this.check.checked = this.enabled;
|
|
330
|
+
}
|
|
331
|
+
this.last = null;
|
|
332
|
+
this.render([]);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
setSize(size) {
|
|
336
|
+
this.size = SIZES.includes(size) ? size : 'medium';
|
|
337
|
+
save('captionSize', this.size);
|
|
338
|
+
if (this.select) {
|
|
339
|
+
this.select.value = this.size;
|
|
340
|
+
}
|
|
341
|
+
this.applySize();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
applySize() {
|
|
345
|
+
this.box.dataset.size = this.size;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// The cues of the open source, made when a source opens or its teams change.
|
|
349
|
+
trackFor(timeline) {
|
|
350
|
+
const app = this.app;
|
|
351
|
+
if (!this.messages || !timeline || !app.source || !app.source.header) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
const styles = app.styles || [];
|
|
355
|
+
const key = `${app.source.id || ''}:${styles.length}`;
|
|
356
|
+
if (!this.track || this.store !== timeline.store || this.key !== key) {
|
|
357
|
+
this.store = timeline.store;
|
|
358
|
+
this.key = key;
|
|
359
|
+
this.track = new CueTrack(timeline.store, captionContext(app.source.header, styles), this.messages,
|
|
360
|
+
!!timeline.live, CHUNK_STEPS);
|
|
361
|
+
} else if (this.track.pending) {
|
|
362
|
+
this.track.extend(CHUNK_STEPS);
|
|
363
|
+
}
|
|
364
|
+
return this.track;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// The cues of the open recording, every settled step read, for Save captions.
|
|
368
|
+
cues() {
|
|
369
|
+
const track = this.trackFor(this.app.timeline);
|
|
370
|
+
if (!track) {
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
track.extend();
|
|
374
|
+
return track.cues;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Saves the cues of the open recording as a WebVTT file, named after the recording, and
|
|
378
|
+
// returns its text. With save false it only returns the text.
|
|
379
|
+
download({ save = true } = {}) {
|
|
380
|
+
const app = this.app;
|
|
381
|
+
const cues = this.cues();
|
|
382
|
+
if (!this.messages || !app.source) {
|
|
383
|
+
if (app.hud) {
|
|
384
|
+
app.hud.toast(t('captions.notReady'), 'error');
|
|
385
|
+
}
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
const text = toVtt(cues);
|
|
389
|
+
if (!save) {
|
|
390
|
+
return text;
|
|
391
|
+
}
|
|
392
|
+
const name = `${String(app.source.id || 'recording').replace(/[^A-Za-z0-9_.-]+/g, '-')}.vtt`;
|
|
393
|
+
const url = URL.createObjectURL(new Blob([text], { type: 'text/vtt' }));
|
|
394
|
+
const link = document.createElement('a');
|
|
395
|
+
link.href = url;
|
|
396
|
+
link.download = name;
|
|
397
|
+
document.body.append(link);
|
|
398
|
+
link.click();
|
|
399
|
+
link.remove();
|
|
400
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
401
|
+
if (app.hud) {
|
|
402
|
+
app.hud.toast(t('captions.saved', { count: cues.length, name }));
|
|
403
|
+
}
|
|
404
|
+
return text;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Shows the cues of the drawn time and sends the new ones to the live region, on each frame.
|
|
408
|
+
update() {
|
|
409
|
+
const app = this.app;
|
|
410
|
+
const hud = document.getElementById('hud');
|
|
411
|
+
if (hud && hud.parentNode && this.box.parentNode !== hud.parentNode) {
|
|
412
|
+
hud.parentNode.insertBefore(this.box, hud.nextSibling);
|
|
413
|
+
hud.parentNode.insertBefore(this.live, this.box.nextSibling);
|
|
414
|
+
}
|
|
415
|
+
const tl = app.timeline;
|
|
416
|
+
const onStage = app.page === 'watch' || app.page === 'play';
|
|
417
|
+
if (!this.enabled || !onStage || !tl || !tl.store || tl.store.size === 0) {
|
|
418
|
+
this.last = null;
|
|
419
|
+
this.render([]);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
const track = this.trackFor(tl);
|
|
423
|
+
if (!track) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const now = tl.t / tl.sps;
|
|
427
|
+
if (this.seekedTo != null) {
|
|
428
|
+
// A seek counts the cues of the moment it lands on as read, and play from there reads
|
|
429
|
+
// the next ones, also when the first frame after it already passed their start.
|
|
430
|
+
this.spoken = { track, ids: new Set(activeCues(track.cues, this.seekedTo).map((cue) => cue.moment)) };
|
|
431
|
+
this.last = this.seekedTo;
|
|
432
|
+
this.seekedTo = null;
|
|
433
|
+
}
|
|
434
|
+
const then = this.last;
|
|
435
|
+
const wall = performance.now() / 1000;
|
|
436
|
+
const elapsed = this.lastWall == null ? 0 : wall - this.lastWall;
|
|
437
|
+
this.last = now;
|
|
438
|
+
this.lastWall = wall;
|
|
439
|
+
const active = activeCues(track.cues, now);
|
|
440
|
+
// Forward play reads each cue it reaches once, also one whose steps settled a moment
|
|
441
|
+
// after the view passed its start, and a seek, a reverse or a pause reads none. Play moves
|
|
442
|
+
// the view by the time that passed at its speed, so a slow page that draws seldom still
|
|
443
|
+
// plays forward, and only a jump beyond that is a seek.
|
|
444
|
+
const reach = Math.max(2, elapsed * Math.max(1, tl.speed || 1) + 0.5);
|
|
445
|
+
const forward = then != null && tl.playing && tl.direction > 0 && now >= then && now - then < reach;
|
|
446
|
+
if (this.spoken.track !== track || (!forward && then != null && Math.abs(now - then) > 0.5)) {
|
|
447
|
+
// After a seek the cues ahead are read again when play reaches them.
|
|
448
|
+
this.spoken = { track, ids: new Set(active.map((cue) => cue.moment)) };
|
|
449
|
+
}
|
|
450
|
+
for (const cue of active) {
|
|
451
|
+
if (!this.spoken.ids.has(cue.moment)) {
|
|
452
|
+
this.spoken.ids.add(cue.moment);
|
|
453
|
+
if (forward) {
|
|
454
|
+
this.announce(cue.text);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
this.render(active);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Called by the page after every seek, with the timeline already at its new place.
|
|
462
|
+
seeked() {
|
|
463
|
+
const tl = this.app.timeline;
|
|
464
|
+
this.seekedTo = tl ? tl.t / tl.sps : null;
|
|
465
|
+
this.lastWall = performance.now() / 1000;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
announce(text) {
|
|
469
|
+
const line = document.createElement('p');
|
|
470
|
+
line.textContent = text;
|
|
471
|
+
this.live.append(line);
|
|
472
|
+
while (this.live.childElementCount > 3) {
|
|
473
|
+
this.live.firstElementChild.remove();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
render(cues) {
|
|
478
|
+
const text = cues.map((cue) => cue.text).join('\n');
|
|
479
|
+
if (text === this.shown) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
this.shown = text;
|
|
483
|
+
this.box.replaceChildren(...cues.map((cue) => {
|
|
484
|
+
const line = document.createElement('span');
|
|
485
|
+
line.className = 'caption-line';
|
|
486
|
+
line.textContent = cue.text;
|
|
487
|
+
return line;
|
|
488
|
+
}));
|
|
489
|
+
this.box.hidden = !cues.length;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Copyright 2026 The cuju Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Decoder of the frames section of recording version 2, which yields the frames of version 1 bit
|
|
5
|
+
// for bit, as the section Recording format of docs/rendering.md describes it. Every product below
|
|
6
|
+
// is an integer under 2**53, so double precision computes it exactly, as the writer's integers do.
|
|
7
|
+
|
|
8
|
+
export const FRAMES_TAG = 'FRMS';
|
|
9
|
+
export const ANNOTATIONS_TAG = 'ANNO';
|
|
10
|
+
const UNIT = 32767;
|
|
11
|
+
const UNIT2 = UNIT * UNIT;
|
|
12
|
+
const JOINTS = 14;
|
|
13
|
+
const CHILDREN = JOINTS - 1;
|
|
14
|
+
const PARENTS = [-1, 0, 1, 2, 2, 4, 2, 6, 1, 8, 9, 1, 11, 12];
|
|
15
|
+
const HEAD_WORDS = 19;
|
|
16
|
+
const HEAD_BYTES = HEAD_WORDS * 4;
|
|
17
|
+
|
|
18
|
+
function padded(players) {
|
|
19
|
+
return (players + 3) & ~3;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function decodedFrameBytes(players) {
|
|
23
|
+
return HEAD_BYTES + players * JOINTS * 14 + 3 * padded(players);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The bytes of a frames section of count frames, which the header's frame_count gives.
|
|
27
|
+
export function sectionBytes(players, count) {
|
|
28
|
+
const short = players * (3 + 4 + 3 * CHILDREN + 3 * CHILDREN + 4 * CHILDREN + 3 * CHILDREN);
|
|
29
|
+
return count * (HEAD_BYTES + 2 * short + players * CHILDREN + 3 * padded(players));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isqrt(value) {
|
|
33
|
+
let root = Math.floor(Math.sqrt(value));
|
|
34
|
+
while (root * root > value) {
|
|
35
|
+
root--;
|
|
36
|
+
}
|
|
37
|
+
while ((root + 1) * (root + 1) <= value) {
|
|
38
|
+
root++;
|
|
39
|
+
}
|
|
40
|
+
return root;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Reads the lanes of a section. A lane holds one value per frame, zigzag coded, its low bytes in
|
|
44
|
+
// one plane and its high bytes in the next, and each kind of lane follows the one before. Each
|
|
45
|
+
// kind decodes at once into one array, lane after lane.
|
|
46
|
+
class Lanes {
|
|
47
|
+
constructor(bytes, count) {
|
|
48
|
+
this.bytes = bytes;
|
|
49
|
+
this.count = count;
|
|
50
|
+
this.at = 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Returns lanes of a width in bytes as signed values, or as bytes for a width of one.
|
|
54
|
+
take(lanes, width) {
|
|
55
|
+
const { bytes, count } = this;
|
|
56
|
+
const size = lanes * count;
|
|
57
|
+
const base = this.at;
|
|
58
|
+
this.at += size * width;
|
|
59
|
+
if (width === 1) {
|
|
60
|
+
return bytes.slice(base, base + size);
|
|
61
|
+
}
|
|
62
|
+
if (width === 2) {
|
|
63
|
+
const out = new Int16Array(size);
|
|
64
|
+
const high = base + size;
|
|
65
|
+
for (let i = 0; i < size; i++) {
|
|
66
|
+
const zigzag = bytes[base + i] | (bytes[high + i] << 8);
|
|
67
|
+
out[i] = (zigzag >>> 1) ^ -(zigzag & 1);
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
const out = new Int32Array(size);
|
|
72
|
+
for (let i = 0; i < size; i++) {
|
|
73
|
+
const zigzag = (bytes[base + i] | (bytes[base + size + i] << 8) | (bytes[base + 2 * size + i] << 16)
|
|
74
|
+
| (bytes[base + 3 * size + i] << 24)) >>> 0;
|
|
75
|
+
out[i] = (zigzag >>> 1) ^ -(zigzag & 1);
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Sums each lane from every keyframe on, in place, the typed array wrapping as the writer's does.
|
|
82
|
+
function sum(values, count, interval) {
|
|
83
|
+
for (let base = 0; base < values.length; base += count) {
|
|
84
|
+
for (let t = 1; t < count; t++) {
|
|
85
|
+
if (t % interval !== 0) {
|
|
86
|
+
values[base + t] += values[base + t - 1];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return values;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// XORs each lane of bytes from every keyframe on, in place.
|
|
94
|
+
function unxor(values, count, interval) {
|
|
95
|
+
for (let base = 0; base < values.length; base += count) {
|
|
96
|
+
for (let t = 1; t < count; t++) {
|
|
97
|
+
if (t % interval !== 0) {
|
|
98
|
+
values[base + t] ^= values[base + t - 1];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return values;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Decodes a frames section into the frames of version 1, back to back in one buffer.
|
|
106
|
+
export function decodeFrames(section, players, count, interval) {
|
|
107
|
+
const size = decodedFrameBytes(players);
|
|
108
|
+
const out = new ArrayBuffer(count * size);
|
|
109
|
+
const bytes = new Uint8Array(out);
|
|
110
|
+
const lanes = new Lanes(section, count);
|
|
111
|
+
const n = players;
|
|
112
|
+
const head = sum(lanes.take(HEAD_WORDS, 4), count, interval);
|
|
113
|
+
const rootPosition = sum(sum(lanes.take(3 * n, 2), count, interval), count, interval);
|
|
114
|
+
const rootRotation = sum(lanes.take(4 * n, 2), count, interval);
|
|
115
|
+
const turn = sum(lanes.take(3 * CHILDREN * n, 2), count, interval);
|
|
116
|
+
const sign = unxor(lanes.take(CHILDREN * n, 1), count, interval);
|
|
117
|
+
const offset = sum(lanes.take(3 * CHILDREN * n, 2), count, interval);
|
|
118
|
+
const rotationResidual = lanes.take(4 * CHILDREN * n, 2);
|
|
119
|
+
const positionResidual = lanes.take(3 * CHILDREN * n, 2);
|
|
120
|
+
const tailBytes = 3 * padded(n);
|
|
121
|
+
const tail = unxor(lanes.take(tailBytes, 1), count, interval);
|
|
122
|
+
const nodesEnd = HEAD_BYTES + n * JOINTS * 14;
|
|
123
|
+
const words = new Int32Array(out);
|
|
124
|
+
const nodes = new Int16Array(out);
|
|
125
|
+
for (let t = 0; t < count; t++) {
|
|
126
|
+
const frameAt = t * size;
|
|
127
|
+
for (let l = 0; l < HEAD_WORDS; l++) {
|
|
128
|
+
words[frameAt / 4 + l] = head[l * count + t];
|
|
129
|
+
}
|
|
130
|
+
for (let l = 0; l < tailBytes; l++) {
|
|
131
|
+
bytes[frameAt + nodesEnd + l] = tail[l * count + t];
|
|
132
|
+
}
|
|
133
|
+
for (let p = 0; p < n; p++) {
|
|
134
|
+
const root = (frameAt + HEAD_BYTES) / 2 + p * JOINTS * 7;
|
|
135
|
+
for (let c = 0; c < 3; c++) {
|
|
136
|
+
nodes[root + c] = rootPosition[(c * n + p) * count + t];
|
|
137
|
+
}
|
|
138
|
+
for (let c = 0; c < 4; c++) {
|
|
139
|
+
nodes[root + 3 + c] = rootRotation[(c * n + p) * count + t];
|
|
140
|
+
}
|
|
141
|
+
for (let j = 1; j < JOINTS; j++) {
|
|
142
|
+
const parent = root + PARENTS[j] * 7;
|
|
143
|
+
const at = root + j * 7;
|
|
144
|
+
const i = j - 1;
|
|
145
|
+
const x1 = nodes[parent + 3];
|
|
146
|
+
const y1 = nodes[parent + 4];
|
|
147
|
+
const z1 = nodes[parent + 5];
|
|
148
|
+
const w1 = nodes[parent + 6];
|
|
149
|
+
// The local rotation, its w from the unit length and the sign lane.
|
|
150
|
+
const lane = (i * 3 * n + p) * count + t;
|
|
151
|
+
const x2 = turn[lane];
|
|
152
|
+
const y2 = turn[lane + n * count];
|
|
153
|
+
const z2 = turn[lane + 2 * n * count];
|
|
154
|
+
let w2 = isqrt(Math.max(UNIT2 - x2 * x2 - y2 * y2 - z2 * z2, 0));
|
|
155
|
+
if (sign[(i * n + p) * count + t]) {
|
|
156
|
+
w2 = -w2;
|
|
157
|
+
}
|
|
158
|
+
const turned = (i * 4 * n + p) * count + t;
|
|
159
|
+
const step = n * count;
|
|
160
|
+
nodes[at + 3] = Math.floor((2 * (w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2) + UNIT) / (2 * UNIT))
|
|
161
|
+
+ rotationResidual[turned];
|
|
162
|
+
nodes[at + 4] = Math.floor((2 * (w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2) + UNIT) / (2 * UNIT))
|
|
163
|
+
+ rotationResidual[turned + step];
|
|
164
|
+
nodes[at + 5] = Math.floor((2 * (w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2) + UNIT) / (2 * UNIT))
|
|
165
|
+
+ rotationResidual[turned + 2 * step];
|
|
166
|
+
nodes[at + 6] = Math.floor((2 * (w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2) + UNIT) / (2 * UNIT))
|
|
167
|
+
+ rotationResidual[turned + 3 * step];
|
|
168
|
+
// The offset in the parent's frame, turned by the parent's rotation.
|
|
169
|
+
const ox = offset[lane];
|
|
170
|
+
const oy = offset[lane + step];
|
|
171
|
+
const oz = offset[lane + 2 * step];
|
|
172
|
+
const tx = y1 * oz - z1 * oy;
|
|
173
|
+
const ty = z1 * ox - x1 * oz;
|
|
174
|
+
const tz = x1 * oy - y1 * ox;
|
|
175
|
+
nodes[at] = nodes[parent] + positionResidual[lane]
|
|
176
|
+
+ Math.floor((2 * (ox * UNIT2 + 2 * w1 * tx + 2 * (y1 * tz - z1 * ty)) + UNIT2) / (2 * UNIT2));
|
|
177
|
+
nodes[at + 1] = nodes[parent + 1] + positionResidual[lane + step]
|
|
178
|
+
+ Math.floor((2 * (oy * UNIT2 + 2 * w1 * ty + 2 * (z1 * tx - x1 * tz)) + UNIT2) / (2 * UNIT2));
|
|
179
|
+
nodes[at + 2] = nodes[parent + 2] + positionResidual[lane + 2 * step]
|
|
180
|
+
+ Math.floor((2 * (oz * UNIT2 + 2 * w1 * tz + 2 * (x1 * ty - y1 * tx)) + UNIT2) / (2 * UNIT2));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|