@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
package/src/spine/client.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { LimitBreach, Meta } from "../__generated__/contract";
|
|
1
|
+
import type { LimitBreach, Meta, StreamData } from "../__generated__/contract";
|
|
2
2
|
import { CommandErrorCode, FaultCode } from "../__generated__/error-codes";
|
|
3
3
|
import { COMMAND_LOST, COMMAND_REFUSED } from "../api/command-rejection";
|
|
4
4
|
import type { Transport } from "../api/transport";
|
|
5
5
|
import { wrapCommandReply } from "../command-reply-units";
|
|
6
|
+
import {
|
|
7
|
+
type DataRateTier,
|
|
8
|
+
fieldsSentOnChange,
|
|
9
|
+
fillUnchangedFields,
|
|
10
|
+
} from "../data-rate";
|
|
6
11
|
import type { ClientMessage, ServerMessage } from "../envelope";
|
|
7
12
|
import { PerfBudget } from "../perf/PerfBudget";
|
|
8
13
|
import { dehydrateArgs } from "../wrap-units";
|
|
@@ -13,7 +18,7 @@ import { warnConnectionError } from "./connection-error-warning";
|
|
|
13
18
|
import { CommandError, type CommandStatus } from "./lifecycle";
|
|
14
19
|
import type { TimelineStore } from "./timeline-store";
|
|
15
20
|
import { type TopicOwnership, TopicOwnershipTracker } from "./topic-ownership";
|
|
16
|
-
import { META_VANTAGE } from "./vantage";
|
|
21
|
+
import { ACTIVE_CRAFT_VANTAGE, META_VANTAGE } from "./vantage";
|
|
17
22
|
|
|
18
23
|
type Callback = (value: unknown) => void;
|
|
19
24
|
/** A subscriber that is also handed the `Meta` of the frame that carried the value, where the client still holds it. */
|
|
@@ -50,12 +55,21 @@ type StoreListener = () => void;
|
|
|
50
55
|
*/
|
|
51
56
|
export const LOSS_MARGIN = 3;
|
|
52
57
|
|
|
58
|
+
/** How long a command sent while the delay is unknown waits for any answer before it is called lost, in seconds on the client's clock. */
|
|
59
|
+
const UNKNOWN_DELAY_LOSS_SECONDS = 120;
|
|
60
|
+
|
|
53
61
|
/** The longest a deadline in game UT waits on the client's clock before it reads the game's UT again, in seconds. */
|
|
54
62
|
const GAME_UT_RECHECK_SECONDS = 5;
|
|
55
63
|
|
|
56
64
|
/** How close to a deadline in game UT counts as reached, in seconds, so that rounding in the clock arithmetic cannot leave a timer one tick short. */
|
|
57
65
|
const GAME_UT_TOLERANCE = 1e-6;
|
|
58
66
|
|
|
67
|
+
/** How far behind the game's UT a frame after a load may be stamped and still belong to the same timeline, in seconds: the mod stamps a withdrawal one float step below the instant it happens at. */
|
|
68
|
+
const REWIND_TOLERANCE_SECONDS = 1e-3;
|
|
69
|
+
|
|
70
|
+
/** The `meta.source` of a reading delivered from a craft's own node, which keeps that craft's own delay. */
|
|
71
|
+
const CRAFT_NODE_SOURCE_PREFIX = "fleet.";
|
|
72
|
+
|
|
59
73
|
/**
|
|
60
74
|
* Dispatch-rate budget for every command this client sends.
|
|
61
75
|
*
|
|
@@ -189,6 +203,12 @@ interface PendingCommand {
|
|
|
189
203
|
replyDueUt?: number;
|
|
190
204
|
/** A deadline the game gave in UT, which the loss timer follows through time warp and a pause. Absent for a command timed on the client's clock alone. */
|
|
191
205
|
gameDeadlineUt?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Set while the command was dispatched with no known delay, so its loss
|
|
208
|
+
* deadline is only the fallback and is replaced from `dispatchedAt` when the
|
|
209
|
+
* delay figure arrives.
|
|
210
|
+
*/
|
|
211
|
+
awaitingDelay?: { at: number; ut: number | undefined };
|
|
192
212
|
/** True for a command read back from the outstanding store rather than dispatched by this client. */
|
|
193
213
|
restored: boolean;
|
|
194
214
|
/** The promise a restored command settles, handed to the first `useCommand` that adopts it. */
|
|
@@ -276,6 +296,24 @@ export interface GroupMember {
|
|
|
276
296
|
topic?: string;
|
|
277
297
|
/** A request id the caller already holds, as {@link TelemetryClient.dispatch} takes. */
|
|
278
298
|
requestId?: string;
|
|
299
|
+
/** What the sending screen had seen, as {@link TelemetryClient.dispatch} takes. */
|
|
300
|
+
seen?: CommandSeen;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* What a command's sending screen had last received from the mod: the run and
|
|
305
|
+
* timeline it was aimed at, and the vessel it showed. A delayed command or a
|
|
306
|
+
* scene change from an older run or timeline is refused, because a game load
|
|
307
|
+
* replaced what it was aimed at. Passed to {@link TelemetryClient.dispatch} by a
|
|
308
|
+
* host forwarding a station's command, so the station's own view is the one
|
|
309
|
+
* judged and not the host's.
|
|
310
|
+
*
|
|
311
|
+
* @category Commands
|
|
312
|
+
*/
|
|
313
|
+
export interface CommandSeen {
|
|
314
|
+
seenBootId: string;
|
|
315
|
+
seenEpoch: number;
|
|
316
|
+
seenVesselId?: string;
|
|
279
317
|
}
|
|
280
318
|
|
|
281
319
|
/**
|
|
@@ -329,24 +367,68 @@ function randomIdPrefix(): string {
|
|
|
329
367
|
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
330
368
|
}
|
|
331
369
|
|
|
370
|
+
/**
|
|
371
|
+
* The `seenVesselId` a command carries when the screen has read a
|
|
372
|
+
* `vessel.identity` and the mod has since withdrawn it, because the active
|
|
373
|
+
* vessel changed and the new one has not been heard yet. No vessel has this id,
|
|
374
|
+
* so the mod refuses the order instead of sending it to a vessel the operator
|
|
375
|
+
* has not seen.
|
|
376
|
+
*/
|
|
377
|
+
const UNKNOWN_CRAFT_ID = "unknown";
|
|
378
|
+
|
|
332
379
|
/**
|
|
333
380
|
* The vessel the operator's screen shows as active, as the optional
|
|
334
|
-
* `seenVesselId` of a command frame
|
|
335
|
-
*
|
|
336
|
-
*
|
|
381
|
+
* `seenVesselId` of a command frame. Nothing when no `vessel.identity` reading
|
|
382
|
+
* has ever arrived; {@link UNKNOWN_CRAFT_ID} when one has arrived and been
|
|
383
|
+
* withdrawn. The mod refuses an order for the active vessel when the game has
|
|
384
|
+
* since switched to another one.
|
|
337
385
|
*/
|
|
338
|
-
function seenVessel(
|
|
386
|
+
function seenVessel(
|
|
387
|
+
identity: unknown,
|
|
388
|
+
read: boolean,
|
|
389
|
+
): { seenVesselId?: string } {
|
|
390
|
+
if (identity === null && read) return { seenVesselId: UNKNOWN_CRAFT_ID };
|
|
339
391
|
if (typeof identity !== "object" || identity === null) return {};
|
|
340
392
|
if (!("vesselId" in identity)) return {};
|
|
341
393
|
const id = identity.vesselId;
|
|
342
394
|
return typeof id === "string" && id !== "" ? { seenVesselId: id } : {};
|
|
343
395
|
}
|
|
344
396
|
|
|
397
|
+
type SampleFrame = Extract<
|
|
398
|
+
ServerMessage,
|
|
399
|
+
{ type: "stream-data" | "stream-binary" }
|
|
400
|
+
>;
|
|
401
|
+
|
|
402
|
+
const isSampleFrame = (message: ServerMessage): message is SampleFrame =>
|
|
403
|
+
message.type === "stream-data" || message.type === "stream-binary";
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* `applied` with the `Meta` the mod sent. A station learns its timeline from
|
|
407
|
+
* what the main screen relays and its commands must name the mod's own epoch,
|
|
408
|
+
* so the epoch a client applies for its own stores stays inside that client.
|
|
409
|
+
*/
|
|
410
|
+
function stampedAsSent(
|
|
411
|
+
applied: ServerMessage,
|
|
412
|
+
incoming: ServerMessage,
|
|
413
|
+
): ServerMessage {
|
|
414
|
+
if (applied === incoming) return applied;
|
|
415
|
+
if (!isSampleFrame(applied) || !isSampleFrame(incoming)) return applied;
|
|
416
|
+
return { ...applied, meta: incoming.meta };
|
|
417
|
+
}
|
|
418
|
+
|
|
345
419
|
export class TelemetryClient {
|
|
346
420
|
private readonly transport: Transport;
|
|
347
421
|
private readonly clock: Clock;
|
|
348
422
|
private readonly subscribers = new Map<string, Set<Subscription>>();
|
|
423
|
+
/** How many live {@link requestRate} claims hold each topic at the fast tier. */
|
|
424
|
+
private readonly fastClaims = new Map<string, number>();
|
|
425
|
+
/** The tier last sent for each subscribed topic, base ones left out: the mod drops it on unsubscribe, and so does this. */
|
|
426
|
+
private readonly sentTiers = new Map<string, DataRateTier>();
|
|
427
|
+
/** The subscription to `system.dataRates` held while any claim is live, so a store attached to this client learns each fast Topic's rate. */
|
|
428
|
+
private releaseRateReport: (() => void) | null = null;
|
|
349
429
|
private readonly lastValues = new Map<string, unknown>();
|
|
430
|
+
/** The last payload this connection delivered of each Topic with fields sent only on change, which a later frame's unchanged fields are taken from. */
|
|
431
|
+
private readonly lastDeliveredWithHeldFields = new Map<string, unknown>();
|
|
350
432
|
/** The `Meta` of the frame that carried each topic's `lastValues` entry, so a value replayed on subscribe says which sample it is. */
|
|
351
433
|
private readonly lastMetas = new Map<string, Meta>();
|
|
352
434
|
|
|
@@ -376,6 +458,10 @@ export class TelemetryClient {
|
|
|
376
458
|
{ epoch: number; vantage: string; validAt: number }
|
|
377
459
|
>();
|
|
378
460
|
private readonly storeListeners = new Set<StoreListener>();
|
|
461
|
+
/** Clients whose commands this one reads as its own screen's, as {@link carryCommandsFrom} lends them. */
|
|
462
|
+
private readonly carriers = new Set<TelemetryClient>();
|
|
463
|
+
private carriedRevision = 0;
|
|
464
|
+
private readonly carriedForOther = new Set<string>();
|
|
379
465
|
/** Reactive-read listeners for the selected vantage: see `onSelectedVantageChange`. */
|
|
380
466
|
private readonly vantageListeners = new Set<() => void>();
|
|
381
467
|
/** Reactive-read listeners for the observed vantage: see `onObservedVantageChange`. */
|
|
@@ -396,6 +482,10 @@ export class TelemetryClient {
|
|
|
396
482
|
private readonly idPrefix: string;
|
|
397
483
|
private selectedVantageId: string | undefined;
|
|
398
484
|
private observedVantageId: string | undefined;
|
|
485
|
+
/** The epoch and `deliveredAt` of the frame that last moved the observed vantage. */
|
|
486
|
+
private observedStampedAt: { epoch: number; deliveredAt: number } | undefined;
|
|
487
|
+
/** Whether the mod was asked to keep this connection at the active craft: see {@link followActiveCraft}. */
|
|
488
|
+
private followingActiveCraft = false;
|
|
399
489
|
/** Raw-frame tap listeners: see `onRawMessage`. */
|
|
400
490
|
private readonly rawMessageListeners = new Set<
|
|
401
491
|
(message: ServerMessage) => void
|
|
@@ -416,6 +506,26 @@ export class TelemetryClient {
|
|
|
416
506
|
* forward on the client's clock until a frame says it runs again.
|
|
417
507
|
*/
|
|
418
508
|
private gamePaused = false;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Whether the newest `game-state` said a scene is loading. UT does not
|
|
512
|
+
* advance through a load, so it holds the game's UT still the same way a
|
|
513
|
+
* pause does.
|
|
514
|
+
*/
|
|
515
|
+
private gameLoading = false;
|
|
516
|
+
/** Whether a load has begun since the last live sample that was not behind the game's UT. */
|
|
517
|
+
private loadSinceLastSample = false;
|
|
518
|
+
|
|
519
|
+
/** The newest UT a live sample was delivered at, the timeline it was on, and the `seq` of the frame that carried it. */
|
|
520
|
+
private newestDelivered:
|
|
521
|
+
| { ut: number; epoch: number; seq: number | undefined }
|
|
522
|
+
| undefined;
|
|
523
|
+
/** How far the client's timeline epoch runs ahead of the wire's, for rewinds the mod did not announce with a new epoch. */
|
|
524
|
+
private epochShift = 0;
|
|
525
|
+
private lastWireEpoch = 0;
|
|
526
|
+
/** The mod's run this client last heard from, empty until it has. */
|
|
527
|
+
private wireBootId = "";
|
|
528
|
+
private readonly timelineListeners = new Set<() => void>();
|
|
419
529
|
/** The keyframe interval each topic's `subscribed` ack declared, kept so a store attached later is told too. */
|
|
420
530
|
private readonly declaredKeyframeIntervals = new Map<string, number>();
|
|
421
531
|
|
|
@@ -488,10 +598,17 @@ export class TelemetryClient {
|
|
|
488
598
|
: undefined;
|
|
489
599
|
/* A transport still connecting reports no change until it opens, so the tracker is told here that nothing can ack yet. */
|
|
490
600
|
if (transport.status !== "connected") this.ownership?.handleDisconnected();
|
|
491
|
-
this.unsubscribeFromTransport = transport.onMessage(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
601
|
+
this.unsubscribeFromTransport = transport.onMessage(
|
|
602
|
+
(incoming, delivery) => {
|
|
603
|
+
const replayed = delivery?.replayed === true;
|
|
604
|
+
this.followTimeline(incoming);
|
|
605
|
+
const message = replayed ? incoming : this.followRewind(incoming);
|
|
606
|
+
if (message.type === "stream-data") this.restoreUnchanged(message);
|
|
607
|
+
const asSent = stampedAsSent(message, incoming);
|
|
608
|
+
for (const listener of this.rawMessageListeners) listener(asSent);
|
|
609
|
+
this.handleMessage(message, replayed);
|
|
610
|
+
},
|
|
611
|
+
);
|
|
495
612
|
this.unsubscribeFromUndelivered =
|
|
496
613
|
transport.onUndelivered?.((command) =>
|
|
497
614
|
this.handleUndelivered(command.requestId, command.reason),
|
|
@@ -626,7 +743,7 @@ export class TelemetryClient {
|
|
|
626
743
|
private outstandingList(): OutstandingCommand[] {
|
|
627
744
|
const list: OutstandingCommand[] = [];
|
|
628
745
|
for (const [requestId, pending] of this.commands) {
|
|
629
|
-
if (pending.unclaimable) continue;
|
|
746
|
+
if (pending.unclaimable || this.carriedForOther.has(requestId)) continue;
|
|
630
747
|
const phase = pending.status.phase;
|
|
631
748
|
if (phase !== "in-flight" && phase !== "lost") continue;
|
|
632
749
|
list.push({
|
|
@@ -735,6 +852,9 @@ export class TelemetryClient {
|
|
|
735
852
|
* Purely additive: does not affect `subscribe`/`getValue`/store-ingest
|
|
736
853
|
* delivery, and costs nothing when no listener is registered (the common
|
|
737
854
|
* case: mission history off, or no recorder attached).
|
|
855
|
+
*
|
|
856
|
+
* A frame keeps the timeline epoch the mod stamped on it, whatever rewind this
|
|
857
|
+
* client has inferred for its own stores.
|
|
738
858
|
*/
|
|
739
859
|
onRawMessage(listener: (message: ServerMessage) => void): () => void {
|
|
740
860
|
this.rawMessageListeners.add(listener);
|
|
@@ -748,10 +868,14 @@ export class TelemetryClient {
|
|
|
748
868
|
* `undefined` is "wherever the server puts a connection that has not chosen",
|
|
749
869
|
* which is the home command, and not a centre id this client could spell: the
|
|
750
870
|
* server alone knows which centre is home. Where that turned out to be is
|
|
751
|
-
* {@link observedVantage}.
|
|
871
|
+
* {@link observedVantage}. After {@link followActiveCraft} it is that observed
|
|
872
|
+
* centre, since the mod chooses it.
|
|
752
873
|
*/
|
|
753
874
|
get selectedVantage(): string | undefined {
|
|
754
|
-
|
|
875
|
+
// While following, the mod picks the centre, so the one in force is the one the frames name.
|
|
876
|
+
return this.followingActiveCraft
|
|
877
|
+
? this.observedVantageId
|
|
878
|
+
: this.selectedVantageId;
|
|
755
879
|
}
|
|
756
880
|
|
|
757
881
|
/**
|
|
@@ -821,17 +945,99 @@ export class TelemetryClient {
|
|
|
821
945
|
// not from; and the re-subscribe below would churn the whole topic set for
|
|
822
946
|
// a request nothing will act on.
|
|
823
947
|
if (!this.canSetVantage) return;
|
|
948
|
+
this.followingActiveCraft = false;
|
|
824
949
|
this.selectedVantageId = centreId;
|
|
825
950
|
for (const listener of this.vantageListeners) listener();
|
|
951
|
+
this.sendVantage(centreId);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Ask the mod to keep this connection at the active craft, and to move it
|
|
956
|
+
* whenever the game changes craft (a switch, an EVA, a docking or an undock),
|
|
957
|
+
* with no further message from this client. While there is no active craft
|
|
958
|
+
* the connection stays at the vantage a fresh connection starts at. Useful for
|
|
959
|
+
* a screen that flies whichever craft is active, which sends this once instead
|
|
960
|
+
* of naming a craft. Used by the pilot screen.
|
|
961
|
+
*
|
|
962
|
+
* Does nothing when the connection is already following, and on a transport
|
|
963
|
+
* that cannot carry a vantage. {@link selectedVantage} then reports the centre
|
|
964
|
+
* the frames name.
|
|
965
|
+
*/
|
|
966
|
+
followActiveCraft(): void {
|
|
967
|
+
if (!this.canSetVantage || this.followingActiveCraft) return;
|
|
968
|
+
this.followingActiveCraft = true;
|
|
969
|
+
for (const listener of this.vantageListeners) listener();
|
|
970
|
+
this.sendVantage(ACTIVE_CRAFT_VANTAGE);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
private sendVantage(centreId: string): void {
|
|
826
974
|
this.transport.send({ type: "set-vantage", centreId });
|
|
827
975
|
// Re-point existing subscriptions at the new vantage: the server reads the selected vantage at subscribe time, so an active topic must re-subscribe.
|
|
828
976
|
for (const topic of this.subscribers.keys()) {
|
|
829
977
|
this.transport.send({ type: "unsubscribe", topic });
|
|
978
|
+
this.sentTiers.delete(topic);
|
|
830
979
|
this.transport.send({ type: "subscribe", topic });
|
|
831
980
|
this.ownership?.noteSubscribeSent(topic);
|
|
981
|
+
this.syncRate(topic);
|
|
832
982
|
}
|
|
833
983
|
}
|
|
834
984
|
|
|
985
|
+
/**
|
|
986
|
+
* Ask for `topic` at `tier` until the returned release is called. The mod is
|
|
987
|
+
* asked for the fastest tier any live claim on the topic holds, and only while
|
|
988
|
+
* the topic is subscribed: a claim made first waits for the subscribe, and one
|
|
989
|
+
* outliving its subscriptions is asked for again when the topic is next
|
|
990
|
+
* subscribed. A `"base"` claim asks for nothing.
|
|
991
|
+
*/
|
|
992
|
+
requestRate(topic: string, tier: DataRateTier): () => void {
|
|
993
|
+
if (topic === "" || tier === "base") return () => {};
|
|
994
|
+
this.fastClaims.set(topic, (this.fastClaims.get(topic) ?? 0) + 1);
|
|
995
|
+
this.releaseRateReport ??= this.subscribe("system.dataRates", () => {});
|
|
996
|
+
this.syncRate(topic);
|
|
997
|
+
let released = false;
|
|
998
|
+
return () => {
|
|
999
|
+
if (released) return;
|
|
1000
|
+
released = true;
|
|
1001
|
+
const remaining = (this.fastClaims.get(topic) ?? 1) - 1;
|
|
1002
|
+
if (remaining > 0) this.fastClaims.set(topic, remaining);
|
|
1003
|
+
else this.fastClaims.delete(topic);
|
|
1004
|
+
this.syncRate(topic);
|
|
1005
|
+
if (this.fastClaims.size === 0) {
|
|
1006
|
+
this.releaseRateReport?.();
|
|
1007
|
+
this.releaseRateReport = null;
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Ask the mod to send `tier` no faster than `samplesPerSecond` while this
|
|
1014
|
+
* connection is open, or withdraw the request with `null`. The mod sends the
|
|
1015
|
+
* tier at the lowest rate any connection asks for this way, never below the
|
|
1016
|
+
* base rate, and `system.dataRates` reports what it sends.
|
|
1017
|
+
*/
|
|
1018
|
+
capRate(tier: DataRateTier, samplesPerSecond: number | null): void {
|
|
1019
|
+
this.transport.send(
|
|
1020
|
+
samplesPerSecond === null
|
|
1021
|
+
? { type: "cap-rate", tier }
|
|
1022
|
+
: { type: "cap-rate", tier, samplesPerSecond },
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** The tier the live claims on `topic` ask for. */
|
|
1027
|
+
claimedTier(topic: string): DataRateTier {
|
|
1028
|
+
return (this.fastClaims.get(topic) ?? 0) > 0 ? "fast" : "base";
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/** Send `set-rate` for `topic` when the tier its claims ask for differs from what the mod holds for it. */
|
|
1032
|
+
private syncRate(topic: string): void {
|
|
1033
|
+
if (!this.subscribers.has(topic)) return;
|
|
1034
|
+
const wanted = this.claimedTier(topic);
|
|
1035
|
+
if (wanted === (this.sentTiers.get(topic) ?? "base")) return;
|
|
1036
|
+
if (wanted === "base") this.sentTiers.delete(topic);
|
|
1037
|
+
else this.sentTiers.set(topic, wanted);
|
|
1038
|
+
this.transport.send({ type: "set-rate", topic, tier: wanted });
|
|
1039
|
+
}
|
|
1040
|
+
|
|
835
1041
|
/**
|
|
836
1042
|
* Subscribe to a topic. On the first subscriber for a topic, sends a
|
|
837
1043
|
* `subscribe` message to the transport. If a sticky last value already
|
|
@@ -863,6 +1069,7 @@ export class TelemetryClient {
|
|
|
863
1069
|
this.subscribers.set(topic, subs);
|
|
864
1070
|
this.transport.send({ type: "subscribe", topic });
|
|
865
1071
|
this.ownership?.noteSubscribeSent(topic);
|
|
1072
|
+
this.syncRate(topic);
|
|
866
1073
|
}
|
|
867
1074
|
const sub: Subscription = { cb };
|
|
868
1075
|
subs.add(sub);
|
|
@@ -885,6 +1092,7 @@ export class TelemetryClient {
|
|
|
885
1092
|
this.lastMetas.delete(topic);
|
|
886
1093
|
this.lastPoints.delete(topic);
|
|
887
1094
|
this.newestRaw.delete(topic);
|
|
1095
|
+
this.sentTiers.delete(topic);
|
|
888
1096
|
this.transport.send({ type: "unsubscribe", topic });
|
|
889
1097
|
this.ownership?.noteReleased(topic);
|
|
890
1098
|
}
|
|
@@ -904,7 +1112,7 @@ export class TelemetryClient {
|
|
|
904
1112
|
* already does, the two delivery paths are independent, neither replaces
|
|
905
1113
|
* the other. `point.validAt`/`point.epoch` are read straight off the
|
|
906
1114
|
* message's own `meta` (`meta.validAt`/`meta.timelineEpoch`), which is what
|
|
907
|
-
* makes this feed correct for a
|
|
1115
|
+
* makes this feed correct for a published processor's epoch-guard/quality-pick
|
|
908
1116
|
* machinery without this class needing to know anything about derivation.
|
|
909
1117
|
*
|
|
910
1118
|
* Does not replay history: a store attached after samples have already
|
|
@@ -925,6 +1133,18 @@ export class TelemetryClient {
|
|
|
925
1133
|
}
|
|
926
1134
|
// Only each topic's newest point is replayed, never the history behind it.
|
|
927
1135
|
for (const [topic, point] of this.lastPoints) store.ingest(topic, point);
|
|
1136
|
+
const requestHistory = this.transport.requestHistory?.bind(this.transport);
|
|
1137
|
+
const releaseHistory = requestHistory
|
|
1138
|
+
? store.setHistorySource({
|
|
1139
|
+
request: async (topic, fromUt, toUt) =>
|
|
1140
|
+
(await requestHistory(topic, fromUt, toUt)).map((frame) => ({
|
|
1141
|
+
validAt: frame.meta.validAt,
|
|
1142
|
+
payload: frame.payload,
|
|
1143
|
+
meta: frame.meta,
|
|
1144
|
+
epoch: frame.meta.timelineEpoch,
|
|
1145
|
+
})),
|
|
1146
|
+
})
|
|
1147
|
+
: undefined;
|
|
928
1148
|
if (this.gameState) {
|
|
929
1149
|
store.setGameState(this.gameState.state, this.gameState.scene);
|
|
930
1150
|
}
|
|
@@ -936,6 +1156,7 @@ export class TelemetryClient {
|
|
|
936
1156
|
store.markTopicUnowned(topic);
|
|
937
1157
|
}
|
|
938
1158
|
return () => {
|
|
1159
|
+
releaseHistory?.();
|
|
939
1160
|
this.stores.delete(store);
|
|
940
1161
|
};
|
|
941
1162
|
}
|
|
@@ -993,6 +1214,7 @@ export class TelemetryClient {
|
|
|
993
1214
|
private delaySource: (() => number) | undefined;
|
|
994
1215
|
|
|
995
1216
|
private warnedNoLossDeadline = false;
|
|
1217
|
+
private awaitingDelayCount = 0;
|
|
996
1218
|
private warnedEmptyTopic = false;
|
|
997
1219
|
|
|
998
1220
|
/**
|
|
@@ -1012,6 +1234,14 @@ export class TelemetryClient {
|
|
|
1012
1234
|
};
|
|
1013
1235
|
}
|
|
1014
1236
|
|
|
1237
|
+
/** The delay source's figure, or nothing while it says the delay is unknown (not finite). */
|
|
1238
|
+
private knownSourceDelay(): number | undefined {
|
|
1239
|
+
const seconds = this.delaySource?.();
|
|
1240
|
+
return seconds !== undefined && Number.isFinite(seconds)
|
|
1241
|
+
? seconds
|
|
1242
|
+
: undefined;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1015
1245
|
/**
|
|
1016
1246
|
* Say so, once, when a dispatch gets no loss deadline.
|
|
1017
1247
|
*
|
|
@@ -1033,11 +1263,19 @@ export class TelemetryClient {
|
|
|
1033
1263
|
private warnNoLossDeadlineOnce(): void {
|
|
1034
1264
|
if (this.warnedNoLossDeadline) return;
|
|
1035
1265
|
this.warnedNoLossDeadline = true;
|
|
1266
|
+
if (this.delaySource === undefined) {
|
|
1267
|
+
console.warn(
|
|
1268
|
+
"[sitrep] no delay authority and no transport prediction: command promises " +
|
|
1269
|
+
"cannot be settled on silence, so an unanswered dispatch will hang. " +
|
|
1270
|
+
"Attach a DelayAuthority (TelemetryProvider does this) or implement " +
|
|
1271
|
+
"Transport.predictConfirmEta.",
|
|
1272
|
+
);
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1036
1275
|
console.warn(
|
|
1037
|
-
"[sitrep]
|
|
1038
|
-
"
|
|
1039
|
-
"
|
|
1040
|
-
"Transport.predictConfirmEta.",
|
|
1276
|
+
"[sitrep] the command delay is not yet known: a command sent now is timed " +
|
|
1277
|
+
"from its dispatch once the figure arrives, and is called lost after " +
|
|
1278
|
+
"a fixed wait if none does.",
|
|
1041
1279
|
);
|
|
1042
1280
|
}
|
|
1043
1281
|
|
|
@@ -1048,6 +1286,7 @@ export class TelemetryClient {
|
|
|
1048
1286
|
topic?: string,
|
|
1049
1287
|
vantage?: string,
|
|
1050
1288
|
requestIdOverride?: string,
|
|
1289
|
+
seen?: CommandSeen,
|
|
1051
1290
|
): { requestId: string; result: Promise<unknown> } {
|
|
1052
1291
|
const { requestId, result, frame } = this.register(
|
|
1053
1292
|
command,
|
|
@@ -1056,6 +1295,7 @@ export class TelemetryClient {
|
|
|
1056
1295
|
topic,
|
|
1057
1296
|
vantage,
|
|
1058
1297
|
requestIdOverride,
|
|
1298
|
+
seen,
|
|
1059
1299
|
);
|
|
1060
1300
|
this.transport.send(frame);
|
|
1061
1301
|
return { requestId, result };
|
|
@@ -1091,7 +1331,15 @@ export class TelemetryClient {
|
|
|
1091
1331
|
throw new Error("a request id in the group is already in use");
|
|
1092
1332
|
}
|
|
1093
1333
|
const registered = members.map((m) =>
|
|
1094
|
-
this.register(
|
|
1334
|
+
this.register(
|
|
1335
|
+
m.command,
|
|
1336
|
+
m.args,
|
|
1337
|
+
m.label,
|
|
1338
|
+
m.topic,
|
|
1339
|
+
vantage,
|
|
1340
|
+
m.requestId,
|
|
1341
|
+
m.seen,
|
|
1342
|
+
),
|
|
1095
1343
|
);
|
|
1096
1344
|
const id = groupId ?? `${this.idPrefix}-g${this.nextRequestId++}`;
|
|
1097
1345
|
this.transport.send({
|
|
@@ -1120,6 +1368,7 @@ export class TelemetryClient {
|
|
|
1120
1368
|
topic: string | undefined,
|
|
1121
1369
|
vantage: string | undefined,
|
|
1122
1370
|
requestIdOverride: string | undefined,
|
|
1371
|
+
seen: CommandSeen | undefined,
|
|
1123
1372
|
): {
|
|
1124
1373
|
requestId: string;
|
|
1125
1374
|
result: Promise<unknown>;
|
|
@@ -1165,10 +1414,11 @@ export class TelemetryClient {
|
|
|
1165
1414
|
// They are alternatives, never both: one source per deployment rather than two
|
|
1166
1415
|
// competing ones. See `Transport.predictConfirmEta` for the rule a new transport
|
|
1167
1416
|
// must follow.
|
|
1417
|
+
const sourceDelay = this.knownSourceDelay();
|
|
1168
1418
|
const predictedEta =
|
|
1169
1419
|
this.transport.predictConfirmEta?.() ??
|
|
1170
|
-
(
|
|
1171
|
-
? this.clock.now() + 2 *
|
|
1420
|
+
(sourceDelay !== undefined
|
|
1421
|
+
? this.clock.now() + 2 * sourceDelay
|
|
1172
1422
|
: undefined);
|
|
1173
1423
|
const etaConfirm = predictedEta ?? this.clock.now();
|
|
1174
1424
|
/*
|
|
@@ -1179,9 +1429,9 @@ export class TelemetryClient {
|
|
|
1179
1429
|
const dispatchUt = this.gameUtNow();
|
|
1180
1430
|
const delayDeadlineUt =
|
|
1181
1431
|
this.transport.predictConfirmEta?.() === undefined &&
|
|
1182
|
-
|
|
1432
|
+
sourceDelay !== undefined &&
|
|
1183
1433
|
dispatchUt !== undefined
|
|
1184
|
-
? dispatchUt + 2 *
|
|
1434
|
+
? dispatchUt + 2 * sourceDelay
|
|
1185
1435
|
: undefined;
|
|
1186
1436
|
if (predictedEta === undefined) this.warnNoLossDeadlineOnce();
|
|
1187
1437
|
const replyDueUt =
|
|
@@ -1203,6 +1453,8 @@ export class TelemetryClient {
|
|
|
1203
1453
|
unclaimable: false,
|
|
1204
1454
|
});
|
|
1205
1455
|
});
|
|
1456
|
+
/* Another screen sent it under its own id, and only that screen reloads and claims it. */
|
|
1457
|
+
if (requestIdOverride !== undefined) this.carriedForOther.add(requestId);
|
|
1206
1458
|
this.outstandingDirty = true;
|
|
1207
1459
|
this.dropOldestAnswered();
|
|
1208
1460
|
|
|
@@ -1219,6 +1471,19 @@ export class TelemetryClient {
|
|
|
1219
1471
|
}
|
|
1220
1472
|
}
|
|
1221
1473
|
|
|
1474
|
+
if (
|
|
1475
|
+
predictedEta === undefined &&
|
|
1476
|
+
pendingNow &&
|
|
1477
|
+
this.delaySource !== undefined
|
|
1478
|
+
) {
|
|
1479
|
+
pendingNow.awaitingDelay = { at: this.clock.now(), ut: dispatchUt };
|
|
1480
|
+
pendingNow.cancelLossTimer = this.clock.schedule(
|
|
1481
|
+
this.clock.now() + UNKNOWN_DELAY_LOSS_SECONDS,
|
|
1482
|
+
() => this.handleLoss(requestId),
|
|
1483
|
+
);
|
|
1484
|
+
this.awaitingDelayCount += 1;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1222
1487
|
this.notifyStore();
|
|
1223
1488
|
return {
|
|
1224
1489
|
requestId,
|
|
@@ -1231,7 +1496,7 @@ export class TelemetryClient {
|
|
|
1231
1496
|
topic: topic ?? "",
|
|
1232
1497
|
// Per-call vantage override (delay-UX): "" ⇒ the server uses the session vantage; "meta" pins a program-meta command to instant dispatch.
|
|
1233
1498
|
vantage: vantage ?? "",
|
|
1234
|
-
...
|
|
1499
|
+
...(seen ?? this.seen()),
|
|
1235
1500
|
args: wireArgs,
|
|
1236
1501
|
sentAt: 0,
|
|
1237
1502
|
},
|
|
@@ -1251,6 +1516,7 @@ export class TelemetryClient {
|
|
|
1251
1516
|
if (excess <= 0) return;
|
|
1252
1517
|
if (!FINAL_PHASES.has(pending.status.phase)) continue;
|
|
1253
1518
|
if (this.heldCommands.has(requestId)) continue;
|
|
1519
|
+
if (pending.awaitingDelay) this.awaitingDelayCount -= 1;
|
|
1254
1520
|
this.commands.delete(requestId);
|
|
1255
1521
|
excess -= 1;
|
|
1256
1522
|
}
|
|
@@ -1277,6 +1543,45 @@ export class TelemetryClient {
|
|
|
1277
1543
|
};
|
|
1278
1544
|
}
|
|
1279
1545
|
|
|
1546
|
+
/**
|
|
1547
|
+
* Reads the commands `carrier` dispatched as ones this screen follows, through
|
|
1548
|
+
* {@link getCarriedCommand}. Useful for a main screen whose stations' commands
|
|
1549
|
+
* leave through a connection of their own. Returns the release.
|
|
1550
|
+
*/
|
|
1551
|
+
carryCommandsFrom(carrier: TelemetryClient): () => void {
|
|
1552
|
+
if (carrier === this) return () => undefined;
|
|
1553
|
+
this.carriers.add(carrier);
|
|
1554
|
+
const stop = carrier.subscribeStore(() => {
|
|
1555
|
+
this.carriedRevision += 1;
|
|
1556
|
+
this.notifyStore();
|
|
1557
|
+
});
|
|
1558
|
+
this.carriedRevision += 1;
|
|
1559
|
+
this.notifyStore();
|
|
1560
|
+
return () => {
|
|
1561
|
+
stop();
|
|
1562
|
+
this.carriers.delete(carrier);
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/** Changes whenever a client this one carries commands from changes, so a reader of {@link getCarriedCommand} can tell. */
|
|
1567
|
+
carriedCommandsRevision(): number {
|
|
1568
|
+
return this.carriedRevision;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* The status of a command this client or a client it carries dispatched,
|
|
1573
|
+
* preferring this client's own record. `idle` when none holds it.
|
|
1574
|
+
*/
|
|
1575
|
+
getCarriedCommand(requestId: string): CommandStatus {
|
|
1576
|
+
const own = this.commands.get(requestId)?.status;
|
|
1577
|
+
if (own) return own;
|
|
1578
|
+
for (const carrier of this.carriers) {
|
|
1579
|
+
const status = carrier.commands.get(requestId)?.status;
|
|
1580
|
+
if (status) return status;
|
|
1581
|
+
}
|
|
1582
|
+
return UNKNOWN_COMMAND;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1280
1585
|
/** Current lifecycle status for a dispatched command, or `idle` if the client holds no record of it: it was never sent, or it was answered long enough ago to be dropped. */
|
|
1281
1586
|
getCommand(requestId: string): CommandStatus {
|
|
1282
1587
|
return this.commands.get(requestId)?.status ?? UNKNOWN_COMMAND;
|
|
@@ -1327,6 +1632,7 @@ export class TelemetryClient {
|
|
|
1327
1632
|
this.unownedListeners.clear();
|
|
1328
1633
|
this.subscriberLabels.clear();
|
|
1329
1634
|
this.commands.clear();
|
|
1635
|
+
this.awaitingDelayCount = 0;
|
|
1330
1636
|
this.stores.clear();
|
|
1331
1637
|
}
|
|
1332
1638
|
|
|
@@ -1336,21 +1642,70 @@ export class TelemetryClient {
|
|
|
1336
1642
|
* no stamp at all (a transport with nothing to say about vantage) changes
|
|
1337
1643
|
* nothing, and the mod's empty stamp clears it: no centre is active yet.
|
|
1338
1644
|
*/
|
|
1339
|
-
private noteObservedVantage(
|
|
1645
|
+
private noteObservedVantage(meta: Meta): void {
|
|
1646
|
+
const vantage = meta.vantage;
|
|
1340
1647
|
if (vantage === undefined || vantage === META_VANTAGE) return;
|
|
1648
|
+
/*
|
|
1649
|
+
* A host replays a quiet Topic's older frames after its newest, to a
|
|
1650
|
+
* station that has just joined, so a frame can arrive stamped from a
|
|
1651
|
+
* centre the session has since left. Only a frame from the same or a later
|
|
1652
|
+
* timeline epoch, and delivered no earlier than the one that set the
|
|
1653
|
+
* vantage within an epoch, may change it.
|
|
1654
|
+
*/
|
|
1655
|
+
const prior = this.observedStampedAt;
|
|
1656
|
+
if (
|
|
1657
|
+
prior !== undefined &&
|
|
1658
|
+
(meta.timelineEpoch < prior.epoch ||
|
|
1659
|
+
(prior.epoch === meta.timelineEpoch &&
|
|
1660
|
+
meta.deliveredAt < prior.deliveredAt))
|
|
1661
|
+
) {
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1664
|
+
const stamp = { epoch: meta.timelineEpoch, deliveredAt: meta.deliveredAt };
|
|
1341
1665
|
// The mod's empty stamp says no command centre is active, so the earlier centre no longer describes what arrives.
|
|
1342
1666
|
if (vantage === "") {
|
|
1667
|
+
this.observedStampedAt = stamp;
|
|
1343
1668
|
if (this.observedVantageId === undefined) return;
|
|
1344
1669
|
this.observedVantageId = undefined;
|
|
1345
|
-
|
|
1670
|
+
this.notifyObservedVantage();
|
|
1346
1671
|
return;
|
|
1347
1672
|
}
|
|
1673
|
+
this.observedStampedAt = stamp;
|
|
1348
1674
|
if (vantage === this.observedVantageId) return;
|
|
1349
1675
|
this.observedVantageId = vantage;
|
|
1676
|
+
this.notifyObservedVantage();
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
private notifyObservedVantage(): void {
|
|
1350
1680
|
for (const listener of this.observedVantageListeners) listener();
|
|
1681
|
+
// A following connection's selection is the observed one.
|
|
1682
|
+
if (this.followingActiveCraft) {
|
|
1683
|
+
for (const listener of this.vantageListeners) listener();
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Put back the fields a frame left out as unchanged, from the last frame of its
|
|
1689
|
+
* Topic this connection delivered, so every reader past this point sees a whole
|
|
1690
|
+
* payload.
|
|
1691
|
+
*/
|
|
1692
|
+
private restoreUnchanged(message: StreamData<unknown>): void {
|
|
1693
|
+
const { unchanged } = message;
|
|
1694
|
+
if (unchanged !== undefined && unchanged.length > 0) {
|
|
1695
|
+
fillUnchangedFields(
|
|
1696
|
+
message.payload,
|
|
1697
|
+
unchanged,
|
|
1698
|
+
this.lastDeliveredWithHeldFields.get(message.topic),
|
|
1699
|
+
);
|
|
1700
|
+
message.unchanged = undefined;
|
|
1701
|
+
}
|
|
1702
|
+
if (fieldsSentOnChange(message.topic).length > 0) {
|
|
1703
|
+
this.lastDeliveredWithHeldFields.set(message.topic, message.payload);
|
|
1704
|
+
}
|
|
1351
1705
|
}
|
|
1352
1706
|
|
|
1353
1707
|
private handleMessage(message: ServerMessage, replayed = false): void {
|
|
1708
|
+
if (this.awaitingDelayCount > 0) this.timeCommandsAwaitingDelay();
|
|
1354
1709
|
if (message.type === "command-response") {
|
|
1355
1710
|
this.handleCommandResponse(message.requestId, message.result);
|
|
1356
1711
|
return;
|
|
@@ -1409,6 +1764,7 @@ export class TelemetryClient {
|
|
|
1409
1764
|
}
|
|
1410
1765
|
if (message.type === "game-state") {
|
|
1411
1766
|
this.gameState = { state: message.state, scene: message.scene };
|
|
1767
|
+
this.noteLoading(message.state === "loading");
|
|
1412
1768
|
for (const store of this.stores) {
|
|
1413
1769
|
store.setGameState(message.state, message.scene);
|
|
1414
1770
|
}
|
|
@@ -1418,6 +1774,15 @@ export class TelemetryClient {
|
|
|
1418
1774
|
// branch existed, which is why the mod's own answer to "does anything
|
|
1419
1775
|
// publish this topic" reached nothing that could use it.
|
|
1420
1776
|
if (message.type === "event") {
|
|
1777
|
+
if (message.name === "timeline-reset") {
|
|
1778
|
+
const kept: unknown = message.keptThroughUt;
|
|
1779
|
+
for (const store of this.stores) {
|
|
1780
|
+
store.noteTimelineReset(
|
|
1781
|
+
message.topic,
|
|
1782
|
+
typeof kept === "number" ? kept : undefined,
|
|
1783
|
+
);
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1421
1786
|
if (message.name === "subscribed") {
|
|
1422
1787
|
this.ownership?.noteAck(message.topic);
|
|
1423
1788
|
/* An ack can arrive after the window that called the topic unowned, and it is the mod's own answer. */
|
|
@@ -1467,6 +1832,7 @@ export class TelemetryClient {
|
|
|
1467
1832
|
const epoch = meta.timelineEpoch ?? 0;
|
|
1468
1833
|
const vantage = meta.vantage ?? "";
|
|
1469
1834
|
const prior = this.newestRaw.get(topic);
|
|
1835
|
+
if (prior !== undefined && prior.epoch > epoch) return false;
|
|
1470
1836
|
if (
|
|
1471
1837
|
prior !== undefined &&
|
|
1472
1838
|
prior.epoch === epoch &&
|
|
@@ -1485,7 +1851,7 @@ export class TelemetryClient {
|
|
|
1485
1851
|
meta: Meta,
|
|
1486
1852
|
replayed: boolean,
|
|
1487
1853
|
): void {
|
|
1488
|
-
this.noteObservedVantage(meta
|
|
1854
|
+
this.noteObservedVantage(meta);
|
|
1489
1855
|
this.noteGameUt(meta, replayed);
|
|
1490
1856
|
const newest = this.isNewestRaw(topic, meta);
|
|
1491
1857
|
/* A replay included: whether the game is paused is a state, and a station's link back to the main screen hands over the current one as replayed history. */
|
|
@@ -1573,8 +1939,16 @@ export class TelemetryClient {
|
|
|
1573
1939
|
knownOneWay !== undefined && nowUt !== undefined
|
|
1574
1940
|
? nowUt + 2 * knownOneWay
|
|
1575
1941
|
: undefined;
|
|
1576
|
-
if (
|
|
1577
|
-
pending.status =
|
|
1942
|
+
if (pending.status.phase === "in-flight") {
|
|
1943
|
+
pending.status = warning
|
|
1944
|
+
? { ...pending.status, accepted: true, warning }
|
|
1945
|
+
: { ...pending.status, accepted: true };
|
|
1946
|
+
}
|
|
1947
|
+
if (gameDeadlineUt !== undefined || roundTrip !== undefined) {
|
|
1948
|
+
if (pending.awaitingDelay) {
|
|
1949
|
+
pending.awaitingDelay = undefined;
|
|
1950
|
+
this.awaitingDelayCount -= 1;
|
|
1951
|
+
}
|
|
1578
1952
|
}
|
|
1579
1953
|
if (gameDeadlineUt !== undefined) {
|
|
1580
1954
|
pending.gameDeadlineUt = gameDeadlineUt;
|
|
@@ -1606,6 +1980,38 @@ export class TelemetryClient {
|
|
|
1606
1980
|
this.notifyStore();
|
|
1607
1981
|
}
|
|
1608
1982
|
|
|
1983
|
+
/**
|
|
1984
|
+
* Gives each command sent while the delay was unknown its loss deadline, worked
|
|
1985
|
+
* from the moment it was dispatched, as soon as the delay source has a figure.
|
|
1986
|
+
*/
|
|
1987
|
+
private timeCommandsAwaitingDelay(): void {
|
|
1988
|
+
const sourceDelay = this.knownSourceDelay();
|
|
1989
|
+
if (sourceDelay === undefined) return;
|
|
1990
|
+
let changed = false;
|
|
1991
|
+
for (const [requestId, pending] of this.commands) {
|
|
1992
|
+
const waiting = pending.awaitingDelay;
|
|
1993
|
+
if (!waiting) continue;
|
|
1994
|
+
pending.awaitingDelay = undefined;
|
|
1995
|
+
this.awaitingDelayCount -= 1;
|
|
1996
|
+
if (!pending.resolve || pending.status.phase !== "in-flight") continue;
|
|
1997
|
+
changed = true;
|
|
1998
|
+
this.outstandingDirty = true;
|
|
1999
|
+
if (waiting.ut !== undefined) {
|
|
2000
|
+
pending.gameDeadlineUt = waiting.ut + 2 * sourceDelay;
|
|
2001
|
+
pending.replyDueUt = pending.gameDeadlineUt;
|
|
2002
|
+
if (this.placeGameDeadline(requestId, pending)) continue;
|
|
2003
|
+
}
|
|
2004
|
+
pending.cancelLossTimer?.();
|
|
2005
|
+
const dueAt = waiting.at + 2 * sourceDelay;
|
|
2006
|
+
pending.etaConfirm = dueAt;
|
|
2007
|
+
pending.status = { ...pending.status, etaConfirm: dueAt };
|
|
2008
|
+
pending.cancelLossTimer = this.clock.schedule(dueAt + LOSS_MARGIN, () =>
|
|
2009
|
+
this.handleLoss(requestId),
|
|
2010
|
+
);
|
|
2011
|
+
}
|
|
2012
|
+
if (changed) this.notifyStore();
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1609
2015
|
/**
|
|
1610
2016
|
* The game's UT now, carried forward on the client's clock from the newest
|
|
1611
2017
|
* frame. `undefined` until a frame has arrived.
|
|
@@ -1613,7 +2019,7 @@ export class TelemetryClient {
|
|
|
1613
2019
|
private gameUtNow(): number | undefined {
|
|
1614
2020
|
const anchor = this.gameClock;
|
|
1615
2021
|
if (!anchor) return undefined;
|
|
1616
|
-
if (this.gamePaused) return anchor.ut;
|
|
2022
|
+
if (this.gamePaused || this.gameLoading) return anchor.ut;
|
|
1617
2023
|
return anchor.ut + (this.clock.now() - anchor.at);
|
|
1618
2024
|
}
|
|
1619
2025
|
|
|
@@ -1642,6 +2048,181 @@ export class TelemetryClient {
|
|
|
1642
2048
|
this.gamePaused = paused;
|
|
1643
2049
|
}
|
|
1644
2050
|
|
|
2051
|
+
/**
|
|
2052
|
+
* Gives a live sample the timeline epoch the client holds it under.
|
|
2053
|
+
*
|
|
2054
|
+
* A quickload or revert starts a new timeline, which the mod announces with
|
|
2055
|
+
* a higher epoch. When a load was seen and the next live sample's UT is
|
|
2056
|
+
* behind the game's UT already seen on the same epoch, no epoch came, and
|
|
2057
|
+
* the sample is the new timeline: the client bumps its own epoch so every
|
|
2058
|
+
* store and the view clock drop the abandoned one. The game's own load is
|
|
2059
|
+
* what tells this apart from samples that merely arrive out of order within
|
|
2060
|
+
* one timeline, which are still refused. A later epoch from the mod is
|
|
2061
|
+
* absorbed into the shift so the two never add up.
|
|
2062
|
+
*/
|
|
2063
|
+
private followRewind(message: ServerMessage): ServerMessage {
|
|
2064
|
+
if (message.type !== "stream-data" && message.type !== "stream-binary") {
|
|
2065
|
+
return message;
|
|
2066
|
+
}
|
|
2067
|
+
const meta = message.meta;
|
|
2068
|
+
const wire = meta.timelineEpoch ?? 0;
|
|
2069
|
+
this.absorbWireEpoch(wire);
|
|
2070
|
+
let epoch = wire + this.epochShift;
|
|
2071
|
+
/*
|
|
2072
|
+
* Behind what has actually been delivered on this timeline, not behind the
|
|
2073
|
+
* clock's estimate of the game's UT. The estimate runs on through a dialog
|
|
2074
|
+
* or a scene load the game spends paused, such as a switch of craft, so the
|
|
2075
|
+
* first frame after one would read as a rewind and empty every Topic.
|
|
2076
|
+
*/
|
|
2077
|
+
const delivered = this.newestDelivered;
|
|
2078
|
+
/*
|
|
2079
|
+
* A reading delivered from a craft's own node arrives on that craft's clock,
|
|
2080
|
+
* after its own delay, so it can trail frames already delivered without any
|
|
2081
|
+
* rewind. A rewind takes every Topic back, so the frames the mod sends from
|
|
2082
|
+
* its own nodes are enough to tell one.
|
|
2083
|
+
*/
|
|
2084
|
+
const fromACraftsNode =
|
|
2085
|
+
typeof meta.source === "string" &&
|
|
2086
|
+
meta.source.startsWith(CRAFT_NODE_SOURCE_PREFIX);
|
|
2087
|
+
/*
|
|
2088
|
+
* The mod numbers frames in the order it builds them, and can send one built
|
|
2089
|
+
* earlier after one built later. A frame built before the newest delivered
|
|
2090
|
+
* one was built before any load that frame could have come after, so it is
|
|
2091
|
+
* not a rewind however far behind its stamp is.
|
|
2092
|
+
*/
|
|
2093
|
+
const builtEarlier =
|
|
2094
|
+
Number.isFinite(meta.seq) &&
|
|
2095
|
+
delivered?.seq !== undefined &&
|
|
2096
|
+
meta.seq < delivered.seq;
|
|
2097
|
+
const behind =
|
|
2098
|
+
!fromACraftsNode &&
|
|
2099
|
+
!builtEarlier &&
|
|
2100
|
+
delivered !== undefined &&
|
|
2101
|
+
epoch === delivered.epoch &&
|
|
2102
|
+
Number.isFinite(meta.deliveredAt) &&
|
|
2103
|
+
meta.deliveredAt < delivered.ut - REWIND_TOLERANCE_SECONDS;
|
|
2104
|
+
const rewound = this.loadSinceLastSample && behind;
|
|
2105
|
+
if (rewound) {
|
|
2106
|
+
this.epochShift += 1;
|
|
2107
|
+
epoch += 1;
|
|
2108
|
+
/* Every Topic starts again on a rewind, so the frame that made the call is named, to be found when one was not a rewind at all. */
|
|
2109
|
+
console.warn(
|
|
2110
|
+
`[sitrep] read a load as a rewind from ${message.topic} (source ${String(meta.source)}, ` +
|
|
2111
|
+
`valid at ${meta.validAt}, delivered at ${meta.deliveredAt}, ` +
|
|
2112
|
+
`behind ${delivered?.ut} delivered on this timeline); every Topic starts again.`,
|
|
2113
|
+
);
|
|
2114
|
+
}
|
|
2115
|
+
if (
|
|
2116
|
+
Number.isFinite(meta.deliveredAt) &&
|
|
2117
|
+
(delivered === undefined ||
|
|
2118
|
+
epoch !== delivered.epoch ||
|
|
2119
|
+
meta.deliveredAt > delivered.ut)
|
|
2120
|
+
) {
|
|
2121
|
+
this.newestDelivered = {
|
|
2122
|
+
ut: meta.deliveredAt,
|
|
2123
|
+
epoch,
|
|
2124
|
+
seq: Number.isFinite(meta.seq) ? meta.seq : undefined,
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
if (rewound || (!this.gameLoading && !behind)) {
|
|
2128
|
+
this.loadSinceLastSample = false;
|
|
2129
|
+
}
|
|
2130
|
+
if (epoch === wire) return message;
|
|
2131
|
+
return { ...message, meta: { ...meta, timelineEpoch: epoch } };
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
/**
|
|
2135
|
+
* Learns the mod's run and timeline from the frames that carry them outside a
|
|
2136
|
+
* sample. A quiet connection hears no stream data after a load, so without
|
|
2137
|
+
* these it would send the old timeline forever and have its commands refused.
|
|
2138
|
+
* Replayed frames count: a late station hears the game's state only that way.
|
|
2139
|
+
*/
|
|
2140
|
+
private followTimeline(message: ServerMessage): void {
|
|
2141
|
+
if (message.type === "hello" || message.type === "game-state") {
|
|
2142
|
+
this.adoptRun(message.bootId);
|
|
2143
|
+
this.absorbWireEpoch(message.timelineEpoch ?? 0);
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
if (message.type === "event" && message.name === "timeline-reset") {
|
|
2147
|
+
this.absorbWireEpoch(message.meta.timelineEpoch ?? 0);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/** A new run counts its epochs from zero again, so nothing kept from the old one can be compared with them. */
|
|
2152
|
+
private adoptRun(bootId: string | undefined): void {
|
|
2153
|
+
if (!bootId || bootId === this.wireBootId) return;
|
|
2154
|
+
const restarted = this.wireBootId !== "";
|
|
2155
|
+
this.wireBootId = bootId;
|
|
2156
|
+
if (!restarted) return;
|
|
2157
|
+
this.lastWireEpoch = 0;
|
|
2158
|
+
this.epochShift = 0;
|
|
2159
|
+
this.notifyTimeline();
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
/** Takes a wire epoch, absorbing a rewind the client had inferred for itself into the shift so the two never add up. */
|
|
2163
|
+
private absorbWireEpoch(wire: number): void {
|
|
2164
|
+
if (wire <= this.lastWireEpoch) return;
|
|
2165
|
+
this.epochShift = Math.max(
|
|
2166
|
+
0,
|
|
2167
|
+
this.epochShift - (wire - this.lastWireEpoch),
|
|
2168
|
+
);
|
|
2169
|
+
this.lastWireEpoch = wire;
|
|
2170
|
+
/*
|
|
2171
|
+
* The mod has announced the timeline the load started, so the load needs no
|
|
2172
|
+
* inferring. Left set, a frame delayed to an earlier UT than another on the
|
|
2173
|
+
* new epoch reads as a second rewind and the client ends one epoch ahead of
|
|
2174
|
+
* every frame the mod sends.
|
|
2175
|
+
*/
|
|
2176
|
+
this.loadSinceLastSample = false;
|
|
2177
|
+
this.notifyTimeline();
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
private notifyTimeline(): void {
|
|
2181
|
+
for (const listener of this.timelineListeners) listener();
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
/** The raw timeline epoch this screen last received from the mod, as a command sends it. */
|
|
2185
|
+
get wireEpoch(): number {
|
|
2186
|
+
return this.lastWireEpoch;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
/** Calls `fn` once `seconds` have passed on this client's clock. Returns a function that cancels it. */
|
|
2190
|
+
scheduleAfter(seconds: number, fn: () => void): () => void {
|
|
2191
|
+
return this.clock.schedule(this.clock.now() + seconds, fn);
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
/** Calls `listener` whenever {@link wireEpoch} changes. Returns a function that stops it. */
|
|
2195
|
+
onTimelineChange(listener: () => void): () => void {
|
|
2196
|
+
this.timelineListeners.add(listener);
|
|
2197
|
+
return () => {
|
|
2198
|
+
this.timelineListeners.delete(listener);
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/** What this screen has last received from the mod, as a command frame carries it. */
|
|
2203
|
+
private seen(): CommandSeen {
|
|
2204
|
+
return {
|
|
2205
|
+
seenBootId: this.wireBootId,
|
|
2206
|
+
seenEpoch: this.lastWireEpoch,
|
|
2207
|
+
...seenVessel(
|
|
2208
|
+
this.lastValues.get("vessel.identity"),
|
|
2209
|
+
this.lastValues.has("vessel.identity"),
|
|
2210
|
+
),
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
/** Holds the game's UT still from the moment a load starts and lets it run again from there when it ends. */
|
|
2215
|
+
private noteLoading(loading: boolean): void {
|
|
2216
|
+
if (loading === this.gameLoading) return;
|
|
2217
|
+
if (loading) this.loadSinceLastSample = true;
|
|
2218
|
+
const anchor = this.gameClock;
|
|
2219
|
+
const ut = this.gameUtNow();
|
|
2220
|
+
if (anchor && ut !== undefined) {
|
|
2221
|
+
this.gameClock = { ut, at: this.clock.now(), epoch: anchor.epoch };
|
|
2222
|
+
}
|
|
2223
|
+
this.gameLoading = loading;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
1645
2226
|
/** The UT a pause began at: the record's own, never earlier than the estimate on the same timeline. */
|
|
1646
2227
|
private pausedAtUt(
|
|
1647
2228
|
anchor: { ut: number; epoch: number },
|
|
@@ -1681,6 +2262,8 @@ export class TelemetryClient {
|
|
|
1681
2262
|
/* A new timeline has its own pause state, which its own `time.warp` will say. */
|
|
1682
2263
|
if (prior && epoch > prior.epoch) this.gamePaused = false;
|
|
1683
2264
|
this.gameClock = { ut, at: this.clock.now(), epoch };
|
|
2265
|
+
/* The deadlines of commands in flight are in the old timeline's UT, so the mod is asked what became of them. */
|
|
2266
|
+
if (prior && epoch > prior.epoch) this.scheduleClaim();
|
|
1684
2267
|
if (prior) return;
|
|
1685
2268
|
let placed = false;
|
|
1686
2269
|
for (const [requestId, pending] of this.commands) {
|
|
@@ -1741,14 +2324,14 @@ export class TelemetryClient {
|
|
|
1741
2324
|
* The reading of the client's clock at which a command's deadline in game UT
|
|
1742
2325
|
* and its margin run out, were the game to run at normal speed from the
|
|
1743
2326
|
* newest frame. Worked from that frame's own reading, so a deadline a whole
|
|
1744
|
-
* number of seconds away lands on one. Infinite while the game is paused, so
|
|
2327
|
+
* number of seconds away lands on one. Infinite while the game is paused or loading, so
|
|
1745
2328
|
* the timer keeps rechecking rather than spending the deadline on the pause.
|
|
1746
2329
|
*/
|
|
1747
2330
|
private clockTimeOfLoss(pending: PendingCommand): number | undefined {
|
|
1748
2331
|
const anchor = this.gameClock;
|
|
1749
2332
|
const dueUt = pending.gameDeadlineUt;
|
|
1750
2333
|
if (!anchor || dueUt === undefined) return undefined;
|
|
1751
|
-
if (this.gamePaused) return Number.POSITIVE_INFINITY;
|
|
2334
|
+
if (this.gamePaused || this.gameLoading) return Number.POSITIVE_INFINITY;
|
|
1752
2335
|
return anchor.at + (dueUt + LOSS_MARGIN - anchor.ut);
|
|
1753
2336
|
}
|
|
1754
2337
|
|