@ksp-gonogo/kerbcast-react 1.4.0 → 1.5.1
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 +132 -11
- package/dist/CameraFeed.d.ts +13 -0
- package/dist/CameraFeed.js +29 -6
- package/dist/StandbyIcon.d.ts +8 -0
- package/dist/StandbyIcon.js +9 -0
- package/dist/hooks/useKerbcastInFlight.d.ts +2 -0
- package/dist/hooks/useKerbcastInFlight.js +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/package.json +9 -8
- package/src/CameraFeed.test.tsx +76 -0
- package/src/CameraFeed.tsx +78 -26
- package/src/StandbyIcon.tsx +33 -0
- package/src/hooks/useKerbcastInFlight.test.tsx +71 -0
- package/src/hooks/useKerbcastInFlight.ts +15 -0
- package/src/index.ts +4 -0
- package/LICENSE +0 -369
- package/dist/hooks/useKerbcamCameras.d.ts +0 -8
- package/dist/hooks/useKerbcamCameras.js +0 -19
- package/dist/hooks/useKerbcamStream.d.ts +0 -10
- package/dist/hooks/useKerbcamStream.js +0 -35
package/README.md
CHANGED
|
@@ -1,26 +1,147 @@
|
|
|
1
1
|
# @ksp-gonogo/kerbcast-react
|
|
2
2
|
|
|
3
|
-
React components and hooks for [kerbcast](https://github.com/ksp-gonogo/kerbcast)
|
|
3
|
+
React components and hooks for [kerbcast](https://github.com/ksp-gonogo/kerbcast)
|
|
4
|
+
camera feeds. Drop a `<CameraFeed>` into your app and it handles WebRTC
|
|
5
|
+
streaming, camera selection, pan/zoom controls, quality throttling,
|
|
6
|
+
fullscreen, and the signal-loss and out-of-flight states for you.
|
|
4
7
|
|
|
5
|
-
This
|
|
6
|
-
|
|
8
|
+
This is the React layer on top of
|
|
9
|
+
[`@ksp-gonogo/kerbcast`](https://www.npmjs.com/package/@ksp-gonogo/kerbcast),
|
|
10
|
+
the core client. Use that package directly if you are not on React or
|
|
11
|
+
want the raw client.
|
|
7
12
|
|
|
8
13
|
## Install
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
```sh
|
|
16
|
+
pnpm add @ksp-gonogo/kerbcast-react @ksp-gonogo/kerbcast
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Peer dependencies: `react` (18 or 19), `react-dom`, and
|
|
20
|
+
`styled-components` (6). The core SDK is a normal dependency and comes
|
|
21
|
+
along automatically.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
Wrap your tree in a `KerbcastProvider` holding a connected client, then
|
|
26
|
+
render feeds. A `flightId` of `null` auto-selects the first live camera.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { KerbcastClient } from "@ksp-gonogo/kerbcast";
|
|
30
|
+
import { KerbcastProvider, CameraFeed } from "@ksp-gonogo/kerbcast-react";
|
|
31
|
+
|
|
32
|
+
const client = new KerbcastClient({ host: "192.168.1.74", port: 8088 });
|
|
33
|
+
await client.connect();
|
|
11
34
|
|
|
35
|
+
function Dashboard() {
|
|
36
|
+
return (
|
|
37
|
+
<KerbcastProvider client={client}>
|
|
38
|
+
<CameraFeed flightId={null} enableFullscreen enableQualityControl />
|
|
39
|
+
</KerbcastProvider>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
12
42
|
```
|
|
13
|
-
|
|
43
|
+
|
|
44
|
+
## `CameraFeed`
|
|
45
|
+
|
|
46
|
+
One camera's video with its overlays and controls. It subscribes to the
|
|
47
|
+
sidecar while mounted and releases on unmount, so mounting a feed is all
|
|
48
|
+
you need to start a stream. It never remounts the `<video>` element as
|
|
49
|
+
quality or source changes, so playback stays uninterrupted.
|
|
50
|
+
|
|
51
|
+
Commonly used props (`CameraFeedProps` has the full set with doc
|
|
52
|
+
comments):
|
|
53
|
+
|
|
54
|
+
- `flightId: number | null`. The camera to show. `null` latches the
|
|
55
|
+
first live camera and re-picks if it dies.
|
|
56
|
+
- `onSelectCamera` / `onDisplayedCameraChange`. The user picked a
|
|
57
|
+
camera, or the resolved camera changed (including auto-latch).
|
|
58
|
+
- `enableFullscreen`, `enablePictureInPicture`, `enableQualityControl`.
|
|
59
|
+
Opt-in built-in controls in the top-right action bar. Each hides
|
|
60
|
+
itself where the browser lacks support.
|
|
61
|
+
- `actions` / `trailingActions`. Your own `FeedAction` buttons in the
|
|
62
|
+
action bar (`trailingActions` sits in the corner, the natural home for
|
|
63
|
+
a close button).
|
|
64
|
+
- `showDebugInfo`. Resolution and encoder readout.
|
|
65
|
+
- `showStatic`. How a stalled or sourceless feed looks. Defaults to
|
|
66
|
+
auto, which honours `prefers-reduced-motion`.
|
|
67
|
+
- `inFlight` / `showStandbyIcon`. Override the in-flight signal for one
|
|
68
|
+
feed, and whether it draws its own standby icon (set `false` when a
|
|
69
|
+
container renders a single shared out-of-flight overlay).
|
|
70
|
+
- `useStream`. Override how the stream is sourced. See below.
|
|
71
|
+
|
|
72
|
+
An imperative `CameraFeedHandle` (via `ref`) exposes `stepCamera`,
|
|
73
|
+
`setPanAxis`, `setZoomRate`, `nudgePan`, and `nudgeZoom` for wiring feeds
|
|
74
|
+
to a gamepad or keyboard.
|
|
75
|
+
|
|
76
|
+
## Hooks
|
|
77
|
+
|
|
78
|
+
- `useKerbcastCameras(): CameraState[]`. The live camera registry,
|
|
79
|
+
re-rendering as cameras appear, change, or are destroyed.
|
|
80
|
+
- `useKerbcastStream(flightId): MediaStream | null`. The video stream
|
|
81
|
+
for one camera, acquiring and releasing its subscription slot. This is
|
|
82
|
+
what `CameraFeed` uses internally.
|
|
83
|
+
- `useKerbcastInFlight(): boolean | undefined`. Whether KSP is in a
|
|
84
|
+
flight scene. `undefined` until the first signal arrives, so you can
|
|
85
|
+
avoid flashing an out-of-flight state on connect.
|
|
86
|
+
- `useKerbcastClock(): { captureUt, epoch, warpRate }`. The sidecar's
|
|
87
|
+
mission-time capture clock, for aligning playout to sim time.
|
|
88
|
+
- `useKerbcastClient()` and `useKerbcastSubscriptions()`. The client
|
|
89
|
+
and subscription manager from context, for building your own feed UI.
|
|
90
|
+
|
|
91
|
+
## Standby icon
|
|
92
|
+
|
|
93
|
+
`StandbyIcon` is the shared rocket-on-the-pad glyph the feed shows out
|
|
94
|
+
of flight. Export it for a dashboard-level standby overlay so your own
|
|
95
|
+
message and the per-feed indicator use one consistent mark:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { StandbyIcon, useKerbcastInFlight } from "@ksp-gonogo/kerbcast-react";
|
|
99
|
+
|
|
100
|
+
function StandbyOverlay() {
|
|
101
|
+
const inFlight = useKerbcastInFlight();
|
|
102
|
+
// Only show once we know we are out of flight; stays hidden while
|
|
103
|
+
// the signal is still undefined so it never flashes on connect.
|
|
104
|
+
if (inFlight !== false) return null;
|
|
105
|
+
return (
|
|
106
|
+
<div className="scrim">
|
|
107
|
+
<StandbyIcon size={44} />
|
|
108
|
+
<p>Camera feeds activate in a flight scene.</p>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
14
112
|
```
|
|
15
113
|
|
|
16
|
-
|
|
114
|
+
## Custom stream sourcing
|
|
115
|
+
|
|
116
|
+
`useStream` lets you route a feed's video through your own pipeline
|
|
117
|
+
(delayed playout for comms-delay parity, an alternate transport, a test
|
|
118
|
+
double) without the feed knowing. It is called as a hook, so it must be
|
|
119
|
+
a stable reference passed consistently across renders.
|
|
120
|
+
|
|
121
|
+
A replacement takes over the camera's subscription slot: the built-in
|
|
122
|
+
`useKerbcastStream` does not run when `useStream` is supplied, so your
|
|
123
|
+
hook must either compose `useKerbcastStream` or acquire the slot itself,
|
|
124
|
+
or the sidecar is never subscribed and the feed stays black.
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import { useKerbcastStream, type CameraStreamHook } from "@ksp-gonogo/kerbcast-react";
|
|
128
|
+
|
|
129
|
+
// Module scope: a stable reference. Composes the built-in hook so the
|
|
130
|
+
// subscription slot is still acquired exactly once.
|
|
131
|
+
const useDelayedStream: CameraStreamHook = (flightId) => {
|
|
132
|
+
const live = useKerbcastStream(flightId);
|
|
133
|
+
return useDelayedPlayout(live); // your own wrapper
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
<CameraFeed flightId={null} useStream={useDelayedStream} />;
|
|
137
|
+
```
|
|
17
138
|
|
|
18
|
-
##
|
|
139
|
+
## License
|
|
19
140
|
|
|
20
|
-
|
|
21
|
-
sidecar page consume the same component without duplicating protocol or rendering code.
|
|
141
|
+
[CC BY-NC-SA 4.0](https://github.com/ksp-gonogo/kerbcast/blob/main/LICENSE).
|
|
22
142
|
|
|
23
143
|
## Versioning
|
|
24
144
|
|
|
25
|
-
|
|
26
|
-
`./scripts/bump-version.sh` bumps them atomically.
|
|
145
|
+
Tracks `@ksp-gonogo/kerbcast` exactly; use matching versions of both.
|
|
146
|
+
`./scripts/bump-version.sh` bumps them atomically. See
|
|
147
|
+
[CHANGELOG.md](https://github.com/ksp-gonogo/kerbcast/blob/main/client-sdk/react/CHANGELOG.md).
|
package/dist/CameraFeed.d.ts
CHANGED
|
@@ -62,6 +62,19 @@ export interface CameraFeedProps {
|
|
|
62
62
|
* (reduced motion defaults to off, normal motion defaults to on).
|
|
63
63
|
*/
|
|
64
64
|
showStatic?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Override the client's in-flight signal for this feed only. When known
|
|
67
|
+
* false, the feed shows the dimmed standby icon instead of SIGNAL LOST.
|
|
68
|
+
* Defaults to the client's `useKerbcastInFlight()` value.
|
|
69
|
+
*/
|
|
70
|
+
inFlight?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Show the per-feed standby icon when out of flight. Default true. Set
|
|
73
|
+
* false when a container renders its own single out-of-flight overlay
|
|
74
|
+
* (e.g. the kerbcast web dashboard) so the icon isn't drawn twice; the
|
|
75
|
+
* feed then just goes dark.
|
|
76
|
+
*/
|
|
77
|
+
showStandbyIcon?: boolean;
|
|
65
78
|
/**
|
|
66
79
|
* "auto" (default): ResizeObserver drives `setRenderSize` at a 16:9 crop,
|
|
67
80
|
* debounced 500 ms. "none": no render-size feedback.
|
package/dist/CameraFeed.js
CHANGED
|
@@ -6,7 +6,9 @@ import styled, { css } from "styled-components";
|
|
|
6
6
|
import { buildCameraLabeler } from "./cameraLabels";
|
|
7
7
|
import { KerbcastProvider, useKerbcastClient } from "./context";
|
|
8
8
|
import { useKerbcastCameras } from "./hooks/useKerbcastCameras";
|
|
9
|
+
import { useKerbcastInFlight } from "./hooks/useKerbcastInFlight";
|
|
9
10
|
import { useKerbcastStream } from "./hooks/useKerbcastStream";
|
|
11
|
+
import { StandbyIcon } from "./StandbyIcon";
|
|
10
12
|
import { isCameraDestroyed } from "./lifecycle";
|
|
11
13
|
// ---------------------------------------------------------------------------
|
|
12
14
|
// Tuning constants
|
|
@@ -147,9 +149,12 @@ function exitFullscreen() {
|
|
|
147
149
|
// ---------------------------------------------------------------------------
|
|
148
150
|
// Inner component (reads from context)
|
|
149
151
|
// ---------------------------------------------------------------------------
|
|
150
|
-
const CameraFeedInner = forwardRef(function CameraFeedInner({ flightId: requestedFlightId, onSelectCamera, onDisplayedCameraChange, showDebugInfo = false, showStatic, renderSize = "auto", emptyMessage = "No camera feeds - start a vessel with Hullcam parts installed", enableFullscreen = false, enablePictureInPicture = false, enableQualityControl = false, actions, trailingActions, useStream, }, ref) {
|
|
152
|
+
const CameraFeedInner = forwardRef(function CameraFeedInner({ flightId: requestedFlightId, onSelectCamera, onDisplayedCameraChange, showDebugInfo = false, showStatic, inFlight: inFlightProp, showStandbyIcon = true, renderSize = "auto", emptyMessage = "No camera feeds - start a vessel with Hullcam parts installed", enableFullscreen = false, enablePictureInPicture = false, enableQualityControl = false, actions, trailingActions, useStream, }, ref) {
|
|
151
153
|
const client = useKerbcastClient();
|
|
152
154
|
const cameras = useKerbcastCameras();
|
|
155
|
+
const inFlightFromClient = useKerbcastInFlight();
|
|
156
|
+
const inFlight = inFlightProp ?? inFlightFromClient;
|
|
157
|
+
const outOfFlight = inFlight === false;
|
|
153
158
|
/*
|
|
154
159
|
* Reduced-motion auto mode: when `showStatic` prop is undefined, read and
|
|
155
160
|
* track `prefers-reduced-motion: reduce`. Reduced motion defaults to off
|
|
@@ -507,7 +512,7 @@ const CameraFeedInner = forwardRef(function CameraFeedInner({ flightId: requeste
|
|
|
507
512
|
void client.camera(flightId).setQuality(preset);
|
|
508
513
|
closeQualityMenu();
|
|
509
514
|
}, [client, flightId, closeQualityMenu]);
|
|
510
|
-
const topOverlay = (_jsxs(TopOverlay, { children: [
|
|
515
|
+
const topOverlay = (_jsxs(TopOverlay, { children: [_jsx(TitleRow, { children: _jsx(TopTitle, { children: hasCameras ? (_jsxs(TitleButton, { ref: cameraMenu.triggerRef, type: "button", "aria-haspopup": "menu", "aria-expanded": cameraMenu.open, "aria-controls": menuId, onClick: cameraMenu.toggle, children: [_jsx(TitleButton__Text, { children: title }), _jsx(ChevronDownIcon, { "aria-hidden": "true" })] })) : (title) }) }), cameraMenu.open &&
|
|
511
516
|
hasCameras &&
|
|
512
517
|
cameraMenu.position &&
|
|
513
518
|
createPortal(_jsx(CameraMenu, { ref: cameraMenu.menuRef, id: menuId, role: "menu", "aria-label": "Camera", style: cameraMenu.position, children: cameras.map((c) => (_jsxs(CameraMenuItem, { type: "button", role: "menuitemradio", "aria-checked": c.flightId === flightId, "$selected": c.flightId === flightId, onClick: () => {
|
|
@@ -517,17 +522,18 @@ const CameraFeedInner = forwardRef(function CameraFeedInner({ flightId: requeste
|
|
|
517
522
|
(camera ? (_jsxs(TopMeta, { children: [camera.vesselName, " \u00B7 ", camera.renderWidth, "\u00D7", camera.renderHeight, bitrateLabel, adaptiveLabel] })) : (_jsx(TopMeta, { children: "no cameras on this vessel" })))] }));
|
|
518
523
|
const renderAction = (a) => (_jsx(OverlayIconButton, { type: "button", "aria-label": a.label, "aria-pressed": a.active ?? undefined, title: a.label, "$active": a.active ?? false, onClick: a.onClick, children: a.icon }, a.id));
|
|
519
524
|
const builtInActions = flightId !== null && (pipAvailable || fullscreenAvailable || qualityAvailable);
|
|
520
|
-
const hasActionBar =
|
|
525
|
+
const hasActionBar = hasCameras ||
|
|
526
|
+
(actions && actions.length > 0) ||
|
|
521
527
|
(trailingActions && trailingActions.length > 0) ||
|
|
522
528
|
builtInActions;
|
|
523
|
-
const actionBar = hasActionBar ? (_jsxs(ActionBar, { children: [actions?.map(renderAction), qualityAvailable && (_jsxs(OverlayIconButton, { ref: qualityMenu.triggerRef, type: "button", "aria-label": "Quality", "aria-haspopup": "menu", "aria-expanded": qualityMenu.open, "aria-controls": qualityMenuId, title: qualityThrottled
|
|
529
|
+
const actionBar = hasActionBar ? (_jsxs(ActionBar, { children: [hasCameras && (_jsxs(StepButtons, { children: [_jsx(OverlayIconButton, { type: "button", "aria-label": "Previous camera", disabled: !canStep, onClick: () => stepCamera(-1), children: "\u2039" }), _jsx(OverlayIconButton, { type: "button", "aria-label": "Next camera", disabled: !canStep, onClick: () => stepCamera(1), children: "\u203A" })] })), actions?.map(renderAction), qualityAvailable && (_jsxs(OverlayIconButton, { ref: qualityMenu.triggerRef, type: "button", "aria-label": "Quality", "aria-haspopup": "menu", "aria-expanded": qualityMenu.open, "aria-controls": qualityMenuId, title: qualityThrottled
|
|
524
530
|
? "Quality (throttled by adaptive performance)"
|
|
525
531
|
: "Quality", "$active": qualityMenu.open, onClick: qualityMenu.toggle, children: [_jsx(QualityIcon, {}), qualityThrottled && _jsx(ThrottledDot, { "aria-hidden": "true" })] })), flightId !== null && pipAvailable && (_jsx(OverlayIconButton, { type: "button", "aria-label": isPip ? "Exit picture in picture" : "Picture in picture", "aria-pressed": isPip, title: isPip ? "Exit picture in picture" : "Picture in picture", "$active": isPip, onClick: togglePip, children: _jsx(PictureInPictureIcon, {}) })), flightId !== null && fullscreenAvailable && (_jsx(OverlayIconButton, { type: "button", "aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen", "aria-pressed": isFullscreen, title: isFullscreen ? "Exit fullscreen" : "Enter fullscreen", "$active": isFullscreen, onClick: toggleFullscreen, children: isFullscreen ? _jsx(FullscreenExitIcon, {}) : _jsx(FullscreenEnterIcon, {}) })), trailingActions?.map(renderAction)] })) : null;
|
|
526
532
|
return (_jsx(Stage, { ref: wrapRef, "$pinned": chromePinned, children: flightId === null ? (_jsxs(_Fragment, { children: [_jsx(Empty, { children: emptyMessage }), topOverlay, actionBar] })) : (_jsxs(_Fragment, { children: [_jsx(StyledVideo, { ref: videoRef, autoPlay: true, playsInline: true, muted: true, controls: false, onClick: () => setChromePinned((v) => !v) }), topOverlay, actionBar, qualityAvailable &&
|
|
527
533
|
qualityMenu.open &&
|
|
528
534
|
qualityMenu.position &&
|
|
529
535
|
camera &&
|
|
530
|
-
createPortal(_jsxs(QualityMenu, { ref: qualityMenu.menuRef, id: qualityMenuId, role: "menu", "aria-label": "Quality", style: qualityMenu.position, children: [_jsx(CameraMenuItem, { type: "button", role: "menuitemradio", "aria-checked": camera.viewerQuality == null, "$selected": camera.viewerQuality == null, onClick: () => selectQuality(null), children: "Auto" }), QUALITY_PRESETS.map(({ preset, label, scale }) => (_jsxs(CameraMenuItem, { type: "button", role: "menuitemradio", "aria-checked": camera.viewerQuality === preset, "$selected": camera.viewerQuality === preset, onClick: () => selectQuality(preset), children: [label, " (", presetDim(camera.operatorWidth, scale), "\u00D7", presetDim(camera.operatorHeight, scale), ")"] }, preset))), _jsxs(QualityMeta, { role: "status", children: ["now ", camera.renderWidth, "\u00D7", camera.renderHeight, qualityThrottled ? " · throttled" : ""] })] }), document.body), isDestroyed && (_jsx(SignalLostOverlay, { role: "status", "aria-label": "Signal lost", children: _jsx(SignalLostText, { "$animated": effectiveShowStatic, children: "SIGNAL LOST" }) })), !effectiveShowStatic && isStale && !isDestroyed && (_jsxs(_Fragment, { children: [_jsx(StaleScrim, { "aria-hidden": "true" }), _jsxs(StaleBadge, { role: "status", "aria-label": "Feed stale", children: [_jsx(StaleIcon, {}), "Stale"] })] })), showZoom && (_jsxs(ZoomControlsWrap, { children: [_jsx(ZoomButton, { type: "button", "aria-label": "Zoom in", "$pos": "top", onPointerDown: () => controllerRef.current?.setZoomRate(1), onPointerUp: () => controllerRef.current?.setZoomRate(0), onPointerLeave: () => controllerRef.current?.setZoomRate(0), onPointerCancel: () => controllerRef.current?.setZoomRate(0), onClick: (e) => {
|
|
536
|
+
createPortal(_jsxs(QualityMenu, { ref: qualityMenu.menuRef, id: qualityMenuId, role: "menu", "aria-label": "Quality", style: qualityMenu.position, children: [_jsx(CameraMenuItem, { type: "button", role: "menuitemradio", "aria-checked": camera.viewerQuality == null, "$selected": camera.viewerQuality == null, onClick: () => selectQuality(null), children: "Auto" }), QUALITY_PRESETS.map(({ preset, label, scale }) => (_jsxs(CameraMenuItem, { type: "button", role: "menuitemradio", "aria-checked": camera.viewerQuality === preset, "$selected": camera.viewerQuality === preset, onClick: () => selectQuality(preset), children: [label, " (", presetDim(camera.operatorWidth, scale), "\u00D7", presetDim(camera.operatorHeight, scale), ")"] }, preset))), _jsxs(QualityMeta, { role: "status", children: ["now ", camera.renderWidth, "\u00D7", camera.renderHeight, qualityThrottled ? " · throttled" : ""] })] }), document.body), outOfFlight ? (showStandbyIcon && (_jsx(StandbyOverlay, { role: "status", "aria-label": "Standby, no active flight", children: _jsx(StandbyIconWrap, { children: _jsx(StandbyIcon, { size: 40 }) }) }))) : (isDestroyed && (_jsx(SignalLostOverlay, { role: "status", "aria-label": "Signal lost", children: _jsx(SignalLostText, { "$animated": effectiveShowStatic, children: "SIGNAL LOST" }) }))), !outOfFlight && !effectiveShowStatic && isStale && !isDestroyed && (_jsxs(_Fragment, { children: [_jsx(StaleScrim, { "aria-hidden": "true" }), _jsxs(StaleBadge, { role: "status", "aria-label": "Feed stale", children: [_jsx(StaleIcon, {}), "Stale"] })] })), showZoom && (_jsxs(ZoomControlsWrap, { children: [_jsx(ZoomButton, { type: "button", "aria-label": "Zoom in", "$pos": "top", onPointerDown: () => controllerRef.current?.setZoomRate(1), onPointerUp: () => controllerRef.current?.setZoomRate(0), onPointerLeave: () => controllerRef.current?.setZoomRate(0), onPointerCancel: () => controllerRef.current?.setZoomRate(0), onClick: (e) => {
|
|
531
537
|
if (e.detail === 0)
|
|
532
538
|
controllerRef.current?.nudgeZoom(-1);
|
|
533
539
|
}, children: "+" }), _jsx(FovSlider, { type: "range", "aria-label": "Zoom", min: camera.fovMin, max: camera.fovMax, step: 0.5, value: sliderFov, onChange: (e) => {
|
|
@@ -741,8 +747,11 @@ const TopOverlay = styled.div `
|
|
|
741
747
|
const TitleRow = styled.div `
|
|
742
748
|
display: flex;
|
|
743
749
|
align-items: flex-start;
|
|
744
|
-
justify-content: space-between;
|
|
745
750
|
gap: 8px;
|
|
751
|
+
/* Reserve the top-right corner where the ActionBar overlay sits (now home
|
|
752
|
+
to the camera step buttons too) so a long title ellipsizes rather than
|
|
753
|
+
sliding underneath the controls. */
|
|
754
|
+
padding-right: 96px;
|
|
746
755
|
`;
|
|
747
756
|
const TopTitle = styled.h3 `
|
|
748
757
|
margin: 0;
|
|
@@ -1035,6 +1044,20 @@ const SignalLostOverlay = styled.div `
|
|
|
1035
1044
|
justify-content: center;
|
|
1036
1045
|
background: rgba(0, 0, 0, 0.25);
|
|
1037
1046
|
`;
|
|
1047
|
+
/* Out-of-flight standby: a dark dimmed cover with the shared hard-hat icon
|
|
1048
|
+
only. Supersedes SIGNAL LOST for the whole-scene case; the client keeps
|
|
1049
|
+
the feed blank behind it so no static bleeds through. */
|
|
1050
|
+
const StandbyOverlay = styled.div `
|
|
1051
|
+
position: absolute;
|
|
1052
|
+
inset: 0;
|
|
1053
|
+
display: flex;
|
|
1054
|
+
align-items: center;
|
|
1055
|
+
justify-content: center;
|
|
1056
|
+
background: rgba(0, 0, 0, 0.55);
|
|
1057
|
+
`;
|
|
1058
|
+
const StandbyIconWrap = styled.div `
|
|
1059
|
+
color: rgba(255, 255, 255, 0.55);
|
|
1060
|
+
`;
|
|
1038
1061
|
const SignalLostText = styled.span `
|
|
1039
1062
|
color: #ff4444;
|
|
1040
1063
|
font-size: 1.1rem;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared standby glyph: a rocket on the pad ("waiting for a flight"). Used by
|
|
3
|
+
* the CameraFeed out-of-flight overlay and the web dashboard standby so the
|
|
4
|
+
* two read as one system. Inherits `currentColor`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function StandbyIcon({ size }: {
|
|
7
|
+
size?: number;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Shared standby glyph: a rocket on the pad ("waiting for a flight"). Used by
|
|
4
|
+
* the CameraFeed out-of-flight overlay and the web dashboard standby so the
|
|
5
|
+
* two read as one system. Inherits `currentColor`.
|
|
6
|
+
*/
|
|
7
|
+
export function StandbyIcon({ size = 32 }) {
|
|
8
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M12 2.5c1.7 1.9 2.6 4.5 2.6 7.3V16H9.4V9.8C9.4 7 10.3 4.4 12 2.5Z" }), _jsx("circle", { cx: "12", cy: "8.8", r: "1.3" }), _jsx("path", { d: "M9.4 13 7.2 16.8 9.4 15.8Z" }), _jsx("path", { d: "M14.6 13 16.8 16.8 14.6 15.8Z" }), _jsx("path", { d: "M10 16 9 20.3" }), _jsx("path", { d: "M14 16 15 20.3" }), _jsx("path", { d: "M4.5 20.5h15" })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useKerbcastClient } from "../context";
|
|
3
|
+
/** Whether KSP is in a flight scene. `undefined` until the first signal. */
|
|
4
|
+
export function useKerbcastInFlight() {
|
|
5
|
+
const client = useKerbcastClient();
|
|
6
|
+
const [inFlight, setInFlight] = useState(() => client.inFlight);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
setInFlight(client.inFlight);
|
|
9
|
+
return client.on("scene-change", () => setInFlight(client.inFlight));
|
|
10
|
+
}, [client]);
|
|
11
|
+
return inFlight;
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export type { KerbcastProviderProps, KerbcastSubscriptions } from "./context";
|
|
|
10
10
|
export { useKerbcastCameras } from "./hooks/useKerbcastCameras";
|
|
11
11
|
export { useKerbcastStream } from "./hooks/useKerbcastStream";
|
|
12
12
|
export { useKerbcastClock } from "./hooks/useKerbcastClock";
|
|
13
|
+
export { useKerbcastInFlight } from "./hooks/useKerbcastInFlight";
|
|
14
|
+
export { StandbyIcon } from "./StandbyIcon";
|
|
13
15
|
export { buildCameraLabeler } from "./cameraLabels";
|
|
14
16
|
export type { LabelableCamera } from "./cameraLabels";
|
|
15
17
|
export { getCameraLifecycle, isCameraDestroyed } from "./lifecycle";
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,9 @@ export { KerbcastProvider, createClientSubscriptions, useKerbcastClient, useKerb
|
|
|
11
11
|
export { useKerbcastCameras } from "./hooks/useKerbcastCameras";
|
|
12
12
|
export { useKerbcastStream } from "./hooks/useKerbcastStream";
|
|
13
13
|
export { useKerbcastClock } from "./hooks/useKerbcastClock";
|
|
14
|
+
export { useKerbcastInFlight } from "./hooks/useKerbcastInFlight";
|
|
15
|
+
// Shared standby glyph (used by CameraFeed + downstream dashboards)
|
|
16
|
+
export { StandbyIcon } from "./StandbyIcon";
|
|
14
17
|
// Camera label utilities
|
|
15
18
|
export { buildCameraLabeler } from "./cameraLabels";
|
|
16
19
|
// Lifecycle utilities
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ksp-gonogo/kerbcast-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "React components and hooks for kerbcast camera feeds.",
|
|
5
5
|
"license": "CC-BY-NC-SA-4.0",
|
|
6
6
|
"author": "Jon Pepler",
|
|
@@ -35,11 +35,17 @@
|
|
|
35
35
|
"README.md",
|
|
36
36
|
"CHANGELOG.md"
|
|
37
37
|
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"prepublishOnly": "pnpm run build"
|
|
43
|
+
},
|
|
38
44
|
"publishConfig": {
|
|
39
45
|
"access": "public"
|
|
40
46
|
},
|
|
41
47
|
"dependencies": {
|
|
42
|
-
"@ksp-gonogo/kerbcast": "
|
|
48
|
+
"@ksp-gonogo/kerbcast": "workspace:^"
|
|
43
49
|
},
|
|
44
50
|
"peerDependencies": {
|
|
45
51
|
"react": "^18 || ^19",
|
|
@@ -58,10 +64,5 @@
|
|
|
58
64
|
"styled-components": "^6.0.0",
|
|
59
65
|
"typescript": "^5.4.0",
|
|
60
66
|
"vitest": "^4.1.4"
|
|
61
|
-
},
|
|
62
|
-
"scripts": {
|
|
63
|
-
"build": "tsc",
|
|
64
|
-
"test": "vitest run",
|
|
65
|
-
"typecheck": "tsc --noEmit"
|
|
66
67
|
}
|
|
67
|
-
}
|
|
68
|
+
}
|
package/src/CameraFeed.test.tsx
CHANGED
|
@@ -155,6 +155,7 @@ function renderFeed(
|
|
|
155
155
|
renderSize?: "auto" | "none";
|
|
156
156
|
enableQualityControl?: boolean;
|
|
157
157
|
showStatic?: boolean;
|
|
158
|
+
showStandbyIcon?: boolean;
|
|
158
159
|
ref?: React.Ref<CameraFeedHandle>;
|
|
159
160
|
},
|
|
160
161
|
) {
|
|
@@ -444,6 +445,39 @@ describe("CameraFeed - camera selection", () => {
|
|
|
444
445
|
).toBe(true);
|
|
445
446
|
});
|
|
446
447
|
|
|
448
|
+
it("renders step buttons inside the action bar alongside injected actions", async () => {
|
|
449
|
+
// Regression: the step buttons used to sit in the title row and were
|
|
450
|
+
// covered by the separately-positioned action bar (and any consumer
|
|
451
|
+
// action buttons) in the top-right corner. They now share the action
|
|
452
|
+
// bar so the two lay out in one flex row instead of overlapping.
|
|
453
|
+
const { client } = await buildConnectedSource(THREE_CAMERAS);
|
|
454
|
+
|
|
455
|
+
render(
|
|
456
|
+
<KerbcastProvider client={client}>
|
|
457
|
+
<CameraFeed
|
|
458
|
+
flightId={42}
|
|
459
|
+
actions={[
|
|
460
|
+
{
|
|
461
|
+
id: "custom",
|
|
462
|
+
label: "Custom action",
|
|
463
|
+
icon: <span>x</span>,
|
|
464
|
+
onClick: () => {},
|
|
465
|
+
},
|
|
466
|
+
]}
|
|
467
|
+
/>
|
|
468
|
+
</KerbcastProvider>,
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
const next = screen.getByRole("button", { name: /next camera/i });
|
|
472
|
+
const custom = screen.getByRole("button", { name: /custom action/i });
|
|
473
|
+
|
|
474
|
+
// The injected action's parent is the action bar; the step buttons live
|
|
475
|
+
// in a wrapper within that same action bar, so it contains both.
|
|
476
|
+
const actionBar = custom.parentElement;
|
|
477
|
+
expect(actionBar).not.toBeNull();
|
|
478
|
+
expect(actionBar?.contains(next)).toBe(true);
|
|
479
|
+
});
|
|
480
|
+
|
|
447
481
|
it("Escape closes the open camera menu", async () => {
|
|
448
482
|
const { client } = await buildConnectedSource(THREE_CAMERAS);
|
|
449
483
|
|
|
@@ -556,6 +590,48 @@ describe("CameraFeed - SIGNAL LOST overlay", () => {
|
|
|
556
590
|
expect(overlay.textContent).toMatch(/SIGNAL LOST/i);
|
|
557
591
|
});
|
|
558
592
|
|
|
593
|
+
it("shows the standby icon (not SIGNAL LOST) when out of flight", async () => {
|
|
594
|
+
const { client, sidecar } = await buildConnectedSource();
|
|
595
|
+
|
|
596
|
+
renderFeed(client, { flightId: 42 });
|
|
597
|
+
|
|
598
|
+
await act(async () => {
|
|
599
|
+
sidecar.fireSceneState(false);
|
|
600
|
+
sidecar.destroyCamera(42);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
expect(screen.queryByRole("status", { name: /signal lost/i })).toBeNull();
|
|
604
|
+
expect(screen.getByRole("status", { name: /standby/i })).toBeTruthy();
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
it("hides the per-feed standby icon when showStandbyIcon is false", async () => {
|
|
608
|
+
const { client, sidecar } = await buildConnectedSource();
|
|
609
|
+
|
|
610
|
+
renderFeed(client, { flightId: 42, showStandbyIcon: false });
|
|
611
|
+
|
|
612
|
+
await act(async () => {
|
|
613
|
+
sidecar.fireSceneState(false);
|
|
614
|
+
sidecar.destroyCamera(42);
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
expect(screen.queryByRole("status", { name: /standby/i })).toBeNull();
|
|
618
|
+
expect(screen.queryByRole("status", { name: /signal lost/i })).toBeNull();
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
it("keeps SIGNAL LOST for a single destroyed camera while in flight", async () => {
|
|
622
|
+
const { client, sidecar } = await buildConnectedSource();
|
|
623
|
+
|
|
624
|
+
renderFeed(client, { flightId: 42 });
|
|
625
|
+
|
|
626
|
+
await act(async () => {
|
|
627
|
+
sidecar.fireSceneState(true);
|
|
628
|
+
sidecar.destroyCamera(42);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
expect(screen.getByRole("status", { name: /signal lost/i })).toBeTruthy();
|
|
632
|
+
expect(screen.queryByRole("status", { name: /standby/i })).toBeNull();
|
|
633
|
+
});
|
|
634
|
+
|
|
559
635
|
it("auto-latch releases a destroyed camera once a live camera exists (vessel switch)", async () => {
|
|
560
636
|
const { client, sidecar } = await buildConnectedSource([
|
|
561
637
|
makeCamera({ flightId: 42, cameraName: "Old Vessel Cam" }),
|
package/src/CameraFeed.tsx
CHANGED
|
@@ -15,7 +15,9 @@ import styled, { css } from "styled-components";
|
|
|
15
15
|
import { buildCameraLabeler } from "./cameraLabels";
|
|
16
16
|
import { KerbcastProvider, useKerbcastClient } from "./context";
|
|
17
17
|
import { useKerbcastCameras } from "./hooks/useKerbcastCameras";
|
|
18
|
+
import { useKerbcastInFlight } from "./hooks/useKerbcastInFlight";
|
|
18
19
|
import { useKerbcastStream } from "./hooks/useKerbcastStream";
|
|
20
|
+
import { StandbyIcon } from "./StandbyIcon";
|
|
19
21
|
import { isCameraDestroyed } from "./lifecycle";
|
|
20
22
|
|
|
21
23
|
// ---------------------------------------------------------------------------
|
|
@@ -275,6 +277,19 @@ export interface CameraFeedProps {
|
|
|
275
277
|
* (reduced motion defaults to off, normal motion defaults to on).
|
|
276
278
|
*/
|
|
277
279
|
showStatic?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Override the client's in-flight signal for this feed only. When known
|
|
282
|
+
* false, the feed shows the dimmed standby icon instead of SIGNAL LOST.
|
|
283
|
+
* Defaults to the client's `useKerbcastInFlight()` value.
|
|
284
|
+
*/
|
|
285
|
+
inFlight?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Show the per-feed standby icon when out of flight. Default true. Set
|
|
288
|
+
* false when a container renders its own single out-of-flight overlay
|
|
289
|
+
* (e.g. the kerbcast web dashboard) so the icon isn't drawn twice; the
|
|
290
|
+
* feed then just goes dark.
|
|
291
|
+
*/
|
|
292
|
+
showStandbyIcon?: boolean;
|
|
278
293
|
/**
|
|
279
294
|
* "auto" (default): ResizeObserver drives `setRenderSize` at a 16:9 crop,
|
|
280
295
|
* debounced 500 ms. "none": no render-size feedback.
|
|
@@ -345,6 +360,8 @@ const CameraFeedInner = forwardRef<CameraFeedHandle, CameraFeedProps>(
|
|
|
345
360
|
onDisplayedCameraChange,
|
|
346
361
|
showDebugInfo = false,
|
|
347
362
|
showStatic,
|
|
363
|
+
inFlight: inFlightProp,
|
|
364
|
+
showStandbyIcon = true,
|
|
348
365
|
renderSize = "auto",
|
|
349
366
|
emptyMessage = "No camera feeds - start a vessel with Hullcam parts installed",
|
|
350
367
|
enableFullscreen = false,
|
|
@@ -358,6 +375,9 @@ const CameraFeedInner = forwardRef<CameraFeedHandle, CameraFeedProps>(
|
|
|
358
375
|
) {
|
|
359
376
|
const client = useKerbcastClient();
|
|
360
377
|
const cameras = useKerbcastCameras();
|
|
378
|
+
const inFlightFromClient = useKerbcastInFlight();
|
|
379
|
+
const inFlight = inFlightProp ?? inFlightFromClient;
|
|
380
|
+
const outOfFlight = inFlight === false;
|
|
361
381
|
|
|
362
382
|
/*
|
|
363
383
|
* Reduced-motion auto mode: when `showStatic` prop is undefined, read and
|
|
@@ -776,26 +796,6 @@ const CameraFeedInner = forwardRef<CameraFeedHandle, CameraFeedProps>(
|
|
|
776
796
|
title
|
|
777
797
|
)}
|
|
778
798
|
</TopTitle>
|
|
779
|
-
{hasCameras && (
|
|
780
|
-
<StepButtons>
|
|
781
|
-
<OverlayIconButton
|
|
782
|
-
type="button"
|
|
783
|
-
aria-label="Previous camera"
|
|
784
|
-
disabled={!canStep}
|
|
785
|
-
onClick={() => stepCamera(-1)}
|
|
786
|
-
>
|
|
787
|
-
‹
|
|
788
|
-
</OverlayIconButton>
|
|
789
|
-
<OverlayIconButton
|
|
790
|
-
type="button"
|
|
791
|
-
aria-label="Next camera"
|
|
792
|
-
disabled={!canStep}
|
|
793
|
-
onClick={() => stepCamera(1)}
|
|
794
|
-
>
|
|
795
|
-
›
|
|
796
|
-
</OverlayIconButton>
|
|
797
|
-
</StepButtons>
|
|
798
|
-
)}
|
|
799
799
|
</TitleRow>
|
|
800
800
|
|
|
801
801
|
{cameraMenu.open &&
|
|
@@ -859,11 +859,32 @@ const CameraFeedInner = forwardRef<CameraFeedHandle, CameraFeedProps>(
|
|
|
859
859
|
const builtInActions =
|
|
860
860
|
flightId !== null && (pipAvailable || fullscreenAvailable || qualityAvailable);
|
|
861
861
|
const hasActionBar =
|
|
862
|
+
hasCameras ||
|
|
862
863
|
(actions && actions.length > 0) ||
|
|
863
864
|
(trailingActions && trailingActions.length > 0) ||
|
|
864
865
|
builtInActions;
|
|
865
866
|
const actionBar = hasActionBar ? (
|
|
866
867
|
<ActionBar>
|
|
868
|
+
{hasCameras && (
|
|
869
|
+
<StepButtons>
|
|
870
|
+
<OverlayIconButton
|
|
871
|
+
type="button"
|
|
872
|
+
aria-label="Previous camera"
|
|
873
|
+
disabled={!canStep}
|
|
874
|
+
onClick={() => stepCamera(-1)}
|
|
875
|
+
>
|
|
876
|
+
‹
|
|
877
|
+
</OverlayIconButton>
|
|
878
|
+
<OverlayIconButton
|
|
879
|
+
type="button"
|
|
880
|
+
aria-label="Next camera"
|
|
881
|
+
disabled={!canStep}
|
|
882
|
+
onClick={() => stepCamera(1)}
|
|
883
|
+
>
|
|
884
|
+
›
|
|
885
|
+
</OverlayIconButton>
|
|
886
|
+
</StepButtons>
|
|
887
|
+
)}
|
|
867
888
|
{actions?.map(renderAction)}
|
|
868
889
|
{qualityAvailable && (
|
|
869
890
|
<OverlayIconButton
|
|
@@ -974,12 +995,24 @@ const CameraFeedInner = forwardRef<CameraFeedHandle, CameraFeedProps>(
|
|
|
974
995
|
</QualityMenu>,
|
|
975
996
|
document.body,
|
|
976
997
|
)}
|
|
977
|
-
{
|
|
978
|
-
|
|
979
|
-
<
|
|
980
|
-
|
|
998
|
+
{outOfFlight ? (
|
|
999
|
+
showStandbyIcon && (
|
|
1000
|
+
<StandbyOverlay role="status" aria-label="Standby, no active flight">
|
|
1001
|
+
<StandbyIconWrap>
|
|
1002
|
+
<StandbyIcon size={40} />
|
|
1003
|
+
</StandbyIconWrap>
|
|
1004
|
+
</StandbyOverlay>
|
|
1005
|
+
)
|
|
1006
|
+
) : (
|
|
1007
|
+
isDestroyed && (
|
|
1008
|
+
<SignalLostOverlay role="status" aria-label="Signal lost">
|
|
1009
|
+
<SignalLostText $animated={effectiveShowStatic}>
|
|
1010
|
+
SIGNAL LOST
|
|
1011
|
+
</SignalLostText>
|
|
1012
|
+
</SignalLostOverlay>
|
|
1013
|
+
)
|
|
981
1014
|
)}
|
|
982
|
-
{!effectiveShowStatic && isStale && !isDestroyed && (
|
|
1015
|
+
{!outOfFlight && !effectiveShowStatic && isStale && !isDestroyed && (
|
|
983
1016
|
<>
|
|
984
1017
|
<StaleScrim aria-hidden="true" />
|
|
985
1018
|
<StaleBadge role="status" aria-label="Feed stale">
|
|
@@ -1361,8 +1394,11 @@ const TopOverlay = styled.div`
|
|
|
1361
1394
|
const TitleRow = styled.div`
|
|
1362
1395
|
display: flex;
|
|
1363
1396
|
align-items: flex-start;
|
|
1364
|
-
justify-content: space-between;
|
|
1365
1397
|
gap: 8px;
|
|
1398
|
+
/* Reserve the top-right corner where the ActionBar overlay sits (now home
|
|
1399
|
+
to the camera step buttons too) so a long title ellipsizes rather than
|
|
1400
|
+
sliding underneath the controls. */
|
|
1401
|
+
padding-right: 96px;
|
|
1366
1402
|
`;
|
|
1367
1403
|
|
|
1368
1404
|
const TopTitle = styled.h3`
|
|
@@ -1678,6 +1714,22 @@ const SignalLostOverlay = styled.div`
|
|
|
1678
1714
|
background: rgba(0, 0, 0, 0.25);
|
|
1679
1715
|
`;
|
|
1680
1716
|
|
|
1717
|
+
/* Out-of-flight standby: a dark dimmed cover with the shared hard-hat icon
|
|
1718
|
+
only. Supersedes SIGNAL LOST for the whole-scene case; the client keeps
|
|
1719
|
+
the feed blank behind it so no static bleeds through. */
|
|
1720
|
+
const StandbyOverlay = styled.div`
|
|
1721
|
+
position: absolute;
|
|
1722
|
+
inset: 0;
|
|
1723
|
+
display: flex;
|
|
1724
|
+
align-items: center;
|
|
1725
|
+
justify-content: center;
|
|
1726
|
+
background: rgba(0, 0, 0, 0.55);
|
|
1727
|
+
`;
|
|
1728
|
+
|
|
1729
|
+
const StandbyIconWrap = styled.div`
|
|
1730
|
+
color: rgba(255, 255, 255, 0.55);
|
|
1731
|
+
`;
|
|
1732
|
+
|
|
1681
1733
|
const SignalLostText = styled.span<{ $animated: boolean }>`
|
|
1682
1734
|
color: #ff4444;
|
|
1683
1735
|
font-size: 1.1rem;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared standby glyph: a rocket on the pad ("waiting for a flight"). Used by
|
|
3
|
+
* the CameraFeed out-of-flight overlay and the web dashboard standby so the
|
|
4
|
+
* two read as one system. Inherits `currentColor`.
|
|
5
|
+
*/
|
|
6
|
+
export function StandbyIcon({ size = 32 }: { size?: number }) {
|
|
7
|
+
return (
|
|
8
|
+
<svg
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
width={size}
|
|
11
|
+
height={size}
|
|
12
|
+
fill="none"
|
|
13
|
+
stroke="currentColor"
|
|
14
|
+
strokeWidth={1.6}
|
|
15
|
+
strokeLinecap="round"
|
|
16
|
+
strokeLinejoin="round"
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
>
|
|
19
|
+
{/* body + nose cone */}
|
|
20
|
+
<path d="M12 2.5c1.7 1.9 2.6 4.5 2.6 7.3V16H9.4V9.8C9.4 7 10.3 4.4 12 2.5Z" />
|
|
21
|
+
{/* window */}
|
|
22
|
+
<circle cx="12" cy="8.8" r="1.3" />
|
|
23
|
+
{/* fins */}
|
|
24
|
+
<path d="M9.4 13 7.2 16.8 9.4 15.8Z" />
|
|
25
|
+
<path d="M14.6 13 16.8 16.8 14.6 15.8Z" />
|
|
26
|
+
{/* launch-clamp legs to the pad */}
|
|
27
|
+
<path d="M10 16 9 20.3" />
|
|
28
|
+
<path d="M14 16 15 20.3" />
|
|
29
|
+
{/* pad ground line */}
|
|
30
|
+
<path d="M4.5 20.5h15" />
|
|
31
|
+
</svg>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useKerbcastInFlight scene-state subscription.
|
|
3
|
+
*
|
|
4
|
+
* Renders a probe through the real hook + real KerbcastClient with only the
|
|
5
|
+
* WebRTC transport faked by the SDK's MockSidecar. Asserts the hook starts
|
|
6
|
+
* undefined (no signal yet) and re-renders on each `scene-state-changed`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { KerbcastClient } from "@ksp-gonogo/kerbcast";
|
|
10
|
+
import { MockSidecar } from "@ksp-gonogo/kerbcast/testing";
|
|
11
|
+
import { act, cleanup, render } from "@testing-library/react";
|
|
12
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
13
|
+
import { KerbcastProvider } from "../context";
|
|
14
|
+
import { useKerbcastInFlight } from "./useKerbcastInFlight";
|
|
15
|
+
|
|
16
|
+
let last: boolean | undefined;
|
|
17
|
+
|
|
18
|
+
function Probe(): null {
|
|
19
|
+
last = useKerbcastInFlight();
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function connected(): Promise<{
|
|
24
|
+
client: KerbcastClient;
|
|
25
|
+
sidecar: MockSidecar;
|
|
26
|
+
}> {
|
|
27
|
+
const sidecar = new MockSidecar();
|
|
28
|
+
const client = new KerbcastClient(
|
|
29
|
+
{ host: "h", port: 1, negotiate: (o) => sidecar.negotiate(o) },
|
|
30
|
+
sidecar.createTransport(),
|
|
31
|
+
);
|
|
32
|
+
await act(async () => {
|
|
33
|
+
await client.connect([], { slots: 4 });
|
|
34
|
+
sidecar.open();
|
|
35
|
+
sidecar.setConnectionState("connected");
|
|
36
|
+
});
|
|
37
|
+
return { client, sidecar };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
cleanup();
|
|
42
|
+
last = undefined;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("useKerbcastInFlight", () => {
|
|
46
|
+
it("starts undefined and reflects scene-state-changed", async () => {
|
|
47
|
+
const { client, sidecar } = await connected();
|
|
48
|
+
|
|
49
|
+
render(
|
|
50
|
+
<KerbcastProvider client={client}>
|
|
51
|
+
<Probe />
|
|
52
|
+
</KerbcastProvider>,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(last).toBeUndefined();
|
|
56
|
+
|
|
57
|
+
await act(async () => {
|
|
58
|
+
sidecar.fireSceneState(false);
|
|
59
|
+
});
|
|
60
|
+
expect(last).toBe(false);
|
|
61
|
+
|
|
62
|
+
await act(async () => {
|
|
63
|
+
sidecar.fireSceneState(true);
|
|
64
|
+
});
|
|
65
|
+
expect(last).toBe(true);
|
|
66
|
+
|
|
67
|
+
await act(async () => {
|
|
68
|
+
await client.disconnect();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useKerbcastClient } from "../context";
|
|
3
|
+
|
|
4
|
+
/** Whether KSP is in a flight scene. `undefined` until the first signal. */
|
|
5
|
+
export function useKerbcastInFlight(): boolean | undefined {
|
|
6
|
+
const client = useKerbcastClient();
|
|
7
|
+
const [inFlight, setInFlight] = useState(() => client.inFlight);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setInFlight(client.inFlight);
|
|
11
|
+
return client.on("scene-change", () => setInFlight(client.inFlight));
|
|
12
|
+
}, [client]);
|
|
13
|
+
|
|
14
|
+
return inFlight;
|
|
15
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,10 @@ export type { KerbcastProviderProps, KerbcastSubscriptions } from "./context";
|
|
|
19
19
|
export { useKerbcastCameras } from "./hooks/useKerbcastCameras";
|
|
20
20
|
export { useKerbcastStream } from "./hooks/useKerbcastStream";
|
|
21
21
|
export { useKerbcastClock } from "./hooks/useKerbcastClock";
|
|
22
|
+
export { useKerbcastInFlight } from "./hooks/useKerbcastInFlight";
|
|
23
|
+
|
|
24
|
+
// Shared standby glyph (used by CameraFeed + downstream dashboards)
|
|
25
|
+
export { StandbyIcon } from "./StandbyIcon";
|
|
22
26
|
|
|
23
27
|
// Camera label utilities
|
|
24
28
|
export { buildCameraLabeler } from "./cameraLabels";
|
package/LICENSE
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
kerbcast
|
|
2
|
-
Copyright (c) 2026 Jon Pepler
|
|
3
|
-
|
|
4
|
-
This work is licensed under the Creative Commons
|
|
5
|
-
Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
6
|
-
Full legal text follows.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
|
10
|
-
Public License
|
|
11
|
-
|
|
12
|
-
By exercising the Licensed Rights (defined below), You accept and agree
|
|
13
|
-
to be bound by the terms and conditions of this Creative Commons
|
|
14
|
-
Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
|
15
|
-
("Public License"). To the extent this Public License may be
|
|
16
|
-
interpreted as a contract, You are granted the Licensed Rights in
|
|
17
|
-
consideration of Your acceptance of these terms and conditions, and the
|
|
18
|
-
Licensor grants You such rights in consideration of benefits the
|
|
19
|
-
Licensor receives from making the Licensed Material available under
|
|
20
|
-
these terms and conditions.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Section 1 -- Definitions.
|
|
24
|
-
|
|
25
|
-
a. Adapted Material means material subject to Copyright and Similar
|
|
26
|
-
Rights that is derived from or based upon the Licensed Material
|
|
27
|
-
and in which the Licensed Material is translated, altered,
|
|
28
|
-
arranged, transformed, or otherwise modified in a manner requiring
|
|
29
|
-
permission under the Copyright and Similar Rights held by the
|
|
30
|
-
Licensor. For purposes of this Public License, where the Licensed
|
|
31
|
-
Material is a musical work, performance, or sound recording,
|
|
32
|
-
Adapted Material is always produced where the Licensed Material is
|
|
33
|
-
synched in timed relation with a moving image.
|
|
34
|
-
|
|
35
|
-
b. Adapter's License means the license You apply to Your Copyright
|
|
36
|
-
and Similar Rights in Your contributions to Adapted Material in
|
|
37
|
-
accordance with the terms and conditions of this Public License.
|
|
38
|
-
|
|
39
|
-
c. BY-NC-SA Compatible License means a license listed at
|
|
40
|
-
creativecommons.org/compatiblelicenses, approved by Creative
|
|
41
|
-
Commons as essentially the equivalent of this Public License.
|
|
42
|
-
|
|
43
|
-
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
44
|
-
closely related to copyright including, without limitation,
|
|
45
|
-
performance, broadcast, sound recording, and Sui Generis Database
|
|
46
|
-
Rights, without regard to how the rights are labeled or
|
|
47
|
-
categorized. For purposes of this Public License, the rights
|
|
48
|
-
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
49
|
-
Rights.
|
|
50
|
-
|
|
51
|
-
e. Effective Technological Measures means those measures that, in the
|
|
52
|
-
absence of proper authority, may not be circumvented under laws
|
|
53
|
-
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
54
|
-
Treaty adopted on December 20, 1996, and/or similar international
|
|
55
|
-
agreements.
|
|
56
|
-
|
|
57
|
-
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
58
|
-
any other exception or limitation to Copyright and Similar Rights
|
|
59
|
-
that applies to Your use of the Licensed Material.
|
|
60
|
-
|
|
61
|
-
g. License Elements means the license attributes listed in the name
|
|
62
|
-
of a Creative Commons Public License. The License Elements of this
|
|
63
|
-
Public License are Attribution, NonCommercial, and ShareAlike.
|
|
64
|
-
|
|
65
|
-
h. Licensed Material means the artistic or literary work, database,
|
|
66
|
-
or other material to which the Licensor applied this Public
|
|
67
|
-
License.
|
|
68
|
-
|
|
69
|
-
i. Licensed Rights means the rights granted to You subject to the
|
|
70
|
-
terms and conditions of this Public License, which are limited to
|
|
71
|
-
all Copyright and Similar Rights that apply to Your use of the
|
|
72
|
-
Licensed Material and that the Licensor has authority to license.
|
|
73
|
-
|
|
74
|
-
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
75
|
-
under this Public License.
|
|
76
|
-
|
|
77
|
-
k. NonCommercial means not primarily intended for or directed towards
|
|
78
|
-
commercial advantage or monetary compensation. For purposes of
|
|
79
|
-
this Public License, the exchange of the Licensed Material for
|
|
80
|
-
other material subject to Copyright and Similar Rights by digital
|
|
81
|
-
file-sharing or similar means is NonCommercial provided there is
|
|
82
|
-
no payment of monetary compensation in connection with the
|
|
83
|
-
exchange.
|
|
84
|
-
|
|
85
|
-
l. Share means to provide material to the public by any means or
|
|
86
|
-
process that requires permission under the Licensed Rights, such
|
|
87
|
-
as reproduction, public display, public performance, distribution,
|
|
88
|
-
dissemination, communication, or importation, and to make material
|
|
89
|
-
available to the public including in ways that members of the
|
|
90
|
-
public may access the material from a place and at a time
|
|
91
|
-
individually chosen by them.
|
|
92
|
-
|
|
93
|
-
m. Sui Generis Database Rights means rights other than copyright
|
|
94
|
-
resulting from Directive 96/9/EC of the European Parliament and of
|
|
95
|
-
the Council of 11 March 1996 on the legal protection of databases,
|
|
96
|
-
as amended and/or succeeded, as well as other essentially
|
|
97
|
-
equivalent rights anywhere in the world.
|
|
98
|
-
|
|
99
|
-
n. You means the individual or entity exercising the Licensed Rights
|
|
100
|
-
under this Public License. Your has a corresponding meaning.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Section 2 -- Scope.
|
|
104
|
-
|
|
105
|
-
a. License grant.
|
|
106
|
-
|
|
107
|
-
1. Subject to the terms and conditions of this Public License,
|
|
108
|
-
the Licensor hereby grants You a worldwide, royalty-free,
|
|
109
|
-
non-sublicensable, non-exclusive, irrevocable license to
|
|
110
|
-
exercise the Licensed Rights in the Licensed Material to:
|
|
111
|
-
|
|
112
|
-
a. reproduce and Share the Licensed Material, in whole or
|
|
113
|
-
in part, for NonCommercial purposes only; and
|
|
114
|
-
|
|
115
|
-
b. produce, reproduce, and Share Adapted Material for
|
|
116
|
-
NonCommercial purposes only.
|
|
117
|
-
|
|
118
|
-
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
119
|
-
Exceptions and Limitations apply to Your use, this Public
|
|
120
|
-
License does not apply, and You do not need to comply with
|
|
121
|
-
its terms and conditions.
|
|
122
|
-
|
|
123
|
-
3. Term. The term of this Public License is specified in Section
|
|
124
|
-
6(a).
|
|
125
|
-
|
|
126
|
-
4. Media and formats; technical modifications allowed. The
|
|
127
|
-
Licensor authorizes You to exercise the Licensed Rights in
|
|
128
|
-
all media and formats whether now known or hereafter created,
|
|
129
|
-
and to make technical modifications necessary to do so. The
|
|
130
|
-
Licensor waives and/or agrees not to assert any right or
|
|
131
|
-
authority to forbid You from making technical modifications
|
|
132
|
-
necessary to exercise the Licensed Rights, including
|
|
133
|
-
technical modifications necessary to circumvent Effective
|
|
134
|
-
Technological Measures. For purposes of this Public License,
|
|
135
|
-
simply making modifications authorized by this Section 2(a)
|
|
136
|
-
(4) never produces Adapted Material.
|
|
137
|
-
|
|
138
|
-
5. Downstream recipients.
|
|
139
|
-
|
|
140
|
-
a. Offer from the Licensor -- Licensed Material. Every
|
|
141
|
-
recipient of the Licensed Material automatically
|
|
142
|
-
receives an offer from the Licensor to exercise the
|
|
143
|
-
Licensed Rights under the terms and conditions of this
|
|
144
|
-
Public License.
|
|
145
|
-
|
|
146
|
-
b. Additional offer from the Licensor -- Adapted Material.
|
|
147
|
-
Every recipient of Adapted Material from You
|
|
148
|
-
automatically receives an offer from the Licensor to
|
|
149
|
-
exercise the Licensed Rights in the Adapted Material
|
|
150
|
-
under the conditions of the Adapter's License You apply.
|
|
151
|
-
|
|
152
|
-
c. No downstream restrictions. You may not offer or impose
|
|
153
|
-
any additional or different terms or conditions on, or
|
|
154
|
-
apply any Effective Technological Measures to, the
|
|
155
|
-
Licensed Material if doing so restricts exercise of the
|
|
156
|
-
Licensed Rights by any recipient of the Licensed
|
|
157
|
-
Material.
|
|
158
|
-
|
|
159
|
-
6. No endorsement. Nothing in this Public License constitutes or
|
|
160
|
-
may be construed as permission to assert or imply that You
|
|
161
|
-
are, or that Your use of the Licensed Material is, connected
|
|
162
|
-
with, or sponsored, endorsed, or granted official status by,
|
|
163
|
-
the Licensor or others designated to receive attribution as
|
|
164
|
-
provided in Section 3(a)(1)(A)(i).
|
|
165
|
-
|
|
166
|
-
b. Other rights.
|
|
167
|
-
|
|
168
|
-
1. Moral rights, such as the right of integrity, are not
|
|
169
|
-
licensed under this Public License, nor are publicity,
|
|
170
|
-
privacy, and/or other similar personality rights; however, to
|
|
171
|
-
the extent possible, the Licensor waives and/or agrees not to
|
|
172
|
-
assert any such rights held by the Licensor to the limited
|
|
173
|
-
extent necessary to allow You to exercise the Licensed
|
|
174
|
-
Rights, but not otherwise.
|
|
175
|
-
|
|
176
|
-
2. Patent and trademark rights are not licensed under this
|
|
177
|
-
Public License.
|
|
178
|
-
|
|
179
|
-
3. To the extent possible, the Licensor waives any right to
|
|
180
|
-
collect royalties from You for the exercise of the Licensed
|
|
181
|
-
Rights, whether directly or through a collecting society
|
|
182
|
-
under any voluntary or waivable statutory or compulsory
|
|
183
|
-
licensing scheme. In all other cases the Licensor expressly
|
|
184
|
-
reserves any right to collect such royalties, including when
|
|
185
|
-
the Licensed Material is used other than for NonCommercial
|
|
186
|
-
purposes.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
Section 3 -- License Conditions.
|
|
190
|
-
|
|
191
|
-
Your exercise of the Licensed Rights is expressly made subject to the
|
|
192
|
-
following conditions.
|
|
193
|
-
|
|
194
|
-
a. Attribution.
|
|
195
|
-
|
|
196
|
-
1. If You Share the Licensed Material (including in modified
|
|
197
|
-
form), You must:
|
|
198
|
-
|
|
199
|
-
a. retain the following if it is supplied by the Licensor
|
|
200
|
-
with the Licensed Material:
|
|
201
|
-
|
|
202
|
-
i. identification of the creator(s) of the Licensed
|
|
203
|
-
Material and any others designated to receive
|
|
204
|
-
attribution, in any reasonable manner requested by
|
|
205
|
-
the Licensor (including by pseudonym if
|
|
206
|
-
designated);
|
|
207
|
-
|
|
208
|
-
ii. a copyright notice;
|
|
209
|
-
|
|
210
|
-
iii. a notice that refers to this Public License;
|
|
211
|
-
|
|
212
|
-
iv. a notice that refers to the disclaimer of
|
|
213
|
-
warranties;
|
|
214
|
-
|
|
215
|
-
v. a URI or hyperlink to the Licensed Material to the
|
|
216
|
-
extent reasonably practicable;
|
|
217
|
-
|
|
218
|
-
b. indicate if You modified the Licensed Material and
|
|
219
|
-
retain an indication of any previous modifications; and
|
|
220
|
-
|
|
221
|
-
c. indicate the Licensed Material is licensed under this
|
|
222
|
-
Public License, and include the text of, or the URI or
|
|
223
|
-
hyperlink to, this Public License.
|
|
224
|
-
|
|
225
|
-
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
226
|
-
reasonable manner based on the medium, means, and context in
|
|
227
|
-
which You Share the Licensed Material. For example, it may be
|
|
228
|
-
reasonable to satisfy the conditions by providing a URI or
|
|
229
|
-
hyperlink to a resource that includes the required
|
|
230
|
-
information.
|
|
231
|
-
3. If requested by the Licensor, You must remove any of the
|
|
232
|
-
information required by Section 3(a)(1)(A) to the extent
|
|
233
|
-
reasonably practicable.
|
|
234
|
-
|
|
235
|
-
b. ShareAlike.
|
|
236
|
-
|
|
237
|
-
In addition to the conditions in Section 3(a), if You Share
|
|
238
|
-
Adapted Material You produce, the following conditions also apply.
|
|
239
|
-
|
|
240
|
-
1. The Adapter's License You apply must be a Creative Commons
|
|
241
|
-
license with the same License Elements, this version or
|
|
242
|
-
later, or a BY-NC-SA Compatible License.
|
|
243
|
-
|
|
244
|
-
2. You must include the text of, or the URI or hyperlink to, the
|
|
245
|
-
Adapter's License You apply. You may satisfy this condition
|
|
246
|
-
in any reasonable manner based on the medium, means, and
|
|
247
|
-
context in which You Share Adapted Material.
|
|
248
|
-
|
|
249
|
-
3. You may not offer or impose any additional or different terms
|
|
250
|
-
or conditions on, or apply any Effective Technological
|
|
251
|
-
Measures to, Adapted Material that restrict exercise of the
|
|
252
|
-
rights granted under the Adapter's License You apply.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
Section 4 -- Sui Generis Database Rights.
|
|
256
|
-
|
|
257
|
-
Where the Licensed Rights include Sui Generis Database Rights that
|
|
258
|
-
apply to Your use of the Licensed Material:
|
|
259
|
-
|
|
260
|
-
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
261
|
-
to extract, reuse, reproduce, and Share all or a substantial
|
|
262
|
-
portion of the contents of the database for NonCommercial purposes
|
|
263
|
-
only;
|
|
264
|
-
|
|
265
|
-
b. if You include all or a substantial portion of the database
|
|
266
|
-
contents in a database in which You have Sui Generis Database
|
|
267
|
-
Rights, then the database in which You have Sui Generis Database
|
|
268
|
-
Rights (but not its individual contents) is Adapted Material,
|
|
269
|
-
including for purposes of Section 3(b); and
|
|
270
|
-
|
|
271
|
-
c. You must comply with the conditions in Section 3(a) if You Share
|
|
272
|
-
all or a substantial portion of the contents of the database.
|
|
273
|
-
|
|
274
|
-
For the avoidance of doubt, this Section 4 supplements and does not
|
|
275
|
-
replace Your obligations under this Public License where the Licensed
|
|
276
|
-
Rights include other Copyright and Similar Rights.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
280
|
-
|
|
281
|
-
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
282
|
-
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
283
|
-
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
284
|
-
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
285
|
-
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
286
|
-
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
287
|
-
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
288
|
-
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
289
|
-
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
290
|
-
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
291
|
-
|
|
292
|
-
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
293
|
-
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
294
|
-
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
295
|
-
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
296
|
-
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
297
|
-
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
298
|
-
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
299
|
-
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
300
|
-
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
301
|
-
|
|
302
|
-
c. The disclaimer of warranties and limitation of liability provided
|
|
303
|
-
above shall be interpreted in a manner that, to the extent
|
|
304
|
-
possible, most closely approximates an absolute disclaimer and
|
|
305
|
-
waiver of all liability.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
Section 6 -- Term and Termination.
|
|
309
|
-
|
|
310
|
-
a. This Public License applies for the term of the Copyright and
|
|
311
|
-
Similar Rights licensed here. However, if You fail to comply with
|
|
312
|
-
this Public License, then Your rights under this Public License
|
|
313
|
-
terminate automatically.
|
|
314
|
-
|
|
315
|
-
b. Where Your right to use the Licensed Material has terminated under
|
|
316
|
-
Section 6(a), it reinstates:
|
|
317
|
-
|
|
318
|
-
1. automatically as of the date the violation is cured, provided
|
|
319
|
-
it is cured within 30 days of Your discovery of the
|
|
320
|
-
violation; or
|
|
321
|
-
|
|
322
|
-
2. upon express reinstatement by the Licensor.
|
|
323
|
-
|
|
324
|
-
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
325
|
-
right the Licensor may have to seek remedies for Your violations
|
|
326
|
-
of this Public License.
|
|
327
|
-
|
|
328
|
-
c. For the avoidance of doubt, the Licensor may also offer the
|
|
329
|
-
Licensed Material under separate terms or conditions or stop
|
|
330
|
-
distributing the Licensed Material at any time; however, doing so
|
|
331
|
-
will not terminate this Public License.
|
|
332
|
-
|
|
333
|
-
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
334
|
-
License.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
Section 7 -- Other Terms and Conditions.
|
|
338
|
-
|
|
339
|
-
a. The Licensor shall not be bound by any additional or different
|
|
340
|
-
terms or conditions communicated by You unless expressly agreed.
|
|
341
|
-
|
|
342
|
-
b. Any arrangements, understandings, or agreements regarding the
|
|
343
|
-
Licensed Material not stated herein are separate from and
|
|
344
|
-
independent of the terms and conditions of this Public License.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
Section 8 -- Interpretation.
|
|
348
|
-
|
|
349
|
-
a. For the avoidance of doubt, this Public License does not, and
|
|
350
|
-
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
351
|
-
conditions on any use of the Licensed Material that could lawfully
|
|
352
|
-
be made without permission under this Public License.
|
|
353
|
-
|
|
354
|
-
b. To the extent possible, if any provision of this Public License is
|
|
355
|
-
deemed unenforceable, it shall be automatically reformed to the
|
|
356
|
-
minimum extent necessary to make it enforceable. If the provision
|
|
357
|
-
cannot be reformed, it shall be severed from this Public License
|
|
358
|
-
without affecting the enforceability of the remaining terms and
|
|
359
|
-
conditions.
|
|
360
|
-
|
|
361
|
-
c. No term or condition of this Public License will be waived and no
|
|
362
|
-
failure to comply consented to unless expressly agreed to by the
|
|
363
|
-
Licensor.
|
|
364
|
-
|
|
365
|
-
d. Nothing in this Public License constitutes or may be interpreted
|
|
366
|
-
as a limitation upon, or waiver of, any privileges and immunities
|
|
367
|
-
that apply to the Licensor or You, including from the legal
|
|
368
|
-
processes of any jurisdiction or authority.
|
|
369
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CameraState } from "@jonpepler/kerbcam";
|
|
2
|
-
/**
|
|
3
|
-
* Live snapshot of the kerbcam camera registry. Returns the empty list
|
|
4
|
-
* before the data channel handshake completes (and after a disconnect).
|
|
5
|
-
* Subscribes via the underlying `KerbcamClient`'s `cameras-change` event for
|
|
6
|
-
* one synchronous push per server-side snapshot or state-changed message.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useKerbcamCameras(): CameraState[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useKerbcamClient } from "../context";
|
|
3
|
-
/**
|
|
4
|
-
* Live snapshot of the kerbcam camera registry. Returns the empty list
|
|
5
|
-
* before the data channel handshake completes (and after a disconnect).
|
|
6
|
-
* Subscribes via the underlying `KerbcamClient`'s `cameras-change` event for
|
|
7
|
-
* one synchronous push per server-side snapshot or state-changed message.
|
|
8
|
-
*/
|
|
9
|
-
export function useKerbcamCameras() {
|
|
10
|
-
const client = useKerbcamClient();
|
|
11
|
-
const [cameras, setCameras] = useState(() => [
|
|
12
|
-
...client.cameras,
|
|
13
|
-
]);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
setCameras([...client.cameras]);
|
|
16
|
-
return client.on("cameras-change", (next) => setCameras([...next]));
|
|
17
|
-
}, [client]);
|
|
18
|
-
return cameras;
|
|
19
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Live `MediaStream` for one kerbcam camera. Returns `null` while the WebRTC
|
|
3
|
-
* track hasn't arrived yet (during connection setup, or after a disconnect).
|
|
4
|
-
* Components bind the stream to a `<video>`'s `srcObject` directly.
|
|
5
|
-
*
|
|
6
|
-
* While mounted with a non-null `flightId`, acquires a subscription slot via
|
|
7
|
-
* the context `KerbcamSubscriptions`. Releases the slot when the component
|
|
8
|
-
* unmounts or the `flightId` changes.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useKerbcamStream(flightId: number | null): MediaStream | null;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { useKerbcamClient, useKerbcamSubscriptions } from "../context";
|
|
3
|
-
/**
|
|
4
|
-
* Live `MediaStream` for one kerbcam camera. Returns `null` while the WebRTC
|
|
5
|
-
* track hasn't arrived yet (during connection setup, or after a disconnect).
|
|
6
|
-
* Components bind the stream to a `<video>`'s `srcObject` directly.
|
|
7
|
-
*
|
|
8
|
-
* While mounted with a non-null `flightId`, acquires a subscription slot via
|
|
9
|
-
* the context `KerbcamSubscriptions`. Releases the slot when the component
|
|
10
|
-
* unmounts or the `flightId` changes.
|
|
11
|
-
*/
|
|
12
|
-
export function useKerbcamStream(flightId) {
|
|
13
|
-
const client = useKerbcamClient();
|
|
14
|
-
const subscriptions = useKerbcamSubscriptions();
|
|
15
|
-
const [stream, setStream] = useState(() => {
|
|
16
|
-
if (flightId === null)
|
|
17
|
-
return null;
|
|
18
|
-
return client.camera(flightId).mediaStream;
|
|
19
|
-
});
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (flightId === null) {
|
|
22
|
-
setStream(null);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const cam = client.camera(flightId);
|
|
26
|
-
setStream(cam.mediaStream);
|
|
27
|
-
const off = cam.on("stream", setStream);
|
|
28
|
-
subscriptions.acquire(flightId);
|
|
29
|
-
return () => {
|
|
30
|
-
off();
|
|
31
|
-
subscriptions.release(flightId);
|
|
32
|
-
};
|
|
33
|
-
}, [client, subscriptions, flightId]);
|
|
34
|
-
return stream;
|
|
35
|
-
}
|