@skyvexsoftware/stratos-sdk 0.1.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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/helpers/createPlugin.d.ts +22 -0
- package/dist/helpers/createPlugin.js +32 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/units.d.ts +36 -0
- package/dist/helpers/units.js +101 -0
- package/dist/hooks/context.d.ts +12 -0
- package/dist/hooks/context.js +18 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/useFlightEvents.d.ts +37 -0
- package/dist/hooks/useFlightEvents.js +152 -0
- package/dist/hooks/useFlightManager.d.ts +20 -0
- package/dist/hooks/useFlightManager.js +90 -0
- package/dist/hooks/useFlightPhase.d.ts +31 -0
- package/dist/hooks/useFlightPhase.js +67 -0
- package/dist/hooks/useLandingAnalysis.d.ts +37 -0
- package/dist/hooks/useLandingAnalysis.js +87 -0
- package/dist/hooks/usePluginLogger.d.ts +13 -0
- package/dist/hooks/usePluginLogger.js +16 -0
- package/dist/hooks/useShellAuth.d.ts +14 -0
- package/dist/hooks/useShellAuth.js +13 -0
- package/dist/hooks/useShellConfig.d.ts +14 -0
- package/dist/hooks/useShellConfig.js +14 -0
- package/dist/hooks/useShellNavigation.d.ts +12 -0
- package/dist/hooks/useShellNavigation.js +15 -0
- package/dist/hooks/useShellToast.d.ts +12 -0
- package/dist/hooks/useShellToast.js +15 -0
- package/dist/hooks/useSimData.d.ts +70 -0
- package/dist/hooks/useSimData.js +135 -0
- package/dist/hooks/useSimulatorData.d.ts +57 -0
- package/dist/hooks/useSimulatorData.js +258 -0
- package/dist/hooks/useTrackingSession.d.ts +40 -0
- package/dist/hooks/useTrackingSession.js +152 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +13 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +28 -0
- package/dist/shared-types/flight-manager.d.ts +112 -0
- package/dist/shared-types/flight-manager.js +2 -0
- package/dist/shared-types/index.d.ts +7 -0
- package/dist/shared-types/index.js +4 -0
- package/dist/shared-types/simulator.d.ts +386 -0
- package/dist/shared-types/simulator.js +48 -0
- package/dist/shared-types/socket-events.d.ts +171 -0
- package/dist/shared-types/socket-events.js +79 -0
- package/dist/shared-types/theme.d.ts +3 -0
- package/dist/shared-types/theme.js +2 -0
- package/dist/types/context.d.ts +206 -0
- package/dist/types/context.js +8 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/dist/types/manifest.d.ts +42 -0
- package/dist/types/manifest.js +12 -0
- package/dist/types/module.d.ts +31 -0
- package/dist/types/module.js +7 -0
- package/dist/ui/alert-dialog.d.ts +21 -0
- package/dist/ui/alert-dialog.js +27 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +21 -0
- package/dist/ui/button.d.ts +17 -0
- package/dist/ui/button.js +39 -0
- package/dist/ui/card.d.ts +10 -0
- package/dist/ui/card.js +25 -0
- package/dist/ui/dialog.d.ts +14 -0
- package/dist/ui/dialog.js +25 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.js +16 -0
- package/dist/ui/input.d.ts +4 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/label.d.ts +5 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/radio-group.d.ts +6 -0
- package/dist/ui/radio-group.js +11 -0
- package/dist/ui/select.d.ts +14 -0
- package/dist/ui/select.js +27 -0
- package/dist/ui/separator.d.ts +5 -0
- package/dist/ui/separator.js +8 -0
- package/dist/ui/slider.d.ts +5 -0
- package/dist/ui/slider.js +8 -0
- package/dist/ui/switch.d.ts +13 -0
- package/dist/ui/switch.js +9 -0
- package/dist/ui/tabs.d.ts +8 -0
- package/dist/ui/tabs.js +13 -0
- package/dist/ui/textarea.d.ts +4 -0
- package/dist/ui/textarea.js +7 -0
- package/dist/ui/tooltip.d.ts +8 -0
- package/dist/ui/tooltip.js +11 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +6 -0
- package/dist/vite/externals.d.ts +9 -0
- package/dist/vite/externals.js +19 -0
- package/dist/vite/plugin-config.d.ts +49 -0
- package/dist/vite/plugin-config.js +236 -0
- package/dist/vite/serve-externals.d.ts +9 -0
- package/dist/vite/serve-externals.js +78 -0
- package/dist/vite/stratos-dev-server.d.ts +21 -0
- package/dist/vite/stratos-dev-server.js +188 -0
- package/package.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Skyvex Software
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# @skyvexsoftware/stratos-sdk
|
|
2
|
+
|
|
3
|
+
The Stratos Plugin SDK provides typed access to shell APIs, shared UI components, and utility functions for building Stratos plugins.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
**External plugin developers (npm):**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @skyvexsoftware/stratos-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Within the Stratos monorepo (workspace):**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @skyvexsoftware/stratos-sdk --workspace
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Available APIs
|
|
20
|
+
|
|
21
|
+
### Plugin Contract Types
|
|
22
|
+
|
|
23
|
+
Type definitions for the plugin system:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import type {
|
|
27
|
+
PluginManifest,
|
|
28
|
+
PluginContext,
|
|
29
|
+
PluginUIContext,
|
|
30
|
+
PluginBackgroundModule,
|
|
31
|
+
PluginUIModule,
|
|
32
|
+
} from "@skyvexsoftware/stratos-sdk";
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Helper Functions
|
|
36
|
+
|
|
37
|
+
#### `createPlugin(module)`
|
|
38
|
+
|
|
39
|
+
Validates and returns a typed plugin background module:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createPlugin } from "@skyvexsoftware/stratos-sdk";
|
|
43
|
+
|
|
44
|
+
export default createPlugin({
|
|
45
|
+
async onStart(ctx) {
|
|
46
|
+
ctx.logger.info("MyPlugin", "Starting...");
|
|
47
|
+
},
|
|
48
|
+
async onStop() {
|
|
49
|
+
// cleanup
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### `PluginRouter` component
|
|
55
|
+
|
|
56
|
+
Optional lightweight router for plugins that need internal multi-page navigation:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { PluginRouter } from "@skyvexsoftware/stratos-sdk";
|
|
60
|
+
import TrackingPage from "./pages/TrackingPage";
|
|
61
|
+
import HistoryPage from "./pages/HistoryPage";
|
|
62
|
+
import HistoryDetailPage from "./pages/HistoryDetailPage";
|
|
63
|
+
|
|
64
|
+
const routes = [
|
|
65
|
+
{ path: "tracking", component: TrackingPage },
|
|
66
|
+
{ path: "history", component: HistoryPage },
|
|
67
|
+
{ path: "history/:id", component: HistoryDetailPage },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
export default function MyPluginRoot() {
|
|
71
|
+
return <PluginRouter routes={routes} defaultPath="tracking" />;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For single-page plugins, just export the component directly:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import HomePage from "./HomePage";
|
|
79
|
+
export default HomePage;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `usePluginRoute()`
|
|
83
|
+
|
|
84
|
+
Returns the current sub-path within the plugin (the URL portion after `/plugins/{pluginId}/`):
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { usePluginRoute } from "@skyvexsoftware/stratos-sdk";
|
|
88
|
+
|
|
89
|
+
function MyComponent() {
|
|
90
|
+
const { subPath } = usePluginRoute();
|
|
91
|
+
// e.g. "history/abc123"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### `usePluginParams()`
|
|
96
|
+
|
|
97
|
+
Access route params matched by `PluginRouter` (e.g. `history/:id`):
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { usePluginParams } from "@skyvexsoftware/stratos-sdk";
|
|
101
|
+
|
|
102
|
+
function DetailPage() {
|
|
103
|
+
const { id } = usePluginParams<{ id: string }>();
|
|
104
|
+
// id === "abc123" when URL is /plugins/my-plugin/history/abc123
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### React Hooks
|
|
109
|
+
|
|
110
|
+
Access shell services from plugin components. All hooks must be used within a `PluginShellProvider` (provided by the shell at runtime).
|
|
111
|
+
|
|
112
|
+
| Hook | Returns | Description |
|
|
113
|
+
| -------------------- | -------------------- | ------------------------------ |
|
|
114
|
+
| `useShellAuth()` | Auth state | Authentication state and token |
|
|
115
|
+
| `useShellConfig()` | Config store | Scoped configuration access |
|
|
116
|
+
| `useShellNavigation()` | Navigation helpers | Route navigation utilities |
|
|
117
|
+
| `useShellToast()` | Toast API | Toast/notification functions |
|
|
118
|
+
| `usePluginLogger()` | Logger | Scoped renderer-side logger |
|
|
119
|
+
| `usePluginContext()` | Full PluginUIContext | All of the above combined |
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import { useShellAuth, useShellToast } from "@skyvexsoftware/stratos-sdk";
|
|
123
|
+
|
|
124
|
+
function MyComponent() {
|
|
125
|
+
const { isAuthenticated } = useShellAuth();
|
|
126
|
+
const toast = useShellToast();
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<button onClick={() => toast.success("Hello!")}>
|
|
130
|
+
{isAuthenticated ? "Logged in" : "Not authenticated"}
|
|
131
|
+
</button>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### UI Primitives
|
|
137
|
+
|
|
138
|
+
Pre-styled shadcn/ui components using Tailwind CSS and Radix UI:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { Button, Card, CardContent, Input, Label } from "@skyvexsoftware/stratos-sdk";
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Available components:
|
|
145
|
+
|
|
146
|
+
- **Button** — with variants: default, destructive, outline, secondary, ghost, link
|
|
147
|
+
- **Card** — CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter
|
|
148
|
+
- **Dialog** — DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription
|
|
149
|
+
- **Input** — text input with validation states
|
|
150
|
+
- **Label** — form label
|
|
151
|
+
- **Select** — SelectTrigger, SelectContent, SelectItem, SelectGroup, SelectValue
|
|
152
|
+
- **Badge** — with variants: default, secondary, destructive, outline
|
|
153
|
+
- **Separator** — horizontal or vertical divider
|
|
154
|
+
- **Tabs** — TabsList, TabsTrigger, TabsContent
|
|
155
|
+
- **Tooltip** — TooltipProvider, TooltipTrigger, TooltipContent
|
|
156
|
+
|
|
157
|
+
### Shared Types
|
|
158
|
+
|
|
159
|
+
Common types used across plugins:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { FlightPhase, SimulatorType } from "@skyvexsoftware/stratos-sdk";
|
|
163
|
+
import type { FlightData, ThemeMode } from "@skyvexsoftware/stratos-sdk";
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Utilities
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { cn } from "@skyvexsoftware/stratos-sdk";
|
|
170
|
+
|
|
171
|
+
// Tailwind class merging utility
|
|
172
|
+
cn("bg-red-500", conditional && "text-white", className);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Peer Dependencies
|
|
176
|
+
|
|
177
|
+
The SDK expects these to be provided by the shell at runtime:
|
|
178
|
+
|
|
179
|
+
- `react` ^19.0.0
|
|
180
|
+
- `@radix-ui/react-*` (dialog, label, select, separator, slot, tabs, tooltip)
|
|
181
|
+
- `@tanstack/react-query` ^5.0.0
|
|
182
|
+
- `class-variance-authority` ^0.7.0
|
|
183
|
+
- `lucide-react` >=0.300.0
|
|
184
|
+
- `socket.io-client` ^4.0.0
|
|
185
|
+
|
|
186
|
+
## Publishing
|
|
187
|
+
|
|
188
|
+
The SDK is published to npm as `@skyvexsoftware/stratos-sdk` directly from the monorepo.
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
pnpm build:sdk # compile TypeScript to dist/
|
|
192
|
+
pnpm --filter @skyvexsoftware/stratos-sdk publish # publish to npm
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The published package contains only the `dist/` folder (compiled JS + declaration files). Locally in the monorepo, pnpm's `workspace:*` protocol resolves to the source files via TypeScript project references.
|
|
196
|
+
|
|
197
|
+
To inspect what would be published without actually publishing:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pnpm --filter @skyvexsoftware/stratos-sdk pack
|
|
201
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PluginBackgroundModule } from "../types/module";
|
|
2
|
+
/**
|
|
3
|
+
* Validates and returns a typed plugin background module.
|
|
4
|
+
*
|
|
5
|
+
* Ensures the module exports the required onStart and onStop functions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createPlugin } from "@skyvexsoftware/stratos-sdk";
|
|
10
|
+
*
|
|
11
|
+
* export default createPlugin({
|
|
12
|
+
* async onStart(ctx) {
|
|
13
|
+
* ctx.logger.info("MyPlugin", "Starting up...");
|
|
14
|
+
* },
|
|
15
|
+
* async onStop() {
|
|
16
|
+
* // cleanup
|
|
17
|
+
* },
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function createPlugin(module: PluginBackgroundModule): PluginBackgroundModule;
|
|
22
|
+
//# sourceMappingURL=createPlugin.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and returns a typed plugin background module.
|
|
3
|
+
*
|
|
4
|
+
* Ensures the module exports the required onStart and onStop functions.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createPlugin } from "@skyvexsoftware/stratos-sdk";
|
|
9
|
+
*
|
|
10
|
+
* export default createPlugin({
|
|
11
|
+
* async onStart(ctx) {
|
|
12
|
+
* ctx.logger.info("MyPlugin", "Starting up...");
|
|
13
|
+
* },
|
|
14
|
+
* async onStop() {
|
|
15
|
+
* // cleanup
|
|
16
|
+
* },
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function createPlugin(module) {
|
|
21
|
+
if (typeof module.onStart !== "function") {
|
|
22
|
+
throw new Error("Plugin module must export an onStart function");
|
|
23
|
+
}
|
|
24
|
+
if (typeof module.onStop !== "function") {
|
|
25
|
+
throw new Error("Plugin module must export an onStop function");
|
|
26
|
+
}
|
|
27
|
+
if (module.onResume !== undefined && typeof module.onResume !== "function") {
|
|
28
|
+
throw new Error("Plugin module onResume must be a function if provided");
|
|
29
|
+
}
|
|
30
|
+
return module;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=createPlugin.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createPlugin } from "./createPlugin";
|
|
2
|
+
export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./units";
|
|
3
|
+
export type { WeightUnit, AltitudeUnit, DistanceUnit, UnitPreferences, } from "./units";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createPlugin } from "./createPlugin";
|
|
2
|
+
export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./units";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type WeightUnit = "lbs" | "kg";
|
|
2
|
+
export type AltitudeUnit = "ft" | "m";
|
|
3
|
+
export type DistanceUnit = "nm" | "km" | "mi";
|
|
4
|
+
export type UnitPreferences = {
|
|
5
|
+
weight: WeightUnit;
|
|
6
|
+
altitude: AltitudeUnit;
|
|
7
|
+
distance: DistanceUnit;
|
|
8
|
+
};
|
|
9
|
+
/** Convert a weight value FROM the given unit TO lbs (canonical). */
|
|
10
|
+
export declare function weightToLbs(value: number, from: WeightUnit): number;
|
|
11
|
+
/** Convert a weight value FROM lbs (canonical) TO the given unit. */
|
|
12
|
+
export declare function weightFromLbs(lbs: number, to: WeightUnit): number;
|
|
13
|
+
/** Convert an altitude value FROM the given unit TO ft (canonical). */
|
|
14
|
+
export declare function altitudeToFt(value: number, from: AltitudeUnit): number;
|
|
15
|
+
/** Convert an altitude value FROM ft (canonical) TO the given unit. */
|
|
16
|
+
export declare function altitudeFromFt(ft: number, to: AltitudeUnit): number;
|
|
17
|
+
/** Convert a vertical speed FROM fpm (canonical) TO the user's altitude unit per minute. */
|
|
18
|
+
export declare function verticalSpeedFromFpm(fpm: number, to: AltitudeUnit): number;
|
|
19
|
+
/** Convert a vertical speed FROM the user's altitude unit per minute TO fpm (canonical). */
|
|
20
|
+
export declare function verticalSpeedToFpm(value: number, from: AltitudeUnit): number;
|
|
21
|
+
/** Convert a distance value FROM the given unit TO nm (canonical). */
|
|
22
|
+
export declare function distanceToNm(value: number, from: DistanceUnit): number;
|
|
23
|
+
/** Convert a distance value FROM nm (canonical) TO the given unit. */
|
|
24
|
+
export declare function distanceFromNm(nm: number, to: DistanceUnit): number;
|
|
25
|
+
/** Format a weight (in lbs) for display in the user's preferred unit. */
|
|
26
|
+
export declare function formatWeight(lbs: number, unit: WeightUnit): string;
|
|
27
|
+
/** Format an altitude (in ft) for display in the user's preferred unit. */
|
|
28
|
+
export declare function formatAltitude(ft: number, unit: AltitudeUnit): string;
|
|
29
|
+
/** Format a distance (in nm) for display in the user's preferred unit. */
|
|
30
|
+
export declare function formatDistance(nm: number, unit: DistanceUnit): string;
|
|
31
|
+
/**
|
|
32
|
+
* Format a vertical speed / landing rate (in fpm) for display in the
|
|
33
|
+
* user's preferred altitude unit per minute.
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatVerticalSpeed(fpm: number, unit: AltitudeUnit): string;
|
|
36
|
+
//# sourceMappingURL=units.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// ── Conversion constants ───────────────────────────────────────────────
|
|
2
|
+
const LBS_TO_KG = 0.45359237;
|
|
3
|
+
const KG_TO_LBS = 1 / LBS_TO_KG;
|
|
4
|
+
const FT_TO_M = 0.3048;
|
|
5
|
+
const M_TO_FT = 1 / FT_TO_M;
|
|
6
|
+
const NM_TO_KM = 1.852;
|
|
7
|
+
const NM_TO_MI = 1.15078;
|
|
8
|
+
const KM_TO_NM = 1 / NM_TO_KM;
|
|
9
|
+
const MI_TO_NM = 1 / NM_TO_MI;
|
|
10
|
+
// FPM ↔ m/min for vertical speed (landing rate)
|
|
11
|
+
const FPM_TO_MPM = FT_TO_M;
|
|
12
|
+
const MPM_TO_FPM = M_TO_FT;
|
|
13
|
+
// ── Weight (canonical: lbs) ────────────────────────────────────────────
|
|
14
|
+
/** Convert a weight value FROM the given unit TO lbs (canonical). */
|
|
15
|
+
export function weightToLbs(value, from) {
|
|
16
|
+
if (from === "lbs")
|
|
17
|
+
return value;
|
|
18
|
+
return value * KG_TO_LBS;
|
|
19
|
+
}
|
|
20
|
+
/** Convert a weight value FROM lbs (canonical) TO the given unit. */
|
|
21
|
+
export function weightFromLbs(lbs, to) {
|
|
22
|
+
if (to === "lbs")
|
|
23
|
+
return lbs;
|
|
24
|
+
return lbs * LBS_TO_KG;
|
|
25
|
+
}
|
|
26
|
+
// ── Altitude (canonical: ft) ───────────────────────────────────────────
|
|
27
|
+
/** Convert an altitude value FROM the given unit TO ft (canonical). */
|
|
28
|
+
export function altitudeToFt(value, from) {
|
|
29
|
+
if (from === "ft")
|
|
30
|
+
return value;
|
|
31
|
+
return value * M_TO_FT;
|
|
32
|
+
}
|
|
33
|
+
/** Convert an altitude value FROM ft (canonical) TO the given unit. */
|
|
34
|
+
export function altitudeFromFt(ft, to) {
|
|
35
|
+
if (to === "ft")
|
|
36
|
+
return ft;
|
|
37
|
+
return ft * FT_TO_M;
|
|
38
|
+
}
|
|
39
|
+
// ── Vertical speed / landing rate (canonical: fpm) ─────────────────────
|
|
40
|
+
/** Convert a vertical speed FROM fpm (canonical) TO the user's altitude unit per minute. */
|
|
41
|
+
export function verticalSpeedFromFpm(fpm, to) {
|
|
42
|
+
if (to === "ft")
|
|
43
|
+
return fpm;
|
|
44
|
+
return fpm * FPM_TO_MPM;
|
|
45
|
+
}
|
|
46
|
+
/** Convert a vertical speed FROM the user's altitude unit per minute TO fpm (canonical). */
|
|
47
|
+
export function verticalSpeedToFpm(value, from) {
|
|
48
|
+
if (from === "ft")
|
|
49
|
+
return value;
|
|
50
|
+
return value * MPM_TO_FPM;
|
|
51
|
+
}
|
|
52
|
+
// ── Distance (canonical: nm) ───────────────────────────────────────────
|
|
53
|
+
/** Convert a distance value FROM the given unit TO nm (canonical). */
|
|
54
|
+
export function distanceToNm(value, from) {
|
|
55
|
+
if (from === "nm")
|
|
56
|
+
return value;
|
|
57
|
+
if (from === "km")
|
|
58
|
+
return value * KM_TO_NM;
|
|
59
|
+
return value * MI_TO_NM;
|
|
60
|
+
}
|
|
61
|
+
/** Convert a distance value FROM nm (canonical) TO the given unit. */
|
|
62
|
+
export function distanceFromNm(nm, to) {
|
|
63
|
+
if (to === "nm")
|
|
64
|
+
return nm;
|
|
65
|
+
if (to === "km")
|
|
66
|
+
return nm * NM_TO_KM;
|
|
67
|
+
return nm * NM_TO_MI;
|
|
68
|
+
}
|
|
69
|
+
// ── Display formatters ─────────────────────────────────────────────────
|
|
70
|
+
/** Format a weight (in lbs) for display in the user's preferred unit. */
|
|
71
|
+
export function formatWeight(lbs, unit) {
|
|
72
|
+
const value = weightFromLbs(lbs, unit);
|
|
73
|
+
return `${Math.round(value).toLocaleString()} ${unit}`;
|
|
74
|
+
}
|
|
75
|
+
/** Format an altitude (in ft) for display in the user's preferred unit. */
|
|
76
|
+
export function formatAltitude(ft, unit) {
|
|
77
|
+
if (unit === "ft") {
|
|
78
|
+
const rounded = Math.round(ft);
|
|
79
|
+
if (rounded >= 18000)
|
|
80
|
+
return `FL${Math.round(rounded / 100)}`;
|
|
81
|
+
return `${rounded.toLocaleString()} ft`;
|
|
82
|
+
}
|
|
83
|
+
const meters = Math.round(altitudeFromFt(ft, "m"));
|
|
84
|
+
return `${meters.toLocaleString()} m`;
|
|
85
|
+
}
|
|
86
|
+
/** Format a distance (in nm) for display in the user's preferred unit. */
|
|
87
|
+
export function formatDistance(nm, unit) {
|
|
88
|
+
const value = distanceFromNm(nm, unit);
|
|
89
|
+
return `${Math.round(value).toLocaleString()} ${unit}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Format a vertical speed / landing rate (in fpm) for display in the
|
|
93
|
+
* user's preferred altitude unit per minute.
|
|
94
|
+
*/
|
|
95
|
+
export function formatVerticalSpeed(fpm, unit) {
|
|
96
|
+
if (unit === "ft")
|
|
97
|
+
return `${Math.round(fpm).toLocaleString()} fpm`;
|
|
98
|
+
const mpm = verticalSpeedFromFpm(fpm, "m");
|
|
99
|
+
return `${Math.round(mpm).toLocaleString()} m/min`;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=units.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PluginUIContext } from "../types/context";
|
|
2
|
+
/**
|
|
3
|
+
* React context for plugin UI components.
|
|
4
|
+
* The shell provides this context via PluginShellProvider.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PluginUICtx: import("react").Context<PluginUIContext | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Access the full plugin UI context.
|
|
9
|
+
* Must be used within a PluginShellProvider (provided by the shell).
|
|
10
|
+
*/
|
|
11
|
+
export declare function usePluginContext(): PluginUIContext;
|
|
12
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* React context for plugin UI components.
|
|
4
|
+
* The shell provides this context via PluginShellProvider.
|
|
5
|
+
*/
|
|
6
|
+
export const PluginUICtx = createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Access the full plugin UI context.
|
|
9
|
+
* Must be used within a PluginShellProvider (provided by the shell).
|
|
10
|
+
*/
|
|
11
|
+
export function usePluginContext() {
|
|
12
|
+
const ctx = useContext(PluginUICtx);
|
|
13
|
+
if (!ctx) {
|
|
14
|
+
throw new Error("usePluginContext must be used within a PluginShellProvider");
|
|
15
|
+
}
|
|
16
|
+
return ctx;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { PluginUICtx, usePluginContext } from "./context";
|
|
2
|
+
export { useFlightEvents, flightEventsKeys } from "./useFlightEvents";
|
|
3
|
+
export { useFlightManager } from "./useFlightManager";
|
|
4
|
+
export { useFlightPhase, flightPhaseKeys } from "./useFlightPhase";
|
|
5
|
+
export { useLandingAnalysis, landingAnalysisKeys } from "./useLandingAnalysis";
|
|
6
|
+
export { useSimData, simDataKeys } from "./useSimData";
|
|
7
|
+
export { useTrackingSession, trackingSessionKeys } from "./useTrackingSession";
|
|
8
|
+
export { usePluginLogger } from "./usePluginLogger";
|
|
9
|
+
export { useShellAuth } from "./useShellAuth";
|
|
10
|
+
export { useShellConfig } from "./useShellConfig";
|
|
11
|
+
export { useShellNavigation } from "./useShellNavigation";
|
|
12
|
+
export { useShellToast } from "./useShellToast";
|
|
13
|
+
export { useSocket, useSimulatorData, useProtocolUrl, useNotifications, useSystemMetrics, } from "./useSimulatorData";
|
|
14
|
+
export { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
15
|
+
export type { ConnectionState, NotificationPayload, ProtocolUrlPayload, SimulatorDataPayload, SimulatorStatusPayload, SocketEventName, SystemMetricsPayload, } from "../shared-types/socket-events";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { PluginUICtx, usePluginContext } from "./context";
|
|
2
|
+
export { useFlightEvents, flightEventsKeys } from "./useFlightEvents";
|
|
3
|
+
export { useFlightManager } from "./useFlightManager";
|
|
4
|
+
export { useFlightPhase, flightPhaseKeys } from "./useFlightPhase";
|
|
5
|
+
export { useLandingAnalysis, landingAnalysisKeys } from "./useLandingAnalysis";
|
|
6
|
+
export { useSimData, simDataKeys } from "./useSimData";
|
|
7
|
+
export { useTrackingSession, trackingSessionKeys } from "./useTrackingSession";
|
|
8
|
+
export { usePluginLogger } from "./usePluginLogger";
|
|
9
|
+
export { useShellAuth } from "./useShellAuth";
|
|
10
|
+
export { useShellConfig } from "./useShellConfig";
|
|
11
|
+
export { useShellNavigation } from "./useShellNavigation";
|
|
12
|
+
export { useShellToast } from "./useShellToast";
|
|
13
|
+
export { useSocket, useSimulatorData, useProtocolUrl, useNotifications, useSystemMetrics, } from "./useSimulatorData";
|
|
14
|
+
// Socket.io event catalog — re-exported from shared-types for convenience
|
|
15
|
+
export { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useFlightEvents — TanStack Query + Socket.io hook for flight event log.
|
|
3
|
+
*
|
|
4
|
+
* Hydrates from GET /api/flight-events on mount, then subscribes to
|
|
5
|
+
* flight:event Socket.io events to append new events to the query cache.
|
|
6
|
+
* Provides comment mutations with optimistic updates.
|
|
7
|
+
*/
|
|
8
|
+
import type { FlightLogEvent, EventCategory } from "../shared-types/simulator";
|
|
9
|
+
export declare const flightEventsKeys: {
|
|
10
|
+
all: readonly ["flight-events"];
|
|
11
|
+
log: (flightId?: string | number | null) => readonly ["flight-events", "log", string | number];
|
|
12
|
+
};
|
|
13
|
+
type UseFlightEventsOptions = {
|
|
14
|
+
flightId?: string | number | null;
|
|
15
|
+
categories?: EventCategory[];
|
|
16
|
+
};
|
|
17
|
+
type UseFlightEventsReturn = {
|
|
18
|
+
events: FlightLogEvent[];
|
|
19
|
+
isTracking: boolean;
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
addComment: (message: string) => void;
|
|
22
|
+
editComment: (id: string, message: string) => void;
|
|
23
|
+
deleteComment: (id: string) => void;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Hook for the live flight event log using TanStack Query + Socket.io.
|
|
27
|
+
*
|
|
28
|
+
* On mount, fetches the current event log via REST.
|
|
29
|
+
* Then subscribes to flight:event Socket.io events and appends new events
|
|
30
|
+
* to the query cache as they arrive.
|
|
31
|
+
*
|
|
32
|
+
* Supports optional category filtering via the `categories` parameter.
|
|
33
|
+
* Comment mutations use optimistic updates and call the REST API.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useFlightEvents(options?: UseFlightEventsOptions): UseFlightEventsReturn;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=useFlightEvents.d.ts.map
|