@reicek/neataptic-ts 0.1.21 → 0.1.22
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 +29 -0
- package/.github/agents/docs-scout.agent.md +29 -0
- package/.github/agents/plan-scout.agent.md +29 -0
- package/.github/agents/solid-split.agent.md +138 -0
- package/.github/copilot-instructions.md +103 -0
- package/package.json +6 -3
- package/plans/ES2023 migration +13 -8
- package/plans/Evolution_Training_Interoperability_Contracts.md +1 -1
- 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/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 +101 -223
- package/src/architecture/README.md +57 -185
- package/src/architecture/layer/README.md +38 -38
- package/src/architecture/network/README.md +33 -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/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/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/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 +562 -568
- 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/Trace-20260309T191949.json +24124 -0
- package/test/examples/flappy_bird/browser-entry/README.md +1129 -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 +6 -399
- package/test/examples/flappy_bird/browser-entry/browser-entry.playback.utils.ts +1 -717
- package/test/examples/flappy_bird/browser-entry/browser-entry.spawn.utils.ts +11 -31
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.utils.ts +15 -893
- package/test/examples/flappy_bird/browser-entry/host/README.md +307 -0
- package/test/examples/flappy_bird/browser-entry/host/host.resize.service.ts +1 -295
- package/test/examples/flappy_bird/browser-entry/host/host.ts +562 -6
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +274 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.constants.ts +31 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.services.ts +360 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.ts +117 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types.ts +63 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.utils.ts +250 -0
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +399 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.topology.utils.ts +255 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.ts +802 -7
- package/test/examples/flappy_bird/browser-entry/playback/README.md +684 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +277 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +770 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.cache.services.ts +178 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.constants.ts +107 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.utils.ts +518 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.ts +117 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.ts +233 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.services.ts +211 -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 +212 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.utils.ts +81 -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 +62 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.services.ts +244 -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 +68 -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 +310 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.services.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.types.ts +39 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.utils.ts +493 -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 +4 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.ts +44 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.service.ts +39 -122
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.services.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.types.ts +62 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.utils.ts +11 -4
- package/test/examples/flappy_bird/browser-entry/playback/playback.ts +409 -8
- package/test/examples/flappy_bird/browser-entry/playback/playback.types.ts +4 -12
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +235 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-launch.service.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.lifecycle.service.ts +81 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.startup.service.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.ts +31 -121
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.types.ts +36 -0
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +557 -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 +957 -19
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.legend.utils.ts +138 -3
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.topology.utils.ts +3 -27
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.ts +1 -23
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +156 -0
- package/test/examples/flappy_bird/constants/README.md +1179 -0
- package/test/examples/flappy_bird/constants/constants.network-view.ts +24 -0
- package/test/examples/flappy_bird/constants/constants.palette.ts +7 -0
- package/test/examples/flappy_bird/constants/constants.starfield.ts +78 -3
- package/test/examples/flappy_bird/environment/README.md +143 -0
- package/test/examples/flappy_bird/environment/environment.observation.utils.ts +1 -19
- package/test/examples/flappy_bird/environment/environment.step.service.ts +3 -66
- package/test/examples/flappy_bird/evaluation/README.md +130 -0
- package/test/examples/flappy_bird/evaluation/evaluation.fitness.utils.ts +1 -1
- package/test/examples/flappy_bird/evaluation/evaluation.rollout.service.ts +5 -375
- package/test/examples/flappy_bird/evaluation/rollout/README.md +291 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.constants.ts +30 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.service.ts +58 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.services.ts +310 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.types.ts +56 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.utils.ts +368 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +618 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.playback.service.ts +7 -7
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.frame.service.ts +364 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types.ts +14 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts +4 -201
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +184 -345
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts +291 -0
- package/test/examples/flappy_bird/flappy.simulation.shared.utils.ts +5 -0
- package/test/examples/flappy_bird/simulation-shared/README.md +417 -0
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +183 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.features.utils.ts +301 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.ts +9 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.vector.utils.ts +59 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.observation.utils.ts +5 -403
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.spawn.utils.ts +20 -6
- package/test/examples/flappy_bird/{evaluation/evaluation.statistics.utils.ts → simulation-shared/simulation-shared.statistics.utils.ts} +23 -8
- package/test/examples/flappy_bird/trainer/README.md +563 -0
- package/test/examples/flappy_bird/trainer/evaluation/README.md +199 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.constants.ts +9 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.services.ts +73 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.ts +165 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.types.ts +25 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.utils.ts +161 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation.service.ts +13 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.services.ts +181 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.ts +126 -0
- package/test/examples/flappy_bird/trainer/trainer.selection.utils.ts +89 -0
- package/test/examples/flappy_bird/trainer/trainer.ts +11 -553
- 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,274 @@
|
|
|
1
|
+
# browser-entry/host/resize
|
|
2
|
+
|
|
3
|
+
## browser-entry/host/resize/host.resize.service.types.ts
|
|
4
|
+
|
|
5
|
+
### host.resize.service.types
|
|
6
|
+
|
|
7
|
+
DOM elements that participate in responsive host sizing.
|
|
8
|
+
|
|
9
|
+
### DeferredNetworkRedrawController
|
|
10
|
+
|
|
11
|
+
Deferred redraw controller used after layout-affecting changes.
|
|
12
|
+
|
|
13
|
+
### ResponsiveViewportLayoutContext
|
|
14
|
+
|
|
15
|
+
Full responsive layout context shared across sizing helpers.
|
|
16
|
+
|
|
17
|
+
### ResponsiveViewportLayoutFlags
|
|
18
|
+
|
|
19
|
+
Layout-mode flags resolved from the current viewport.
|
|
20
|
+
|
|
21
|
+
### ResponsiveViewportMeasurements
|
|
22
|
+
|
|
23
|
+
Measured viewport and panel budgets for responsive layout.
|
|
24
|
+
|
|
25
|
+
### ResponsiveViewportSizingElements
|
|
26
|
+
|
|
27
|
+
DOM elements that participate in responsive host sizing.
|
|
28
|
+
|
|
29
|
+
### SimulationCanvasBounds
|
|
30
|
+
|
|
31
|
+
Width and height bounds for the simulation canvas.
|
|
32
|
+
|
|
33
|
+
### StatsPanelDimensions
|
|
34
|
+
|
|
35
|
+
Resolved height and width budgets for the stats panel.
|
|
36
|
+
|
|
37
|
+
## browser-entry/host/resize/host.resize.service.ts
|
|
38
|
+
|
|
39
|
+
### applyResponsiveViewportSizing
|
|
40
|
+
|
|
41
|
+
`(responsiveViewportSizingElements: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportSizingElements, deferredNetworkRedrawController: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").DeferredNetworkRedrawController, onNetworkResize: () => void) => void`
|
|
42
|
+
|
|
43
|
+
Applies responsive sizing to the simulation and network canvases.
|
|
44
|
+
|
|
45
|
+
Parameters:
|
|
46
|
+
|
|
47
|
+
- `responsiveViewportSizingElements` - - Host elements participating in layout.
|
|
48
|
+
- `deferredNetworkRedrawController` - - Deferred redraw controller.
|
|
49
|
+
- `onNetworkResize` - - Immediate network resize callback.
|
|
50
|
+
|
|
51
|
+
Returns: Nothing.
|
|
52
|
+
|
|
53
|
+
### installResponsiveViewportSizing
|
|
54
|
+
|
|
55
|
+
`(canvas: HTMLCanvasElement, containerElement: HTMLElement, mainSplitContainer: HTMLElement, statsContainer: HTMLElement, statsSplitContainer: HTMLElement, statsTableHost: HTMLElement, networkCanvas: HTMLCanvasElement, networkCanvasHost: HTMLElement, onNetworkResize: () => void) => void`
|
|
56
|
+
|
|
57
|
+
Installs responsive viewport sizing for simulation and network canvases.
|
|
58
|
+
|
|
59
|
+
Parameters:
|
|
60
|
+
|
|
61
|
+
- `canvas` - - Simulation canvas to resize.
|
|
62
|
+
- `containerElement` - - Width/height source.
|
|
63
|
+
- `mainSplitContainer` - - Main split panel host.
|
|
64
|
+
- `statsContainer` - - Stats host element.
|
|
65
|
+
- `statsSplitContainer` - - Stats split panel containing stats and network panes.
|
|
66
|
+
- `statsTableHost` - - Stats table host element.
|
|
67
|
+
- `networkCanvas` - - Network canvas.
|
|
68
|
+
- `networkCanvasHost` - - Network host element.
|
|
69
|
+
- `onNetworkResize` - - Callback after network resize.
|
|
70
|
+
|
|
71
|
+
Returns: Nothing.
|
|
72
|
+
|
|
73
|
+
## browser-entry/host/resize/host.resize.service.services.ts
|
|
74
|
+
|
|
75
|
+
### applyMinimalMobileViewportLayout
|
|
76
|
+
|
|
77
|
+
`(responsiveViewportSizingElements: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportSizingElements, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext) => void`
|
|
78
|
+
|
|
79
|
+
Applies the minimal mobile layout that hides the auxiliary panes.
|
|
80
|
+
|
|
81
|
+
Parameters:
|
|
82
|
+
|
|
83
|
+
- `responsiveViewportSizingElements` - - Host elements participating in layout.
|
|
84
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
85
|
+
|
|
86
|
+
Returns: Nothing.
|
|
87
|
+
|
|
88
|
+
### applyNetworkCanvasHostHeight
|
|
89
|
+
|
|
90
|
+
`(networkCanvasHost: HTMLElement, deferredNetworkRedrawController: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").DeferredNetworkRedrawController) => void`
|
|
91
|
+
|
|
92
|
+
Applies the fixed network host height and queues redraw when it changes.
|
|
93
|
+
|
|
94
|
+
Parameters:
|
|
95
|
+
|
|
96
|
+
- `networkCanvasHost` - - Network canvas host element.
|
|
97
|
+
- `deferredNetworkRedrawController` - - Deferred redraw controller.
|
|
98
|
+
|
|
99
|
+
Returns: Nothing.
|
|
100
|
+
|
|
101
|
+
### applyResponsiveCanvasBounds
|
|
102
|
+
|
|
103
|
+
`(responsiveViewportSizingElements: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportSizingElements, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext, statsPanelDimensions: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").StatsPanelDimensions, onNetworkResize: () => void) => void`
|
|
104
|
+
|
|
105
|
+
Applies simulation and network canvas backing sizes for the active layout.
|
|
106
|
+
|
|
107
|
+
Parameters:
|
|
108
|
+
|
|
109
|
+
- `responsiveViewportSizingElements` - - Host elements participating in layout.
|
|
110
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
111
|
+
- `statsPanelDimensions` - - Resolved stats panel dimensions.
|
|
112
|
+
- `onNetworkResize` - - Immediate network resize callback.
|
|
113
|
+
|
|
114
|
+
Returns: Nothing.
|
|
115
|
+
|
|
116
|
+
### applySplitContainerLayoutStyles
|
|
117
|
+
|
|
118
|
+
`(responsiveViewportSizingElements: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportSizingElements, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext) => void`
|
|
119
|
+
|
|
120
|
+
Applies the split-container styles for the standard layout modes.
|
|
121
|
+
|
|
122
|
+
Parameters:
|
|
123
|
+
|
|
124
|
+
- `responsiveViewportSizingElements` - - Host elements participating in layout.
|
|
125
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
126
|
+
|
|
127
|
+
Returns: Nothing.
|
|
128
|
+
|
|
129
|
+
### applyStandardViewportLayout
|
|
130
|
+
|
|
131
|
+
`(responsiveViewportSizingElements: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportSizingElements, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext, deferredNetworkRedrawController: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").DeferredNetworkRedrawController) => import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").StatsPanelDimensions`
|
|
132
|
+
|
|
133
|
+
Applies the standard tablet and desktop layout and returns panel dimensions.
|
|
134
|
+
|
|
135
|
+
Parameters:
|
|
136
|
+
|
|
137
|
+
- `responsiveViewportSizingElements` - - Host elements participating in layout.
|
|
138
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
139
|
+
- `deferredNetworkRedrawController` - - Deferred redraw controller.
|
|
140
|
+
|
|
141
|
+
Returns: Resolved stats panel dimensions.
|
|
142
|
+
|
|
143
|
+
### applyStatsContainerDimensions
|
|
144
|
+
|
|
145
|
+
`(statsContainer: HTMLElement, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext, statsPanelDimensions: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").StatsPanelDimensions) => void`
|
|
146
|
+
|
|
147
|
+
Applies the resolved dimensions and scrolling rules to the stats container.
|
|
148
|
+
|
|
149
|
+
Parameters:
|
|
150
|
+
|
|
151
|
+
- `statsContainer` - - Stats host element.
|
|
152
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
153
|
+
- `statsPanelDimensions` - - Resolved stats panel dimensions.
|
|
154
|
+
|
|
155
|
+
Returns: Nothing.
|
|
156
|
+
|
|
157
|
+
### applyStatsPaneOrdering
|
|
158
|
+
|
|
159
|
+
`(statsTableHost: HTMLElement, networkCanvasHost: HTMLElement, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext) => void`
|
|
160
|
+
|
|
161
|
+
Applies ordering and flex styles for stats and network panes.
|
|
162
|
+
|
|
163
|
+
Parameters:
|
|
164
|
+
|
|
165
|
+
- `statsTableHost` - - Stats table host element.
|
|
166
|
+
- `networkCanvasHost` - - Network canvas host element.
|
|
167
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
168
|
+
|
|
169
|
+
Returns: Nothing.
|
|
170
|
+
|
|
171
|
+
### createDeferredNetworkRedrawController
|
|
172
|
+
|
|
173
|
+
`(onNetworkResize: () => void) => import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").DeferredNetworkRedrawController`
|
|
174
|
+
|
|
175
|
+
Creates a deferred redraw controller that waits for layout to settle.
|
|
176
|
+
|
|
177
|
+
Parameters:
|
|
178
|
+
|
|
179
|
+
- `onNetworkResize` - - Callback after network resize.
|
|
180
|
+
|
|
181
|
+
Returns: Deferred redraw controller.
|
|
182
|
+
|
|
183
|
+
### installResponsiveViewportSizingListeners
|
|
184
|
+
|
|
185
|
+
`(containerElement: HTMLElement, applyCanvasSize: () => void, deferredNetworkRedrawController: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").DeferredNetworkRedrawController) => void`
|
|
186
|
+
|
|
187
|
+
Installs window and container listeners for responsive host sizing.
|
|
188
|
+
|
|
189
|
+
Parameters:
|
|
190
|
+
|
|
191
|
+
- `containerElement` - - Width and height source.
|
|
192
|
+
- `applyCanvasSize` - - Shared sizing callback.
|
|
193
|
+
- `deferredNetworkRedrawController` - - Deferred redraw controller.
|
|
194
|
+
|
|
195
|
+
Returns: Nothing.
|
|
196
|
+
|
|
197
|
+
## browser-entry/host/resize/host.resize.service.constants.ts
|
|
198
|
+
|
|
199
|
+
### host.resize.service.constants
|
|
200
|
+
|
|
201
|
+
Shared CSS tokens used by the host resize layout appliers.
|
|
202
|
+
|
|
203
|
+
### FLAPPY_HOST_RESIZE_MIN_DIMENSION_PX
|
|
204
|
+
|
|
205
|
+
### FLAPPY_HOST_RESIZE_SPLIT_RATIO
|
|
206
|
+
|
|
207
|
+
### FLAPPY_HOST_RESIZE_STYLE_TOKENS
|
|
208
|
+
|
|
209
|
+
## browser-entry/host/resize/host.resize.service.utils.ts
|
|
210
|
+
|
|
211
|
+
### resolveHeaderHeightPx
|
|
212
|
+
|
|
213
|
+
`(containerElement: HTMLElement) => number`
|
|
214
|
+
|
|
215
|
+
Resolves the header canvas height, if present.
|
|
216
|
+
|
|
217
|
+
Parameters:
|
|
218
|
+
|
|
219
|
+
- `containerElement` - - Width and height source.
|
|
220
|
+
|
|
221
|
+
Returns: Header height in pixels.
|
|
222
|
+
|
|
223
|
+
### resolveMinimalMobileCanvasBounds
|
|
224
|
+
|
|
225
|
+
`(containerElement: HTMLElement, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext) => import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").SimulationCanvasBounds`
|
|
226
|
+
|
|
227
|
+
Resolves the simulation canvas bounds for the minimal mobile layout.
|
|
228
|
+
|
|
229
|
+
Parameters:
|
|
230
|
+
|
|
231
|
+
- `containerElement` - - Width and height source.
|
|
232
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
233
|
+
|
|
234
|
+
Returns: Simulation canvas bounds.
|
|
235
|
+
|
|
236
|
+
### resolveResponsiveViewportLayoutContext
|
|
237
|
+
|
|
238
|
+
`(containerElement: HTMLElement, statsContainer: HTMLElement, networkCanvasHost: HTMLElement) => import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext`
|
|
239
|
+
|
|
240
|
+
Resolves responsive layout measurements and mode flags from the host DOM.
|
|
241
|
+
|
|
242
|
+
Parameters:
|
|
243
|
+
|
|
244
|
+
- `containerElement` - - Width and height source.
|
|
245
|
+
- `statsContainer` - - Stats host element.
|
|
246
|
+
- `networkCanvasHost` - - Network host element.
|
|
247
|
+
|
|
248
|
+
Returns: Responsive layout context.
|
|
249
|
+
|
|
250
|
+
### resolveSimulationCanvasBounds
|
|
251
|
+
|
|
252
|
+
`(containerElement: HTMLElement, responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext, statsPanelDimensions: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").StatsPanelDimensions) => import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").SimulationCanvasBounds`
|
|
253
|
+
|
|
254
|
+
Resolves simulation canvas bounds from the current viewport layout.
|
|
255
|
+
|
|
256
|
+
Parameters:
|
|
257
|
+
|
|
258
|
+
- `containerElement` - - Width and height source.
|
|
259
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
260
|
+
- `statsPanelDimensions` - - Resolved stats panel dimensions.
|
|
261
|
+
|
|
262
|
+
Returns: Simulation canvas bounds.
|
|
263
|
+
|
|
264
|
+
### resolveStatsPanelDimensions
|
|
265
|
+
|
|
266
|
+
`(responsiveViewportLayoutContext: import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").ResponsiveViewportLayoutContext) => import("test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types").StatsPanelDimensions`
|
|
267
|
+
|
|
268
|
+
Resolves the stats panel height and width budgets.
|
|
269
|
+
|
|
270
|
+
Parameters:
|
|
271
|
+
|
|
272
|
+
- `responsiveViewportLayoutContext` - - Responsive layout context.
|
|
273
|
+
|
|
274
|
+
Returns: Stats panel dimensions.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CSS tokens used by the host resize layout appliers.
|
|
3
|
+
*/
|
|
4
|
+
export const FLAPPY_HOST_RESIZE_STYLE_TOKENS = {
|
|
5
|
+
rowDirection: 'row' as CSSStyleDeclaration['flexDirection'],
|
|
6
|
+
columnDirection: 'column' as CSSStyleDeclaration['flexDirection'],
|
|
7
|
+
stretchAlignment: 'stretch' as CSSStyleDeclaration['alignItems'],
|
|
8
|
+
flexStartAlignment: 'flex-start' as CSSStyleDeclaration['alignItems'],
|
|
9
|
+
hiddenDisplay: 'none' as CSSStyleDeclaration['display'],
|
|
10
|
+
blockDisplay: 'block' as CSSStyleDeclaration['display'],
|
|
11
|
+
autoSize: 'auto',
|
|
12
|
+
zeroSizePx: '0px',
|
|
13
|
+
fullSize: '100%',
|
|
14
|
+
hiddenOverflow: 'hidden' as CSSStyleDeclaration['overflowY'],
|
|
15
|
+
autoOverflow: 'auto' as CSSStyleDeclaration['overflowY'],
|
|
16
|
+
primaryOrder: '0',
|
|
17
|
+
secondaryOrder: '1',
|
|
18
|
+
autoFlex: '0 0 auto',
|
|
19
|
+
fillFlex: '1 1 0',
|
|
20
|
+
fullFlex: '1 1 100%',
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Split ratio used when dividing the viewport between simulation and stats.
|
|
25
|
+
*/
|
|
26
|
+
export const FLAPPY_HOST_RESIZE_SPLIT_RATIO = 0.5;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Minimum positive dimension enforced by resize math.
|
|
30
|
+
*/
|
|
31
|
+
export const FLAPPY_HOST_RESIZE_MIN_DIMENSION_PX = 1;
|
|
@@ -0,0 +1,360 @@
|
|
|
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
|
+
* Creates a deferred redraw controller that waits for layout to settle.
|
|
27
|
+
*
|
|
28
|
+
* @param onNetworkResize - Callback after network resize.
|
|
29
|
+
* @returns Deferred redraw controller.
|
|
30
|
+
*/
|
|
31
|
+
export function createDeferredNetworkRedrawController(
|
|
32
|
+
onNetworkResize: () => void,
|
|
33
|
+
): DeferredNetworkRedrawController {
|
|
34
|
+
let pendingNetworkRedrawRequest = false;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
requestNetworkRedrawAfterLayout: (): void => {
|
|
38
|
+
// Step 1: Skip duplicate redraw requests while one is already queued.
|
|
39
|
+
if (pendingNetworkRedrawRequest) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
pendingNetworkRedrawRequest = true;
|
|
43
|
+
|
|
44
|
+
// Step 2: Wait two animation frames so flexbox layout has settled before redrawing.
|
|
45
|
+
requestAnimationFrame(() => {
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
pendingNetworkRedrawRequest = false;
|
|
48
|
+
onNetworkResize();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Applies the minimal mobile layout that hides the auxiliary panes.
|
|
57
|
+
*
|
|
58
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
59
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
60
|
+
* @returns Nothing.
|
|
61
|
+
*/
|
|
62
|
+
export function applyMinimalMobileViewportLayout(
|
|
63
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
64
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
65
|
+
): void {
|
|
66
|
+
// Step 1: Arrange the split containers so gameplay occupies the full vertical budget.
|
|
67
|
+
responsiveViewportSizingElements.mainSplitContainer.style.flexDirection =
|
|
68
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.columnDirection;
|
|
69
|
+
responsiveViewportSizingElements.mainSplitContainer.style.gap = `${FLAPPY_VIEWPORT_VERTICAL_LAYOUT_GUTTER_PX}px`;
|
|
70
|
+
responsiveViewportSizingElements.statsSplitContainer.style.flexDirection =
|
|
71
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.rowDirection;
|
|
72
|
+
responsiveViewportSizingElements.statsSplitContainer.style.alignItems =
|
|
73
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.flexStartAlignment;
|
|
74
|
+
responsiveViewportSizingElements.statsSplitContainer.style.height =
|
|
75
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoSize;
|
|
76
|
+
responsiveViewportSizingElements.statsTableHost.style.order =
|
|
77
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.primaryOrder;
|
|
78
|
+
responsiveViewportSizingElements.networkCanvasHost.style.order =
|
|
79
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.secondaryOrder;
|
|
80
|
+
|
|
81
|
+
// Step 2: Hide the stats pane so the simulation canvas gets the full available height.
|
|
82
|
+
responsiveViewportSizingElements.statsContainer.style.display =
|
|
83
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenDisplay;
|
|
84
|
+
responsiveViewportSizingElements.statsContainer.style.height =
|
|
85
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.zeroSizePx;
|
|
86
|
+
responsiveViewportSizingElements.statsContainer.style.maxHeight =
|
|
87
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.zeroSizePx;
|
|
88
|
+
responsiveViewportSizingElements.statsContainer.style.overflowY =
|
|
89
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenOverflow;
|
|
90
|
+
|
|
91
|
+
// Step 3: Apply the simulation canvas backing size directly from the mobile viewport budget.
|
|
92
|
+
const mobileCanvasBounds = resolveMinimalMobileCanvasBounds(
|
|
93
|
+
responsiveViewportSizingElements.containerElement,
|
|
94
|
+
responsiveViewportLayoutContext,
|
|
95
|
+
);
|
|
96
|
+
applyCanvasBackingSize(
|
|
97
|
+
responsiveViewportSizingElements.canvas,
|
|
98
|
+
mobileCanvasBounds.availableWidthPx,
|
|
99
|
+
mobileCanvasBounds.availableHeightPx,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Applies the standard tablet and desktop layout and returns panel dimensions.
|
|
105
|
+
*
|
|
106
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
107
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
108
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
109
|
+
* @returns Resolved stats panel dimensions.
|
|
110
|
+
*/
|
|
111
|
+
export function applyStandardViewportLayout(
|
|
112
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
113
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
114
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
115
|
+
): StatsPanelDimensions {
|
|
116
|
+
// Step 1: Restore the stats container and apply split orientation styles.
|
|
117
|
+
responsiveViewportSizingElements.statsContainer.style.display =
|
|
118
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.blockDisplay;
|
|
119
|
+
applySplitContainerLayoutStyles(
|
|
120
|
+
responsiveViewportSizingElements,
|
|
121
|
+
responsiveViewportLayoutContext,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// Step 2: Resolve the stats panel dimensions from the current viewport budget.
|
|
125
|
+
const statsPanelDimensions = resolveStatsPanelDimensions(
|
|
126
|
+
responsiveViewportLayoutContext,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Step 3: Clamp the network panel height and queue a redraw when the height changed.
|
|
130
|
+
applyNetworkCanvasHostHeight(
|
|
131
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
132
|
+
deferredNetworkRedrawController,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// Step 4: Apply the final stats container dimensions and scrolling rules.
|
|
136
|
+
applyStatsContainerDimensions(
|
|
137
|
+
responsiveViewportSizingElements.statsContainer,
|
|
138
|
+
responsiveViewportLayoutContext,
|
|
139
|
+
statsPanelDimensions,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
return statsPanelDimensions;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Applies simulation and network canvas backing sizes for the active layout.
|
|
147
|
+
*
|
|
148
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
149
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
150
|
+
* @param statsPanelDimensions - Resolved stats panel dimensions.
|
|
151
|
+
* @param onNetworkResize - Immediate network resize callback.
|
|
152
|
+
* @returns Nothing.
|
|
153
|
+
*/
|
|
154
|
+
export function applyResponsiveCanvasBounds(
|
|
155
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
156
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
157
|
+
statsPanelDimensions: StatsPanelDimensions,
|
|
158
|
+
onNetworkResize: () => void,
|
|
159
|
+
): void {
|
|
160
|
+
// Step 1: Resolve simulation canvas size from the remaining viewport budget.
|
|
161
|
+
const simulationCanvasBounds = resolveSimulationCanvasBounds(
|
|
162
|
+
responsiveViewportSizingElements.containerElement,
|
|
163
|
+
responsiveViewportLayoutContext,
|
|
164
|
+
statsPanelDimensions,
|
|
165
|
+
);
|
|
166
|
+
applySimulationCanvasBounds(
|
|
167
|
+
responsiveViewportSizingElements.canvas,
|
|
168
|
+
simulationCanvasBounds.availableWidthPx,
|
|
169
|
+
simulationCanvasBounds.availableHeightPx,
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// Step 2: Resize the network canvas backing store and redraw immediately when it changed.
|
|
173
|
+
const { widthPx, heightPx } = resolveNetworkCanvasSizePx(
|
|
174
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
175
|
+
FLAPPY_UI_NETWORK_HOST_INSET_PX,
|
|
176
|
+
);
|
|
177
|
+
if (
|
|
178
|
+
applyCanvasBackingSize(
|
|
179
|
+
responsiveViewportSizingElements.networkCanvas,
|
|
180
|
+
widthPx,
|
|
181
|
+
heightPx,
|
|
182
|
+
)
|
|
183
|
+
) {
|
|
184
|
+
onNetworkResize();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Installs window and container listeners for responsive host sizing.
|
|
190
|
+
*
|
|
191
|
+
* @param containerElement - Width and height source.
|
|
192
|
+
* @param applyCanvasSize - Shared sizing callback.
|
|
193
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
194
|
+
* @returns Nothing.
|
|
195
|
+
*/
|
|
196
|
+
export function installResponsiveViewportSizingListeners(
|
|
197
|
+
containerElement: HTMLElement,
|
|
198
|
+
applyCanvasSize: () => void,
|
|
199
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
200
|
+
): void {
|
|
201
|
+
// Step 1: Run the first post-layout redraw after the initial sizing pass.
|
|
202
|
+
deferredNetworkRedrawController.requestNetworkRedrawAfterLayout();
|
|
203
|
+
|
|
204
|
+
// Step 2: Recompute layout on window resize.
|
|
205
|
+
window.addEventListener('resize', applyCanvasSize);
|
|
206
|
+
|
|
207
|
+
// Step 3: Observe host-size changes when ResizeObserver is available.
|
|
208
|
+
if (typeof ResizeObserver !== 'function') {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
213
|
+
applyCanvasSize();
|
|
214
|
+
deferredNetworkRedrawController.requestNetworkRedrawAfterLayout();
|
|
215
|
+
});
|
|
216
|
+
resizeObserver.observe(containerElement);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Applies the split-container styles for the standard layout modes.
|
|
221
|
+
*
|
|
222
|
+
* @param responsiveViewportSizingElements - Host elements participating in layout.
|
|
223
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
224
|
+
* @returns Nothing.
|
|
225
|
+
*/
|
|
226
|
+
function applySplitContainerLayoutStyles(
|
|
227
|
+
responsiveViewportSizingElements: ResponsiveViewportSizingElements,
|
|
228
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
229
|
+
): void {
|
|
230
|
+
// Step 1: Configure the outer split direction based on landscape or stacked layout.
|
|
231
|
+
responsiveViewportSizingElements.mainSplitContainer.style.flexDirection =
|
|
232
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
233
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.rowDirection
|
|
234
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.columnDirection;
|
|
235
|
+
responsiveViewportSizingElements.mainSplitContainer.style.gap = `${FLAPPY_VIEWPORT_VERTICAL_LAYOUT_GUTTER_PX}px`;
|
|
236
|
+
|
|
237
|
+
// Step 2: Configure the inner stats/network split and alignment.
|
|
238
|
+
responsiveViewportSizingElements.statsSplitContainer.style.flexDirection =
|
|
239
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
240
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.columnDirection
|
|
241
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.rowDirection;
|
|
242
|
+
responsiveViewportSizingElements.statsSplitContainer.style.alignItems =
|
|
243
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
244
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.stretchAlignment
|
|
245
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.flexStartAlignment;
|
|
246
|
+
responsiveViewportSizingElements.statsSplitContainer.style.height =
|
|
247
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
248
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize
|
|
249
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoSize;
|
|
250
|
+
responsiveViewportSizingElements.statsSplitContainer.style.gap =
|
|
251
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
252
|
+
? '0'
|
|
253
|
+
: FLAPPY_HOST_STATS_SPLIT_GAP;
|
|
254
|
+
|
|
255
|
+
// Step 3: Apply stats/network ordering and flex rules for the chosen layout.
|
|
256
|
+
applyStatsPaneOrdering(
|
|
257
|
+
responsiveViewportSizingElements.statsTableHost,
|
|
258
|
+
responsiveViewportSizingElements.networkCanvasHost,
|
|
259
|
+
responsiveViewportLayoutContext,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Applies ordering and flex styles for stats and network panes.
|
|
265
|
+
*
|
|
266
|
+
* @param statsTableHost - Stats table host element.
|
|
267
|
+
* @param networkCanvasHost - Network canvas host element.
|
|
268
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
269
|
+
* @returns Nothing.
|
|
270
|
+
*/
|
|
271
|
+
function applyStatsPaneOrdering(
|
|
272
|
+
statsTableHost: HTMLElement,
|
|
273
|
+
networkCanvasHost: HTMLElement,
|
|
274
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
275
|
+
): void {
|
|
276
|
+
// Step 1: Order the network panel first only for landscape split layouts.
|
|
277
|
+
if (responsiveViewportLayoutContext.useLandscapeSplitLayout) {
|
|
278
|
+
networkCanvasHost.style.order =
|
|
279
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.primaryOrder;
|
|
280
|
+
statsTableHost.style.order = FLAPPY_HOST_RESIZE_STYLE_TOKENS.secondaryOrder;
|
|
281
|
+
} else {
|
|
282
|
+
statsTableHost.style.order = FLAPPY_HOST_RESIZE_STYLE_TOKENS.primaryOrder;
|
|
283
|
+
networkCanvasHost.style.order =
|
|
284
|
+
FLAPPY_HOST_RESIZE_STYLE_TOKENS.secondaryOrder;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Step 2: Collapse the stats table when the network-only compact panel is active.
|
|
288
|
+
statsTableHost.style.display =
|
|
289
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
290
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenDisplay
|
|
291
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.blockDisplay;
|
|
292
|
+
statsTableHost.style.flex =
|
|
293
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
294
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoFlex
|
|
295
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.fillFlex;
|
|
296
|
+
networkCanvasHost.style.flex =
|
|
297
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
298
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullFlex
|
|
299
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoFlex;
|
|
300
|
+
networkCanvasHost.style.width =
|
|
301
|
+
responsiveViewportLayoutContext.useNetworkOnlyPanel
|
|
302
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize
|
|
303
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoSize;
|
|
304
|
+
networkCanvasHost.style.maxWidth = FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Applies the fixed network host height and queues redraw when it changes.
|
|
309
|
+
*
|
|
310
|
+
* @param networkCanvasHost - Network canvas host element.
|
|
311
|
+
* @param deferredNetworkRedrawController - Deferred redraw controller.
|
|
312
|
+
* @returns Nothing.
|
|
313
|
+
*/
|
|
314
|
+
function applyNetworkCanvasHostHeight(
|
|
315
|
+
networkCanvasHost: HTMLElement,
|
|
316
|
+
deferredNetworkRedrawController: DeferredNetworkRedrawController,
|
|
317
|
+
): void {
|
|
318
|
+
// Step 1: Update the host height only when the fixed target changed.
|
|
319
|
+
if (
|
|
320
|
+
networkCanvasHost.offsetHeight === FLAPPY_UI_NETWORK_HOST_FIXED_HEIGHT_PX
|
|
321
|
+
) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Step 2: Apply the fixed host height and request a post-layout redraw.
|
|
326
|
+
networkCanvasHost.style.height = `${FLAPPY_UI_NETWORK_HOST_FIXED_HEIGHT_PX}px`;
|
|
327
|
+
deferredNetworkRedrawController.requestNetworkRedrawAfterLayout();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Applies the resolved dimensions and scrolling rules to the stats container.
|
|
332
|
+
*
|
|
333
|
+
* @param statsContainer - Stats host element.
|
|
334
|
+
* @param responsiveViewportLayoutContext - Responsive layout context.
|
|
335
|
+
* @param statsPanelDimensions - Resolved stats panel dimensions.
|
|
336
|
+
* @returns Nothing.
|
|
337
|
+
*/
|
|
338
|
+
function applyStatsContainerDimensions(
|
|
339
|
+
statsContainer: HTMLElement,
|
|
340
|
+
responsiveViewportLayoutContext: ResponsiveViewportLayoutContext,
|
|
341
|
+
statsPanelDimensions: StatsPanelDimensions,
|
|
342
|
+
): void {
|
|
343
|
+
// Step 1: Apply the resolved stats panel height.
|
|
344
|
+
statsContainer.style.height = `${statsPanelDimensions.adjustedStatsPanelHeightPx}px`;
|
|
345
|
+
statsContainer.style.maxHeight = `${statsPanelDimensions.adjustedStatsPanelHeightPx}px`;
|
|
346
|
+
|
|
347
|
+
// Step 2: Apply width and scrolling rules that differ between landscape and stacked layouts.
|
|
348
|
+
statsContainer.style.width =
|
|
349
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
350
|
+
? `${statsPanelDimensions.resolvedStatsPanelWidthPx}px`
|
|
351
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize;
|
|
352
|
+
statsContainer.style.maxWidth =
|
|
353
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
354
|
+
? `${statsPanelDimensions.resolvedStatsPanelWidthPx}px`
|
|
355
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.fullSize;
|
|
356
|
+
statsContainer.style.overflowY =
|
|
357
|
+
responsiveViewportLayoutContext.useLandscapeSplitLayout
|
|
358
|
+
? FLAPPY_HOST_RESIZE_STYLE_TOKENS.autoOverflow
|
|
359
|
+
: FLAPPY_HOST_RESIZE_STYLE_TOKENS.hiddenOverflow;
|
|
360
|
+
}
|