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,429 @@
|
|
|
1
|
+
// Copyright 2026 The cuju Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// The client of the local server, for recordings in the format of the section Recording format of
|
|
5
|
+
// docs/rendering.md, live sources, teams with their styles, models and images, and folder uploads.
|
|
6
|
+
|
|
7
|
+
import { formatNumber, serverText, t, tOr } from './i18n.js';
|
|
8
|
+
import { summaryList } from './names.js';
|
|
9
|
+
import { hideSummaries, hideSummary } from './spoilers.js';
|
|
10
|
+
|
|
11
|
+
// An error of the server, whose message is in the language of the page when the server gives the
|
|
12
|
+
// id of its message, else the server's own English text. The id and values stay on the error.
|
|
13
|
+
export class ApiError extends Error {
|
|
14
|
+
constructor(message, status = 0, id = null, values = null) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.id = id;
|
|
18
|
+
this.values = values;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
|
|
23
|
+
export const MAX_MODEL_BYTES = 30 * 1024 * 1024;
|
|
24
|
+
|
|
25
|
+
async function request(method, path, { body, json, headers, timeout } = {}) {
|
|
26
|
+
let res;
|
|
27
|
+
const init = { method, headers: { ...(headers || {}) }, cache: 'no-store' };
|
|
28
|
+
if (timeout) {
|
|
29
|
+
init.signal = AbortSignal.timeout(timeout);
|
|
30
|
+
}
|
|
31
|
+
if (json !== undefined) {
|
|
32
|
+
init.body = JSON.stringify(json);
|
|
33
|
+
init.headers['Content-Type'] = 'application/json';
|
|
34
|
+
} else if (body !== undefined) {
|
|
35
|
+
init.body = body;
|
|
36
|
+
init.headers['Content-Type'] = init.headers['Content-Type'] || 'application/octet-stream';
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
res = await fetch(path, init);
|
|
40
|
+
} catch {
|
|
41
|
+
throw new ApiError(t('api.unreachable', { origin: location.origin }), 0);
|
|
42
|
+
}
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
let detail = '';
|
|
45
|
+
let id = null;
|
|
46
|
+
let values = null;
|
|
47
|
+
try {
|
|
48
|
+
const text = await res.text();
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(text);
|
|
51
|
+
detail = parsed.error ? serverText(parsed, 'error') : (parsed.message || text);
|
|
52
|
+
id = typeof parsed.error_id === 'string' ? parsed.error_id : null;
|
|
53
|
+
values = parsed.error_values && typeof parsed.error_values === 'object' ? parsed.error_values : null;
|
|
54
|
+
} catch {
|
|
55
|
+
detail = text;
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
detail = '';
|
|
59
|
+
}
|
|
60
|
+
throw new ApiError(detail ? `${detail}` : t('api.status', { status: res.status, text: res.statusText }), res.status, id, values);
|
|
61
|
+
}
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function getJson(path) {
|
|
66
|
+
return (await request('GET', path)).json();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const enc = encodeURIComponent;
|
|
70
|
+
|
|
71
|
+
export const api = {
|
|
72
|
+
// The lists hide the outcomes of the tournament matches that a person has not watched yet.
|
|
73
|
+
matches: async () => hideSummaries(summaryList(await getJson('/api/matches'))),
|
|
74
|
+
languages: () => getJson('/api/languages'),
|
|
75
|
+
importLanguage: async (document) => (await request('POST', '/api/languages', { json: document })).json(),
|
|
76
|
+
removeLanguage: async (code) => (await request('DELETE', `/api/languages/${enc(code)}`)).json(),
|
|
77
|
+
matchBytes: async (id, onProgress) => {
|
|
78
|
+
const res = await request('GET', `/api/matches/${enc(id)}`);
|
|
79
|
+
const total = Number(res.headers.get('Content-Length')) || 0;
|
|
80
|
+
if (!res.body || !onProgress) {
|
|
81
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
82
|
+
}
|
|
83
|
+
const reader = res.body.getReader();
|
|
84
|
+
const chunks = [];
|
|
85
|
+
let got = 0;
|
|
86
|
+
for (;;) {
|
|
87
|
+
const { done, value } = await reader.read();
|
|
88
|
+
if (done) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
chunks.push(value);
|
|
92
|
+
got += value.length;
|
|
93
|
+
onProgress(got, total);
|
|
94
|
+
}
|
|
95
|
+
const out = new Uint8Array(got);
|
|
96
|
+
let o = 0;
|
|
97
|
+
for (const c of chunks) {
|
|
98
|
+
out.set(c, o);
|
|
99
|
+
o += c.length;
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
},
|
|
103
|
+
// Deleting a recording moves it to the Trash, and only the Trash deletes one for good.
|
|
104
|
+
deleteMatch: (id) => request('DELETE', `/api/matches/${enc(id)}`),
|
|
105
|
+
matchDetails: async (id) => hideSummary(await getJson(`/api/matches/${enc(id)}/details`)),
|
|
106
|
+
trash: async () => hideSummaries(summaryList(await getJson('/api/trash'))),
|
|
107
|
+
restoreMatch: async (id) => (await request('POST', `/api/trash/${enc(id)}/restore`)).json(),
|
|
108
|
+
purgeMatch: (id) => request('DELETE', `/api/trash/${enc(id)}`),
|
|
109
|
+
patchMatch: async (id, changes) => (await request('PATCH', `/api/matches/${enc(id)}`, { json: changes })).json().catch(() => null),
|
|
110
|
+
live: () => getJson('/api/live'),
|
|
111
|
+
selectEnvironment: async (id, environment) => (await request('POST', `/api/live/${enc(id)}/environment`, { json: { environment } })).json(),
|
|
112
|
+
liveStream: (id, signal) => fetch(`/api/live/${enc(id)}/stream?sequence=1&annotations=1`, { signal, cache: 'no-store' }),
|
|
113
|
+
liveGrid: (id, first, count) => getJson(`/api/live/${enc(id)}/grid?first=${first}&count=${count}`),
|
|
114
|
+
info: () => getJson('/api/info'),
|
|
115
|
+
scenarios: () => getJson('/api/scenarios'),
|
|
116
|
+
// The players of both sides of every scenario, which tell the teams that can play a side.
|
|
117
|
+
scenarioSides: () => getJson('/api/scenarios/sides'),
|
|
118
|
+
teams: () => getJson('/api/teams'),
|
|
119
|
+
uploadTeam: async (name, filename, body, format, control = null) => {
|
|
120
|
+
let path = `/api/teams?name=${enc(name)}&filename=${enc(filename)}`;
|
|
121
|
+
if (format) path += `&format=${enc(format)}`;
|
|
122
|
+
if (control) path += `&control=${enc(JSON.stringify(control))}`;
|
|
123
|
+
return (await request('POST', path, { body })).json();
|
|
124
|
+
},
|
|
125
|
+
putImage: (id, slot, body, type) =>
|
|
126
|
+
request('PUT', `/api/teams/${enc(id)}/images/${enc(slot)}`, { body, headers: { 'Content-Type': type } }),
|
|
127
|
+
image: async (id, slot) => (await request('GET', `/api/teams/${enc(id)}/images/${enc(slot)}`)).blob(),
|
|
128
|
+
deleteImage: (id, slot) => request('DELETE', `/api/teams/${enc(id)}/images/${enc(slot)}`),
|
|
129
|
+
exportUrl: (id) => `/api/teams/${enc(id)}/export`,
|
|
130
|
+
updateTeam: async (id, changes) => (await request('PATCH', `/api/teams/${enc(id)}`, { json: changes })).json(),
|
|
131
|
+
deleteTeam: (id) => request('DELETE', `/api/teams/${enc(id)}`),
|
|
132
|
+
duplicateTeam: async (id) => (await request('POST', `/api/teams/${enc(id)}/duplicate`)).json(),
|
|
133
|
+
putModel: (id, joints, bytes) =>
|
|
134
|
+
request('PUT', `/api/teams/${enc(id)}/model?joints=${enc(JSON.stringify(joints))}`, { body: bytes }),
|
|
135
|
+
modelBytes: async (id) => (await request('GET', `/api/teams/${enc(id)}/model`)).arrayBuffer(),
|
|
136
|
+
deleteModel: (id) => request('DELETE', `/api/teams/${enc(id)}/model`),
|
|
137
|
+
models: () => getJson('/api/models'),
|
|
138
|
+
requests: () => getJson('/api/requests'),
|
|
139
|
+
requestMatch: async (spec) => (await request('POST', '/api/requests', { json: spec })).json(),
|
|
140
|
+
cancelRequest: (id) => request('DELETE', `/api/requests/${enc(id)}`),
|
|
141
|
+
// The game that a person plays, one at a time, its stream, its input, pause and quit.
|
|
142
|
+
game: () => getJson('/api/game'),
|
|
143
|
+
startGame: async (spec) => (await request('POST', '/api/game', { json: spec })).json(),
|
|
144
|
+
gameStream: (id, signal) => fetch(`/api/game/${enc(id)}/stream`, { signal, cache: 'no-store' }),
|
|
145
|
+
gameInput: async (id, input) => (await request('POST', `/api/game/${enc(id)}/input`, { json: input, timeout: 1500 })).json(),
|
|
146
|
+
pauseGame: async (id, paused) => (await request('POST', `/api/game/${enc(id)}/pause`, { json: { paused } })).json(),
|
|
147
|
+
quitGame: async (id) => (await request('DELETE', `/api/game/${enc(id)}`)).json(),
|
|
148
|
+
// Team sounds, Ogg, MP3 or WAV of at most MAX_SOUND_BYTES, one per slot of SOUND_SLOTS.
|
|
149
|
+
putSound: async (id, slot, body, type) =>
|
|
150
|
+
(await request('PUT', `/api/teams/${enc(id)}/sounds/${enc(slot)}`, { body, headers: { 'Content-Type': type || 'application/octet-stream' } })).json(),
|
|
151
|
+
soundBytes: async (id, slot) => (await request('GET', `/api/teams/${enc(id)}/sounds/${enc(slot)}`)).arrayBuffer(),
|
|
152
|
+
deleteSound: (id, slot) => request('DELETE', `/api/teams/${enc(id)}/sounds/${enc(slot)}`),
|
|
153
|
+
// Team celebration clips, binary glTF files of at most 10 MB, named by the page.
|
|
154
|
+
putClip: async (id, name, joints, bytes) => {
|
|
155
|
+
const query = joints && joints.body ? `?joints=${enc(JSON.stringify(joints))}` : '';
|
|
156
|
+
return (await request('PUT', `/api/teams/${enc(id)}/clips/${enc(name)}${query}`, { body: bytes })).json();
|
|
157
|
+
},
|
|
158
|
+
clipJoints: async (id, name, joints) => (await request('PATCH', `/api/teams/${enc(id)}/clips/${enc(name)}`, { json: { joints } })).json(),
|
|
159
|
+
clipBytes: async (id, name) => (await request('GET', `/api/teams/${enc(id)}/clips/${enc(name)}`)).arrayBuffer(),
|
|
160
|
+
deleteClip: (id, name) => request('DELETE', `/api/teams/${enc(id)}/clips/${enc(name)}`),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// The team setting travels as JSON through both forms.
|
|
164
|
+
export const CONTROLLABLE = { '5v5': 5, '11v11': 11 };
|
|
165
|
+
|
|
166
|
+
export function controlFromValue(value) {
|
|
167
|
+
if (value && typeof value === 'object') return structuredClone(value);
|
|
168
|
+
if (String(value).startsWith('{')) return JSON.parse(value);
|
|
169
|
+
const players = parseInt(value, 10) || 1;
|
|
170
|
+
const fixed = /-keeper$/.test(value);
|
|
171
|
+
return {
|
|
172
|
+
players, assignment: fixed ? 'fixed' : 'dynamic',
|
|
173
|
+
selection: fixed ? Array.from({ length: players }, (_, i) => i + 1) : [],
|
|
174
|
+
goalkeeper: fixed ? 'builtin' : 'scenario', action_set: 'default',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function controlValue(control) {
|
|
179
|
+
if (!control?.assignment) {
|
|
180
|
+
return JSON.stringify(controlFromValue(control?.goalkeeper === 'builtin'
|
|
181
|
+
? `${control.players}-keeper` : String(control?.players || 1)));
|
|
182
|
+
}
|
|
183
|
+
return JSON.stringify(control);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// The team setting in short, each value in the words of api.control.short.<field>.<value>, the
|
|
187
|
+
// value itself for one without words.
|
|
188
|
+
export function controlLabel(control) {
|
|
189
|
+
const c = controlFromValue(controlValue(control));
|
|
190
|
+
const values = {
|
|
191
|
+
players: c.players,
|
|
192
|
+
// The word of the assignment agrees with the number of players, as dinâmico or dinâmicos.
|
|
193
|
+
assignment: tOr(`api.control.short.assignment.${c.assignment}`, c.assignment, { count: c.players }),
|
|
194
|
+
selection: c.selection.join(', '),
|
|
195
|
+
goalkeeper: tOr(`api.control.short.goalkeeper.${c.goalkeeper}`, c.goalkeeper),
|
|
196
|
+
actionSet: tOr(`api.control.short.actionSet.${c.action_set}`, c.action_set),
|
|
197
|
+
};
|
|
198
|
+
return t(c.assignment === 'fixed' ? 'api.control.summary.fixed' : 'api.control.summary', values);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function controlForm(format, initial = null) {
|
|
202
|
+
const root = document.createElement('div');
|
|
203
|
+
let current = controlFromValue(controlValue(initial));
|
|
204
|
+
function field(label, choices = null) {
|
|
205
|
+
const row = document.createElement('label');
|
|
206
|
+
row.className = 'field';
|
|
207
|
+
row.append(document.createTextNode(label));
|
|
208
|
+
const input = document.createElement(choices ? 'select' : 'input');
|
|
209
|
+
for (const [value, text] of choices || []) {
|
|
210
|
+
const option = document.createElement('option');
|
|
211
|
+
option.value = value;
|
|
212
|
+
option.textContent = text;
|
|
213
|
+
input.append(option);
|
|
214
|
+
}
|
|
215
|
+
row.append(input);
|
|
216
|
+
root.append(row);
|
|
217
|
+
return input;
|
|
218
|
+
}
|
|
219
|
+
const count = field(t('api.control.count'));
|
|
220
|
+
count.type = 'number';
|
|
221
|
+
count.min = '1';
|
|
222
|
+
count.value = current.players;
|
|
223
|
+
const assignment = field(t('api.control.assignment'), [
|
|
224
|
+
['dynamic', t('api.control.assignment.dynamic')], ['fixed', t('api.control.assignment.fixed')],
|
|
225
|
+
]);
|
|
226
|
+
assignment.value = current.assignment;
|
|
227
|
+
const by = field(t('api.control.by'), [['index', t('api.control.by.index')], ['role', t('api.control.by.role')]]);
|
|
228
|
+
by.value = typeof current.selection[0] === 'string' ? 'role' : 'index';
|
|
229
|
+
const selection = field(t('api.control.selection'));
|
|
230
|
+
selection.value = current.selection.join(', ');
|
|
231
|
+
const goalkeeper = field(t('api.control.goalkeeper'), [
|
|
232
|
+
['agent', t('api.control.goalkeeper.agent')], ['builtin', t('api.control.goalkeeper.builtin')],
|
|
233
|
+
['scenario', t('api.control.goalkeeper.scenario')],
|
|
234
|
+
]);
|
|
235
|
+
goalkeeper.value = current.goalkeeper;
|
|
236
|
+
const actionSet = field(t('api.control.actionSet'), [
|
|
237
|
+
['default', t('api.control.actionSet.default')], ['v2', t('api.control.actionSet.v2')],
|
|
238
|
+
]);
|
|
239
|
+
actionSet.value = current.action_set;
|
|
240
|
+
const lineup = document.createElement('div');
|
|
241
|
+
lineup.className = 'lineup-picker';
|
|
242
|
+
lineup.setAttribute('role', 'group');
|
|
243
|
+
lineup.setAttribute('aria-label', t('api.control.lineup'));
|
|
244
|
+
root.append(lineup);
|
|
245
|
+
function update() {
|
|
246
|
+
const fixed = assignment.value === 'fixed';
|
|
247
|
+
by.disabled = selection.disabled = !fixed;
|
|
248
|
+
current = {
|
|
249
|
+
players: Number(count.value), assignment: assignment.value,
|
|
250
|
+
selection: fixed && selection.value.trim() ? selection.value.split(',').map(
|
|
251
|
+
(item) => by.value === 'role' ? item.trim().toUpperCase() : Number(item.trim())
|
|
252
|
+
) : [],
|
|
253
|
+
goalkeeper: goalkeeper.value, action_set: actionSet.value,
|
|
254
|
+
};
|
|
255
|
+
root.value = JSON.stringify(current);
|
|
256
|
+
const remainingRoles = [...current.selection];
|
|
257
|
+
for (const button of lineup.querySelectorAll('button')) {
|
|
258
|
+
const chosen = fixed && (by.value === 'index'
|
|
259
|
+
? current.selection.includes(Number(button.dataset.index))
|
|
260
|
+
: remainingRoles.includes(button.dataset.role));
|
|
261
|
+
if (chosen && by.value === 'role') {
|
|
262
|
+
remainingRoles.splice(remainingRoles.indexOf(button.dataset.role), 1);
|
|
263
|
+
}
|
|
264
|
+
button.setAttribute('aria-pressed', String(chosen));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
root.addEventListener('input', update);
|
|
268
|
+
root.addEventListener('change', update);
|
|
269
|
+
root.setFormat = (next) => {
|
|
270
|
+
count.max = CONTROLLABLE[next] || 11;
|
|
271
|
+
const roles = next === '5v5' ? ['GK', 'RM', 'CF', 'LB', 'CB']
|
|
272
|
+
: ['GK', 'LB', 'CB', 'CB', 'RB', 'CM', 'CM', 'CM', 'LM', 'CF', 'RM'];
|
|
273
|
+
lineup.replaceChildren(...roles.map((role, index) => {
|
|
274
|
+
const button = document.createElement('button');
|
|
275
|
+
button.type = 'button';
|
|
276
|
+
button.className = 'lineup-btn';
|
|
277
|
+
const number = document.createElement('span');
|
|
278
|
+
number.className = 'lineup-index';
|
|
279
|
+
number.textContent = String(index);
|
|
280
|
+
const name = document.createElement('span');
|
|
281
|
+
name.className = 'lineup-role';
|
|
282
|
+
name.textContent = role;
|
|
283
|
+
button.append(number, name);
|
|
284
|
+
button.setAttribute('aria-label', t('api.control.lineup.player', { index, role }));
|
|
285
|
+
button.setAttribute('aria-pressed', 'false');
|
|
286
|
+
button.dataset.index = String(index);
|
|
287
|
+
button.dataset.role = role;
|
|
288
|
+
button.disabled = next === '5v5' && index === 0;
|
|
289
|
+
button.addEventListener('click', () => {
|
|
290
|
+
const chosen = assignment.value !== 'fixed' ? [] : by.value === 'role'
|
|
291
|
+
? [...lineup.querySelectorAll('button[aria-pressed="true"]')].map(
|
|
292
|
+
(item) => item.dataset.index
|
|
293
|
+
) : selection.value.split(',').map((v) => v.trim()).filter(Boolean);
|
|
294
|
+
assignment.value = 'fixed';
|
|
295
|
+
by.value = 'index';
|
|
296
|
+
const value = String(index);
|
|
297
|
+
selection.value = chosen.includes(value)
|
|
298
|
+
? chosen.filter((v) => v !== value).join(', ') : [...chosen, value].join(', ');
|
|
299
|
+
count.value = selection.value.split(',').filter(Boolean).length || 1;
|
|
300
|
+
if (!selection.value) {
|
|
301
|
+
assignment.value = 'dynamic';
|
|
302
|
+
}
|
|
303
|
+
update();
|
|
304
|
+
root.dispatchEvent(new Event('change', { bubbles: true }));
|
|
305
|
+
});
|
|
306
|
+
return button;
|
|
307
|
+
}));
|
|
308
|
+
update();
|
|
309
|
+
};
|
|
310
|
+
root.setFormat(format);
|
|
311
|
+
return root;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export const SOUND_SLOTS = ['goal', 'shot', 'pass', 'tackle', 'save', 'kick', 'celebration', 'chant'];
|
|
315
|
+
export const MAX_SOUND_BYTES = 2 * 1024 * 1024;
|
|
316
|
+
|
|
317
|
+
// Files of a Kaggle submission folder without caches and dot files, paths with forward slashes.
|
|
318
|
+
export function keepFile(path) {
|
|
319
|
+
return !path.split('/').some((part) => part === '__pycache__' || part.startsWith('.'));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Packs files as CUJDIR1, the magic, a uint32 length, a JSON index, then the bytes in order.
|
|
323
|
+
export async function packFolder(files) {
|
|
324
|
+
const index = files.map((f) => ({ path: f.path, size: f.file.size }));
|
|
325
|
+
const json = new TextEncoder().encode(JSON.stringify(index));
|
|
326
|
+
const head = new Uint8Array(12);
|
|
327
|
+
head.set(new TextEncoder().encode('CUJDIR1\n'), 0);
|
|
328
|
+
new DataView(head.buffer).setUint32(8, json.length, true);
|
|
329
|
+
const parts = [head, json];
|
|
330
|
+
for (const f of files) {
|
|
331
|
+
parts.push(new Uint8Array(await f.file.arrayBuffer()));
|
|
332
|
+
}
|
|
333
|
+
return new Blob(parts);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Files from a folder input, each with its path and file.
|
|
337
|
+
export function filesFromInput(fileList) {
|
|
338
|
+
return Array.from(fileList)
|
|
339
|
+
.map((file) => ({ path: (file.webkitRelativePath || file.name).replace(/\\/g, '/'), file }))
|
|
340
|
+
.filter((f) => keepFile(f.path));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Files from a dropped folder, walking entries recursively.
|
|
344
|
+
export async function filesFromDrop(items) {
|
|
345
|
+
const entries = [];
|
|
346
|
+
for (const item of Array.from(items)) {
|
|
347
|
+
const entry = item.webkitGetAsEntry ? item.webkitGetAsEntry() : null;
|
|
348
|
+
if (entry) {
|
|
349
|
+
entries.push(entry);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const out = [];
|
|
353
|
+
const readAll = (dir) => new Promise((resolve, reject) => {
|
|
354
|
+
const reader = dir.createReader();
|
|
355
|
+
const list = [];
|
|
356
|
+
const next = () => reader.readEntries((batch) => {
|
|
357
|
+
if (batch.length === 0) {
|
|
358
|
+
resolve(list);
|
|
359
|
+
} else {
|
|
360
|
+
list.push(...batch);
|
|
361
|
+
next();
|
|
362
|
+
}
|
|
363
|
+
}, reject);
|
|
364
|
+
next();
|
|
365
|
+
});
|
|
366
|
+
const walk = async (entry) => {
|
|
367
|
+
if (entry.isFile) {
|
|
368
|
+
const file = await new Promise((resolve, reject) => entry.file(resolve, reject));
|
|
369
|
+
out.push({ path: entry.fullPath.replace(/^\/+/, ''), file });
|
|
370
|
+
} else if (entry.isDirectory) {
|
|
371
|
+
for (const child of await readAll(entry)) {
|
|
372
|
+
await walk(child);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
for (const e of entries) {
|
|
377
|
+
await walk(e);
|
|
378
|
+
}
|
|
379
|
+
return { files: out.filter((f) => keepFile(f.path)), folder: entries.length === 1 && entries[0].isDirectory ? entries[0].name : null };
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function formatBytes(n) {
|
|
383
|
+
if (!Number.isFinite(n)) {
|
|
384
|
+
return '';
|
|
385
|
+
}
|
|
386
|
+
// The figures follow the language, with its decimal mark and without grouping, as toFixed.
|
|
387
|
+
const figure = (value, digits) => formatNumber(value, { minimumFractionDigits: digits, maximumFractionDigits: digits, useGrouping: false });
|
|
388
|
+
if (n < 1024) {
|
|
389
|
+
return t('api.bytes.b', { size: n });
|
|
390
|
+
}
|
|
391
|
+
if (n < 1024 * 1024) {
|
|
392
|
+
return t('api.bytes.kb', { size: figure(n / 1024, 1) });
|
|
393
|
+
}
|
|
394
|
+
if (n < 1024 * 1024 * 1024) {
|
|
395
|
+
return t('api.bytes.mb', { size: figure(n / 1024 / 1024, 1) });
|
|
396
|
+
}
|
|
397
|
+
return t('api.bytes.gb', { size: figure(n / 1024 / 1024 / 1024, 2) });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Accepts an ISO string, or seconds or milliseconds since the epoch.
|
|
401
|
+
export function formatDate(value) {
|
|
402
|
+
if (value == null || value === '') {
|
|
403
|
+
return '';
|
|
404
|
+
}
|
|
405
|
+
let date;
|
|
406
|
+
if (typeof value === 'number') {
|
|
407
|
+
date = new Date(value < 1e12 ? value * 1000 : value);
|
|
408
|
+
} else {
|
|
409
|
+
date = new Date(value);
|
|
410
|
+
}
|
|
411
|
+
if (Number.isNaN(date.getTime())) {
|
|
412
|
+
return String(value);
|
|
413
|
+
}
|
|
414
|
+
return new Intl.DateTimeFormat(uiLocale(), { dateStyle: 'medium', timeStyle: 'short' }).format(date);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Dates and numbers follow the language of the page, not the browser's locale.
|
|
418
|
+
export function uiLocale() {
|
|
419
|
+
return document.documentElement.lang || 'en-US';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// A date as a calendar day alone, in the language of the page.
|
|
423
|
+
export function formatDay(value) {
|
|
424
|
+
const date = typeof value === 'number' ? new Date(value < 1e12 ? value * 1000 : value) : new Date(value);
|
|
425
|
+
if (Number.isNaN(date.getTime())) {
|
|
426
|
+
return '';
|
|
427
|
+
}
|
|
428
|
+
return new Intl.DateTimeFormat(uiLocale(), { dateStyle: 'medium' }).format(date);
|
|
429
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Copyright 2026 The cuju Authors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// The comfort rules of the page, the motion preference with the fades and still shots of reduced
|
|
5
|
+
// motion, the levels of the three sound channels that the page keeps in the browser, the controls
|
|
6
|
+
// that keep their own keys and the open panels that take a captured pointer back.
|
|
7
|
+
|
|
8
|
+
// Follow the system, always reduce, or always move in full.
|
|
9
|
+
export const MOTION_CHOICES = ['system', 'reduce', 'full'];
|
|
10
|
+
|
|
11
|
+
// The channels under the master volume. Each level runs from 0 to 1 and starts at 1, or 0.8 for
|
|
12
|
+
// the music of team packages, so a level only ever turns its channel down.
|
|
13
|
+
export const SOUND_CHANNELS = ['crowd', 'ambience', 'effects', 'music'];
|
|
14
|
+
export const SOUND_DEFAULTS = { music: 0.8 };
|
|
15
|
+
|
|
16
|
+
// The stored motion preference, or system for anything else.
|
|
17
|
+
export function motionChoice(value) {
|
|
18
|
+
return MOTION_CHOICES.includes(value) ? value : 'system';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Whether the page reduces motion, for a preference and the system's own setting.
|
|
22
|
+
export function motionReduced(choice, systemReduces) {
|
|
23
|
+
const chosen = motionChoice(choice);
|
|
24
|
+
return chosen === 'reduce' || (chosen === 'system' && !!systemReduces);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The cover of the fade that takes the place of a wipe under reduced motion, at the progress p of
|
|
28
|
+
// the wipe from 0 to 1. It rises over the first three tenths, covers the view fully from 0.3 to
|
|
29
|
+
// 0.7, where the wipe covers it and the cut happens, and clears over the last three tenths.
|
|
30
|
+
export function fadeCover(p) {
|
|
31
|
+
if (!(p > 0 && p < 1)) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
const smooth = (x) => {
|
|
35
|
+
const u = Math.max(0, Math.min(1, x));
|
|
36
|
+
return u * u * (3 - 2 * u);
|
|
37
|
+
};
|
|
38
|
+
return Math.min(smooth(p / 0.3), 1 - smooth((p - 0.7) / 0.3));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The least time in seconds that a still shot holds before its subject may cut it, and the part
|
|
42
|
+
// of the half frame its subject may leave the middle by before then.
|
|
43
|
+
export const STILL_HOLD = 1;
|
|
44
|
+
export const STILL_EDGE = 0.7;
|
|
45
|
+
|
|
46
|
+
// Whether a still shot under reduced motion cuts to a new framing, because the subject it wants
|
|
47
|
+
// to see left the frame, moved far nearer or farther, or after the shortest hold neared the edge.
|
|
48
|
+
// The view holds the position and target of the still, its vertical field of view in degrees,
|
|
49
|
+
// and the seconds it has held. Points are objects with x, y and z, with y up.
|
|
50
|
+
export function stillCut(view, want, aspect = 16 / 9, held = Infinity) {
|
|
51
|
+
const fx = view.target.x - view.pos.x;
|
|
52
|
+
const fy = view.target.y - view.pos.y;
|
|
53
|
+
const fz = view.target.z - view.pos.z;
|
|
54
|
+
const length = Math.hypot(fx, fy, fz);
|
|
55
|
+
if (!(length > 1e-6)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const f = [fx / length, fy / length, fz / length];
|
|
59
|
+
// The right of the view is level, and straight down looks along the x axis.
|
|
60
|
+
const flat = Math.hypot(f[0], f[2]);
|
|
61
|
+
const r = flat > 1e-6 ? [-f[2] / flat, 0, f[0] / flat] : [1, 0, 0];
|
|
62
|
+
const u = [r[1] * f[2] - r[2] * f[1], r[2] * f[0] - r[0] * f[2], r[0] * f[1] - r[1] * f[0]];
|
|
63
|
+
const d = [want.x - view.pos.x, want.y - view.pos.y, want.z - view.pos.z];
|
|
64
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
65
|
+
const depth = dot(d, f);
|
|
66
|
+
if (!(depth > 0.1)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const tanV = Math.tan(((view.fov || 40) * Math.PI) / 360);
|
|
70
|
+
const tanH = tanV * Math.max(0.5, aspect || 16 / 9);
|
|
71
|
+
const edge = Math.max(Math.abs(dot(d, r) / depth) / tanH, Math.abs(dot(d, u) / depth) / tanV);
|
|
72
|
+
const near = depth / length;
|
|
73
|
+
if (edge > 1 || near < 0.5 || near > 2) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return held >= STILL_HOLD && edge > STILL_EDGE;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// A channel level within 0 and 1, and 1 for anything that is not a number.
|
|
80
|
+
export function soundLevel(value, fallback = 1) {
|
|
81
|
+
const level = typeof value === 'number' ? value : Number.NaN;
|
|
82
|
+
return Number.isFinite(level) ? Math.max(0, Math.min(1, level)) : fallback;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The levels of every channel from a stored object, each kept within 0 and 1.
|
|
86
|
+
export function soundLevels(stored) {
|
|
87
|
+
const source = stored && typeof stored === 'object' ? stored : {};
|
|
88
|
+
return Object.fromEntries(SOUND_CHANNELS.map((name) => [name, soundLevel(source[name], SOUND_DEFAULTS[name] ?? 1)]));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Controls that keep their keys, so Space or a letter on one of them acts on that control alone.
|
|
92
|
+
export const OWN_KEYS = [
|
|
93
|
+
'button', 'a[href]', 'summary', '[role="button"]', '[role="link"]', '[role^="menuitem"]',
|
|
94
|
+
'[role="slider"]', '[role="checkbox"]', '[role="radio"]', '[role="switch"]', '[role="tab"]',
|
|
95
|
+
'[role="option"]', '[role="treeitem"]', '[role="spinbutton"]',
|
|
96
|
+
].join(', ');
|
|
97
|
+
|
|
98
|
+
// Buttons and links act on Enter and Space alone, so a letter or a question mark pressed on one
|
|
99
|
+
// still reaches the single key shortcuts of the page, such as H, M and F. A button inside a
|
|
100
|
+
// dialog, a menu or a list keeps every key, as do the other controls of OWN_KEYS.
|
|
101
|
+
const PLAIN = 'button, a[href], [role="button"], [role="link"]';
|
|
102
|
+
const PLAIN_ROLES = [null, 'button', 'link'];
|
|
103
|
+
const HOLDERS = 'dialog, [role="dialog"], [role="alertdialog"], [role="menu"], [role="menubar"], '
|
|
104
|
+
+ '[role="listbox"], [role="tablist"], [role="tree"], [role="grid"], .dd-panel';
|
|
105
|
+
|
|
106
|
+
// Whether a control keeps a key to itself, the control being the closest element of OWN_KEYS
|
|
107
|
+
// around the key's target, or null. Esc always goes on to the page.
|
|
108
|
+
export function keepsKey(control, key, modifiers = {}) {
|
|
109
|
+
if (!control || key === 'Escape') {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const plain = control.matches(PLAIN) && PLAIN_ROLES.includes(control.getAttribute('role'));
|
|
113
|
+
const letter = /^[a-z?]$/i.test(key) && !modifiers.ctrlKey && !modifiers.metaKey && !modifiers.altKey;
|
|
114
|
+
return !(plain && letter && !control.closest(HOLDERS));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Whatever opens over the page and asks for a click or a key. A dialog, an open details element,
|
|
118
|
+
// a menu, a popover or a list of a dropdown, the panel of a button that shows as expanded, the
|
|
119
|
+
// team editor, the lineups, the cards after the match and any element marked with data-prompt.
|
|
120
|
+
// Each counts only while it shows.
|
|
121
|
+
export const POINTER_PANELS = [
|
|
122
|
+
'dialog[open]', 'details[open]', '[role="dialog"]', '[role="alertdialog"]', '[aria-modal="true"]',
|
|
123
|
+
'[role="menu"]', '.dd-panel.open', 'button[aria-expanded="true"]', '#team-editor:not([hidden])',
|
|
124
|
+
'#lineups', '.post-card', '#victory', '#spotlight', '[data-prompt]',
|
|
125
|
+
].join(', ');
|
|
126
|
+
|
|
127
|
+
// The first panel of the page that shows and wants the pointer, or null.
|
|
128
|
+
export function openPanel(root = document) {
|
|
129
|
+
for (const node of root.querySelectorAll(POINTER_PANELS)) {
|
|
130
|
+
if (node.getClientRects().length > 0) {
|
|
131
|
+
return node;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|