@ksp-gonogo/sitrep-sdk 1.0.0-rc.45 → 1.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.
- package/README.md +48 -93
- package/dist/__generated__/command-map.d.ts +247 -2
- package/dist/__generated__/command-map.d.ts.map +1 -1
- package/dist/__generated__/command-map.js +91 -19
- package/dist/__generated__/command-map.js.map +1 -1
- package/dist/__generated__/contract.d.ts +3062 -352
- package/dist/__generated__/contract.d.ts.map +1 -1
- package/dist/__generated__/contract.js +187 -3
- package/dist/__generated__/contract.js.map +1 -1
- package/dist/__generated__/delay-roles.d.ts +2 -2
- package/dist/__generated__/delay-roles.d.ts.map +1 -1
- package/dist/__generated__/delay-roles.js +12 -0
- package/dist/__generated__/delay-roles.js.map +1 -1
- package/dist/__generated__/error-codes.d.ts +11 -11
- package/dist/__generated__/error-codes.d.ts.map +1 -1
- package/dist/__generated__/error-codes.js +12 -12
- package/dist/__generated__/error-codes.js.map +1 -1
- package/dist/__generated__/frames.d.ts +40 -4
- package/dist/__generated__/frames.d.ts.map +1 -1
- package/dist/__generated__/frames.js +20 -4
- package/dist/__generated__/frames.js.map +1 -1
- package/dist/__generated__/reckonability.d.ts +3 -1
- package/dist/__generated__/reckonability.d.ts.map +1 -1
- package/dist/__generated__/reckonability.js +1 -1
- package/dist/__generated__/reckonability.js.map +1 -1
- package/dist/__generated__/sample-kinds.d.ts +18 -2
- package/dist/__generated__/sample-kinds.d.ts.map +1 -1
- package/dist/__generated__/sample-kinds.js +18 -2
- package/dist/__generated__/sample-kinds.js.map +1 -1
- package/dist/__generated__/topic-map.d.ts +41 -17
- package/dist/__generated__/topic-map.d.ts.map +1 -1
- package/dist/__generated__/topic-map.js +16 -3
- package/dist/__generated__/topic-map.js.map +1 -1
- package/dist/__generated__/units.d.ts +247 -6
- package/dist/__generated__/units.d.ts.map +1 -1
- package/dist/__generated__/units.js +949 -76
- package/dist/__generated__/units.js.map +1 -1
- package/dist/api/command-rejection.d.ts +2 -2
- package/dist/api/command-rejection.js +1 -1
- package/dist/api/contribution-slots.d.ts +122 -21
- package/dist/api/contribution-slots.d.ts.map +1 -1
- package/dist/api/contribution-slots.js +4 -4
- package/dist/api/contribution-slots.js.map +1 -1
- package/dist/api/error-codes.d.ts +3 -2
- package/dist/api/error-codes.d.ts.map +1 -1
- package/dist/api/error-codes.js +3 -2
- package/dist/api/error-codes.js.map +1 -1
- package/dist/api/framework-reads.d.ts +2 -2
- package/dist/api/framework-reads.d.ts.map +1 -1
- package/dist/api/framework-reads.js +6 -1
- package/dist/api/framework-reads.js.map +1 -1
- package/dist/api/host.d.ts +14 -6
- package/dist/api/host.d.ts.map +1 -1
- package/dist/api/host.js.map +1 -1
- package/dist/api/index.d.ts +70 -60
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +66 -54
- package/dist/api/index.js.map +1 -1
- package/dist/api/logger-contract.d.ts +2 -1
- package/dist/api/logger-contract.d.ts.map +1 -1
- package/dist/api/logger.d.ts +6 -3
- package/dist/api/logger.d.ts.map +1 -1
- package/dist/api/logger.js +6 -3
- package/dist/api/logger.js.map +1 -1
- package/dist/api/part-panels.d.ts +143 -0
- package/dist/api/part-panels.d.ts.map +1 -0
- package/dist/api/part-panels.js +104 -0
- package/dist/api/part-panels.js.map +1 -0
- package/dist/api/plot-layers.d.ts +1 -1
- package/dist/api/plot-layers.js +1 -1
- package/dist/api/registry.d.ts +4 -2
- package/dist/api/registry.d.ts.map +1 -1
- package/dist/api/registry.js +4 -2
- package/dist/api/registry.js.map +1 -1
- package/dist/api/settings/store.d.ts +1 -1
- package/dist/api/settings/store.d.ts.map +1 -1
- package/dist/api/settings/store.js +7 -2
- package/dist/api/settings/store.js.map +1 -1
- package/dist/api/slots.d.ts +150 -70
- package/dist/api/slots.d.ts.map +1 -1
- package/dist/api/station-brokers.d.ts +24 -15
- package/dist/api/station-brokers.d.ts.map +1 -1
- package/dist/api/station-brokers.js +24 -15
- package/dist/api/station-brokers.js.map +1 -1
- package/dist/api/tiny-size.d.ts +2 -1
- package/dist/api/tiny-size.d.ts.map +1 -1
- package/dist/api/tiny-size.js +2 -1
- package/dist/api/tiny-size.js.map +1 -1
- package/dist/api/tone.d.ts +1 -1
- package/dist/api/transport.d.ts +9 -0
- package/dist/api/transport.d.ts.map +1 -1
- package/dist/api/types.d.ts +356 -68
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/uplink-banner.d.ts +113 -0
- package/dist/api/uplink-banner.d.ts.map +1 -0
- package/dist/api/uplink-banner.js +69 -0
- package/dist/api/uplink-banner.js.map +1 -0
- package/dist/api/uplink-handles.d.ts +2 -12
- package/dist/api/uplink-handles.d.ts.map +1 -1
- package/dist/api/uplink-handles.js +2 -1
- package/dist/api/uplink-handles.js.map +1 -1
- package/dist/binary-frame.d.ts +4 -4
- package/dist/binary-frame.js +2 -2
- package/dist/combine-readings.d.ts +4 -3
- package/dist/combine-readings.d.ts.map +1 -1
- package/dist/combine-readings.js +4 -3
- package/dist/combine-readings.js.map +1 -1
- package/dist/command-delay.d.ts +81 -2
- package/dist/command-delay.d.ts.map +1 -1
- package/dist/command-delay.js +51 -8
- package/dist/command-delay.js.map +1 -1
- package/dist/command-value.d.ts +98 -0
- package/dist/command-value.d.ts.map +1 -0
- package/dist/command-value.js +87 -0
- package/dist/command-value.js.map +1 -0
- package/dist/commands.d.ts +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/compat-versions.d.ts +1 -1
- package/dist/compat-versions.d.ts.map +1 -1
- package/dist/compat-versions.js +3 -3
- package/dist/compat-versions.js.map +1 -1
- package/dist/contract-enum-names.d.ts +2 -2
- package/dist/contract-enum-names.js +2 -2
- package/dist/contract-tags.d.ts +33 -2
- package/dist/contract-tags.d.ts.map +1 -1
- package/dist/contract-tags.js +54 -5
- package/dist/contract-tags.js.map +1 -1
- package/dist/data-rate.d.ts +84 -0
- package/dist/data-rate.d.ts.map +1 -0
- package/dist/data-rate.js +133 -0
- package/dist/data-rate.js.map +1 -0
- package/dist/delay-roles.d.ts +14 -1
- package/dist/delay-roles.d.ts.map +1 -1
- package/dist/delay-roles.js +5 -1
- package/dist/delay-roles.js.map +1 -1
- package/dist/dock-markers.d.ts +126 -0
- package/dist/dock-markers.d.ts.map +1 -0
- package/dist/dock-markers.js +100 -0
- package/dist/dock-markers.js.map +1 -0
- package/dist/envelope.d.ts +2 -2
- package/dist/envelope.d.ts.map +1 -1
- package/dist/flight/types.d.ts +31 -2
- package/dist/flight/types.d.ts.map +1 -1
- package/dist/flight/types.js.map +1 -1
- package/dist/frames/index.d.ts +1 -4
- package/dist/frames/index.d.ts.map +1 -1
- package/dist/frames/index.js +0 -3
- package/dist/frames/index.js.map +1 -1
- package/dist/go-no-go-countdown.d.ts +65 -0
- package/dist/go-no-go-countdown.d.ts.map +1 -0
- package/dist/go-no-go-countdown.js +71 -0
- package/dist/go-no-go-countdown.js.map +1 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/ksp-enum-names.d.ts +35 -4
- package/dist/ksp-enum-names.d.ts.map +1 -1
- package/dist/ksp-enum-names.js +31 -4
- package/dist/ksp-enum-names.js.map +1 -1
- package/dist/locked.d.ts +1 -1
- package/dist/locked.js +1 -1
- package/dist/media/delayed-playout-buffer.d.ts +29 -4
- package/dist/media/delayed-playout-buffer.d.ts.map +1 -1
- package/dist/media/delayed-playout-buffer.js +12 -5
- package/dist/media/delayed-playout-buffer.js.map +1 -1
- package/dist/media/encoded-frame-delay.d.ts +21 -16
- package/dist/media/encoded-frame-delay.d.ts.map +1 -1
- package/dist/media/encoded-frame-delay.js +21 -14
- package/dist/media/encoded-frame-delay.js.map +1 -1
- package/dist/media/frame-delay.d.ts +119 -5
- package/dist/media/frame-delay.d.ts.map +1 -1
- package/dist/media/frame-delay.js +201 -15
- package/dist/media/frame-delay.js.map +1 -1
- package/dist/media/frame-stamp-timeline.d.ts +119 -0
- package/dist/media/frame-stamp-timeline.d.ts.map +1 -0
- package/dist/media/frame-stamp-timeline.js +194 -0
- package/dist/media/frame-stamp-timeline.js.map +1 -0
- package/dist/media/index.d.ts +4 -3
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.js.map +1 -1
- package/dist/media/radio-support.d.ts +8 -7
- package/dist/media/radio-support.d.ts.map +1 -1
- package/dist/media/radio-support.js +5 -6
- package/dist/media/radio-support.js.map +1 -1
- package/dist/media/worker/delay-worker-client.d.ts +27 -1
- package/dist/media/worker/delay-worker-client.d.ts.map +1 -1
- package/dist/media/worker/delay-worker-client.js +53 -5
- package/dist/media/worker/delay-worker-client.js.map +1 -1
- package/dist/media/worker/delay-worker.d.ts +45 -8
- package/dist/media/worker/delay-worker.d.ts.map +1 -1
- package/dist/media/worker/delay-worker.js +644 -56
- package/dist/media/worker/delay-worker.js.map +4 -4
- package/dist/media/worker/frame-delay-report.d.ts +25 -0
- package/dist/media/worker/frame-delay-report.d.ts.map +1 -0
- package/dist/media/worker/frame-delay-report.js +112 -0
- package/dist/media/worker/frame-delay-report.js.map +1 -0
- package/dist/media/worker/lead-limit-report.d.ts +13 -0
- package/dist/media/worker/lead-limit-report.d.ts.map +1 -0
- package/dist/media/worker/lead-limit-report.js +19 -0
- package/dist/media/worker/lead-limit-report.js.map +1 -0
- package/dist/media/worker/presentation-pacer.d.ts +70 -1
- package/dist/media/worker/presentation-pacer.d.ts.map +1 -1
- package/dist/media/worker/presentation-pacer.js +167 -9
- package/dist/media/worker/presentation-pacer.js.map +1 -1
- package/dist/media/worker/worker-delay-clock.d.ts +4 -5
- package/dist/media/worker/worker-delay-clock.d.ts.map +1 -1
- package/dist/media/worker/worker-delay-clock.js +6 -2
- package/dist/media/worker/worker-delay-clock.js.map +1 -1
- package/dist/perf/PerfBudget.d.ts +2 -2
- package/dist/perf/PerfBudget.js +2 -2
- package/dist/rail-tags.d.ts +7 -0
- package/dist/rail-tags.d.ts.map +1 -1
- package/dist/rail-tags.js.map +1 -1
- package/dist/raw-field-split.d.ts +1 -1
- package/dist/raw-field-split.js +1 -1
- package/dist/reading.d.ts +6 -6
- package/dist/reading.js +5 -5
- package/dist/reads-index.json +446 -37
- package/dist/resource-transfer.d.ts +177 -0
- package/dist/resource-transfer.d.ts.map +1 -0
- package/dist/resource-transfer.js +190 -0
- package/dist/resource-transfer.js.map +1 -0
- package/dist/runtime-topic-registry.d.ts +2 -2
- package/dist/runtime-topic-registry.d.ts.map +1 -1
- package/dist/runtime-topic-registry.js +23 -2
- package/dist/runtime-topic-registry.js.map +1 -1
- package/dist/sample-step-tracker.d.ts +17 -0
- package/dist/sample-step-tracker.d.ts.map +1 -0
- package/dist/sample-step-tracker.js +38 -0
- package/dist/sample-step-tracker.js.map +1 -0
- package/dist/sha256-fallback.d.ts +6 -0
- package/dist/sha256-fallback.d.ts.map +1 -0
- package/dist/sha256-fallback.js +68 -0
- package/dist/sha256-fallback.js.map +1 -0
- package/dist/spine/arrival-deadline.d.ts +7 -0
- package/dist/spine/arrival-deadline.d.ts.map +1 -1
- package/dist/spine/arrival-deadline.js +12 -0
- package/dist/spine/arrival-deadline.js.map +1 -1
- package/dist/spine/bound-command.d.ts +58 -0
- package/dist/spine/bound-command.d.ts.map +1 -0
- package/dist/spine/bound-command.js +162 -0
- package/dist/spine/bound-command.js.map +1 -0
- package/dist/spine/capability-lock.d.ts +6 -1
- package/dist/spine/capability-lock.d.ts.map +1 -1
- package/dist/spine/capability-lock.js +56 -5
- package/dist/spine/capability-lock.js.map +1 -1
- package/dist/spine/catalog-fallback.d.ts +28 -0
- package/dist/spine/catalog-fallback.d.ts.map +1 -0
- package/dist/spine/catalog-fallback.js +120 -0
- package/dist/spine/catalog-fallback.js.map +1 -0
- package/dist/spine/celestial-facts.d.ts.map +1 -1
- package/dist/spine/celestial-facts.js +5 -2
- package/dist/spine/celestial-facts.js.map +1 -1
- package/dist/spine/centre-commands.d.ts +84 -0
- package/dist/spine/centre-commands.d.ts.map +1 -0
- package/dist/spine/centre-commands.js +236 -0
- package/dist/spine/centre-commands.js.map +1 -0
- package/dist/spine/client-reading.js +1 -1
- package/dist/spine/client-timeline.d.ts +48 -1
- package/dist/spine/client-timeline.d.ts.map +1 -1
- package/dist/spine/client-timeline.js +151 -3
- package/dist/spine/client-timeline.js.map +1 -1
- package/dist/spine/client.d.ts +154 -4
- package/dist/spine/client.d.ts.map +1 -1
- package/dist/spine/client.js +530 -34
- package/dist/spine/client.js.map +1 -1
- package/dist/spine/command-gate.d.ts +8 -0
- package/dist/spine/command-gate.d.ts.map +1 -1
- package/dist/spine/command-gate.js +36 -3
- package/dist/spine/command-gate.js.map +1 -1
- package/dist/spine/command-outcomes.d.ts +60 -0
- package/dist/spine/command-outcomes.d.ts.map +1 -0
- package/dist/spine/command-outcomes.js +256 -0
- package/dist/spine/command-outcomes.js.map +1 -0
- package/dist/spine/connectivity-history.d.ts +5 -3
- package/dist/spine/connectivity-history.d.ts.map +1 -1
- package/dist/spine/connectivity-history.js.map +1 -1
- package/dist/spine/context.d.ts +62 -11
- package/dist/spine/context.d.ts.map +1 -1
- package/dist/spine/context.js +125 -39
- package/dist/spine/context.js.map +1 -1
- package/dist/spine/core-reckoners.d.ts.map +1 -1
- package/dist/spine/core-reckoners.js +16 -39
- package/dist/spine/core-reckoners.js.map +1 -1
- package/dist/spine/delay-authority-context.d.ts +5 -0
- package/dist/spine/delay-authority-context.d.ts.map +1 -0
- package/dist/spine/delay-authority-context.js +7 -0
- package/dist/spine/delay-authority-context.js.map +1 -0
- package/dist/spine/delay-authority.d.ts +76 -1
- package/dist/spine/delay-authority.d.ts.map +1 -1
- package/dist/spine/delay-authority.js +217 -3
- package/dist/spine/delay-authority.js.map +1 -1
- package/dist/spine/delay-estimate.d.ts +41 -0
- package/dist/spine/delay-estimate.d.ts.map +1 -0
- package/dist/spine/delay-estimate.js +70 -0
- package/dist/spine/delay-estimate.js.map +1 -0
- package/dist/spine/delta-v-budget.js +2 -2
- package/dist/spine/delta-v-budget.js.map +1 -1
- package/dist/spine/dv-stage-resources.d.ts +32 -17
- package/dist/spine/dv-stage-resources.d.ts.map +1 -1
- package/dist/spine/dv-stage-resources.js +44 -37
- package/dist/spine/dv-stage-resources.js.map +1 -1
- package/dist/spine/index.d.ts +7 -1
- package/dist/spine/index.d.ts.map +1 -1
- package/dist/spine/index.js +11 -5
- package/dist/spine/index.js.map +1 -1
- package/dist/spine/kepler-reckoning.d.ts +56 -0
- package/dist/spine/kepler-reckoning.d.ts.map +1 -1
- package/dist/spine/kepler-reckoning.js +179 -3
- package/dist/spine/kepler-reckoning.js.map +1 -1
- package/dist/spine/kepler.d.ts +1 -1
- package/dist/spine/kepler.js +1 -1
- package/dist/spine/known-holds.d.ts +8 -0
- package/dist/spine/known-holds.d.ts.map +1 -0
- package/dist/spine/known-holds.js +78 -0
- package/dist/spine/known-holds.js.map +1 -0
- package/dist/spine/lagrange.d.ts +9 -34
- package/dist/spine/lagrange.d.ts.map +1 -1
- package/dist/spine/lagrange.js +4 -24
- package/dist/spine/lagrange.js.map +1 -1
- package/dist/spine/lifecycle.d.ts +21 -0
- package/dist/spine/lifecycle.d.ts.map +1 -1
- package/dist/spine/lifecycle.js.map +1 -1
- package/dist/spine/lock-scope.d.ts +2 -2
- package/dist/spine/map-topic.d.ts +3 -3
- package/dist/spine/map-topic.js +3 -3
- package/dist/spine/never-reckonable.js +1 -1
- package/dist/spine/never-reckonable.js.map +1 -1
- package/dist/spine/orbit-patches.d.ts +6 -4
- package/dist/spine/orbit-patches.d.ts.map +1 -1
- package/dist/spine/orbit-patches.js +45 -10
- package/dist/spine/orbit-patches.js.map +1 -1
- package/dist/spine/orbital-solve.d.ts +1 -1
- package/dist/spine/orbital-solve.d.ts.map +1 -1
- package/dist/spine/orbital-solve.js +35 -0
- package/dist/spine/orbital-solve.js.map +1 -1
- package/dist/spine/powered-reckoning.d.ts +5 -0
- package/dist/spine/powered-reckoning.d.ts.map +1 -1
- package/dist/spine/powered-reckoning.js.map +1 -1
- package/dist/spine/processorEvaluator.d.ts +29 -0
- package/dist/spine/processorEvaluator.d.ts.map +1 -1
- package/dist/spine/processorEvaluator.js +94 -71
- package/dist/spine/processorEvaluator.js.map +1 -1
- package/dist/spine/processors.d.ts +56 -4
- package/dist/spine/processors.d.ts.map +1 -1
- package/dist/spine/processors.js +110 -0
- package/dist/spine/processors.js.map +1 -1
- package/dist/spine/rail-registry.d.ts +1 -1
- package/dist/spine/rail-registry.d.ts.map +1 -1
- package/dist/spine/reckoner-generation.d.ts +5 -0
- package/dist/spine/reckoner-generation.d.ts.map +1 -0
- package/dist/spine/reckoner-generation.js +10 -0
- package/dist/spine/reckoner-generation.js.map +1 -0
- package/dist/spine/reckoners.d.ts.map +1 -1
- package/dist/spine/reckoners.js +3 -0
- package/dist/spine/reckoners.js.map +1 -1
- package/dist/spine/replay-session-controller.d.ts +1 -1
- package/dist/spine/replay-session-controller.d.ts.map +1 -1
- package/dist/spine/replay-session-controller.js +4 -6
- package/dist/spine/replay-session-controller.js.map +1 -1
- package/dist/spine/resolve-tracked.d.ts +20 -2
- package/dist/spine/resolve-tracked.d.ts.map +1 -1
- package/dist/spine/resolve-tracked.js +32 -2
- package/dist/spine/resolve-tracked.js.map +1 -1
- package/dist/spine/send-status.d.ts +2 -0
- package/dist/spine/send-status.d.ts.map +1 -1
- package/dist/spine/send-status.js.map +1 -1
- package/dist/spine/settings-registry.d.ts +7 -0
- package/dist/spine/settings-registry.d.ts.map +1 -1
- package/dist/spine/settings-registry.js.map +1 -1
- package/dist/spine/slot-ids.d.ts +1 -1
- package/dist/spine/slot-ids.d.ts.map +1 -1
- package/dist/spine/slot-ids.js +6 -3
- package/dist/spine/slot-ids.js.map +1 -1
- package/dist/spine/space-center-state.d.ts +17 -9
- package/dist/spine/space-center-state.d.ts.map +1 -1
- package/dist/spine/space-center-state.js +14 -15
- package/dist/spine/space-center-state.js.map +1 -1
- package/dist/spine/stage-countdown-store.d.ts +38 -0
- package/dist/spine/stage-countdown-store.d.ts.map +1 -0
- package/dist/spine/stage-countdown-store.js +53 -0
- package/dist/spine/stage-countdown-store.js.map +1 -0
- package/dist/spine/stream-status.d.ts +3 -3
- package/dist/spine/stream-status.js +3 -3
- package/dist/spine/subscribe-read.d.ts +1 -1
- package/dist/spine/subscribe-read.js +2 -2
- package/dist/spine/system-state.d.ts +13 -13
- package/dist/spine/system-state.d.ts.map +1 -1
- package/dist/spine/system-state.js +18 -18
- package/dist/spine/system-state.js.map +1 -1
- package/dist/spine/timeline-store.d.ts +304 -113
- package/dist/spine/timeline-store.d.ts.map +1 -1
- package/dist/spine/timeline-store.js +921 -223
- package/dist/spine/timeline-store.js.map +1 -1
- package/dist/spine/uplink-clients.d.ts +32 -16
- package/dist/spine/uplink-clients.d.ts.map +1 -1
- package/dist/spine/uplink-clients.js +8 -4
- package/dist/spine/uplink-clients.js.map +1 -1
- package/dist/spine/uplink-delays.d.ts +31 -0
- package/dist/spine/uplink-delays.d.ts.map +1 -0
- package/dist/spine/uplink-delays.js +46 -0
- package/dist/spine/uplink-delays.js.map +1 -0
- package/dist/spine/uplink-health.d.ts +109 -14
- package/dist/spine/uplink-health.d.ts.map +1 -1
- package/dist/spine/uplink-health.js +21 -17
- package/dist/spine/uplink-health.js.map +1 -1
- package/dist/spine/use-action-input.d.ts.map +1 -1
- package/dist/spine/use-action-input.js +14 -9
- package/dist/spine/use-action-input.js.map +1 -1
- package/dist/spine/use-body-states.d.ts.map +1 -1
- package/dist/spine/use-body-states.js +3 -3
- package/dist/spine/use-body-states.js.map +1 -1
- package/dist/spine/use-command.d.ts +94 -31
- package/dist/spine/use-command.d.ts.map +1 -1
- package/dist/spine/use-command.js +409 -197
- package/dist/spine/use-command.js.map +1 -1
- package/dist/spine/use-last-known-path.d.ts +36 -0
- package/dist/spine/use-last-known-path.d.ts.map +1 -0
- package/dist/spine/use-last-known-path.js +46 -0
- package/dist/spine/use-last-known-path.js.map +1 -0
- package/dist/spine/use-observed-vantage.d.ts +13 -0
- package/dist/spine/use-observed-vantage.d.ts.map +1 -0
- package/dist/spine/use-observed-vantage.js +20 -0
- package/dist/spine/use-observed-vantage.js.map +1 -0
- package/dist/spine/use-orbit-trajectory.d.ts +1 -1
- package/dist/spine/use-orbit-trajectory.d.ts.map +1 -1
- package/dist/spine/use-orbit-trajectory.js +17 -3
- package/dist/spine/use-orbit-trajectory.js.map +1 -1
- package/dist/spine/use-stream-connected.d.ts +8 -0
- package/dist/spine/use-stream-connected.d.ts.map +1 -0
- package/dist/spine/use-stream-connected.js +16 -0
- package/dist/spine/use-stream-connected.js.map +1 -0
- package/dist/spine/use-stream-event.d.ts +6 -1
- package/dist/spine/use-stream-event.d.ts.map +1 -1
- package/dist/spine/use-stream-event.js +5 -1
- package/dist/spine/use-stream-event.js.map +1 -1
- package/dist/spine/use-stream.d.ts +5 -2
- package/dist/spine/use-stream.d.ts.map +1 -1
- package/dist/spine/use-stream.js +7 -4
- package/dist/spine/use-stream.js.map +1 -1
- package/dist/spine/use-telemetry.d.ts +5 -1
- package/dist/spine/use-telemetry.d.ts.map +1 -1
- package/dist/spine/use-telemetry.js.map +1 -1
- package/dist/spine/use-topic-clock.d.ts +54 -0
- package/dist/spine/use-topic-clock.d.ts.map +1 -0
- package/dist/spine/use-topic-clock.js +137 -0
- package/dist/spine/use-topic-clock.js.map +1 -0
- package/dist/spine/use-transmissions.d.ts.map +1 -1
- package/dist/spine/use-transmissions.js +9 -4
- package/dist/spine/use-transmissions.js.map +1 -1
- package/dist/spine/vantage.d.ts +6 -0
- package/dist/spine/vantage.d.ts.map +1 -1
- package/dist/spine/vantage.js +6 -0
- package/dist/spine/vantage.js.map +1 -1
- package/dist/spine/view-clock.d.ts +23 -3
- package/dist/spine/view-clock.d.ts.map +1 -1
- package/dist/spine/view-clock.js +80 -2
- package/dist/spine/view-clock.js.map +1 -1
- package/dist/testing/fake-command.d.ts +48 -0
- package/dist/testing/fake-command.d.ts.map +1 -0
- package/dist/testing/fake-command.js +63 -0
- package/dist/testing/fake-command.js.map +1 -0
- package/dist/testing/index.d.ts +5 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +6 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/install-act-gate-stretch.d.ts +1 -2
- package/dist/testing/install-act-gate-stretch.d.ts.map +1 -1
- package/dist/testing/install-act-gate-stretch.js +1 -2
- package/dist/testing/install-act-gate-stretch.js.map +1 -1
- package/dist/testing/install-dom-stubs.d.ts +2 -5
- package/dist/testing/install-dom-stubs.d.ts.map +1 -1
- package/dist/testing/install-dom-stubs.js +2 -34
- package/dist/testing/install-dom-stubs.js.map +1 -1
- package/dist/testing/install-real-test-host.d.ts.map +1 -1
- package/dist/testing/install-real-test-host.js +7 -6
- package/dist/testing/install-real-test-host.js.map +1 -1
- package/dist/testing/recorded-uplink-banners.d.ts +49 -0
- package/dist/testing/recorded-uplink-banners.d.ts.map +1 -0
- package/dist/testing/recorded-uplink-banners.js +45 -0
- package/dist/testing/recorded-uplink-banners.js.map +1 -0
- package/dist/testing/render.d.ts +16 -3
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +16 -3
- package/dist/testing/render.js.map +1 -1
- package/dist/testing/stream-fixture.js +3 -3
- package/dist/testing/stream-fixture.js.map +1 -1
- package/dist/testing/stub-transport.d.ts +6 -0
- package/dist/testing/stub-transport.d.ts.map +1 -1
- package/dist/testing/stub-transport.js +3 -0
- package/dist/testing/stub-transport.js.map +1 -1
- package/dist/timeline.d.ts +2 -98
- package/dist/timeline.d.ts.map +1 -1
- package/dist/topics.d.ts +68 -28
- package/dist/topics.d.ts.map +1 -1
- package/dist/topics.js +21 -18
- package/dist/topics.js.map +1 -1
- package/dist/unit-system/index.d.ts +1 -1
- package/dist/unit-system/index.d.ts.map +1 -1
- package/dist/unit-system/index.js +1 -1
- package/dist/unit-system/index.js.map +1 -1
- package/dist/unit-system/value.d.ts +26 -5
- package/dist/unit-system/value.d.ts.map +1 -1
- package/dist/unit-system/value.js +41 -21
- package/dist/unit-system/value.js.map +1 -1
- package/dist/units.d.ts.map +1 -1
- package/dist/units.js +2 -1
- package/dist/units.js.map +1 -1
- package/dist/uplink-externals.d.ts +17 -7
- package/dist/uplink-externals.d.ts.map +1 -1
- package/dist/uplink-externals.js +17 -7
- package/dist/uplink-externals.js.map +1 -1
- package/dist/uplink-load.d.ts +3 -2
- package/dist/uplink-load.d.ts.map +1 -1
- package/dist/uplink-load.js +9 -6
- package/dist/uplink-load.js.map +1 -1
- package/dist/uplink-manifest.d.ts +8 -3
- package/dist/uplink-manifest.d.ts.map +1 -1
- package/dist/uplink-manifest.js +5 -1
- package/dist/uplink-manifest.js.map +1 -1
- package/dist/wrap-units.d.ts.map +1 -1
- package/dist/wrap-units.js +3 -2
- package/dist/wrap-units.js.map +1 -1
- package/package.json +1 -1
- package/src/__generated__/command-map.ts +215 -19
- package/src/__generated__/contract.ts +3102 -330
- package/src/__generated__/delay-roles.ts +12 -0
- package/src/__generated__/error-codes.ts +13 -13
- package/src/__generated__/frames.ts +20 -4
- package/src/__generated__/reckonability.ts +3 -1
- package/src/__generated__/sample-kinds.ts +18 -2
- package/src/__generated__/topic-map.ts +68 -19
- package/src/__generated__/units.json +958 -94
- package/src/__generated__/units.ts +949 -76
- package/src/api/command-rejection.ts +2 -2
- package/src/api/contribution-slots.ts +128 -25
- package/src/api/error-codes.ts +3 -2
- package/src/api/framework-reads.ts +6 -1
- package/src/api/host.ts +14 -6
- package/src/api/index.ts +127 -67
- package/src/api/logger-contract.ts +2 -1
- package/src/api/logger.ts +6 -3
- package/src/api/part-panels.ts +221 -0
- package/src/api/plot-layers.ts +1 -1
- package/src/api/registry.ts +4 -2
- package/src/api/settings/store.ts +7 -2
- package/src/api/slots.ts +153 -70
- package/src/api/station-brokers.ts +24 -15
- package/src/api/tiny-size.ts +2 -1
- package/src/api/tone.ts +1 -1
- package/src/api/transport.ts +13 -0
- package/src/api/types.ts +388 -68
- package/src/api/uplink-banner.ts +128 -0
- package/src/api/uplink-handles.ts +4 -1
- package/src/binary-frame.ts +4 -4
- package/src/combine-readings.ts +4 -3
- package/src/command-delay.ts +144 -11
- package/src/command-value.ts +181 -0
- package/src/compat-versions.ts +3 -3
- package/src/contract-enum-names.ts +2 -2
- package/src/contract-tags.ts +67 -5
- package/src/data-rate.ts +178 -0
- package/src/delay-roles.ts +19 -2
- package/src/dock-markers.ts +182 -0
- package/src/envelope.ts +4 -0
- package/src/flight/types.ts +31 -2
- package/src/frames/index.ts +0 -4
- package/src/go-no-go-countdown.ts +116 -0
- package/src/index.ts +64 -4
- package/src/ksp-enum-names.ts +48 -3
- package/src/locked.ts +1 -1
- package/src/media/__fixtures__/hull-after-revert.json +1506 -0
- package/src/media/delayed-playout-buffer.ts +41 -9
- package/src/media/encoded-frame-delay.ts +29 -17
- package/src/media/frame-delay.ts +328 -22
- package/src/media/frame-stamp-timeline.ts +270 -0
- package/src/media/index.ts +5 -0
- package/src/media/radio-support.ts +8 -7
- package/src/media/worker/delay-worker-client.ts +104 -6
- package/src/media/worker/delay-worker.ts +228 -27
- package/src/media/worker/frame-delay-report.ts +141 -0
- package/src/media/worker/lead-limit-report.ts +27 -0
- package/src/media/worker/presentation-pacer.ts +216 -9
- package/src/media/worker/worker-delay-clock.ts +9 -6
- package/src/perf/PerfBudget.ts +2 -2
- package/src/rail-tags.ts +8 -0
- package/src/raw-field-split.ts +1 -1
- package/src/reading.ts +6 -6
- package/src/resource-transfer.ts +352 -0
- package/src/runtime-topic-registry.ts +23 -2
- package/src/sample-step-tracker.ts +38 -0
- package/src/sha256-fallback.ts +69 -0
- package/src/spine/__fixtures__/crash/crash-eva.json +224 -0
- package/src/spine/__fixtures__/crash/crash-separated-pod-pod-root.json +144 -0
- package/src/spine/__fixtures__/crash/crash-separated-pod.json +111 -0
- package/src/spine/__fixtures__/switch/back-to-craft.jsonl +101 -0
- package/src/spine/__fixtures__/switch/late-sent-frame.jsonl +16 -0
- package/src/spine/__fixtures__/switch/linked-craft.jsonl +63 -0
- package/src/spine/__fixtures__/switch/station-trim.jsonl +229 -0
- package/src/spine/__fixtures__/switch/switch-with-scene.jsonl +110 -0
- package/src/spine/__fixtures__/switch/unlinked-craft.jsonl +46 -0
- package/src/spine/arrival-deadline.ts +15 -0
- package/src/spine/bound-command.ts +243 -0
- package/src/spine/capability-lock.ts +65 -6
- package/src/spine/catalog-fallback.ts +152 -0
- package/src/spine/celestial-facts.ts +4 -2
- package/src/spine/centre-commands.ts +314 -0
- package/src/spine/client-reading.ts +1 -1
- package/src/spine/client-timeline.ts +165 -4
- package/src/spine/client.ts +615 -32
- package/src/spine/command-gate.ts +44 -3
- package/src/spine/command-outcomes.ts +303 -0
- package/src/spine/connectivity-history.ts +5 -3
- package/src/spine/context.tsx +154 -50
- package/src/spine/core-reckoners.ts +31 -50
- package/src/spine/delay-authority-context.ts +9 -0
- package/src/spine/delay-authority.ts +227 -3
- package/src/spine/delay-estimate.ts +88 -0
- package/src/spine/delta-v-budget.ts +2 -2
- package/src/spine/dv-stage-resources.ts +55 -43
- package/src/spine/index.ts +11 -5
- package/src/spine/kepler-reckoning.ts +245 -3
- package/src/spine/kepler.ts +1 -1
- package/src/spine/known-holds.ts +96 -0
- package/src/spine/lagrange.ts +10 -46
- package/src/spine/lifecycle.ts +22 -0
- package/src/spine/lock-scope.ts +2 -2
- package/src/spine/map-topic.ts +3 -3
- package/src/spine/never-reckonable.ts +1 -1
- package/src/spine/orbit-patches.ts +54 -10
- package/src/spine/orbital-solve.ts +53 -1
- package/src/spine/powered-reckoning.ts +5 -1
- package/src/spine/processorEvaluator.ts +106 -72
- package/src/spine/processors.ts +144 -4
- package/src/spine/rail-registry.ts +1 -1
- package/src/spine/reckoner-generation.ts +11 -0
- package/src/spine/reckoners.ts +3 -0
- package/src/spine/replay-session-controller.ts +4 -6
- package/src/spine/resolve-tracked.ts +50 -1
- package/src/spine/send-status.ts +2 -0
- package/src/spine/settings-registry.ts +7 -0
- package/src/spine/slot-ids.ts +6 -3
- package/src/spine/space-center-state.ts +17 -20
- package/src/spine/stage-countdown-store.ts +76 -0
- package/src/spine/stream-status.ts +4 -4
- package/src/spine/subscribe-read.ts +2 -2
- package/src/spine/system-state.ts +19 -21
- package/src/spine/timeline-store.ts +1119 -247
- package/src/spine/uplink-clients.ts +44 -22
- package/src/spine/uplink-delays.ts +57 -0
- package/src/spine/uplink-health.ts +59 -27
- package/src/spine/use-action-input.ts +13 -9
- package/src/spine/use-body-states.ts +5 -4
- package/src/spine/use-command.ts +620 -239
- package/src/spine/use-last-known-path.ts +75 -0
- package/src/spine/use-observed-vantage.ts +24 -0
- package/src/spine/use-orbit-trajectory.ts +22 -3
- package/src/spine/use-stream-connected.ts +23 -0
- package/src/spine/use-stream-event.ts +6 -2
- package/src/spine/use-stream.ts +7 -4
- package/src/spine/use-telemetry.ts +5 -1
- package/src/spine/use-topic-clock.ts +196 -0
- package/src/spine/use-transmissions.ts +37 -18
- package/src/spine/vantage.ts +7 -0
- package/src/spine/view-clock.ts +89 -3
- package/src/testing/fake-command.ts +109 -0
- package/src/testing/index.ts +12 -1
- package/src/testing/install-act-gate-stretch.ts +1 -2
- package/src/testing/install-dom-stubs.ts +2 -38
- package/src/testing/install-real-test-host.ts +10 -6
- package/src/testing/recorded-uplink-banners.ts +71 -0
- package/src/testing/render.tsx +16 -3
- package/src/testing/stream-fixture.tsx +3 -3
- package/src/testing/stub-transport.ts +9 -0
- package/src/timeline.ts +2 -103
- package/src/topics.ts +87 -26
- package/src/unit-system/index.ts +2 -0
- package/src/unit-system/value.ts +61 -21
- package/src/units.ts +2 -1
- package/src/uplink-externals.ts +17 -7
- package/src/uplink-load.ts +9 -8
- package/src/uplink-manifest.ts +8 -3
- package/src/wrap-units.ts +3 -9
- package/dist/spine/contributed-channels.d.ts +0 -56
- package/dist/spine/contributed-channels.d.ts.map +0 -1
- package/dist/spine/contributed-channels.js +0 -108
- package/dist/spine/contributed-channels.js.map +0 -1
- package/src/spine/contributed-channels.ts +0 -134
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {
|
|
2
|
+
SystemBodies,
|
|
3
|
+
TrackingStationCatalog,
|
|
4
|
+
} from "../__generated__/contract";
|
|
5
|
+
import {
|
|
6
|
+
type DataRateReport,
|
|
7
|
+
type Meta,
|
|
8
|
+
Quality,
|
|
9
|
+
Staleness,
|
|
10
|
+
} from "../__generated__/contract";
|
|
11
|
+
import { GENERATED_TOPIC_IDS } from "../__generated__/topic-map";
|
|
2
12
|
import type { Transport } from "../api/transport";
|
|
3
13
|
import {
|
|
4
14
|
channelKindOf,
|
|
@@ -7,6 +17,12 @@ import {
|
|
|
7
17
|
sampleKindOf,
|
|
8
18
|
} from "../channel-tags";
|
|
9
19
|
import { type SampleKind, valueTagsOf } from "../contract-tags";
|
|
20
|
+
import {
|
|
21
|
+
hasSupersededFields,
|
|
22
|
+
samplesPerSecondOf,
|
|
23
|
+
supersededPayload,
|
|
24
|
+
tierSamplesPerSecondOf,
|
|
25
|
+
} from "../data-rate";
|
|
10
26
|
import {
|
|
11
27
|
type DeclaredDelayRoles,
|
|
12
28
|
type DelayLane,
|
|
@@ -33,8 +49,13 @@ import {
|
|
|
33
49
|
reckonableInputSpelling,
|
|
34
50
|
reckonableValuesOf,
|
|
35
51
|
} from "../reckonability";
|
|
36
|
-
import
|
|
37
|
-
import {
|
|
52
|
+
import { dynamicValue, isValue, type Value } from "../unit-system/value";
|
|
53
|
+
import {
|
|
54
|
+
CATALOG_FALLBACK_INPUTS,
|
|
55
|
+
CATALOG_FALLBACK_TOPICS,
|
|
56
|
+
catalogIdentityPoint,
|
|
57
|
+
catalogOrbitPoint,
|
|
58
|
+
} from "./catalog-fallback";
|
|
38
59
|
import {
|
|
39
60
|
type ReckonerFor,
|
|
40
61
|
readingFrom,
|
|
@@ -45,16 +66,28 @@ import {
|
|
|
45
66
|
type ClientTimelineOptions,
|
|
46
67
|
type TimelinePoint,
|
|
47
68
|
} from "./client-timeline";
|
|
48
|
-
/**
|
|
49
|
-
* The derived-channel authoring types moved to `@ksp-gonogo/sitrep-sdk` so an Uplink
|
|
50
|
-
* can write a channel without importing this package. Re-exported here unchanged.
|
|
51
|
-
*/
|
|
52
69
|
import {
|
|
53
70
|
HeartbeatTracker,
|
|
54
71
|
type HeartbeatTrackerOptions,
|
|
55
72
|
} from "./heartbeat-tracker";
|
|
56
|
-
import {
|
|
57
|
-
|
|
73
|
+
import {
|
|
74
|
+
processorInputTopics,
|
|
75
|
+
processorRuntimeFor,
|
|
76
|
+
recordPublishedEvaluation,
|
|
77
|
+
runProcessorCompute,
|
|
78
|
+
} from "./processorEvaluator";
|
|
79
|
+
import {
|
|
80
|
+
type AnyProcessorDefinition,
|
|
81
|
+
type Dep,
|
|
82
|
+
getProcessor,
|
|
83
|
+
isProcessorDep,
|
|
84
|
+
isReadingDep,
|
|
85
|
+
isSubjectDep,
|
|
86
|
+
type ProcessorFrame,
|
|
87
|
+
type PublishedProcessorDefinition,
|
|
88
|
+
type SubjectDep,
|
|
89
|
+
} from "./processors";
|
|
90
|
+
import { reckonerGeneration } from "./reckoner-generation";
|
|
58
91
|
import {
|
|
59
92
|
CORE_RECKONER_OWNER,
|
|
60
93
|
getReckoner,
|
|
@@ -65,8 +98,6 @@ import type { StreamStatusValue } from "./stream-status";
|
|
|
65
98
|
import { worstStatus } from "./stream-status";
|
|
66
99
|
import type { Certainty, ViewClock } from "./view-clock";
|
|
67
100
|
|
|
68
|
-
export type { DerivedChannelDefinition, DerivedGet } from "../timeline";
|
|
69
|
-
|
|
70
101
|
/**
|
|
71
102
|
* The frozen view-time token for one frame or read cycle. Useful for making every
|
|
72
103
|
* reading drawn in one frame show the same instant. Taken by the stream hooks and
|
|
@@ -141,6 +172,25 @@ function mintToken(clock: ViewClock, generation: number): FrameToken {
|
|
|
141
172
|
};
|
|
142
173
|
}
|
|
143
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Where a store that keeps only the window its readers draw gets older points
|
|
177
|
+
* from: the one screen that holds the full run. Used by a station's store, which
|
|
178
|
+
* asks the main screen over PeerJS.
|
|
179
|
+
*
|
|
180
|
+
* @category Stream fixture
|
|
181
|
+
*/
|
|
182
|
+
export interface HistorySource {
|
|
183
|
+
/** The points of `topic` with `validAt` in `[fromUt, toUt]`, oldest first. Rejects when the main screen cannot answer. */
|
|
184
|
+
request(
|
|
185
|
+
topic: string,
|
|
186
|
+
fromUt: number,
|
|
187
|
+
toUt: number,
|
|
188
|
+
): Promise<readonly TimelinePoint<unknown>[]>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Seconds of game time kept beyond what readers hold, so a hold-last or interpolated read at the view edge finds its neighbours. */
|
|
192
|
+
const HELD_WINDOW_FLOOR_SECONDS = 10;
|
|
193
|
+
|
|
144
194
|
export interface TimelineStoreOptions {
|
|
145
195
|
timelineOptions?: ClientTimelineOptions;
|
|
146
196
|
/** Per-topic keyframe intervals and the staleness margin that decide when a reading is held for want of a new frame. */
|
|
@@ -208,31 +258,51 @@ function walkFieldPath(value: unknown, fieldPath: readonly string[]): unknown {
|
|
|
208
258
|
}
|
|
209
259
|
|
|
210
260
|
/**
|
|
211
|
-
* Which lane a
|
|
261
|
+
* Which lane a published processor is read in: the most conservative of its
|
|
212
262
|
* declared inputs.
|
|
213
263
|
*
|
|
214
|
-
* A
|
|
215
|
-
* the
|
|
216
|
-
*
|
|
264
|
+
* A processor with no inputs is as current as the frame either way, so it takes
|
|
265
|
+
* the delayed lane with everything else rather than being special-cased into the
|
|
266
|
+
* one that can run ahead.
|
|
217
267
|
*
|
|
218
|
-
* Reads
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
268
|
+
* Reads its declared deps and not what `compute` consulted, because the lane has
|
|
269
|
+
* to be decided before `compute` runs. A processor that consults a subset of its
|
|
270
|
+
* deps is therefore read no more current than the input it declared and skipped,
|
|
271
|
+
* which is the safe direction of that inaccuracy.
|
|
222
272
|
*/
|
|
223
|
-
function
|
|
224
|
-
def:
|
|
273
|
+
function processorLane(
|
|
274
|
+
def: AnyProcessorDefinition,
|
|
225
275
|
declaredLane: (topic: string) => DelayLane,
|
|
226
276
|
): DelayLane {
|
|
227
|
-
const inputs = def
|
|
277
|
+
const inputs = [...processorInputTopics(def)];
|
|
228
278
|
return inputs.length > 0 &&
|
|
229
279
|
inputs.every((topic) => declaredLane(topic) === "true-now")
|
|
230
280
|
? "true-now"
|
|
231
281
|
: "delayed";
|
|
232
282
|
}
|
|
233
283
|
|
|
234
|
-
/**
|
|
235
|
-
|
|
284
|
+
/**
|
|
285
|
+
* What a processor's dependencies resolve against: a live frame, or one instant
|
|
286
|
+
* of a replay over stored history.
|
|
287
|
+
*/
|
|
288
|
+
interface ProcessorDepSource {
|
|
289
|
+
viewUt: number;
|
|
290
|
+
point(topic: string): TimelinePoint<unknown> | undefined;
|
|
291
|
+
reading(topic: string): TopicReading<unknown>;
|
|
292
|
+
processor(id: string): ProcessorRun;
|
|
293
|
+
/** Whether this run counts against the evaluation budget. A replay of history does not, so a chart rebuild cannot trip it. */
|
|
294
|
+
live: boolean;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** One processor evaluated, and the oldest input instant it consumed. */
|
|
298
|
+
interface ProcessorRun {
|
|
299
|
+
computed: unknown;
|
|
300
|
+
result: unknown;
|
|
301
|
+
oldest: number;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Synthetic envelope `Meta` stamped on a published processor's point. Status is read through `sampleStatus`, so this only has to satisfy the `Meta` shape every `TimelinePoint` carries. */
|
|
305
|
+
function processorMeta(viewUt: number, epoch: number): Meta {
|
|
236
306
|
return {
|
|
237
307
|
source: "derived",
|
|
238
308
|
validAt: viewUt,
|
|
@@ -329,6 +399,20 @@ export type GapModel =
|
|
|
329
399
|
/** The answer for a span wider than warp-free sampling that no model claims. */
|
|
330
400
|
const UNCLAIMED: GapModel = { carried: false, unclaimed: true };
|
|
331
401
|
|
|
402
|
+
/** The `meta.source` a payload carries about itself, or `undefined` where it carries none. */
|
|
403
|
+
function payloadMetaSource(payload: unknown): string | undefined {
|
|
404
|
+
if (typeof payload !== "object" || payload === null) return undefined;
|
|
405
|
+
if (!("meta" in payload)) return undefined;
|
|
406
|
+
const { meta } = payload;
|
|
407
|
+
if (typeof meta !== "object" || meta === null || !("source" in meta)) {
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
return typeof meta.source === "string" ? meta.source : undefined;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** The game's statement of which craft is active. */
|
|
414
|
+
const ACTIVE_VESSEL_TOPIC = "ksp.activeVessel";
|
|
415
|
+
|
|
332
416
|
/**
|
|
333
417
|
* How many instants inside one unobserved span the model is asked about. Enough
|
|
334
418
|
* to draw one full swing of an orbit smoothly, which is the most a single span
|
|
@@ -356,6 +440,76 @@ const RECKONED_EDGE_BISECTIONS = 12;
|
|
|
356
440
|
/** The engine-built roster whose `delayRoles` block decides every declared topic's lane. */
|
|
357
441
|
const UPLINK_ROSTER_TOPIC = "system.uplinks";
|
|
358
442
|
|
|
443
|
+
/** The report that names the active craft in its `meta.source` the moment the game switches, ahead of every delayed reading of the craft itself. */
|
|
444
|
+
const ACTIVE_CRAFT_TOPIC = "comms.delay";
|
|
445
|
+
const DATA_RATES_TOPIC = "system.dataRates";
|
|
446
|
+
|
|
447
|
+
const CRAFT_SOURCE_PREFIX = "vessel:";
|
|
448
|
+
|
|
449
|
+
/** The domain of the topics that describe whichever craft is active. */
|
|
450
|
+
const ACTIVE_VESSEL_TOPIC_PREFIX = "vessel.";
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The command centre's figures about the active craft whose payloads do not name
|
|
454
|
+
* the craft: its route, its signal, its centre, its link's grading and each
|
|
455
|
+
* centre's delay to it. Each is the active craft's only once recorded after that
|
|
456
|
+
* craft became active, so a screen never shows the craft left behind's figure as
|
|
457
|
+
* the new craft's.
|
|
458
|
+
*/
|
|
459
|
+
const UNNAMED_ACTIVE_CRAFT_FIGURES: ReadonlySet<string> = new Set([
|
|
460
|
+
"comms.path",
|
|
461
|
+
"comms.signal",
|
|
462
|
+
"comms.commandCentre",
|
|
463
|
+
"comms.degrade",
|
|
464
|
+
"commandCentre.activeVesselDelay",
|
|
465
|
+
]);
|
|
466
|
+
|
|
467
|
+
const CORE_TOPIC_IDS: ReadonlySet<string> = new Set(GENERATED_TOPIC_IDS);
|
|
468
|
+
|
|
469
|
+
/** The reports of the active craft's link, which the mod sends through a blackout. */
|
|
470
|
+
const LINK_REPORT_TOPICS: ReadonlySet<string> = new Set([
|
|
471
|
+
"comms.link",
|
|
472
|
+
"comms.connectivity",
|
|
473
|
+
"comms.control",
|
|
474
|
+
]);
|
|
475
|
+
|
|
476
|
+
/** The vessel id a `ksp.activeVessel` payload names, or `undefined` for a withdrawn statement or one with none. */
|
|
477
|
+
function statedVesselId(payload: unknown): string | undefined {
|
|
478
|
+
if (typeof payload !== "object" || payload === null) return undefined;
|
|
479
|
+
if (!("vesselId" in payload)) return undefined;
|
|
480
|
+
const id = payload.vesselId;
|
|
481
|
+
return typeof id === "string" && id !== "" ? id : undefined;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** The node a craft's own readings are delivered from, as the envelope's `meta.source` names it. */
|
|
485
|
+
const CRAFT_NODE_PREFIX = "fleet.";
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* The craft a reading describes, lower-cased as a payload's `meta.source`: the
|
|
489
|
+
* payload's own word, else the craft whose node delivered it. An Uplink's payload
|
|
490
|
+
* may carry no meta of its own, and a reading kept per craft is still delivered
|
|
491
|
+
* from that craft's node.
|
|
492
|
+
*/
|
|
493
|
+
function craftOfPoint(point: TimelinePoint<unknown>): string | undefined {
|
|
494
|
+
const own = craftSourceOf(point.payload);
|
|
495
|
+
if (own !== undefined) return own.toLowerCase();
|
|
496
|
+
const node = point.meta.source;
|
|
497
|
+
return typeof node === "string" && node.startsWith(CRAFT_NODE_PREFIX)
|
|
498
|
+
? `${CRAFT_SOURCE_PREFIX}${node.slice(CRAFT_NODE_PREFIX.length)}`.toLowerCase()
|
|
499
|
+
: undefined;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** The `meta.source` a payload carries, when it names a craft. */
|
|
503
|
+
function craftSourceOf(payload: unknown): string | undefined {
|
|
504
|
+
if (typeof payload !== "object" || payload === null) return undefined;
|
|
505
|
+
const meta = (payload as { meta?: unknown }).meta;
|
|
506
|
+
if (typeof meta !== "object" || meta === null) return undefined;
|
|
507
|
+
const source = (meta as { source?: unknown }).source;
|
|
508
|
+
return typeof source === "string" && source.startsWith(CRAFT_SOURCE_PREFIX)
|
|
509
|
+
? source
|
|
510
|
+
: undefined;
|
|
511
|
+
}
|
|
512
|
+
|
|
359
513
|
/**
|
|
360
514
|
* How long, in milliseconds, a load must run before it is shown. Useful for
|
|
361
515
|
* keeping a brief scene change from flashing every reading as held and back. A
|
|
@@ -364,6 +518,20 @@ const UPLINK_ROSTER_TOPIC = "system.uplinks";
|
|
|
364
518
|
*/
|
|
365
519
|
export const GAME_LOADING_ONSET_MS = 750;
|
|
366
520
|
|
|
521
|
+
function hasSignalDelay(seconds: number): boolean {
|
|
522
|
+
return seconds > 0 && Number.isFinite(seconds);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* How long after a load ends a Topic may keep standing on readings from before
|
|
527
|
+
* it, waiting for the mod to send what its command centre had heard at the save.
|
|
528
|
+
* Past this the Topic blanks until its first fresh reading.
|
|
529
|
+
*/
|
|
530
|
+
const LOAD_BRIDGE_GRACE_MS = 5000;
|
|
531
|
+
|
|
532
|
+
/** How long a notice about a game load stays on screen, in seconds: the "Game loaded" banner, and the status line of a command the load undid. */
|
|
533
|
+
export const GAME_LOAD_NOTICE_SECONDS = 10;
|
|
534
|
+
|
|
367
535
|
/**
|
|
368
536
|
* What the game is doing as the operator is shown it, with the scene being loaded
|
|
369
537
|
* or the one that stands. Useful for telling the operator the game is loading.
|
|
@@ -615,7 +783,7 @@ function lerpFieldValue(
|
|
|
615
783
|
if (lerped === undefined || typeof lerped.value !== "number") {
|
|
616
784
|
return undefined;
|
|
617
785
|
}
|
|
618
|
-
return { value:
|
|
786
|
+
return { value: dynamicValue(before.unit, lerped.value) };
|
|
619
787
|
}
|
|
620
788
|
if (typeof before === "number" && typeof after === "number") {
|
|
621
789
|
if (ANGULAR_DEGREE_FIELD_NAMES.has(key)) {
|
|
@@ -732,18 +900,34 @@ function interpolatedRead<Payload>(
|
|
|
732
900
|
* - In a drawing loop of your own, pass `sample(topic, token)` the token from
|
|
733
901
|
* `currentFrame()`, or one you made with `beginFrame()`
|
|
734
902
|
*
|
|
735
|
-
*
|
|
903
|
+
* Published processors are read through
|
|
736
904
|
* `sample` the same way.
|
|
737
905
|
*
|
|
738
906
|
* @category Stream fixture
|
|
739
907
|
*/
|
|
740
908
|
export class TimelineStore {
|
|
741
909
|
private readonly timelines = new Map<string, ClientTimeline<unknown>>();
|
|
742
|
-
|
|
910
|
+
/* Every revision counted in `dataRevision` only ever grows and no timeline is ever removed, so the sum moves on every change. */
|
|
911
|
+
private publishedRegistrations = 0;
|
|
912
|
+
/**
|
|
913
|
+
* Samples a game second each Topic above one arrives at, from the latest
|
|
914
|
+
* `system.dataRates`. A Topic's timeline keeps its point bound times this, so
|
|
915
|
+
* it spans the same game time at any rate.
|
|
916
|
+
*/
|
|
917
|
+
private readonly topicRates = new Map<string, number>();
|
|
918
|
+
private readonly publishedProcessors = new Map<
|
|
743
919
|
string,
|
|
744
|
-
|
|
920
|
+
PublishedProcessorDefinition
|
|
745
921
|
>();
|
|
746
922
|
private readonly frameListeners = new Set<() => void>();
|
|
923
|
+
/* Seconds each raw Topic's readers draw, one entry per live hold. Only read while a history source is set. */
|
|
924
|
+
private readonly heldWindows = new Map<string, Set<{ seconds: number }>>();
|
|
925
|
+
/* The span last asked the history source for, per raw Topic and epoch, so a gap is requested once. */
|
|
926
|
+
private readonly askedFrom = new Map<
|
|
927
|
+
string,
|
|
928
|
+
{ epoch: number; fromUt: number; toUt: number }
|
|
929
|
+
>();
|
|
930
|
+
private historySource: HistorySource | undefined;
|
|
747
931
|
private currentToken: FrameToken;
|
|
748
932
|
private generation = 0;
|
|
749
933
|
|
|
@@ -800,20 +984,20 @@ export class TimelineStore {
|
|
|
800
984
|
* (including as `currentToken`), its cache entry is collected too. The
|
|
801
985
|
* first `sample(topic, token)` read for a given `(token, topic)` pair is
|
|
802
986
|
* authoritative for that token's whole lifetime; a mid-frame `ingest`
|
|
803
|
-
* cannot flip it. Also the seam
|
|
987
|
+
* cannot flip it. Also the seam published processors reuse instead of
|
|
804
988
|
* building their own per-frame cache.
|
|
805
989
|
*/
|
|
806
990
|
private readonly frameCache = new WeakMap<FrameToken, Map<string, unknown>>();
|
|
807
991
|
|
|
808
992
|
/**
|
|
809
|
-
* What each
|
|
810
|
-
* its field subtopics. A frame whose `
|
|
993
|
+
* What each published processor answered last, and the point served for each of
|
|
994
|
+
* its field subtopics. A frame whose `compute` comes out structurally equal
|
|
811
995
|
* hands back these same objects, so a reader comparing by reference sees a
|
|
812
996
|
* change only when the record really moved. Keyed by definition, so a
|
|
813
997
|
* channel re-registered under the same topic starts clean.
|
|
814
998
|
*/
|
|
815
|
-
private readonly
|
|
816
|
-
|
|
999
|
+
private readonly publishedCarry = new WeakMap<
|
|
1000
|
+
AnyProcessorDefinition,
|
|
817
1001
|
{ value: unknown; points: Map<string, TimelinePoint<unknown>> }
|
|
818
1002
|
>();
|
|
819
1003
|
|
|
@@ -898,6 +1082,7 @@ export class TimelineStore {
|
|
|
898
1082
|
* reference by default.
|
|
899
1083
|
*/
|
|
900
1084
|
private transportConnected = true;
|
|
1085
|
+
private readonly connectionListeners = new Set<() => void>();
|
|
901
1086
|
|
|
902
1087
|
/**
|
|
903
1088
|
* What the game is doing, as the mod last said and as the operator is shown
|
|
@@ -907,6 +1092,8 @@ export class TimelineStore {
|
|
|
907
1092
|
*/
|
|
908
1093
|
private gameShown: GameStatus = { state: "ready", scene: "" };
|
|
909
1094
|
private gameOnset: ReturnType<typeof setTimeout> | undefined;
|
|
1095
|
+
private bridgeGrace: ReturnType<typeof setTimeout> | undefined;
|
|
1096
|
+
private delayedAtLoadStart = false;
|
|
910
1097
|
private readonly gameListeners = new Set<() => void>();
|
|
911
1098
|
|
|
912
1099
|
/**
|
|
@@ -921,6 +1108,22 @@ export class TimelineStore {
|
|
|
921
1108
|
*/
|
|
922
1109
|
private declaredRoles: DeclaredDelayRoles | undefined;
|
|
923
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* The craft the game has active, as a `meta.source`, captured at ingest. The
|
|
1113
|
+
* game's own statement of it (`ksp.activeVessel`) names the new craft the
|
|
1114
|
+
* moment of a switch; the `meta.source` of the newest `comms.delay` is the
|
|
1115
|
+
* fallback while that statement has not been heard, and for a linked craft it
|
|
1116
|
+
* can name the craft left behind for a whole signal delay after the switch.
|
|
1117
|
+
* Either way, after a switch every delayed reading in the timelines is still
|
|
1118
|
+
* about the old craft.
|
|
1119
|
+
*/
|
|
1120
|
+
private activeCraftSource: string | undefined;
|
|
1121
|
+
|
|
1122
|
+
/** Whether the game's statement of the active craft has been heard, which then outranks the delay report. */
|
|
1123
|
+
private activeCraftStated = false;
|
|
1124
|
+
/** When the game last named a craft other than the one before it as active, or negative infinity before any change. */
|
|
1125
|
+
private activeCraftSinceUt = Number.NEGATIVE_INFINITY;
|
|
1126
|
+
|
|
924
1127
|
/** The sample kinds the mod stated on the newest `system.uplinks`, captured at ingest for the same reason the roles are. */
|
|
925
1128
|
private declaredKinds: DeclaredSampleKinds | undefined;
|
|
926
1129
|
|
|
@@ -942,7 +1145,25 @@ export class TimelineStore {
|
|
|
942
1145
|
* outright over this.
|
|
943
1146
|
*/
|
|
944
1147
|
setTransportConnected(connected: boolean): void {
|
|
1148
|
+
if (this.transportConnected === connected) return;
|
|
945
1149
|
this.transportConnected = connected;
|
|
1150
|
+
for (const listener of this.connectionListeners) listener();
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Whether the stream to the mod is open, as the transport last said. True
|
|
1155
|
+
* until a transport says otherwise.
|
|
1156
|
+
*/
|
|
1157
|
+
streamConnected(): boolean {
|
|
1158
|
+
return this.transportConnected;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/** Called whenever {@link streamConnected} changes. Returns an unsubscribe function. */
|
|
1162
|
+
subscribeStreamConnected(listener: () => void): () => void {
|
|
1163
|
+
this.connectionListeners.add(listener);
|
|
1164
|
+
return () => {
|
|
1165
|
+
this.connectionListeners.delete(listener);
|
|
1166
|
+
};
|
|
946
1167
|
}
|
|
947
1168
|
|
|
948
1169
|
/**
|
|
@@ -962,6 +1183,16 @@ export class TimelineStore {
|
|
|
962
1183
|
clearTimeout(this.gameOnset);
|
|
963
1184
|
this.gameOnset = undefined;
|
|
964
1185
|
}
|
|
1186
|
+
if (this.bridgeGrace !== undefined) {
|
|
1187
|
+
clearTimeout(this.bridgeGrace);
|
|
1188
|
+
this.bridgeGrace = undefined;
|
|
1189
|
+
}
|
|
1190
|
+
if (state === "loading" && !this.loadRequested) {
|
|
1191
|
+
this.delayedAtLoadStart = hasSignalDelay(this.clock.delaySeconds());
|
|
1192
|
+
}
|
|
1193
|
+
this.loadRequested = state === "loading";
|
|
1194
|
+
this.gameRunning = state === "ready";
|
|
1195
|
+
if (!this.loadRequested) this.endBridgesAfterLoad();
|
|
965
1196
|
if (state === "loading") {
|
|
966
1197
|
this.gameOnset = setTimeout(() => {
|
|
967
1198
|
this.gameOnset = undefined;
|
|
@@ -975,6 +1206,62 @@ export class TimelineStore {
|
|
|
975
1206
|
});
|
|
976
1207
|
}
|
|
977
1208
|
|
|
1209
|
+
/**
|
|
1210
|
+
* Answer a `timeline-reset` the mod sent for `topic`. While a load is in
|
|
1211
|
+
* progress and kept history, the Topic's readings at or before
|
|
1212
|
+
* `keptThroughUt` stand, graded `"loading"`, until the load ends. A load that
|
|
1213
|
+
* kept none empties the Topic here. A reset with no load in progress leaves
|
|
1214
|
+
* the readings to the first sample of the new timeline.
|
|
1215
|
+
*/
|
|
1216
|
+
noteTimelineReset(topic: string, keptThroughUt: number | undefined): void {
|
|
1217
|
+
const timeline = this.timelines.get(topic);
|
|
1218
|
+
if (!timeline) return;
|
|
1219
|
+
if (keptThroughUt !== undefined && !this.loadRequested) return;
|
|
1220
|
+
timeline.retainThrough(keptThroughUt);
|
|
1221
|
+
this.beginFrame();
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
/*
|
|
1225
|
+
* With a delay the mod sends each Topic what its command centre had heard at
|
|
1226
|
+
* the save a tick after the load ends, so a Topic keeps its readings until its
|
|
1227
|
+
* first reading of the new timeline replaces them, or the grace runs out. With
|
|
1228
|
+
* no delay the loaded world's own first frame is the next thing sent and the
|
|
1229
|
+
* Topic blanks at once until it arrives.
|
|
1230
|
+
*/
|
|
1231
|
+
private endBridgesAfterLoad(): void {
|
|
1232
|
+
/*
|
|
1233
|
+
* The delay is read again at the end of the load only as a second
|
|
1234
|
+
* opinion: the load empties the Topics the delay is learned from, so on a
|
|
1235
|
+
* first load it can read zero here while the screen was delayed before.
|
|
1236
|
+
*/
|
|
1237
|
+
if (
|
|
1238
|
+
!this.delayedAtLoadStart &&
|
|
1239
|
+
!hasSignalDelay(this.clock.delaySeconds())
|
|
1240
|
+
) {
|
|
1241
|
+
this.endBridges();
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
this.bridgeGrace = setTimeout(() => {
|
|
1245
|
+
this.bridgeGrace = undefined;
|
|
1246
|
+
this.endBridges();
|
|
1247
|
+
}, LOAD_BRIDGE_GRACE_MS);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* Empty every timeline still standing on readings from before a load that
|
|
1252
|
+
* kept history: the load is over, and the mod now holds each channel's first
|
|
1253
|
+
* frame back, so nothing from before it is shown.
|
|
1254
|
+
*/
|
|
1255
|
+
private endBridges(): void {
|
|
1256
|
+
let ended = false;
|
|
1257
|
+
for (const timeline of this.timelines.values()) {
|
|
1258
|
+
if (!timeline.bridging) continue;
|
|
1259
|
+
timeline.retainThrough(undefined);
|
|
1260
|
+
ended = true;
|
|
1261
|
+
}
|
|
1262
|
+
if (ended) this.beginFrame();
|
|
1263
|
+
}
|
|
1264
|
+
|
|
978
1265
|
/** What the game is doing as the operator is shown it. */
|
|
979
1266
|
gameStatus(): GameStatus {
|
|
980
1267
|
return this.gameShown;
|
|
@@ -988,6 +1275,26 @@ export class TimelineStore {
|
|
|
988
1275
|
};
|
|
989
1276
|
}
|
|
990
1277
|
|
|
1278
|
+
private loadRequested = false;
|
|
1279
|
+
|
|
1280
|
+
/** Whether the game last said it was running a scene: not loading one, and not at its main menu. */
|
|
1281
|
+
private gameRunning = false;
|
|
1282
|
+
private lastRunningUt: number | undefined;
|
|
1283
|
+
private resetFrom: { epoch: number; ut: number } | undefined;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* The UT this screen was showing, in the epoch before the current one, if
|
|
1287
|
+
* the game was running a scene then. Undefined when no game was running
|
|
1288
|
+
* before the current epoch began, as on a screen that connected at the main
|
|
1289
|
+
* menu. Useful for saying how far a load moved the game from where the
|
|
1290
|
+
* operator last saw it. Used by the banner that announces a loaded game.
|
|
1291
|
+
*/
|
|
1292
|
+
utBeforeReset(): number | undefined {
|
|
1293
|
+
return this.resetFrom?.epoch === this.clock.getEpoch()
|
|
1294
|
+
? this.resetFrom.ut
|
|
1295
|
+
: undefined;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
991
1298
|
private showGameStatus(status: GameStatus): void {
|
|
992
1299
|
if (
|
|
993
1300
|
status.state === this.gameShown.state &&
|
|
@@ -1058,9 +1365,32 @@ export class TimelineStore {
|
|
|
1058
1365
|
// resynchronizing period that follows. This point's own arrival still
|
|
1059
1366
|
// counts as a fresh heartbeat for its topic once the clear has run.
|
|
1060
1367
|
this.heartbeats.reset();
|
|
1368
|
+
if (this.lastRunningUt !== undefined) {
|
|
1369
|
+
this.resetFrom = { epoch: point.epoch, ut: this.lastRunningUt };
|
|
1370
|
+
this.lastRunningUt = undefined;
|
|
1371
|
+
}
|
|
1061
1372
|
}
|
|
1062
1373
|
|
|
1063
1374
|
this.timelineFor<Payload>(topic).append(point);
|
|
1375
|
+
if (this.historySource) this.keepHeldWindow(topic);
|
|
1376
|
+
if (topic === DATA_RATES_TOPIC) {
|
|
1377
|
+
this.applyDataRates(point.payload as DataRateReport | null);
|
|
1378
|
+
}
|
|
1379
|
+
if (topic === ACTIVE_CRAFT_TOPIC && !this.activeCraftStated) {
|
|
1380
|
+
this.activeCraftSource =
|
|
1381
|
+
craftSourceOf(point.payload) ?? this.activeCraftSource;
|
|
1382
|
+
}
|
|
1383
|
+
if (topic === ACTIVE_VESSEL_TOPIC) {
|
|
1384
|
+
const id = statedVesselId(point.payload);
|
|
1385
|
+
if (id !== undefined) {
|
|
1386
|
+
const source = `${CRAFT_SOURCE_PREFIX}${id}`;
|
|
1387
|
+
if (this.activeCraftStated && source !== this.activeCraftSource) {
|
|
1388
|
+
this.activeCraftSinceUt = point.validAt;
|
|
1389
|
+
}
|
|
1390
|
+
this.activeCraftSource = source;
|
|
1391
|
+
this.activeCraftStated = true;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1064
1394
|
if (topic === UPLINK_ROSTER_TOPIC) {
|
|
1065
1395
|
this.declaredRoles = readDeclaredDelayRoles(point.payload);
|
|
1066
1396
|
this.declaredKinds = readDeclaredSampleKinds(point.payload);
|
|
@@ -1071,6 +1401,16 @@ export class TimelineStore {
|
|
|
1071
1401
|
point.epoch,
|
|
1072
1402
|
options.replayed === true,
|
|
1073
1403
|
);
|
|
1404
|
+
if (this.gameRunning && !options.replayed) {
|
|
1405
|
+
const ut = this.clock.utNowEstimate();
|
|
1406
|
+
if (Number.isFinite(ut)) this.lastRunningUt = ut;
|
|
1407
|
+
}
|
|
1408
|
+
if (hasSupersededFields(topic)) {
|
|
1409
|
+
this.timelineFor<Payload>(topic).supersedeBefore(
|
|
1410
|
+
this.clock.certaintyHorizonUt(),
|
|
1411
|
+
(payload) => supersededPayload(topic, payload),
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1074
1414
|
// Every live sample, keyframe or change-emission alike, confirms the link
|
|
1075
1415
|
// is alive as of this arrival. A recorded one does not: it describes the
|
|
1076
1416
|
// past, and can be delivered while the craft is still out of contact.
|
|
@@ -1088,40 +1428,196 @@ export class TimelineStore {
|
|
|
1088
1428
|
}
|
|
1089
1429
|
}
|
|
1090
1430
|
|
|
1431
|
+
/**
|
|
1432
|
+
* Make a reader's window of `topic` count as needed, for as long as the
|
|
1433
|
+
* returned release has not been called. With a history source set, a Topic
|
|
1434
|
+
* keeps only the longest window any live hold names plus a short floor, and
|
|
1435
|
+
* older points are asked for from the source when a hold needs them. Without
|
|
1436
|
+
* one the store keeps every point its bound allows and a hold does nothing.
|
|
1437
|
+
* Used by the series hook behind charts and sparklines.
|
|
1438
|
+
*/
|
|
1439
|
+
holdWindow(topic: string, seconds: number): () => void {
|
|
1440
|
+
const hold = { seconds };
|
|
1441
|
+
const rawTopics = this.rawTopicsOf(topic);
|
|
1442
|
+
for (const raw of rawTopics) {
|
|
1443
|
+
let holds = this.heldWindows.get(raw);
|
|
1444
|
+
if (!holds) {
|
|
1445
|
+
holds = new Set();
|
|
1446
|
+
this.heldWindows.set(raw, holds);
|
|
1447
|
+
}
|
|
1448
|
+
holds.add(hold);
|
|
1449
|
+
}
|
|
1450
|
+
if (this.historySource) {
|
|
1451
|
+
for (const raw of rawTopics) this.keepHeldWindow(raw);
|
|
1452
|
+
}
|
|
1453
|
+
return () => {
|
|
1454
|
+
for (const raw of rawTopics) {
|
|
1455
|
+
this.heldWindows.get(raw)?.delete(hold);
|
|
1456
|
+
if (this.historySource) this.keepHeldWindow(raw);
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Keep only the window readers hold, fetching older points from `source`
|
|
1463
|
+
* when a reader asks for more than is held. Useful on a screen that is not the
|
|
1464
|
+
* one holding the full run. Returns the function that puts the store back to
|
|
1465
|
+
* keeping everything its bound allows.
|
|
1466
|
+
*/
|
|
1467
|
+
setHistorySource(source: HistorySource): () => void {
|
|
1468
|
+
this.historySource = source;
|
|
1469
|
+
for (const topic of this.timelines.keys()) this.keepHeldWindow(topic);
|
|
1470
|
+
return () => {
|
|
1471
|
+
if (this.historySource === source) this.historySource = undefined;
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/** How many points all Topics hold between them. */
|
|
1476
|
+
heldPointCount(): number {
|
|
1477
|
+
let total = 0;
|
|
1478
|
+
for (const timeline of this.timelines.values()) total += timeline.size;
|
|
1479
|
+
return total;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
private rawTopicsOf(topic: string): string[] {
|
|
1483
|
+
const out = new Set<string>();
|
|
1484
|
+
for (const wire of this.resolveSubscriptionTopics(topic)) {
|
|
1485
|
+
out.add(this.resolveRawFieldSubtopic(wire)?.rawTopic ?? wire);
|
|
1486
|
+
}
|
|
1487
|
+
return [...out];
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
private keepHeldWindow(raw: string): void {
|
|
1491
|
+
const timeline = this.timelines.get(raw);
|
|
1492
|
+
const latest = timeline?.latest();
|
|
1493
|
+
if (!timeline || !latest) return;
|
|
1494
|
+
let need = 0;
|
|
1495
|
+
for (const hold of this.heldWindows.get(raw) ?? []) {
|
|
1496
|
+
need = Math.max(need, hold.seconds);
|
|
1497
|
+
}
|
|
1498
|
+
const viewUt = this.clock.viewUt("delayed");
|
|
1499
|
+
const anchor = Number.isFinite(viewUt)
|
|
1500
|
+
? Math.min(latest.validAt, viewUt)
|
|
1501
|
+
: latest.validAt;
|
|
1502
|
+
const fromUt = anchor - need - HELD_WINDOW_FLOOR_SECONDS;
|
|
1503
|
+
/*
|
|
1504
|
+
* A topic that follows the active craft keeps each craft's newest reading,
|
|
1505
|
+
* because a read walks back to the active craft's own: the game names a new
|
|
1506
|
+
* craft just after its reading arrives, and the view can lie behind that
|
|
1507
|
+
* reading until the delay to the craft is known.
|
|
1508
|
+
*/
|
|
1509
|
+
timeline.trimBefore(
|
|
1510
|
+
fromUt,
|
|
1511
|
+
this.followsActiveCraft(raw) ? craftOfPoint : undefined,
|
|
1512
|
+
);
|
|
1513
|
+
if (need > 0) this.fetchHeldWindow(raw, timeline, fromUt);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
private fetchHeldWindow(
|
|
1517
|
+
raw: string,
|
|
1518
|
+
timeline: ClientTimeline<unknown>,
|
|
1519
|
+
fromUt: number,
|
|
1520
|
+
): void {
|
|
1521
|
+
const source = this.historySource;
|
|
1522
|
+
const earliest = timeline.earliest();
|
|
1523
|
+
if (!source || !earliest || earliest.validAt <= fromUt) return;
|
|
1524
|
+
const asked = this.askedFrom.get(raw);
|
|
1525
|
+
const epoch = timeline.epoch;
|
|
1526
|
+
const toUt = earliest.validAt;
|
|
1527
|
+
if (
|
|
1528
|
+
asked &&
|
|
1529
|
+
asked.epoch === epoch &&
|
|
1530
|
+
asked.fromUt <= fromUt &&
|
|
1531
|
+
asked.toUt >= toUt
|
|
1532
|
+
) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
this.askedFrom.set(raw, { epoch, fromUt, toUt });
|
|
1536
|
+
source
|
|
1537
|
+
.request(raw, fromUt, toUt)
|
|
1538
|
+
.then((points) => {
|
|
1539
|
+
if (this.historySource !== source || timeline.epoch !== epoch) return;
|
|
1540
|
+
const held = new Set(
|
|
1541
|
+
timeline.range(fromUt, toUt).map((p) => `${p.validAt}:${p.meta.seq}`),
|
|
1542
|
+
);
|
|
1543
|
+
for (const point of points) {
|
|
1544
|
+
if (point.epoch !== epoch) continue;
|
|
1545
|
+
const key = `${point.validAt}:${point.meta.seq}`;
|
|
1546
|
+
if (held.has(key)) continue;
|
|
1547
|
+
held.add(key);
|
|
1548
|
+
timeline.append(point);
|
|
1549
|
+
}
|
|
1550
|
+
})
|
|
1551
|
+
.catch(() => {
|
|
1552
|
+
if (this.askedFrom.get(raw)?.fromUt === fromUt) {
|
|
1553
|
+
this.askedFrom.delete(raw);
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1091
1558
|
/** The per-topic `ClientTimeline`, created on first access. */
|
|
1092
1559
|
getTimeline<Payload>(topic: string): ClientTimeline<Payload> {
|
|
1093
1560
|
return this.timelineFor<Payload>(topic);
|
|
1094
1561
|
}
|
|
1095
1562
|
|
|
1096
1563
|
/**
|
|
1097
|
-
*
|
|
1564
|
+
* Publish a processor as a Topic on this store. From this point on,
|
|
1098
1565
|
* `sample(def.topic, token)`, and every reactive read built on it,
|
|
1099
|
-
* transparently returns the
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
* resolved too (`resolveDerivedTopic`).
|
|
1566
|
+
* transparently returns the processor's value for the frame instead of reading
|
|
1567
|
+
* a raw `ClientTimeline`, so a caller never needs to know whether a topic is
|
|
1568
|
+
* raw or computed. If `def.fields` is set, `"<topic>.<field>"` subtopics are
|
|
1569
|
+
* resolved too (`resolvePublishedTopic`).
|
|
1104
1570
|
*
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1571
|
+
* `id` and `owner` are optional for a processor that is not in the registry,
|
|
1572
|
+
* and `deps` may name a Topic no generated list knows. Publishing the same
|
|
1573
|
+
* `topic` twice replaces the previous definition, useful for hot-reload and
|
|
1574
|
+
* test setup, not a guarded no-op.
|
|
1107
1575
|
*/
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1576
|
+
publishProcessor<Values extends readonly unknown[], Payload>(def: {
|
|
1577
|
+
id?: string;
|
|
1578
|
+
owner?: string;
|
|
1579
|
+
topic: string;
|
|
1580
|
+
fields?: boolean;
|
|
1581
|
+
deps: readonly (Dep | string)[];
|
|
1582
|
+
compute: (
|
|
1583
|
+
values: Values,
|
|
1584
|
+
frame: ProcessorFrame,
|
|
1585
|
+
) => Payload | null | undefined;
|
|
1586
|
+
}): void {
|
|
1587
|
+
this.publishedRegistrations++;
|
|
1588
|
+
this.publishedProcessors.set(def.topic, {
|
|
1589
|
+
...def,
|
|
1590
|
+
id: def.id ?? def.topic,
|
|
1591
|
+
owner: def.owner ?? CORE_RECKONER_OWNER,
|
|
1592
|
+
deps: def.deps as readonly Dep[],
|
|
1593
|
+
compute: def.compute as PublishedProcessorDefinition["compute"],
|
|
1594
|
+
});
|
|
1115
1595
|
}
|
|
1116
1596
|
|
|
1117
1597
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1598
|
+
* A number that changes whenever anything a read of history rests on changes:
|
|
1599
|
+
* a sample stored, evicted or rewound away on any Topic, or a model or
|
|
1600
|
+
* published processor registered. Useful for a reader that rebuilds a window of history on
|
|
1601
|
+
* every frame to skip the rebuild while the view time and this number both
|
|
1602
|
+
* stand still, since nothing it reads can have moved. Used by the series hook
|
|
1603
|
+
* behind charts and sparklines.
|
|
1604
|
+
*/
|
|
1605
|
+
dataRevision(): number {
|
|
1606
|
+
let revision = reckonerGeneration() + this.publishedRegistrations;
|
|
1607
|
+
for (const timeline of this.timelines.values()) {
|
|
1608
|
+
revision += timeline.revision;
|
|
1609
|
+
}
|
|
1610
|
+
return revision;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Whether a processor is already published under `topic`. Lets a caller adding
|
|
1615
|
+
* processors after construction leave an existing one alone, so a topic keeps
|
|
1120
1616
|
* the model it was built with rather than the model whichever import landed
|
|
1121
1617
|
* last.
|
|
1122
1618
|
*/
|
|
1123
|
-
|
|
1124
|
-
return this.
|
|
1619
|
+
hasPublishedProcessor(topic: string): boolean {
|
|
1620
|
+
return this.publishedProcessors.has(topic);
|
|
1125
1621
|
}
|
|
1126
1622
|
|
|
1127
1623
|
/**
|
|
@@ -1221,15 +1717,13 @@ export class TimelineStore {
|
|
|
1221
1717
|
/**
|
|
1222
1718
|
* The raw wire topics that must actually be subscribed (via
|
|
1223
1719
|
* `TelemetryClient.subscribe`) to keep `topic` resolvable, the
|
|
1224
|
-
*
|
|
1720
|
+
* published-processor input ref-counting mechanism. A published processor's own
|
|
1225
1721
|
* topic (or one of its `"<topic>.<field>"` subtopics) is never itself a
|
|
1226
1722
|
* subscribable wire topic; no server channel produces it, so a caller
|
|
1227
1723
|
* that naively subscribed to the derived topic name would never receive
|
|
1228
1724
|
* any data and the channel would silently stay "not whole yet" forever.
|
|
1229
1725
|
* This resolves `topic` down to the declared `inputs` it actually needs,
|
|
1230
|
-
* recursively (a
|
|
1231
|
-
* per `DerivedGet`'s doc: `derive` can read another derived channel as an
|
|
1232
|
-
* input), de-duplicated, and defended against a malformed cyclical
|
|
1726
|
+
* recursively (a published processor can depend on another one), de-duplicated, and defended against a malformed cyclical
|
|
1233
1727
|
* declaration (an authoring bug, never expected in practice) via a
|
|
1234
1728
|
* visited-set guard rather than an infinite loop.
|
|
1235
1729
|
*
|
|
@@ -1250,7 +1744,7 @@ export class TimelineStore {
|
|
|
1250
1744
|
* A model declares its inputs and `registeredReckoning` refuses to run it
|
|
1251
1745
|
* with one of them missing, which is the whole point of declaring them. But
|
|
1252
1746
|
* nothing was holding those inputs up. A read subscribed the topic it was
|
|
1253
|
-
* reading and a
|
|
1747
|
+
* reading and a published processor's deps, and a raw topic's reckoner deps
|
|
1254
1748
|
* are neither, so a lone plot of `vessel.flight.altitudeAsl` declined with
|
|
1255
1749
|
* `input-absent` for ever and drew no tail, while the same plot beside a
|
|
1256
1750
|
* widget reading `vessel.orbit` drew one. Whether a model runs is not
|
|
@@ -1281,8 +1775,10 @@ export class TimelineStore {
|
|
|
1281
1775
|
const parsed = this.resolveRawFieldSubtopic(topic);
|
|
1282
1776
|
const elected =
|
|
1283
1777
|
getReckoner(topic) ?? (parsed ? getReckoner(parsed.rawTopic) : undefined);
|
|
1284
|
-
|
|
1285
|
-
|
|
1778
|
+
const out = new Set<string>(
|
|
1779
|
+
this.vesselInputTopics(parsed?.rawTopic ?? topic),
|
|
1780
|
+
);
|
|
1781
|
+
if (!elected) return [...out];
|
|
1286
1782
|
for (const dep of elected.definition.deps as readonly Dep[]) {
|
|
1287
1783
|
const depTopic =
|
|
1288
1784
|
typeof dep === "string"
|
|
@@ -1298,12 +1794,26 @@ export class TimelineStore {
|
|
|
1298
1794
|
return [...out];
|
|
1299
1795
|
}
|
|
1300
1796
|
|
|
1797
|
+
/**
|
|
1798
|
+
* The topics a read of the active craft's figures needs besides its own: the
|
|
1799
|
+
* game's statement of which craft is active, which tells a craft's own
|
|
1800
|
+
* samples from the previous craft's, and for the orbit and identity the
|
|
1801
|
+
* catalog and bodies they fall back to until the craft's own arrive.
|
|
1802
|
+
*/
|
|
1803
|
+
private vesselInputTopics(raw: string): string[] {
|
|
1804
|
+
if (this.resolvePublishedTopic(raw)) return [];
|
|
1805
|
+
if (this.laneForTopic(raw) === "true-now") return [];
|
|
1806
|
+
return CATALOG_FALLBACK_TOPICS.includes(raw)
|
|
1807
|
+
? [ACTIVE_VESSEL_TOPIC, ...CATALOG_FALLBACK_INPUTS]
|
|
1808
|
+
: [ACTIVE_VESSEL_TOPIC];
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1301
1811
|
private collectSubscriptionTopics(
|
|
1302
1812
|
topic: string,
|
|
1303
1813
|
out: Set<string>,
|
|
1304
1814
|
visiting: Set<string>,
|
|
1305
1815
|
): void {
|
|
1306
|
-
const resolved = this.
|
|
1816
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
1307
1817
|
if (!resolved) {
|
|
1308
1818
|
// Raw record field-subtopic: the raw wire topic that must
|
|
1309
1819
|
// actually be subscribed is the record itself (`"time.warp"`), never
|
|
@@ -1317,22 +1827,22 @@ export class TimelineStore {
|
|
|
1317
1827
|
const parentTopic = resolved.def.topic;
|
|
1318
1828
|
if (visiting.has(parentTopic)) return; // cyclical declaration, break, don't loop forever
|
|
1319
1829
|
visiting.add(parentTopic);
|
|
1320
|
-
for (const input of resolved.def
|
|
1830
|
+
for (const input of processorInputTopics(resolved.def)) {
|
|
1321
1831
|
this.collectSubscriptionTopics(input, out, visiting);
|
|
1322
1832
|
}
|
|
1323
1833
|
}
|
|
1324
1834
|
|
|
1325
1835
|
/**
|
|
1326
1836
|
* True when `topic` names a `"<parent>.<field>"` subtopic whose parent
|
|
1327
|
-
* resolved to a whole, non-tombstoned
|
|
1837
|
+
* resolved to a whole, non-tombstoned computed record (the processor
|
|
1328
1838
|
* genuinely ran) but `field` is not a key on the record it produced, a
|
|
1329
1839
|
* structurally dead mapping (e.g. a stale migration-table entry pointing
|
|
1330
|
-
* at a field a `
|
|
1840
|
+
* at a field a `compute` never emits), as opposed to ordinary
|
|
1331
1841
|
* "not whole yet" loading (parent has no point at all yet) or a confirmed
|
|
1332
1842
|
* absence (parent tombstoned): both of which return `false` here, same as
|
|
1333
1843
|
* a healthy field that just hasn't arrived.
|
|
1334
1844
|
*
|
|
1335
|
-
* `sample()` alone can't make this distinction: `
|
|
1845
|
+
* `sample()` alone can't make this distinction: `samplePublished`'s field
|
|
1336
1846
|
* lookup collapses "unknown field name" and "not whole yet" onto the same
|
|
1337
1847
|
* `undefined` return, deliberately (see its own doc comment). This is a
|
|
1338
1848
|
* separate diagnostic read for a caller that needs to tell "still loading, keep waiting" apart
|
|
@@ -1348,7 +1858,7 @@ export class TimelineStore {
|
|
|
1348
1858
|
* failure into an empty gauge). The second branch below applies the exact
|
|
1349
1859
|
* same "whole-but-missing-field = unresolvable" check to a raw parent,
|
|
1350
1860
|
* walking the full fieldpath (which may be 1+ segments, unlike the
|
|
1351
|
-
* single-segment
|
|
1861
|
+
* single-segment published-processor case above) via the same walk
|
|
1352
1862
|
* `sampleRawFieldSubtopic`/`sampleRange` use.
|
|
1353
1863
|
*/
|
|
1354
1864
|
isUnresolvableField(
|
|
@@ -1360,7 +1870,7 @@ export class TimelineStore {
|
|
|
1360
1870
|
const parentTopic = topic.slice(0, dot);
|
|
1361
1871
|
const field = topic.slice(dot + 1);
|
|
1362
1872
|
|
|
1363
|
-
if (this.
|
|
1873
|
+
if (this.publishedProcessors.has(parentTopic)) {
|
|
1364
1874
|
const parentPoint = this.sample<Record<string, unknown>>(
|
|
1365
1875
|
parentTopic,
|
|
1366
1876
|
token,
|
|
@@ -1393,20 +1903,20 @@ export class TimelineStore {
|
|
|
1393
1903
|
}
|
|
1394
1904
|
|
|
1395
1905
|
/**
|
|
1396
|
-
* `true` when `topic` names a registered
|
|
1906
|
+
* `true` when `topic` names a registered published processor, its own topic
|
|
1397
1907
|
* or one of its `"<topic>.<field>"` subtopics (`resolveDerivedTopic`).
|
|
1398
1908
|
* `false` for a raw topic, including a raw record field-subtopic
|
|
1399
1909
|
* (`resolveRawFieldSubtopic`, e.g. `"vessel.orbit.sma"`), that string
|
|
1400
1910
|
* looks derived-shaped (it has dots) but resolves to a real wire record's
|
|
1401
|
-
* timeline, not a
|
|
1911
|
+
* timeline, not a published processor. What `sampleRange`
|
|
1402
1912
|
* consults to decide "there's a stored history to range over" (a raw
|
|
1403
|
-
* topic always has one, a
|
|
1913
|
+
* topic always has one, a published processor's never does, it's a per-frame
|
|
1404
1914
|
* computed value, see `sampleRange`'s own doc) versus `isUnresolvableField`
|
|
1405
1915
|
* above, which asks a narrower question (a specific field name on an
|
|
1406
1916
|
* otherwise-whole derived record) for a different caller.
|
|
1407
1917
|
*/
|
|
1408
|
-
|
|
1409
|
-
return this.
|
|
1918
|
+
isProcessorTopic(topic: string): boolean {
|
|
1919
|
+
return this.resolvePublishedTopic(topic) !== undefined;
|
|
1410
1920
|
}
|
|
1411
1921
|
|
|
1412
1922
|
/**
|
|
@@ -1418,9 +1928,9 @@ export class TimelineStore {
|
|
|
1418
1928
|
* hold-last read.
|
|
1419
1929
|
*
|
|
1420
1930
|
* Returns `undefined`, not an empty array, when `topic` resolves to a
|
|
1421
|
-
* registered
|
|
1931
|
+
* registered published processor (`isProcessorTopic`): a computed value is
|
|
1422
1932
|
* computed fresh per frame from whatever its inputs currently hold
|
|
1423
|
-
* (`
|
|
1933
|
+
* (`samplePublished`), never stored as its own buffered history, so there is
|
|
1424
1934
|
* structurally nothing to range over. This is the caller's "give up,
|
|
1425
1935
|
* permanently, on this topic" signal: distinct from an empty array,
|
|
1426
1936
|
* which means "genuinely nothing landed in the window yet" and may fill
|
|
@@ -1443,20 +1953,20 @@ export class TimelineStore {
|
|
|
1443
1953
|
fromUt: number,
|
|
1444
1954
|
toUt: number,
|
|
1445
1955
|
): TimelinePoint<Payload>[] | undefined {
|
|
1446
|
-
if (this.
|
|
1956
|
+
if (this.resolvePublishedTopic(topic)) return undefined;
|
|
1447
1957
|
|
|
1448
1958
|
const epoch = this.clock.getEpoch();
|
|
1449
1959
|
const rawField = this.resolveRawFieldSubtopic(topic);
|
|
1450
1960
|
if (!rawField) {
|
|
1451
1961
|
const timeline = this.timelineFor<Payload>(topic);
|
|
1452
|
-
if (timeline.epoch < epoch) return [];
|
|
1962
|
+
if (timeline.epoch < epoch && !timeline.bridging) return [];
|
|
1453
1963
|
return timeline.range(fromUt, toUt);
|
|
1454
1964
|
}
|
|
1455
1965
|
|
|
1456
1966
|
const parentTimeline = this.timelineFor<Record<string, unknown>>(
|
|
1457
1967
|
rawField.rawTopic,
|
|
1458
1968
|
);
|
|
1459
|
-
if (parentTimeline.epoch < epoch) return [];
|
|
1969
|
+
if (parentTimeline.epoch < epoch && !parentTimeline.bridging) return [];
|
|
1460
1970
|
|
|
1461
1971
|
const out: TimelinePoint<Payload>[] = [];
|
|
1462
1972
|
for (const point of parentTimeline.range(fromUt, toUt)) {
|
|
@@ -1486,41 +1996,33 @@ export class TimelineStore {
|
|
|
1486
1996
|
}
|
|
1487
1997
|
|
|
1488
1998
|
/**
|
|
1489
|
-
* Windowed series for a
|
|
1490
|
-
* (which structurally can't serve one:
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1494
|
-
*
|
|
1495
|
-
* changed
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
* exercises it today.
|
|
1512
|
-
*
|
|
1513
|
-
* Returns `undefined` when `topic` doesn't resolve to a registered derived
|
|
1514
|
-
* channel at all (mirrors `sampleRange`'s contract): callers are expected
|
|
1515
|
-
* to gate on `isDerivedTopic` first, same as `sampleRange`'s own callers
|
|
1516
|
-
* gate the other way.
|
|
1517
|
-
*/
|
|
1518
|
-
sampleDerivedRange<Payload>(
|
|
1999
|
+
* Windowed series for a published processor: the counterpart to `sampleRange`
|
|
2000
|
+
* (which structurally can't serve one: nothing is ever stored for a computed
|
|
2001
|
+
* Topic). Useful for plotting one as a series, as a graph widget does.
|
|
2002
|
+
*
|
|
2003
|
+
* Runs `compute` again at every UT any of its input Topics actually changed at
|
|
2004
|
+
* within `[fromUt, toUt]` (a change-gated raw timeline only ever carries a point
|
|
2005
|
+
* when something changed, so this is exactly the set of instants the result
|
|
2006
|
+
* could have changed too), its deps resolved by hold-last lookup over each
|
|
2007
|
+
* input's own buffered range (queried from `-Infinity` through `toUt`, so an
|
|
2008
|
+
* input that last changed before `fromUt` still resolves correctly at the first
|
|
2009
|
+
* in-window instant; `ClientTimeline`'s own retention window bounds this, not an
|
|
2010
|
+
* unbounded scan). A processor dep is replayed at the same instant.
|
|
2011
|
+
*
|
|
2012
|
+
* No status is recorded for a past instant, so a `{ reading }` dep is handed in
|
|
2013
|
+
* as observed at its last sample, and as pending before its first.
|
|
2014
|
+
*
|
|
2015
|
+
* Returns `undefined` when `topic` doesn't resolve to a published processor at
|
|
2016
|
+
* all (mirrors `sampleRange`'s contract): callers are expected to gate on
|
|
2017
|
+
* `isProcessorTopic` first, same as `sampleRange`'s own callers gate the other
|
|
2018
|
+
* way.
|
|
2019
|
+
*/
|
|
2020
|
+
sampleProcessorRange<Payload>(
|
|
1519
2021
|
topic: string,
|
|
1520
2022
|
fromUt: number,
|
|
1521
2023
|
toUt: number,
|
|
1522
2024
|
): TimelinePoint<Payload>[] | undefined {
|
|
1523
|
-
const resolved = this.
|
|
2025
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
1524
2026
|
if (!resolved) return undefined;
|
|
1525
2027
|
const { def, field } = resolved;
|
|
1526
2028
|
|
|
@@ -1528,7 +2030,7 @@ export class TimelineStore {
|
|
|
1528
2030
|
|
|
1529
2031
|
const inputRanges = new Map<string, TimelinePoint<unknown>[]>();
|
|
1530
2032
|
const changeUts = new Set<number>();
|
|
1531
|
-
for (const inputTopic of def
|
|
2033
|
+
for (const inputTopic of processorInputTopics(def)) {
|
|
1532
2034
|
const points =
|
|
1533
2035
|
this.sampleRange<unknown>(inputTopic, -Infinity, toUt) ?? [];
|
|
1534
2036
|
inputRanges.set(inputTopic, points);
|
|
@@ -1543,20 +2045,33 @@ export class TimelineStore {
|
|
|
1543
2045
|
const out: TimelinePoint<Payload>[] = [];
|
|
1544
2046
|
|
|
1545
2047
|
for (const ut of sortedUts) {
|
|
1546
|
-
const
|
|
2048
|
+
const point = (
|
|
1547
2049
|
inputTopic: string,
|
|
1548
|
-
): TimelinePoint<
|
|
2050
|
+
): TimelinePoint<unknown> | undefined => {
|
|
1549
2051
|
const points = inputRanges.get(inputTopic);
|
|
1550
2052
|
if (!points || points.length === 0) return undefined;
|
|
1551
2053
|
let last: TimelinePoint<unknown> | undefined;
|
|
1552
|
-
for (const
|
|
1553
|
-
if (
|
|
2054
|
+
for (const candidate of points) {
|
|
2055
|
+
if (candidate.validAt <= ut) last = candidate;
|
|
1554
2056
|
else break;
|
|
1555
2057
|
}
|
|
1556
|
-
return last
|
|
2058
|
+
return last;
|
|
2059
|
+
};
|
|
2060
|
+
const source: ProcessorDepSource = {
|
|
2061
|
+
viewUt: ut,
|
|
2062
|
+
point,
|
|
2063
|
+
reading: (inputTopic) => {
|
|
2064
|
+
const at = point(inputTopic);
|
|
2065
|
+
return readingFrom(at, at ? "live" : "resyncing", {
|
|
2066
|
+
reckonUt: ut,
|
|
2067
|
+
receivedUt: ut,
|
|
2068
|
+
});
|
|
2069
|
+
},
|
|
2070
|
+
processor: (id) => this.runNestedProcessor(id, source),
|
|
2071
|
+
live: false,
|
|
1557
2072
|
};
|
|
1558
2073
|
|
|
1559
|
-
const value =
|
|
2074
|
+
const { computed: value } = this.runProcessor(def, source);
|
|
1560
2075
|
if (value === undefined) continue; // not whole yet at this instant
|
|
1561
2076
|
|
|
1562
2077
|
if (value !== null && field && !(field in (value as object))) continue; // unknown field name
|
|
@@ -1571,7 +2086,7 @@ export class TimelineStore {
|
|
|
1571
2086
|
out.push({
|
|
1572
2087
|
validAt: ut,
|
|
1573
2088
|
payload: payload as Payload,
|
|
1574
|
-
meta:
|
|
2089
|
+
meta: processorMeta(ut, epoch),
|
|
1575
2090
|
epoch,
|
|
1576
2091
|
});
|
|
1577
2092
|
}
|
|
@@ -1583,7 +2098,7 @@ export class TimelineStore {
|
|
|
1583
2098
|
* The part of a series nobody measured: what the topic's own forward model
|
|
1584
2099
|
* says the quantity did between the last observation and `toUt`.
|
|
1585
2100
|
*
|
|
1586
|
-
* `
|
|
2101
|
+
* `sampleProcessorRange` above emits a point only where a declared input
|
|
1587
2102
|
* changed, which is exactly right for history and is why a chart of a
|
|
1588
2103
|
* modelled quantity simply stopped at the last thing that arrived. During a
|
|
1589
2104
|
* blackout no input changes, so the trace ended and said nothing about
|
|
@@ -1601,7 +2116,7 @@ export class TimelineStore {
|
|
|
1601
2116
|
* A reckoned instant is a presentation-time projection, so it must never be
|
|
1602
2117
|
* reachable as an observation. Keeping it in its own return type and its own
|
|
1603
2118
|
* method is what makes that structural rather than a convention: nothing
|
|
1604
|
-
* stores one, the mission-history replay reaches for `
|
|
2119
|
+
* stores one, the mission-history replay reaches for `sampleProcessorRange` and
|
|
1605
2120
|
* never this, and a recording exported later cannot contain one. The one
|
|
1606
2121
|
* caller that wants both halves joins them at the boundary that draws them,
|
|
1607
2122
|
* and says which indices came from here.
|
|
@@ -1849,7 +2364,20 @@ export class TimelineStore {
|
|
|
1849
2364
|
const rawTopic = parsed?.rawTopic ?? topic;
|
|
1850
2365
|
const token = this.currentToken;
|
|
1851
2366
|
if (!getReckoner(rawTopic)) return unclaimed;
|
|
1852
|
-
const
|
|
2367
|
+
const depTopics = this.reckonerDepTopics(rawTopic);
|
|
2368
|
+
/*
|
|
2369
|
+
* The model reads the newest inputs, so it can only speak for a span those
|
|
2370
|
+
* inputs already described. An input published after the span opened (the
|
|
2371
|
+
* elements of a craft on the ground, new every sample) would answer for
|
|
2372
|
+
* the past with the present's state.
|
|
2373
|
+
*/
|
|
2374
|
+
const inputMoved = depTopics.some(
|
|
2375
|
+
(dep) =>
|
|
2376
|
+
(this.sample<unknown>(dep, token)?.validAt ??
|
|
2377
|
+
Number.NEGATIVE_INFINITY) > before.validAt,
|
|
2378
|
+
);
|
|
2379
|
+
if (inputMoved) return unclaimed;
|
|
2380
|
+
const inputs = depTopics
|
|
1853
2381
|
.map(
|
|
1854
2382
|
(dep) => `${dep}@${this.sample<unknown>(dep, token)?.validAt ?? "-"}`,
|
|
1855
2383
|
)
|
|
@@ -2013,10 +2541,10 @@ export class TimelineStore {
|
|
|
2013
2541
|
* lifetime, so a mid-frame `ingest` can't flip the answer mid-read-cycle
|
|
2014
2542
|
* (tearing): the change only surfaces once a new `beginFrame()` mints a
|
|
2015
2543
|
* new token. **Except across an epoch bump**:
|
|
2016
|
-
* the memo key folds in `clock.getEpoch()`, same as the
|
|
2544
|
+
* the memo key folds in `clock.getEpoch()`, same as the published-processor
|
|
2017
2545
|
* path below, so a mid-token quickload rewind is a cache miss rather
|
|
2018
|
-
* than a replayed pre-bump ghost: including to a
|
|
2019
|
-
*
|
|
2546
|
+
* than a replayed pre-bump ghost: including to a published processor's
|
|
2547
|
+
* dep reading this same topic through this same token.
|
|
2020
2548
|
*/
|
|
2021
2549
|
sample<Payload>(
|
|
2022
2550
|
topic: string,
|
|
@@ -2029,28 +2557,140 @@ export class TimelineStore {
|
|
|
2029
2557
|
* {@link sample}, with the delay lane pinned rather than taken from the
|
|
2030
2558
|
* topic's own declaration.
|
|
2031
2559
|
*
|
|
2032
|
-
* Only a
|
|
2560
|
+
* Only a published processor pins one, and only to its own lane: a processor whose
|
|
2033
2561
|
* inputs are a mix reads all of them delayed, so its output is never stamped
|
|
2034
2562
|
* more current than its most delayed input and never blends two instants a
|
|
2035
|
-
* signal delay apart into one value. See {@link
|
|
2563
|
+
* signal delay apart into one value. See {@link evaluateProcessor}.
|
|
2036
2564
|
*/
|
|
2037
2565
|
private sampleInLane<Payload>(
|
|
2038
2566
|
topic: string,
|
|
2039
2567
|
token: FrameToken,
|
|
2040
2568
|
laneOverride: DelayLane | undefined,
|
|
2569
|
+
modelled = false,
|
|
2570
|
+
): TimelinePoint<Payload> | undefined {
|
|
2571
|
+
const raw = this.sampleInLaneUnfiltered<Payload>(
|
|
2572
|
+
topic,
|
|
2573
|
+
token,
|
|
2574
|
+
laneOverride,
|
|
2575
|
+
);
|
|
2576
|
+
const own =
|
|
2577
|
+
raw && !this.isReportedByOtherVessel(topic, raw, token) ? raw : undefined;
|
|
2578
|
+
if (own && own.payload !== null) return own;
|
|
2579
|
+
return (this.catalogFallback<Payload>(topic, token, modelled) ?? own) as
|
|
2580
|
+
| TimelinePoint<Payload>
|
|
2581
|
+
| undefined;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
/**
|
|
2585
|
+
* Whether the point a reading of `topic` is built from is the active craft's
|
|
2586
|
+
* catalog entry carried forward, rather than a sample the craft sent. A
|
|
2587
|
+
* consumer that acts on an orbit it was sent, such as a burn planner, asks
|
|
2588
|
+
* this and declines while it holds.
|
|
2589
|
+
*/
|
|
2590
|
+
isCatalogFallback(
|
|
2591
|
+
topic: string,
|
|
2592
|
+
token: FrameToken = this.currentToken,
|
|
2593
|
+
): boolean {
|
|
2594
|
+
const point = this.sampleInLane<unknown>(topic, token, undefined, true);
|
|
2595
|
+
return point !== undefined && this.catalogFallbackPoints.has(point);
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
/**
|
|
2599
|
+
* Whether the newest reading `topic` holds is one the active craft sent: it
|
|
2600
|
+
* names that craft and is not a withdrawal. It looks at what has arrived
|
|
2601
|
+
* here, not at what the view shows, so it answers true while the craft's
|
|
2602
|
+
* reading is held back by a delay not yet known. Useful for telling the
|
|
2603
|
+
* operator the craft's data is on its way when it is not on screen yet. Used
|
|
2604
|
+
* by the alarm host service.
|
|
2605
|
+
*/
|
|
2606
|
+
hasArrivedFromActiveCraft(topic: string): boolean {
|
|
2607
|
+
const timeline = this.timelines.get(topic);
|
|
2608
|
+
if (!timeline) return false;
|
|
2609
|
+
if (timeline.epoch < this.clock.getEpoch() && !timeline.bridging) {
|
|
2610
|
+
return false;
|
|
2611
|
+
}
|
|
2612
|
+
const active = this.activeVesselId(this.currentToken);
|
|
2613
|
+
if (active === undefined) return false;
|
|
2614
|
+
const own = `${CRAFT_SOURCE_PREFIX}${active}`.toLowerCase();
|
|
2615
|
+
// Each craft's readings arrive after its own delay, so a nearer craft's can be newer than the active craft's own.
|
|
2616
|
+
const newestOwn = timeline.lastMatchingAt(
|
|
2617
|
+
Number.POSITIVE_INFINITY,
|
|
2618
|
+
(point) => payloadMetaSource(point.payload)?.toLowerCase() === own,
|
|
2619
|
+
);
|
|
2620
|
+
return newestOwn !== undefined && newestOwn.payload !== null;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
/** The game's statement of which craft is active, or `undefined` while it names none. */
|
|
2624
|
+
private activeVesselId(token: FrameToken): string | undefined {
|
|
2625
|
+
const active = this.sample("ksp.activeVessel", token)?.payload;
|
|
2626
|
+
const id =
|
|
2627
|
+
typeof active === "object" && active !== null && "vesselId" in active
|
|
2628
|
+
? active.vesselId
|
|
2629
|
+
: undefined;
|
|
2630
|
+
return typeof id === "string" && id !== "" ? id : undefined;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
/** Points built from the catalog, kept so the same inputs give the same point and a reading's identity holds between frames. */
|
|
2634
|
+
private readonly catalogFallbacks = new Map<
|
|
2635
|
+
string,
|
|
2636
|
+
{ catalog: unknown; bodies: unknown; point: TimelinePoint<unknown> }
|
|
2637
|
+
>();
|
|
2638
|
+
private readonly catalogFallbackPoints = new WeakSet<object>();
|
|
2639
|
+
|
|
2640
|
+
/**
|
|
2641
|
+
* The craft the game names as active, as the command centre's catalog has it,
|
|
2642
|
+
* for a craft whose own `vessel.identity` or `vessel.orbit` has not arrived.
|
|
2643
|
+
* The orbit is offered only to a reading, which models it forward and marks
|
|
2644
|
+
* it so; the identity is a held fact and is offered to any read. Nothing
|
|
2645
|
+
* crosses that the centre does not already hold under its own delay.
|
|
2646
|
+
*/
|
|
2647
|
+
private catalogFallback<Payload>(
|
|
2648
|
+
topic: string,
|
|
2649
|
+
token: FrameToken,
|
|
2650
|
+
modelled: boolean,
|
|
2651
|
+
): TimelinePoint<Payload> | undefined {
|
|
2652
|
+
if (!CATALOG_FALLBACK_TOPICS.includes(topic)) return undefined;
|
|
2653
|
+
if (topic === "vessel.orbit" && !modelled) return undefined;
|
|
2654
|
+
const id = this.activeVesselId(token);
|
|
2655
|
+
if (id === undefined) return undefined;
|
|
2656
|
+
const [catalogTopic, bodiesTopic] = CATALOG_FALLBACK_INPUTS;
|
|
2657
|
+
const catalog = this.sample<TrackingStationCatalog>(catalogTopic, token);
|
|
2658
|
+
const bodies = this.sample<SystemBodies>(bodiesTopic, token);
|
|
2659
|
+
const key = `${topic}\0${id}`;
|
|
2660
|
+
const held = this.catalogFallbacks.get(key);
|
|
2661
|
+
if (held && held.catalog === catalog && held.bodies === bodies) {
|
|
2662
|
+
return held.point as TimelinePoint<Payload>;
|
|
2663
|
+
}
|
|
2664
|
+
const point =
|
|
2665
|
+
topic === "vessel.orbit"
|
|
2666
|
+
? catalogOrbitPoint(catalog, bodies, id)
|
|
2667
|
+
: catalogIdentityPoint(catalog, id);
|
|
2668
|
+
if (!point) {
|
|
2669
|
+
this.catalogFallbacks.delete(key);
|
|
2670
|
+
return undefined;
|
|
2671
|
+
}
|
|
2672
|
+
this.catalogFallbackPoints.add(point);
|
|
2673
|
+
this.catalogFallbacks.set(key, { catalog, bodies, point });
|
|
2674
|
+
return point as TimelinePoint<Payload>;
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
private sampleInLaneUnfiltered<Payload>(
|
|
2678
|
+
topic: string,
|
|
2679
|
+
token: FrameToken,
|
|
2680
|
+
laneOverride: DelayLane | undefined,
|
|
2041
2681
|
): TimelinePoint<Payload> | undefined {
|
|
2042
2682
|
const effectiveToken =
|
|
2043
2683
|
token.generation === this.generation ? token : this.currentToken;
|
|
2044
2684
|
const lane = laneOverride ?? this.laneForTopic(topic);
|
|
2045
2685
|
const viewUt = this.viewUtFor(effectiveToken, lane);
|
|
2046
2686
|
|
|
2047
|
-
const resolved = this.
|
|
2687
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
2048
2688
|
if (resolved) {
|
|
2049
2689
|
// Outer memoize keyed by the EXACT requested topic (parent or a field
|
|
2050
2690
|
// subtopic): this is what gives a re-read within the same frame back
|
|
2051
2691
|
// the identical `TimelinePoint` object (referential stability for
|
|
2052
2692
|
// React bail-out, mirroring the raw-topic path below), on top of the
|
|
2053
|
-
// inner memoize inside `
|
|
2693
|
+
// inner memoize inside `evaluateProcessor` that keeps `compute` itself
|
|
2054
2694
|
// running only once per frame regardless of how many field subtopics
|
|
2055
2695
|
// of the same parent are read.
|
|
2056
2696
|
//
|
|
@@ -2060,17 +2700,17 @@ export class TimelineStore {
|
|
|
2060
2700
|
// value must NOT survive a mid-frame epoch bump
|
|
2061
2701
|
// (quickload rewind) for the rest of the frame. Folding epoch into the
|
|
2062
2702
|
// key makes a post-bump read a fresh cache miss, so it falls through to
|
|
2063
|
-
// `
|
|
2703
|
+
// `samplePublished` and recomputes against the new epoch instead of
|
|
2064
2704
|
// serving pre-reset output.
|
|
2065
2705
|
const epoch = this.clock.getEpoch();
|
|
2066
2706
|
return this.memoize(
|
|
2067
2707
|
effectiveToken,
|
|
2068
2708
|
`${topic}\0epoch\0${epoch}\0lane\0${lane}`,
|
|
2069
|
-
() => this.
|
|
2709
|
+
() => this.samplePublished<Payload>(resolved, effectiveToken, epoch),
|
|
2070
2710
|
);
|
|
2071
2711
|
}
|
|
2072
2712
|
|
|
2073
|
-
// Folds in the CURRENT epoch: exactly like the
|
|
2713
|
+
// Folds in the CURRENT epoch: exactly like the published-processor key above,
|
|
2074
2714
|
// guarding against the same class of stale-epoch ghost. Without this, the
|
|
2075
2715
|
// first read of a given (token, topic) pair is authoritative for the
|
|
2076
2716
|
// token's whole lifetime (frame-coherence, intentional for an
|
|
@@ -2079,7 +2719,7 @@ export class TimelineStore {
|
|
|
2079
2719
|
// sweep (`ingest`) already propagates to every `ClientTimeline`
|
|
2080
2720
|
// immediately. An unkeyed cache would keep replaying the pre-bump
|
|
2081
2721
|
// `TimelinePoint` object for the rest of the token's life, including to
|
|
2082
|
-
// any
|
|
2722
|
+
// any published processor's dep that reads this same topic through this
|
|
2083
2723
|
// same token: defeating the epoch guard below and the sweep that just
|
|
2084
2724
|
// ran. Folding epoch into the key makes a post-bump read a fresh cache
|
|
2085
2725
|
// miss, so it falls through to the guard/`timeline.at` again instead.
|
|
@@ -2089,8 +2729,8 @@ export class TimelineStore {
|
|
|
2089
2729
|
`${topic}\0epoch\0${epoch}\0lane\0${lane}`,
|
|
2090
2730
|
() => {
|
|
2091
2731
|
const timeline = this.timelineFor<Payload>(topic);
|
|
2092
|
-
if (timeline.epoch < epoch) return undefined;
|
|
2093
|
-
return
|
|
2732
|
+
if (timeline.epoch < epoch && !timeline.bridging) return undefined;
|
|
2733
|
+
return this.activeCraftsOwnAt(topic, timeline, viewUt, effectiveToken);
|
|
2094
2734
|
},
|
|
2095
2735
|
);
|
|
2096
2736
|
if (literal !== undefined) return literal;
|
|
@@ -2098,7 +2738,7 @@ export class TimelineStore {
|
|
|
2098
2738
|
// Raw record field-subtopic fallback, which is what the retired flat key
|
|
2099
2739
|
// vocabulary used to depend on and what a dotted read still uses:
|
|
2100
2740
|
// `topic` is a `"<domain>.<channel>.<field...>"` string with no
|
|
2101
|
-
// registered-
|
|
2741
|
+
// registered-published-processor match: e.g. `"time.warp.warpRate"`. No
|
|
2102
2742
|
// wire message is EVER published to that literal string; the real wire
|
|
2103
2743
|
// topic is `"time.warp"`, a whole record `{ warpRate, warpRateIndex,
|
|
2104
2744
|
// warpMode, paused }`. See `resolveRawFieldSubtopic`'s own doc for the
|
|
@@ -2125,6 +2765,49 @@ export class TimelineStore {
|
|
|
2125
2765
|
);
|
|
2126
2766
|
}
|
|
2127
2767
|
|
|
2768
|
+
/**
|
|
2769
|
+
* The point an active-vessel topic shows at `ut`: the active craft's own
|
|
2770
|
+
* newest reading. After a switch the timeline holds readings of both craft,
|
|
2771
|
+
* each reaching the screen after its own craft's delay, so a nearer craft's
|
|
2772
|
+
* newer readings can lie past the active craft's; those are passed over, and
|
|
2773
|
+
* a topic with no reading of the active craft yet shows none.
|
|
2774
|
+
*/
|
|
2775
|
+
private activeCraftsOwnAt<Payload>(
|
|
2776
|
+
topic: string,
|
|
2777
|
+
timeline: ClientTimeline<Payload>,
|
|
2778
|
+
ut: number,
|
|
2779
|
+
token: FrameToken,
|
|
2780
|
+
): TimelinePoint<Payload> | undefined {
|
|
2781
|
+
const point = timeline.at(ut);
|
|
2782
|
+
if (point === undefined || !this.followsActiveCraft(topic)) {
|
|
2783
|
+
return point;
|
|
2784
|
+
}
|
|
2785
|
+
const active = this.activeCraftSourceAt(token);
|
|
2786
|
+
if (active === undefined) return point;
|
|
2787
|
+
const subject = craftOfPoint(point);
|
|
2788
|
+
if (subject === undefined || subject === active) return point;
|
|
2789
|
+
return timeline.lastMatchingAt(
|
|
2790
|
+
ut,
|
|
2791
|
+
(candidate) => craftOfPoint(candidate) === active,
|
|
2792
|
+
);
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
/** Whether `topic` describes whichever craft is active: core's `vessel.` domain, and every Topic the mod lists as following the active craft. */
|
|
2796
|
+
private followsActiveCraft(topic: string): boolean {
|
|
2797
|
+
return (
|
|
2798
|
+
topic.startsWith(ACTIVE_VESSEL_TOPIC_PREFIX) ||
|
|
2799
|
+
this.declaredRoles?.followsActiveCraft?.has(topic) === true
|
|
2800
|
+
);
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
/** The active craft as a payload's `meta.source` names it, lower-cased: from the game's own statement, else from the newest delay report. */
|
|
2804
|
+
private activeCraftSourceAt(token: FrameToken): string | undefined {
|
|
2805
|
+
const id = this.activeVesselId(token);
|
|
2806
|
+
const source =
|
|
2807
|
+
id !== undefined ? `${CRAFT_SOURCE_PREFIX}${id}` : this.activeCraftSource;
|
|
2808
|
+
return source?.toLowerCase();
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2128
2811
|
/** The frozen view time `token` exposes for `lane`. Both are minted together, so which one a read takes is the only thing a lane decides. */
|
|
2129
2812
|
private viewUtFor(token: FrameToken, lane: DelayLane): number {
|
|
2130
2813
|
return lane === "true-now" ? token.trueNowViewUt : token.viewUt;
|
|
@@ -2134,16 +2817,16 @@ export class TimelineStore {
|
|
|
2134
2817
|
* Which lane `topic` is read in, for every shape of topic this store serves
|
|
2135
2818
|
* rather than only the declared ones.
|
|
2136
2819
|
*
|
|
2137
|
-
* A
|
|
2138
|
-
* ({@link
|
|
2820
|
+
* A published processor takes the most conservative of its inputs
|
|
2821
|
+
* ({@link processorLane}). A raw field subtopic takes its parent record's lane,
|
|
2139
2822
|
* because `time.warp.warpRate` is the same wire frame as `time.warp` and
|
|
2140
2823
|
* reading the two at different instants would be the same record disagreeing
|
|
2141
2824
|
* with itself. Anything else is its own declaration, and an undeclared
|
|
2142
2825
|
* topic is delayed.
|
|
2143
2826
|
*/
|
|
2144
2827
|
private laneForTopic(topic: string): DelayLane {
|
|
2145
|
-
const derived = this.
|
|
2146
|
-
if (derived) return
|
|
2828
|
+
const derived = this.resolvePublishedTopic(topic);
|
|
2829
|
+
if (derived) return processorLane(derived.def, this.declaredLane);
|
|
2147
2830
|
/* The whole topic is asked first because a topic under a TrueNow dynamic
|
|
2148
2831
|
namespace is its own wire topic, and the generic field split would
|
|
2149
2832
|
otherwise cut it into a parent no prefix matches. A field subtopic of a
|
|
@@ -2225,10 +2908,10 @@ export class TimelineStore {
|
|
|
2225
2908
|
* differs, or either side is a tombstone); never fabricates a value it
|
|
2226
2909
|
* can't justify.
|
|
2227
2910
|
*
|
|
2228
|
-
* A
|
|
2911
|
+
* A published processor already computed its own record at the frozen
|
|
2229
2912
|
* `viewUt`: propagation (or the channel's own basis-appropriate
|
|
2230
2913
|
* handling) is its past-horizon/interpolation story, so this falls
|
|
2231
|
-
* through to the ordinary
|
|
2914
|
+
* through to the ordinary computed read (`sample`) rather than
|
|
2232
2915
|
* interpolating the output record after the fact.
|
|
2233
2916
|
*/
|
|
2234
2917
|
sampleInterpolated<Payload>(
|
|
@@ -2240,7 +2923,7 @@ export class TimelineStore {
|
|
|
2240
2923
|
token.generation === this.generation ? token : this.currentToken;
|
|
2241
2924
|
const lane = laneOverride ?? this.laneForTopic(topic);
|
|
2242
2925
|
|
|
2243
|
-
if (this.
|
|
2926
|
+
if (this.resolvePublishedTopic(topic)) {
|
|
2244
2927
|
return this.sampleInLane<Payload>(topic, effectiveToken, laneOverride);
|
|
2245
2928
|
}
|
|
2246
2929
|
|
|
@@ -2253,7 +2936,7 @@ export class TimelineStore {
|
|
|
2253
2936
|
`\0interp\0${topic}\0epoch\0${epoch}\0lane\0${lane}`,
|
|
2254
2937
|
() => {
|
|
2255
2938
|
const timeline = this.timelineFor<Payload>(topic);
|
|
2256
|
-
if (timeline.epoch < epoch) return undefined;
|
|
2939
|
+
if (timeline.epoch < epoch && !timeline.bridging) return undefined;
|
|
2257
2940
|
const viewUt = this.viewUtFor(effectiveToken, lane);
|
|
2258
2941
|
// A topic that is not continuous as a whole stands until its next sample.
|
|
2259
2942
|
if (sampleKindOf(topic, [], this.declaredKinds) !== "continuous") {
|
|
@@ -2432,7 +3115,7 @@ export class TimelineStore {
|
|
|
2432
3115
|
*
|
|
2433
3116
|
* The three answers are distinct and the caller needs all three: a model to
|
|
2434
3117
|
* offer, a refusal to render, or nothing at all, which is what lets the
|
|
2435
|
-
* remaining ladder rungs (a
|
|
3118
|
+
* remaining ladder rungs (a published processor's label, a field read borrowing
|
|
2436
3119
|
* its record's model) still be tried.
|
|
2437
3120
|
*
|
|
2438
3121
|
* ## A declared input that did not arrive declines before the model runs
|
|
@@ -2906,6 +3589,10 @@ export class TimelineStore {
|
|
|
2906
3589
|
return { points: [], truncatedAtBreak: false };
|
|
2907
3590
|
}
|
|
2908
3591
|
if (!window) return { points: [anchor], truncatedAtBreak: false };
|
|
3592
|
+
// A point built from the catalog has no history of its own in the topic: what the timeline holds in its span is the craft left behind, or the withdrawal of it.
|
|
3593
|
+
if (this.catalogFallbackPoints.has(anchor)) {
|
|
3594
|
+
return { points: [anchor], truncatedAtBreak: false };
|
|
3595
|
+
}
|
|
2909
3596
|
const key = `reckon-window:${topic}:${anchor.validAt}:${window.spanUt}:${window.maxSamples}`;
|
|
2910
3597
|
return this.memoize(token, key, () => {
|
|
2911
3598
|
const raw = this.sampleRange<Payload>(
|
|
@@ -2913,7 +3600,7 @@ export class TimelineStore {
|
|
|
2913
3600
|
anchor.validAt - window.spanUt,
|
|
2914
3601
|
anchor.validAt,
|
|
2915
3602
|
);
|
|
2916
|
-
// A
|
|
3603
|
+
// A published processor has no stored history to range over (`sampleRange` answers `undefined` for one), so its window is the point it computed.
|
|
2917
3604
|
if (!raw || raw.length === 0) {
|
|
2918
3605
|
return { points: [anchor], truncatedAtBreak: false };
|
|
2919
3606
|
}
|
|
@@ -3047,6 +3734,30 @@ export class TimelineStore {
|
|
|
3047
3734
|
};
|
|
3048
3735
|
}
|
|
3049
3736
|
|
|
3737
|
+
/**
|
|
3738
|
+
* Whether `point` is a delayed payload whose own meta names a vessel other than the
|
|
3739
|
+
* one `ksp.activeVessel` names. That topic is read with no delay and needs no
|
|
3740
|
+
* link, so it can name a craft whose own telemetry has not arrived: until it
|
|
3741
|
+
* does, the figures still held are the previous craft's and are not shown.
|
|
3742
|
+
* Nothing is withheld while no active vessel is known.
|
|
3743
|
+
*/
|
|
3744
|
+
private isReportedByOtherVessel(
|
|
3745
|
+
topic: string,
|
|
3746
|
+
point: TimelinePoint<unknown>,
|
|
3747
|
+
token: FrameToken,
|
|
3748
|
+
): boolean {
|
|
3749
|
+
// A true-now topic is the game's own statement and never carries a craft's delayed figures.
|
|
3750
|
+
if (this.laneForTopic(topic) === "true-now") return false;
|
|
3751
|
+
// The craft a payload describes is named by the payload's own meta; the envelope's source is the node it was observed from.
|
|
3752
|
+
const source = payloadMetaSource(point.payload);
|
|
3753
|
+
if (source === undefined || !source.startsWith("vessel:")) return false;
|
|
3754
|
+
const activeId = this.activeVesselId(token);
|
|
3755
|
+
if (activeId === undefined) return false;
|
|
3756
|
+
return (
|
|
3757
|
+
source.slice("vessel:".length).toLowerCase() !== activeId.toLowerCase()
|
|
3758
|
+
);
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3050
3761
|
/**
|
|
3051
3762
|
* The topic's value and its currency as one `TopicReading<Payload>`, at a frame token's
|
|
3052
3763
|
* frozen `viewUt`: `sample()` and `sampleStatus()` folded into the union a
|
|
@@ -3074,21 +3785,43 @@ export class TimelineStore {
|
|
|
3074
3785
|
sampleReading<Payload>(
|
|
3075
3786
|
topic: string,
|
|
3076
3787
|
token: FrameToken = this.currentToken,
|
|
3788
|
+
laneOverride?: DelayLane,
|
|
3077
3789
|
): TopicReading<Payload> {
|
|
3078
3790
|
const effectiveToken =
|
|
3079
3791
|
token.generation === this.generation ? token : this.currentToken;
|
|
3080
3792
|
// Epoch-folded like every sibling read: a reading memoized before a mid-frame epoch bump (quickload rewind) must not survive it.
|
|
3081
3793
|
const epoch = this.clock.getEpoch();
|
|
3794
|
+
const lane = laneOverride ?? this.laneForTopic(topic);
|
|
3795
|
+
// Only a read in the topic's own lane is the reading a widget holds, so only that one may take part in its identity.
|
|
3796
|
+
const ownLane = lane === this.laneForTopic(topic);
|
|
3082
3797
|
return this.memoize(
|
|
3083
3798
|
effectiveToken,
|
|
3084
|
-
`\0reading\0${topic}\0epoch\0${epoch}`,
|
|
3799
|
+
`\0reading\0${topic}\0epoch\0${epoch}${ownLane ? "" : `\0lane\0${lane}`}`,
|
|
3085
3800
|
() => {
|
|
3086
|
-
const point = this.
|
|
3087
|
-
|
|
3088
|
-
const receivedUt = this.viewUtFor(
|
|
3801
|
+
const point = this.sampleInLane<Payload>(
|
|
3802
|
+
topic,
|
|
3089
3803
|
effectiveToken,
|
|
3090
|
-
|
|
3804
|
+
laneOverride,
|
|
3805
|
+
true,
|
|
3091
3806
|
);
|
|
3807
|
+
// A point built from the catalog is a held fact about where the craft was last known, whatever the topic's own wire status.
|
|
3808
|
+
const status =
|
|
3809
|
+
point && this.catalogFallbackPoints.has(point)
|
|
3810
|
+
? "held"
|
|
3811
|
+
: this.sampleStatus(topic, effectiveToken);
|
|
3812
|
+
const viewedUt = this.viewUtFor(effectiveToken, lane);
|
|
3813
|
+
/*
|
|
3814
|
+
* While the signal delay to the craft is not known the view has no
|
|
3815
|
+
* instant to stand at, and nothing could be solved. A reading built from
|
|
3816
|
+
* the catalog is about where the craft is now, which the client knows
|
|
3817
|
+
* without any delay, so it is carried to that.
|
|
3818
|
+
*/
|
|
3819
|
+
const fromCatalog =
|
|
3820
|
+
point !== undefined && this.catalogFallbackPoints.has(point);
|
|
3821
|
+
const receivedUt =
|
|
3822
|
+
fromCatalog && !Number.isFinite(viewedUt)
|
|
3823
|
+
? this.clock.utNowEstimate()
|
|
3824
|
+
: viewedUt;
|
|
3092
3825
|
// A true-now lane can sit a fraction of a second past a sub-second SCET, and a model is never asked for an instant behind its own observation.
|
|
3093
3826
|
const reckonUt = Math.max(effectiveToken.scetUt, receivedUt);
|
|
3094
3827
|
/*
|
|
@@ -3138,7 +3871,7 @@ export class TimelineStore {
|
|
|
3138
3871
|
const declineKey = declined
|
|
3139
3872
|
? `${declined.reason}\0${declined.input ?? ""}`
|
|
3140
3873
|
: undefined;
|
|
3141
|
-
const previous = this.readings.get(topic);
|
|
3874
|
+
const previous = ownLane ? this.readings.get(topic) : undefined;
|
|
3142
3875
|
const sameInputs =
|
|
3143
3876
|
previous !== undefined &&
|
|
3144
3877
|
previous.point === point &&
|
|
@@ -3200,6 +3933,7 @@ export class TimelineStore {
|
|
|
3200
3933
|
) {
|
|
3201
3934
|
return previous.reading as TopicReading<Payload>;
|
|
3202
3935
|
}
|
|
3936
|
+
if (!ownLane) return reading as TopicReading<Payload>;
|
|
3203
3937
|
this.readings.set(topic, {
|
|
3204
3938
|
point,
|
|
3205
3939
|
status,
|
|
@@ -3223,7 +3957,7 @@ export class TimelineStore {
|
|
|
3223
3957
|
* per-`(token, key)` cache) so a status read and a value read for the
|
|
3224
3958
|
* same topic in the same frame always agree about which frame they
|
|
3225
3959
|
* describe. Field subtopics (`"<topic>.<field>"`) share their parent
|
|
3226
|
-
*
|
|
3960
|
+
* published processor's status outright: a field is just one slice of the
|
|
3227
3961
|
* one memoized record, staleness applies to the whole record.
|
|
3228
3962
|
*/
|
|
3229
3963
|
sampleStatus(
|
|
@@ -3233,11 +3967,11 @@ export class TimelineStore {
|
|
|
3233
3967
|
const effectiveToken =
|
|
3234
3968
|
token.generation === this.generation ? token : this.currentToken;
|
|
3235
3969
|
|
|
3236
|
-
const resolved = this.
|
|
3970
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
3237
3971
|
if (resolved) {
|
|
3238
3972
|
const parentTopic = resolved.def.topic;
|
|
3239
3973
|
// Fold epoch into the key exactly like the derived-VALUE path in
|
|
3240
|
-
// sample(). A
|
|
3974
|
+
// sample(). A published processor's status must NOT survive a mid-frame epoch bump
|
|
3241
3975
|
// (quickload rewind) for the rest of the frame, or a status read and a
|
|
3242
3976
|
// value read for the same topic in the same frame could disagree about
|
|
3243
3977
|
// which epoch they describe.
|
|
@@ -3245,7 +3979,7 @@ export class TimelineStore {
|
|
|
3245
3979
|
return this.memoize(
|
|
3246
3980
|
effectiveToken,
|
|
3247
3981
|
`\0status\0${parentTopic}\0epoch\0${epoch}`,
|
|
3248
|
-
() => this.
|
|
3982
|
+
() => this.samplePublishedStatus(resolved.def, effectiveToken),
|
|
3249
3983
|
);
|
|
3250
3984
|
}
|
|
3251
3985
|
|
|
@@ -3281,7 +4015,12 @@ export class TimelineStore {
|
|
|
3281
4015
|
/** Whether `topic` has a point recorded under its own literal string, in this epoch, by the frame's view time. */
|
|
3282
4016
|
private hasLiteralPoint(topic: string, token: FrameToken): boolean {
|
|
3283
4017
|
const timeline = this.timelines.get(topic);
|
|
3284
|
-
if (
|
|
4018
|
+
if (
|
|
4019
|
+
!timeline ||
|
|
4020
|
+
(timeline.epoch < this.clock.getEpoch() && !timeline.bridging)
|
|
4021
|
+
) {
|
|
4022
|
+
return false;
|
|
4023
|
+
}
|
|
3285
4024
|
return (
|
|
3286
4025
|
timeline.at(this.viewUtFor(token, this.laneForTopic(topic))) !== undefined
|
|
3287
4026
|
);
|
|
@@ -3302,7 +4041,9 @@ export class TimelineStore {
|
|
|
3302
4041
|
* orthogonal: the client already confirmedly knows there
|
|
3303
4042
|
* is no value, and that doesn't stop being true just because the
|
|
3304
4043
|
* transport dropped a moment later.
|
|
3305
|
-
* 3.
|
|
4044
|
+
* 3. The game's own `"loading"` state outranks every stamp below it: the
|
|
4045
|
+
* scene is being replaced, so no stamped grade describes the link.
|
|
4046
|
+
* 3b. Server-stamped `meta.staleness` wins outright when present (a
|
|
3306
4047
|
* catch-up/late-joiner mark is authoritative, no client inference
|
|
3307
4048
|
* needed for it, and it out-ranks a live transport-down reading too:
|
|
3308
4049
|
* it's a stronger, already-settled claim about this specific point).
|
|
@@ -3323,14 +4064,45 @@ export class TimelineStore {
|
|
|
3323
4064
|
const point = this.sample(topic, token);
|
|
3324
4065
|
if (!point) return "resyncing";
|
|
3325
4066
|
if (point.payload === null) return "absent";
|
|
4067
|
+
if (this.timelineFor(topic).bridging) return "loading";
|
|
4068
|
+
/*
|
|
4069
|
+
* A reading about a craft that is no longer the active one is not a
|
|
4070
|
+
* reading of the active craft, whatever its age: it waits for the new
|
|
4071
|
+
* craft's own report, as a topic never heard from does. Judged only once
|
|
4072
|
+
* the active craft is known, and only for a payload that names a craft.
|
|
4073
|
+
*/
|
|
4074
|
+
const subject = craftSourceOf(point.payload);
|
|
4075
|
+
if (
|
|
4076
|
+
subject !== undefined &&
|
|
4077
|
+
this.activeCraftSource !== undefined &&
|
|
4078
|
+
subject !== this.activeCraftSource
|
|
4079
|
+
) {
|
|
4080
|
+
return "resyncing";
|
|
4081
|
+
}
|
|
4082
|
+
/* A figure that names no craft and was recorded before the craft switched to became active is the craft left behind's. */
|
|
4083
|
+
if (
|
|
4084
|
+
subject === undefined &&
|
|
4085
|
+
UNNAMED_ACTIVE_CRAFT_FIGURES.has(topic) &&
|
|
4086
|
+
point.validAt <= this.activeCraftSinceUt
|
|
4087
|
+
) {
|
|
4088
|
+
return "resyncing";
|
|
4089
|
+
}
|
|
4090
|
+
/*
|
|
4091
|
+
* A scene load replaces every reading, so a grade the mod stamped on the
|
|
4092
|
+
* old scene's samples says nothing about the link while it runs: the load
|
|
4093
|
+
* is why the reading is held, and it outranks the stamp.
|
|
4094
|
+
*/
|
|
4095
|
+
if (this.gameShown.state === "loading") return "loading";
|
|
3326
4096
|
if (point.meta.staleness === Staleness.LastBeforeBlackout) {
|
|
3327
4097
|
return "last-before-blackout";
|
|
3328
4098
|
}
|
|
3329
4099
|
if (point.meta.staleness === Staleness.Recorded) return "recorded";
|
|
3330
4100
|
if (point.meta.staleness === Staleness.Held) return "held";
|
|
3331
4101
|
if (!this.transportConnected) return "disconnected";
|
|
3332
|
-
if (this.gameShown.state === "loading") return "loading";
|
|
3333
4102
|
if (this.gameShown.state === "no-game") return "no-game";
|
|
4103
|
+
if (this.predatesLossOfLink(topic, point.validAt, token)) {
|
|
4104
|
+
return "last-before-blackout";
|
|
4105
|
+
}
|
|
3334
4106
|
return this.heartbeats.isOverdue(
|
|
3335
4107
|
topic,
|
|
3336
4108
|
this.clock.certaintyHorizonUt(),
|
|
@@ -3341,6 +4113,43 @@ export class TimelineStore {
|
|
|
3341
4113
|
: "live";
|
|
3342
4114
|
}
|
|
3343
4115
|
|
|
4116
|
+
/**
|
|
4117
|
+
* Whether the mod withholds `topic` while the active craft has no link home:
|
|
4118
|
+
* a delayed Topic the core declares, or any `vessel.*` Topic. The three link
|
|
4119
|
+
* reports are exempt because they are how the loss is told. A runtime-built
|
|
4120
|
+
* namespace other than `vessel.*` is keyed by a craft of its own and freezes on
|
|
4121
|
+
* that craft's link, so it is not judged here.
|
|
4122
|
+
*/
|
|
4123
|
+
private freezesWithActiveCraftLink(topic: string): boolean {
|
|
4124
|
+
const wireTopic = this.resolveRawFieldSubtopic(topic)?.rawTopic ?? topic;
|
|
4125
|
+
if (LINK_REPORT_TOPICS.has(wireTopic)) return false;
|
|
4126
|
+
if (!wireTopic.startsWith("vessel.") && !CORE_TOPIC_IDS.has(wireTopic)) {
|
|
4127
|
+
return false;
|
|
4128
|
+
}
|
|
4129
|
+
return this.laneForTopic(topic) === "delayed";
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
/**
|
|
4133
|
+
* Whether `topic` is a reading of the active vessel that was taken before the
|
|
4134
|
+
* vessel's link home was lost. The ground's view of a craft freezes at the last
|
|
4135
|
+
* thing it heard, and a craft with no route is sent nothing at all, so nothing
|
|
4136
|
+
* arrives to say the readings are old: the loss itself, on `comms.link`, which
|
|
4137
|
+
* keeps arriving through a blackout, is the only word. A reading taken after
|
|
4138
|
+
* the loss means frames are still reaching the ground and is current.
|
|
4139
|
+
*/
|
|
4140
|
+
private predatesLossOfLink(
|
|
4141
|
+
topic: string,
|
|
4142
|
+
validAt: number,
|
|
4143
|
+
token: FrameToken,
|
|
4144
|
+
): boolean {
|
|
4145
|
+
if (!this.freezesWithActiveCraftLink(topic)) return false;
|
|
4146
|
+
const link = this.sample<{ connected?: boolean | null }>(
|
|
4147
|
+
"comms.link",
|
|
4148
|
+
token,
|
|
4149
|
+
);
|
|
4150
|
+
return link?.payload?.connected === false && validAt < link.validAt;
|
|
4151
|
+
}
|
|
4152
|
+
|
|
3344
4153
|
/**
|
|
3345
4154
|
* The least UT the mod leaves between two keyframes right now: its
|
|
3346
4155
|
* real-time keyframe floor times the warp rate, both off the latest
|
|
@@ -3358,34 +4167,36 @@ export class TimelineStore {
|
|
|
3358
4167
|
return Number.isFinite(gap) && gap > 0 ? gap : 0;
|
|
3359
4168
|
}
|
|
3360
4169
|
|
|
3361
|
-
/** A
|
|
3362
|
-
private
|
|
3363
|
-
def:
|
|
4170
|
+
/** A published processor's own status: the worst of every input's. */
|
|
4171
|
+
private samplePublishedStatus(
|
|
4172
|
+
def: AnyProcessorDefinition,
|
|
3364
4173
|
token: FrameToken,
|
|
3365
4174
|
): StreamStatusValue {
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
4175
|
+
return worstStatus(
|
|
4176
|
+
[...processorInputTopics(def)].map((input) =>
|
|
4177
|
+
this.sampleStatus(input, token),
|
|
4178
|
+
),
|
|
4179
|
+
);
|
|
3369
4180
|
}
|
|
3370
4181
|
|
|
3371
4182
|
/**
|
|
3372
|
-
* `topic` is either a
|
|
3373
|
-
*
|
|
3374
|
-
*
|
|
3375
|
-
*
|
|
3376
|
-
*
|
|
4183
|
+
* `topic` is either a published processor's own topic, or (when that processor
|
|
4184
|
+
* opted into `fields: true`) a `"<topic>.<field>"` subtopic of one. Anything
|
|
4185
|
+
* else (including a raw topic that happens to contain a dot, e.g.
|
|
4186
|
+
* `"vessel.orbit"` itself) resolves to `undefined` here and falls through to the
|
|
4187
|
+
* raw-timeline path in `sample()`.
|
|
3377
4188
|
*/
|
|
3378
|
-
private
|
|
4189
|
+
private resolvePublishedTopic(
|
|
3379
4190
|
topic: string,
|
|
3380
|
-
): { def:
|
|
3381
|
-
const exact = this.
|
|
4191
|
+
): { def: PublishedProcessorDefinition; field?: string } | undefined {
|
|
4192
|
+
const exact = this.publishedProcessors.get(topic);
|
|
3382
4193
|
if (exact) return { def: exact };
|
|
3383
4194
|
|
|
3384
4195
|
const dot = topic.lastIndexOf(".");
|
|
3385
4196
|
if (dot === -1) return undefined;
|
|
3386
4197
|
const parentTopic = topic.slice(0, dot);
|
|
3387
4198
|
const field = topic.slice(dot + 1);
|
|
3388
|
-
const parent = this.
|
|
4199
|
+
const parent = this.publishedProcessors.get(parentTopic);
|
|
3389
4200
|
if (!parent?.fields) return undefined;
|
|
3390
4201
|
return { def: parent, field };
|
|
3391
4202
|
}
|
|
@@ -3414,7 +4225,7 @@ export class TimelineStore {
|
|
|
3414
4225
|
* so has no member in any generated list to match against.
|
|
3415
4226
|
*
|
|
3416
4227
|
* Never consulted for a topic `resolveDerivedTopic` already matched
|
|
3417
|
-
* (checked first at every call site): a registered
|
|
4228
|
+
* (checked first at every call site): a registered published processor's own
|
|
3418
4229
|
* `fields: true` subtopics keep using that mechanism unchanged.
|
|
3419
4230
|
*/
|
|
3420
4231
|
private resolveRawFieldSubtopic(
|
|
@@ -3433,10 +4244,10 @@ export class TimelineStore {
|
|
|
3433
4244
|
|
|
3434
4245
|
/**
|
|
3435
4246
|
* Reads `parsed.rawTopic` (a real raw topic, recurses through the ordinary
|
|
3436
|
-
* `sample()` path, including its own
|
|
4247
|
+
* `sample()` path, including its own published-processor/epoch/frame-coherence
|
|
3437
4248
|
* handling) and walks `parsed.fieldPath` into its payload.
|
|
3438
4249
|
*
|
|
3439
|
-
* Mirrors `
|
|
4250
|
+
* Mirrors `samplePublished`'s two "nothing" cases (never conflated):
|
|
3440
4251
|
* no point on the parent at all yet -> `undefined` ("not whole
|
|
3441
4252
|
* yet": the raw topic's own not-arrived-yet case, propagated as-is,
|
|
3442
4253
|
* intentionally not re-classified). A tombstoned parent (`payload: null`)
|
|
@@ -3444,13 +4255,13 @@ export class TimelineStore {
|
|
|
3444
4255
|
* record is gone, so every field of it is too). A field name not present
|
|
3445
4256
|
* on an otherwise-whole, non-null record -> `undefined` (the phantom-
|
|
3446
4257
|
* mapping case `TimelineStore.isUnresolvableField`'s doc describes for the
|
|
3447
|
-
*
|
|
4258
|
+
* published-processor analog; not extended to this raw path, every raw-field
|
|
3448
4259
|
* key that vocabulary shipped was checked against the real wire fixture
|
|
3449
4260
|
* before it was retired, so there is no known-dead mapping this needs to
|
|
3450
4261
|
* catch yet).
|
|
3451
4262
|
*
|
|
3452
4263
|
* Reuses the parent point's own `meta`/`validAt`/`epoch` verbatim, unlike
|
|
3453
|
-
* a
|
|
4264
|
+
* a published processor (which fabricates its own `processorMeta`), a raw field
|
|
3454
4265
|
* subtopic isn't a new computation, it's the same measured/received record
|
|
3455
4266
|
* narrowed to one field, so its staleness/quality/provenance genuinely are
|
|
3456
4267
|
* the whole record's.
|
|
@@ -3511,92 +4322,133 @@ export class TimelineStore {
|
|
|
3511
4322
|
}
|
|
3512
4323
|
|
|
3513
4324
|
/**
|
|
3514
|
-
*
|
|
3515
|
-
*
|
|
3516
|
-
*
|
|
3517
|
-
*
|
|
3518
|
-
* once (memoized to once per `(topic, frame)`). `get`
|
|
3519
|
-
* (passed to `derive`) is `sample` bound to this same `token`, the
|
|
3520
|
-
* structural single-view-time invariant: there is no other way for
|
|
3521
|
-
* a `derive` implementation to read a UT. `epoch` is threaded in from the
|
|
3522
|
-
* caller (rather than re-read via `this.clock.getEpoch()`) so the value
|
|
3523
|
-
* used to build the memo key and the value stamped on the resulting point
|
|
3524
|
-
* are guaranteed to agree, even though `derive` itself may cause further
|
|
3525
|
-
* ingests via side effects it has no business having.
|
|
4325
|
+
* One processor's dependencies resolved against `source` and its `compute`
|
|
4326
|
+
* run. Reading deps and processor deps carry their own instant into `oldest`:
|
|
4327
|
+
* a published processor's age is the oldest input it was handed, so a value
|
|
4328
|
+
* twenty minutes into a blackout does not look as fresh as one reporting now.
|
|
3526
4329
|
*/
|
|
3527
|
-
private
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
const
|
|
4330
|
+
private runProcessor(
|
|
4331
|
+
def: AnyProcessorDefinition,
|
|
4332
|
+
source: ProcessorDepSource,
|
|
4333
|
+
): ProcessorRun {
|
|
4334
|
+
let oldest = Number.POSITIVE_INFINITY;
|
|
4335
|
+
const values = def.deps.map((dep) => {
|
|
4336
|
+
if (isProcessorDep(dep)) {
|
|
4337
|
+
const nested = source.processor(dep.id);
|
|
4338
|
+
oldest = Math.min(oldest, nested.oldest);
|
|
4339
|
+
return nested.result;
|
|
4340
|
+
}
|
|
4341
|
+
if (isReadingDep(dep)) {
|
|
4342
|
+
const reading = source.reading(dep.reading);
|
|
4343
|
+
const point = source.point(dep.reading);
|
|
4344
|
+
if (point) oldest = Math.min(oldest, point.validAt);
|
|
4345
|
+
return reading;
|
|
4346
|
+
}
|
|
4347
|
+
if (isSubjectDep(dep)) {
|
|
4348
|
+
throw new Error(
|
|
4349
|
+
"A processor cannot declare a per-subject dep: the subject is read from " +
|
|
4350
|
+
"a reckoner's point, and a processor has none. Resolve the subject in " +
|
|
4351
|
+
"the reckoner that owns it and declare the resulting topic here.",
|
|
4352
|
+
);
|
|
4353
|
+
}
|
|
4354
|
+
const point = source.point(dep);
|
|
4355
|
+
if (point) oldest = Math.min(oldest, point.validAt);
|
|
4356
|
+
return point ? point.payload : undefined;
|
|
4357
|
+
});
|
|
4358
|
+
const run = runProcessorCompute(def, values, source.viewUt);
|
|
4359
|
+
if (source.live) recordPublishedEvaluation();
|
|
4360
|
+
return { ...run, oldest };
|
|
4361
|
+
}
|
|
4362
|
+
|
|
4363
|
+
private runNestedProcessor(
|
|
4364
|
+
id: string,
|
|
4365
|
+
source: ProcessorDepSource,
|
|
4366
|
+
): ProcessorRun {
|
|
4367
|
+
const def = getProcessor(id);
|
|
4368
|
+
if (!def) {
|
|
4369
|
+
return {
|
|
4370
|
+
computed: undefined,
|
|
4371
|
+
result: undefined,
|
|
4372
|
+
oldest: Number.POSITIVE_INFINITY,
|
|
4373
|
+
};
|
|
4374
|
+
}
|
|
4375
|
+
return this.runProcessor(def, source);
|
|
4376
|
+
}
|
|
3533
4377
|
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
const
|
|
4378
|
+
/**
|
|
4379
|
+
* One evaluation of a published processor for the frame, the same `memoize`
|
|
4380
|
+
* seam raw `sample()` reads use, so N field-subtopic reads
|
|
4381
|
+
* (`system.state.bodyCount`, ...) and a `useProcessor` read in one frame still
|
|
4382
|
+
* call `compute` exactly once. Inputs are resolved through this same token in
|
|
4383
|
+
* the processor's own lane, the structural single-view-time invariant: a
|
|
4384
|
+
* `compute` has no other way to read a UT, and one value is never assembled
|
|
4385
|
+
* from two instants a signal delay apart. The lane is true-now only when every
|
|
4386
|
+
* input is, and delayed the moment one is not, so a record is never stamped
|
|
4387
|
+
* more current than the most delayed thing it read.
|
|
4388
|
+
*
|
|
4389
|
+
* Keyed by id, with a `\0`-prefix so it can never collide with a topic's own
|
|
4390
|
+
* outer memo in `sample()`. The epoch is folded in so a mid-frame epoch bump
|
|
4391
|
+
* recomputes rather than serving pre-reset output.
|
|
4392
|
+
*/
|
|
4393
|
+
evaluateProcessor(
|
|
4394
|
+
def: AnyProcessorDefinition,
|
|
4395
|
+
token: FrameToken,
|
|
4396
|
+
): { value: unknown; result: unknown; observedAt: number } {
|
|
4397
|
+
const lane = processorLane(def, this.declaredLane);
|
|
4398
|
+
const epoch = this.clock.getEpoch();
|
|
4399
|
+
return this.memoize(
|
|
3554
4400
|
token,
|
|
3555
|
-
`\
|
|
4401
|
+
`\0processor\0${def.id}\0epoch\0${epoch}\0lane\0${lane}`,
|
|
3556
4402
|
() => {
|
|
3557
|
-
// The oldest input this record actually CONSUMED, which is how current
|
|
3558
|
-
// it really is. Stamping `token.viewUt` instead would make every derived
|
|
3559
|
-
// read report an age of zero, so a record twenty minutes into a blackout
|
|
3560
|
-
// would look exactly as fresh as one reporting now. Tracked here rather
|
|
3561
|
-
// than declared per channel because `get` is the only way in and the
|
|
3562
|
-
// store owns it: a channel cannot forget to say what it read, and a
|
|
3563
|
-
// channel that consults a subset of its declared `inputs` comes out
|
|
3564
|
-
// right without special-casing.
|
|
3565
|
-
let oldest = Number.POSITIVE_INFINITY;
|
|
3566
|
-
const note = <Noted>(
|
|
3567
|
-
point: TimelinePoint<Noted> | undefined,
|
|
3568
|
-
): TimelinePoint<Noted> | undefined => {
|
|
3569
|
-
if (point) oldest = Math.min(oldest, point.validAt);
|
|
3570
|
-
return point;
|
|
3571
|
-
};
|
|
3572
4403
|
const viewUt = this.viewUtFor(token, lane);
|
|
3573
|
-
const
|
|
3574
|
-
|
|
3575
|
-
|
|
4404
|
+
const source: ProcessorDepSource = {
|
|
4405
|
+
viewUt,
|
|
4406
|
+
point: (topic) => this.sampleInLane(topic, token, lane),
|
|
4407
|
+
reading: (topic) => this.sampleReading(topic, token, lane),
|
|
4408
|
+
processor: (id) =>
|
|
4409
|
+
this.memoize(
|
|
4410
|
+
token,
|
|
4411
|
+
`\0nested\0${id}\0epoch\0${epoch}\0lane\0${lane}`,
|
|
4412
|
+
() => this.runNestedProcessor(id, source),
|
|
4413
|
+
),
|
|
4414
|
+
live: true,
|
|
4415
|
+
};
|
|
4416
|
+
const { computed, result, oldest } = this.runProcessor(def, source);
|
|
3576
4417
|
const carry = this.carryFor(def);
|
|
3577
|
-
carry.value = shareEqual(carry.value,
|
|
4418
|
+
carry.value = shareEqual(carry.value, computed);
|
|
3578
4419
|
return {
|
|
3579
4420
|
value: carry.value,
|
|
3580
|
-
|
|
4421
|
+
result,
|
|
4422
|
+
// A processor that read nothing is as current as the frame; nothing can be older than the moment being asked about.
|
|
3581
4423
|
observedAt: Number.isFinite(oldest)
|
|
3582
4424
|
? Math.min(oldest, viewUt)
|
|
3583
4425
|
: viewUt,
|
|
3584
4426
|
};
|
|
3585
4427
|
},
|
|
3586
4428
|
);
|
|
4429
|
+
}
|
|
4430
|
+
|
|
4431
|
+
/** A published processor's value as a point on its Topic or one of its field Topics. */
|
|
4432
|
+
private samplePublished<Payload>(
|
|
4433
|
+
resolved: { def: PublishedProcessorDefinition; field?: string },
|
|
4434
|
+
token: FrameToken,
|
|
4435
|
+
epoch: number,
|
|
4436
|
+
): TimelinePoint<Payload> | undefined {
|
|
4437
|
+
const { def, field } = resolved;
|
|
4438
|
+
const { value, observedAt: at } = this.evaluateProcessor(def, token);
|
|
3587
4439
|
|
|
3588
4440
|
if (value === undefined) {
|
|
3589
|
-
// Not whole yet: an input has no point at-or-before
|
|
4441
|
+
// Not whole yet: an input has no point at-or-before the view time in the
|
|
3590
4442
|
// current epoch (cold start, or resynchronizing after an epoch reset).
|
|
3591
|
-
// There is no point to serve at all here, NOT a
|
|
3592
|
-
//
|
|
3593
|
-
//
|
|
4443
|
+
// There is no point to serve at all here, NOT a tombstone: propagates
|
|
4444
|
+
// through field subtopics too, since there's nothing to extract a field
|
|
4445
|
+
// from yet.
|
|
3594
4446
|
return undefined;
|
|
3595
4447
|
}
|
|
3596
4448
|
|
|
3597
4449
|
if (value === null) {
|
|
3598
|
-
// Confirmed absence, a required input tombstoned or the
|
|
3599
|
-
return this.carryPoint(def, field, null as Payload,
|
|
4450
|
+
// Confirmed absence, a required input tombstoned or the processor itself returning null: a real point carrying `payload: null`, per the tombstone model.
|
|
4451
|
+
return this.carryPoint(def, field, null as Payload, at, epoch);
|
|
3600
4452
|
}
|
|
3601
4453
|
|
|
3602
4454
|
if (field && !(field in (value as object))) return undefined; // unknown field name, nothing to serve
|
|
@@ -3605,24 +4457,24 @@ export class TimelineStore {
|
|
|
3605
4457
|
? (Reflect.get(value as object, field) as Payload)
|
|
3606
4458
|
: (value as Payload);
|
|
3607
4459
|
|
|
3608
|
-
return this.carryPoint(def, field, payload,
|
|
4460
|
+
return this.carryPoint(def, field, payload, at, epoch);
|
|
3609
4461
|
}
|
|
3610
4462
|
|
|
3611
|
-
private carryFor(def:
|
|
4463
|
+
private carryFor(def: AnyProcessorDefinition): {
|
|
3612
4464
|
value: unknown;
|
|
3613
4465
|
points: Map<string, TimelinePoint<unknown>>;
|
|
3614
4466
|
} {
|
|
3615
|
-
let carry = this.
|
|
4467
|
+
let carry = this.publishedCarry.get(def);
|
|
3616
4468
|
if (!carry) {
|
|
3617
4469
|
carry = { value: undefined, points: new Map() };
|
|
3618
|
-
this.
|
|
4470
|
+
this.publishedCarry.set(def, carry);
|
|
3619
4471
|
}
|
|
3620
4472
|
return carry;
|
|
3621
4473
|
}
|
|
3622
4474
|
|
|
3623
4475
|
/** The point last served for this field when it describes the same thing, else a new one. */
|
|
3624
4476
|
private carryPoint<Payload>(
|
|
3625
|
-
def:
|
|
4477
|
+
def: AnyProcessorDefinition,
|
|
3626
4478
|
field: string | undefined,
|
|
3627
4479
|
payload: Payload,
|
|
3628
4480
|
observedAt: number,
|
|
@@ -3642,7 +4494,7 @@ export class TimelineStore {
|
|
|
3642
4494
|
const point: TimelinePoint<Payload> = {
|
|
3643
4495
|
validAt: observedAt,
|
|
3644
4496
|
payload,
|
|
3645
|
-
meta:
|
|
4497
|
+
meta: processorMeta(observedAt, epoch),
|
|
3646
4498
|
epoch,
|
|
3647
4499
|
};
|
|
3648
4500
|
points.set(key, point as TimelinePoint<unknown>);
|
|
@@ -3654,7 +4506,7 @@ export class TimelineStore {
|
|
|
3654
4506
|
* `(token, key)` pair wins for that token's lifetime; subsequent calls
|
|
3655
4507
|
* return the cached result even if the underlying data changes in
|
|
3656
4508
|
* between. Private for now, exposed indirectly via `sample()`, but
|
|
3657
|
-
* deliberately generic so
|
|
4509
|
+
* deliberately generic so published processors can reuse the same
|
|
3658
4510
|
* per-frame cache instead of building their own.
|
|
3659
4511
|
*/
|
|
3660
4512
|
private memoize<Memoized>(
|
|
@@ -3730,8 +4582,28 @@ export class TimelineStore {
|
|
|
3730
4582
|
let timeline = this.timelines.get(topic);
|
|
3731
4583
|
if (!timeline) {
|
|
3732
4584
|
timeline = new ClientTimeline<Payload>(this.options.timelineOptions);
|
|
4585
|
+
timeline.scaleMaxPoints(this.topicRates.get(topic) ?? 1);
|
|
3733
4586
|
this.timelines.set(topic, timeline as ClientTimeline<unknown>);
|
|
3734
4587
|
}
|
|
3735
4588
|
return timeline as ClientTimeline<Payload>;
|
|
3736
4589
|
}
|
|
4590
|
+
|
|
4591
|
+
/** Re-bound every timeline whose Topic's rate `report` changes, so each keeps the same span of game time. */
|
|
4592
|
+
private applyDataRates(report: DataRateReport | null): void {
|
|
4593
|
+
if (!report) return;
|
|
4594
|
+
const base = tierSamplesPerSecondOf(report, "base");
|
|
4595
|
+
const next = new Map<string, number>();
|
|
4596
|
+
for (const row of report.topics) {
|
|
4597
|
+
const rate = samplesPerSecondOf(report, row.topic);
|
|
4598
|
+
if (rate > base) next.set(row.topic, rate / base);
|
|
4599
|
+
}
|
|
4600
|
+
const changed = new Set([...this.topicRates.keys(), ...next.keys()]);
|
|
4601
|
+
this.topicRates.clear();
|
|
4602
|
+
for (const [topic, scale] of next) this.topicRates.set(topic, scale);
|
|
4603
|
+
for (const topic of changed) {
|
|
4604
|
+
this.timelines
|
|
4605
|
+
.get(topic)
|
|
4606
|
+
?.scaleMaxPoints(this.topicRates.get(topic) ?? 1);
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
3737
4609
|
}
|