@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/use-command.ts
CHANGED
|
@@ -15,13 +15,17 @@ import {
|
|
|
15
15
|
classifyCommandRejection,
|
|
16
16
|
} from "../api/command-rejection";
|
|
17
17
|
import type {
|
|
18
|
+
BoundCommand,
|
|
19
|
+
BoundCommandOptions,
|
|
18
20
|
CommandFailure,
|
|
19
21
|
CommandFound,
|
|
20
22
|
CommandLoss,
|
|
21
23
|
CommandRefusal,
|
|
22
24
|
CommandStatus,
|
|
23
25
|
CommandUndelivered,
|
|
26
|
+
CommandWarning,
|
|
24
27
|
UseCommandOptions,
|
|
28
|
+
ValueCommand,
|
|
25
29
|
} from "../api/types";
|
|
26
30
|
import {
|
|
27
31
|
type CommsDelayLike,
|
|
@@ -38,23 +42,43 @@ import type {
|
|
|
38
42
|
CommandId,
|
|
39
43
|
CommandReply,
|
|
40
44
|
} from "../commands";
|
|
45
|
+
import { commandRail } from "../commands";
|
|
41
46
|
import type { RailTags } from "../rail-tags";
|
|
42
47
|
import { railTagsForCommand } from "../rail-tags";
|
|
43
|
-
import { type Reading, readingOf
|
|
48
|
+
import { type Reading, readingOf } from "../reading";
|
|
44
49
|
import type { Value } from "../unit-system";
|
|
50
|
+
import { value } from "../unit-system/value";
|
|
45
51
|
import {
|
|
52
|
+
arrivalUtAfter,
|
|
46
53
|
arrivalUtOf,
|
|
47
54
|
arrivesTooLate,
|
|
48
55
|
LATE_ARRIVAL_DETAIL,
|
|
49
56
|
LATE_ARRIVAL_ERROR_CODE,
|
|
50
57
|
} from "./arrival-deadline";
|
|
58
|
+
import { bindCommand, bindValue } from "./bound-command";
|
|
59
|
+
import {
|
|
60
|
+
carriesCommand,
|
|
61
|
+
centreCommandOutcomes,
|
|
62
|
+
centreCommandRows,
|
|
63
|
+
centreRowId,
|
|
64
|
+
createCentreCommandMemory,
|
|
65
|
+
dismissCentreOutcome,
|
|
66
|
+
} from "./centre-commands";
|
|
51
67
|
import {
|
|
52
68
|
type CommandGateStatus,
|
|
53
69
|
hasItemVerdict,
|
|
70
|
+
mergeGateReports,
|
|
54
71
|
selectCommandGate,
|
|
55
72
|
toGateStatus,
|
|
56
73
|
} from "./command-gate";
|
|
57
74
|
import { openCommandGroup } from "./command-group";
|
|
75
|
+
import {
|
|
76
|
+
activeVesselIdOf,
|
|
77
|
+
type CommandOutcomeSet,
|
|
78
|
+
commandOutcomesOf,
|
|
79
|
+
NO_OUTCOMES,
|
|
80
|
+
} from "./command-outcomes";
|
|
81
|
+
import { JOURNEY_TOPIC, readJourney } from "./comms-journey";
|
|
58
82
|
import { ROUTE_TOPIC, readRouteRows } from "./comms-route";
|
|
59
83
|
import {
|
|
60
84
|
type CommsLinkLike,
|
|
@@ -64,27 +88,39 @@ import {
|
|
|
64
88
|
useTelemetryClientOptional,
|
|
65
89
|
useTelemetryStoreOptional,
|
|
66
90
|
} from "./context";
|
|
91
|
+
import { CENTRE_DELAY_TOPIC, IDENTITY_TOPIC } from "./delay-authority";
|
|
92
|
+
import { useDelayAuthorityOptional } from "./delay-authority-context";
|
|
67
93
|
import {
|
|
68
94
|
GATE_CHECK_COMMAND,
|
|
69
95
|
GATE_CHECK_DEBOUNCE_MS,
|
|
70
96
|
gateCheckKey,
|
|
71
97
|
readGateCheckReply,
|
|
72
98
|
} from "./gate-check";
|
|
99
|
+
import { queueAsKnown } from "./known-holds";
|
|
73
100
|
import { CommandError } from "./lifecycle";
|
|
74
101
|
import { useClaimCapability } from "./lock-scope";
|
|
75
102
|
import { commandDelayed } from "./map-command";
|
|
76
103
|
import { useRailRegistry } from "./rail-registry";
|
|
77
|
-
import {
|
|
104
|
+
import {
|
|
105
|
+
type PendingUplinkQueueLike,
|
|
106
|
+
resolveTracked,
|
|
107
|
+
type TrackedConfirmation,
|
|
108
|
+
} from "./resolve-tracked";
|
|
78
109
|
import {
|
|
79
110
|
readNextLossUt,
|
|
80
111
|
type SendStatus,
|
|
81
112
|
sendStatusFromRoutes,
|
|
82
113
|
} from "./send-status";
|
|
114
|
+
import {
|
|
115
|
+
type CommandTarget,
|
|
116
|
+
commandTargetOf,
|
|
117
|
+
UPLINK_DELAYS_TOPIC,
|
|
118
|
+
} from "./uplink-delays";
|
|
83
119
|
import { useLatestValue, useStream } from "./use-stream";
|
|
120
|
+
import { useStreamConnected } from "./use-stream-connected";
|
|
84
121
|
import { META_VANTAGE } from "./vantage";
|
|
85
122
|
|
|
86
123
|
export type { UseCommandOptions };
|
|
87
|
-
export { META_VANTAGE };
|
|
88
124
|
|
|
89
125
|
/** Shared constant so `getSnapshot` returns a referentially stable value when
|
|
90
126
|
* no command has been dispatched yet, a fresh object literal here would
|
|
@@ -97,23 +133,10 @@ const IDLE: CommandStatus = { phase: "idle" };
|
|
|
97
133
|
* in-flight, or every consumer re-renders needlessly. */
|
|
98
134
|
const NO_IN_FLIGHT: InFlightCommand[] = [];
|
|
99
135
|
|
|
100
|
-
|
|
101
|
-
* consumer of a hook that has refused nothing, which is nearly all of them. */
|
|
102
|
-
const NO_REFUSALS: CommandRefusal[] = [];
|
|
103
|
-
|
|
104
|
-
/** Same reason as `NO_REFUSALS`. */
|
|
105
|
-
const NO_LOSSES: CommandLoss[] = [];
|
|
136
|
+
const NO_SUBSCRIBE = () => () => {};
|
|
106
137
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
const NO_FOUNDS: CommandFound[] = [];
|
|
110
|
-
|
|
111
|
-
/** Same reason as `NO_REFUSALS`. Empty unless a transport gave up on a link
|
|
112
|
-
* entirely, which is once per outage that never ends. */
|
|
113
|
-
const NO_UNDELIVERED: CommandUndelivered[] = [];
|
|
114
|
-
|
|
115
|
-
/** Same reason as `NO_REFUSALS`. Empty unless the mod answered a dispatch with a fault. */
|
|
116
|
-
const NO_FAILURES: CommandFailure[] = [];
|
|
138
|
+
/** A fresh `[]` per render would re-render every consumer of a hook that has no warning, which is nearly all of them. */
|
|
139
|
+
const NO_WARNINGS: CommandWarning[] = [];
|
|
117
140
|
|
|
118
141
|
const MOD_FAULTS: ReadonlySet<string> = new Set(
|
|
119
142
|
CORE_ERROR_CODES.filter((d) => d.kind === "fault" && d.origin === "mod").map(
|
|
@@ -126,6 +149,16 @@ function isModFault(code: string): boolean {
|
|
|
126
149
|
return MOD_FAULTS.has(code);
|
|
127
150
|
}
|
|
128
151
|
|
|
152
|
+
/**
|
|
153
|
+
* The delay, in seconds, below which a likely refusal stops the press at the
|
|
154
|
+
* control. A verdict held for less than this is as good as the game's own
|
|
155
|
+
* answer; one held for this long or longer is advice and the press is sent. Zero
|
|
156
|
+
* delay counts as below it. Used by {@link useCommand}.
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
export const GATE_STOPS_PRESS_BELOW_SECONDS = 5;
|
|
161
|
+
|
|
129
162
|
/**
|
|
130
163
|
* The dispatch handle: send the command, read its status, and see the commands
|
|
131
164
|
* still in flight. Useful for showing the operator whether a command has been
|
|
@@ -139,47 +172,94 @@ function isModFault(code: string): boolean {
|
|
|
139
172
|
* such floor and stays `unknown`, because there is nothing every command's
|
|
140
173
|
* arguments have in common.
|
|
141
174
|
*
|
|
142
|
-
* `
|
|
175
|
+
* `dangerouslySendWithoutInput` is declared method-style rather than as a property holding a function.
|
|
143
176
|
* That is what makes a typed handle assignable to the bare `UseCommandResult` that
|
|
144
177
|
* every delay-rail control takes. As a property, `strictFunctionTypes` checks the
|
|
145
178
|
* parameter contravariantly and a typed handle would no longer be assignable.
|
|
146
179
|
*/
|
|
147
180
|
export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
148
181
|
/**
|
|
149
|
-
* Sends
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
182
|
+
* Sends this command with no kit input drawing it, so nothing on screen shows
|
|
183
|
+
* the operator that it was sent except the panel's delay rail. Useful for a
|
|
184
|
+
* send that no kit input starts, such as a price query, a background sync or
|
|
185
|
+
* typed text in a script terminal. Used by a script terminal and by the
|
|
186
|
+
* maneuver planner when it removes a completed node.
|
|
187
|
+
*
|
|
188
|
+
* A control the operator presses takes the command through its `command` prop
|
|
189
|
+
* instead: pass {@link with} or {@link toArgs} to a {@link Button}, a
|
|
190
|
+
* {@link Slider} or another kit input, which then draws sent, refused and the
|
|
191
|
+
* rest. A key or serial binding presses a {@link useCommandControl}.
|
|
192
|
+
*
|
|
193
|
+
* Resolves with the reply once the command has run. Rejects when the game
|
|
194
|
+
* refuses it, and when no reply arrives by the expected time. A refusal or loss
|
|
195
|
+
* from a call whose promise nobody awaits is still recorded in `refusals` or
|
|
196
|
+
* `losses`.
|
|
153
197
|
*
|
|
154
198
|
* `opts.label` is a description of this dispatch to show the operator.
|
|
155
199
|
* `opts.topic` addresses the command to one part or route on the craft, such
|
|
156
200
|
* as one script terminal.
|
|
157
201
|
*/
|
|
158
|
-
|
|
202
|
+
dangerouslySendWithoutInput(
|
|
203
|
+
args?: Args,
|
|
204
|
+
opts?: { label?: string; topic?: string },
|
|
205
|
+
): Promise<Reply>;
|
|
206
|
+
/**
|
|
207
|
+
* This command with its arguments set, for a kit input to send when the
|
|
208
|
+
* operator presses it. Useful for naming what one control sends and what
|
|
209
|
+
* happens around the press. Taken by the `command` prop of a kit input such
|
|
210
|
+
* as a button. `args` may be a function, called at the press, for arguments
|
|
211
|
+
* that change while the control waits.
|
|
212
|
+
*/
|
|
213
|
+
with(
|
|
214
|
+
args?: Args | (() => Args),
|
|
215
|
+
options?: BoundCommandOptions<Args, Reply>,
|
|
216
|
+
): BoundCommand<Args, Reply>;
|
|
217
|
+
/**
|
|
218
|
+
* This command with a way to turn an input's value into its arguments, for
|
|
219
|
+
* an input that sets a value. Useful for a toggle, a stepper or a field.
|
|
220
|
+
* Taken by the `command` prop of a kit input that sets a value. Return
|
|
221
|
+
* `undefined` where there is nothing to send.
|
|
222
|
+
*/
|
|
223
|
+
toArgs<Value>(
|
|
224
|
+
toArgs: (value: Value) => Args | undefined,
|
|
225
|
+
options?: BoundCommandOptions<Args, Reply>,
|
|
226
|
+
): ValueCommand<Value, Args, Reply>;
|
|
159
227
|
/** The state of the latest dispatch. See {@link CommandStatus}. */
|
|
160
228
|
status: CommandStatus;
|
|
161
229
|
/**
|
|
162
|
-
* Every dispatch
|
|
163
|
-
*
|
|
164
|
-
* on
|
|
230
|
+
* Every dispatch of this command still travelling or awaiting its reply,
|
|
231
|
+
* from this handle and from anyone else at the same command centre: another
|
|
232
|
+
* screen, or another widget on this one. An entry that is overdue or lost
|
|
233
|
+
* stays until dismissed; one that has arrived on a connected path is dropped.
|
|
165
234
|
*/
|
|
166
235
|
inFlight: InFlightCommand[];
|
|
236
|
+
/**
|
|
237
|
+
* What the mod said of each dispatch of this command that it accepted with a
|
|
238
|
+
* warning, such as a continuous input it will drop where it would have to
|
|
239
|
+
* wait: from this handle while it is in flight, and from any other screen or
|
|
240
|
+
* widget at the same command centre while it is on the centre's queue.
|
|
241
|
+
*/
|
|
242
|
+
warnings: CommandWarning[];
|
|
167
243
|
/**
|
|
168
244
|
* How the command travels, as its Uplink declared it. {@link CommandDelay}
|
|
169
245
|
* chooses how to draw the command from these.
|
|
170
246
|
*/
|
|
171
247
|
tags: RailTags;
|
|
172
248
|
/**
|
|
173
|
-
* The
|
|
174
|
-
* never-delayed sim-meta command (`time.*`)
|
|
175
|
-
*
|
|
249
|
+
* The one-way delay from the command centre the command is sent from to the
|
|
250
|
+
* command's own target: `0` for a never-delayed sim-meta command (`time.*`)
|
|
251
|
+
* and `0` at the meta-vantage, both instant by construction. For a command to
|
|
252
|
+
* the active craft it is that centre's delay to the craft; for one to
|
|
253
|
+
* anything else (the home command, a lens, another craft) it is the delay the
|
|
254
|
+
* mod reports for that target on `system.uplink.delays`.
|
|
176
255
|
* `<CommandDelay>` renders nothing at 0.
|
|
177
256
|
*
|
|
178
|
-
* `null`
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
257
|
+
* `null` wherever the delay to the target is not known: no measurable path,
|
|
258
|
+
* a change of craft whose new delay has not arrived, a target named by an
|
|
259
|
+
* argument, or no reading at all. It is never 0 for those, and never the
|
|
260
|
+
* delay to some other target. A 0 says the command arrives now, which for a
|
|
261
|
+
* target nothing can reach is the one wrong answer that reads as everything
|
|
262
|
+
* being fine.
|
|
183
263
|
*/
|
|
184
264
|
effectiveDelaySeconds: number | null;
|
|
185
265
|
/**
|
|
@@ -195,7 +275,7 @@ export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
|
195
275
|
* `"no-path"` when nothing measurable is reported.
|
|
196
276
|
*
|
|
197
277
|
* `null` until a `comms.delay` reading arrives, which is not the same as
|
|
198
|
-
* `"no-path"`. It does not stop {@link
|
|
278
|
+
* `"no-path"`. It does not stop {@link UseCommandResult.dangerouslySendWithoutInput}: a command sent with no path is
|
|
199
279
|
* reported in {@link losses}.
|
|
200
280
|
*/
|
|
201
281
|
delayMode: DelayMode | null;
|
|
@@ -203,7 +283,7 @@ export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
|
203
283
|
* What an order sent now would do, from the sending centre's `comms.route`
|
|
204
284
|
* prediction: it goes at once, is held for a predicted contact and arrives at
|
|
205
285
|
* a stated time, or has no route. An advisory, never a gate: it does not
|
|
206
|
-
* decide whether {@link
|
|
286
|
+
* decide whether {@link UseCommandResult.dangerouslySendWithoutInput} dispatches. `undefined` for an instant command
|
|
207
287
|
* and while no route is known for the sending centre.
|
|
208
288
|
*/
|
|
209
289
|
sendStatus: SendStatus | undefined;
|
|
@@ -220,6 +300,15 @@ export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
|
220
300
|
* a rail reads it, so an outcome is never left with nobody to say it.
|
|
221
301
|
*/
|
|
222
302
|
railed: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Whether a blocked gate stops the press. True for a command the mod declares
|
|
305
|
+
* instant, and for a delayed command whose verdict is held for less than
|
|
306
|
+
* {@link GATE_STOPS_PRESS_BELOW_SECONDS} seconds, since a verdict that fresh is
|
|
307
|
+
* as good as the game's answer. At that limit or above, or when the delay is
|
|
308
|
+
* not known, a blocked gate is advice: the command is sent and the game decides on
|
|
309
|
+
* arrival.
|
|
310
|
+
*/
|
|
311
|
+
gateStopsPress?: boolean;
|
|
223
312
|
/** Dispatches the game refused, newest last, each with its reason. */
|
|
224
313
|
refusals: CommandRefusal[];
|
|
225
314
|
/**
|
|
@@ -240,6 +329,11 @@ export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
|
240
329
|
* is a connection.
|
|
241
330
|
*/
|
|
242
331
|
undelivered: CommandUndelivered[];
|
|
332
|
+
/**
|
|
333
|
+
* The stream to the mod is down, so a press sends nothing. A control reads it
|
|
334
|
+
* to draw its stream-down state: dimmed, with a dotted edge.
|
|
335
|
+
*/
|
|
336
|
+
streamDown: boolean;
|
|
243
337
|
/**
|
|
244
338
|
* Every dispatch from this hook the mod answered with a fault rather than a
|
|
245
339
|
* reply, newest last, until the operator clears it with the same `dismiss`:
|
|
@@ -259,10 +353,11 @@ export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
|
259
353
|
* control was before the channel existed, so a control that ignores this
|
|
260
354
|
* field behaves exactly as it did.
|
|
261
355
|
*
|
|
262
|
-
* A `blocked` gate
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
356
|
+
* A `blocked` gate on a delayed command is advice that the game is likely to
|
|
357
|
+
* refuse it: the control says why and the command is sent when pressed, for
|
|
358
|
+
* the game to decide on arrival. On an instant command, which has no arrival,
|
|
359
|
+
* `dangerouslySendWithoutInput` refuses locally with the gate's own reason
|
|
360
|
+
* and dispatches nothing.
|
|
266
361
|
*/
|
|
267
362
|
gate?: CommandGateStatus;
|
|
268
363
|
/**
|
|
@@ -272,7 +367,10 @@ export interface UseCommandResult<Args = unknown, Reply = AnyCommandReply> {
|
|
|
272
367
|
*
|
|
273
368
|
* A control that sends arguments draws itself from this rather than from
|
|
274
369
|
* `gate`, so the one facility the career cannot afford goes dark while the
|
|
275
|
-
* rest stay live.
|
|
370
|
+
* rest stay live. For an instant command `dangerouslySendWithoutInput`
|
|
371
|
+
* refuses locally on the same answer. For a delayed command that would
|
|
372
|
+
* reach the vessel at or after the UT it acts at, the answer is a blocked
|
|
373
|
+
* verdict of advice only.
|
|
276
374
|
*/
|
|
277
375
|
// A method rather than a function-valued property, so a typed handle stays assignable to the bare one.
|
|
278
376
|
gateFor(args: Args): CommandGateStatus | undefined;
|
|
@@ -320,16 +418,67 @@ export type UseCommandResultFor<Command extends CommandId> = UseCommandResult<
|
|
|
320
418
|
CommandReply<Command>
|
|
321
419
|
>;
|
|
322
420
|
|
|
421
|
+
/** The game's statement of which craft is active. */
|
|
422
|
+
const ACTIVE_VESSEL_TOPIC = "ksp.activeVessel";
|
|
423
|
+
|
|
424
|
+
const CRAFT_SOURCE_PREFIX = "vessel:";
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* The link of the active craft, and the craft the game names as active
|
|
428
|
+
* (`"vessel:<guid>"`, lower-cased) once it has named one.
|
|
429
|
+
*/
|
|
430
|
+
function useActiveCraftLink(): {
|
|
431
|
+
connected: boolean | null | undefined;
|
|
432
|
+
craft: string | undefined;
|
|
433
|
+
} {
|
|
434
|
+
/*
|
|
435
|
+
* The newest report on the wire is read first, since it is not held back by
|
|
436
|
+
* the view clock. It is the newest of any craft: after a switch it stays the
|
|
437
|
+
* report of the craft just left until the new craft's next one, which can be a
|
|
438
|
+
* keyframe interval away. A report that names another craft is passed over
|
|
439
|
+
* for the store's reading, which follows the active craft.
|
|
440
|
+
*/
|
|
441
|
+
const newest = useLatestValue<
|
|
442
|
+
CommsLinkLike & { meta?: { source?: unknown } }
|
|
443
|
+
>("comms.link");
|
|
444
|
+
const store = useTelemetryStoreOptional();
|
|
445
|
+
const active = useLatestValue<{ vesselId?: unknown }>(ACTIVE_VESSEL_TOPIC);
|
|
446
|
+
const craft =
|
|
447
|
+
typeof active?.vesselId === "string" && active.vesselId !== ""
|
|
448
|
+
? `${CRAFT_SOURCE_PREFIX}${active.vesselId}`.toLowerCase()
|
|
449
|
+
: undefined;
|
|
450
|
+
const source = newest?.meta?.source;
|
|
451
|
+
const named =
|
|
452
|
+
typeof source === "string" && source.startsWith(CRAFT_SOURCE_PREFIX)
|
|
453
|
+
? source.toLowerCase()
|
|
454
|
+
: undefined;
|
|
455
|
+
if (craft === undefined || named === undefined || named === craft) {
|
|
456
|
+
return { connected: newest?.connected, craft };
|
|
457
|
+
}
|
|
458
|
+
/* Read at the renders the hook already has, with no subscription of its own: the store's reading changes on its frames, and a command's outcome is only judged at a render. */
|
|
459
|
+
const followed = store?.sampleReading<CommsLinkLike>(
|
|
460
|
+
"comms.link",
|
|
461
|
+
store.currentFrame(),
|
|
462
|
+
);
|
|
463
|
+
return {
|
|
464
|
+
connected:
|
|
465
|
+
followed?.state === "observed" || followed?.state === "held"
|
|
466
|
+
? followed.value.connected
|
|
467
|
+
: undefined,
|
|
468
|
+
craft,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
|
|
323
472
|
/**
|
|
324
473
|
* Sends `command` to the mod through the nearest `TelemetryProvider` and reflects
|
|
325
474
|
* its progress (`idle`, `in-flight`, then `confirmed` or `failed`). Useful for a
|
|
326
475
|
* control that sends a command and shows the operator the delay before it takes
|
|
327
|
-
* effect. Used by command widgets, and its handle is what {@link
|
|
476
|
+
* effect. Used by command widgets, and its handle is what {@link Button}
|
|
328
477
|
* takes.
|
|
329
478
|
*
|
|
330
479
|
* The hook also holds the set of dispatches still in flight (`inFlight`), so a
|
|
331
480
|
* command widget gets delay state from the same hook it already calls to dispatch,
|
|
332
|
-
* with no separate opt-in. `
|
|
481
|
+
* with no separate opt-in. `dangerouslySendWithoutInput` can be called more than once; any status change
|
|
333
482
|
* for the active request re-renders the caller. `inFlight` accumulates every
|
|
334
483
|
* pending dispatch, not only the latest: see `UseCommandResult.inFlight`.
|
|
335
484
|
*
|
|
@@ -340,23 +489,32 @@ export type UseCommandResultFor<Command extends CommandId> = UseCommandResult<
|
|
|
340
489
|
*/
|
|
341
490
|
export function useCommand<Command extends CommandId>(
|
|
342
491
|
command: Command,
|
|
343
|
-
options?: UseCommandOptions
|
|
492
|
+
options?: UseCommandOptions<CommandArgs<Command>>,
|
|
344
493
|
): UseCommandResult<CommandArgs<Command>, CommandReply<Command>>;
|
|
345
494
|
export function useCommand<Args = unknown, Reply = AnyCommandReply>(
|
|
346
495
|
command: string,
|
|
347
|
-
options?: UseCommandOptions
|
|
496
|
+
options?: UseCommandOptions<Args>,
|
|
348
497
|
): UseCommandResult<Args, Reply>;
|
|
349
498
|
export function useCommand(
|
|
350
499
|
command: string,
|
|
351
500
|
options?: UseCommandOptions,
|
|
352
501
|
): UseCommandResult {
|
|
353
|
-
|
|
502
|
+
/*
|
|
503
|
+
* The mod's own declaration decides whether a command is about the program
|
|
504
|
+
* rather than a craft, so a widget has no vantage to choose for one.
|
|
505
|
+
*/
|
|
506
|
+
const vantage = commandRail(command)?.meta ? META_VANTAGE : options?.vantage;
|
|
507
|
+
// Read through a ref: the caller passes a fresh check each render, over that render's telemetry.
|
|
508
|
+
const confirmedByRef = useRef(options?.confirmedBy);
|
|
509
|
+
confirmedByRef.current = options?.confirmedBy;
|
|
510
|
+
const scopeTopic = options?.topic;
|
|
354
511
|
useClaimCapability("command", command);
|
|
355
512
|
// Degrade gracefully with no `TelemetryProvider` mounted (disconnected).
|
|
356
513
|
// Status stays IDLE and `send` is a no-op: you can't dispatch a command with
|
|
357
514
|
// no link, and the hook must not throw just because the dashboard rendered
|
|
358
515
|
// before a connection exists.
|
|
359
516
|
const client = useTelemetryClientOptional();
|
|
517
|
+
const streamDown = !useStreamConnected();
|
|
360
518
|
const [requestId, setRequestId] = useState<string | null>(null);
|
|
361
519
|
|
|
362
520
|
const subscribe = useCallback(
|
|
@@ -389,6 +547,8 @@ export function useCommand(
|
|
|
389
547
|
}, [client, requestId]);
|
|
390
548
|
|
|
391
549
|
const status = useSyncExternalStore(subscribe, getSnapshot);
|
|
550
|
+
// Re-reads the rows of commands a carried client dispatched, which `status` does not follow.
|
|
551
|
+
useSyncExternalStore(subscribe, () => client?.carriedCommandsRevision() ?? 0);
|
|
392
552
|
|
|
393
553
|
// --- inFlight bookkeeping: this hook's OWN dispatches, retained past a
|
|
394
554
|
// queue age-out (Task 4 / Task 4a of the delayed-command-ux plan). ---
|
|
@@ -397,41 +557,93 @@ export function useCommand(
|
|
|
397
557
|
// Pruned once the id leaves the underlying set anyway, so it can't grow
|
|
398
558
|
// unbounded over a long session.
|
|
399
559
|
const [dismissedIds, setDismissedIds] = useState<string[]>([]);
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
560
|
+
/*
|
|
561
|
+
* Refusals, losses, founds, undelivered and failures are held on the client,
|
|
562
|
+
* keyed by command id, and accumulated on each dispatch promise's own
|
|
563
|
+
* rejection rather than derived from `status`: status only tracks the LATEST
|
|
564
|
+
* requestId, and these outcomes are terminal so nothing could re-derive
|
|
565
|
+
* them. Held there, an outcome outlives the widget that sent the command.
|
|
566
|
+
*/
|
|
567
|
+
const outcomeStore = useMemo(
|
|
568
|
+
() => (client ? commandOutcomesOf(client) : null),
|
|
569
|
+
[client],
|
|
570
|
+
);
|
|
571
|
+
const { refusals, losses, founds, undelivered, failures } =
|
|
572
|
+
useSyncExternalStore(
|
|
573
|
+
outcomeStore?.subscribe ?? NO_SUBSCRIBE,
|
|
574
|
+
useCallback(
|
|
575
|
+
() => outcomeStore?.get(command) ?? NO_OUTCOMES,
|
|
576
|
+
[outcomeStore, command],
|
|
577
|
+
),
|
|
578
|
+
);
|
|
579
|
+
const editOutcomes = useCallback(
|
|
580
|
+
<Key extends keyof CommandOutcomeSet>(
|
|
581
|
+
key: Key,
|
|
582
|
+
update: (prev: CommandOutcomeSet[Key]) => CommandOutcomeSet[Key],
|
|
583
|
+
) => outcomeStore?.edit(command, key, update),
|
|
584
|
+
[outcomeStore, command],
|
|
585
|
+
);
|
|
586
|
+
const setRefusals = useCallback(
|
|
587
|
+
(update: (prev: CommandRefusal[]) => CommandRefusal[]) =>
|
|
588
|
+
editOutcomes("refusals", update),
|
|
589
|
+
[editOutcomes],
|
|
590
|
+
);
|
|
591
|
+
const setLosses = useCallback(
|
|
592
|
+
(update: (prev: CommandLoss[]) => CommandLoss[]) =>
|
|
593
|
+
editOutcomes("losses", update),
|
|
594
|
+
[editOutcomes],
|
|
595
|
+
);
|
|
596
|
+
const setUndelivered = useCallback(
|
|
597
|
+
(update: (prev: CommandUndelivered[]) => CommandUndelivered[]) =>
|
|
598
|
+
editOutcomes("undelivered", update),
|
|
599
|
+
[editOutcomes],
|
|
600
|
+
);
|
|
601
|
+
const setFailures = useCallback(
|
|
602
|
+
(update: (prev: CommandFailure[]) => CommandFailure[]) =>
|
|
603
|
+
editOutcomes("failures", update),
|
|
604
|
+
[editOutcomes],
|
|
605
|
+
);
|
|
424
606
|
const entryCacheRef = useRef<Map<string, PendingEntry>>(new Map());
|
|
425
607
|
const firstSeenAtRef = useRef<Map<string, number>>(new Map());
|
|
608
|
+
// Each tracked dispatch's args, for the caller's check of whether the telemetry shows them.
|
|
609
|
+
const argsRef = useRef<Map<string, unknown>>(new Map());
|
|
610
|
+
const labelsRef = useRef<Map<string, string>>(new Map());
|
|
611
|
+
// Every request id this hook sent whose entry may still be queued, so its own entry never reads as someone else's.
|
|
612
|
+
const ownIdsRef = useRef<Set<string>>(new Set());
|
|
613
|
+
const centreMemoryRef = useRef(createCentreCommandMemory());
|
|
614
|
+
// When this client first saw each ran dispatch's reply, as a UT.
|
|
615
|
+
const answeredAtRef = useRef<Map<string, number>>(new Map());
|
|
616
|
+
// Dispatches whose promise resolved, which still says they ran once the client has dropped the record.
|
|
617
|
+
const ranRef = useRef<Set<string>>(new Set());
|
|
426
618
|
const connectivityHistoryRef = useRef<ConnectivityHistory>(
|
|
427
619
|
new ConnectivityHistory(),
|
|
428
620
|
);
|
|
621
|
+
// The active craft `connectivityHistoryRef` describes, once the game has named one.
|
|
622
|
+
const historyCraftRef = useRef<string | undefined>(undefined);
|
|
429
623
|
|
|
430
|
-
const
|
|
624
|
+
const sentQueue = useLatestValue<PendingUplinkQueueLike>(
|
|
625
|
+
"system.uplink.pending",
|
|
626
|
+
);
|
|
627
|
+
const journeyPayload = useLatestValue<unknown>(JOURNEY_TOPIC);
|
|
628
|
+
// The queue as the centre knows it: a hold only once the relay's report of it has come home.
|
|
629
|
+
const queue = useMemo(
|
|
630
|
+
() => queueAsKnown(sentQueue, readJourney(journeyPayload)),
|
|
631
|
+
[sentQueue, journeyPayload],
|
|
632
|
+
);
|
|
431
633
|
// Memoised on the report identity so a control does not re-render on every
|
|
432
634
|
// unrelated render of its widget. The report is republished whole at the
|
|
433
635
|
// engine's gate cadence, and every `useCommand` in the tree reads the same one.
|
|
434
|
-
const
|
|
636
|
+
const liveGates = useLatestValue<CommandGateReport>("system.uplink.gates");
|
|
637
|
+
const homeGates = useLatestValue<CommandGateReport>(
|
|
638
|
+
"system.uplink.gates.home",
|
|
639
|
+
);
|
|
640
|
+
const craftGates = useLatestValue<CommandGateReport>(
|
|
641
|
+
"system.uplink.gates.craft",
|
|
642
|
+
);
|
|
643
|
+
const gateReport = useMemo(
|
|
644
|
+
() => mergeGateReports(liveGates, homeGates, craftGates),
|
|
645
|
+
[liveGates, homeGates, craftGates],
|
|
646
|
+
);
|
|
435
647
|
const gate = useMemo(
|
|
436
648
|
() => selectCommandGate(gateReport, command),
|
|
437
649
|
[gateReport, command],
|
|
@@ -467,9 +679,25 @@ export function useCommand(
|
|
|
467
679
|
const superseded =
|
|
468
680
|
checked?.report !== gateReport &&
|
|
469
681
|
hasItemVerdict(gateReport, command, args);
|
|
470
|
-
|
|
471
|
-
? answered
|
|
472
|
-
|
|
682
|
+
const verdict =
|
|
683
|
+
answered?.blocked && !superseded ? answered : (published ?? answered);
|
|
684
|
+
if (verdict?.blocked) return verdict;
|
|
685
|
+
// Advice only: the command still goes, and the game decides on arrival.
|
|
686
|
+
const clock = storeRef.current?.clock;
|
|
687
|
+
const arrivalUt = !clock
|
|
688
|
+
? undefined
|
|
689
|
+
: isInstantRef.current || toActiveVesselRef.current
|
|
690
|
+
? arrivalUtOf(clock, !isInstantRef.current)
|
|
691
|
+
: arrivalUtAfter(clock, effectiveDelayRef.current);
|
|
692
|
+
return arrivesTooLate(command, args, arrivalUt)
|
|
693
|
+
? {
|
|
694
|
+
command,
|
|
695
|
+
blocked: true,
|
|
696
|
+
undetermined: false,
|
|
697
|
+
errorCode: LATE_ARRIVAL_ERROR_CODE,
|
|
698
|
+
detail: LATE_ARRIVAL_DETAIL,
|
|
699
|
+
}
|
|
700
|
+
: verdict;
|
|
473
701
|
},
|
|
474
702
|
[gateReport, command, checked],
|
|
475
703
|
);
|
|
@@ -529,7 +757,6 @@ export function useCommand(
|
|
|
529
757
|
checkSupersededRef.current = undefined;
|
|
530
758
|
};
|
|
531
759
|
}, [client, command, vantage]);
|
|
532
|
-
const localRefusalSeqRef = useRef(0);
|
|
533
760
|
/*
|
|
534
761
|
* Whether a tracked dispatch has been settled by something other than
|
|
535
762
|
* silence, which is what separates a command that arrived from one nobody
|
|
@@ -557,20 +784,49 @@ export function useCommand(
|
|
|
557
784
|
(id: string) => client?.getCommand(id).phase === "lost",
|
|
558
785
|
[client],
|
|
559
786
|
);
|
|
787
|
+
const confirmation = useCallback(
|
|
788
|
+
(id: string): TrackedConfirmation | undefined => {
|
|
789
|
+
const check = confirmedByRef.current;
|
|
790
|
+
if (!check || !argsRef.current.has(id)) return undefined;
|
|
791
|
+
const status = client?.getCommand(id);
|
|
792
|
+
const ran =
|
|
793
|
+
status?.phase === "confirmed" ||
|
|
794
|
+
(status?.phase === "found" && status.outcome === "ran") ||
|
|
795
|
+
ranRef.current.has(id);
|
|
796
|
+
if (!ran) return undefined;
|
|
797
|
+
let answeredAtUt = answeredAtRef.current.get(id);
|
|
798
|
+
if (answeredAtUt === undefined) {
|
|
799
|
+
answeredAtUt = nowUtRef.current;
|
|
800
|
+
answeredAtRef.current.set(id, answeredAtUt);
|
|
801
|
+
}
|
|
802
|
+
return { confirmed: check(argsRef.current.get(id)), answeredAtUt };
|
|
803
|
+
},
|
|
804
|
+
[client],
|
|
805
|
+
);
|
|
560
806
|
const ackPhases = useSyncExternalStore(
|
|
561
807
|
subscribe,
|
|
562
808
|
useCallback(
|
|
563
809
|
() =>
|
|
564
810
|
dispatchedIds
|
|
565
|
-
.map((id) =>
|
|
811
|
+
.map((id) => {
|
|
812
|
+
const status = client?.getCommand(id);
|
|
813
|
+
if (status?.phase !== "in-flight") return status?.phase ?? "idle";
|
|
814
|
+
return `${status.phase}${status.accepted ? "+" : ""}${status.warning ? "!" : ""}`;
|
|
815
|
+
})
|
|
566
816
|
.join(","),
|
|
567
817
|
[client, dispatchedIds],
|
|
568
818
|
),
|
|
569
819
|
);
|
|
570
820
|
|
|
571
|
-
const connectivity =
|
|
821
|
+
const connectivity = useActiveCraftLink();
|
|
572
822
|
const commsDelay = useLatestValue<CommsDelayLike>("comms.delay");
|
|
573
823
|
const commsDelayReading = useStream<CommsDelayLike>("comms.delay");
|
|
824
|
+
const uplinkDelays = useLatestValue<unknown>(UPLINK_DELAYS_TOPIC);
|
|
825
|
+
const uplinkDelaysReading = useStream<unknown>(UPLINK_DELAYS_TOPIC);
|
|
826
|
+
const delayAuthority = useDelayAuthorityOptional();
|
|
827
|
+
// Read only so a change of centre row or of craft re-renders the figure the authority holds.
|
|
828
|
+
useLatestValue<unknown>(CENTRE_DELAY_TOPIC);
|
|
829
|
+
useLatestValue<unknown>(IDENTITY_TOPIC);
|
|
574
830
|
|
|
575
831
|
/*
|
|
576
832
|
* The delay display + effective delay this command hands to `<CommandDelay>`.
|
|
@@ -579,36 +835,93 @@ export function useCommand(
|
|
|
579
835
|
*
|
|
580
836
|
* `effectiveDelaySeconds` is 0 for a never-delayed sim-meta command
|
|
581
837
|
* (`time.*`) and for a meta-vantage dispatch, both of which are instant
|
|
582
|
-
* server-side and so are knowably zero. Otherwise it is the
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
* the topic.
|
|
838
|
+
* server-side and so are knowably zero. Otherwise it is the delay to the
|
|
839
|
+
* command's own target, which only the mod can place: `system.uplink.delays`
|
|
840
|
+
* says whether that is the active craft, timed by the centre's own delay to
|
|
841
|
+
* it, or something else, with the figure the centre knows for it.
|
|
587
842
|
*
|
|
588
|
-
* A zero is NOT the fallback for
|
|
589
|
-
* splits "no path home" from "the
|
|
590
|
-
* connected" by that value alone
|
|
591
|
-
* collapsing the first onto the
|
|
592
|
-
*
|
|
593
|
-
* value-first way and names zero the one direction this must never fail in.
|
|
843
|
+
* A zero is NOT the fallback for an unknown delay, and nor is the active
|
|
844
|
+
* craft's delay. `comms.delay.oneWaySeconds` splits "no path home" from "the
|
|
845
|
+
* delay feature is off and the craft is connected" by that value alone
|
|
846
|
+
* (`Sitrep.Contract/Comms.cs:CommsDelay`), and collapsing the first onto the
|
|
847
|
+
* second clocked a craft nothing could reach as if it were on the LAN.
|
|
594
848
|
*/
|
|
595
849
|
const tags = railTagsForCommand(command);
|
|
596
850
|
const isInstant = !commandDelayed(command) || vantage === META_VANTAGE;
|
|
597
851
|
const isInstantRef = useRef(isInstant);
|
|
598
852
|
isInstantRef.current = isInstant;
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
853
|
+
/*
|
|
854
|
+
* Whether the verdict this handle holds is live. The mod publishes a delayed
|
|
855
|
+
* command's verdict after its delay, whichever vantage the press is sent from,
|
|
856
|
+
* so a command sent from the meta-vantage (no delay of its own) still reads an
|
|
857
|
+
* old verdict and the press is advised rather than stopped.
|
|
858
|
+
*/
|
|
859
|
+
const declaredInstant = !commandDelayed(command);
|
|
860
|
+
const verdictTarget = declaredInstant
|
|
861
|
+
? null
|
|
862
|
+
: commandTargetOf(uplinkDelays, command, undefined);
|
|
863
|
+
const verdictDelaySeconds = delayToTarget(
|
|
864
|
+
declaredInstant,
|
|
865
|
+
verdictTarget,
|
|
866
|
+
() =>
|
|
867
|
+
delayAuthority
|
|
868
|
+
? delayAuthority.commandDelaySeconds(undefined)
|
|
869
|
+
: liveOneWaySeconds(commsDelay),
|
|
870
|
+
);
|
|
871
|
+
const gateStopsPress =
|
|
872
|
+
verdictDelaySeconds !== null &&
|
|
873
|
+
verdictDelaySeconds < GATE_STOPS_PRESS_BELOW_SECONDS;
|
|
874
|
+
const gateStopsPressRef = useRef(gateStopsPress);
|
|
875
|
+
gateStopsPressRef.current = gateStopsPress;
|
|
876
|
+
const sentFrom =
|
|
877
|
+
vantage === undefined || vantage === "" ? undefined : vantage;
|
|
878
|
+
const target = isInstant
|
|
879
|
+
? null
|
|
880
|
+
: commandTargetOf(uplinkDelays, command, sentFrom);
|
|
881
|
+
const toActiveVessel = target?.kind === "active-vessel";
|
|
882
|
+
const toActiveVesselRef = useRef(toActiveVessel);
|
|
883
|
+
toActiveVesselRef.current = toActiveVessel;
|
|
884
|
+
const effectiveDelaySeconds = delayToTarget(isInstant, target, () =>
|
|
885
|
+
delayAuthority
|
|
886
|
+
? delayAuthority.commandDelaySeconds(sentFrom)
|
|
887
|
+
: liveOneWaySeconds(commsDelay),
|
|
888
|
+
);
|
|
889
|
+
const effectiveDelayRef = useRef(effectiveDelaySeconds);
|
|
890
|
+
effectiveDelayRef.current = effectiveDelaySeconds;
|
|
891
|
+
let delayReading: Reading<Value<"s">> | null = null;
|
|
892
|
+
if (!isInstant && effectiveDelaySeconds !== null) {
|
|
893
|
+
const figure = () => value("s", Math.max(0, effectiveDelaySeconds));
|
|
894
|
+
if (
|
|
895
|
+
toActiveVessel &&
|
|
896
|
+
(commsDelayReading.state === "observed" ||
|
|
897
|
+
commsDelayReading.state === "held")
|
|
898
|
+
) {
|
|
899
|
+
delayReading = readingOf(commsDelayReading, figure);
|
|
900
|
+
}
|
|
901
|
+
if (
|
|
902
|
+
!toActiveVessel &&
|
|
903
|
+
(uplinkDelaysReading.state === "observed" ||
|
|
904
|
+
uplinkDelaysReading.state === "held")
|
|
905
|
+
) {
|
|
906
|
+
delayReading = readingOf(uplinkDelaysReading, figure);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
604
909
|
/*
|
|
605
910
|
* The three-valued answer the package already computes, passed through rather
|
|
606
911
|
* than re-derived, so a widget can SAY "no path" instead of inferring it from
|
|
607
912
|
* a number that cannot express it. `null` is the fourth state and the one
|
|
608
913
|
* `DelayMode` deliberately has no token for: nothing has been read, which is
|
|
609
914
|
* not the same claim as "there is no path" and must not be dressed up as one.
|
|
915
|
+
* A command to anything but the active craft has a mode only once its delay
|
|
916
|
+
* is known.
|
|
610
917
|
*/
|
|
611
|
-
const delayMode =
|
|
918
|
+
const delayMode = toActiveVessel
|
|
919
|
+
? commsDelay
|
|
920
|
+
? currentMode(commsDelay)
|
|
921
|
+
: null
|
|
922
|
+
: target?.kind === "elsewhere" && target.seconds !== null
|
|
923
|
+
? currentMode({ oneWaySeconds: value("s", target.seconds) })
|
|
924
|
+
: null;
|
|
612
925
|
// A synchronous, NON-subscribing read of the same undelayed clock
|
|
613
926
|
// `useUtNow` tracks (`ViewClock.utNowEstimate()`): deliberately NOT
|
|
614
927
|
// `useUtNow()` itself, which subscribes to a real-wall-clock ~16ms tick
|
|
@@ -623,6 +936,9 @@ export function useCommand(
|
|
|
623
936
|
// whether the test ever touches `inFlight`.
|
|
624
937
|
const store = useTelemetryStoreOptional();
|
|
625
938
|
const nowUt = store?.clock.utNowEstimate() ?? 0;
|
|
939
|
+
// Before any sample the estimate is a stand-in 0, which is no time to date an outcome against.
|
|
940
|
+
const clockSampled =
|
|
941
|
+
store !== undefined && Number.isFinite(store.clock.confirmedEdgeUt());
|
|
626
942
|
const routePayload = useLatestValue<unknown>(ROUTE_TOPIC);
|
|
627
943
|
const nextLossPayload = useLatestValue<unknown>("comms.nextLoss");
|
|
628
944
|
const sendStatus = isInstant
|
|
@@ -634,7 +950,17 @@ export function useCommand(
|
|
|
634
950
|
readNextLossUt(nextLossPayload),
|
|
635
951
|
);
|
|
636
952
|
|
|
637
|
-
|
|
953
|
+
/* The history is of one craft's link, so it starts again when another craft becomes active. */
|
|
954
|
+
if (
|
|
955
|
+
connectivity.craft !== undefined &&
|
|
956
|
+
connectivity.craft !== historyCraftRef.current
|
|
957
|
+
) {
|
|
958
|
+
if (historyCraftRef.current !== undefined) {
|
|
959
|
+
connectivityHistoryRef.current = new ConnectivityHistory();
|
|
960
|
+
}
|
|
961
|
+
historyCraftRef.current = connectivity.craft;
|
|
962
|
+
}
|
|
963
|
+
if (typeof connectivity.connected === "boolean") {
|
|
638
964
|
connectivityHistoryRef.current.record(nowUt, connectivity.connected);
|
|
639
965
|
}
|
|
640
966
|
|
|
@@ -673,7 +999,7 @@ export function useCommand(
|
|
|
673
999
|
if (dispatchTick === 0 || railVerifiedRef.current) return;
|
|
674
1000
|
if (railed && !rail) {
|
|
675
1001
|
throw new Error(
|
|
676
|
-
`useCommand(${JSON.stringify(command)}).
|
|
1002
|
+
`useCommand(${JSON.stringify(command)}).dangerouslySendWithoutInput() dispatched a command ` +
|
|
677
1003
|
"with no command rail mounted above it, so its outcome would reach " +
|
|
678
1004
|
"nobody. Mount the widget inside a DelayRailProvider: the dashboard, " +
|
|
679
1005
|
"renderWidget and the test render all do.",
|
|
@@ -696,8 +1022,16 @@ export function useCommand(
|
|
|
696
1022
|
pathConnectedDuring,
|
|
697
1023
|
acknowledged,
|
|
698
1024
|
judgedLost,
|
|
1025
|
+
confirmation,
|
|
699
1026
|
);
|
|
700
|
-
if (resolution.kind === "classified")
|
|
1027
|
+
if (resolution.kind === "classified") {
|
|
1028
|
+
const sentWith = argsRef.current.get(id);
|
|
1029
|
+
computed.push(
|
|
1030
|
+
sentWith === undefined
|
|
1031
|
+
? resolution.item
|
|
1032
|
+
: { ...resolution.item, args: sentWith },
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
701
1035
|
}
|
|
702
1036
|
// Hide dismissed commands. The underlying `computed` set still drives the
|
|
703
1037
|
// dismissed-id prune below, so a dismissed id is dropped from the set once
|
|
@@ -708,6 +1042,76 @@ export function useCommand(
|
|
|
708
1042
|
: computed;
|
|
709
1043
|
if (visible.length > 0) inFlight = visible;
|
|
710
1044
|
}
|
|
1045
|
+
const centreRows = isInstant
|
|
1046
|
+
? NO_IN_FLIGHT
|
|
1047
|
+
: centreCommandRows({
|
|
1048
|
+
command,
|
|
1049
|
+
queue,
|
|
1050
|
+
own: ownIdsRef.current,
|
|
1051
|
+
memory: centreMemoryRef.current,
|
|
1052
|
+
nowUt,
|
|
1053
|
+
pathConnectedDuring,
|
|
1054
|
+
statusOf: (id) => client?.getCarriedCommand(id),
|
|
1055
|
+
topic: scopeTopic,
|
|
1056
|
+
});
|
|
1057
|
+
if (centreRows.length > 0) {
|
|
1058
|
+
inFlight = [...inFlight, ...centreRows].sort(
|
|
1059
|
+
(a, b) => a.dispatchedAt - b.dispatchedAt,
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
let warnings = NO_WARNINGS;
|
|
1064
|
+
for (const id of dispatchedIds) {
|
|
1065
|
+
const status = client?.getCommand(id);
|
|
1066
|
+
if (status?.phase !== "in-flight" || !status.warning) continue;
|
|
1067
|
+
if (warnings === NO_WARNINGS) warnings = [];
|
|
1068
|
+
warnings.push({
|
|
1069
|
+
id,
|
|
1070
|
+
command,
|
|
1071
|
+
label: labelsRef.current.get(id) ?? "",
|
|
1072
|
+
warning: status.warning,
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
/*
|
|
1076
|
+
* The centre writes the same warning on the command's queue entry, so every
|
|
1077
|
+
* screen at the centre shows it, and the sender keeps one copy of its own.
|
|
1078
|
+
*/
|
|
1079
|
+
for (const entry of queue?.pending ?? []) {
|
|
1080
|
+
if (!carriesCommand(entry, command) || !entry.warning) continue;
|
|
1081
|
+
const id = centreRowId(entry);
|
|
1082
|
+
if (warnings.some((w) => w.id === id)) continue;
|
|
1083
|
+
if (warnings === NO_WARNINGS) warnings = [];
|
|
1084
|
+
warnings.push({ id, command, label: entry.label, warning: entry.warning });
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/*
|
|
1088
|
+
* What became of another screen's command, as the centre reports it, listed
|
|
1089
|
+
* with this hook's own refusals and failures so every screen says the same.
|
|
1090
|
+
*/
|
|
1091
|
+
const centreOutcomes = isInstant
|
|
1092
|
+
? null
|
|
1093
|
+
: centreCommandOutcomes({
|
|
1094
|
+
command,
|
|
1095
|
+
queue,
|
|
1096
|
+
own: ownIdsRef.current,
|
|
1097
|
+
memory: centreMemoryRef.current,
|
|
1098
|
+
nowUt: clockSampled ? nowUt : null,
|
|
1099
|
+
epoch: store?.clock.getEpoch() ?? 0,
|
|
1100
|
+
vesselId: client ? activeVesselIdOf(client) : null,
|
|
1101
|
+
topic: scopeTopic,
|
|
1102
|
+
});
|
|
1103
|
+
const allRefusals =
|
|
1104
|
+
centreOutcomes && centreOutcomes.refusals.length > 0
|
|
1105
|
+
? [...refusals, ...centreOutcomes.refusals]
|
|
1106
|
+
: refusals;
|
|
1107
|
+
const allFailures =
|
|
1108
|
+
centreOutcomes && centreOutcomes.failures.length > 0
|
|
1109
|
+
? [...failures, ...centreOutcomes.failures]
|
|
1110
|
+
: failures;
|
|
1111
|
+
const allFounds =
|
|
1112
|
+
centreOutcomes && centreOutcomes.founds.length > 0
|
|
1113
|
+
? [...founds, ...centreOutcomes.founds]
|
|
1114
|
+
: founds;
|
|
711
1115
|
|
|
712
1116
|
// Prune tracked ids once resolved/expired, so `dispatchedIds` (and the
|
|
713
1117
|
// caches it drives) don't grow forever over a long session. Separate from
|
|
@@ -747,6 +1151,7 @@ export function useCommand(
|
|
|
747
1151
|
pathConnectedDuring,
|
|
748
1152
|
acknowledged,
|
|
749
1153
|
judgedLost,
|
|
1154
|
+
confirmation,
|
|
750
1155
|
);
|
|
751
1156
|
return (
|
|
752
1157
|
resolution.kind === "classified" || resolution.kind === "waiting"
|
|
@@ -769,6 +1174,7 @@ export function useCommand(
|
|
|
769
1174
|
pathConnectedDuring,
|
|
770
1175
|
acknowledged,
|
|
771
1176
|
judgedLost,
|
|
1177
|
+
confirmation,
|
|
772
1178
|
ackPhases,
|
|
773
1179
|
dismissedIds,
|
|
774
1180
|
]);
|
|
@@ -779,124 +1185,51 @@ export function useCommand(
|
|
|
779
1185
|
* first-seen time before its id reaches `dispatchedIds`, so an id that has
|
|
780
1186
|
* never been in the list is one that is about to be.
|
|
781
1187
|
*/
|
|
1188
|
+
useEffect(() => {
|
|
1189
|
+
const own = ownIdsRef.current;
|
|
1190
|
+
if (own.size === 0) return;
|
|
1191
|
+
const queued = new Set<string>();
|
|
1192
|
+
for (const entry of queue?.pending ?? []) {
|
|
1193
|
+
queued.add(entry.clientRequestId);
|
|
1194
|
+
for (const member of entry.members ?? []) queued.add(member);
|
|
1195
|
+
}
|
|
1196
|
+
// A settled entry is still this hook's own while the centre lists it.
|
|
1197
|
+
for (const entry of queue?.settled ?? []) queued.add(entry.clientRequestId);
|
|
1198
|
+
for (const id of own) {
|
|
1199
|
+
if (!queued.has(id) && !dispatchedIds.includes(id)) own.delete(id);
|
|
1200
|
+
}
|
|
1201
|
+
}, [queue, dispatchedIds]);
|
|
1202
|
+
|
|
782
1203
|
const trackedBeforeRef = useRef<readonly string[]>(dispatchedIds);
|
|
783
1204
|
useEffect(() => {
|
|
784
1205
|
for (const id of trackedBeforeRef.current) {
|
|
785
1206
|
if (dispatchedIds.includes(id)) continue;
|
|
786
1207
|
entryCacheRef.current.delete(id);
|
|
787
1208
|
firstSeenAtRef.current.delete(id);
|
|
1209
|
+
argsRef.current.delete(id);
|
|
1210
|
+
labelsRef.current.delete(id);
|
|
1211
|
+
answeredAtRef.current.delete(id);
|
|
1212
|
+
ranRef.current.delete(id);
|
|
788
1213
|
}
|
|
789
1214
|
trackedBeforeRef.current = dispatchedIds;
|
|
790
1215
|
}, [dispatchedIds]);
|
|
791
1216
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
* It carries the `undelivered` promotion for the same reason and by the same
|
|
809
|
-
* route: a stranded command's promise rejected as `E_LOST` long before the
|
|
810
|
-
* transport gave up, so the status store is again the only channel the
|
|
811
|
-
* correction arrives on.
|
|
812
|
-
*/
|
|
813
|
-
useEffect(() => {
|
|
814
|
-
if (!client || losses.length === 0) return;
|
|
815
|
-
const sweep = () => {
|
|
816
|
-
const promoted: CommandFound[] = [];
|
|
817
|
-
const unsent: CommandUndelivered[] = [];
|
|
818
|
-
for (const loss of losses) {
|
|
819
|
-
const status = client.getCommand(loss.id);
|
|
820
|
-
if (status.phase === "undelivered") {
|
|
821
|
-
unsent.push({ ...loss, reason: status.reason });
|
|
822
|
-
continue;
|
|
823
|
-
}
|
|
824
|
-
if (status.phase !== "found") continue;
|
|
825
|
-
promoted.push(
|
|
826
|
-
status.outcome === "refused"
|
|
827
|
-
? {
|
|
828
|
-
...loss,
|
|
829
|
-
outcome: "refused",
|
|
830
|
-
errorCode: status.errorCode,
|
|
831
|
-
reason: status.reason,
|
|
832
|
-
breach: status.breach,
|
|
833
|
-
detail: status.detail,
|
|
834
|
-
}
|
|
835
|
-
: status.outcome === "errored"
|
|
836
|
-
? { ...loss, outcome: "errored", error: status.error }
|
|
837
|
-
: { ...loss, outcome: "ran", result: status.result },
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
if (promoted.length === 0 && unsent.length === 0) return;
|
|
841
|
-
setLosses((prev) =>
|
|
842
|
-
prev.filter(
|
|
843
|
-
(l) =>
|
|
844
|
-
!promoted.some((f) => f.id === l.id) &&
|
|
845
|
-
!unsent.some((u) => u.id === l.id),
|
|
846
|
-
),
|
|
847
|
-
);
|
|
848
|
-
if (promoted.length > 0) setFounds((prev) => [...prev, ...promoted]);
|
|
849
|
-
if (unsent.length > 0) {
|
|
850
|
-
setUndelivered((prev) => [
|
|
851
|
-
...prev,
|
|
852
|
-
// A store notify can arrive more than once for the same status, and `losses` is only filtered on the render after this one.
|
|
853
|
-
...unsent.filter((u) => !prev.some((seen) => seen.id === u.id)),
|
|
854
|
-
]);
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
// Once up front: a reply can land between the render that read `losses` and the effect that subscribes, and a store notify for it would then be gone.
|
|
858
|
-
sweep();
|
|
859
|
-
return client.subscribeStore(sweep);
|
|
860
|
-
}, [client, losses]);
|
|
861
|
-
|
|
862
|
-
const dismiss = useCallback((id: string) => {
|
|
863
|
-
setDismissedIds((prev) => (prev.includes(id) ? prev : [...prev, id]));
|
|
864
|
-
// A refusal is dropped outright rather than hidden behind `dismissedIds`.
|
|
865
|
-
// That set is pruned once an id leaves the underlying in-flight set, which a
|
|
866
|
-
// refused dispatch does as soon as its grace window closes, and a dismissed
|
|
867
|
-
// refusal that came back would read as the game refusing a second time.
|
|
868
|
-
setRefusals((prev) => {
|
|
869
|
-
const keep = prev.filter((r) => r.id !== id);
|
|
870
|
-
return keep.length === prev.length ? prev : keep;
|
|
871
|
-
});
|
|
872
|
-
// Dropped outright for the same reason a refusal is: a loss is terminal, so a dismissed one that came back would read as a second silence.
|
|
873
|
-
setLosses((prev) => {
|
|
874
|
-
const keep = prev.filter((l) => l.id !== id);
|
|
875
|
-
return keep.length === prev.length ? prev : keep;
|
|
876
|
-
});
|
|
877
|
-
/*
|
|
878
|
-
* Dropped outright for the third time, same reason again: a found is
|
|
879
|
-
* terminal, and one that came back would read as the command answering
|
|
880
|
-
* twice.
|
|
881
|
-
*/
|
|
882
|
-
setFounds((prev) => {
|
|
883
|
-
const keep = prev.filter((f) => f.id !== id);
|
|
884
|
-
return keep.length === prev.length ? prev : keep;
|
|
885
|
-
});
|
|
886
|
-
/*
|
|
887
|
-
* And a fourth time, same reason: nothing can answer a command that was
|
|
888
|
-
* never sent, so a dismissed one that reappeared would be a second silence
|
|
889
|
-
* about the same dispatch.
|
|
890
|
-
*/
|
|
891
|
-
setUndelivered((prev) => {
|
|
892
|
-
const keep = prev.filter((u) => u.id !== id);
|
|
893
|
-
return keep.length === prev.length ? prev : keep;
|
|
894
|
-
});
|
|
895
|
-
setFailures((prev) => {
|
|
896
|
-
const keep = prev.filter((f) => f.id !== id);
|
|
897
|
-
return keep.length === prev.length ? prev : keep;
|
|
898
|
-
});
|
|
899
|
-
}, []);
|
|
1217
|
+
const dismiss = useCallback(
|
|
1218
|
+
(id: string) => {
|
|
1219
|
+
centreMemoryRef.current.dismissed.add(id);
|
|
1220
|
+
dismissCentreOutcome(centreMemoryRef.current, id);
|
|
1221
|
+
setDismissedIds((prev) => (prev.includes(id) ? prev : [...prev, id]));
|
|
1222
|
+
/*
|
|
1223
|
+
* An outcome is dropped outright rather than hidden behind `dismissedIds`.
|
|
1224
|
+
* That set is pruned once an id leaves the underlying in-flight set, which
|
|
1225
|
+
* a settled dispatch does as soon as its grace window closes, and a
|
|
1226
|
+
* dismissed outcome that came back would read as the command answering
|
|
1227
|
+
* twice.
|
|
1228
|
+
*/
|
|
1229
|
+
outcomeStore?.dismiss(command, id);
|
|
1230
|
+
},
|
|
1231
|
+
[outcomeStore, command],
|
|
1232
|
+
);
|
|
900
1233
|
|
|
901
1234
|
/*
|
|
902
1235
|
* Everything a dispatch needs once it has a request id: the tracking, and
|
|
@@ -916,6 +1249,16 @@ export function useCommand(
|
|
|
916
1249
|
newRequestId,
|
|
917
1250
|
storeRef.current?.clock.wallNow() ?? performance.now() / 1000,
|
|
918
1251
|
);
|
|
1252
|
+
argsRef.current.set(newRequestId, args);
|
|
1253
|
+
labelsRef.current.set(newRequestId, label);
|
|
1254
|
+
ownIdsRef.current.add(newRequestId);
|
|
1255
|
+
result.then(
|
|
1256
|
+
() => {
|
|
1257
|
+
ranRef.current.add(newRequestId);
|
|
1258
|
+
outcomeStore?.supersedeFailures(command);
|
|
1259
|
+
},
|
|
1260
|
+
() => undefined,
|
|
1261
|
+
);
|
|
919
1262
|
setDispatchedIds((prev) => [...prev, newRequestId]);
|
|
920
1263
|
// Schedule the dev-only rail check on the first unverified dispatch (see the effect above).
|
|
921
1264
|
if (process.env.NODE_ENV !== "production" && !railVerifiedRef.current) {
|
|
@@ -1014,7 +1357,14 @@ export function useCommand(
|
|
|
1014
1357
|
// something.
|
|
1015
1358
|
return result as Promise<AnyCommandReply>;
|
|
1016
1359
|
},
|
|
1017
|
-
[
|
|
1360
|
+
[
|
|
1361
|
+
command,
|
|
1362
|
+
outcomeStore,
|
|
1363
|
+
setLosses,
|
|
1364
|
+
setUndelivered,
|
|
1365
|
+
setFailures,
|
|
1366
|
+
setRefusals,
|
|
1367
|
+
],
|
|
1018
1368
|
);
|
|
1019
1369
|
|
|
1020
1370
|
// Commands an earlier page of this screen sent under this id and is still waiting on, taken once so their answers show as a send's own do.
|
|
@@ -1025,7 +1375,7 @@ export function useCommand(
|
|
|
1025
1375
|
}
|
|
1026
1376
|
}, [client, command, trackDispatch]);
|
|
1027
1377
|
|
|
1028
|
-
const
|
|
1378
|
+
const dangerouslySendWithoutInput = useCallback(
|
|
1029
1379
|
(
|
|
1030
1380
|
args?: unknown,
|
|
1031
1381
|
opts?: { label?: string; topic?: string },
|
|
@@ -1033,7 +1383,7 @@ export function useCommand(
|
|
|
1033
1383
|
// No provider mounted: nothing left the ground, so nothing can come back.
|
|
1034
1384
|
//
|
|
1035
1385
|
// Resolving with `undefined` would read as a confirmed command:
|
|
1036
|
-
// `
|
|
1386
|
+
// a command `Button` awaits `send()`, calls `onConfirmed`, and returns to
|
|
1037
1387
|
// rest, so a press with no link would render byte-identically to a press
|
|
1038
1388
|
// that worked. A rejection is what the controls are built to read, and
|
|
1039
1389
|
// it matches the client's own answer on `dispose()` and for a command
|
|
@@ -1065,9 +1415,8 @@ export function useCommand(
|
|
|
1065
1415
|
>,
|
|
1066
1416
|
reason: string,
|
|
1067
1417
|
): Promise<AnyCommandReply> => {
|
|
1068
|
-
localRefusalSeqRef.current += 1;
|
|
1069
1418
|
const refusal: CommandRefusal = {
|
|
1070
|
-
id: `local-refusal:${command}:${
|
|
1419
|
+
id: `local-refusal:${command}:${outcomeStore?.nextLocalSeq() ?? 0}`,
|
|
1071
1420
|
errorCode: verdict.errorCode,
|
|
1072
1421
|
reason: verdict.reason,
|
|
1073
1422
|
command,
|
|
@@ -1089,20 +1438,30 @@ export function useCommand(
|
|
|
1089
1438
|
refused.catch(() => undefined);
|
|
1090
1439
|
return refused;
|
|
1091
1440
|
};
|
|
1441
|
+
/*
|
|
1442
|
+
* A gate stops the press only when its verdict is fresh enough to stand for
|
|
1443
|
+
* the game's answer: the command is declared instant, or its verdict is held
|
|
1444
|
+
* a few seconds at most. Past that the command goes and the mod reads the
|
|
1445
|
+
* gates again when it arrives.
|
|
1446
|
+
*/
|
|
1092
1447
|
const standing = selectCommandGate(gateReportRef.current, command, args);
|
|
1093
|
-
if (standing?.blocked) {
|
|
1448
|
+
if (standing?.blocked && gateStopsPressRef.current) {
|
|
1094
1449
|
return refuseLocally(standing, "its gate refuses it");
|
|
1095
1450
|
}
|
|
1096
|
-
// A command that acts at a UT and would land at or after it is
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1451
|
+
// A command that acts at a UT and would land at or after it is stopped before it leaves, on the same terms.
|
|
1452
|
+
if (gateStopsPressRef.current) {
|
|
1453
|
+
const clock = storeRef.current?.clock;
|
|
1454
|
+
const arrivalUt = !clock
|
|
1455
|
+
? undefined
|
|
1456
|
+
: isInstantRef.current || toActiveVesselRef.current
|
|
1457
|
+
? arrivalUtOf(clock, !isInstantRef.current)
|
|
1458
|
+
: arrivalUtAfter(clock, effectiveDelayRef.current);
|
|
1459
|
+
if (arrivesTooLate(command, args, arrivalUt)) {
|
|
1460
|
+
return refuseLocally(
|
|
1461
|
+
{ errorCode: LATE_ARRIVAL_ERROR_CODE, detail: LATE_ARRIVAL_DETAIL },
|
|
1462
|
+
LATE_ARRIVAL_DETAIL,
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1106
1465
|
}
|
|
1107
1466
|
const track = (
|
|
1108
1467
|
newRequestId: string,
|
|
@@ -1116,7 +1475,7 @@ export function useCommand(
|
|
|
1116
1475
|
command,
|
|
1117
1476
|
args,
|
|
1118
1477
|
label: opts?.label,
|
|
1119
|
-
topic: opts?.topic,
|
|
1478
|
+
topic: opts?.topic ?? scopeTopic,
|
|
1120
1479
|
vantage,
|
|
1121
1480
|
instant: isInstantRef.current,
|
|
1122
1481
|
track,
|
|
@@ -1126,22 +1485,32 @@ export function useCommand(
|
|
|
1126
1485
|
command,
|
|
1127
1486
|
args,
|
|
1128
1487
|
opts?.label,
|
|
1129
|
-
opts?.topic,
|
|
1488
|
+
opts?.topic ?? scopeTopic,
|
|
1130
1489
|
vantage,
|
|
1131
1490
|
);
|
|
1132
1491
|
return track(newRequestId, result);
|
|
1133
1492
|
},
|
|
1134
|
-
[
|
|
1493
|
+
[
|
|
1494
|
+
client,
|
|
1495
|
+
command,
|
|
1496
|
+
vantage,
|
|
1497
|
+
scopeTopic,
|
|
1498
|
+
trackDispatch,
|
|
1499
|
+
outcomeStore,
|
|
1500
|
+
setRefusals,
|
|
1501
|
+
],
|
|
1135
1502
|
);
|
|
1136
1503
|
|
|
1137
1504
|
const outcome = {
|
|
1138
1505
|
status,
|
|
1139
1506
|
inFlight,
|
|
1140
|
-
|
|
1507
|
+
warnings,
|
|
1508
|
+
refusals: allRefusals,
|
|
1141
1509
|
losses,
|
|
1142
|
-
founds,
|
|
1510
|
+
founds: allFounds,
|
|
1143
1511
|
undelivered,
|
|
1144
|
-
|
|
1512
|
+
streamDown,
|
|
1513
|
+
failures: allFailures,
|
|
1145
1514
|
tags,
|
|
1146
1515
|
effectiveDelaySeconds,
|
|
1147
1516
|
delayReading,
|
|
@@ -1164,15 +1533,27 @@ export function useCommand(
|
|
|
1164
1533
|
rail.update(railId, outcome);
|
|
1165
1534
|
});
|
|
1166
1535
|
|
|
1167
|
-
|
|
1536
|
+
const handle: UseCommandResult = {
|
|
1537
|
+
dangerouslySendWithoutInput,
|
|
1538
|
+
gateFor,
|
|
1539
|
+
check,
|
|
1540
|
+
railed: railed && rail !== null,
|
|
1541
|
+
gateStopsPress,
|
|
1542
|
+
...outcome,
|
|
1543
|
+
with: (args, options) => bindCommand(handle, args, options),
|
|
1544
|
+
toArgs: (toArgs, options) => bindValue(handle, toArgs, options),
|
|
1545
|
+
};
|
|
1546
|
+
return handle;
|
|
1168
1547
|
}
|
|
1169
1548
|
|
|
1170
|
-
/**
|
|
1171
|
-
function
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
1549
|
+
/** 0 for an instant command, the target's own figure elsewhere, `activeVessel()` for the active craft, and `null` for a target nobody has placed. */
|
|
1550
|
+
function delayToTarget(
|
|
1551
|
+
isInstant: boolean,
|
|
1552
|
+
target: CommandTarget | null,
|
|
1553
|
+
activeVessel: () => number | null,
|
|
1554
|
+
): number | null {
|
|
1555
|
+
if (isInstant) return 0;
|
|
1556
|
+
if (target?.kind === "elsewhere") return target.seconds;
|
|
1557
|
+
if (target?.kind === "active-vessel") return activeVessel();
|
|
1558
|
+
return null;
|
|
1178
1559
|
}
|