@inventure71/paddockjs 2.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +176 -1
  2. package/INSTALL_AND_UPDATE.md +24 -4
  3. package/README.md +84 -512
  4. package/docs/architecture.md +38 -24
  5. package/docs/component_inventory.md +72 -0
  6. package/docs/composable-layouts.md +77 -0
  7. package/docs/concepts.md +2 -2
  8. package/docs/custom_model_controller.md +6 -6
  9. package/docs/data-helpers.md +50 -0
  10. package/docs/data_contract.md +104 -27
  11. package/docs/getting-started.md +75 -0
  12. package/docs/headless-environment.md +68 -0
  13. package/docs/index.md +18 -4
  14. package/docs/learnings.md +6 -6
  15. package/docs/rules.md +12 -8
  16. package/docs/sense_contract.md +1 -1
  17. package/docs/system_specs.md +71 -21
  18. package/docs/theming.md +64 -0
  19. package/docs/training.md +26 -19
  20. package/docs/troubleshooting.md +76 -0
  21. package/docs/upgrading-hosts-to-3.md +42 -0
  22. package/examples/python/README.md +6 -0
  23. package/examples/python/base_policy_server.py +19 -0
  24. package/package.json +10 -3
  25. package/src/api/PaddockSimulatorController.js +150 -24
  26. package/src/api/runtimeTheme.js +59 -0
  27. package/src/app/F1SimulatorApp.js +213 -29
  28. package/src/app/banners/raceDataBannerController.js +71 -36
  29. package/src/app/banners/stewardMessageController.js +5 -4
  30. package/src/app/camera/cameraConstants.js +2 -0
  31. package/src/app/camera/cameraController.js +86 -29
  32. package/src/app/camera/cameraGeometry.js +12 -1
  33. package/src/app/domBindings.js +89 -9
  34. package/src/app/layoutScheduler.js +27 -0
  35. package/src/app/layoutSupport.js +165 -0
  36. package/src/app/raceOverlayClearanceSupport.js +158 -0
  37. package/src/app/readouts/carOverviewRenderer.js +16 -8
  38. package/src/app/readouts/controlStateRenderer.js +1 -1
  39. package/src/app/readouts/raceStatusRenderer.js +30 -21
  40. package/src/app/readouts/readoutFormatters.js +2 -0
  41. package/src/app/readouts/telemetryRenderer.js +17 -8
  42. package/src/app/readouts/timingTowerRenderer.js +262 -49
  43. package/src/app/runtime/frameLoop.js +5 -1
  44. package/src/app/runtime/runtimeVisibility.js +66 -5
  45. package/src/config/cssValues.js +16 -0
  46. package/src/config/defaultOptions.js +58 -38
  47. package/src/config/themeOptions.js +830 -0
  48. package/src/config/timingGapMode.js +13 -0
  49. package/src/config/urlOptions.js +25 -0
  50. package/src/data/championship.js +14 -9
  51. package/src/data/index.d.ts +212 -0
  52. package/src/data/index.js +14 -0
  53. package/src/environment/controllerLoop.js +17 -3
  54. package/src/environment/episode.js +11 -1
  55. package/src/environment/index.d.ts +1 -2
  56. package/src/environment/metrics.js +59 -16
  57. package/src/environment/observationVector.js +50 -33
  58. package/src/environment/observations.js +89 -20
  59. package/src/environment/options.js +1 -1
  60. package/src/environment/runtime.js +44 -11
  61. package/src/environment/scenarios.js +1 -1
  62. package/src/environment/sensors/carRays.js +48 -37
  63. package/src/environment/sensors/index.js +501 -97
  64. package/src/environment/sensors/indexedRayBands.js +134 -46
  65. package/src/environment/sensors/rayBandTrace.js +1171 -0
  66. package/src/environment/sensors/rayChannels.js +108 -0
  67. package/src/environment/sensors/rayConfig.js +71 -25
  68. package/src/environment/sensors/rayGeometry.js +23 -17
  69. package/src/environment/sensors/sensorTargets.js +67 -1
  70. package/src/environment/sensors/surfaceRays.js +167 -118
  71. package/src/environment/sensors/trackRays.js +157 -48
  72. package/src/index.d.ts +153 -9
  73. package/src/index.js +52 -3
  74. package/src/simulation/collisionGeometry.js +260 -96
  75. package/src/simulation/driver/driverController.js +1 -1
  76. package/src/simulation/driver/edgeRecovery.js +1 -1
  77. package/src/simulation/driver/racingControls.js +2 -2
  78. package/src/simulation/driver/rejoinControls.js +2 -2
  79. package/src/simulation/pit/pitFlow.js +21 -9
  80. package/src/simulation/pit/pitKinematics.js +2 -2
  81. package/src/simulation/pit/pitQueue.js +5 -3
  82. package/src/simulation/pit/pitRouteMovement.js +9 -4
  83. package/src/simulation/pit/pitRouting.js +79 -46
  84. package/src/simulation/pit/pitState.js +1 -0
  85. package/src/simulation/pit/pitTireService.js +7 -3
  86. package/src/simulation/race/raceFinish.js +25 -8
  87. package/src/simulation/race/raceOrder.js +189 -32
  88. package/src/simulation/race/raceProgress.js +129 -37
  89. package/src/simulation/race/raceSetup.js +4 -6
  90. package/src/simulation/race/raceStep.js +26 -14
  91. package/src/simulation/race/safetyCar.js +1 -1
  92. package/src/simulation/race/stalledDnf.js +1 -1
  93. package/src/simulation/raceSimulation.js +20 -17
  94. package/src/simulation/rules/collisionSteward.js +40 -23
  95. package/src/simulation/rules/rulesReview.js +77 -56
  96. package/src/simulation/snapshots/raceSnapshots.js +37 -0
  97. package/src/simulation/timing/drsTiming.js +143 -30
  98. package/src/simulation/timing/gapEstimation.js +25 -3
  99. package/src/simulation/timing/lapTelemetry.js +138 -40
  100. package/src/simulation/timing/raceTiming.js +5 -1
  101. package/src/simulation/timing/sectorPerformance.js +104 -26
  102. package/src/simulation/timing/timingHistory.js +229 -14
  103. package/src/simulation/timing/timingLines.js +65 -7
  104. package/src/simulation/track/pitLaneLayout.js +30 -3
  105. package/src/simulation/track/pitLaneState.js +218 -19
  106. package/src/simulation/track/spatialQueries.js +66 -33
  107. package/src/simulation/track/trackMath.js +91 -24
  108. package/src/simulation/track/trackModel.js +2 -0
  109. package/src/simulation/track/trackQueryIndex.js +1468 -189
  110. package/src/simulation/track/trackQueryPitIndex.js +138 -14
  111. package/src/simulation/track/trackQueryScratch.js +7 -0
  112. package/src/simulation/track/trackQueryStats.js +25 -0
  113. package/src/simulation/track/trackSnapshotJson.js +139 -0
  114. package/src/simulation/track/trackStatePolicy.js +249 -2
  115. package/src/simulation/vehicle/contactResolution.js +99 -62
  116. package/src/simulation/vehicle/mainTrackWheelSurface.js +73 -34
  117. package/src/simulation/vehicle/pitWheelSurface.js +81 -28
  118. package/src/simulation/vehicle/runoffResponse.js +54 -29
  119. package/src/simulation/vehicle/vehicleGeometry.js +245 -51
  120. package/src/simulation/vehicle/vehicleKinematics.js +2 -2
  121. package/src/simulation/vehicle/vehiclePhysics.js +45 -30
  122. package/src/simulation/vehicle/vehicleSnapshots.js +35 -1
  123. package/src/simulation/vehicle/vehicleState.js +7 -1
  124. package/src/simulation/vehicle/wheelSurface.js +807 -92
  125. package/src/simulation/warmup/runtimeWarmup.js +0 -1
  126. package/src/styles.css +1568 -519
  127. package/src/ui/bannerTemplates.js +38 -28
  128. package/src/ui/cameraControlsTemplate.js +16 -5
  129. package/src/ui/carOverviewTemplate.js +12 -5
  130. package/src/ui/raceCanvasTemplate.js +31 -8
  131. package/src/ui/raceControlsTemplate.js +27 -10
  132. package/src/ui/shellTemplate.js +3 -1
  133. package/src/ui/telemetryDrawerTemplate.js +23 -10
  134. package/src/ui/telemetryTemplates.js +58 -32
  135. package/src/ui/templateUtils.js +48 -0
  136. package/src/ui/timingTowerTemplate.js +29 -12
package/README.md CHANGED
@@ -1,584 +1,156 @@
1
1
  # PaddockJS
2
2
 
3
- PaddockJS is an installable F1-style simulator component for browser host websites. It owns the simulator source, bundled simulator assets, CSS, demo data, and public mount API.
3
+ PaddockJS is an installable browser component package for an F1-style project race simulator. It owns the simulator UI, PixiJS runtime, bundled simulator assets, CSS, demo data, and public mount APIs. Host websites provide data, page placement, routing, and optional theme choices.
4
4
 
5
- ## Install
5
+ Code snippets in this README are illustrative host integration fragments unless a section says they are a complete runnable file.
6
6
 
7
- From npm:
7
+ ## Install
8
8
 
9
9
  ```bash
10
10
  npm install @inventure71/paddockjs
11
11
  ```
12
12
 
13
- ## Documentation
14
-
15
- Start with [docs/index.md](docs/index.md) for the full package map: what to install, which API to use, what data to pass, how rules modules work, how the browser and headless runtimes differ, and which verification commands prove a change. If you are integrating the package into a host site, read [System Specs](docs/system_specs.md), [Data Contract](docs/data_contract.md), and [Rules](docs/rules.md) first. If you already trained a driver model and want to run it in PaddockJS, use the [Custom Model Controller Guide](docs/custom_model_controller.md).
16
-
17
- ## Package Workflow
18
-
19
- The repo includes the full package-release boundary:
20
-
21
- - a tracked showcase host in `local-preview/`
22
- - public TypeScript declarations in `src/index.d.ts`
23
- - GitHub Actions CI in `.github/workflows/ci.yml`
24
- - Changesets release automation in `.github/workflows/release.yml`
25
- - npm trusted publishing support through GitHub Actions OIDC
26
-
27
- Useful commands:
28
-
29
- ```bash
30
- npm run check
31
- npm run check:release
32
- npm run consumer:smoke
33
- npm run browser:smoke
34
- npm run showcase:dev
35
- npm run showcase:build
36
- npm run changeset
37
- ```
38
-
39
- `npm run check` is the normal local gate: fast runtime tests, public declarations, dry package contents, packed-package consumption in a fresh Vite app, the showcase build, and a quick Chromium smoke against the showcase. `npm run check:release` runs the same package gates plus slow characterization tests and the full browser smoke matrix.
40
-
41
- Local development and showcase builds require Node `20.19.0` or newer. CI currently runs the package check on Node 22 and releases on Node 24.
42
-
43
- ## 2.0 Release Highlights
44
-
45
- The `2.0.x` release line adds the stricter opt-in simulator physics mode, richer procedural track generation, indexed track/ray queries, barrier destruction and stalled-DNF behavior, batch-training participant profiles, replay ghosts, compact/vectorized environment output, policy-server/live-preview Policy Runner paths, Python policy-server examples, the custom model controller guide, the Rules showcase page, and the full release-gated local preview coverage.
46
-
47
- The package still does not ship trained model weights, model storage, a Python Gymnasium/PettingZoo package, static obstacles, weather, reliability failures, fuel-load effects, or debug mutation APIs. Those remain host-owned or future scope.
48
-
49
- ## Expert Environment API
50
-
51
- Headless training code imports the environment subpath:
52
-
53
- ```js
54
- import { createPaddockEnvironment } from '@inventure71/paddockjs/environment';
55
- ```
56
-
57
- The package root remains the browser component API. The environment subpath is intentionally browser-free and does not import DOM, PixiJS, or package CSS.
58
- PaddockJS is a bring-your-own-model environment. It does not choose an ML framework, store model weights, or ship a trained driver. The shared `createPaddockDriverControllerLoop()` helper lets a user-owned controller run against either browser expert mode or `createPaddockEnvironment()` with the same batched `decideBatch(context)` call shape.
59
-
60
- Browser and headless environments default to `physicsMode: 'arcade'` for existing hosts. Opt into the stricter vehicle model with `physicsMode: 'simulator'` when you want 2D velocity/yaw dynamics, traction limits, steering scrub, derived slip telemetry, reduced off-road grip, and simulator-mode AI tuning:
61
-
62
- ```js
63
- const env = createPaddockEnvironment({
64
- drivers,
65
- entries,
66
- controlledDrivers: ['budget'],
67
- frameSkip: 2,
68
- physicsMode: 'simulator',
69
- });
70
-
71
- let result = env.reset();
72
- result = env.step({
73
- budget: { steering: 0, throttle: 1, brake: 0 },
74
- });
75
- ```
13
+ Use Node `20.19.0` or newer for local package development and modern Vite-based host builds.
76
14
 
77
- Action steering is an absolute normalized steering target: `-1` points the wheel to maximum left, `0` points it to center, `1` points it to maximum right, and intermediate values target the same percentage of the maximum angle. Physics still rate-limits how quickly the steering wheel reaches that target.
15
+ ## Browser Mount
78
16
 
79
- The environment can run with no reward, as above, or with a host-supplied `reward(context)` callback. Reward formulas stay user-owned; PaddockJS only supplies the neutral facts:
17
+ For a normal website page, mount the all-in-one simulator from the root browser package:
80
18
 
81
19
  ```js
82
- const env = createPaddockEnvironment({
83
- drivers,
84
- entries,
85
- controlledDrivers: ['budget'],
86
- reward({ metrics, episode }) {
87
- if (metrics.destroyed) return -200;
88
- if (metrics.offTrack) return -12;
89
- if (episode.terminated) return 0;
90
- return metrics.legalProgressDeltaMeters;
91
- },
92
- });
93
- ```
94
-
95
- Reward callback results are converted to numbers per controlled driver. Missing, `NaN`, or infinite callback results become a neutral `0` so one bad callback value cannot poison a training batch.
96
-
97
- The repository also includes dependency-free examples that use the same environment contract:
98
-
99
- ```bash
100
- node examples/train-basic-policy.mjs --generations=4 --candidates=5 --episodes=1 --steps=240
101
- ```
102
-
103
- The starter script imports the public `@inventure71/paddockjs/environment` subpath and uses self-contained example data from `examples/trainingData.mjs`, so it does not depend on private package source modules for demo drivers. `createProgressReward()` remains available as example/demo reward code only; it is not the official reward and not part of the environment objective.
104
-
105
- Each default ray reports track-transition distance and car distance. A track hit uses `kind: 'exit'` when the ray leaves the road and `kind: 'entry'` when an off-track ray points back to the road. Richer sensor layouts are opt-in: rays can use per-ray lengths, predefined layouts such as `driver-front-heavy`, channels for `roadEdge`, `kerb`, `illegalSurface`, and `car`, and `precision: 'driver' | 'debug'`. Driver precision is the default model-facing contract; debug precision is only for clearly labeled diagnostics. Surface channels are computed only when requested. Barrier walls are rendered and enforced as hard destruction boundaries in both physics modes, but they are not model-facing ray targets. `observation.object.self.onTrack` follows the simulator's wheel-level legality rules, so track, kerb, and legal pit-lane/box surfaces are on-track for reward and observation purposes. `pitIntent: 0` is always accepted as the no-op clear value, including environments where pit stops are disabled.
106
-
107
- For realistic local-perception policies, use `physicsMode: 'simulator'` with `observation.profile: 'physical-driver'`. It exposes yaw rate, local boundary distances, contact-patch surface readings, richer opponent radar, and surface-aware ray fields in the versioned vector schema. The profile defaults track lookahead to `[]` so the policy does not receive privileged future curvature unless the host explicitly opts back in.
108
-
109
- External training code can inspect the environment contract without guessing field ranges:
110
-
111
- ```js
112
- const actionSpec = env.getActionSpec();
113
- const observationSpec = env.getObservationSpec();
114
- ```
115
-
116
- Controller modules own model loading, inference, memory, rewards, and logs. PaddockJS supplies cached specs, stable controlled-driver ordering, compact observations, action validation, and repeated stepping through normal physics controls:
117
-
118
- ```js
119
- import { createPaddockDriverControllerLoop } from '@inventure71/paddockjs';
120
-
121
- const controller = {
122
- async decideBatch(ctx) {
123
- return Object.fromEntries(ctx.orderedObservations.map(({ driverId, vector }) => [
124
- driverId,
125
- userModelAction(vector),
126
- ]));
127
- },
128
- };
129
-
130
- const loop = createPaddockDriverControllerLoop({
131
- runtime: env,
132
- controller,
133
- actionRepeat: 4,
134
- });
135
- await loop.reset();
136
- await loop.step();
137
- ```
138
-
139
- `loop.start()` may begin from a fresh runtime and will lazily reset before the first scheduled step. In `onStep(ctx)`, `ctx.actions` is the current applied action map and `ctx.previousActions` is the action map applied on the prior physics step. Scheduled playback stops on controller/runtime errors and exposes the value through `loop.stats.lastError`.
140
-
141
- The environment also exposes reset-only scenario placement, neutral rollout recording, deterministic evaluation metrics, and a JSON-serializable worker protocol for external bridges:
20
+ import { mountF1Simulator } from '@inventure71/paddockjs';
142
21
 
143
- ```js
144
- const env = createPaddockEnvironment({
145
- drivers,
146
- entries,
147
- controlledDrivers: ['budget'],
148
- scenario: {
149
- preset: 'off-track-recovery',
150
- placements: {
151
- budget: { distanceMeters: 420, offsetMeters: 16, speedKph: 65 },
22
+ const root = document.getElementById('sim-root');
23
+
24
+ if (root) {
25
+ await mountF1Simulator(root, {
26
+ drivers: [
27
+ {
28
+ id: 'budget',
29
+ name: 'Budget Buddy',
30
+ color: '#ff2d55',
31
+ link: '/projects/budget-buddy',
32
+ raceData: ['AI finance coach', 'Python + LLM', 'Budget guardrails'],
33
+ },
34
+ ],
35
+ entries: [
36
+ {
37
+ driverId: 'budget',
38
+ driverNumber: 71,
39
+ timingName: 'Budget',
40
+ },
41
+ ],
42
+ onDriverOpen(driver) {
43
+ if (driver.link) window.location.href = driver.link;
152
44
  },
153
- },
154
- });
45
+ });
46
+ }
155
47
  ```
156
48
 
157
- Scenario placement is an environment reset feature, not a policy assist. During `step(actions)`, controlled cars still move only through normalized steering, throttle, brake, and pit intent. `steering`, `throttle`, and `brake` are required for each controlled-driver action; missing or non-finite values fail validation instead of becoming silent zero controls.
158
-
159
- For same-environment batched learning, controlled cars can use compact vector observations and reset independently at episode boundaries:
49
+ The root package is browser-oriented and imports package CSS. If your host build does not extract CSS from JavaScript imports, import the stylesheet explicitly:
160
50
 
161
51
  ```js
162
- const env = createPaddockEnvironment({
163
- drivers,
164
- entries,
165
- controlledDrivers: agentIds,
166
- physicsMode: 'simulator',
167
- participantInteractions: { defaultProfile: 'batch-training' },
168
- observation: {
169
- profile: 'physical-driver',
170
- output: 'vector',
171
- includeSchema: false,
172
- vectorType: 'float32',
173
- },
174
- result: {
175
- stateOutput: 'none',
176
- resetDriversObservationScope: 'reset',
177
- },
178
- });
179
-
180
- const schema = env.getObservationSpec();
181
- let result = env.reset();
182
- result = env.step(actionsByDriver);
183
-
184
- env.resetDrivers({
185
- [agentIds[0]]: { distanceMeters: 1200, offsetMeters: 3, speedKph: 80 },
186
- }, {
187
- stateOutput: 'none',
188
- observationScope: 'reset',
189
- });
52
+ import '@inventure71/paddockjs/styles.css';
190
53
  ```
191
54
 
192
- `batch-training` cars remain real rendered cars in `snapshot.cars`, but they are non-colliding, sensor-hidden, pit-non-blocking, and excluded from race order by default. Step results include `info.drivers[driverId]` episode state and neutral `metrics[driverId]` facts for external logging or user-defined rewards. `stateOutput: 'none'` suppresses repeated `state.snapshot` payloads for high-throughput loops; use `minimal` when the loop still needs the observation snapshot, or omit the option for the full backward-compatible public snapshot. Deterministic evaluation helpers can accept compact no-state base options and internally request the minimal snapshot needed for evaluation metrics. Reset placements are classified against the same runoff/barrier rules before observations are returned: recovery starts stay physical, while cars placed inside terminal barrier space return destroyed metrics and stable miss-valued rays instead of running far-out ray geometry.
55
+ PaddockJS CSS is scoped under package mount/component roots and uses system font stacks. The package does not load Google Fonts or any other remote font. Hosts that want branded typography should load fonts in the host app.
193
56
 
194
- On the package's local 20-car simulator benchmark with front-heavy physical-driver rays, compact vector/no-state output measured around `3.3ms` per environment action, with a no-ray baseline around `1.5ms`. Those numbers are hardware dependent, but they show the intended usage: keep schema/spec lookup separate, request compact vectors in training loops, and reserve full snapshots for debugging or visualization.
57
+ Start here:
195
58
 
196
- For multi-car training and visual comparison, PaddockJS separates real participants from replay overlays:
59
+ - [Getting Started](docs/getting-started.md): install, browser mount, CSS, assets, host responsibilities, and container sizing.
60
+ - [Data Contract](docs/data_contract.md): driver, entry, callback, rules, and option shapes.
61
+ - [Troubleshooting](docs/troubleshooting.md): common integration failures and supported checks.
197
62
 
198
- - `participantInteractions` changes how physics-driven cars interact with collisions, sensors, pit occupancy, and race order. Those cars remain in `snapshot.cars` and still move through steering, throttle, brake, pit intent, tire state, timing, and rules.
199
- - `replayGhosts` are trajectory-driven overlays for reference laps, debugging, or comparison. They appear in `snapshot.replayGhosts`, never in `snapshot.cars`, and do not collide, rank, pit, or trigger penalties. They are sensor-hidden by default and only appear in rays or nearby observations when their own sensor flags opt in.
200
- - In the browser view, non-colliding participants remain solid clickable cars but get a blue no-collision outline marker. Replay ghosts remain translucent overlays.
63
+ ## Composable Layouts
201
64
 
202
- ```js
203
- const env = createPaddockEnvironment({
204
- drivers,
205
- entries,
206
- controlledDrivers: ['model-a', 'model-b'],
207
- participantInteractions: {
208
- drivers: {
209
- 'model-a': { profile: 'isolated-training' },
210
- 'model-b': { profile: 'isolated-training' },
211
- },
212
- },
213
- });
214
- ```
215
-
216
- `isolated-training` is the no-collision profile for real cars that should still remain in race order. `batch-training` is the preferred no-collision profile for same-environment learner batches because it is also excluded from race order. Both profiles hide the car from other cars' ray sensors and `nearbyCars` observations by default; use `phantom-race` or explicit `detectableByRays` / `detectableAsNearby` overrides only when sensor visibility is intentional.
217
-
218
- Browser expert mode is opt-in through the normal mount API. When enabled, the visual simulator advances only when host code calls `simulator.expert.step(actions)`. Expert mode is a mount-time boundary; changing `expert` through `restart(nextOptions)` is rejected so ticker ownership cannot silently change under a mounted simulator.
219
- Set `expert.visualizeSensors` to draw expert sensor rays inside the actual race canvas for visual debugging:
220
-
221
- ```js
222
- const simulator = await mountF1Simulator(root, {
223
- drivers,
224
- entries,
225
- expert: {
226
- enabled: true,
227
- controlledDrivers: ['budget'],
228
- frameSkip: 4,
229
- visualizeSensors: {
230
- rays: true,
231
- },
232
- },
233
- });
234
- ```
235
-
236
- The overlay renders ray values from the same active observation returned by `simulator.expert.step(actions)`; it does not recompute a separate sensor model for the browser layer. Each detected ray channel is shown as its own colored marker, so road-edge, kerb, illegal surface, and car hits can be inspected independently. This applies to every model-facing sense: Policy Runner and expert visualizations must show what the policy receives, while extra high-precision diagnostics must be labeled separately.
237
-
238
- When multiple drivers are controlled, sensor visualization renders the selected controlled driver by default so batch-training previews do not draw every agent's rays every frame. Use `visualizeSensors: { rays: true, drivers: 'all' }` only when you intentionally want the heavier all-controlled-car overlay.
239
-
240
- ## API
241
-
242
- The root package exports the browser mounts, composable helper mounts, data/rating helpers, bundled asset and preset constants, procedural-track helper, simulator unit converters, and `createPaddockDriverControllerLoop`. The browser-free training runtime lives under `@inventure71/paddockjs/environment`; see [docs/system_specs.md](docs/system_specs.md) for the full export catalog.
243
-
244
- All-in-one mount:
245
-
246
- ```js
247
- import { mountF1Simulator } from '@inventure71/paddockjs';
248
-
249
- const simulator = await mountF1Simulator(document.getElementById('sim-root'), {
250
- preset: 'timing-overlay',
251
- drivers: [
252
- {
253
- id: 'budget',
254
- name: 'Budget Buddy',
255
- color: '#ff2d55',
256
- link: '/project_details/project-budget-buddy.html',
257
- raceData: ['AI finance coach', 'Python + LLM', 'Budget guardrails'],
258
- },
259
- ],
260
- entries: [
261
- {
262
- driverId: 'budget',
263
- driverNumber: 71,
264
- timingName: 'Budget',
265
- driver: { pace: 52, racecraft: 74, aggression: 38, riskTolerance: 47, patience: 81, consistency: 86 },
266
- vehicle: { id: 'budget-bb01', name: 'BB-01 Ledger', power: 48, braking: 72, aero: 55, dragEfficiency: 66, mechanicalGrip: 63, weightControl: 58, tireCare: 82 },
267
- },
268
- ],
269
- initialCameraMode: 'show-all',
270
- expert: {
271
- enabled: true,
272
- controlledDrivers: ['budget'],
273
- },
274
- onDriverOpen(driver) {
275
- window.location.href = driver.link;
276
- },
277
- });
278
- ```
279
-
280
- Composable mount:
65
+ Use `createPaddockSimulator()` when a host wants to place package-owned surfaces in separate roots while keeping one simulator controller:
281
66
 
282
67
  ```js
283
68
  import { createPaddockSimulator } from '@inventure71/paddockjs';
284
69
 
285
- const simulator = createPaddockSimulator({
286
- drivers,
287
- entries,
288
- onDriverOpen(driver) {
289
- window.location.href = driver.link;
290
- },
291
- });
70
+ const simulator = createPaddockSimulator({ drivers, entries });
292
71
 
293
72
  simulator.mountRaceControls(document.getElementById('sim-controls'));
294
- simulator.mountCameraControls(document.getElementById('sim-camera-controls'));
295
- simulator.mountSafetyCarControl(document.getElementById('sim-safety-car'));
296
- simulator.mountTimingTower(document.getElementById('sim-timing'));
297
73
  simulator.mountRaceCanvas(document.getElementById('sim-race'), {
74
+ includeTimingTower: true,
298
75
  includeRaceDataPanel: true,
299
76
  });
300
- simulator.mountTelemetryCore(document.getElementById('sim-telemetry-core'));
301
- simulator.mountTelemetrySectors(document.getElementById('sim-telemetry-sectors'));
302
- simulator.mountTelemetrySectorBanner(document.getElementById('sim-telemetry-sector-banner'));
303
- simulator.mountTelemetryLapTimes(document.getElementById('sim-telemetry-laps'));
304
- simulator.mountTelemetrySectorTimes(document.getElementById('sim-telemetry-sector-times'));
305
- simulator.mountCarDriverOverview(document.getElementById('sim-overview'));
77
+ simulator.mountRaceDataPanel(document.getElementById('sim-race-data'));
306
78
 
307
79
  await simulator.start();
308
80
  ```
309
81
 
310
- The race canvas can also own the timing tower when a host wants a single reusable race-window component:
82
+ The controller methods are the canonical composable API. See [Composable Layouts](docs/composable-layouts.md) for the available surfaces, lifecycle, restart behavior, and sizing contract.
311
83
 
312
- ```js
313
- simulator.mountRaceCanvas(document.getElementById('sim-race'), {
314
- includeTimingTower: true,
315
- includeRaceDataPanel: true,
316
- timingTowerVerticalFit: 'scroll',
317
- });
318
- ```
84
+ ## Headless And Data Subpaths
319
85
 
320
- For a packaged race-window template with a right-side telemetry drawer:
86
+ Do not import the root package from raw Node or headless training code. The root package is for browser mounts and imports CSS/assets.
321
87
 
322
- ```js
323
- simulator.mountRaceTelemetryDrawer(document.getElementById('sim-race-workbench'), {
324
- timingTowerVerticalFit: 'expand-race-view',
325
- raceDataTelemetryDetail: true,
326
- });
327
- ```
328
-
329
- When a composable host intends to use pit APIs or automatic pit behavior, include the pit rules in the simulator options before mounting components:
88
+ Use the browser-free environment subpath for simulation/training loops:
330
89
 
331
90
  ```js
332
- const simulator = createPaddockSimulator({
333
- drivers,
334
- entries,
335
- rules: {
336
- ruleset: 'custom',
337
- modules: {
338
- pitStops: { enabled: true },
339
- stalledDnf: { enabled: true },
340
- tireStrategy: { enabled: true, mandatoryDistinctDryCompounds: 2 },
341
- },
342
- },
343
- });
91
+ import { createPaddockEnvironment } from '@inventure71/paddockjs/environment';
344
92
  ```
345
93
 
346
- `drivers` is the host-owned project/pilot list. `entries` is the optional driver/car/team pairing sheet. The car/driver overview uses the existing driver and vehicle rating components from each entry. Driver and vehicle entries can also include `customFields` as extra label/value metadata. Entries can include `team: { id, name, color, icon, pitCrew }`; the timing tower uses the team icon and defaults team color to the car color when omitted. `team.pitCrew` accepts `speed`, `consistency`, and `reliability` values from `0` to `1` for optional pit-service variability. Assets, including the default car image and generic driver helmet, are bundled by default, so the host website does not need to provide simulator images or textures.
347
-
348
- The returned object supports:
349
-
350
- - `destroy()`
351
- - `restart(nextOptions)` for non-asset, non-expert race/data/seed changes
352
- - `selectDriver(driverId)`
353
- - `setSafetyCarDeployed(deployed)`
354
- - `setRedFlagDeployed(deployed)`
355
- - `setPitLaneOpen(open)`
356
- - `callSafetyCar()`
357
- - `clearSafetyCar()`
358
- - `toggleSafetyCar()`
359
- - `setPitIntent(driverId, intent, targetCompound?)`
360
- - `getPitIntent(driverId)`
361
- - `getPitTargetCompound(driverId)`
362
- - `getSimulationSpeed()`
363
- - `servePenalty(penaltyId)`
364
- - `cancelPenalty(penaltyId)`
365
- - `getSnapshot()`
366
- - `expert` when explicitly enabled, otherwise `null`
367
-
368
- Useful UI options:
94
+ Use the CSS-free data subpath for tooling, server-side data normalization, and procedural track helpers:
369
95
 
370
96
  ```js
371
- preset: 'timing-overlay',
372
- theme: {
373
- accentColor: '#00ff84',
374
- timingTowerMaxWidth: '360px',
375
- raceViewMinHeight: '720px',
376
- },
377
- ui: {
378
- layoutPreset: 'left-tower-overlay',
379
- cameraControls: 'external',
380
- showFps: false,
381
- telemetryIncludesOverview: false,
382
- telemetryModules: ['core', 'sectors', 'lapTimes', 'sectorTimes'],
383
- raceDataBanners: {
384
- initial: 'project',
385
- enabled: ['project', 'radio'],
386
- },
387
- raceDataBannerSize: 'auto',
388
- raceDataTelemetryDetail: true,
389
- timingTowerVerticalFit: 'expand-race-view',
390
- },
391
- debug: {
392
- physicsModeIndicator: false,
393
- }
97
+ import { DriverData, normalizeSimulatorDrivers } from '@inventure71/paddockjs/data';
394
98
  ```
395
99
 
396
- `preset` is resolved before explicit host options. Available presets are `dashboard`, `timing-overlay`, `compact-race`, and `full-dashboard`; hosts can start from a preset and override any `ui`, `debug`, or `theme` field. `debug.physicsModeIndicator: true` renders a small top-left race-canvas square: blue for arcade physics and red for simulator physics. It defaults to `false` for package consumers and is intended only for debug/development use. `theme` maps to package CSS variables for the stable sizing/color contract: `accentColor`, `greenColor`, `yellowColor`, `timingTowerMaxWidth`, and `raceViewMinHeight`.
100
+ Read [Headless Environment](docs/headless-environment.md), [Data Helpers](docs/data-helpers.md), and [Bring Your Own Model](docs/training.md) for those paths.
397
101
 
398
- If `trackSeed` is omitted, each mounted browser simulator creates a fresh procedural circuit. Passing `trackSeed` makes the track deterministic so multiple embeds can share the same generated circuit; repeated procedural seeds are cached within the page runtime as immutable track definitions. Treat values returned by `createProceduralTrack()` as read-only and pass custom mutable copies when experimenting with track-definition edits. `restart({ trackSeed })` rebuilds the race on the deterministic circuit for the new seed. Asset URL changes are not restartable; destroy and mount a new simulator when changing assets.
102
+ ## Runtime Theming
399
103
 
400
- Warmup is enabled by default across browser, headless environment, and direct simulation creation. The runtime warms a disposable instance during loading and caches by configuration fingerprint, so identical resets/restarts skip repeated warmup while seed/config changes warm again automatically. Override with `warmup: { enabled, policy: 'config-change' | 'always' | 'never', steps }` or `warmup: false`.
401
-
402
- Generated circuits are built from seeded connected region boundaries that are smoothed and warped into a validated centerline, so tracks can include concave infield/outfield sections and chicane-like bends instead of simple oval-like fallback shapes. Hosts can pass `trackGeneration` alongside `trackSeed` to choose a profile and override semantic generation controls:
104
+ Use mount-time `theme` for defaults and controller methods for runtime site theme toggles:
403
105
 
404
106
  ```js
405
- const simulator = await mountF1Simulator(root, {
406
- drivers,
407
- entries,
408
- trackSeed: 4101,
409
- trackGeneration: {
410
- profile: 'training-short',
411
- length: { minMeters: 900, maxMeters: 1800 },
412
- startStraight: { gridMeters: 0 },
413
- pitLane: { enabled: false },
414
- },
415
- rules: {
416
- modules: {
417
- pitStops: { enabled: false },
418
- },
419
- },
420
- });
107
+ const simulator = await mountF1Simulator(root, { drivers, entries });
421
108
 
422
- simulator.restart({
423
- trackSeed: 5051,
424
- trackGeneration: { profile: 'race' },
425
- });
426
- ```
109
+ simulator.setThemeMode(document.documentElement.dataset.theme === 'light' ? 'light' : 'dark');
427
110
 
428
- Advanced callers can import `createProceduralTrack(seed, options)` when they need the generated track definition directly instead of mounting a simulator:
429
-
430
- ```js
431
- import { createProceduralTrack } from '@inventure71/paddockjs';
432
-
433
- const trainingTrack = createProceduralTrack(4101, {
434
- profile: 'training-short',
435
- length: { minMeters: 900, maxMeters: 1800 },
436
- startStraight: { gridMeters: 0, exitMeters: 80, blendMeters: 80 },
437
- pitLane: { enabled: false },
438
- shape: { scale: 0.2, cornerDensity: 1.3, variation: 0.22 },
439
- validation: { minClearanceMultiplier: 1, maxLocalTurnRadians: 1.85 },
440
- attempts: { primary: 80, fallback: 200 },
111
+ const stopThemeSync = simulator.syncThemeFrom(document.documentElement, {
112
+ attribute: 'data-theme',
113
+ map: { light: 'light', dark: 'dark' },
441
114
  });
442
115
  ```
443
116
 
444
- Profiles are presets, not separate generators. `race` preserves the default full circuit with pit lane; `training-short`, `training-medium`, and `training-technical` generate smaller pitless circuits for training or demos. Resolution is `race` defaults, then the selected profile, then explicit overrides.
445
-
446
- Pit-lane geometry depends on the resolved generation options. The `race` profile includes:
447
-
448
- - rendered pit lane beside the start/finish straight
449
- - lane-aligned procedural entry and exit roads
450
- - main fast lane sized from the team/box layout
451
- - parallel working lane
452
- - 10 shared team service areas
453
- - 20 unused garage boxes arranged as 10 team pairs
454
-
455
- Training profiles disable pit-lane generation by default. If a host explicitly sets `pitLane: { enabled: false }`, pit-related rules should also be disabled or left in a no-op configuration.
456
-
457
- Pit-lane asphalt, working-lane service areas, and garage boxes are legal drivable surfaces for sensors, runoff handling, track-limit stewarding, and stalled-DNF timing. In both physics modes, the rendered barrier wall marks the hard outer runoff boundary; cars whose footprint reaches the wall's inner face are marked `destroyed`, stopped, removed from active collision/sensor participation, and treated as DNF entries at the bottom of the timing order. `physicsMode` changes vehicle integration and grip behavior, not barrier consequences. Environment results expose destruction as neutral `metrics[driverId].destroyed` and a per-driver `endReason: 'destroyed'`, so training loops can assign their own negative reward and then call `resetDrivers()` for a new episode. Opt-in stalled off-track DNF uses `endReason: 'stalled-off-track'` without setting `destroyed`. Tire energy degrades down to 1% and affects grip nonlinearly, so badly worn tires are slower and harder to rotate without making the car instantly undrivable.
117
+ Do not restart the simulator only to change presentation. Runtime theme APIs keep race state, selected driver, penalties, speed, camera state, and pit intent state. See [Theming](docs/theming.md).
458
118
 
459
- When `rules.modules.pitStops.enabled` is true, cars automatically form bounded pit trains when lane space is available. They brake to the limiter by the main pit-lane start, drive along the main fast lane, pass through the team queue spot as a rolling gate, roll into the team-colored working-lane service area when it is clear, stop, serve eligible penalties before tire work, show the remaining stationary service time above the car, change to the requested configured tire compound or the default alternate compound, and exit back to the race track.
119
+ ## Upgrade From 2.x
460
120
 
461
- `tireStrategy` does not enable automatic pit stops. It controls available compounds, pit-stop target compound choices, and tire-requirement stewarding. Use `rules.modules.pitStops.enabled: true` for automatic pit routing and pit APIs, or choose a preset such as `ruleset: 'fia2025'` / `ruleset: 'grandPrix2025'` that enables both pit stops and the two-compound tire strategy by default.
121
+ If a host is moving from 2.x-era usage, use [Upgrading Hosts To PaddockJS 4.x](docs/upgrading-hosts-to-3.md). The short version:
462
122
 
463
- Team-mates share one service area. Every car enters through the queue spot first, but it only stops there when the active service spot is blocked. A second team car waits in the queue spot until the active service spot is physically clear, including the previous car's first movement out of the box, without blocking the main fast lane.
123
+ - install `@inventure71/paddockjs@4`
124
+ - remove `trackQueryIndex`
125
+ - replace `physicsMode: 'simulator'` with `physicsMode: 'advanced'` or omit it for `arcade`
126
+ - import package CSS intentionally for browser mounts
127
+ - use `/environment` for headless simulation and `/data` for CSS-free helpers
128
+ - rebuild and browser-smoke the host page
464
129
 
465
- By default, built-in AI cars request an opportunistic `pitIntent: 1` below 50% tire energy and commit `pitIntent: 2` below 30%. Hosts can change those thresholds with `tirePitRequestThresholdPercent` and `tirePitCommitThresholdPercent`. Expert/headless controlled drivers do not receive those automatic tire-threshold calls and must request service with `pitIntent`.
130
+ ## Reference Docs
466
131
 
467
- Hosts can override the pit call with `setPitIntent(driverId, 0 | 1 | 2, 'H')` or expert action `{ pitIntent: 2, pitCompound: 'H' }`:
132
+ Normal consumers should start with the task docs above. These reference docs are the deeper package source of truth:
468
133
 
469
- - `0` means no request
470
- - `1` means keep trying until a free pit-entry window is available
471
- - `2` means commit to entering at the next pit-entry window even when pit-lane capacity or gap checks would block an opportunistic stop
134
+ - [System Specs](docs/system_specs.md): public API, runtime guarantees, and verification standards.
135
+ - [Rules](docs/rules.md): race-control behavior, DRS, safety car, starts, ordering, contact handling, pits, penalties, and simulation rules.
136
+ - [Concepts](docs/concepts.md): simulator vocabulary.
137
+ - [Architecture](docs/architecture.md): module ownership and data/control flow for package contributors.
138
+ - [Component Inventory](docs/component_inventory.md): package-owned UI surfaces and template ownership.
472
139
 
473
- Completed stops can be re-armed later by tire condition or by `setPitIntent`, so pit stops are not one-use per race. Optional `pitStops.variability` uses `team.pitCrew` speed, consistency, and reliability to adjust service time and slow-stop chance; `pitStops.variability.perfect: true` forces deterministic default service time for training.
474
-
475
- `setPitLaneOpen(false)` keeps new pending pit calls on track until reopened and the canvas shows a small red/green/yellow light near pit entry. `setRedFlagDeployed(true)` freezes race movement, closes the effective pit lane, and emits red-flag race-control state until cleared. The pit speed limiter applies on the straight main pit lane/working lane, not on the entry and exit connector roads, but automatic pit-entry routing still keeps connector speeds bounded so cars can reach the limiter safely.
140
+ ## Package Workflow
476
141
 
477
- Race behavior is configurable through `rules`. Flat existing options such as `standingStart: false` remain supported, and advanced behavior is grouped under module config:
142
+ Useful local commands:
478
143
 
479
- ```js
480
- const simulator = await mountF1Simulator(root, {
481
- drivers,
482
- rules: {
483
- ruleset: 'fia2025',
484
- modules: {
485
- pitStops: {
486
- enabled: true,
487
- pitLaneSpeedLimitKph: 80,
488
- maxConcurrentPitLaneCars: 3,
489
- minimumPitLaneGapMeters: 20,
490
- tirePitRequestThresholdPercent: 50,
491
- tirePitCommitThresholdPercent: 30,
492
- variability: {
493
- enabled: true,
494
- perfect: false,
495
- },
496
- },
497
- tireStrategy: {
498
- enabled: true,
499
- mandatoryDistinctDryCompounds: 2,
500
- },
501
- tireDegradation: {
502
- enabled: true,
503
- },
504
- stalledDnf: {
505
- enabled: true,
506
- maxStoppedSeconds: 12,
507
- speedThresholdKph: 5,
508
- },
509
- penalties: {
510
- trackLimits: { strictness: 0.8 },
511
- collision: { strictness: 0.5, consequences: [{ type: 'time', seconds: 5 }] },
512
- tireRequirement: { strictness: 1, consequences: [{ type: 'time', seconds: 10 }] },
513
- pitLaneSpeeding: { strictness: 1, speedLimitKph: 80 },
514
- },
515
- },
516
- },
517
- ui: {
518
- penaltyBanners: true,
519
- timingPenaltyBadges: true,
520
- },
521
- });
144
+ ```bash
145
+ npm run docs:check
146
+ npm run check
147
+ npm run check:release
148
+ npm run consumer:smoke
149
+ npm run browser:smoke:quick -- --skip-build
150
+ npm run showcase:dev
522
151
  ```
523
152
 
524
- For deterministic single-skill training or visual checkpoint comparison, set `rules.modules.tireDegradation.enabled: false` so tyre energy remains fixed while the car still drives through normal steering, throttle, brake, and surface physics. `rules.modules.stalledDnf` defaults to `enabled: false` so base simulator and training environments keep stuck off-track cars live unless a host opts in. Set `enabled: true` to retire cars that are off legal racing or pit surfaces while below `speedThresholdKph` for `maxStoppedSeconds`.
525
-
526
- Supported rulesets are `paddock`, `grandPrix2025`, `fia2025`, and `custom`. Presets only choose defaults; explicit module config wins. Weather, reliability, and fuel-load performance effects are reserved future modules and are not active `2.0.x` behavior. Penalty subsections use `strictness` from `0` to `1` instead of plain booleans. Track limits use the white line as the legal edge and require all four wheel contact patches to be fully outside the same side of the line before recording a violation, so normal kerb riding is not punished. Per-car `surface` is resolved from the worst wheel surface, snapshots include `car.wheels` for per-wheel surface and white-line state, and asymmetric left/right wheel resistance adds a small capped yaw tug toward the slower side when only one side is on a worse surface. Collision stewarding is driven by a body collision hull, not transparent sprite bounds or wheel-only overlap, and contact events include shape ids, contact type, depth, and time of impact. It considers impact severity, closing speed, and whether one car clearly hit another from behind; clear rear contact penalizes only the physically trailing car, including lapped traffic cases, while unclear meaningful contact records shared-fault penalties for both cars. Stalled off-track DNFs emit `car-dnf` with `reason: 'stalled-off-track'`, freeze the car, remove it from active control/collision/sensor/pit participation, and classify it with the existing DNF metadata. Pit-lane speeding is enforced on the main fast lane, working lane, service areas, and garage boxes, but not on pit-entry or pit-exit connector roads. Track-limit warnings are emitted as `track-limits` events, while penalty decisions are exposed through `snapshot.penalties` plus `penalty` events. Penalty consequences support warning, time, drive-through, stop-go, position-drop, grid-drop, and disqualification payloads. Time consequences are additive, drive-through and stop-go penalties are service obligations, and unserved service penalties convert to configured time at final classification.
527
-
528
- `initialCameraMode` accepts `'overview'`, `'leader'`, `'selected'`, `'show-all'`, or `'pit'`; invalid values fall back to `'leader'`. The overview camera frames the active generated track bounds, including package-owned track padding and pit-lane extent, instead of using a fixed world-center zoom. Camera mode changes ease from the current camera target to the next target after the initial frame, so switching between leader, selected, overview, show-all, and pit views does not snap the world view.
529
-
530
- The pit camera targets the generated operational pit-lane geometry, including the lane, boxes, service areas, and queue areas, while excluding the longer entry/exit access roads. It zooms out as needed to fit that work area inside the active race-view safe area, and its control is hidden when the active track has no pit lane.
531
-
532
- Zoom buttons and wheel zoom apply to every camera mode. Zoom-out is bounded by the active generated track frame so the camera cannot pull far beyond the circuit. The renderer keeps grass coverage larger than the simulated world, and the transparent canvas host uses the same grass color as a fallback around the framed circuit.
533
-
534
- `layoutPreset: 'left-tower-overlay'` creates a left broadcast gutter inside the race view, frames the camera around the remaining race area, and places the timing tower in that gutter without covering camera controls. The project/radio lower-third stays inside the race window and can intentionally render over the timing sidebar instead of shrinking around it.
535
-
536
- Composable hosts should pass `{ includeRaceDataPanel: true }` to `mountRaceCanvas()` when they want that lower-third clipped and layered by the race window. `mountRaceDataPanel()` remains available for hosts that intentionally want the banner as a standalone surface.
537
-
538
- `raceDataTelemetryDetail: true` makes the project lower-third include a compact S1/S2/S3 sector strip with live sector elapsed time and per-sector progress. That telemetry project lower-third stays visible until dismissed, muted, or replaced, while radio mode keeps its normal schedule. The standalone `mountTelemetrySectorBanner()` surface remains available only when a host explicitly mounts it.
539
-
540
- `includeTimingTower: true` embeds the timing tower directly inside the race canvas and reserves camera space from the measured tower gutter when the tower is a side overlay. In narrow mobile hosts, package CSS stacks the embedded timing tower full-width and the camera stops reserving a fake left gutter.
541
-
542
- `mountRaceTelemetryDrawer()` is a higher-level template that mounts an external top control row, race canvas, embedded timing tower, lower-third, top steward message, safety-car control, and a right telemetry drawer together. Pass `{ raceDataTelemetryDetail: true }` when the drawer lower-third should include compact sector detail.
543
-
544
- The drawer top row contains camera controls, a `1x` simulation-speed button that cycles through `2x`, `3x`, `4x`, `5x`, `10x`, and back to `1x`, a `Mute banners` toggle, safety car, and the telemetry toggle so those controls do not cover the race. For other camera-control placements the speed button is hidden by default and can be enabled with `ui.simulationSpeedControl: true`.
545
-
546
- `Mute banners` is off by default and temporarily suppresses project/radio lower-thirds while it is pressed; steward penalty banners are separate and remain controlled by `penaltyBanners`. Opening the drawer reduces the race area instead of overlaying it, and closing it removes the drawer from interaction. The drawer uses the same package-owned `telemetry-stack` component as `mountTelemetryPanel()`, so constrained host heights scroll telemetry vertically instead of letting the sidebar escape its frame.
547
-
548
- Banner and timing layout options:
549
-
550
- - `raceDataBanners.initial` selects the starting banner state: `'project'`, `'radio'`, or `'hidden'`.
551
- - `raceDataBanners.enabled` chooses which banner types may appear.
552
- - `raceDataBannerSize: 'auto'` uses the race space to the right of the timing board when it is wide enough and falls back to the full lower-third overlap when it is not.
553
- - `raceDataBannerSize: 'custom'` preserves the default CSS-variable-driven lower-third size for hosts that want to tune their own banner geometry.
554
- - `timingTowerVerticalFit: 'expand-race-view'` lets the race window grow tall enough for the tower.
555
- - `timingTowerVerticalFit: 'scroll'` keeps the race window height and scrolls the timing list inside the cropped tower.
556
-
557
- The same timing fit values can be passed to `mountRaceCanvas()` when `includeTimingTower` is enabled. Standalone timing towers are capped by `--timing-board-max-width` and fill their mount root height; placing the root in a fixed-height container makes only the timing entries scroll. Timing entries always stack from the top as fixed rows, so P1/P2 occupy the same vertical positions whether the race has 2 cars or 20.
558
-
559
- The timing tower includes an `Int`/`Gap` broadcast switch: `Int` shows the interval to the car ahead, while `Gap` shows total gap to the leader. Seconds gaps are measured from hidden fixed timing-line crossings on the track. If a car is one or more whole laps behind in the selected mode, the tower shows labels such as `+1` or `+2` instead of a seconds estimate.
560
-
561
- Other UI switches:
562
-
563
- - `cameraControls` defaults to `'external'`; set it to `'embedded'` only when controls should intentionally appear inside the canvas, or `false` to omit them.
564
- - `penaltyBanners: true` shows warnings and penalties in the top steward message instead of the project/radio lower-third.
565
- - `showFps: false` hides the FPS readout.
566
- - `telemetryIncludesOverview: false` keeps the car/driver overview out of the telemetry stack so hosts can mount `mountCarDriverOverview()` separately.
567
- - `telemetryModules` controls optional package-owned telemetry surfaces: `core`, `sectors`, `lapTimes`, and `sectorTimes`.
568
-
569
- Project/radio lower-thirds include a package-owned top-right close button that hides the current pill before its scheduled timeout. Time penalties put a large `+10s` style chip in the left block of the steward message and the affected car/rule beside it. Warning messages use warning colors and do not create timing-row `!` badges. The telemetry surfaces are also available as fully detached mount methods.
570
-
571
- ### Composable overlay layout contract
572
-
573
- `ui.layoutPreset: 'left-tower-overlay'` is package-owned. Hosts should not recreate or depend on internal shell classes such as `.sim-shell--left-tower-overlay` or `.sim-grid` as their public integration contract.
574
-
575
- For the all-in-one simulator, call `mountF1Simulator()` and let PaddockJS generate the shell. For composable layouts, hosts should provide mount roots and call package mount methods such as `mountRaceCanvas(root, { includeTimingTower: true, includeRaceDataPanel: true })` or `mountRaceTelemetryDrawer(root)`. Host CSS may size the outer container, but timing-tower placement, gutter measurement, camera safe area, and narrow-screen stacking are owned by PaddockJS.
576
-
577
- Mounted package surfaces include a lightweight red start-light loading overlay. The runtime removes each overlay after PixiJS, assets, controls, and the initial readouts are ready.
578
-
579
- The runtime also pauses its render ticker when the race canvas is offscreen or the browser tab is hidden. This keeps pages with multiple PaddockJS embeds responsive without requiring host code to manually start and stop each simulator. At `5x` and `10x` browser playback, noncritical timing/readout DOM refreshes run at a lower cadence while fixed-step simulation and race events keep using authoritative race state.
580
-
581
- Lifecycle callbacks are optional and host-owned. PaddockJS emits `onLoadingChange`, `onReady`, `onError`, `onDriverSelect`, `onRaceEvent`, `onLapChange`, and `onRaceFinish`; lifecycle callback errors are routed to `onError` when provided and do not stop the simulator loop. `onDriverOpen(driver)` is host-owned navigation code and is not wrapped as a lifecycle callback. Race snapshots include per-car interval timing, leader-gap timing, whole-lap gap counts, calibrated `speedKph`, automatic `track.sectors`, hidden `track.timingLines`, per-car `lapTelemetry`, finish state, `raceControl.winner` after the first finisher, and final `raceControl.classification` only after the whole field is finished or DNF. Sector telemetry clears future-sector values so banners and sidebars show completed splits before the active sector plus the active live timer, not stale later-sector entries. Cars that have crossed the line before full race completion expose `raceStatus: 'waved-flag'` / `wavedFlag: true` and stay frozen in provisional finish order; later barrier contact or stalled-off-track detection does not turn that result into DNF. Destroyed/out-of-race cars expose DNF metadata, show `DNF` at the bottom of the timing tower, render faded/gray in the race canvas, and appear after finishers in final classification with no finish time. If a DNF car is restored before final classification, it re-enters live timing and the race waits for it again; once `raceControl.finished` is true, classification stays final. Final classification applies time penalties and unserved service conversions through `adjustedFinishTime`, then applies position-drop and disqualification consequences to finishers before DNF entries. The field then circulates in safety-car mode and the race canvas shows a package-owned winner banner.
153
+ `npm run check` is the normal local gate: docs checks, fast runtime tests, public declarations, dry package contents, packed-package consumption in a fresh Vite app, the showcase build, and a quick Chromium smoke against the showcase. `npm run check:release` adds slow characterization tests and the full browser smoke matrix.
582
154
 
583
155
  ## License
584
156