@reicek/neataptic-ts 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/boundary-mapper.agent.md +31 -0
- package/.github/agents/docs-scout.agent.md +29 -0
- package/.github/agents/plan-scout.agent.md +31 -0
- package/.github/agents/solid-split.agent.md +143 -0
- package/.github/copilot-instructions.md +119 -0
- package/.github/skills/solid-split-playbook/SKILL.md +220 -0
- package/.github/skills/solid-split-playbook/assets/docs-checklist.md +34 -0
- package/.github/skills/solid-split-playbook/assets/split-plan-template.md +48 -0
- package/.github/skills/solid-split-playbook/assets/split-workflow-checklist.md +51 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +63 -0
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +24 -0
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +101 -0
- package/.github/skills/trace-audit-reporting/SKILL.md +96 -0
- package/.github/skills/trace-audit-reporting/assets/performance-report-template.md +123 -0
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +132 -0
- package/package.json +7 -3
- package/plans/ES2023 migration +13 -8
- package/plans/Evolution_Training_Interoperability_Contracts.md +1 -1
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +53 -0
- package/plans/Flappy_Evolution_Worker_Documentation_Pass.md +58 -0
- package/plans/Interactive_Examples_and_Learning_Path.md +10 -2
- package/plans/Memory_Optimization.md +3 -3
- package/plans/README.md +63 -0
- package/plans/Roadmap.md +15 -3
- package/plans/asciiMaze_SOLID_split.done.md +130 -0
- package/plans/flappy_bird_SOLID_split.done.md +67 -0
- package/scripts/analyze-trace.ts +590 -0
- package/scripts/assets/theme.css +221 -34
- package/scripts/copy-examples.mjs +9 -5
- package/scripts/export-onnx.mjs +3 -3
- package/scripts/generate-bench-tables.mjs +10 -10
- package/scripts/generate-bench-tables.ts +10 -10
- package/scripts/generate-docs.ts +1415 -449
- package/scripts/render-docs-html.ts +15 -8
- package/src/README.md +127 -222
- package/src/architecture/README.md +117 -184
- package/src/architecture/architect.ts +6 -0
- package/src/architecture/layer/README.md +38 -38
- package/src/architecture/network/README.md +49 -31
- package/src/architecture/network/activate/README.md +77 -77
- package/src/architecture/network/connect/README.md +15 -13
- package/src/architecture/network/deterministic/README.md +7 -7
- package/src/architecture/network/evolve/README.md +44 -44
- package/src/architecture/network/gating/README.md +20 -20
- package/src/architecture/network/genetic/README.md +51 -51
- package/src/architecture/network/mutate/README.md +97 -97
- package/src/architecture/network/network.types.ts +39 -0
- package/src/architecture/network/onnx/README.md +264 -264
- package/src/architecture/network/prune/README.md +39 -39
- package/src/architecture/network/remove/README.md +26 -26
- package/src/architecture/network/serialize/README.md +56 -56
- package/src/architecture/network/serialize/network.serialize.json.utils.ts +1 -0
- package/src/architecture/network/serialize/network.serialize.utils.ts +6 -1
- package/src/architecture/network/serialize/network.serialize.utils.types.ts +1 -1
- package/src/architecture/network/slab/README.md +61 -61
- package/src/architecture/network/standalone/README.md +24 -24
- package/src/architecture/network/stats/README.md +9 -9
- package/src/architecture/network/topology/README.md +46 -46
- package/src/architecture/network/training/README.md +21 -21
- package/src/architecture/network.ts +114 -10
- package/src/methods/README.md +9 -87
- package/src/multithreading/README.md +8 -77
- package/src/multithreading/workers/README.md +2 -2
- package/src/multithreading/workers/browser/README.md +0 -6
- package/src/multithreading/workers/node/README.md +0 -3
- package/src/neat/README.md +623 -568
- package/src/neat/neat.evolve.population.utils.ts +29 -5
- package/src/neat/neat.helpers.ts +16 -0
- package/src/neat/neat.topology-intent.utils.ts +160 -0
- package/src/utils/README.md +18 -18
- package/test/examples/asciiMaze/README.md +59 -59
- package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +14 -9
- package/test/examples/asciiMaze/browser-entry/README.md +196 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.abort.services.ts +95 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.constants.ts +23 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.curriculum.services.ts +115 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.globals.services.ts +106 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.host.services.ts +157 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.services.ts +14 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.ts +129 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.types.ts +120 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.utils.ts +98 -0
- package/test/examples/asciiMaze/browser-entry.ts +10 -576
- package/test/examples/asciiMaze/dashboardManager/README.md +276 -0
- package/test/examples/asciiMaze/dashboardManager/archive/README.md +16 -0
- package/test/examples/asciiMaze/dashboardManager/archive/dashboardManager.archive.services.ts +267 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.constants.ts +35 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.services.ts +103 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.ts +181 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.types.ts +267 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.utils.ts +254 -0
- package/test/examples/asciiMaze/dashboardManager/live/README.md +14 -0
- package/test/examples/asciiMaze/dashboardManager/live/dashboardManager.live.services.ts +264 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +47 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/dashboardManager.telemetry.services.ts +513 -0
- package/test/examples/asciiMaze/dashboardManager.ts +13 -2335
- package/test/examples/asciiMaze/evolutionEngine/README.md +1058 -0
- package/test/examples/asciiMaze/evolutionEngine/curriculumPhase.ts +90 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.constants.ts +36 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.ts +58 -513
- package/test/examples/asciiMaze/evolutionEngine/engineState.types.ts +212 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.utils.ts +301 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.types.ts +445 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +81 -50
- package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +2 -4
- package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +17 -33
- package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +1 -1
- package/test/examples/asciiMaze/evolutionEngine/rngAndTiming.ts +1 -2
- package/test/examples/asciiMaze/evolutionEngine/sampling.ts +1 -1
- package/test/examples/asciiMaze/evolutionEngine/scratchPools.ts +2 -5
- package/test/examples/asciiMaze/evolutionEngine/setupHelpers.ts +30 -37
- package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +16 -58
- package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +2 -2
- package/test/examples/asciiMaze/evolutionEngine.ts +55 -55
- package/test/examples/asciiMaze/fitness.ts +2 -2
- package/test/examples/asciiMaze/fitness.types.ts +65 -0
- package/test/examples/asciiMaze/interfaces.ts +64 -1352
- package/test/examples/asciiMaze/mazeMovement/README.md +356 -0
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +49 -0
- package/test/examples/asciiMaze/mazeMovement/finalization/mazeMovement.finalization.ts +138 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.constants.ts +101 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.services.ts +230 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.ts +299 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.types.ts +185 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.utils.ts +153 -0
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +91 -0
- package/test/examples/asciiMaze/mazeMovement/policy/mazeMovement.policy.ts +467 -0
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +95 -0
- package/test/examples/asciiMaze/mazeMovement/runtime/mazeMovement.runtime.ts +354 -0
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +124 -0
- package/test/examples/asciiMaze/mazeMovement/shaping/mazeMovement.shaping.ts +459 -0
- package/test/examples/asciiMaze/mazeMovement.ts +12 -2978
- package/test/examples/flappy_bird/README.md +193 -88
- package/test/examples/flappy_bird/browser-entry/README.md +1441 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.host.utils.ts +4 -324
- package/test/examples/flappy_bird/browser-entry/browser-entry.network-view.utils.ts +9 -396
- package/test/examples/flappy_bird/browser-entry/browser-entry.playback.utils.ts +6 -714
- package/test/examples/flappy_bird/browser-entry/browser-entry.render.types.ts +26 -3
- package/test/examples/flappy_bird/browser-entry/browser-entry.runtime.types.ts +16 -1
- package/test/examples/flappy_bird/browser-entry/browser-entry.simulation.types.ts +39 -5
- package/test/examples/flappy_bird/browser-entry/browser-entry.spawn.utils.ts +11 -31
- package/test/examples/flappy_bird/browser-entry/browser-entry.stats.types.ts +32 -4
- package/test/examples/flappy_bird/browser-entry/browser-entry.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.types.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.types.ts +50 -7
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.utils.ts +21 -893
- package/test/examples/flappy_bird/browser-entry/browser-entry.worker.types.ts +91 -10
- package/test/examples/flappy_bird/browser-entry/host/README.md +318 -0
- package/test/examples/flappy_bird/browser-entry/host/host.canvas.service.ts +16 -0
- package/test/examples/flappy_bird/browser-entry/host/host.constants.ts +20 -0
- package/test/examples/flappy_bird/browser-entry/host/host.dom.service.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/host/host.resize.service.ts +1 -295
- package/test/examples/flappy_bird/browser-entry/host/host.stats.service.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/host/host.ts +592 -6
- package/test/examples/flappy_bird/browser-entry/host/host.types.ts +13 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +309 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.constants.ts +47 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.services.ts +392 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.ts +132 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.utils.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +389 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.draw.service.ts +13 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.labels.utils.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.layout.utils.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.topology.utils.ts +267 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.ts +823 -7
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.types.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/playback/README.md +845 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +355 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +1068 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.batch.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.cache.services.ts +207 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.constants.ts +197 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.batch.utils.ts +114 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.layout.utils.test.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.layout.utils.ts +204 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.services.ts +49 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.utils.ts +313 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.layer.services.ts +81 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.test.ts +33 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.ts +201 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.selection.utils.ts +171 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.timing.utils.ts +124 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.test.ts +279 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.ts +132 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.scene.services.ts +26 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.services.ts +65 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.ts +48 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.types.ts +342 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.utils.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.cache.services.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.constants.ts +127 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.draw.services.ts +184 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.scene.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.services.ts +6 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.ts +53 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.types.ts +105 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.utils.ts +100 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +541 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.bird.utils.ts +180 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.canvas.services.ts +77 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.entity.services.ts +167 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.scene.services.ts +57 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.test.ts +176 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.ts +113 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.services.ts +35 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.trail.utils.ts +248 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.types.ts +103 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.utils.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.constants.ts +1 -1
- package/test/examples/flappy_bird/browser-entry/playback/playback.frame-render.service.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.iteration.services.ts +192 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.loop.service.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.orchestration.types.ts +78 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.render.pipe-outline.service.ts +128 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.render.service.ts +1 -116
- package/test/examples/flappy_bird/browser-entry/playback/playback.session.services.ts +184 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.test.ts +121 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.layer.services.ts +36 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.service.ts +11 -128
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.services.ts +268 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.types.ts +91 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.utils.ts +11 -4
- package/test/examples/flappy_bird/browser-entry/playback/playback.trail.utils.ts +9 -86
- package/test/examples/flappy_bird/browser-entry/playback/playback.ts +75 -7
- package/test/examples/flappy_bird/browser-entry/playback/playback.types.ts +12 -9
- package/test/examples/flappy_bird/browser-entry/playback/playback.worker-channel.utils.ts +11 -123
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +55 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.services.ts +103 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.test.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.ts +28 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +95 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.test.ts +35 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.test.ts +37 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +71 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.request.services.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.summary.services.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.types.ts +53 -0
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +304 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.browser-globals.service.ts +15 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.errors.ts +17 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-launch.service.ts +56 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-loop.service.ts +19 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.lifecycle.service.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.startup.service.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.telemetry.service.ts +24 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.ts +31 -121
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.types.ts +65 -0
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +568 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.colors.utils.ts +26 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.constants.ts +110 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.draw.service.ts +979 -19
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.legend.utils.ts +157 -3
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.topology.utils.ts +13 -27
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.ts +7 -20
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.types.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +238 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.errors.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.generation.service.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.playback.service.test.ts +143 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.playback.service.ts +140 -14
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.request.service.ts +27 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.types.ts +23 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.url.service.ts +5 -0
- package/test/examples/flappy_bird/constants/README.md +1163 -0
- package/test/examples/flappy_bird/constants/constants.birds.ts +16 -38
- package/test/examples/flappy_bird/constants/constants.difficulty.ts +21 -0
- package/test/examples/flappy_bird/constants/constants.network-view.ts +24 -0
- package/test/examples/flappy_bird/constants/constants.network.ts +1 -1
- package/test/examples/flappy_bird/constants/constants.observation.ts +7 -0
- package/test/examples/flappy_bird/constants/constants.palette.ts +9 -2
- package/test/examples/flappy_bird/constants/constants.physics.ts +9 -0
- package/test/examples/flappy_bird/constants/constants.pipe-render.ts +3 -0
- package/test/examples/flappy_bird/constants/constants.pipes.ts +22 -3
- package/test/examples/flappy_bird/constants/constants.runtime.ts +28 -4
- package/test/examples/flappy_bird/constants/constants.starfield.ts +78 -3
- package/test/examples/flappy_bird/constants/constants.ts +6 -0
- package/test/examples/flappy_bird/environment/README.md +182 -0
- package/test/examples/flappy_bird/environment/environment.collision.utils.ts +7 -0
- package/test/examples/flappy_bird/environment/environment.constants.ts +16 -3
- package/test/examples/flappy_bird/environment/environment.observation.utils.ts +12 -19
- package/test/examples/flappy_bird/environment/environment.state.service.ts +10 -0
- package/test/examples/flappy_bird/environment/environment.step.service.ts +15 -66
- package/test/examples/flappy_bird/environment/environment.types.ts +14 -0
- package/test/examples/flappy_bird/evaluation/README.md +155 -0
- package/test/examples/flappy_bird/evaluation/evaluation.constants.ts +23 -4
- package/test/examples/flappy_bird/evaluation/evaluation.fitness.utils.ts +16 -1
- package/test/examples/flappy_bird/evaluation/evaluation.rollout.service.ts +7 -374
- package/test/examples/flappy_bird/evaluation/evaluation.seed.utils.ts +4 -0
- package/test/examples/flappy_bird/evaluation/evaluation.types.ts +18 -2
- package/test/examples/flappy_bird/evaluation/rollout/README.md +355 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.constants.ts +38 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.service.ts +71 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.services.ts +338 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.types.ts +69 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.utils.ts +399 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +845 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.constants.ts +49 -7
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.errors.ts +34 -3
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.evolution.service.ts +22 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.playback.service.ts +62 -26
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.protocol.service.ts +27 -1
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.runtime.service.ts +23 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.frame.service.ts +378 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types.ts +22 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts +20 -203
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.test.ts +94 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.ts +78 -13
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +235 -344
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types.ts +170 -22
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts +314 -0
- package/test/examples/flappy_bird/flappy.simulation.shared.utils.ts +17 -0
- package/test/examples/flappy_bird/flappyEnvironment.ts +21 -0
- package/test/examples/flappy_bird/flappyEvaluation.ts +12 -0
- package/test/examples/flappy_bird/flappyEvolution.worker.ts +7 -0
- package/test/examples/flappy_bird/index.ts +8 -2
- package/test/examples/flappy_bird/rng.ts +10 -0
- package/test/examples/flappy_bird/simulation-shared/README.md +518 -0
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +255 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.features.utils.ts +339 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.ts +19 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.vector.utils.ts +81 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.constants.ts +3 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.control.utils.ts +6 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.difficulty.utils.ts +9 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.errors.ts +10 -1
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.memory.utils.ts +18 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.observation.utils.ts +7 -402
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.spawn.utils.ts +36 -6
- package/test/examples/flappy_bird/{evaluation/evaluation.statistics.utils.ts → simulation-shared/simulation-shared.statistics.utils.ts} +30 -9
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.types.ts +38 -5
- package/test/examples/flappy_bird/trainFlappyBird.ts +13 -0
- package/test/examples/flappy_bird/trainer/README.md +676 -0
- package/test/examples/flappy_bird/trainer/evaluation/README.md +253 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.constants.ts +15 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.services.ts +86 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.ts +187 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.types.ts +32 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.utils.ts +182 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation.service.ts +13 -0
- package/test/examples/flappy_bird/trainer/trainer.fitness.service.ts +23 -1
- package/test/examples/flappy_bird/trainer/trainer.loop.service.ts +17 -1
- package/test/examples/flappy_bird/trainer/trainer.report.service.services.ts +181 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.ts +136 -0
- package/test/examples/flappy_bird/trainer/trainer.selection.utils.ts +89 -0
- package/test/examples/flappy_bird/trainer/trainer.setup.service.ts +22 -0
- package/test/examples/flappy_bird/trainer/trainer.signals.service.ts +8 -0
- package/test/examples/flappy_bird/trainer/trainer.ts +38 -553
- package/test/examples/flappy_bird/trainer/trainer.types.ts +44 -7
- package/test/neat/neat.topology-intent.test.ts +129 -0
- package/test/network/network.topology-intent.test.ts +44 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.utils.ts +0 -12
- package/test/examples/flappy_bird/environment/environment.ts +0 -7
- package/test/examples/flappy_bird/evaluation/evaluation.ts +0 -7
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.ts +0 -15
- package/test/examples/flappy_bird/trainer/trainer.statistics.utils.ts +0 -78
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FLAPPY_UI_NETWORK_HOST_FIXED_HEIGHT_PX,
|
|
3
|
+
FLAPPY_UI_NETWORK_HOST_INSET_PX,
|
|
4
|
+
FLAPPY_VIEWPORT_VERTICAL_LAYOUT_GUTTER_PX,
|
|
5
|
+
} from '../../../constants/constants';
|
|
6
|
+
import { FLAPPY_HOST_STATS_SPLIT_GAP } from '../host.constants';
|
|
7
|
+
import {
|
|
8
|
+
applyCanvasBackingSize,
|
|
9
|
+
applySimulationCanvasBounds,
|
|
10
|
+
resolveNetworkCanvasSizePx,
|
|
11
|
+
} from '../host.canvas.service';
|
|
12
|
+
import { FLAPPY_HOST_RESIZE_STYLE_TOKENS } from './host.resize.service.constants';
|
|
13
|
+
import {
|
|
14
|
+
resolveMinimalMobileCanvasBounds,
|
|
15
|
+
resolveSimulationCanvasBounds,
|
|
16
|
+
resolveStatsPanelDimensions,
|
|
17
|
+
} from './host.resize.service.utils';
|
|
18
|
+
import type {
|
|
19
|
+
DeferredNetworkRedrawController,
|
|
20
|
+
ResponsiveViewportLayoutContext,
|
|
21
|
+
ResponsiveViewportSizingElements,
|
|
22
|
+
StatsPanelDimensions,
|
|
23
|
+
} from './host.resize.service.types';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Layout-application helpers for responsive host sizing.
|
|
27
|
+
*
|
|
28
|
+
* These helpers implement the actual responsive policy once the viewport has
|
|
29
|
+
* been measured: choose a layout mode, resize canvases, reorder panes, and
|
|
30
|
+
* trigger redraws when the network panel geometry changes.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a deferred redraw controller that waits for layout to settle.
|
|
35
|
+
*
|
|
36
|
+
* Waiting two animation frames is a pragmatic way to avoid redrawing the network
|
|
37
|
+
* panel against transient intermediate layout sizes.
|
|
38
|
+
*
|
|
39
|
+
* @param onNetworkResize - Callback after network resize.
|
|
40
|
+
* @returns Deferred redraw controller.
|
|
41
|
+
*/
|
|
42
|
+
export function createDeferredNetworkRedrawController(
|
|
43
|
+
onNetworkResize: () => void,
|
|
44
|
+
): DeferredNetworkRedrawController {
|
|
45
|
+
let pendingNetworkRedrawRequest = false;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
requestNetworkRedrawAfterLayout: (): void => {
|
|
49
|
+
// Step 1: Skip duplicate redraw requests while one is already queued.
|
|
50
|
+
if (pendingNetworkRedrawRequest) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
pendingNetworkRedrawRequest = true;
|
|
54
|
+
|
|
55
|
+
// Step 2: Wait two animation frames so flexbox layout has settled before redrawing.
|
|
56
|
+
requestAnimationFrame(() => {
|
|
57
|
+
requestAnimationFrame(() => {
|
|
58
|
+
pendingNetworkRedrawRequest = false;
|
|
59
|
+
onNetworkResize();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Applies the minimal mobile layout that hides the auxiliary panes.
|
|
68
|
+
*
|
|
69
|
+
* On the smallest viewports, the resize policy prioritizes the simulation canvas
|
|
70
|
+
* and temporarily hides the stats/network panel to preserve playable space.
|
|
71
|
+
*
|
|
72
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
73
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
74
|
+
* @returns Nothing.
|
|
75
|
+
*/
|
|
76
|
+
export function applyMinimalMobileViewportLayout(
|
|
77
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
78
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
79
|
+
): void {
|
|
80
|
+
// Step 1: Arrange the split containers so gameplay occupies the full vertical budget.
|
|
81
|
+
responsiveViewportSizingElements.mainSplitContainer.style.flexDirection =
|
|
82
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.columnDirection;
|
|
83
|
+
responsiveViewportSizingElements.mainSplitContainer.style.gap = `${FLAPPY_VIEWPORT_VERTICAL_LAYOUT_GUTTER_PX}px`;
|
|
84
|
+
responsiveViewportSizingElements.statsSplitContainer.style.flexDirection =
|
|
85
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.rowDirection;
|
|
86
|
+
responsiveViewportSizingElements.statsSplitContainer.style.alignItems =
|
|
87
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.flexStartAlignment;
|
|
88
|
+
responsiveViewportSizingElements.statsSplitContainer.style.height =
|
|
89
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoSize;
|
|
90
|
+
responsiveViewportSizingElements.statsTableHost.style.order =
|
|
91
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.primaryOrder;
|
|
92
|
+
responsiveViewportSizingElements.networkCanvasHost.style.order =
|
|
93
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.secondaryOrder;
|
|
94
|
+
|
|
95
|
+
// Step 2: Hide the stats pane so the simulation canvas gets the full available height.
|
|
96
|
+
responsiveViewportSizingElements.statsContainer.style.display =
|
|
97
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenDisplay;
|
|
98
|
+
responsiveViewportSizingElements.statsContainer.style.height =
|
|
99
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.zeroSizePx;
|
|
100
|
+
responsiveViewportSizingElements.statsContainer.style.maxHeight =
|
|
101
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.zeroSizePx;
|
|
102
|
+
responsiveViewportSizingElements.statsContainer.style.overflowY =
|
|
103
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenOverflow;
|
|
104
|
+
|
|
105
|
+
// Step 3: Apply the simulation canvas backing size directly from the mobile viewport budget.
|
|
106
|
+
const mobileCanvasBounds = resolveMinimalMobileCanvasBounds(
|
|
107
|
+
responsiveViewportSizingElements.containerElement,
|
|
108
|
+
responsiveViewportLayoutContext,
|
|
109
|
+
);
|
|
110
|
+
applyCanvasBackingSize(
|
|
111
|
+
responsiveViewportSizingElements.canvas,
|
|
112
|
+
mobileCanvasBounds.availableWidthPx,
|
|
113
|
+
mobileCanvasBounds.availableHeightPx,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Applies the standard tablet and desktop layout and returns panel dimensions.
|
|
119
|
+
*
|
|
120
|
+
* This path keeps the auxiliary panes visible and resolves a balanced split
|
|
121
|
+
* between simulation and side-panel content.
|
|
122
|
+
*
|
|
123
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
124
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
125
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
126
|
+
* @returns Resolved stats panel dimensions.
|
|
127
|
+
*/
|
|
128
|
+
export function applyStandardViewportLayout(
|
|
129
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
130
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
131
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
132
|
+
): StatsPanelDimensions {
|
|
133
|
+
// Step 1: Restore the stats container and apply split orientation styles.
|
|
134
|
+
responsiveViewportSizingElements.statsContainer.style.display =
|
|
135
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.blockDisplay;
|
|
136
|
+
applySplitContainerLayoutStyles(
|
|
137
|
+
responsiveViewportSizingElements,
|
|
138
|
+
responsiveViewportLayoutContext,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// Step 2: Resolve the stats panel dimensions from the current viewport budget.
|
|
142
|
+
const statsPanelDimensions = resolveStatsPanelDimensions(
|
|
143
|
+
responsiveViewportLayoutContext,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// Step 3: Clamp the network panel height and queue a redraw when the height changed.
|
|
147
|
+
applyNetworkCanvasHostHeight(
|
|
148
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
149
|
+
deferredNetworkRedrawController,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Step 4: Apply the final stats container dimensions and scrolling rules.
|
|
153
|
+
applyStatsContainerDimensions(
|
|
154
|
+
responsiveViewportSizingElements.statsContainer,
|
|
155
|
+
responsiveViewportLayoutContext,
|
|
156
|
+
statsPanelDimensions,
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
return statsPanelDimensions;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Applies simulation and network canvas backing sizes for the active layout.
|
|
164
|
+
*
|
|
165
|
+
* Once panel dimensions are known, this helper updates both backing stores and
|
|
166
|
+
* triggers an immediate network redraw when the visualization canvas changed.
|
|
167
|
+
*
|
|
168
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
169
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
170
|
+
* @param statsPanelDimensions - Resolved stats panel dimensions.
|
|
171
|
+
* @param onNetworkResize - Immediate network resize callback.
|
|
172
|
+
* @returns Nothing.
|
|
173
|
+
*/
|
|
174
|
+
export function applyResponsiveCanvasBounds(
|
|
175
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
176
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
177
|
+
statsPanelDimensions: StatsPanelDimensions,
|
|
178
|
+
onNetworkResize: () => void,
|
|
179
|
+
): void {
|
|
180
|
+
// Step 1: Resolve simulation canvas size from the remaining viewport budget.
|
|
181
|
+
const simulationCanvasBounds = resolveSimulationCanvasBounds(
|
|
182
|
+
responsiveViewportSizingElements.containerElement,
|
|
183
|
+
responsiveViewportLayoutContext,
|
|
184
|
+
statsPanelDimensions,
|
|
185
|
+
);
|
|
186
|
+
applySimulationCanvasBounds(
|
|
187
|
+
responsiveViewportSizingElements.canvas,
|
|
188
|
+
simulationCanvasBounds.availableWidthPx,
|
|
189
|
+
simulationCanvasBounds.availableHeightPx,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// Step 2: Resize the network canvas backing store and redraw immediately when it changed.
|
|
193
|
+
const { widthPx, heightPx } = resolveNetworkCanvasSizePx(
|
|
194
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
195
|
+
FLAPPY_UI_NETWORK_HOST_INSET_PX,
|
|
196
|
+
);
|
|
197
|
+
if (
|
|
198
|
+
applyCanvasBackingSize(
|
|
199
|
+
responsiveViewportSizingElements.networkCanvas,
|
|
200
|
+
widthPx,
|
|
201
|
+
heightPx,
|
|
202
|
+
)
|
|
203
|
+
) {
|
|
204
|
+
onNetworkResize();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Installs window and container listeners for responsive host sizing.
|
|
210
|
+
*
|
|
211
|
+
* The host listens both to global window resizes and to container-specific size
|
|
212
|
+
* changes when `ResizeObserver` is available.
|
|
213
|
+
*
|
|
214
|
+
* @param containerElement - Width and height source.
|
|
215
|
+
* @param applyCanvasSize - Shared sizing callback.
|
|
216
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
217
|
+
* @returns Nothing.
|
|
218
|
+
*/
|
|
219
|
+
export function installResponsiveViewportSizingListeners(
|
|
220
|
+
containerElement: HTMLElement,
|
|
221
|
+
applyCanvasSize: () => void,
|
|
222
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
223
|
+
): void {
|
|
224
|
+
// Step 1: Run the first post-layout redraw after the initial sizing pass.
|
|
225
|
+
deferredNetworkRedrawController.requestNetworkRedrawAfterLayout();
|
|
226
|
+
|
|
227
|
+
// Step 2: Recompute layout on window resize.
|
|
228
|
+
window.addEventListener('resize', applyCanvasSize);
|
|
229
|
+
|
|
230
|
+
// Step 3: Observe host-size changes when ResizeObserver is available.
|
|
231
|
+
if (typeof ResizeObserver !== 'function') {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
236
|
+
applyCanvasSize();
|
|
237
|
+
deferredNetworkRedrawController.requestNetworkRedrawAfterLayout();
|
|
238
|
+
});
|
|
239
|
+
resizeObserver.observe(containerElement);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Applies the split-container styles for the standard layout modes.
|
|
244
|
+
*
|
|
245
|
+
* This helper decides whether the main panels should stack or sit side-by-side,
|
|
246
|
+
* then applies the matching flexbox configuration.
|
|
247
|
+
*
|
|
248
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
249
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
250
|
+
* @returns Nothing.
|
|
251
|
+
*/
|
|
252
|
+
function applySplitContainerLayoutStyles(
|
|
253
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
254
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
255
|
+
): void {
|
|
256
|
+
// Step 1: Configure the outer split direction based on landscape or stacked layout.
|
|
257
|
+
responsiveViewportSizingElements.mainSplitContainer.style.flexDirection =
|
|
258
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
259
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.rowDirection
|
|
260
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.columnDirection;
|
|
261
|
+
responsiveViewportSizingElements.mainSplitContainer.style.gap = `${FLAPPY_VIEWPORT_VERTICAL_LAYOUT_GUTTER_PX}px`;
|
|
262
|
+
|
|
263
|
+
// Step 2: Configure the inner stats/network split and alignment.
|
|
264
|
+
responsiveViewportSizingElements.statsSplitContainer.style.flexDirection =
|
|
265
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
266
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.columnDirection
|
|
267
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.rowDirection;
|
|
268
|
+
responsiveViewportSizingElements.statsSplitContainer.style.alignItems =
|
|
269
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
270
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.stretchAlignment
|
|
271
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.flexStartAlignment;
|
|
272
|
+
responsiveViewportSizingElements.statsSplitContainer.style.height =
|
|
273
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
274
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize
|
|
275
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoSize;
|
|
276
|
+
responsiveViewportSizingElements.statsSplitContainer.style.gap =
|
|
277
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
278
|
+
? '0'
|
|
279
|
+
: FLAPPY_HOST_STATS_SPLIT_GAP;
|
|
280
|
+
|
|
281
|
+
// Step 3: Apply stats/network ordering and flex rules for the chosen layout.
|
|
282
|
+
applyStatsPaneOrdering(
|
|
283
|
+
responsiveViewportSizingElements.statsTableHost,
|
|
284
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
285
|
+
responsiveViewportLayoutContext,
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Applies ordering and flex styles for stats and network panes.
|
|
291
|
+
*
|
|
292
|
+
* Compact layouts may hide the stats table or promote the network panel so the
|
|
293
|
+
* most informative content remains visible in constrained space.
|
|
294
|
+
*
|
|
295
|
+
* @param statsTableHost - Stats table host element.
|
|
296
|
+
* @param networkCanvasHost - Network canvas host element.
|
|
297
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
298
|
+
* @returns Nothing.
|
|
299
|
+
*/
|
|
300
|
+
function applyStatsPaneOrdering(
|
|
301
|
+
statsTableHost: HTMLElement,
|
|
302
|
+
networkCanvasHost: HTMLElement,
|
|
303
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
304
|
+
): void {
|
|
305
|
+
// Step 1: Order the network panel first only for landscape split layouts.
|
|
306
|
+
if (responsiveViewportLayoutContext.useLandscapeSplitLayout) {
|
|
307
|
+
networkCanvasHost.style.order =
|
|
308
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.primaryOrder;
|
|
309
|
+
statsTableHost.style.order = FLAPPY_HOST_RESIZE_STYLE_TOKENS.secondaryOrder;
|
|
310
|
+
} else {
|
|
311
|
+
statsTableHost.style.order = FLAPPY_HOST_RESIZE_STYLE_TOKENS.primaryOrder;
|
|
312
|
+
networkCanvasHost.style.order =
|
|
313
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.secondaryOrder;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Step 2: Collapse the stats table when the network-only compact panel is active.
|
|
317
|
+
statsTableHost.style.display =
|
|
318
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
319
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenDisplay
|
|
320
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.blockDisplay;
|
|
321
|
+
statsTableHost.style.flex =
|
|
322
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
323
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoFlex
|
|
324
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.fillFlex;
|
|
325
|
+
networkCanvasHost.style.flex =
|
|
326
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
327
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullFlex
|
|
328
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoFlex;
|
|
329
|
+
networkCanvasHost.style.width =
|
|
330
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
331
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize
|
|
332
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoSize;
|
|
333
|
+
networkCanvasHost.style.maxWidth = FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Applies the fixed network host height and queues redraw when it changes.
|
|
338
|
+
*
|
|
339
|
+
* The network panel uses a fixed-height target so the visualization remains
|
|
340
|
+
* readable and stable across layout transitions.
|
|
341
|
+
*
|
|
342
|
+
* @param networkCanvasHost - Network canvas host element.
|
|
343
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
344
|
+
* @returns Nothing.
|
|
345
|
+
*/
|
|
346
|
+
function applyNetworkCanvasHostHeight(
|
|
347
|
+
networkCanvasHost: HTMLElement,
|
|
348
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
349
|
+
): void {
|
|
350
|
+
// Step 1: Update the host height only when the fixed target changed.
|
|
351
|
+
if (
|
|
352
|
+
networkCanvasHost.offsetHeight === FLAPPY_UI_NETWORK_HOST_FIXED_HEIGHT_PX
|
|
353
|
+
) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Step 2: Apply the fixed host height and request a post-layout redraw.
|
|
358
|
+
networkCanvasHost.style.height = `${FLAPPY_UI_NETWORK_HOST_FIXED_HEIGHT_PX}px`;
|
|
359
|
+
deferredNetworkRedrawController.requestNetworkRedrawAfterLayout();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Applies the resolved dimensions and scrolling rules to the stats container.
|
|
364
|
+
*
|
|
365
|
+
* @param statsContainer - Stats host element.
|
|
366
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
367
|
+
* @param statsPanelDimensions - Resolved stats panel dimensions.
|
|
368
|
+
* @returns Nothing.
|
|
369
|
+
*/
|
|
370
|
+
function applyStatsContainerDimensions(
|
|
371
|
+
statsContainer: HTMLElement,
|
|
372
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
373
|
+
statsPanelDimensions: StatsPanelDimensions,
|
|
374
|
+
): void {
|
|
375
|
+
// Step 1: Apply the resolved stats panel height.
|
|
376
|
+
statsContainer.style.height = `${statsPanelDimensions.adjustedStatsPanelHeightPx}px`;
|
|
377
|
+
statsContainer.style.maxHeight = `${statsPanelDimensions.adjustedStatsPanelHeightPx}px`;
|
|
378
|
+
|
|
379
|
+
// Step 2: Apply width and scrolling rules that differ between landscape and stacked layouts.
|
|
380
|
+
statsContainer.style.width =
|
|
381
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
382
|
+
? `${statsPanelDimensions.resolvedStatsPanelWidthPx}px`
|
|
383
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize;
|
|
384
|
+
statsContainer.style.maxWidth =
|
|
385
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
386
|
+
? `${statsPanelDimensions.resolvedStatsPanelWidthPx}px`
|
|
387
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize;
|
|
388
|
+
statsContainer.style.overflowY =
|
|
389
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
390
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoOverflow
|
|
391
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenOverflow;
|
|
392
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyMinimalMobileViewportLayout,
|
|
3
|
+
applyResponsiveCanvasBounds,
|
|
4
|
+
applyStandardViewportLayout,
|
|
5
|
+
createDeferredNetworkRedrawController,
|
|
6
|
+
installResponsiveViewportSizingListeners,
|
|
7
|
+
} from './host.resize.service.services';
|
|
8
|
+
import { resolveResponsiveViewportLayoutContext } from './host.resize.service.utils';
|
|
9
|
+
import type {
|
|
10
|
+
DeferredNetworkRedrawController,
|
|
11
|
+
ResponsiveViewportSizingElements,
|
|
12
|
+
} from './host.resize.service.types';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Top-level responsive sizing orchestration for the browser host.
|
|
16
|
+
*
|
|
17
|
+
* This module wires the host resize lifecycle together: gather the relevant DOM
|
|
18
|
+
* elements, run the initial layout pass, and keep canvas sizing synchronized with
|
|
19
|
+
* viewport changes over time.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Installs responsive viewport sizing for simulation and network canvases.
|
|
24
|
+
*
|
|
25
|
+
* This is the public entrypoint used by host assembly. It captures the elements,
|
|
26
|
+
* creates the deferred redraw policy, runs the first layout pass, and installs
|
|
27
|
+
* ongoing resize listeners.
|
|
28
|
+
*
|
|
29
|
+
* @param canvas - Simulation canvas to resize.
|
|
30
|
+
* @param containerElement - Width/height source.
|
|
31
|
+
* @param mainSplitContainer - Main split panel host.
|
|
32
|
+
* @param statsContainer - Stats host element.
|
|
33
|
+
* @param statsSplitContainer - Stats split panel containing stats and network panes.
|
|
34
|
+
* @param statsTableHost - Stats table host element.
|
|
35
|
+
* @param networkCanvas - Network canvas.
|
|
36
|
+
* @param networkCanvasHost - Network host element.
|
|
37
|
+
* @param onNetworkResize - Callback after network resize.
|
|
38
|
+
* @returns Nothing.
|
|
39
|
+
*/
|
|
40
|
+
export function installResponsiveViewportSizing(
|
|
41
|
+
canvas: HTMLCanvasElement,
|
|
42
|
+
containerElement: HTMLElement,
|
|
43
|
+
mainSplitContainer: HTMLElement,
|
|
44
|
+
statsContainer: HTMLElement,
|
|
45
|
+
statsSplitContainer: HTMLElement,
|
|
46
|
+
statsTableHost: HTMLElement,
|
|
47
|
+
networkCanvas: HTMLCanvasElement,
|
|
48
|
+
networkCanvasHost: HTMLElement,
|
|
49
|
+
onNetworkResize: () => void,
|
|
50
|
+
): void {
|
|
51
|
+
// Step 1: Capture the DOM elements involved in responsive host sizing.
|
|
52
|
+
const responsiveViewportSizingElements: ResponsiveViewportSizingElements = {
|
|
53
|
+
canvas,
|
|
54
|
+
containerElement,
|
|
55
|
+
mainSplitContainer,
|
|
56
|
+
statsContainer,
|
|
57
|
+
statsSplitContainer,
|
|
58
|
+
statsTableHost,
|
|
59
|
+
networkCanvas,
|
|
60
|
+
networkCanvasHost,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Step 2: Create the deferred redraw controller used after layout-affecting changes.
|
|
64
|
+
const deferredNetworkRedrawController =
|
|
65
|
+
createDeferredNetworkRedrawController(onNetworkResize);
|
|
66
|
+
|
|
67
|
+
// Step 3: Build the shared sizing callback used by initial load and resize events.
|
|
68
|
+
const applyCanvasSize = (): void => {
|
|
69
|
+
applyResponsiveViewportSizing(
|
|
70
|
+
responsiveViewportSizingElements,
|
|
71
|
+
deferredNetworkRedrawController,
|
|
72
|
+
onNetworkResize,
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Step 4: Run the initial sizing pass and install resize observers.
|
|
77
|
+
applyCanvasSize();
|
|
78
|
+
installResponsiveViewportSizingListeners(
|
|
79
|
+
containerElement,
|
|
80
|
+
applyCanvasSize,
|
|
81
|
+
deferredNetworkRedrawController,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Applies responsive sizing to the simulation and network canvases.
|
|
87
|
+
*
|
|
88
|
+
* The resize flow is intentionally split into two branches: the minimal mobile
|
|
89
|
+
* path and the richer standard path used for tablet and desktop layouts.
|
|
90
|
+
*
|
|
91
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
92
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
93
|
+
* @param onNetworkResize - Immediate network resize callback.
|
|
94
|
+
* @returns Nothing.
|
|
95
|
+
*/
|
|
96
|
+
function applyResponsiveViewportSizing(
|
|
97
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
98
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
99
|
+
onNetworkResize: () => void,
|
|
100
|
+
): void {
|
|
101
|
+
// Step 1: Measure the current viewport constraints and layout mode flags.
|
|
102
|
+
const responsiveViewportLayoutContext =
|
|
103
|
+
resolveResponsiveViewportLayoutContext(
|
|
104
|
+
responsiveViewportSizingElements.containerElement,
|
|
105
|
+
responsiveViewportSizingElements.statsContainer,
|
|
106
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// Step 2: Route the simplest mobile layout through the dedicated minimal-flow helper.
|
|
110
|
+
if (responsiveViewportLayoutContext.useMinimalMobileLayout) {
|
|
111
|
+
applyMinimalMobileViewportLayout(
|
|
112
|
+
responsiveViewportSizingElements,
|
|
113
|
+
responsiveViewportLayoutContext,
|
|
114
|
+
);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Step 3: Apply the desktop and tablet host layout and resolve stats panel dimensions.
|
|
119
|
+
const statsPanelDimensions = applyStandardViewportLayout(
|
|
120
|
+
responsiveViewportSizingElements,
|
|
121
|
+
responsiveViewportLayoutContext,
|
|
122
|
+
deferredNetworkRedrawController,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Step 4: Resize the simulation and network canvases for the resolved layout.
|
|
126
|
+
applyResponsiveCanvasBounds(
|
|
127
|
+
responsiveViewportSizingElements,
|
|
128
|
+
responsiveViewportLayoutContext,
|
|
129
|
+
statsPanelDimensions,
|
|
130
|
+
onNetworkResize,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contracts for responsive browser-host sizing.
|
|
3
|
+
*
|
|
4
|
+
* The resize subsystem coordinates several DOM elements and several layout modes
|
|
5
|
+
* at once, so these types capture the measured viewport state, the active mode
|
|
6
|
+
* flags, and the grouped DOM handles needed by the appliers.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* DOM elements that participate in responsive host sizing.
|
|
11
|
+
*
|
|
12
|
+
* Keeping the participating elements together makes the responsive helpers read
|
|
13
|
+
* as layout orchestration rather than long DOM parameter lists.
|
|
14
|
+
*/
|
|
15
|
+
export type ResponsiveViewportSizingElements = {
|
|
16
|
+
canvas: HTMLCanvasElement;
|
|
17
|
+
containerElement: HTMLElement;
|
|
18
|
+
mainSplitContainer: HTMLElement;
|
|
19
|
+
statsContainer: HTMLElement;
|
|
20
|
+
statsSplitContainer: HTMLElement;
|
|
21
|
+
statsTableHost: HTMLElement;
|
|
22
|
+
networkCanvas: HTMLCanvasElement;
|
|
23
|
+
networkCanvasHost: HTMLElement;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Deferred redraw controller used after layout-affecting changes.
|
|
28
|
+
*
|
|
29
|
+
* The network panel redraw is deferred because flexbox and canvas sizing can
|
|
30
|
+
* settle over multiple animation frames.
|
|
31
|
+
*/
|
|
32
|
+
export type DeferredNetworkRedrawController = {
|
|
33
|
+
requestNetworkRedrawAfterLayout: () => void;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Measured viewport and panel budgets for responsive layout.
|
|
38
|
+
*
|
|
39
|
+
* These values are the raw numeric inputs to the resize policy before any mode
|
|
40
|
+
* branching happens.
|
|
41
|
+
*/
|
|
42
|
+
export type ResponsiveViewportMeasurements = {
|
|
43
|
+
headerHeightPx: number;
|
|
44
|
+
nonNetworkStatsHeightPx: number;
|
|
45
|
+
hardMinimumSimulationHeightPx: number;
|
|
46
|
+
totalCanvasBudgetPx: number;
|
|
47
|
+
viewportWidthPx: number;
|
|
48
|
+
viewportHeightPx: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Layout-mode flags resolved from the current viewport.
|
|
53
|
+
*
|
|
54
|
+
* The host currently distinguishes between minimal mobile, landscape split, and
|
|
55
|
+
* compact network-only variants.
|
|
56
|
+
*/
|
|
57
|
+
export type ResponsiveViewportLayoutFlags = {
|
|
58
|
+
useMinimalMobileLayout: boolean;
|
|
59
|
+
useLandscapeSplitLayout: boolean;
|
|
60
|
+
useNetworkOnlyPanel: boolean;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Full responsive layout context shared across sizing helpers.
|
|
65
|
+
*
|
|
66
|
+
* This merges measurements and mode flags into the one context object used by
|
|
67
|
+
* the resize appliers.
|
|
68
|
+
*/
|
|
69
|
+
export type ResponsiveViewportLayoutContext = ResponsiveViewportMeasurements &
|
|
70
|
+
ResponsiveViewportLayoutFlags;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Resolved height and width budgets for the stats panel.
|
|
74
|
+
*
|
|
75
|
+
* The stats panel dimensions are derived from the current viewport budget after
|
|
76
|
+
* minimum readable canvas space is reserved.
|
|
77
|
+
*/
|
|
78
|
+
export type StatsPanelDimensions = {
|
|
79
|
+
adjustedStatsPanelHeightPx: number;
|
|
80
|
+
resolvedStatsPanelWidthPx: number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Width and height bounds for the simulation canvas.
|
|
85
|
+
*
|
|
86
|
+
* These are the final pixel budgets the simulation canvas may consume for the
|
|
87
|
+
* current responsive layout.
|
|
88
|
+
*/
|
|
89
|
+
export type SimulationCanvasBounds = {
|
|
90
|
+
availableWidthPx: number;
|
|
91
|
+
availableHeightPx: number;
|
|
92
|
+
};
|