@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,22 +1,22 @@
|
|
|
1
|
-
import { Quality, Staleness } from "../__generated__/contract.js";
|
|
1
|
+
import { Quality, Staleness, } from "../__generated__/contract.js";
|
|
2
|
+
import { GENERATED_TOPIC_IDS } from "../__generated__/topic-map.js";
|
|
2
3
|
import { channelKindOf, readDeclaredSampleKinds, sampleKindOf, } from "../channel-tags.js";
|
|
3
4
|
import { valueTagsOf } from "../contract-tags.js";
|
|
5
|
+
import { hasSupersededFields, samplesPerSecondOf, supersededPayload, tierSamplesPerSecondOf, } from "../data-rate.js";
|
|
4
6
|
import { delayLaneOf, readDeclaredDelayRoles, } from "../delay-roles.js";
|
|
5
7
|
import { magnitudeOr } from "../magnitude.js";
|
|
6
8
|
import { PerfBudget } from "../perf/PerfBudget.js";
|
|
7
9
|
import { splitRawFieldSubtopic } from "../raw-field-split.js";
|
|
8
10
|
import { bandIsWellFormed } from "../reading.js";
|
|
9
11
|
import { reckonableInputSpelling, reckonableValuesOf, } from "../reckonability.js";
|
|
10
|
-
import {
|
|
12
|
+
import { dynamicValue, isValue } from "../unit-system/value.js";
|
|
13
|
+
import { CATALOG_FALLBACK_INPUTS, CATALOG_FALLBACK_TOPICS, catalogIdentityPoint, catalogOrbitPoint, } from "./catalog-fallback.js";
|
|
11
14
|
import { readingFrom, } from "./client-reading.js";
|
|
12
15
|
import { ClientTimeline, } from "./client-timeline.js";
|
|
13
|
-
/**
|
|
14
|
-
* The derived-channel authoring types moved to `@ksp-gonogo/sitrep-sdk` so an Uplink
|
|
15
|
-
* can write a channel without importing this package. Re-exported here unchanged.
|
|
16
|
-
*/
|
|
17
16
|
import { HeartbeatTracker, } from "./heartbeat-tracker.js";
|
|
18
|
-
import { processorRuntimeFor } from "./processorEvaluator.js";
|
|
19
|
-
import { isSubjectDep } from "./processors.js";
|
|
17
|
+
import { processorInputTopics, processorRuntimeFor, recordPublishedEvaluation, runProcessorCompute, } from "./processorEvaluator.js";
|
|
18
|
+
import { getProcessor, isProcessorDep, isReadingDep, isSubjectDep, } from "./processors.js";
|
|
19
|
+
import { reckonerGeneration } from "./reckoner-generation.js";
|
|
20
20
|
import { CORE_RECKONER_OWNER, getReckoner, getReckonerConflicts, } from "./reckoners.js";
|
|
21
21
|
import { shareEqual } from "./share-equal.js";
|
|
22
22
|
import { worstStatus } from "./stream-status.js";
|
|
@@ -42,6 +42,8 @@ function mintToken(clock, generation) {
|
|
|
42
42
|
trueNowCertainty: clock.certaintyFor(trueNowViewUt, "true-now"),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
+
/** Seconds of game time kept beyond what readers hold, so a hold-last or interpolated read at the view edge finds its neighbours. */
|
|
46
|
+
const HELD_WINDOW_FLOOR_SECONDS = 10;
|
|
45
47
|
/**
|
|
46
48
|
* Whether a model claiming `covered` has answered for a read of `fieldPath`.
|
|
47
49
|
*
|
|
@@ -70,27 +72,27 @@ function walkFieldPath(value, fieldPath) {
|
|
|
70
72
|
return cursor;
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
|
-
* Which lane a
|
|
75
|
+
* Which lane a published processor is read in: the most conservative of its
|
|
74
76
|
* declared inputs.
|
|
75
77
|
*
|
|
76
|
-
* A
|
|
77
|
-
* the
|
|
78
|
-
*
|
|
78
|
+
* A processor with no inputs is as current as the frame either way, so it takes
|
|
79
|
+
* the delayed lane with everything else rather than being special-cased into the
|
|
80
|
+
* one that can run ahead.
|
|
79
81
|
*
|
|
80
|
-
* Reads
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
82
|
+
* Reads its declared deps and not what `compute` consulted, because the lane has
|
|
83
|
+
* to be decided before `compute` runs. A processor that consults a subset of its
|
|
84
|
+
* deps is therefore read no more current than the input it declared and skipped,
|
|
85
|
+
* which is the safe direction of that inaccuracy.
|
|
84
86
|
*/
|
|
85
|
-
function
|
|
86
|
-
const inputs = def
|
|
87
|
+
function processorLane(def, declaredLane) {
|
|
88
|
+
const inputs = [...processorInputTopics(def)];
|
|
87
89
|
return inputs.length > 0 &&
|
|
88
90
|
inputs.every((topic) => declaredLane(topic) === "true-now")
|
|
89
91
|
? "true-now"
|
|
90
92
|
: "delayed";
|
|
91
93
|
}
|
|
92
|
-
/** Synthetic envelope `Meta` stamped on a
|
|
93
|
-
function
|
|
94
|
+
/** 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. */
|
|
95
|
+
function processorMeta(viewUt, epoch) {
|
|
94
96
|
return {
|
|
95
97
|
source: "derived",
|
|
96
98
|
validAt: viewUt,
|
|
@@ -105,6 +107,20 @@ function derivedMeta(viewUt, epoch) {
|
|
|
105
107
|
}
|
|
106
108
|
/** The answer for a span wider than warp-free sampling that no model claims. */
|
|
107
109
|
const UNCLAIMED = { carried: false, unclaimed: true };
|
|
110
|
+
/** The `meta.source` a payload carries about itself, or `undefined` where it carries none. */
|
|
111
|
+
function payloadMetaSource(payload) {
|
|
112
|
+
if (typeof payload !== "object" || payload === null)
|
|
113
|
+
return undefined;
|
|
114
|
+
if (!("meta" in payload))
|
|
115
|
+
return undefined;
|
|
116
|
+
const { meta } = payload;
|
|
117
|
+
if (typeof meta !== "object" || meta === null || !("source" in meta)) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return typeof meta.source === "string" ? meta.source : undefined;
|
|
121
|
+
}
|
|
122
|
+
/** The game's statement of which craft is active. */
|
|
123
|
+
const ACTIVE_VESSEL_TOPIC = "ksp.activeVessel";
|
|
108
124
|
/**
|
|
109
125
|
* How many instants inside one unobserved span the model is asked about. Enough
|
|
110
126
|
* to draw one full swing of an orbit smoothly, which is the most a single span
|
|
@@ -128,6 +144,71 @@ const MAX_RECKONED_TAIL_SAMPLES = 48;
|
|
|
128
144
|
const RECKONED_EDGE_BISECTIONS = 12;
|
|
129
145
|
/** The engine-built roster whose `delayRoles` block decides every declared topic's lane. */
|
|
130
146
|
const UPLINK_ROSTER_TOPIC = "system.uplinks";
|
|
147
|
+
/** 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. */
|
|
148
|
+
const ACTIVE_CRAFT_TOPIC = "comms.delay";
|
|
149
|
+
const DATA_RATES_TOPIC = "system.dataRates";
|
|
150
|
+
const CRAFT_SOURCE_PREFIX = "vessel:";
|
|
151
|
+
/** The domain of the topics that describe whichever craft is active. */
|
|
152
|
+
const ACTIVE_VESSEL_TOPIC_PREFIX = "vessel.";
|
|
153
|
+
/**
|
|
154
|
+
* The command centre's figures about the active craft whose payloads do not name
|
|
155
|
+
* the craft: its route, its signal, its centre, its link's grading and each
|
|
156
|
+
* centre's delay to it. Each is the active craft's only once recorded after that
|
|
157
|
+
* craft became active, so a screen never shows the craft left behind's figure as
|
|
158
|
+
* the new craft's.
|
|
159
|
+
*/
|
|
160
|
+
const UNNAMED_ACTIVE_CRAFT_FIGURES = new Set([
|
|
161
|
+
"comms.path",
|
|
162
|
+
"comms.signal",
|
|
163
|
+
"comms.commandCentre",
|
|
164
|
+
"comms.degrade",
|
|
165
|
+
"commandCentre.activeVesselDelay",
|
|
166
|
+
]);
|
|
167
|
+
const CORE_TOPIC_IDS = new Set(GENERATED_TOPIC_IDS);
|
|
168
|
+
/** The reports of the active craft's link, which the mod sends through a blackout. */
|
|
169
|
+
const LINK_REPORT_TOPICS = new Set([
|
|
170
|
+
"comms.link",
|
|
171
|
+
"comms.connectivity",
|
|
172
|
+
"comms.control",
|
|
173
|
+
]);
|
|
174
|
+
/** The vessel id a `ksp.activeVessel` payload names, or `undefined` for a withdrawn statement or one with none. */
|
|
175
|
+
function statedVesselId(payload) {
|
|
176
|
+
if (typeof payload !== "object" || payload === null)
|
|
177
|
+
return undefined;
|
|
178
|
+
if (!("vesselId" in payload))
|
|
179
|
+
return undefined;
|
|
180
|
+
const id = payload.vesselId;
|
|
181
|
+
return typeof id === "string" && id !== "" ? id : undefined;
|
|
182
|
+
}
|
|
183
|
+
/** The node a craft's own readings are delivered from, as the envelope's `meta.source` names it. */
|
|
184
|
+
const CRAFT_NODE_PREFIX = "fleet.";
|
|
185
|
+
/**
|
|
186
|
+
* The craft a reading describes, lower-cased as a payload's `meta.source`: the
|
|
187
|
+
* payload's own word, else the craft whose node delivered it. An Uplink's payload
|
|
188
|
+
* may carry no meta of its own, and a reading kept per craft is still delivered
|
|
189
|
+
* from that craft's node.
|
|
190
|
+
*/
|
|
191
|
+
function craftOfPoint(point) {
|
|
192
|
+
const own = craftSourceOf(point.payload);
|
|
193
|
+
if (own !== undefined)
|
|
194
|
+
return own.toLowerCase();
|
|
195
|
+
const node = point.meta.source;
|
|
196
|
+
return typeof node === "string" && node.startsWith(CRAFT_NODE_PREFIX)
|
|
197
|
+
? `${CRAFT_SOURCE_PREFIX}${node.slice(CRAFT_NODE_PREFIX.length)}`.toLowerCase()
|
|
198
|
+
: undefined;
|
|
199
|
+
}
|
|
200
|
+
/** The `meta.source` a payload carries, when it names a craft. */
|
|
201
|
+
function craftSourceOf(payload) {
|
|
202
|
+
if (typeof payload !== "object" || payload === null)
|
|
203
|
+
return undefined;
|
|
204
|
+
const meta = payload.meta;
|
|
205
|
+
if (typeof meta !== "object" || meta === null)
|
|
206
|
+
return undefined;
|
|
207
|
+
const source = meta.source;
|
|
208
|
+
return typeof source === "string" && source.startsWith(CRAFT_SOURCE_PREFIX)
|
|
209
|
+
? source
|
|
210
|
+
: undefined;
|
|
211
|
+
}
|
|
131
212
|
/**
|
|
132
213
|
* How long, in milliseconds, a load must run before it is shown. Useful for
|
|
133
214
|
* keeping a brief scene change from flashing every reading as held and back. A
|
|
@@ -135,6 +216,17 @@ const UPLINK_ROSTER_TOPIC = "system.uplinks";
|
|
|
135
216
|
* an operator will tolerate on screen, so it lives here and not in the contract.
|
|
136
217
|
*/
|
|
137
218
|
export const GAME_LOADING_ONSET_MS = 750;
|
|
219
|
+
function hasSignalDelay(seconds) {
|
|
220
|
+
return seconds > 0 && Number.isFinite(seconds);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* How long after a load ends a Topic may keep standing on readings from before
|
|
224
|
+
* it, waiting for the mod to send what its command centre had heard at the save.
|
|
225
|
+
* Past this the Topic blanks until its first fresh reading.
|
|
226
|
+
*/
|
|
227
|
+
const LOAD_BRIDGE_GRACE_MS = 5000;
|
|
228
|
+
/** 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. */
|
|
229
|
+
export const GAME_LOAD_NOTICE_SECONDS = 10;
|
|
138
230
|
/**
|
|
139
231
|
* How far apart to sample a reckoned tail: the cadence the observations
|
|
140
232
|
* themselves were arriving at, widened if that would overrun the resolution
|
|
@@ -311,7 +403,7 @@ function lerpFieldValue(key, before, after, t, holds) {
|
|
|
311
403
|
if (lerped === undefined || typeof lerped.value !== "number") {
|
|
312
404
|
return undefined;
|
|
313
405
|
}
|
|
314
|
-
return { value:
|
|
406
|
+
return { value: dynamicValue(before.unit, lerped.value) };
|
|
315
407
|
}
|
|
316
408
|
if (typeof before === "number" && typeof after === "number") {
|
|
317
409
|
if (ANGULAR_DEGREE_FIELD_NAMES.has(key)) {
|
|
@@ -409,7 +501,7 @@ function interpolatedRead(timeline, viewUt, holds) {
|
|
|
409
501
|
* - In a drawing loop of your own, pass `sample(topic, token)` the token from
|
|
410
502
|
* `currentFrame()`, or one you made with `beginFrame()`
|
|
411
503
|
*
|
|
412
|
-
*
|
|
504
|
+
* Published processors are read through
|
|
413
505
|
* `sample` the same way.
|
|
414
506
|
*
|
|
415
507
|
* @category Stream fixture
|
|
@@ -418,8 +510,21 @@ export class TimelineStore {
|
|
|
418
510
|
clock;
|
|
419
511
|
options;
|
|
420
512
|
timelines = new Map();
|
|
421
|
-
|
|
513
|
+
/* Every revision counted in `dataRevision` only ever grows and no timeline is ever removed, so the sum moves on every change. */
|
|
514
|
+
publishedRegistrations = 0;
|
|
515
|
+
/**
|
|
516
|
+
* Samples a game second each Topic above one arrives at, from the latest
|
|
517
|
+
* `system.dataRates`. A Topic's timeline keeps its point bound times this, so
|
|
518
|
+
* it spans the same game time at any rate.
|
|
519
|
+
*/
|
|
520
|
+
topicRates = new Map();
|
|
521
|
+
publishedProcessors = new Map();
|
|
422
522
|
frameListeners = new Set();
|
|
523
|
+
/* Seconds each raw Topic's readers draw, one entry per live hold. Only read while a history source is set. */
|
|
524
|
+
heldWindows = new Map();
|
|
525
|
+
/* The span last asked the history source for, per raw Topic and epoch, so a gap is requested once. */
|
|
526
|
+
askedFrom = new Map();
|
|
527
|
+
historySource;
|
|
423
528
|
currentToken;
|
|
424
529
|
generation = 0;
|
|
425
530
|
/**
|
|
@@ -469,18 +574,18 @@ export class TimelineStore {
|
|
|
469
574
|
* (including as `currentToken`), its cache entry is collected too. The
|
|
470
575
|
* first `sample(topic, token)` read for a given `(token, topic)` pair is
|
|
471
576
|
* authoritative for that token's whole lifetime; a mid-frame `ingest`
|
|
472
|
-
* cannot flip it. Also the seam
|
|
577
|
+
* cannot flip it. Also the seam published processors reuse instead of
|
|
473
578
|
* building their own per-frame cache.
|
|
474
579
|
*/
|
|
475
580
|
frameCache = new WeakMap();
|
|
476
581
|
/**
|
|
477
|
-
* What each
|
|
478
|
-
* its field subtopics. A frame whose `
|
|
582
|
+
* What each published processor answered last, and the point served for each of
|
|
583
|
+
* its field subtopics. A frame whose `compute` comes out structurally equal
|
|
479
584
|
* hands back these same objects, so a reader comparing by reference sees a
|
|
480
585
|
* change only when the record really moved. Keyed by definition, so a
|
|
481
586
|
* channel re-registered under the same topic starts clean.
|
|
482
587
|
*/
|
|
483
|
-
|
|
588
|
+
publishedCarry = new WeakMap();
|
|
484
589
|
/**
|
|
485
590
|
* Each raw field subtopic's point, per parent point, so a field read of a
|
|
486
591
|
* record that did not change hands back the same object on every frame.
|
|
@@ -533,6 +638,7 @@ export class TimelineStore {
|
|
|
533
638
|
* reference by default.
|
|
534
639
|
*/
|
|
535
640
|
transportConnected = true;
|
|
641
|
+
connectionListeners = new Set();
|
|
536
642
|
/**
|
|
537
643
|
* What the game is doing, as the mod last said and as the operator is shown
|
|
538
644
|
* it: a load is shown only once it has run `GAME_LOADING_ONSET_MS`, so a
|
|
@@ -541,6 +647,8 @@ export class TimelineStore {
|
|
|
541
647
|
*/
|
|
542
648
|
gameShown = { state: "ready", scene: "" };
|
|
543
649
|
gameOnset;
|
|
650
|
+
bridgeGrace;
|
|
651
|
+
delayedAtLoadStart = false;
|
|
544
652
|
gameListeners = new Set();
|
|
545
653
|
/**
|
|
546
654
|
* The delay roles the mod stated on the newest `system.uplinks` delivered.
|
|
@@ -553,6 +661,20 @@ export class TimelineStore {
|
|
|
553
661
|
* into the delayed lane until the next keyframe.
|
|
554
662
|
*/
|
|
555
663
|
declaredRoles;
|
|
664
|
+
/**
|
|
665
|
+
* The craft the game has active, as a `meta.source`, captured at ingest. The
|
|
666
|
+
* game's own statement of it (`ksp.activeVessel`) names the new craft the
|
|
667
|
+
* moment of a switch; the `meta.source` of the newest `comms.delay` is the
|
|
668
|
+
* fallback while that statement has not been heard, and for a linked craft it
|
|
669
|
+
* can name the craft left behind for a whole signal delay after the switch.
|
|
670
|
+
* Either way, after a switch every delayed reading in the timelines is still
|
|
671
|
+
* about the old craft.
|
|
672
|
+
*/
|
|
673
|
+
activeCraftSource;
|
|
674
|
+
/** Whether the game's statement of the active craft has been heard, which then outranks the delay report. */
|
|
675
|
+
activeCraftStated = false;
|
|
676
|
+
/** When the game last named a craft other than the one before it as active, or negative infinity before any change. */
|
|
677
|
+
activeCraftSinceUt = Number.NEGATIVE_INFINITY;
|
|
556
678
|
/** The sample kinds the mod stated on the newest `system.uplinks`, captured at ingest for the same reason the roles are. */
|
|
557
679
|
declaredKinds;
|
|
558
680
|
constructor(clock, options = {}) {
|
|
@@ -571,7 +693,25 @@ export class TimelineStore {
|
|
|
571
693
|
* outright over this.
|
|
572
694
|
*/
|
|
573
695
|
setTransportConnected(connected) {
|
|
696
|
+
if (this.transportConnected === connected)
|
|
697
|
+
return;
|
|
574
698
|
this.transportConnected = connected;
|
|
699
|
+
for (const listener of this.connectionListeners)
|
|
700
|
+
listener();
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Whether the stream to the mod is open, as the transport last said. True
|
|
704
|
+
* until a transport says otherwise.
|
|
705
|
+
*/
|
|
706
|
+
streamConnected() {
|
|
707
|
+
return this.transportConnected;
|
|
708
|
+
}
|
|
709
|
+
/** Called whenever {@link streamConnected} changes. Returns an unsubscribe function. */
|
|
710
|
+
subscribeStreamConnected(listener) {
|
|
711
|
+
this.connectionListeners.add(listener);
|
|
712
|
+
return () => {
|
|
713
|
+
this.connectionListeners.delete(listener);
|
|
714
|
+
};
|
|
575
715
|
}
|
|
576
716
|
/**
|
|
577
717
|
* Set what the game is doing, from the mod's `game-state` frame.
|
|
@@ -590,6 +730,17 @@ export class TimelineStore {
|
|
|
590
730
|
clearTimeout(this.gameOnset);
|
|
591
731
|
this.gameOnset = undefined;
|
|
592
732
|
}
|
|
733
|
+
if (this.bridgeGrace !== undefined) {
|
|
734
|
+
clearTimeout(this.bridgeGrace);
|
|
735
|
+
this.bridgeGrace = undefined;
|
|
736
|
+
}
|
|
737
|
+
if (state === "loading" && !this.loadRequested) {
|
|
738
|
+
this.delayedAtLoadStart = hasSignalDelay(this.clock.delaySeconds());
|
|
739
|
+
}
|
|
740
|
+
this.loadRequested = state === "loading";
|
|
741
|
+
this.gameRunning = state === "ready";
|
|
742
|
+
if (!this.loadRequested)
|
|
743
|
+
this.endBridgesAfterLoad();
|
|
593
744
|
if (state === "loading") {
|
|
594
745
|
this.gameOnset = setTimeout(() => {
|
|
595
746
|
this.gameOnset = undefined;
|
|
@@ -602,6 +753,61 @@ export class TimelineStore {
|
|
|
602
753
|
scene,
|
|
603
754
|
});
|
|
604
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Answer a `timeline-reset` the mod sent for `topic`. While a load is in
|
|
758
|
+
* progress and kept history, the Topic's readings at or before
|
|
759
|
+
* `keptThroughUt` stand, graded `"loading"`, until the load ends. A load that
|
|
760
|
+
* kept none empties the Topic here. A reset with no load in progress leaves
|
|
761
|
+
* the readings to the first sample of the new timeline.
|
|
762
|
+
*/
|
|
763
|
+
noteTimelineReset(topic, keptThroughUt) {
|
|
764
|
+
const timeline = this.timelines.get(topic);
|
|
765
|
+
if (!timeline)
|
|
766
|
+
return;
|
|
767
|
+
if (keptThroughUt !== undefined && !this.loadRequested)
|
|
768
|
+
return;
|
|
769
|
+
timeline.retainThrough(keptThroughUt);
|
|
770
|
+
this.beginFrame();
|
|
771
|
+
}
|
|
772
|
+
/*
|
|
773
|
+
* With a delay the mod sends each Topic what its command centre had heard at
|
|
774
|
+
* the save a tick after the load ends, so a Topic keeps its readings until its
|
|
775
|
+
* first reading of the new timeline replaces them, or the grace runs out. With
|
|
776
|
+
* no delay the loaded world's own first frame is the next thing sent and the
|
|
777
|
+
* Topic blanks at once until it arrives.
|
|
778
|
+
*/
|
|
779
|
+
endBridgesAfterLoad() {
|
|
780
|
+
/*
|
|
781
|
+
* The delay is read again at the end of the load only as a second
|
|
782
|
+
* opinion: the load empties the Topics the delay is learned from, so on a
|
|
783
|
+
* first load it can read zero here while the screen was delayed before.
|
|
784
|
+
*/
|
|
785
|
+
if (!this.delayedAtLoadStart &&
|
|
786
|
+
!hasSignalDelay(this.clock.delaySeconds())) {
|
|
787
|
+
this.endBridges();
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
this.bridgeGrace = setTimeout(() => {
|
|
791
|
+
this.bridgeGrace = undefined;
|
|
792
|
+
this.endBridges();
|
|
793
|
+
}, LOAD_BRIDGE_GRACE_MS);
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Empty every timeline still standing on readings from before a load that
|
|
797
|
+
* kept history: the load is over, and the mod now holds each channel's first
|
|
798
|
+
* frame back, so nothing from before it is shown.
|
|
799
|
+
*/
|
|
800
|
+
endBridges() {
|
|
801
|
+
let ended = false;
|
|
802
|
+
for (const timeline of this.timelines.values()) {
|
|
803
|
+
if (!timeline.bridging)
|
|
804
|
+
continue;
|
|
805
|
+
timeline.retainThrough(undefined);
|
|
806
|
+
ended = true;
|
|
807
|
+
}
|
|
808
|
+
if (ended)
|
|
809
|
+
this.beginFrame();
|
|
810
|
+
}
|
|
605
811
|
/** What the game is doing as the operator is shown it. */
|
|
606
812
|
gameStatus() {
|
|
607
813
|
return this.gameShown;
|
|
@@ -613,6 +819,23 @@ export class TimelineStore {
|
|
|
613
819
|
this.gameListeners.delete(listener);
|
|
614
820
|
};
|
|
615
821
|
}
|
|
822
|
+
loadRequested = false;
|
|
823
|
+
/** Whether the game last said it was running a scene: not loading one, and not at its main menu. */
|
|
824
|
+
gameRunning = false;
|
|
825
|
+
lastRunningUt;
|
|
826
|
+
resetFrom;
|
|
827
|
+
/**
|
|
828
|
+
* The UT this screen was showing, in the epoch before the current one, if
|
|
829
|
+
* the game was running a scene then. Undefined when no game was running
|
|
830
|
+
* before the current epoch began, as on a screen that connected at the main
|
|
831
|
+
* menu. Useful for saying how far a load moved the game from where the
|
|
832
|
+
* operator last saw it. Used by the banner that announces a loaded game.
|
|
833
|
+
*/
|
|
834
|
+
utBeforeReset() {
|
|
835
|
+
return this.resetFrom?.epoch === this.clock.getEpoch()
|
|
836
|
+
? this.resetFrom.ut
|
|
837
|
+
: undefined;
|
|
838
|
+
}
|
|
616
839
|
showGameStatus(status) {
|
|
617
840
|
if (status.state === this.gameShown.state &&
|
|
618
841
|
status.scene === this.gameShown.scene) {
|
|
@@ -674,13 +897,45 @@ export class TimelineStore {
|
|
|
674
897
|
// resynchronizing period that follows. This point's own arrival still
|
|
675
898
|
// counts as a fresh heartbeat for its topic once the clear has run.
|
|
676
899
|
this.heartbeats.reset();
|
|
900
|
+
if (this.lastRunningUt !== undefined) {
|
|
901
|
+
this.resetFrom = { epoch: point.epoch, ut: this.lastRunningUt };
|
|
902
|
+
this.lastRunningUt = undefined;
|
|
903
|
+
}
|
|
677
904
|
}
|
|
678
905
|
this.timelineFor(topic).append(point);
|
|
906
|
+
if (this.historySource)
|
|
907
|
+
this.keepHeldWindow(topic);
|
|
908
|
+
if (topic === DATA_RATES_TOPIC) {
|
|
909
|
+
this.applyDataRates(point.payload);
|
|
910
|
+
}
|
|
911
|
+
if (topic === ACTIVE_CRAFT_TOPIC && !this.activeCraftStated) {
|
|
912
|
+
this.activeCraftSource =
|
|
913
|
+
craftSourceOf(point.payload) ?? this.activeCraftSource;
|
|
914
|
+
}
|
|
915
|
+
if (topic === ACTIVE_VESSEL_TOPIC) {
|
|
916
|
+
const id = statedVesselId(point.payload);
|
|
917
|
+
if (id !== undefined) {
|
|
918
|
+
const source = `${CRAFT_SOURCE_PREFIX}${id}`;
|
|
919
|
+
if (this.activeCraftStated && source !== this.activeCraftSource) {
|
|
920
|
+
this.activeCraftSinceUt = point.validAt;
|
|
921
|
+
}
|
|
922
|
+
this.activeCraftSource = source;
|
|
923
|
+
this.activeCraftStated = true;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
679
926
|
if (topic === UPLINK_ROSTER_TOPIC) {
|
|
680
927
|
this.declaredRoles = readDeclaredDelayRoles(point.payload);
|
|
681
928
|
this.declaredKinds = readDeclaredSampleKinds(point.payload);
|
|
682
929
|
}
|
|
683
930
|
this.clock.observeSample(point.validAt, point.meta.deliveredAt, point.epoch, options.replayed === true);
|
|
931
|
+
if (this.gameRunning && !options.replayed) {
|
|
932
|
+
const ut = this.clock.utNowEstimate();
|
|
933
|
+
if (Number.isFinite(ut))
|
|
934
|
+
this.lastRunningUt = ut;
|
|
935
|
+
}
|
|
936
|
+
if (hasSupersededFields(topic)) {
|
|
937
|
+
this.timelineFor(topic).supersedeBefore(this.clock.certaintyHorizonUt(), (payload) => supersededPayload(topic, payload));
|
|
938
|
+
}
|
|
684
939
|
// Every live sample, keyframe or change-emission alike, confirms the link
|
|
685
940
|
// is alive as of this arrival. A recorded one does not: it describes the
|
|
686
941
|
// past, and can be delivered while the craft is still out of contact.
|
|
@@ -696,33 +951,177 @@ export class TimelineStore {
|
|
|
696
951
|
}
|
|
697
952
|
}
|
|
698
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Make a reader's window of `topic` count as needed, for as long as the
|
|
956
|
+
* returned release has not been called. With a history source set, a Topic
|
|
957
|
+
* keeps only the longest window any live hold names plus a short floor, and
|
|
958
|
+
* older points are asked for from the source when a hold needs them. Without
|
|
959
|
+
* one the store keeps every point its bound allows and a hold does nothing.
|
|
960
|
+
* Used by the series hook behind charts and sparklines.
|
|
961
|
+
*/
|
|
962
|
+
holdWindow(topic, seconds) {
|
|
963
|
+
const hold = { seconds };
|
|
964
|
+
const rawTopics = this.rawTopicsOf(topic);
|
|
965
|
+
for (const raw of rawTopics) {
|
|
966
|
+
let holds = this.heldWindows.get(raw);
|
|
967
|
+
if (!holds) {
|
|
968
|
+
holds = new Set();
|
|
969
|
+
this.heldWindows.set(raw, holds);
|
|
970
|
+
}
|
|
971
|
+
holds.add(hold);
|
|
972
|
+
}
|
|
973
|
+
if (this.historySource) {
|
|
974
|
+
for (const raw of rawTopics)
|
|
975
|
+
this.keepHeldWindow(raw);
|
|
976
|
+
}
|
|
977
|
+
return () => {
|
|
978
|
+
for (const raw of rawTopics) {
|
|
979
|
+
this.heldWindows.get(raw)?.delete(hold);
|
|
980
|
+
if (this.historySource)
|
|
981
|
+
this.keepHeldWindow(raw);
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Keep only the window readers hold, fetching older points from `source`
|
|
987
|
+
* when a reader asks for more than is held. Useful on a screen that is not the
|
|
988
|
+
* one holding the full run. Returns the function that puts the store back to
|
|
989
|
+
* keeping everything its bound allows.
|
|
990
|
+
*/
|
|
991
|
+
setHistorySource(source) {
|
|
992
|
+
this.historySource = source;
|
|
993
|
+
for (const topic of this.timelines.keys())
|
|
994
|
+
this.keepHeldWindow(topic);
|
|
995
|
+
return () => {
|
|
996
|
+
if (this.historySource === source)
|
|
997
|
+
this.historySource = undefined;
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
/** How many points all Topics hold between them. */
|
|
1001
|
+
heldPointCount() {
|
|
1002
|
+
let total = 0;
|
|
1003
|
+
for (const timeline of this.timelines.values())
|
|
1004
|
+
total += timeline.size;
|
|
1005
|
+
return total;
|
|
1006
|
+
}
|
|
1007
|
+
rawTopicsOf(topic) {
|
|
1008
|
+
const out = new Set();
|
|
1009
|
+
for (const wire of this.resolveSubscriptionTopics(topic)) {
|
|
1010
|
+
out.add(this.resolveRawFieldSubtopic(wire)?.rawTopic ?? wire);
|
|
1011
|
+
}
|
|
1012
|
+
return [...out];
|
|
1013
|
+
}
|
|
1014
|
+
keepHeldWindow(raw) {
|
|
1015
|
+
const timeline = this.timelines.get(raw);
|
|
1016
|
+
const latest = timeline?.latest();
|
|
1017
|
+
if (!timeline || !latest)
|
|
1018
|
+
return;
|
|
1019
|
+
let need = 0;
|
|
1020
|
+
for (const hold of this.heldWindows.get(raw) ?? []) {
|
|
1021
|
+
need = Math.max(need, hold.seconds);
|
|
1022
|
+
}
|
|
1023
|
+
const viewUt = this.clock.viewUt("delayed");
|
|
1024
|
+
const anchor = Number.isFinite(viewUt)
|
|
1025
|
+
? Math.min(latest.validAt, viewUt)
|
|
1026
|
+
: latest.validAt;
|
|
1027
|
+
const fromUt = anchor - need - HELD_WINDOW_FLOOR_SECONDS;
|
|
1028
|
+
/*
|
|
1029
|
+
* A topic that follows the active craft keeps each craft's newest reading,
|
|
1030
|
+
* because a read walks back to the active craft's own: the game names a new
|
|
1031
|
+
* craft just after its reading arrives, and the view can lie behind that
|
|
1032
|
+
* reading until the delay to the craft is known.
|
|
1033
|
+
*/
|
|
1034
|
+
timeline.trimBefore(fromUt, this.followsActiveCraft(raw) ? craftOfPoint : undefined);
|
|
1035
|
+
if (need > 0)
|
|
1036
|
+
this.fetchHeldWindow(raw, timeline, fromUt);
|
|
1037
|
+
}
|
|
1038
|
+
fetchHeldWindow(raw, timeline, fromUt) {
|
|
1039
|
+
const source = this.historySource;
|
|
1040
|
+
const earliest = timeline.earliest();
|
|
1041
|
+
if (!source || !earliest || earliest.validAt <= fromUt)
|
|
1042
|
+
return;
|
|
1043
|
+
const asked = this.askedFrom.get(raw);
|
|
1044
|
+
const epoch = timeline.epoch;
|
|
1045
|
+
const toUt = earliest.validAt;
|
|
1046
|
+
if (asked &&
|
|
1047
|
+
asked.epoch === epoch &&
|
|
1048
|
+
asked.fromUt <= fromUt &&
|
|
1049
|
+
asked.toUt >= toUt) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
this.askedFrom.set(raw, { epoch, fromUt, toUt });
|
|
1053
|
+
source
|
|
1054
|
+
.request(raw, fromUt, toUt)
|
|
1055
|
+
.then((points) => {
|
|
1056
|
+
if (this.historySource !== source || timeline.epoch !== epoch)
|
|
1057
|
+
return;
|
|
1058
|
+
const held = new Set(timeline.range(fromUt, toUt).map((p) => `${p.validAt}:${p.meta.seq}`));
|
|
1059
|
+
for (const point of points) {
|
|
1060
|
+
if (point.epoch !== epoch)
|
|
1061
|
+
continue;
|
|
1062
|
+
const key = `${point.validAt}:${point.meta.seq}`;
|
|
1063
|
+
if (held.has(key))
|
|
1064
|
+
continue;
|
|
1065
|
+
held.add(key);
|
|
1066
|
+
timeline.append(point);
|
|
1067
|
+
}
|
|
1068
|
+
})
|
|
1069
|
+
.catch(() => {
|
|
1070
|
+
if (this.askedFrom.get(raw)?.fromUt === fromUt) {
|
|
1071
|
+
this.askedFrom.delete(raw);
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
699
1075
|
/** The per-topic `ClientTimeline`, created on first access. */
|
|
700
1076
|
getTimeline(topic) {
|
|
701
1077
|
return this.timelineFor(topic);
|
|
702
1078
|
}
|
|
703
1079
|
/**
|
|
704
|
-
*
|
|
1080
|
+
* Publish a processor as a Topic on this store. From this point on,
|
|
705
1081
|
* `sample(def.topic, token)`, and every reactive read built on it,
|
|
706
|
-
* transparently returns the
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
* useful for hot-reload
|
|
1082
|
+
* transparently returns the processor's value for the frame instead of reading
|
|
1083
|
+
* a raw `ClientTimeline`, so a caller never needs to know whether a topic is
|
|
1084
|
+
* raw or computed. If `def.fields` is set, `"<topic>.<field>"` subtopics are
|
|
1085
|
+
* resolved too (`resolvePublishedTopic`).
|
|
1086
|
+
*
|
|
1087
|
+
* `id` and `owner` are optional for a processor that is not in the registry,
|
|
1088
|
+
* and `deps` may name a Topic no generated list knows. Publishing the same
|
|
1089
|
+
* `topic` twice replaces the previous definition, useful for hot-reload and
|
|
1090
|
+
* test setup, not a guarded no-op.
|
|
1091
|
+
*/
|
|
1092
|
+
publishProcessor(def) {
|
|
1093
|
+
this.publishedRegistrations++;
|
|
1094
|
+
this.publishedProcessors.set(def.topic, {
|
|
1095
|
+
...def,
|
|
1096
|
+
id: def.id ?? def.topic,
|
|
1097
|
+
owner: def.owner ?? CORE_RECKONER_OWNER,
|
|
1098
|
+
deps: def.deps,
|
|
1099
|
+
compute: def.compute,
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* A number that changes whenever anything a read of history rests on changes:
|
|
1104
|
+
* a sample stored, evicted or rewound away on any Topic, or a model or
|
|
1105
|
+
* published processor registered. Useful for a reader that rebuilds a window of history on
|
|
1106
|
+
* every frame to skip the rebuild while the view time and this number both
|
|
1107
|
+
* stand still, since nothing it reads can have moved. Used by the series hook
|
|
1108
|
+
* behind charts and sparklines.
|
|
714
1109
|
*/
|
|
715
|
-
|
|
716
|
-
this.
|
|
1110
|
+
dataRevision() {
|
|
1111
|
+
let revision = reckonerGeneration() + this.publishedRegistrations;
|
|
1112
|
+
for (const timeline of this.timelines.values()) {
|
|
1113
|
+
revision += timeline.revision;
|
|
1114
|
+
}
|
|
1115
|
+
return revision;
|
|
717
1116
|
}
|
|
718
1117
|
/**
|
|
719
|
-
* Whether a
|
|
720
|
-
*
|
|
1118
|
+
* Whether a processor is already published under `topic`. Lets a caller adding
|
|
1119
|
+
* processors after construction leave an existing one alone, so a topic keeps
|
|
721
1120
|
* the model it was built with rather than the model whichever import landed
|
|
722
1121
|
* last.
|
|
723
1122
|
*/
|
|
724
|
-
|
|
725
|
-
return this.
|
|
1123
|
+
hasPublishedProcessor(topic) {
|
|
1124
|
+
return this.publishedProcessors.has(topic);
|
|
726
1125
|
}
|
|
727
1126
|
/**
|
|
728
1127
|
* Mint a new frozen `FrameToken` from the clock's current `viewUt()` and
|
|
@@ -812,15 +1211,13 @@ export class TimelineStore {
|
|
|
812
1211
|
/**
|
|
813
1212
|
* The raw wire topics that must actually be subscribed (via
|
|
814
1213
|
* `TelemetryClient.subscribe`) to keep `topic` resolvable, the
|
|
815
|
-
*
|
|
1214
|
+
* published-processor input ref-counting mechanism. A published processor's own
|
|
816
1215
|
* topic (or one of its `"<topic>.<field>"` subtopics) is never itself a
|
|
817
1216
|
* subscribable wire topic; no server channel produces it, so a caller
|
|
818
1217
|
* that naively subscribed to the derived topic name would never receive
|
|
819
1218
|
* any data and the channel would silently stay "not whole yet" forever.
|
|
820
1219
|
* This resolves `topic` down to the declared `inputs` it actually needs,
|
|
821
|
-
* recursively (a
|
|
822
|
-
* per `DerivedGet`'s doc: `derive` can read another derived channel as an
|
|
823
|
-
* input), de-duplicated, and defended against a malformed cyclical
|
|
1220
|
+
* recursively (a published processor can depend on another one), de-duplicated, and defended against a malformed cyclical
|
|
824
1221
|
* declaration (an authoring bug, never expected in practice) via a
|
|
825
1222
|
* visited-set guard rather than an infinite loop.
|
|
826
1223
|
*
|
|
@@ -840,7 +1237,7 @@ export class TimelineStore {
|
|
|
840
1237
|
* A model declares its inputs and `registeredReckoning` refuses to run it
|
|
841
1238
|
* with one of them missing, which is the whole point of declaring them. But
|
|
842
1239
|
* nothing was holding those inputs up. A read subscribed the topic it was
|
|
843
|
-
* reading and a
|
|
1240
|
+
* reading and a published processor's deps, and a raw topic's reckoner deps
|
|
844
1241
|
* are neither, so a lone plot of `vessel.flight.altitudeAsl` declined with
|
|
845
1242
|
* `input-absent` for ever and drew no tail, while the same plot beside a
|
|
846
1243
|
* widget reading `vessel.orbit` drew one. Whether a model runs is not
|
|
@@ -870,9 +1267,9 @@ export class TimelineStore {
|
|
|
870
1267
|
reckonerDepTopics(topic) {
|
|
871
1268
|
const parsed = this.resolveRawFieldSubtopic(topic);
|
|
872
1269
|
const elected = getReckoner(topic) ?? (parsed ? getReckoner(parsed.rawTopic) : undefined);
|
|
1270
|
+
const out = new Set(this.vesselInputTopics(parsed?.rawTopic ?? topic));
|
|
873
1271
|
if (!elected)
|
|
874
|
-
return [];
|
|
875
|
-
const out = new Set();
|
|
1272
|
+
return [...out];
|
|
876
1273
|
for (const dep of elected.definition.deps) {
|
|
877
1274
|
const depTopic = typeof dep === "string"
|
|
878
1275
|
? dep
|
|
@@ -887,8 +1284,23 @@ export class TimelineStore {
|
|
|
887
1284
|
}
|
|
888
1285
|
return [...out];
|
|
889
1286
|
}
|
|
1287
|
+
/**
|
|
1288
|
+
* The topics a read of the active craft's figures needs besides its own: the
|
|
1289
|
+
* game's statement of which craft is active, which tells a craft's own
|
|
1290
|
+
* samples from the previous craft's, and for the orbit and identity the
|
|
1291
|
+
* catalog and bodies they fall back to until the craft's own arrive.
|
|
1292
|
+
*/
|
|
1293
|
+
vesselInputTopics(raw) {
|
|
1294
|
+
if (this.resolvePublishedTopic(raw))
|
|
1295
|
+
return [];
|
|
1296
|
+
if (this.laneForTopic(raw) === "true-now")
|
|
1297
|
+
return [];
|
|
1298
|
+
return CATALOG_FALLBACK_TOPICS.includes(raw)
|
|
1299
|
+
? [ACTIVE_VESSEL_TOPIC, ...CATALOG_FALLBACK_INPUTS]
|
|
1300
|
+
: [ACTIVE_VESSEL_TOPIC];
|
|
1301
|
+
}
|
|
890
1302
|
collectSubscriptionTopics(topic, out, visiting) {
|
|
891
|
-
const resolved = this.
|
|
1303
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
892
1304
|
if (!resolved) {
|
|
893
1305
|
// Raw record field-subtopic: the raw wire topic that must
|
|
894
1306
|
// actually be subscribed is the record itself (`"time.warp"`), never
|
|
@@ -903,21 +1315,21 @@ export class TimelineStore {
|
|
|
903
1315
|
if (visiting.has(parentTopic))
|
|
904
1316
|
return; // cyclical declaration, break, don't loop forever
|
|
905
1317
|
visiting.add(parentTopic);
|
|
906
|
-
for (const input of resolved.def
|
|
1318
|
+
for (const input of processorInputTopics(resolved.def)) {
|
|
907
1319
|
this.collectSubscriptionTopics(input, out, visiting);
|
|
908
1320
|
}
|
|
909
1321
|
}
|
|
910
1322
|
/**
|
|
911
1323
|
* True when `topic` names a `"<parent>.<field>"` subtopic whose parent
|
|
912
|
-
* resolved to a whole, non-tombstoned
|
|
1324
|
+
* resolved to a whole, non-tombstoned computed record (the processor
|
|
913
1325
|
* genuinely ran) but `field` is not a key on the record it produced, a
|
|
914
1326
|
* structurally dead mapping (e.g. a stale migration-table entry pointing
|
|
915
|
-
* at a field a `
|
|
1327
|
+
* at a field a `compute` never emits), as opposed to ordinary
|
|
916
1328
|
* "not whole yet" loading (parent has no point at all yet) or a confirmed
|
|
917
1329
|
* absence (parent tombstoned): both of which return `false` here, same as
|
|
918
1330
|
* a healthy field that just hasn't arrived.
|
|
919
1331
|
*
|
|
920
|
-
* `sample()` alone can't make this distinction: `
|
|
1332
|
+
* `sample()` alone can't make this distinction: `samplePublished`'s field
|
|
921
1333
|
* lookup collapses "unknown field name" and "not whole yet" onto the same
|
|
922
1334
|
* `undefined` return, deliberately (see its own doc comment). This is a
|
|
923
1335
|
* separate diagnostic read for a caller that needs to tell "still loading, keep waiting" apart
|
|
@@ -933,7 +1345,7 @@ export class TimelineStore {
|
|
|
933
1345
|
* failure into an empty gauge). The second branch below applies the exact
|
|
934
1346
|
* same "whole-but-missing-field = unresolvable" check to a raw parent,
|
|
935
1347
|
* walking the full fieldpath (which may be 1+ segments, unlike the
|
|
936
|
-
* single-segment
|
|
1348
|
+
* single-segment published-processor case above) via the same walk
|
|
937
1349
|
* `sampleRawFieldSubtopic`/`sampleRange` use.
|
|
938
1350
|
*/
|
|
939
1351
|
isUnresolvableField(topic, token = this.currentToken) {
|
|
@@ -942,7 +1354,7 @@ export class TimelineStore {
|
|
|
942
1354
|
return false;
|
|
943
1355
|
const parentTopic = topic.slice(0, dot);
|
|
944
1356
|
const field = topic.slice(dot + 1);
|
|
945
|
-
if (this.
|
|
1357
|
+
if (this.publishedProcessors.has(parentTopic)) {
|
|
946
1358
|
const parentPoint = this.sample(parentTopic, token);
|
|
947
1359
|
if (!parentPoint || parentPoint.payload === null)
|
|
948
1360
|
return false;
|
|
@@ -966,20 +1378,20 @@ export class TimelineStore {
|
|
|
966
1378
|
return false;
|
|
967
1379
|
}
|
|
968
1380
|
/**
|
|
969
|
-
* `true` when `topic` names a registered
|
|
1381
|
+
* `true` when `topic` names a registered published processor, its own topic
|
|
970
1382
|
* or one of its `"<topic>.<field>"` subtopics (`resolveDerivedTopic`).
|
|
971
1383
|
* `false` for a raw topic, including a raw record field-subtopic
|
|
972
1384
|
* (`resolveRawFieldSubtopic`, e.g. `"vessel.orbit.sma"`), that string
|
|
973
1385
|
* looks derived-shaped (it has dots) but resolves to a real wire record's
|
|
974
|
-
* timeline, not a
|
|
1386
|
+
* timeline, not a published processor. What `sampleRange`
|
|
975
1387
|
* consults to decide "there's a stored history to range over" (a raw
|
|
976
|
-
* topic always has one, a
|
|
1388
|
+
* topic always has one, a published processor's never does, it's a per-frame
|
|
977
1389
|
* computed value, see `sampleRange`'s own doc) versus `isUnresolvableField`
|
|
978
1390
|
* above, which asks a narrower question (a specific field name on an
|
|
979
1391
|
* otherwise-whole derived record) for a different caller.
|
|
980
1392
|
*/
|
|
981
|
-
|
|
982
|
-
return this.
|
|
1393
|
+
isProcessorTopic(topic) {
|
|
1394
|
+
return this.resolvePublishedTopic(topic) !== undefined;
|
|
983
1395
|
}
|
|
984
1396
|
/**
|
|
985
1397
|
* Windowed range read for a raw topic (or raw record field-subtopic): the
|
|
@@ -990,9 +1402,9 @@ export class TimelineStore {
|
|
|
990
1402
|
* hold-last read.
|
|
991
1403
|
*
|
|
992
1404
|
* Returns `undefined`, not an empty array, when `topic` resolves to a
|
|
993
|
-
* registered
|
|
1405
|
+
* registered published processor (`isProcessorTopic`): a computed value is
|
|
994
1406
|
* computed fresh per frame from whatever its inputs currently hold
|
|
995
|
-
* (`
|
|
1407
|
+
* (`samplePublished`), never stored as its own buffered history, so there is
|
|
996
1408
|
* structurally nothing to range over. This is the caller's "give up,
|
|
997
1409
|
* permanently, on this topic" signal: distinct from an empty array,
|
|
998
1410
|
* which means "genuinely nothing landed in the window yet" and may fill
|
|
@@ -1011,18 +1423,18 @@ export class TimelineStore {
|
|
|
1011
1423
|
* live series.
|
|
1012
1424
|
*/
|
|
1013
1425
|
sampleRange(topic, fromUt, toUt) {
|
|
1014
|
-
if (this.
|
|
1426
|
+
if (this.resolvePublishedTopic(topic))
|
|
1015
1427
|
return undefined;
|
|
1016
1428
|
const epoch = this.clock.getEpoch();
|
|
1017
1429
|
const rawField = this.resolveRawFieldSubtopic(topic);
|
|
1018
1430
|
if (!rawField) {
|
|
1019
1431
|
const timeline = this.timelineFor(topic);
|
|
1020
|
-
if (timeline.epoch < epoch)
|
|
1432
|
+
if (timeline.epoch < epoch && !timeline.bridging)
|
|
1021
1433
|
return [];
|
|
1022
1434
|
return timeline.range(fromUt, toUt);
|
|
1023
1435
|
}
|
|
1024
1436
|
const parentTimeline = this.timelineFor(rawField.rawTopic);
|
|
1025
|
-
if (parentTimeline.epoch < epoch)
|
|
1437
|
+
if (parentTimeline.epoch < epoch && !parentTimeline.bridging)
|
|
1026
1438
|
return [];
|
|
1027
1439
|
const out = [];
|
|
1028
1440
|
for (const point of parentTimeline.range(fromUt, toUt)) {
|
|
@@ -1051,44 +1463,36 @@ export class TimelineStore {
|
|
|
1051
1463
|
return out;
|
|
1052
1464
|
}
|
|
1053
1465
|
/**
|
|
1054
|
-
* Windowed series for a
|
|
1055
|
-
* (which structurally can't serve one:
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
* changed
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
*
|
|
1078
|
-
* Returns `undefined` when `topic` doesn't resolve to a registered derived
|
|
1079
|
-
* channel at all (mirrors `sampleRange`'s contract): callers are expected
|
|
1080
|
-
* to gate on `isDerivedTopic` first, same as `sampleRange`'s own callers
|
|
1081
|
-
* gate the other way.
|
|
1082
|
-
*/
|
|
1083
|
-
sampleDerivedRange(topic, fromUt, toUt) {
|
|
1084
|
-
const resolved = this.resolveDerivedTopic(topic);
|
|
1466
|
+
* Windowed series for a published processor: the counterpart to `sampleRange`
|
|
1467
|
+
* (which structurally can't serve one: nothing is ever stored for a computed
|
|
1468
|
+
* Topic). Useful for plotting one as a series, as a graph widget does.
|
|
1469
|
+
*
|
|
1470
|
+
* Runs `compute` again at every UT any of its input Topics actually changed at
|
|
1471
|
+
* within `[fromUt, toUt]` (a change-gated raw timeline only ever carries a point
|
|
1472
|
+
* when something changed, so this is exactly the set of instants the result
|
|
1473
|
+
* could have changed too), its deps resolved by hold-last lookup over each
|
|
1474
|
+
* input's own buffered range (queried from `-Infinity` through `toUt`, so an
|
|
1475
|
+
* input that last changed before `fromUt` still resolves correctly at the first
|
|
1476
|
+
* in-window instant; `ClientTimeline`'s own retention window bounds this, not an
|
|
1477
|
+
* unbounded scan). A processor dep is replayed at the same instant.
|
|
1478
|
+
*
|
|
1479
|
+
* No status is recorded for a past instant, so a `{ reading }` dep is handed in
|
|
1480
|
+
* as observed at its last sample, and as pending before its first.
|
|
1481
|
+
*
|
|
1482
|
+
* Returns `undefined` when `topic` doesn't resolve to a published processor at
|
|
1483
|
+
* all (mirrors `sampleRange`'s contract): callers are expected to gate on
|
|
1484
|
+
* `isProcessorTopic` first, same as `sampleRange`'s own callers gate the other
|
|
1485
|
+
* way.
|
|
1486
|
+
*/
|
|
1487
|
+
sampleProcessorRange(topic, fromUt, toUt) {
|
|
1488
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
1085
1489
|
if (!resolved)
|
|
1086
1490
|
return undefined;
|
|
1087
1491
|
const { def, field } = resolved;
|
|
1088
1492
|
const epoch = this.clock.getEpoch();
|
|
1089
1493
|
const inputRanges = new Map();
|
|
1090
1494
|
const changeUts = new Set();
|
|
1091
|
-
for (const inputTopic of def
|
|
1495
|
+
for (const inputTopic of processorInputTopics(def)) {
|
|
1092
1496
|
const points = this.sampleRange(inputTopic, -Infinity, toUt) ?? [];
|
|
1093
1497
|
inputRanges.set(inputTopic, points);
|
|
1094
1498
|
for (const point of points) {
|
|
@@ -1100,20 +1504,33 @@ export class TimelineStore {
|
|
|
1100
1504
|
const sortedUts = [...changeUts].sort((a, b) => a - b);
|
|
1101
1505
|
const out = [];
|
|
1102
1506
|
for (const ut of sortedUts) {
|
|
1103
|
-
const
|
|
1507
|
+
const point = (inputTopic) => {
|
|
1104
1508
|
const points = inputRanges.get(inputTopic);
|
|
1105
1509
|
if (!points || points.length === 0)
|
|
1106
1510
|
return undefined;
|
|
1107
1511
|
let last;
|
|
1108
|
-
for (const
|
|
1109
|
-
if (
|
|
1110
|
-
last =
|
|
1512
|
+
for (const candidate of points) {
|
|
1513
|
+
if (candidate.validAt <= ut)
|
|
1514
|
+
last = candidate;
|
|
1111
1515
|
else
|
|
1112
1516
|
break;
|
|
1113
1517
|
}
|
|
1114
1518
|
return last;
|
|
1115
1519
|
};
|
|
1116
|
-
const
|
|
1520
|
+
const source = {
|
|
1521
|
+
viewUt: ut,
|
|
1522
|
+
point,
|
|
1523
|
+
reading: (inputTopic) => {
|
|
1524
|
+
const at = point(inputTopic);
|
|
1525
|
+
return readingFrom(at, at ? "live" : "resyncing", {
|
|
1526
|
+
reckonUt: ut,
|
|
1527
|
+
receivedUt: ut,
|
|
1528
|
+
});
|
|
1529
|
+
},
|
|
1530
|
+
processor: (id) => this.runNestedProcessor(id, source),
|
|
1531
|
+
live: false,
|
|
1532
|
+
};
|
|
1533
|
+
const { computed: value } = this.runProcessor(def, source);
|
|
1117
1534
|
if (value === undefined)
|
|
1118
1535
|
continue; // not whole yet at this instant
|
|
1119
1536
|
if (value !== null && field && !(field in value))
|
|
@@ -1129,7 +1546,7 @@ export class TimelineStore {
|
|
|
1129
1546
|
out.push({
|
|
1130
1547
|
validAt: ut,
|
|
1131
1548
|
payload: payload,
|
|
1132
|
-
meta:
|
|
1549
|
+
meta: processorMeta(ut, epoch),
|
|
1133
1550
|
epoch,
|
|
1134
1551
|
});
|
|
1135
1552
|
}
|
|
@@ -1139,7 +1556,7 @@ export class TimelineStore {
|
|
|
1139
1556
|
* The part of a series nobody measured: what the topic's own forward model
|
|
1140
1557
|
* says the quantity did between the last observation and `toUt`.
|
|
1141
1558
|
*
|
|
1142
|
-
* `
|
|
1559
|
+
* `sampleProcessorRange` above emits a point only where a declared input
|
|
1143
1560
|
* changed, which is exactly right for history and is why a chart of a
|
|
1144
1561
|
* modelled quantity simply stopped at the last thing that arrived. During a
|
|
1145
1562
|
* blackout no input changes, so the trace ended and said nothing about
|
|
@@ -1157,7 +1574,7 @@ export class TimelineStore {
|
|
|
1157
1574
|
* A reckoned instant is a presentation-time projection, so it must never be
|
|
1158
1575
|
* reachable as an observation. Keeping it in its own return type and its own
|
|
1159
1576
|
* method is what makes that structural rather than a convention: nothing
|
|
1160
|
-
* stores one, the mission-history replay reaches for `
|
|
1577
|
+
* stores one, the mission-history replay reaches for `sampleProcessorRange` and
|
|
1161
1578
|
* never this, and a recording exported later cannot contain one. The one
|
|
1162
1579
|
* caller that wants both halves joins them at the boundary that draws them,
|
|
1163
1580
|
* and says which indices came from here.
|
|
@@ -1375,7 +1792,18 @@ export class TimelineStore {
|
|
|
1375
1792
|
const token = this.currentToken;
|
|
1376
1793
|
if (!getReckoner(rawTopic))
|
|
1377
1794
|
return unclaimed;
|
|
1378
|
-
const
|
|
1795
|
+
const depTopics = this.reckonerDepTopics(rawTopic);
|
|
1796
|
+
/*
|
|
1797
|
+
* The model reads the newest inputs, so it can only speak for a span those
|
|
1798
|
+
* inputs already described. An input published after the span opened (the
|
|
1799
|
+
* elements of a craft on the ground, new every sample) would answer for
|
|
1800
|
+
* the past with the present's state.
|
|
1801
|
+
*/
|
|
1802
|
+
const inputMoved = depTopics.some((dep) => (this.sample(dep, token)?.validAt ??
|
|
1803
|
+
Number.NEGATIVE_INFINITY) > before.validAt);
|
|
1804
|
+
if (inputMoved)
|
|
1805
|
+
return unclaimed;
|
|
1806
|
+
const inputs = depTopics
|
|
1379
1807
|
.map((dep) => `${dep}@${this.sample(dep, token)?.validAt ?? "-"}`)
|
|
1380
1808
|
.join(",");
|
|
1381
1809
|
const key = `${before.validAt}\0${span}\0${unclaimed !== undefined}\0${inputs}\0${this.clock.getEpoch()}`;
|
|
@@ -1523,10 +1951,10 @@ export class TimelineStore {
|
|
|
1523
1951
|
* lifetime, so a mid-frame `ingest` can't flip the answer mid-read-cycle
|
|
1524
1952
|
* (tearing): the change only surfaces once a new `beginFrame()` mints a
|
|
1525
1953
|
* new token. **Except across an epoch bump**:
|
|
1526
|
-
* the memo key folds in `clock.getEpoch()`, same as the
|
|
1954
|
+
* the memo key folds in `clock.getEpoch()`, same as the published-processor
|
|
1527
1955
|
* path below, so a mid-token quickload rewind is a cache miss rather
|
|
1528
|
-
* than a replayed pre-bump ghost: including to a
|
|
1529
|
-
*
|
|
1956
|
+
* than a replayed pre-bump ghost: including to a published processor's
|
|
1957
|
+
* dep reading this same topic through this same token.
|
|
1530
1958
|
*/
|
|
1531
1959
|
sample(topic, token = this.currentToken) {
|
|
1532
1960
|
return this.sampleInLane(topic, token, undefined);
|
|
@@ -1535,22 +1963,107 @@ export class TimelineStore {
|
|
|
1535
1963
|
* {@link sample}, with the delay lane pinned rather than taken from the
|
|
1536
1964
|
* topic's own declaration.
|
|
1537
1965
|
*
|
|
1538
|
-
* Only a
|
|
1966
|
+
* Only a published processor pins one, and only to its own lane: a processor whose
|
|
1539
1967
|
* inputs are a mix reads all of them delayed, so its output is never stamped
|
|
1540
1968
|
* more current than its most delayed input and never blends two instants a
|
|
1541
|
-
* signal delay apart into one value. See {@link
|
|
1969
|
+
* signal delay apart into one value. See {@link evaluateProcessor}.
|
|
1970
|
+
*/
|
|
1971
|
+
sampleInLane(topic, token, laneOverride, modelled = false) {
|
|
1972
|
+
const raw = this.sampleInLaneUnfiltered(topic, token, laneOverride);
|
|
1973
|
+
const own = raw && !this.isReportedByOtherVessel(topic, raw, token) ? raw : undefined;
|
|
1974
|
+
if (own && own.payload !== null)
|
|
1975
|
+
return own;
|
|
1976
|
+
return (this.catalogFallback(topic, token, modelled) ?? own);
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Whether the point a reading of `topic` is built from is the active craft's
|
|
1980
|
+
* catalog entry carried forward, rather than a sample the craft sent. A
|
|
1981
|
+
* consumer that acts on an orbit it was sent, such as a burn planner, asks
|
|
1982
|
+
* this and declines while it holds.
|
|
1542
1983
|
*/
|
|
1543
|
-
|
|
1984
|
+
isCatalogFallback(topic, token = this.currentToken) {
|
|
1985
|
+
const point = this.sampleInLane(topic, token, undefined, true);
|
|
1986
|
+
return point !== undefined && this.catalogFallbackPoints.has(point);
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Whether the newest reading `topic` holds is one the active craft sent: it
|
|
1990
|
+
* names that craft and is not a withdrawal. It looks at what has arrived
|
|
1991
|
+
* here, not at what the view shows, so it answers true while the craft's
|
|
1992
|
+
* reading is held back by a delay not yet known. Useful for telling the
|
|
1993
|
+
* operator the craft's data is on its way when it is not on screen yet. Used
|
|
1994
|
+
* by the alarm host service.
|
|
1995
|
+
*/
|
|
1996
|
+
hasArrivedFromActiveCraft(topic) {
|
|
1997
|
+
const timeline = this.timelines.get(topic);
|
|
1998
|
+
if (!timeline)
|
|
1999
|
+
return false;
|
|
2000
|
+
if (timeline.epoch < this.clock.getEpoch() && !timeline.bridging) {
|
|
2001
|
+
return false;
|
|
2002
|
+
}
|
|
2003
|
+
const active = this.activeVesselId(this.currentToken);
|
|
2004
|
+
if (active === undefined)
|
|
2005
|
+
return false;
|
|
2006
|
+
const own = `${CRAFT_SOURCE_PREFIX}${active}`.toLowerCase();
|
|
2007
|
+
// Each craft's readings arrive after its own delay, so a nearer craft's can be newer than the active craft's own.
|
|
2008
|
+
const newestOwn = timeline.lastMatchingAt(Number.POSITIVE_INFINITY, (point) => payloadMetaSource(point.payload)?.toLowerCase() === own);
|
|
2009
|
+
return newestOwn !== undefined && newestOwn.payload !== null;
|
|
2010
|
+
}
|
|
2011
|
+
/** The game's statement of which craft is active, or `undefined` while it names none. */
|
|
2012
|
+
activeVesselId(token) {
|
|
2013
|
+
const active = this.sample("ksp.activeVessel", token)?.payload;
|
|
2014
|
+
const id = typeof active === "object" && active !== null && "vesselId" in active
|
|
2015
|
+
? active.vesselId
|
|
2016
|
+
: undefined;
|
|
2017
|
+
return typeof id === "string" && id !== "" ? id : undefined;
|
|
2018
|
+
}
|
|
2019
|
+
/** Points built from the catalog, kept so the same inputs give the same point and a reading's identity holds between frames. */
|
|
2020
|
+
catalogFallbacks = new Map();
|
|
2021
|
+
catalogFallbackPoints = new WeakSet();
|
|
2022
|
+
/**
|
|
2023
|
+
* The craft the game names as active, as the command centre's catalog has it,
|
|
2024
|
+
* for a craft whose own `vessel.identity` or `vessel.orbit` has not arrived.
|
|
2025
|
+
* The orbit is offered only to a reading, which models it forward and marks
|
|
2026
|
+
* it so; the identity is a held fact and is offered to any read. Nothing
|
|
2027
|
+
* crosses that the centre does not already hold under its own delay.
|
|
2028
|
+
*/
|
|
2029
|
+
catalogFallback(topic, token, modelled) {
|
|
2030
|
+
if (!CATALOG_FALLBACK_TOPICS.includes(topic))
|
|
2031
|
+
return undefined;
|
|
2032
|
+
if (topic === "vessel.orbit" && !modelled)
|
|
2033
|
+
return undefined;
|
|
2034
|
+
const id = this.activeVesselId(token);
|
|
2035
|
+
if (id === undefined)
|
|
2036
|
+
return undefined;
|
|
2037
|
+
const [catalogTopic, bodiesTopic] = CATALOG_FALLBACK_INPUTS;
|
|
2038
|
+
const catalog = this.sample(catalogTopic, token);
|
|
2039
|
+
const bodies = this.sample(bodiesTopic, token);
|
|
2040
|
+
const key = `${topic}\0${id}`;
|
|
2041
|
+
const held = this.catalogFallbacks.get(key);
|
|
2042
|
+
if (held && held.catalog === catalog && held.bodies === bodies) {
|
|
2043
|
+
return held.point;
|
|
2044
|
+
}
|
|
2045
|
+
const point = topic === "vessel.orbit"
|
|
2046
|
+
? catalogOrbitPoint(catalog, bodies, id)
|
|
2047
|
+
: catalogIdentityPoint(catalog, id);
|
|
2048
|
+
if (!point) {
|
|
2049
|
+
this.catalogFallbacks.delete(key);
|
|
2050
|
+
return undefined;
|
|
2051
|
+
}
|
|
2052
|
+
this.catalogFallbackPoints.add(point);
|
|
2053
|
+
this.catalogFallbacks.set(key, { catalog, bodies, point });
|
|
2054
|
+
return point;
|
|
2055
|
+
}
|
|
2056
|
+
sampleInLaneUnfiltered(topic, token, laneOverride) {
|
|
1544
2057
|
const effectiveToken = token.generation === this.generation ? token : this.currentToken;
|
|
1545
2058
|
const lane = laneOverride ?? this.laneForTopic(topic);
|
|
1546
2059
|
const viewUt = this.viewUtFor(effectiveToken, lane);
|
|
1547
|
-
const resolved = this.
|
|
2060
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
1548
2061
|
if (resolved) {
|
|
1549
2062
|
// Outer memoize keyed by the EXACT requested topic (parent or a field
|
|
1550
2063
|
// subtopic): this is what gives a re-read within the same frame back
|
|
1551
2064
|
// the identical `TimelinePoint` object (referential stability for
|
|
1552
2065
|
// React bail-out, mirroring the raw-topic path below), on top of the
|
|
1553
|
-
// inner memoize inside `
|
|
2066
|
+
// inner memoize inside `evaluateProcessor` that keeps `compute` itself
|
|
1554
2067
|
// running only once per frame regardless of how many field subtopics
|
|
1555
2068
|
// of the same parent are read.
|
|
1556
2069
|
//
|
|
@@ -1560,12 +2073,12 @@ export class TimelineStore {
|
|
|
1560
2073
|
// value must NOT survive a mid-frame epoch bump
|
|
1561
2074
|
// (quickload rewind) for the rest of the frame. Folding epoch into the
|
|
1562
2075
|
// key makes a post-bump read a fresh cache miss, so it falls through to
|
|
1563
|
-
// `
|
|
2076
|
+
// `samplePublished` and recomputes against the new epoch instead of
|
|
1564
2077
|
// serving pre-reset output.
|
|
1565
2078
|
const epoch = this.clock.getEpoch();
|
|
1566
|
-
return this.memoize(effectiveToken, `${topic}\0epoch\0${epoch}\0lane\0${lane}`, () => this.
|
|
2079
|
+
return this.memoize(effectiveToken, `${topic}\0epoch\0${epoch}\0lane\0${lane}`, () => this.samplePublished(resolved, effectiveToken, epoch));
|
|
1567
2080
|
}
|
|
1568
|
-
// Folds in the CURRENT epoch: exactly like the
|
|
2081
|
+
// Folds in the CURRENT epoch: exactly like the published-processor key above,
|
|
1569
2082
|
// guarding against the same class of stale-epoch ghost. Without this, the
|
|
1570
2083
|
// first read of a given (token, topic) pair is authoritative for the
|
|
1571
2084
|
// token's whole lifetime (frame-coherence, intentional for an
|
|
@@ -1574,23 +2087,23 @@ export class TimelineStore {
|
|
|
1574
2087
|
// sweep (`ingest`) already propagates to every `ClientTimeline`
|
|
1575
2088
|
// immediately. An unkeyed cache would keep replaying the pre-bump
|
|
1576
2089
|
// `TimelinePoint` object for the rest of the token's life, including to
|
|
1577
|
-
// any
|
|
2090
|
+
// any published processor's dep that reads this same topic through this
|
|
1578
2091
|
// same token: defeating the epoch guard below and the sweep that just
|
|
1579
2092
|
// ran. Folding epoch into the key makes a post-bump read a fresh cache
|
|
1580
2093
|
// miss, so it falls through to the guard/`timeline.at` again instead.
|
|
1581
2094
|
const epoch = this.clock.getEpoch();
|
|
1582
2095
|
const literal = this.memoize(effectiveToken, `${topic}\0epoch\0${epoch}\0lane\0${lane}`, () => {
|
|
1583
2096
|
const timeline = this.timelineFor(topic);
|
|
1584
|
-
if (timeline.epoch < epoch)
|
|
2097
|
+
if (timeline.epoch < epoch && !timeline.bridging)
|
|
1585
2098
|
return undefined;
|
|
1586
|
-
return
|
|
2099
|
+
return this.activeCraftsOwnAt(topic, timeline, viewUt, effectiveToken);
|
|
1587
2100
|
});
|
|
1588
2101
|
if (literal !== undefined)
|
|
1589
2102
|
return literal;
|
|
1590
2103
|
// Raw record field-subtopic fallback, which is what the retired flat key
|
|
1591
2104
|
// vocabulary used to depend on and what a dotted read still uses:
|
|
1592
2105
|
// `topic` is a `"<domain>.<channel>.<field...>"` string with no
|
|
1593
|
-
// registered-
|
|
2106
|
+
// registered-published-processor match: e.g. `"time.warp.warpRate"`. No
|
|
1594
2107
|
// wire message is EVER published to that literal string; the real wire
|
|
1595
2108
|
// topic is `"time.warp"`, a whole record `{ warpRate, warpRateIndex,
|
|
1596
2109
|
// warpMode, paused }`. See `resolveRawFieldSubtopic`'s own doc for the
|
|
@@ -1608,6 +2121,37 @@ export class TimelineStore {
|
|
|
1608
2121
|
return literal;
|
|
1609
2122
|
return this.memoize(effectiveToken, `\0rawfield\0${topic}\0epoch\0${epoch}\0lane\0${lane}`, () => this.sampleRawFieldSubtopic(rawField, effectiveToken, laneOverride));
|
|
1610
2123
|
}
|
|
2124
|
+
/**
|
|
2125
|
+
* The point an active-vessel topic shows at `ut`: the active craft's own
|
|
2126
|
+
* newest reading. After a switch the timeline holds readings of both craft,
|
|
2127
|
+
* each reaching the screen after its own craft's delay, so a nearer craft's
|
|
2128
|
+
* newer readings can lie past the active craft's; those are passed over, and
|
|
2129
|
+
* a topic with no reading of the active craft yet shows none.
|
|
2130
|
+
*/
|
|
2131
|
+
activeCraftsOwnAt(topic, timeline, ut, token) {
|
|
2132
|
+
const point = timeline.at(ut);
|
|
2133
|
+
if (point === undefined || !this.followsActiveCraft(topic)) {
|
|
2134
|
+
return point;
|
|
2135
|
+
}
|
|
2136
|
+
const active = this.activeCraftSourceAt(token);
|
|
2137
|
+
if (active === undefined)
|
|
2138
|
+
return point;
|
|
2139
|
+
const subject = craftOfPoint(point);
|
|
2140
|
+
if (subject === undefined || subject === active)
|
|
2141
|
+
return point;
|
|
2142
|
+
return timeline.lastMatchingAt(ut, (candidate) => craftOfPoint(candidate) === active);
|
|
2143
|
+
}
|
|
2144
|
+
/** Whether `topic` describes whichever craft is active: core's `vessel.` domain, and every Topic the mod lists as following the active craft. */
|
|
2145
|
+
followsActiveCraft(topic) {
|
|
2146
|
+
return (topic.startsWith(ACTIVE_VESSEL_TOPIC_PREFIX) ||
|
|
2147
|
+
this.declaredRoles?.followsActiveCraft?.has(topic) === true);
|
|
2148
|
+
}
|
|
2149
|
+
/** 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. */
|
|
2150
|
+
activeCraftSourceAt(token) {
|
|
2151
|
+
const id = this.activeVesselId(token);
|
|
2152
|
+
const source = id !== undefined ? `${CRAFT_SOURCE_PREFIX}${id}` : this.activeCraftSource;
|
|
2153
|
+
return source?.toLowerCase();
|
|
2154
|
+
}
|
|
1611
2155
|
/** 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. */
|
|
1612
2156
|
viewUtFor(token, lane) {
|
|
1613
2157
|
return lane === "true-now" ? token.trueNowViewUt : token.viewUt;
|
|
@@ -1616,17 +2160,17 @@ export class TimelineStore {
|
|
|
1616
2160
|
* Which lane `topic` is read in, for every shape of topic this store serves
|
|
1617
2161
|
* rather than only the declared ones.
|
|
1618
2162
|
*
|
|
1619
|
-
* A
|
|
1620
|
-
* ({@link
|
|
2163
|
+
* A published processor takes the most conservative of its inputs
|
|
2164
|
+
* ({@link processorLane}). A raw field subtopic takes its parent record's lane,
|
|
1621
2165
|
* because `time.warp.warpRate` is the same wire frame as `time.warp` and
|
|
1622
2166
|
* reading the two at different instants would be the same record disagreeing
|
|
1623
2167
|
* with itself. Anything else is its own declaration, and an undeclared
|
|
1624
2168
|
* topic is delayed.
|
|
1625
2169
|
*/
|
|
1626
2170
|
laneForTopic(topic) {
|
|
1627
|
-
const derived = this.
|
|
2171
|
+
const derived = this.resolvePublishedTopic(topic);
|
|
1628
2172
|
if (derived)
|
|
1629
|
-
return
|
|
2173
|
+
return processorLane(derived.def, this.declaredLane);
|
|
1630
2174
|
/* The whole topic is asked first because a topic under a TrueNow dynamic
|
|
1631
2175
|
namespace is its own wire topic, and the generic field split would
|
|
1632
2176
|
otherwise cut it into a parent no prefix matches. A field subtopic of a
|
|
@@ -1692,16 +2236,16 @@ export class TimelineStore {
|
|
|
1692
2236
|
* differs, or either side is a tombstone); never fabricates a value it
|
|
1693
2237
|
* can't justify.
|
|
1694
2238
|
*
|
|
1695
|
-
* A
|
|
2239
|
+
* A published processor already computed its own record at the frozen
|
|
1696
2240
|
* `viewUt`: propagation (or the channel's own basis-appropriate
|
|
1697
2241
|
* handling) is its past-horizon/interpolation story, so this falls
|
|
1698
|
-
* through to the ordinary
|
|
2242
|
+
* through to the ordinary computed read (`sample`) rather than
|
|
1699
2243
|
* interpolating the output record after the fact.
|
|
1700
2244
|
*/
|
|
1701
2245
|
sampleInterpolated(topic, token = this.currentToken, laneOverride) {
|
|
1702
2246
|
const effectiveToken = token.generation === this.generation ? token : this.currentToken;
|
|
1703
2247
|
const lane = laneOverride ?? this.laneForTopic(topic);
|
|
1704
|
-
if (this.
|
|
2248
|
+
if (this.resolvePublishedTopic(topic)) {
|
|
1705
2249
|
return this.sampleInLane(topic, effectiveToken, laneOverride);
|
|
1706
2250
|
}
|
|
1707
2251
|
// Same epoch-fold as `sample()`'s raw path above. A mid-token epoch bump
|
|
@@ -1710,7 +2254,7 @@ export class TimelineStore {
|
|
|
1710
2254
|
const epoch = this.clock.getEpoch();
|
|
1711
2255
|
return this.memoize(effectiveToken, `\0interp\0${topic}\0epoch\0${epoch}\0lane\0${lane}`, () => {
|
|
1712
2256
|
const timeline = this.timelineFor(topic);
|
|
1713
|
-
if (timeline.epoch < epoch)
|
|
2257
|
+
if (timeline.epoch < epoch && !timeline.bridging)
|
|
1714
2258
|
return undefined;
|
|
1715
2259
|
const viewUt = this.viewUtFor(effectiveToken, lane);
|
|
1716
2260
|
// A topic that is not continuous as a whole stands until its next sample.
|
|
@@ -1874,7 +2418,7 @@ export class TimelineStore {
|
|
|
1874
2418
|
*
|
|
1875
2419
|
* The three answers are distinct and the caller needs all three: a model to
|
|
1876
2420
|
* offer, a refusal to render, or nothing at all, which is what lets the
|
|
1877
|
-
* remaining ladder rungs (a
|
|
2421
|
+
* remaining ladder rungs (a published processor's label, a field read borrowing
|
|
1878
2422
|
* its record's model) still be tried.
|
|
1879
2423
|
*
|
|
1880
2424
|
* ## A declared input that did not arrive declines before the model runs
|
|
@@ -2279,10 +2823,14 @@ export class TimelineStore {
|
|
|
2279
2823
|
}
|
|
2280
2824
|
if (!window)
|
|
2281
2825
|
return { points: [anchor], truncatedAtBreak: false };
|
|
2826
|
+
// 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.
|
|
2827
|
+
if (this.catalogFallbackPoints.has(anchor)) {
|
|
2828
|
+
return { points: [anchor], truncatedAtBreak: false };
|
|
2829
|
+
}
|
|
2282
2830
|
const key = `reckon-window:${topic}:${anchor.validAt}:${window.spanUt}:${window.maxSamples}`;
|
|
2283
2831
|
return this.memoize(token, key, () => {
|
|
2284
2832
|
const raw = this.sampleRange(topic, anchor.validAt - window.spanUt, anchor.validAt);
|
|
2285
|
-
// A
|
|
2833
|
+
// A published processor has no stored history to range over (`sampleRange` answers `undefined` for one), so its window is the point it computed.
|
|
2286
2834
|
if (!raw || raw.length === 0) {
|
|
2287
2835
|
return { points: [anchor], truncatedAtBreak: false };
|
|
2288
2836
|
}
|
|
@@ -2396,6 +2944,26 @@ export class TimelineStore {
|
|
|
2396
2944
|
note: "no model is registered for this topic",
|
|
2397
2945
|
};
|
|
2398
2946
|
}
|
|
2947
|
+
/**
|
|
2948
|
+
* Whether `point` is a delayed payload whose own meta names a vessel other than the
|
|
2949
|
+
* one `ksp.activeVessel` names. That topic is read with no delay and needs no
|
|
2950
|
+
* link, so it can name a craft whose own telemetry has not arrived: until it
|
|
2951
|
+
* does, the figures still held are the previous craft's and are not shown.
|
|
2952
|
+
* Nothing is withheld while no active vessel is known.
|
|
2953
|
+
*/
|
|
2954
|
+
isReportedByOtherVessel(topic, point, token) {
|
|
2955
|
+
// A true-now topic is the game's own statement and never carries a craft's delayed figures.
|
|
2956
|
+
if (this.laneForTopic(topic) === "true-now")
|
|
2957
|
+
return false;
|
|
2958
|
+
// The craft a payload describes is named by the payload's own meta; the envelope's source is the node it was observed from.
|
|
2959
|
+
const source = payloadMetaSource(point.payload);
|
|
2960
|
+
if (source === undefined || !source.startsWith("vessel:"))
|
|
2961
|
+
return false;
|
|
2962
|
+
const activeId = this.activeVesselId(token);
|
|
2963
|
+
if (activeId === undefined)
|
|
2964
|
+
return false;
|
|
2965
|
+
return (source.slice("vessel:".length).toLowerCase() !== activeId.toLowerCase());
|
|
2966
|
+
}
|
|
2399
2967
|
/**
|
|
2400
2968
|
* The topic's value and its currency as one `TopicReading<Payload>`, at a frame token's
|
|
2401
2969
|
* frozen `viewUt`: `sample()` and `sampleStatus()` folded into the union a
|
|
@@ -2420,14 +2988,30 @@ export class TimelineStore {
|
|
|
2420
2988
|
*
|
|
2421
2989
|
* `reading-identity.test.ts` is the guard.
|
|
2422
2990
|
*/
|
|
2423
|
-
sampleReading(topic, token = this.currentToken) {
|
|
2991
|
+
sampleReading(topic, token = this.currentToken, laneOverride) {
|
|
2424
2992
|
const effectiveToken = token.generation === this.generation ? token : this.currentToken;
|
|
2425
2993
|
// Epoch-folded like every sibling read: a reading memoized before a mid-frame epoch bump (quickload rewind) must not survive it.
|
|
2426
2994
|
const epoch = this.clock.getEpoch();
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2995
|
+
const lane = laneOverride ?? this.laneForTopic(topic);
|
|
2996
|
+
// 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.
|
|
2997
|
+
const ownLane = lane === this.laneForTopic(topic);
|
|
2998
|
+
return this.memoize(effectiveToken, `\0reading\0${topic}\0epoch\0${epoch}${ownLane ? "" : `\0lane\0${lane}`}`, () => {
|
|
2999
|
+
const point = this.sampleInLane(topic, effectiveToken, laneOverride, true);
|
|
3000
|
+
// A point built from the catalog is a held fact about where the craft was last known, whatever the topic's own wire status.
|
|
3001
|
+
const status = point && this.catalogFallbackPoints.has(point)
|
|
3002
|
+
? "held"
|
|
3003
|
+
: this.sampleStatus(topic, effectiveToken);
|
|
3004
|
+
const viewedUt = this.viewUtFor(effectiveToken, lane);
|
|
3005
|
+
/*
|
|
3006
|
+
* While the signal delay to the craft is not known the view has no
|
|
3007
|
+
* instant to stand at, and nothing could be solved. A reading built from
|
|
3008
|
+
* the catalog is about where the craft is now, which the client knows
|
|
3009
|
+
* without any delay, so it is carried to that.
|
|
3010
|
+
*/
|
|
3011
|
+
const fromCatalog = point !== undefined && this.catalogFallbackPoints.has(point);
|
|
3012
|
+
const receivedUt = fromCatalog && !Number.isFinite(viewedUt)
|
|
3013
|
+
? this.clock.utNowEstimate()
|
|
3014
|
+
: viewedUt;
|
|
2431
3015
|
// 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.
|
|
2432
3016
|
const reckonUt = Math.max(effectiveToken.scetUt, receivedUt);
|
|
2433
3017
|
/*
|
|
@@ -2468,7 +3052,7 @@ export class TimelineStore {
|
|
|
2468
3052
|
const declineKey = declined
|
|
2469
3053
|
? `${declined.reason}\0${declined.input ?? ""}`
|
|
2470
3054
|
: undefined;
|
|
2471
|
-
const previous = this.readings.get(topic);
|
|
3055
|
+
const previous = ownLane ? this.readings.get(topic) : undefined;
|
|
2472
3056
|
const sameInputs = previous !== undefined &&
|
|
2473
3057
|
previous.point === point &&
|
|
2474
3058
|
previous.status === status &&
|
|
@@ -2509,6 +3093,8 @@ export class TimelineStore {
|
|
|
2509
3093
|
reading.reckoning.status !== "available") {
|
|
2510
3094
|
return previous.reading;
|
|
2511
3095
|
}
|
|
3096
|
+
if (!ownLane)
|
|
3097
|
+
return reading;
|
|
2512
3098
|
this.readings.set(topic, {
|
|
2513
3099
|
point,
|
|
2514
3100
|
status,
|
|
@@ -2530,21 +3116,21 @@ export class TimelineStore {
|
|
|
2530
3116
|
* per-`(token, key)` cache) so a status read and a value read for the
|
|
2531
3117
|
* same topic in the same frame always agree about which frame they
|
|
2532
3118
|
* describe. Field subtopics (`"<topic>.<field>"`) share their parent
|
|
2533
|
-
*
|
|
3119
|
+
* published processor's status outright: a field is just one slice of the
|
|
2534
3120
|
* one memoized record, staleness applies to the whole record.
|
|
2535
3121
|
*/
|
|
2536
3122
|
sampleStatus(topic, token = this.currentToken) {
|
|
2537
3123
|
const effectiveToken = token.generation === this.generation ? token : this.currentToken;
|
|
2538
|
-
const resolved = this.
|
|
3124
|
+
const resolved = this.resolvePublishedTopic(topic);
|
|
2539
3125
|
if (resolved) {
|
|
2540
3126
|
const parentTopic = resolved.def.topic;
|
|
2541
3127
|
// Fold epoch into the key exactly like the derived-VALUE path in
|
|
2542
|
-
// sample(). A
|
|
3128
|
+
// sample(). A published processor's status must NOT survive a mid-frame epoch bump
|
|
2543
3129
|
// (quickload rewind) for the rest of the frame, or a status read and a
|
|
2544
3130
|
// value read for the same topic in the same frame could disagree about
|
|
2545
3131
|
// which epoch they describe.
|
|
2546
3132
|
const epoch = this.clock.getEpoch();
|
|
2547
|
-
return this.memoize(effectiveToken, `\0status\0${parentTopic}\0epoch\0${epoch}`, () => this.
|
|
3133
|
+
return this.memoize(effectiveToken, `\0status\0${parentTopic}\0epoch\0${epoch}`, () => this.samplePublishedStatus(resolved.def, effectiveToken));
|
|
2548
3134
|
}
|
|
2549
3135
|
/*
|
|
2550
3136
|
* A raw field subtopic with no literal point of its own takes its parent's
|
|
@@ -2572,8 +3158,10 @@ export class TimelineStore {
|
|
|
2572
3158
|
/** Whether `topic` has a point recorded under its own literal string, in this epoch, by the frame's view time. */
|
|
2573
3159
|
hasLiteralPoint(topic, token) {
|
|
2574
3160
|
const timeline = this.timelines.get(topic);
|
|
2575
|
-
if (!timeline ||
|
|
3161
|
+
if (!timeline ||
|
|
3162
|
+
(timeline.epoch < this.clock.getEpoch() && !timeline.bridging)) {
|
|
2576
3163
|
return false;
|
|
3164
|
+
}
|
|
2577
3165
|
return (timeline.at(this.viewUtFor(token, this.laneForTopic(topic))) !== undefined);
|
|
2578
3166
|
}
|
|
2579
3167
|
/**
|
|
@@ -2591,7 +3179,9 @@ export class TimelineStore {
|
|
|
2591
3179
|
* orthogonal: the client already confirmedly knows there
|
|
2592
3180
|
* is no value, and that doesn't stop being true just because the
|
|
2593
3181
|
* transport dropped a moment later.
|
|
2594
|
-
* 3.
|
|
3182
|
+
* 3. The game's own `"loading"` state outranks every stamp below it: the
|
|
3183
|
+
* scene is being replaced, so no stamped grade describes the link.
|
|
3184
|
+
* 3b. Server-stamped `meta.staleness` wins outright when present (a
|
|
2595
3185
|
* catch-up/late-joiner mark is authoritative, no client inference
|
|
2596
3186
|
* needed for it, and it out-ranks a live transport-down reading too:
|
|
2597
3187
|
* it's a stronger, already-settled claim about this specific point).
|
|
@@ -2614,6 +3204,33 @@ export class TimelineStore {
|
|
|
2614
3204
|
return "resyncing";
|
|
2615
3205
|
if (point.payload === null)
|
|
2616
3206
|
return "absent";
|
|
3207
|
+
if (this.timelineFor(topic).bridging)
|
|
3208
|
+
return "loading";
|
|
3209
|
+
/*
|
|
3210
|
+
* A reading about a craft that is no longer the active one is not a
|
|
3211
|
+
* reading of the active craft, whatever its age: it waits for the new
|
|
3212
|
+
* craft's own report, as a topic never heard from does. Judged only once
|
|
3213
|
+
* the active craft is known, and only for a payload that names a craft.
|
|
3214
|
+
*/
|
|
3215
|
+
const subject = craftSourceOf(point.payload);
|
|
3216
|
+
if (subject !== undefined &&
|
|
3217
|
+
this.activeCraftSource !== undefined &&
|
|
3218
|
+
subject !== this.activeCraftSource) {
|
|
3219
|
+
return "resyncing";
|
|
3220
|
+
}
|
|
3221
|
+
/* A figure that names no craft and was recorded before the craft switched to became active is the craft left behind's. */
|
|
3222
|
+
if (subject === undefined &&
|
|
3223
|
+
UNNAMED_ACTIVE_CRAFT_FIGURES.has(topic) &&
|
|
3224
|
+
point.validAt <= this.activeCraftSinceUt) {
|
|
3225
|
+
return "resyncing";
|
|
3226
|
+
}
|
|
3227
|
+
/*
|
|
3228
|
+
* A scene load replaces every reading, so a grade the mod stamped on the
|
|
3229
|
+
* old scene's samples says nothing about the link while it runs: the load
|
|
3230
|
+
* is why the reading is held, and it outranks the stamp.
|
|
3231
|
+
*/
|
|
3232
|
+
if (this.gameShown.state === "loading")
|
|
3233
|
+
return "loading";
|
|
2617
3234
|
if (point.meta.staleness === Staleness.LastBeforeBlackout) {
|
|
2618
3235
|
return "last-before-blackout";
|
|
2619
3236
|
}
|
|
@@ -2623,14 +3240,45 @@ export class TimelineStore {
|
|
|
2623
3240
|
return "held";
|
|
2624
3241
|
if (!this.transportConnected)
|
|
2625
3242
|
return "disconnected";
|
|
2626
|
-
if (this.gameShown.state === "loading")
|
|
2627
|
-
return "loading";
|
|
2628
3243
|
if (this.gameShown.state === "no-game")
|
|
2629
3244
|
return "no-game";
|
|
3245
|
+
if (this.predatesLossOfLink(topic, point.validAt, token)) {
|
|
3246
|
+
return "last-before-blackout";
|
|
3247
|
+
}
|
|
2630
3248
|
return this.heartbeats.isOverdue(topic, this.clock.certaintyHorizonUt(), this.clock.confidence(), this.keyframeFloorGapUt(token))
|
|
2631
3249
|
? "held"
|
|
2632
3250
|
: "live";
|
|
2633
3251
|
}
|
|
3252
|
+
/**
|
|
3253
|
+
* Whether the mod withholds `topic` while the active craft has no link home:
|
|
3254
|
+
* a delayed Topic the core declares, or any `vessel.*` Topic. The three link
|
|
3255
|
+
* reports are exempt because they are how the loss is told. A runtime-built
|
|
3256
|
+
* namespace other than `vessel.*` is keyed by a craft of its own and freezes on
|
|
3257
|
+
* that craft's link, so it is not judged here.
|
|
3258
|
+
*/
|
|
3259
|
+
freezesWithActiveCraftLink(topic) {
|
|
3260
|
+
const wireTopic = this.resolveRawFieldSubtopic(topic)?.rawTopic ?? topic;
|
|
3261
|
+
if (LINK_REPORT_TOPICS.has(wireTopic))
|
|
3262
|
+
return false;
|
|
3263
|
+
if (!wireTopic.startsWith("vessel.") && !CORE_TOPIC_IDS.has(wireTopic)) {
|
|
3264
|
+
return false;
|
|
3265
|
+
}
|
|
3266
|
+
return this.laneForTopic(topic) === "delayed";
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Whether `topic` is a reading of the active vessel that was taken before the
|
|
3270
|
+
* vessel's link home was lost. The ground's view of a craft freezes at the last
|
|
3271
|
+
* thing it heard, and a craft with no route is sent nothing at all, so nothing
|
|
3272
|
+
* arrives to say the readings are old: the loss itself, on `comms.link`, which
|
|
3273
|
+
* keeps arriving through a blackout, is the only word. A reading taken after
|
|
3274
|
+
* the loss means frames are still reaching the ground and is current.
|
|
3275
|
+
*/
|
|
3276
|
+
predatesLossOfLink(topic, validAt, token) {
|
|
3277
|
+
if (!this.freezesWithActiveCraftLink(topic))
|
|
3278
|
+
return false;
|
|
3279
|
+
const link = this.sample("comms.link", token);
|
|
3280
|
+
return link?.payload?.connected === false && validAt < link.validAt;
|
|
3281
|
+
}
|
|
2634
3282
|
/**
|
|
2635
3283
|
* The least UT the mod leaves between two keyframes right now: its
|
|
2636
3284
|
* real-time keyframe floor times the warp rate, both off the latest
|
|
@@ -2644,20 +3292,19 @@ export class TimelineStore {
|
|
|
2644
3292
|
const gap = magnitudeOr(warp.warpRate, 0) * magnitudeOr(warp.keyframeFloorSec, 0);
|
|
2645
3293
|
return Number.isFinite(gap) && gap > 0 ? gap : 0;
|
|
2646
3294
|
}
|
|
2647
|
-
/** A
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
return worstStatus(def.inputs.map(getStatus));
|
|
3295
|
+
/** A published processor's own status: the worst of every input's. */
|
|
3296
|
+
samplePublishedStatus(def, token) {
|
|
3297
|
+
return worstStatus([...processorInputTopics(def)].map((input) => this.sampleStatus(input, token)));
|
|
2651
3298
|
}
|
|
2652
3299
|
/**
|
|
2653
|
-
* `topic` is either a
|
|
2654
|
-
*
|
|
2655
|
-
*
|
|
2656
|
-
*
|
|
2657
|
-
*
|
|
3300
|
+
* `topic` is either a published processor's own topic, or (when that processor
|
|
3301
|
+
* opted into `fields: true`) a `"<topic>.<field>"` subtopic of one. Anything
|
|
3302
|
+
* else (including a raw topic that happens to contain a dot, e.g.
|
|
3303
|
+
* `"vessel.orbit"` itself) resolves to `undefined` here and falls through to the
|
|
3304
|
+
* raw-timeline path in `sample()`.
|
|
2658
3305
|
*/
|
|
2659
|
-
|
|
2660
|
-
const exact = this.
|
|
3306
|
+
resolvePublishedTopic(topic) {
|
|
3307
|
+
const exact = this.publishedProcessors.get(topic);
|
|
2661
3308
|
if (exact)
|
|
2662
3309
|
return { def: exact };
|
|
2663
3310
|
const dot = topic.lastIndexOf(".");
|
|
@@ -2665,7 +3312,7 @@ export class TimelineStore {
|
|
|
2665
3312
|
return undefined;
|
|
2666
3313
|
const parentTopic = topic.slice(0, dot);
|
|
2667
3314
|
const field = topic.slice(dot + 1);
|
|
2668
|
-
const parent = this.
|
|
3315
|
+
const parent = this.publishedProcessors.get(parentTopic);
|
|
2669
3316
|
if (!parent?.fields)
|
|
2670
3317
|
return undefined;
|
|
2671
3318
|
return { def: parent, field };
|
|
@@ -2694,7 +3341,7 @@ export class TimelineStore {
|
|
|
2694
3341
|
* so has no member in any generated list to match against.
|
|
2695
3342
|
*
|
|
2696
3343
|
* Never consulted for a topic `resolveDerivedTopic` already matched
|
|
2697
|
-
* (checked first at every call site): a registered
|
|
3344
|
+
* (checked first at every call site): a registered published processor's own
|
|
2698
3345
|
* `fields: true` subtopics keep using that mechanism unchanged.
|
|
2699
3346
|
*/
|
|
2700
3347
|
resolveRawFieldSubtopic(topic) {
|
|
@@ -2708,10 +3355,10 @@ export class TimelineStore {
|
|
|
2708
3355
|
}
|
|
2709
3356
|
/**
|
|
2710
3357
|
* Reads `parsed.rawTopic` (a real raw topic, recurses through the ordinary
|
|
2711
|
-
* `sample()` path, including its own
|
|
3358
|
+
* `sample()` path, including its own published-processor/epoch/frame-coherence
|
|
2712
3359
|
* handling) and walks `parsed.fieldPath` into its payload.
|
|
2713
3360
|
*
|
|
2714
|
-
* Mirrors `
|
|
3361
|
+
* Mirrors `samplePublished`'s two "nothing" cases (never conflated):
|
|
2715
3362
|
* no point on the parent at all yet -> `undefined` ("not whole
|
|
2716
3363
|
* yet": the raw topic's own not-arrived-yet case, propagated as-is,
|
|
2717
3364
|
* intentionally not re-classified). A tombstoned parent (`payload: null`)
|
|
@@ -2719,13 +3366,13 @@ export class TimelineStore {
|
|
|
2719
3366
|
* record is gone, so every field of it is too). A field name not present
|
|
2720
3367
|
* on an otherwise-whole, non-null record -> `undefined` (the phantom-
|
|
2721
3368
|
* mapping case `TimelineStore.isUnresolvableField`'s doc describes for the
|
|
2722
|
-
*
|
|
3369
|
+
* published-processor analog; not extended to this raw path, every raw-field
|
|
2723
3370
|
* key that vocabulary shipped was checked against the real wire fixture
|
|
2724
3371
|
* before it was retired, so there is no known-dead mapping this needs to
|
|
2725
3372
|
* catch yet).
|
|
2726
3373
|
*
|
|
2727
3374
|
* Reuses the parent point's own `meta`/`validAt`/`epoch` verbatim, unlike
|
|
2728
|
-
* a
|
|
3375
|
+
* a published processor (which fabricates its own `processorMeta`), a raw field
|
|
2729
3376
|
* subtopic isn't a new computation, it's the same measured/received record
|
|
2730
3377
|
* narrowed to one field, so its staleness/quality/provenance genuinely are
|
|
2731
3378
|
* the whole record's.
|
|
@@ -2769,91 +3416,120 @@ export class TimelineStore {
|
|
|
2769
3416
|
return point;
|
|
2770
3417
|
}
|
|
2771
3418
|
/**
|
|
2772
|
-
*
|
|
2773
|
-
*
|
|
2774
|
-
*
|
|
2775
|
-
*
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
// never collide with a real topic string), the OUTER `memoize` call in
|
|
2789
|
-
// `sample()` also uses `def.topic` as its key when the parent topic
|
|
2790
|
-
// (not a field subtopic) is what's requested, so sharing the same key
|
|
2791
|
-
// here would let that outer wrapped `TimelinePoint` clobber this raw
|
|
2792
|
-
// derive() value in the shared per-token cache. Also folds in `epoch`
|
|
2793
|
-
// (see `sample()`'s matching comment): this is the memo that actually
|
|
2794
|
-
// calls `derive`, so it's the one that must recompute on a mid-frame
|
|
2795
|
-
// epoch bump; the outer memoize in `sample()` only needs a matching key
|
|
2796
|
-
// so it doesn't short-circuit before ever reaching this one.
|
|
2797
|
-
// The channel's own lane: TRUE-NOW only when every declared input is, and
|
|
2798
|
-
// DELAYED the moment one is not. Both halves matter. A derived record must
|
|
2799
|
-
// not be stamped more current than the most delayed thing it read, and its
|
|
2800
|
-
// inputs are pinned to the same lane so one value is never assembled from
|
|
2801
|
-
// two instants a light-time apart. A channel reading a delayed vessel
|
|
2802
|
-
// channel and the true-now `trackingStation.bodies` stays delayed, and reads the body
|
|
2803
|
-
// catalogue at the delayed instant.
|
|
2804
|
-
const lane = derivedLane(def, this.declaredLane);
|
|
2805
|
-
const { value, observedAt } = this.memoize(token, `\0derived\0${def.topic}\0epoch\0${epoch}`, () => {
|
|
2806
|
-
// The oldest input this record actually CONSUMED, which is how current
|
|
2807
|
-
// it really is. Stamping `token.viewUt` instead would make every derived
|
|
2808
|
-
// read report an age of zero, so a record twenty minutes into a blackout
|
|
2809
|
-
// would look exactly as fresh as one reporting now. Tracked here rather
|
|
2810
|
-
// than declared per channel because `get` is the only way in and the
|
|
2811
|
-
// store owns it: a channel cannot forget to say what it read, and a
|
|
2812
|
-
// channel that consults a subset of its declared `inputs` comes out
|
|
2813
|
-
// right without special-casing.
|
|
2814
|
-
let oldest = Number.POSITIVE_INFINITY;
|
|
2815
|
-
const note = (point) => {
|
|
3419
|
+
* One processor's dependencies resolved against `source` and its `compute`
|
|
3420
|
+
* run. Reading deps and processor deps carry their own instant into `oldest`:
|
|
3421
|
+
* a published processor's age is the oldest input it was handed, so a value
|
|
3422
|
+
* twenty minutes into a blackout does not look as fresh as one reporting now.
|
|
3423
|
+
*/
|
|
3424
|
+
runProcessor(def, source) {
|
|
3425
|
+
let oldest = Number.POSITIVE_INFINITY;
|
|
3426
|
+
const values = def.deps.map((dep) => {
|
|
3427
|
+
if (isProcessorDep(dep)) {
|
|
3428
|
+
const nested = source.processor(dep.id);
|
|
3429
|
+
oldest = Math.min(oldest, nested.oldest);
|
|
3430
|
+
return nested.result;
|
|
3431
|
+
}
|
|
3432
|
+
if (isReadingDep(dep)) {
|
|
3433
|
+
const reading = source.reading(dep.reading);
|
|
3434
|
+
const point = source.point(dep.reading);
|
|
2816
3435
|
if (point)
|
|
2817
3436
|
oldest = Math.min(oldest, point.validAt);
|
|
2818
|
-
return
|
|
3437
|
+
return reading;
|
|
3438
|
+
}
|
|
3439
|
+
if (isSubjectDep(dep)) {
|
|
3440
|
+
throw new Error("A processor cannot declare a per-subject dep: the subject is read from " +
|
|
3441
|
+
"a reckoner's point, and a processor has none. Resolve the subject in " +
|
|
3442
|
+
"the reckoner that owns it and declare the resulting topic here.");
|
|
3443
|
+
}
|
|
3444
|
+
const point = source.point(dep);
|
|
3445
|
+
if (point)
|
|
3446
|
+
oldest = Math.min(oldest, point.validAt);
|
|
3447
|
+
return point ? point.payload : undefined;
|
|
3448
|
+
});
|
|
3449
|
+
const run = runProcessorCompute(def, values, source.viewUt);
|
|
3450
|
+
if (source.live)
|
|
3451
|
+
recordPublishedEvaluation();
|
|
3452
|
+
return { ...run, oldest };
|
|
3453
|
+
}
|
|
3454
|
+
runNestedProcessor(id, source) {
|
|
3455
|
+
const def = getProcessor(id);
|
|
3456
|
+
if (!def) {
|
|
3457
|
+
return {
|
|
3458
|
+
computed: undefined,
|
|
3459
|
+
result: undefined,
|
|
3460
|
+
oldest: Number.POSITIVE_INFINITY,
|
|
2819
3461
|
};
|
|
3462
|
+
}
|
|
3463
|
+
return this.runProcessor(def, source);
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* One evaluation of a published processor for the frame, the same `memoize`
|
|
3467
|
+
* seam raw `sample()` reads use, so N field-subtopic reads
|
|
3468
|
+
* (`system.state.bodyCount`, ...) and a `useProcessor` read in one frame still
|
|
3469
|
+
* call `compute` exactly once. Inputs are resolved through this same token in
|
|
3470
|
+
* the processor's own lane, the structural single-view-time invariant: a
|
|
3471
|
+
* `compute` has no other way to read a UT, and one value is never assembled
|
|
3472
|
+
* from two instants a signal delay apart. The lane is true-now only when every
|
|
3473
|
+
* input is, and delayed the moment one is not, so a record is never stamped
|
|
3474
|
+
* more current than the most delayed thing it read.
|
|
3475
|
+
*
|
|
3476
|
+
* Keyed by id, with a `\0`-prefix so it can never collide with a topic's own
|
|
3477
|
+
* outer memo in `sample()`. The epoch is folded in so a mid-frame epoch bump
|
|
3478
|
+
* recomputes rather than serving pre-reset output.
|
|
3479
|
+
*/
|
|
3480
|
+
evaluateProcessor(def, token) {
|
|
3481
|
+
const lane = processorLane(def, this.declaredLane);
|
|
3482
|
+
const epoch = this.clock.getEpoch();
|
|
3483
|
+
return this.memoize(token, `\0processor\0${def.id}\0epoch\0${epoch}\0lane\0${lane}`, () => {
|
|
2820
3484
|
const viewUt = this.viewUtFor(token, lane);
|
|
2821
|
-
const
|
|
2822
|
-
|
|
3485
|
+
const source = {
|
|
3486
|
+
viewUt,
|
|
3487
|
+
point: (topic) => this.sampleInLane(topic, token, lane),
|
|
3488
|
+
reading: (topic) => this.sampleReading(topic, token, lane),
|
|
3489
|
+
processor: (id) => this.memoize(token, `\0nested\0${id}\0epoch\0${epoch}\0lane\0${lane}`, () => this.runNestedProcessor(id, source)),
|
|
3490
|
+
live: true,
|
|
3491
|
+
};
|
|
3492
|
+
const { computed, result, oldest } = this.runProcessor(def, source);
|
|
2823
3493
|
const carry = this.carryFor(def);
|
|
2824
|
-
carry.value = shareEqual(carry.value,
|
|
3494
|
+
carry.value = shareEqual(carry.value, computed);
|
|
2825
3495
|
return {
|
|
2826
3496
|
value: carry.value,
|
|
2827
|
-
|
|
3497
|
+
result,
|
|
3498
|
+
// A processor that read nothing is as current as the frame; nothing can be older than the moment being asked about.
|
|
2828
3499
|
observedAt: Number.isFinite(oldest)
|
|
2829
3500
|
? Math.min(oldest, viewUt)
|
|
2830
3501
|
: viewUt,
|
|
2831
3502
|
};
|
|
2832
3503
|
});
|
|
3504
|
+
}
|
|
3505
|
+
/** A published processor's value as a point on its Topic or one of its field Topics. */
|
|
3506
|
+
samplePublished(resolved, token, epoch) {
|
|
3507
|
+
const { def, field } = resolved;
|
|
3508
|
+
const { value, observedAt: at } = this.evaluateProcessor(def, token);
|
|
2833
3509
|
if (value === undefined) {
|
|
2834
|
-
// Not whole yet: an input has no point at-or-before
|
|
3510
|
+
// Not whole yet: an input has no point at-or-before the view time in the
|
|
2835
3511
|
// current epoch (cold start, or resynchronizing after an epoch reset).
|
|
2836
|
-
// There is no point to serve at all here, NOT a
|
|
2837
|
-
//
|
|
2838
|
-
//
|
|
3512
|
+
// There is no point to serve at all here, NOT a tombstone: propagates
|
|
3513
|
+
// through field subtopics too, since there's nothing to extract a field
|
|
3514
|
+
// from yet.
|
|
2839
3515
|
return undefined;
|
|
2840
3516
|
}
|
|
2841
3517
|
if (value === null) {
|
|
2842
|
-
// Confirmed absence, a required input tombstoned or the
|
|
2843
|
-
return this.carryPoint(def, field, null,
|
|
3518
|
+
// Confirmed absence, a required input tombstoned or the processor itself returning null: a real point carrying `payload: null`, per the tombstone model.
|
|
3519
|
+
return this.carryPoint(def, field, null, at, epoch);
|
|
2844
3520
|
}
|
|
2845
3521
|
if (field && !(field in value))
|
|
2846
3522
|
return undefined; // unknown field name, nothing to serve
|
|
2847
3523
|
const payload = field
|
|
2848
3524
|
? Reflect.get(value, field)
|
|
2849
3525
|
: value;
|
|
2850
|
-
return this.carryPoint(def, field, payload,
|
|
3526
|
+
return this.carryPoint(def, field, payload, at, epoch);
|
|
2851
3527
|
}
|
|
2852
3528
|
carryFor(def) {
|
|
2853
|
-
let carry = this.
|
|
3529
|
+
let carry = this.publishedCarry.get(def);
|
|
2854
3530
|
if (!carry) {
|
|
2855
3531
|
carry = { value: undefined, points: new Map() };
|
|
2856
|
-
this.
|
|
3532
|
+
this.publishedCarry.set(def, carry);
|
|
2857
3533
|
}
|
|
2858
3534
|
return carry;
|
|
2859
3535
|
}
|
|
@@ -2871,7 +3547,7 @@ export class TimelineStore {
|
|
|
2871
3547
|
const point = {
|
|
2872
3548
|
validAt: observedAt,
|
|
2873
3549
|
payload,
|
|
2874
|
-
meta:
|
|
3550
|
+
meta: processorMeta(observedAt, epoch),
|
|
2875
3551
|
epoch,
|
|
2876
3552
|
};
|
|
2877
3553
|
points.set(key, point);
|
|
@@ -2882,7 +3558,7 @@ export class TimelineStore {
|
|
|
2882
3558
|
* `(token, key)` pair wins for that token's lifetime; subsequent calls
|
|
2883
3559
|
* return the cached result even if the underlying data changes in
|
|
2884
3560
|
* between. Private for now, exposed indirectly via `sample()`, but
|
|
2885
|
-
* deliberately generic so
|
|
3561
|
+
* deliberately generic so published processors can reuse the same
|
|
2886
3562
|
* per-frame cache instead of building their own.
|
|
2887
3563
|
*/
|
|
2888
3564
|
memoize(token, key, compute) {
|
|
@@ -2954,9 +3630,31 @@ export class TimelineStore {
|
|
|
2954
3630
|
let timeline = this.timelines.get(topic);
|
|
2955
3631
|
if (!timeline) {
|
|
2956
3632
|
timeline = new ClientTimeline(this.options.timelineOptions);
|
|
3633
|
+
timeline.scaleMaxPoints(this.topicRates.get(topic) ?? 1);
|
|
2957
3634
|
this.timelines.set(topic, timeline);
|
|
2958
3635
|
}
|
|
2959
3636
|
return timeline;
|
|
2960
3637
|
}
|
|
3638
|
+
/** Re-bound every timeline whose Topic's rate `report` changes, so each keeps the same span of game time. */
|
|
3639
|
+
applyDataRates(report) {
|
|
3640
|
+
if (!report)
|
|
3641
|
+
return;
|
|
3642
|
+
const base = tierSamplesPerSecondOf(report, "base");
|
|
3643
|
+
const next = new Map();
|
|
3644
|
+
for (const row of report.topics) {
|
|
3645
|
+
const rate = samplesPerSecondOf(report, row.topic);
|
|
3646
|
+
if (rate > base)
|
|
3647
|
+
next.set(row.topic, rate / base);
|
|
3648
|
+
}
|
|
3649
|
+
const changed = new Set([...this.topicRates.keys(), ...next.keys()]);
|
|
3650
|
+
this.topicRates.clear();
|
|
3651
|
+
for (const [topic, scale] of next)
|
|
3652
|
+
this.topicRates.set(topic, scale);
|
|
3653
|
+
for (const topic of changed) {
|
|
3654
|
+
this.timelines
|
|
3655
|
+
.get(topic)
|
|
3656
|
+
?.scaleMaxPoints(this.topicRates.get(topic) ?? 1);
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
2961
3659
|
}
|
|
2962
3660
|
//# sourceMappingURL=timeline-store.js.map
|